linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] tools: Add new "test" taint to kernel-chktaint
@ 2022-08-24  4:19 Joe Fradley
  2022-08-24  4:41 ` David Gow
  2022-08-29 22:46 ` Brendan Higgins
  0 siblings, 2 replies; 6+ messages in thread
From: Joe Fradley @ 2022-08-24  4:19 UTC (permalink / raw)
  To: davidgow, brendanhiggins, skhan
  Cc: linux-kselftest, kunit-dev, corbet, Joe Fradley, kernel-team,
	linux-kernel

Commit c272612cb4a2 ("kunit: Taint the kernel when KUnit tests are run")
added a new taint flag for when in-kernel tests run. This commit adds
recognition of this new flag in kernel-chktaint.

Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Joe Fradley <joefradley@google.com>
---
Changes in v2:
- based off of kselftest/kunit branch
- Added David's Reviewed-by tag

 tools/debugging/kernel-chktaint | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/debugging/kernel-chktaint b/tools/debugging/kernel-chktaint
index f1af27ce9f20..279be06332be 100755
--- a/tools/debugging/kernel-chktaint
+++ b/tools/debugging/kernel-chktaint
@@ -187,6 +187,7 @@ else
 	echo " * auxiliary taint, defined for and used by distros (#16)"
 
 fi
+
 T=`expr $T / 2`
 if [ `expr $T % 2` -eq 0 ]; then
 	addout " "
@@ -195,6 +196,14 @@ else
 	echo " * kernel was built with the struct randomization plugin (#17)"
 fi
 
+T=`expr $T / 2`
+if [ `expr $T % 2` -eq 0 ]; then
+	addout " "
+else
+	addout "N"
+	echo " * an in-kernel test (such as a KUnit test) has been run (#18)"
+fi
+
 echo "For a more detailed explanation of the various taint flags see"
 echo " Documentation/admin-guide/tainted-kernels.rst in the Linux kernel sources"
 echo " or https://kernel.org/doc/html/latest/admin-guide/tainted-kernels.html"
-- 
2.37.1.595.g718a3a8f04-goog


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

* Re: [PATCH v2] tools: Add new "test" taint to kernel-chktaint
  2022-08-24  4:19 [PATCH v2] tools: Add new "test" taint to kernel-chktaint Joe Fradley
@ 2022-08-24  4:41 ` David Gow
  2022-09-01 18:57   ` Shuah Khan
  2022-08-29 22:46 ` Brendan Higgins
  1 sibling, 1 reply; 6+ messages in thread
From: David Gow @ 2022-08-24  4:41 UTC (permalink / raw)
  To: Joe Fradley
  Cc: Brendan Higgins, Shuah Khan, open list:KERNEL SELFTEST FRAMEWORK,
	KUnit Development, Jonathan Corbet, kernel-team,
	Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 1824 bytes --]

On Wed, Aug 24, 2022 at 12:19 PM Joe Fradley <joefradley@google.com> wrote:
>
> Commit c272612cb4a2 ("kunit: Taint the kernel when KUnit tests are run")
> added a new taint flag for when in-kernel tests run. This commit adds
> recognition of this new flag in kernel-chktaint.
>
> Reviewed-by: David Gow <davidgow@google.com>
> Signed-off-by: Joe Fradley <joefradley@google.com>
> ---
> Changes in v2:
> - based off of kselftest/kunit branch
> - Added David's Reviewed-by tag
>

This still looks good to me.

Unless anyone objects, I guess we'll take this through the KUnit
branch (which, after all, is where the taint was originally added).
I've added it to the list for 6.1, but it technically could be
considered a fix for 6.0 as well.

Cheers,
-- David

>  tools/debugging/kernel-chktaint | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/tools/debugging/kernel-chktaint b/tools/debugging/kernel-chktaint
> index f1af27ce9f20..279be06332be 100755
> --- a/tools/debugging/kernel-chktaint
> +++ b/tools/debugging/kernel-chktaint
> @@ -187,6 +187,7 @@ else
>         echo " * auxiliary taint, defined for and used by distros (#16)"
>
>  fi
> +
>  T=`expr $T / 2`
>  if [ `expr $T % 2` -eq 0 ]; then
>         addout " "
> @@ -195,6 +196,14 @@ else
>         echo " * kernel was built with the struct randomization plugin (#17)"
>  fi
>
> +T=`expr $T / 2`
> +if [ `expr $T % 2` -eq 0 ]; then
> +       addout " "
> +else
> +       addout "N"
> +       echo " * an in-kernel test (such as a KUnit test) has been run (#18)"
> +fi
> +
>  echo "For a more detailed explanation of the various taint flags see"
>  echo " Documentation/admin-guide/tainted-kernels.rst in the Linux kernel sources"
>  echo " or https://kernel.org/doc/html/latest/admin-guide/tainted-kernels.html"
> --
> 2.37.1.595.g718a3a8f04-goog
>

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4003 bytes --]

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

* Re: [PATCH v2] tools: Add new "test" taint to kernel-chktaint
  2022-08-24  4:19 [PATCH v2] tools: Add new "test" taint to kernel-chktaint Joe Fradley
  2022-08-24  4:41 ` David Gow
@ 2022-08-29 22:46 ` Brendan Higgins
  1 sibling, 0 replies; 6+ messages in thread
From: Brendan Higgins @ 2022-08-29 22:46 UTC (permalink / raw)
  To: Joe Fradley
  Cc: davidgow, skhan, linux-kselftest, kunit-dev, corbet, kernel-team,
	linux-kernel

On Tue, Aug 23, 2022 at 9:19 PM Joe Fradley <joefradley@google.com> wrote:
>
> Commit c272612cb4a2 ("kunit: Taint the kernel when KUnit tests are run")
> added a new taint flag for when in-kernel tests run. This commit adds
> recognition of this new flag in kernel-chktaint.
>
> Reviewed-by: David Gow <davidgow@google.com>
> Signed-off-by: Joe Fradley <joefradley@google.com>

Thanks!

Reviewed-by: Brendan Higgins <brendanhiggins@google.com>

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

* Re: [PATCH v2] tools: Add new "test" taint to kernel-chktaint
  2022-08-24  4:41 ` David Gow
@ 2022-09-01 18:57   ` Shuah Khan
  2022-09-01 23:44     ` Joe Fradley
  2022-09-01 23:53     ` David Gow
  0 siblings, 2 replies; 6+ messages in thread
From: Shuah Khan @ 2022-09-01 18:57 UTC (permalink / raw)
  To: David Gow, Joe Fradley
  Cc: Brendan Higgins, open list:KERNEL SELFTEST FRAMEWORK,
	KUnit Development, Jonathan Corbet, kernel-team,
	Linux Kernel Mailing List, Shuah Khan

On 8/23/22 22:41, David Gow wrote:
> On Wed, Aug 24, 2022 at 12:19 PM Joe Fradley <joefradley@google.com> wrote:
>>
>> Commit c272612cb4a2 ("kunit: Taint the kernel when KUnit tests are run")
>> added a new taint flag for when in-kernel tests run. This commit adds
>> recognition of this new flag in kernel-chktaint.
>>

What happens without this change? It isn't clear what this change is
fixing.

>> Reviewed-by: David Gow <davidgow@google.com>
>> Signed-off-by: Joe Fradley <joefradley@google.com>
>> ---
>> Changes in v2:
>> - based off of kselftest/kunit branch
>> - Added David's Reviewed-by tag
>>
> 
> This still looks good to me.
> 
> Unless anyone objects, I guess we'll take this through the KUnit
> branch (which, after all, is where the taint was originally added).
> I've added it to the list for 6.1, but it technically could be
> considered a fix for 6.0 as well.
> 

I can definitely take this for Linux 6.0 with additional information
on the problems seen without this change.

thanks,
-- Shuah


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

* Re: [PATCH v2] tools: Add new "test" taint to kernel-chktaint
  2022-09-01 18:57   ` Shuah Khan
@ 2022-09-01 23:44     ` Joe Fradley
  2022-09-01 23:53     ` David Gow
  1 sibling, 0 replies; 6+ messages in thread
From: Joe Fradley @ 2022-09-01 23:44 UTC (permalink / raw)
  To: Shuah Khan
  Cc: David Gow, Brendan Higgins, open list:KERNEL SELFTEST FRAMEWORK,
	KUnit Development, Jonathan Corbet, kernel-team,
	Linux Kernel Mailing List

On Thu, Sep 1, 2022 at 11:57 AM Shuah Khan <skhan@linuxfoundation.org> wrote:
>
> On 8/23/22 22:41, David Gow wrote:
> > On Wed, Aug 24, 2022 at 12:19 PM Joe Fradley <joefradley@google.com> wrote:
> >>
> >> Commit c272612cb4a2 ("kunit: Taint the kernel when KUnit tests are run")
> >> added a new taint flag for when in-kernel tests run. This commit adds
> >> recognition of this new flag in kernel-chktaint.
> >>
>
> What happens without this change? It isn't clear what this change is
> fixing.

Without this change the correct reason will not be displayed if the kernel
is tainted because of a test.

>
> >> Reviewed-by: David Gow <davidgow@google.com>
> >> Signed-off-by: Joe Fradley <joefradley@google.com>
> >> ---
> >> Changes in v2:
> >> - based off of kselftest/kunit branch
> >> - Added David's Reviewed-by tag
> >>
> >
> > This still looks good to me.
> >
> > Unless anyone objects, I guess we'll take this through the KUnit
> > branch (which, after all, is where the taint was originally added).
> > I've added it to the list for 6.1, but it technically could be
> > considered a fix for 6.0 as well.
> >
>
> I can definitely take this for Linux 6.0 with additional information
> on the problems seen without this change.

Great, thank you very much.

>
> thanks,
> -- Shuah
>

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

* Re: [PATCH v2] tools: Add new "test" taint to kernel-chktaint
  2022-09-01 18:57   ` Shuah Khan
  2022-09-01 23:44     ` Joe Fradley
@ 2022-09-01 23:53     ` David Gow
  1 sibling, 0 replies; 6+ messages in thread
From: David Gow @ 2022-09-01 23:53 UTC (permalink / raw)
  To: Shuah Khan
  Cc: Joe Fradley, Brendan Higgins,
	open list:KERNEL SELFTEST FRAMEWORK, KUnit Development,
	Jonathan Corbet, kernel-team, Linux Kernel Mailing List

On Fri, Sep 2, 2022 at 2:57 AM Shuah Khan <skhan@linuxfoundation.org> wrote:
>
> On 8/23/22 22:41, David Gow wrote:
> > On Wed, Aug 24, 2022 at 12:19 PM Joe Fradley <joefradley@google.com> wrote:
> >>
> >> Commit c272612cb4a2 ("kunit: Taint the kernel when KUnit tests are run")
> >> added a new taint flag for when in-kernel tests run. This commit adds
> >> recognition of this new flag in kernel-chktaint.
> >>
>
> What happens without this change? It isn't clear what this change is
> fixing.
>

Without this patch, running ./tools/debugging/kernel-chktaint against
a kernel tainted due to loading/running an in-kernel test (KUnit,
kselftest, etc) will not describe the reason for the taint:

Kernel is "tainted" for the following reasons:
For a more detailed explanation of the various taint flags see
Documentation/admin-guide/tainted-kernels.rst in the Linux kernel sources
or https://kernel.org/doc/html/latest/admin-guide/tainted-kernels.html
Raw taint value as int/string: 262144/'G                 '

With this change (which should've been introduced along with the new
taint flag), the 'N' taint is printed correctly, along with an
explanation:

Kernel is "tainted" for the following reasons:
* an in-kernel test (such as a KUnit test) has been run (#18)
For a more detailed explanation of the various taint flags see
Documentation/admin-guide/tainted-kernels.rst in the Linux kernel sources
or https://kernel.org/doc/html/latest/admin-guide/tainted-kernels.html
Raw taint value as int/string: 262144/'G                 N'

> >> Reviewed-by: David Gow <davidgow@google.com>
> >> Signed-off-by: Joe Fradley <joefradley@google.com>
> >> ---
> >> Changes in v2:
> >> - based off of kselftest/kunit branch
> >> - Added David's Reviewed-by tag
> >>
> >
> > This still looks good to me.
> >
> > Unless anyone objects, I guess we'll take this through the KUnit
> > branch (which, after all, is where the taint was originally added).
> > I've added it to the list for 6.1, but it technically could be
> > considered a fix for 6.0 as well.
> >
>
> I can definitely take this for Linux 6.0 with additional information
> on the problems seen without this change.
>

Yeah, basically the output from kernel-chktaint is incomplete (and, in
the case of the taint string, I'd argue wrong).

Not a disaster if this doesn't land for 6.0, but given 6.0 c an
generate the new taint flag, it makes sense to decode it correctly if
possible.

Cheers,
-- David

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

end of thread, other threads:[~2022-09-01 23:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-24  4:19 [PATCH v2] tools: Add new "test" taint to kernel-chktaint Joe Fradley
2022-08-24  4:41 ` David Gow
2022-09-01 18:57   ` Shuah Khan
2022-09-01 23:44     ` Joe Fradley
2022-09-01 23:53     ` David Gow
2022-08-29 22:46 ` Brendan Higgins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).