提交 182853f3 编写于 作者: M Miguel Ojeda 提交者: Zheng Zengkai

scripts: checkpatch: diagnose uses of `%pA` in the C side

maillist inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5J75G
CVE: NA

Reference: https://lore.kernel.org/rust-for-linux/CANiq72nDcJLSB3pLhkdqGdLitfmqqCUVVfkY5EjP9AcwVv9B4A@mail.gmail.com/T/#t

--------------------------------

The `%pA` format specifier is only intended to be used from Rust.

`checkpatch.pl` already gives a warning for invalid specificers:

    WARNING: Invalid vsprintf pointer extension '%pA'

With this change, we introduce an error message with further
explanation:

    ERROR: '%pA' is only intended to be used from Rust code
Suggested-by: NKees Cook <keescook@chromium.org>
Co-developed-by: NAlex Gaynor <alex.gaynor@gmail.com>
Signed-off-by: NAlex Gaynor <alex.gaynor@gmail.com>
Co-developed-by: NWedson Almeida Filho <wedsonaf@google.com>
Signed-off-by: NWedson Almeida Filho <wedsonaf@google.com>
Signed-off-by: NMiguel Ojeda <ojeda@kernel.org>
Signed-off-by: NWeilong Chen <chenweilong@huawei.com>
上级 02248b6d
......@@ -6312,6 +6312,10 @@ sub process {
my $stat_real = get_stat_real($linenr, $lc);
my $ext_type = "Invalid";
my $use = "";
if ($bad_specifier =~ /pA/) {
ERROR("VSPRINTF_RUST",
"'\%pA' is only intended to be used from Rust code\n" . "$here\n$stat_real\n");
}
if ($bad_specifier =~ /p[Ff]/) {
$use = " - use %pS instead";
$use =~ s/pS/ps/ if ($bad_specifier =~ /pf/);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册