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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230919193516.GA20937@noisy.programming.kicks-ass.net>
Date:   Tue, 19 Sep 2023 21:35:16 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Linus Torvalds <torvalds@...ux-foundation.org>
Cc:     Bartosz Golaszewski <bartosz.golaszewski@...aro.org>,
        Alexey Dobriyan <adobriyan@...il.com>,
        linux-kernel@...r.kernel.org,
        Linus Walleij <linus.walleij@...aro.org>,
        akpm@...ux-foundation.org
Subject: Re: Buggy __free(kfree) usage pattern already in tree

On Tue, Sep 19, 2023 at 03:10:38PM +0200, Peter Zijlstra wrote:

> This isn't exactly nice..
> 
> I tried something like:
> 
> 	scoped_cond_guard (mutex_intr, return -EINTR, &task->signal->cred_guard_mutex) {
> 		...
> 	}
> 
> Which I can make work, but then I also tried to capture my other case:
> 
> 	scoped_cond_guard (rwsem_down_intr, if (task) return -EINTR,
> 			   task ? &task->signal->exec_guard_mutex : NULL)  {
> 
> 		...
> 	}
> 
> But I can't get that to work because of that extra if, the not case
> doesn't fall through and do the body.
> 
> Anyway, I'll poke more..


#define scoped_cond_guard(_name, _label, args...)		\
	for (CLASS(_name, scope)(args),				\
	     *done = NULL; !done; done = (void *)1)		\
		if (!__guard_ptr(_name)(&scope)) goto _label;	\
		else

Allows one to write:

	scoped_cond_guard (rwsem_down_intr, no_lock,
 			   task ? &task->signal->exec_guard_mutex : NULL)  {

		if (0) {
no_lock:
			if (task)
				return -EINTR;
		}

		... block that holds exec_guard_mutex if task ...
	}

Still not exactly pretty, but perhaps better than before...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ