Patch "sysv, ipc: fix security-layer leaking" has been added to the 4.4-stable tree
This is a note to let you know that I've just added the patch titled
sysv, ipc: fix security-layer leaking
to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
sysv-ipc-fix-security-layer-leaking.patch
and it can be found in the queue-4.4 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
9b24fef9f0410fb5364245d6cc2bd044cc064007Mon Sep 17 00:00:00 2001
From: Fabian Frederick <[email protected]>
Date: Tue, 2 Aug 2016 14:03:07 -0700
Subject: sysv, ipc: fix security-layer leaking
From: Fabian Frederick <[email protected]>
commit 9b24fef9f0410fb5364245d6cc2bd044cc064007 upstream.
Commit 53dad6d3a8e5 ("ipc: fix race with LSMs") updated ipc_rcu_putref() to receive rcu freeing function but used generic ipc_rcu_free() instead of msg_rcu_free() which does security cleaning.
Running LTP msgsnd06 with kmemleak gives the following:
cat /sys/kernel/debug/kmemleak
unreferenced object 0xffff88003c0a11f8 (size 8):
comm "msgsnd06", pid 1645, jiffies 4294672526 (age 6.549s)
hex dump (first 8 bytes):
1b 00 00 00 01 00 00 00 ........
backtrace:
kmemleak_alloc+0x23/0x40
kmem_cache_alloc_trace+0xe1/0x180
selinux_msg_queue_alloc_security+0x3f/0xd0
security_msg_queue_alloc+0x2e/0x40
newque+0x4e/0x150
ipcget+0x159/0x1b0
SyS_msgget+0x39/0x40
entry_SYSCALL_64_fastpath+0x13/0x8fManfred Spraul suggested to fix sem.c as well and Davidlohr Bueso to only use ipc_rcu_free in case of security allocation failure in newary()
--- ipc/msg.c | 2 +- ipc/sem.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-)
ipc/msg.c +1 -1
@@ -680,7 +680,7 @@ long do_msgsnd(int msqid, long mtype, vorcu_read_lock ();ipc_lock_object (&msq->q_perm); -ipc_rcu_putref (msq, ipc_rcu_free); +ipc_rcu_putref (msq, msg_rcu_free);/* raced with RMID? */ if (!ipc_valid_object (&msq->q_perm)) { err = -EIDRM ;
ipc/sem.c +6 -6
@@ -442,7 +442,7 @@ static inline struct sem_array *sem_obtastatic inline void sem_lock_and_putref (struct sem_array *sma) {sem_lock (sma,NULL ,-1 ); -ipc_rcu_putref (sma, ipc_rcu_free); +ipc_rcu_putref (sma, sem_rcu_free); }static inline void sem_rmid (struct ipc_namespace *ns,struct sem_array *s)
@@ -1385,7 +1385,7 @@ static int semctl_main(struct ipc_namesprcu_read_unlock (); sem_io =ipc_alloc (sizeof (ushort)*nsems);if (sem_io ==NULL ) { -ipc_rcu_putref (sma, ipc_rcu_free); +ipc_rcu_putref (sma, sem_rcu_free);return -ENOMEM ; }
@@ -1419,20 +1419,20 @@ static int semctl_main(struct ipc_namespif (nsems >SEMMSL_FAST ) { sem_io =ipc_alloc (sizeof (ushort)*nsems);if (sem_io ==NULL ) { -ipc_rcu_putref (sma, ipc_rcu_free); +ipc_rcu_putref (sma, sem_rcu_free);return -ENOMEM ; } }if (copy_from_user (sem_io, p, nsems*sizeof (ushort))) { -ipc_rcu_putref (sma, ipc_rcu_free); +ipc_rcu_putref (sma, sem_rcu_free); err = -EFAULT ; goto out_free; }for (i =0 ; i < nsems; i++) {if (sem_io[i] >SEMVMX ) { -ipc_rcu_putref (sma, ipc_rcu_free); +ipc_rcu_putref (sma, sem_rcu_free); err = -ERANGE ; goto out_free; }
@@ -1722,7 +1722,7 @@ static struct sem_undo *find_alloc_undo(/* step 2: allocate new undo structure */ new =kzalloc (sizeof (struct sem_undo ) +sizeof (short )*nsems,GFP_KERNEL );if (!new) { -ipc_rcu_putref (sma, ipc_rcu_free); +ipc_rcu_putref (sma, sem_rcu_free);return ERR_PTR (-ENOMEM ); }
Patches currently in stable-queue which might be from [email protected] are
queue-4.4/sysv-ipc-fix-security-layer-leaking.patch