lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJ-ks9=AFHN_ZBGXcEk4HiJNpJUB4tBU6Kyrxng_hXC_yM0VAQ@mail.gmail.com>
Date: Sat, 26 Oct 2024 08:26:57 -0400
From: Tamir Duberstein <tamird@...il.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Andy Whitcroft <apw@...onical.com>, Joe Perches <joe@...ches.com>, 
	Dwaipayan Ray <dwaipayanray1@...il.com>, Lukas Bulwahn <lukas.bulwahn@...il.com>, 
	Simon Horman <horms@...nel.org>, 
	Niklas Söderlund <niklas.soderlund+renesas@...natech.se>, 
	Philippe Schenker <philippe.schenker@...adex.com>, Louis Peens <louis.peens@...igine.com>, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] checkpatch: always parse orig_commit in fixes tag

On Fri, Oct 25, 2024 at 8:44 PM Andrew Morton <akpm@...ux-foundation.org> wrote:
>
> On Fri, 25 Oct 2024 19:43:19 -0400 Tamir Duberstein <tamird@...il.com> wrote:
>
> > Do not require the presence of `$balanced_parens` to get the commit SHA;
> > this allows a `Fixes: deadbeef` tag to get a correct suggestion rather
> > than a suggestion containing a reference to HEAD.
>
> Got it, thanks.  Below is what I ended up with:
>
>
> From: Tamir Duberstein <tamird@...il.com>
> Subject: checkpatch: always parse orig_commit in fixes tag
> Date: Fri, 25 Oct 2024 19:43:19 -0400
>
> Do not require the presence of `$balanced_parens` to get the commit SHA;
> this allows a `Fixes: deadbeef` tag to get a correct suggestion rather
> than a suggestion containing a reference to HEAD.
>
> Given this patch:
>
> : From: Tamir Duberstein <tamird@...il.com>
> : Subject: Test patch
> : Date: Fri, 25 Oct 2024 19:30:51 -0400
> :
> : This is a test patch.
> :
> : Fixes: bd17e036b495
> : Signed-off-by: Tamir Duberstein <tamird@...il.com>
> : --- /dev/null
> : +++ b/new-file
> : @@ -0,0 +1 @@
> : +Test.
>
>
> Before:
>
> WARNING: Please use correct Fixes: style 'Fixes: <12 chars of sha1> ("<title line>")' - ie: 'Fixes: c10a7d25e68f ("Test patch")'
>
> After:
>
> WARNING: Please use correct Fixes: style 'Fixes: <12 chars of sha1> ("<title line>")' - ie: 'Fixes: bd17e036b495 ("checkpatch: warn for non-standard fixes tag style")'
>
>
>
> The prior behavior incorrectly suggested the patch's own SHA and title
> line rather than the referenced commit's.  This fixes that.
>
> Ironically this:
>
> Fixes: bd17e036b495 ("checkpatch: warn for non-standard fixes tag style")
> Signed-off-by: Tamir Duberstein <tamird@...il.com>
> Cc: Andy Whitcroft <apw@...onical.com>
> Cc: Dwaipayan Ray <dwaipayanray1@...il.com>
> Cc: Joe Perches <joe@...ches.com>
> Cc: Louis Peens <louis.peens@...igine.com>
> Cc: Lukas Bulwahn <lukas.bulwahn@...il.com>
> Cc: Niklas Söderlund <niklas.soderlund+renesas@...natech.se>
> Cc: Philippe Schenker <philippe.schenker@...adex.com>
> Cc: Simon Horman <horms@...nel.org>
> Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
> ---
>
>  scripts/checkpatch.pl |   37 ++++++++++++++++---------------------
>  1 file changed, 16 insertions(+), 21 deletions(-)
>
> --- a/scripts/checkpatch.pl~checkpatch-always-parse-orig_commit-in-fixes-tag
> +++ a/scripts/checkpatch.pl
> @@ -3209,36 +3209,31 @@ sub process {
>
>  # Check Fixes: styles is correct
>                 if (!$in_header_lines &&
> -                   $line =~ /^\s*fixes:?\s*(?:commit\s*)?[0-9a-f]{5,}\b/i) {
> -                       my $orig_commit = "";
> -                       my $id = "0123456789ab";
> -                       my $title = "commit title";
> -                       my $tag_case = 1;
> -                       my $tag_space = 1;
> -                       my $id_length = 1;
> -                       my $id_case = 1;
> +                   $line =~ /^\s*(fixes:?)\s*(?:commit\s*)?([0-9a-f]{5,40})(?:\s*($balanced_parens))?/i) {
> +                       my $tag = $1;
> +                       my $orig_commit = $2;
> +                       my $title;
>                         my $title_has_quotes = 0;
>                         $fixes_tag = 1;
> -
> -                       if ($line =~ /(\s*fixes:?)\s+([0-9a-f]{5,})\s+($balanced_parens)/i) {
> -                               my $tag = $1;
> -                               $orig_commit = $2;
> -                               $title = $3;
> -
> -                               $tag_case = 0 if $tag eq "Fixes:";
> -                               $tag_space = 0 if ($line =~ /^fixes:? [0-9a-f]{5,} ($balanced_parens)/i);
> -
> -                               $id_length = 0 if ($orig_commit =~ /^[0-9a-f]{12}$/i);
> -                               $id_case = 0 if ($orig_commit !~ /[A-F]/);
> -
> +                       if (defined $3) {
>                                 # Always strip leading/trailing parens then double quotes if existing
> -                               $title = substr($title, 1, -1);
> +                               $title = substr($3, 1, -1);
>                                 if ($title =~ /^".*"$/) {
>                                         $title = substr($title, 1, -1);
>                                         $title_has_quotes = 1;
>                                 }
> +                       } else {
> +                               $title = "commit title"
>                         }
>
> +
> +                       my $tag_case = not ($tag eq "Fixes:");
> +                       my $tag_space = not ($line =~ /^fixes:? [0-9a-f]{5,40} ($balanced_parens)/i);
> +
> +                       my $id_length = not ($orig_commit =~ /^[0-9a-f]{12}$/i);
> +                       my $id_case = not ($orig_commit !~ /[A-F]/);
> +
> +                       my $id = "0123456789ab";
>                         my ($cid, $ctitle) = git_commit_info($orig_commit, $id,
>                                                              $title);
>
> _
>

Thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ