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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250623075943-44fdf86a-adcd-478c-bf78-906145678adb@linutronix.de>
Date: Mon, 23 Jun 2025 08:03:29 +0200
From: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
To: Arnd Bergmann <arnd@...nel.org>
Cc: Petr Mladek <pmladek@...e.com>, 
	John Ogness <john.ogness@...utronix.de>, Arnd Bergmann <arnd@...db.de>, 
	Steven Rostedt <rostedt@...dmis.org>, Sergey Senozhatsky <senozhatsky@...omium.org>, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] printk: kunit: support offstack cpumask

On Fri, Jun 20, 2025 at 09:25:20PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@...db.de>
> 
> For large values of CONFIG_NR_CPUS, the newly added kunit test fails
> to build:
> 
> kernel/printk/printk_ringbuffer_kunit_test.c: In function 'test_readerwriter':
> kernel/printk/printk_ringbuffer_kunit_test.c:279:1: error: the frame size of 1432 bytes is larger than 1280 bytes [-Werror=frame-larger-than=]
> 
> Change this to use cpumask_var_t and allocate it dynamically when
> CONFIG_CPUMASK_OFFSTACK is set.
> 
> Fixes: 5ea2bcdfbf46 ("printk: ringbuffer: Add KUnit test")
> Signed-off-by: Arnd Bergmann <arnd@...db.de>
> ---
>  kernel/printk/printk_ringbuffer_kunit_test.c | 17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/kernel/printk/printk_ringbuffer_kunit_test.c b/kernel/printk/printk_ringbuffer_kunit_test.c
> index 4081ae051d8e..9f79bc91246e 100644
> --- a/kernel/printk/printk_ringbuffer_kunit_test.c
> +++ b/kernel/printk/printk_ringbuffer_kunit_test.c
> @@ -227,9 +227,12 @@ static void test_readerwriter(struct kunit *test)
>  	struct prbtest_thread_data *thread_data;
>  	struct prbtest_data *test_data;
>  	struct task_struct *thread;
> -	cpumask_t test_cpus;
> +	cpumask_var_t test_cpus;
>  	int cpu, reader_cpu;
>  
> +	if (alloc_cpumask_var(&test_cpus, GFP_KERNEL))
> +		return;

IMO this shouldn't fail silently and instead should do:

KUNIT_FAIL_AND_ABORT(test, "Unable to allocate cpumask");

> +
>  	cpus_read_lock();
>  	/*
>  	 * Failure of KUNIT_ASSERT() kills the current task
> @@ -237,15 +240,15 @@ static void test_readerwriter(struct kunit *test)
>  	 * Instead use a snapshot of the online CPUs.
>  	 * If they change during test execution it is unfortunate but not a grave error.
>  	 */
> -	cpumask_copy(&test_cpus, cpu_online_mask);
> +	cpumask_copy(test_cpus, cpu_online_mask);
>  	cpus_read_unlock();
>  
>  	/* One CPU is for the reader, all others are writers */
> -	reader_cpu = cpumask_first(&test_cpus);
> -	if (cpumask_weight(&test_cpus) == 1)
> +	reader_cpu = cpumask_first(test_cpus);
> +	if (cpumask_weight(test_cpus) == 1)
>  		kunit_warn(test, "more than one CPU is recommended");
>  	else
> -		cpumask_clear_cpu(reader_cpu, &test_cpus);
> +		cpumask_clear_cpu(reader_cpu, test_cpus);
>  
>  	/* KUnit test can get restarted more times. */
>  	prbtest_prb_reinit(&test_rb);
> @@ -258,7 +261,7 @@ static void test_readerwriter(struct kunit *test)
>  
>  	kunit_info(test, "running for %lu ms\n", runtime_ms);
>  
> -	for_each_cpu(cpu, &test_cpus) {
> +	for_each_cpu(cpu, test_cpus) {
>  		thread_data = kunit_kmalloc(test, sizeof(*thread_data), GFP_KERNEL);
>  		KUNIT_ASSERT_NOT_NULL(test, thread_data);
>  		thread_data->test_data = test_data;
> @@ -276,6 +279,8 @@ static void test_readerwriter(struct kunit *test)
>  	prbtest_reader(test_data, runtime_ms);
>  
>  	kunit_info(test, "completed test\n");
> +
> +	free_cpumask_var(test_cpus);
>  }
>  
>  static struct kunit_case prb_test_cases[] = {
> -- 
> 2.39.5
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ