public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] checkpatch: recognise NOKPROBE_SYMBOL for blank line detection after function/struct/union/enum
@ 2023-01-20 11:46 Christian Borntraeger
  2023-01-20 16:10 ` Joe Perches
  2023-08-18 14:36 ` Heiko Carstens
  0 siblings, 2 replies; 4+ messages in thread
From: Christian Borntraeger @ 2023-01-20 11:46 UTC (permalink / raw)
  To: Andy Whitcroft, Joe Perches; +Cc: Dwaipayan Ray, Lukas Bulwahn, linux-kernel

NOKPROBE_SYMBOL should be treated like EXPORT_SYMBOL to avoid
false positives.

Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
---
 scripts/checkpatch.pl | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 78cc595b98ce..037acbcee0e1 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3995,6 +3995,7 @@ sub process {
 		    $line =~ /^\+/ &&
 		    !($line =~ /^\+\s*$/ ||
 		      $line =~ /^\+\s*(?:EXPORT_SYMBOL|early_param)/ ||
+		      $line =~ /^\+\s*NOKPROBE_SYMBOL/ ||
 		      $line =~ /^\+\s*MODULE_/i ||
 		      $line =~ /^\+\s*\#\s*(?:end|elif|else)/ ||
 		      $line =~ /^\+[a-z_]*init/ ||
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] checkpatch: recognise NOKPROBE_SYMBOL for blank line detection after function/struct/union/enum
  2023-01-20 11:46 [PATCH 1/1] checkpatch: recognise NOKPROBE_SYMBOL for blank line detection after function/struct/union/enum Christian Borntraeger
@ 2023-01-20 16:10 ` Joe Perches
  2023-01-24 12:16   ` Christian Borntraeger
  2023-08-18 14:36 ` Heiko Carstens
  1 sibling, 1 reply; 4+ messages in thread
From: Joe Perches @ 2023-01-20 16:10 UTC (permalink / raw)
  To: Christian Borntraeger, Andy Whitcroft
  Cc: Dwaipayan Ray, Lukas Bulwahn, linux-kernel, kernel-janitors

On Fri, 2023-01-20 at 12:46 +0100, Christian Borntraeger wrote:
> NOKPROBE_SYMBOL should be treated like EXPORT_SYMBOL to avoid
> false positives.
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -3995,6 +3995,7 @@ sub process {
>  		    $line =~ /^\+/ &&
>  		    !($line =~ /^\+\s*$/ ||
>  		      $line =~ /^\+\s*(?:EXPORT_SYMBOL|early_param)/ ||
> +		      $line =~ /^\+\s*NOKPROBE_SYMBOL/ ||
>  		      $line =~ /^\+\s*MODULE_/i ||
>  		      $line =~ /^\+\s*\#\s*(?:end|elif|else)/ ||
>  		      $line =~ /^\+[a-z_]*init/ ||

$ git grep -P -w -oh '\w*NOKPROBE_SYMBOL\w*' | sort | uniq -c
     60 _ASM_NOKPROBE_SYMBOL
      2 __NOKPROBE_SYMBOL
    304 NOKPROBE_SYMBOL

Any issue with these other variants? (it doesn't seem so)

btw: __NOKPROBE_SYMBOL has a ; at the end of its definition.

include/asm-generic/kprobes.h:# define __NOKPROBE_SYMBOL(fname)                         \
include/asm-generic/kprobes.h-static unsigned long __used                                       \
include/asm-generic/kprobes.h-  __section("_kprobe_blacklist")                          \
include/asm-generic/kprobes.h-  _kbl_addr_##fname = (unsigned long)fname;

And so there are extra ; uses after ever use of NOKPROBE_SYMBOL(foo);

$ git grep -w NOKPROBE_SYMBOL | grep ';' | wc -l
285

There are only 10 uses of NOKPROBE_SYMBOL(foo) without a semicolon

$ git grep -P '\bNOKPROBE_SYMBOL\s*\(\s*\w+\s*\)\s*(?:[^\;]|$)'
arch/arm/kernel/traps.c:NOKPROBE_SYMBOL(do_undefinstr)
arch/arm/probes/kprobes/opt-arm.c:NOKPROBE_SYMBOL(optimized_callback)
arch/arm64/kernel/kgdb.c:NOKPROBE_SYMBOL(kgdb_brk_fn)
arch/powerpc/mm/cacheflush.c:NOKPROBE_SYMBOL(flush_dcache_icache_phys)
arch/powerpc/platforms/82xx/pq2.c:NOKPROBE_SYMBOL(pq2_restart)
include/asm-generic/kprobes.h:# define NOKPROBE_SYMBOL(fname)   __NOKPROBE_SYMBOL(fname)
include/asm-generic/kprobes.h:# define NOKPROBE_SYMBOL(fname)
kernel/fail_function.c:NOKPROBE_SYMBOL(fei_kprobe_handler)
kernel/kprobes.c:NOKPROBE_SYMBOL(__kretprobe_trampoline_handler)
kernel/trace/trace_eprobe.c:NOKPROBE_SYMBOL(process_fetch_insn)
kernel/trace/trace_kprobe.c:NOKPROBE_SYMBOL(process_fetch_insn)
kernel/trace/trace_uprobe.c:NOKPROBE_SYMBOL(process_fetch_insn)

The actual uses with NOKPROBE_SYMBOL(foo) should likely have semicolons added
and the __NOKPROBE_SYMBOL definition should have the semicolon removed.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] checkpatch: recognise NOKPROBE_SYMBOL for blank line detection after function/struct/union/enum
  2023-01-20 16:10 ` Joe Perches
@ 2023-01-24 12:16   ` Christian Borntraeger
  0 siblings, 0 replies; 4+ messages in thread
From: Christian Borntraeger @ 2023-01-24 12:16 UTC (permalink / raw)
  To: Joe Perches, Andy Whitcroft
  Cc: Dwaipayan Ray, Lukas Bulwahn, linux-kernel, kernel-janitors



Am 20.01.23 um 17:10 schrieb Joe Perches:
> On Fri, 2023-01-20 at 12:46 +0100, Christian Borntraeger wrote:
>> NOKPROBE_SYMBOL should be treated like EXPORT_SYMBOL to avoid
>> false positives.
> []
>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []
>> @@ -3995,6 +3995,7 @@ sub process {
>>   		    $line =~ /^\+/ &&
>>   		    !($line =~ /^\+\s*$/ ||
>>   		      $line =~ /^\+\s*(?:EXPORT_SYMBOL|early_param)/ ||
>> +		      $line =~ /^\+\s*NOKPROBE_SYMBOL/ ||
>>   		      $line =~ /^\+\s*MODULE_/i ||
>>   		      $line =~ /^\+\s*\#\s*(?:end|elif|else)/ ||
>>   		      $line =~ /^\+[a-z_]*init/ ||
> 
> $ git grep -P -w -oh '\w*NOKPROBE_SYMBOL\w*' | sort | uniq -c
>       60 _ASM_NOKPROBE_SYMBOL
>        2 __NOKPROBE_SYMBOL
>      304 NOKPROBE_SYMBOL
> 
> Any issue with these other variants? (it doesn't seem so)
7
The other variants should not matter.
> 
> btw: __NOKPROBE_SYMBOL has a ; at the end of its definition.
> 
> include/asm-generic/kprobes.h:# define __NOKPROBE_SYMBOL(fname)                         \
> include/asm-generic/kprobes.h-static unsigned long __used                                       \
> include/asm-generic/kprobes.h-  __section("_kprobe_blacklist")                          \
> include/asm-generic/kprobes.h-  _kbl_addr_##fname = (unsigned long)fname;
> 
> And so there are extra ; uses after ever use of NOKPROBE_SYMBOL(foo);
> 
> $ git grep -w NOKPROBE_SYMBOL | grep ';' | wc -l
> 285
> 
> There are only 10 uses of NOKPROBE_SYMBOL(foo) without a semicolon
> 
> $ git grep -P '\bNOKPROBE_SYMBOL\s*\(\s*\w+\s*\)\s*(?:[^\;]|$)'
> arch/arm/kernel/traps.c:NOKPROBE_SYMBOL(do_undefinstr)
> arch/arm/probes/kprobes/opt-arm.c:NOKPROBE_SYMBOL(optimized_callback)
> arch/arm64/kernel/kgdb.c:NOKPROBE_SYMBOL(kgdb_brk_fn)
> arch/powerpc/mm/cacheflush.c:NOKPROBE_SYMBOL(flush_dcache_icache_phys)
> arch/powerpc/platforms/82xx/pq2.c:NOKPROBE_SYMBOL(pq2_restart)
> include/asm-generic/kprobes.h:# define NOKPROBE_SYMBOL(fname)   __NOKPROBE_SYMBOL(fname)
> include/asm-generic/kprobes.h:# define NOKPROBE_SYMBOL(fname)
> kernel/fail_function.c:NOKPROBE_SYMBOL(fei_kprobe_handler)
> kernel/kprobes.c:NOKPROBE_SYMBOL(__kretprobe_trampoline_handler)
> kernel/trace/trace_eprobe.c:NOKPROBE_SYMBOL(process_fetch_insn)
> kernel/trace/trace_kprobe.c:NOKPROBE_SYMBOL(process_fetch_insn)
> kernel/trace/trace_uprobe.c:NOKPROBE_SYMBOL(process_fetch_insn)
> 
> The actual uses with NOKPROBE_SYMBOL(foo) should likely have semicolons added
> and the __NOKPROBE_SYMBOL definition should have the semicolon removed.

That would be an independent check I guess.
  

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] checkpatch: recognise NOKPROBE_SYMBOL for blank line detection after function/struct/union/enum
  2023-01-20 11:46 [PATCH 1/1] checkpatch: recognise NOKPROBE_SYMBOL for blank line detection after function/struct/union/enum Christian Borntraeger
  2023-01-20 16:10 ` Joe Perches
@ 2023-08-18 14:36 ` Heiko Carstens
  1 sibling, 0 replies; 4+ messages in thread
From: Heiko Carstens @ 2023-08-18 14:36 UTC (permalink / raw)
  To: Christian Borntraeger, Joe Perches
  Cc: Andy Whitcroft, Dwaipayan Ray, Lukas Bulwahn, linux-kernel,
	Andrew Morton

On Fri, Jan 20, 2023 at 12:46:49PM +0100, Christian Borntraeger wrote:
> NOKPROBE_SYMBOL should be treated like EXPORT_SYMBOL to avoid
> false positives.
> 
> Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
> ---
>  scripts/checkpatch.pl | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 78cc595b98ce..037acbcee0e1 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3995,6 +3995,7 @@ sub process {
>  		    $line =~ /^\+/ &&
>  		    !($line =~ /^\+\s*$/ ||
>  		      $line =~ /^\+\s*(?:EXPORT_SYMBOL|early_param)/ ||
> +		      $line =~ /^\+\s*NOKPROBE_SYMBOL/ ||
>  		      $line =~ /^\+\s*MODULE_/i ||
>  		      $line =~ /^\+\s*\#\s*(?:end|elif|else)/ ||
>  		      $line =~ /^\+[a-z_]*init/ ||

Seven months later... Joe, is there actually anything that prevents this
from being merged?
You were the only one who replied back then:
https://lore.kernel.org/lkml/20230120114649.117018-1-borntraeger@linux.ibm.com/

And it is kind of not obvious what the result was.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-08-18 14:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-20 11:46 [PATCH 1/1] checkpatch: recognise NOKPROBE_SYMBOL for blank line detection after function/struct/union/enum Christian Borntraeger
2023-01-20 16:10 ` Joe Perches
2023-01-24 12:16   ` Christian Borntraeger
2023-08-18 14:36 ` Heiko Carstens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox