[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ryrgmipmo3h4724jszbvd2oilm5tavvjuojyrw2sz2ec6nmt7m@ijiguteitm67>
Date: Thu, 16 Jan 2025 11:01:26 +0100
From: Joel Granados <joel.granados@...nel.org>
To: John Sperbeck <jsperbeck@...gle.com>
Cc: Kees Cook <kees@...nel.org>, Wen Yang <wen.yang@...ux.dev>,
linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH v3] sysctl: expose sysctl_check_table for unit testing
and use it
On Sun, Jan 12, 2025 at 11:00:01PM -0800, John Sperbeck wrote:
> In commit b5ffbd139688 ("sysctl: move the extra1/2 boundary check
> of u8 to sysctl_check_table_array"), a kunit test was added that
> registers a sysctl table. If the test is run as a module, then a
> lingering reference to the module is left behind, and a 'sysctl -a'
> leads to a panic.
>
> This can be reproduced with these kernel config settings:
>
> CONFIG_KUNIT=y
> CONFIG_SYSCTL_KUNIT_TEST=m
>
> Then run these commands:
>
> modprobe sysctl-test
> rmmod sysctl-test
> sysctl -a
>
> The panic varies but generally looks something like this:
>
> BUG: unable to handle page fault for address: ffffa4571c0c7db4
> #PF: supervisor read access in kernel mode
> #PF: error_code(0x0000) - not-present page
> PGD 100000067 P4D 100000067 PUD 100351067 PMD 114f5e067 PTE 0
> Oops: Oops: 0000 [#1] SMP NOPTI
> ... ... ...
> RIP: 0010:proc_sys_readdir+0x166/0x2c0
> ... ... ...
> Call Trace:
> <TASK>
> iterate_dir+0x6e/0x140
> __se_sys_getdents+0x6e/0x100
> do_syscall_64+0x70/0x150
> entry_SYSCALL_64_after_hwframe+0x76/0x7e
>
> Instead of fully registering a sysctl table, expose the underlying
> checking function and use it in the unit test.
>
> Fixes: b5ffbd139688 ("sysctl: move the extra1/2 boundary check of u8 to sysctl_check_table_array")
> Signed-off-by: John Sperbeck <jsperbeck@...gle.com>
You have received a error from the bot. please address it to move
forward.
Best
> ---
> fs/proc/proc_sysctl.c | 22 +++++++++++++++++-----
> include/linux/sysctl.h | 8 ++++++++
> kernel/sysctl-test.c | 9 ++++++---
> 3 files changed, 31 insertions(+), 8 deletions(-)
>
...
>
> static struct kunit_case sysctl_test_cases[] = {
> --
> 2.47.1.613.gc27f4b7a9f-goog
>
--
Joel Granados
Powered by blists - more mailing lists