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] [day] [month] [year] [list]
Message-ID: <LV3PR11MB876827543D56176BC8023124F50EA@LV3PR11MB8768.namprd11.prod.outlook.com>
Date: Wed, 10 Sep 2025 15:19:36 +0000
From: "Kumar, Kaushlendra" <kaushlendra.kumar@...el.com>
To: "paulmck@...nel.org" <paulmck@...nel.org>
CC: "dave@...olabs.net" <dave@...olabs.net>, "josh@...htriplett.org"
	<josh@...htriplett.org>, "frederic@...nel.org" <frederic@...nel.org>,
	"neeraj.upadhyay@...nel.org" <neeraj.upadhyay@...nel.org>,
	"rostedt@...dmis.org" <rostedt@...dmis.org>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] refperf: Remove redundant kfree() after
 torture_stop_kthread()

Hi Paul,

On Tue, Sep 09, 2025 at 11:11:48AM +0530, Paul E. McKenney <paulmck@...nel.org> wrote:
> On Tue, Sep 09, 2025 at 11:11:48AM +0530, Kaushlendra Kumar wrote:
> > Remove unnecessary kfree(main_task) call in ref_scale_cleanup() as
> > torture_stop_kthread() already handles the memory cleanup for the task 
> > structure internally.
> 
> Again, thank you for your interest in Linux-kernel RCU!
> 
> And you are right that the kfree(main_task) is redundant, especially given that the main_task pointer will be set to NULL in _torture_stop_kthread(), so that this kfree() is just a confusing no-op.
> 
> > The torture_stop_kthread() function is designed to stop the kernel 
> > thread and free the associated task structure as part of its cleanup 
> > process. The additional kfree(main_task) call after 
> > torture_stop_kthread() results in a double-free condition.
> 
> But this last sentence needs adjustment.  Because _torture_stop_kthread() NULLs the pointer, the second kfree() gets a NULL pointer, thus not doing a duplicate free, right?

You're absolutely correct! Thank you for the clarification.
.I have sent a v2 patch with the corrected commit message.

> For ease of debugging with kdgb, drgn, and other tools, it would also be good to set reader_tasks to NULL.  Please feel free to do that, either as part of this patch or as a separate patch.

I'll handle the reader_tasks = NULL assignment as a separate patch to
keep this one focused on removing the redundant kfree().

Thank you for the review!

Best regards,
Kaushlendra Kumar

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ