Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

checkpatch: check for missing Fixes tags

This check looks for common words that probably indicate a patch
is a fix. For now the regex is:

(?:(?:BUG: K.|UB)SAN: |Call Trace:|stable\@|syzkaller)/)

Why are stable patches encouraged to have a fixes tag? Some people mark
their stable patches as "# 5.10" etc. This is useful but a Fixes tag is
still a good idea. For example, the Fixes tag helps in review. It
helps people to not cherry-pick buggy patches without also
cherry-picking the fix.

Also if a bug affects the 5.7 kernel some people will round it up to
5.10+ because 5.7 is not supported on kernel.org. It's possible the Bad
Binder bug was caused by this sort of gap where companies outside of
kernel.org are supporting different kernels from kernel.org.

Should it be counted as a Fix when a patch just silences harmless
WARN_ON() stack trace. Yes. Definitely.

Is silencing compiler warnings a fix? It seems unfair to the original
authors, but we use -Werror now, and warnings break the build so let's
just add Fixes tags. I tell people that silencing static checker
warnings is not a fix but the rules on this vary by subsystem.

Is fixing a minor LTP issue (Linux Test Project) a fix? Probably? It's
hard to know what to do if the LTP test has technically always been
broken.

One clear false positive from this check is when someone updated their
debug output and included before and after Call Traces. Or when crashes
are introduced deliberately for testing. In those cases, you should
just ignore checkpatch.

Link: https://lkml.kernel.org/r/ZmhUgZBKeF_8ixA6@moroto
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Cc: Andy Whitcroft <apw@canonical.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Dwaipayan Ray <dwaipayanray1@gmail.com>
Cc: Joe Perches <joe@perches.com>
Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Cc: Sasha Levin <sashal@kernel.org>
Cc: Thorsten Leemhuis <linux@leemhuis.info>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Dan Carpenter and committed by
Andrew Morton
d5d6281a d6bb3951

+24
+24
scripts/checkpatch.pl
··· 28 28 my %verbose_emitted = (); 29 29 my $tree = 1; 30 30 my $chk_signoff = 1; 31 + my $chk_fixes_tag = 1; 31 32 my $chk_patch = 1; 32 33 my $tst_only; 33 34 my $emacs = 0; ··· 89 88 -v, --verbose verbose mode 90 89 --no-tree run without a kernel tree 91 90 --no-signoff do not check for 'Signed-off-by' line 91 + --no-fixes-tag do not check for 'Fixes:' tag 92 92 --patch treat FILE as patchfile (default) 93 93 --emacs emacs compile window format 94 94 --terse one line per report ··· 297 295 'v|verbose!' => \$verbose, 298 296 'tree!' => \$tree, 299 297 'signoff!' => \$chk_signoff, 298 + 'fixes-tag!' => \$chk_fixes_tag, 300 299 'patch!' => \$chk_patch, 301 300 'emacs!' => \$emacs, 302 301 'terse!' => \$terse, ··· 1260 1257 } 1261 1258 1262 1259 $chk_signoff = 0 if ($file); 1260 + $chk_fixes_tag = 0 if ($file); 1263 1261 1264 1262 my @rawlines = (); 1265 1263 my @lines = (); ··· 2640 2636 2641 2637 our $clean = 1; 2642 2638 my $signoff = 0; 2639 + my $fixes_tag = 0; 2640 + my $is_revert = 0; 2641 + my $needs_fixes_tag = ""; 2643 2642 my $author = ''; 2644 2643 my $authorsignoff = 0; 2645 2644 my $author_sob = ''; ··· 3196 3189 } 3197 3190 } 3198 3191 3192 + # These indicate a bug fix 3193 + if (!$in_header_lines && !$is_patch && 3194 + $line =~ /^This reverts commit/) { 3195 + $is_revert = 1; 3196 + } 3197 + 3198 + if (!$in_header_lines && !$is_patch && 3199 + $line =~ /((?:(?:BUG: K.|UB)SAN: |Call Trace:|stable\@|syzkaller))/) { 3200 + $needs_fixes_tag = $1; 3201 + } 3199 3202 3200 3203 # Check Fixes: styles is correct 3201 3204 if (!$in_header_lines && ··· 3218 3201 my $id_length = 1; 3219 3202 my $id_case = 1; 3220 3203 my $title_has_quotes = 0; 3204 + $fixes_tag = 1; 3221 3205 3222 3206 if ($line =~ /(\s*fixes:?)\s+([0-9a-f]{5,})\s+($balanced_parens)/i) { 3223 3207 my $tag = $1; ··· 7714 7696 if (!$is_patch && $filename !~ /cover-letter\.patch$/) { 7715 7697 ERROR("NOT_UNIFIED_DIFF", 7716 7698 "Does not appear to be a unified-diff format patch\n"); 7699 + } 7700 + if ($is_patch && $has_commit_log && $chk_fixes_tag) { 7701 + if ($needs_fixes_tag ne "" && !$is_revert && !$fixes_tag) { 7702 + WARN("MISSING_FIXES_TAG", 7703 + "The commit message has '$needs_fixes_tag', perhaps it also needs a 'Fixes:' tag?\n"); 7704 + } 7717 7705 } 7718 7706 if ($is_patch && $has_commit_log && $chk_signoff) { 7719 7707 if ($signoff == 0) {