Files
android_kernel_xiaomi_sm8450/include/linux
Joel Fernandes (Google) f57e515a1b kernel/pid.c: convert struct pid count to refcount_t
struct pid's count is an atomic_t field used as a refcount.  Use
refcount_t for it which is basically atomic_t but does additional
checking to prevent use-after-free bugs.

For memory ordering, the only change is with the following:

 -	if ((atomic_read(&pid->count) == 1) ||
 -	     atomic_dec_and_test(&pid->count)) {
 +	if (refcount_dec_and_test(&pid->count)) {
 		kmem_cache_free(ns->pid_cachep, pid);

Here the change is from: Fully ordered --> RELEASE + ACQUIRE (as per
refcount-vs-atomic.rst) This ACQUIRE should take care of making sure the
free happens after the refcount_dec_and_test().

The above hunk also removes atomic_read() since it is not needed for the
code to work and it is unclear how beneficial it is.  The removal lets
refcount_dec_and_test() check for cases where get_pid() happened before
the object was freed.

Link: http://lkml.kernel.org/r/20190701183826.191936-1-joel@joelfernandes.org
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Reviewed-by: Andrea Parri <andrea.parri@amarulasolutions.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Elena Reshetova <elena.reshetova@intel.com>
Cc: Jann Horn <jannh@google.com>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: KJ Tsanaktsidis <ktsanaktsidis@zendesk.com>
Cc: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-07-16 19:23:24 -07:00
..
2019-06-20 09:23:22 +02:00
2019-05-31 11:13:10 +02:00
2019-07-10 09:00:57 -06:00
2019-05-14 19:52:50 -07:00
2019-07-01 08:18:54 -06:00
2019-07-10 09:00:57 -06:00
2019-07-10 09:00:57 -06:00
2019-04-09 17:05:46 -07:00
2019-05-07 08:39:02 -06:00
2019-05-09 15:25:13 -04:00
2019-06-12 20:27:13 +02:00
2019-07-08 11:00:02 +02:00
2019-07-10 13:17:30 +02:00
2019-02-28 03:28:53 -05:00
2019-06-12 20:30:39 +02:00
2019-02-28 08:24:23 -07:00
2019-06-14 14:18:53 -06:00
2019-04-22 09:48:12 -06:00
2019-02-15 16:54:38 +01:00
2019-07-05 21:34:50 +02:00
2019-06-26 13:19:46 -07:00
2019-06-10 13:00:24 +02:00
2019-04-08 22:56:14 +02:00
2019-03-07 18:32:03 -08:00
2019-07-08 19:25:19 -07:00
2019-02-20 07:22:17 -07:00
2019-02-20 07:22:10 -07:00
2019-07-09 14:15:37 -07:00
2019-02-08 15:02:49 -08:00
2019-07-12 17:08:41 -05:00
2019-05-14 19:52:51 -07:00
2019-06-12 11:42:13 +02:00
2019-06-15 12:25:49 +02:00
2019-05-14 19:52:48 -07:00
2019-04-02 17:57:35 +02:00
2019-05-08 22:14:36 +02:00
2019-05-31 12:37:46 -07:00
2019-05-16 15:51:55 -07:00
2019-07-09 14:32:14 -06:00
2019-02-07 16:38:35 +01:00
2019-07-08 10:51:25 +02:00
2019-07-12 11:05:43 -07:00
2019-06-14 20:18:27 -07:00
2019-07-07 11:50:03 +02:00
2019-06-05 11:54:38 +02:00
2019-05-15 17:35:54 +01:00
2019-04-09 15:14:49 -06:00
2019-07-10 09:00:57 -06:00