Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 28 Mar 2019 15:26:19 +0100
From: Oleg Nesterov <>
To: Joel Fernandes <>
Cc: Jann Horn <>, Kees Cook <>,
	"Eric W. Biederman" <>,
	LKML <>,
	Android Kernel Team <>,
	Kernel Hardening <>,
	Andrew Morton <>,
	Matthew Wilcox <>,
	Michal Hocko <>,
	"Reshetova, Elena" <>
Subject: Re: [PATCH] Convert struct pid count to refcount_t

On 03/27, Joel Fernandes wrote:
> Also, based on Kees comment, I think it appears to me that get_pid and
> put_pid can race in this way in the original code right?
> get_pid			put_pid
> 			atomic_dec_and_test returns 1
> atomic_inc
> 			kfree
> deref pid /* boom */
> -------------------------------------------------
> I think get_pid needs to call atomic_inc_not_zero()


get_pid() should only be used if you already have a reference or you do
something like

	pid = find_vpid();

in this case we rely on call_rcu(delayed_put_pid) which drops the initial

If put_pid() sees pid->count == 1, then a) nobody else has a reference and
b) nobody else can find this pid on rcu-protected lists, so it is safe to
free it.


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.