mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bradley Morgan <brads@mainlining.org>
To: Joel Granados <joel.granados@kernel.org>
Cc: Zhan Xusheng <zhanxusheng1024@gmail.com>,
	Zhan Xusheng <zhanxusheng@xiaomi.com>,
	Kees Cook <kees@kernel.org>, Shuah Khan <shuah@kernel.org>,
	Kuniyuki Iwashima <kuniyu@google.com>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH 2/2] selftests: sysctl: Check the sign of a negative jiffies read
Date: Fri, 25 Sep 2026 16:03:44 +0100	[thread overview]
Message-ID: <E0D7623B-F209-42AA-BED8-39755CE4BCF5@mainlining.org> (raw)
In-Reply-To: <4wuqtjbpekdnpf6gn7pjc32bed2ln44unp2dd2zatiju4zeq5e@efqhttn3pfyc>

On 25 September 2026 12:45:27 BST, Joel Granados <joel.granados@kernel.org>
wrote:
>On Wed, Sep 23, 2026 at 04:53:54PM +0100, Bradley Morgan wrote:
>> On 23 September 2026 15:49:37 BST, Zhan Xusheng
><zhanxusheng1024@gmail.com>
>> wrote:
>> >proc_int_k2u_conv_kop() returns the sign through *negp and the
>magnitude
>> >through *u_ptr.  For a negative value it used to convert the
>> >sign-extended int and negate afterwards, so the magnitude came back as
>a
>> >wrapped 64-bit number.  Nothing noticed, because no test wrote a
>> >negative value to a jiffies sysctl.
>> >
>> >Write one to each of the three int converters and require the value to
>> >read back unchanged.  Each value is chosen to convert exactly at every
>> >CONFIG_HZ, so the test does not depend on it:
>> >
>> >	converter		write	jiffies stored	reads back
>> >	jiffies			-1	-HZ		-1
>> >	ms_jiffies		-1000	-HZ		-1000
>> >	userhz_jiffies		-100	-HZ		-100
>> >
>> >On a kernel without the fix, at CONFIG_HZ=250:
>> >
>> >  # int_jiffies: got '-18372957097414713411', want '-1'
>> >  # int_ms_jiffies: got '-18446744069414585320', want '-1000'
>> >  # int_userhz_jiffies: got '-18446742229035144346', want '-100'
>> >  not ok 1 test_int_jiffies_negative
>> >
>> >(paths shortened; the runner prints them under
>> >/proc/sys/debug/test_sysctl)
>> >
>> >Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
>> >---
>> > tools/testing/selftests/sysctl/sysctl.sh | 23 +++++++++++++++++++++++
>> > 1 file changed, 23 insertions(+)
>> >
>> >diff --git a/tools/testing/selftests/sysctl/sysctl.sh
>b/tools/testing/selftests/sysctl/sysctl.sh
>> >index ceb5cfa0cfd4..ad1ee0fccd7c 100755
>> >--- a/tools/testing/selftests/sysctl/sysctl.sh
>> >+++ b/tools/testing/selftests/sysctl/sysctl.sh
>> >@@ -328,6 +328,29 @@ test_int_plain()
>> > 	assert_int_range "$t" "$baseline" || RET=$KSFT_FAIL
>> > }
>> > 
>> >+# The jiffies converters report the sign separately from the
>magnitude, so a
>> >+# negative value must survive the round trip through the converter. 
>Each
>> >+# value below is chosen to convert exactly at every CONFIG_HZ.
>> 
>> I have a feeling this could be decreased, but I don't care.
>
>If you don't care, don't comment.
>> 

its because I think it could, but it isn't a complete patch breaker.

>> Reviewed-by: Bradley Morgan <brads@mainlining.org>
>> 
>> 
>> Tested on PowerPC: 
>> 
>> Tested-by: Bradley Morgan <brads@mainlining.org> # POWER10
>
>Please don't suffix anything after the tag as b4 picks it up.
>
>Best
>

--- Thanks!
"I'm not a very positive person" - Linus torvalds

  reply	other threads:[~2026-09-25 15:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23 14:49 [PATCH 0/2] sysctl: Cover the jiffies converters in the selftests Zhan Xusheng
2026-09-23 14:49 ` [PATCH 1/2] sysctl: Add jiffies converter entries to the test module Zhan Xusheng
2026-09-23 15:53   ` Bradley Morgan
2026-09-23 14:49 ` [PATCH 2/2] selftests: sysctl: Check the sign of a negative jiffies read Zhan Xusheng
2026-09-23 15:53   ` Bradley Morgan
2026-09-25 11:45     ` Joel Granados
2026-09-25 15:03       ` Bradley Morgan [this message]
2026-09-25 11:41 ` [PATCH 0/2] sysctl: Cover the jiffies converters in the selftests Joel Granados

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E0D7623B-F209-42AA-BED8-39755CE4BCF5@mainlining.org \
    --to=brads@mainlining.org \
    --cc=joel.granados@kernel.org \
    --cc=kees@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=zhanxusheng1024@gmail.com \
    --cc=zhanxusheng@xiaomi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®