* [PATCH V2 linux-next] ipc/msg.c: fix memory leak in do_msgsnd()
@ 2016-08-01 11:40 Fabian Frederick
2016-08-01 12:24 ` Greg KH
2016-08-01 18:57 ` Davidlohr Bueso
0 siblings, 2 replies; 4+ messages in thread
From: Fabian Frederick @ 2016-08-01 11:40 UTC (permalink / raw)
To: Davidlohr Bueso; +Cc: Manfred Spraul, stable, linux-kernel, Andrew Morton, fabf
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:
[<ffffffff818e2c43>] kmemleak_alloc+0x23/0x40
[<ffffffff81177f31>] kmem_cache_alloc_trace+0xe1/0x180
[<ffffffff812d42af>] selinux_msg_queue_alloc_security+0x3f/0xd0
[<ffffffff812cc6be>] security_msg_queue_alloc+0x2e/0x40
[<ffffffff812b94ee>] newque+0x4e/0x150
[<ffffffff812b8cb9>] ipcget+0x159/0x1b0
[<ffffffff812b98d9>] SyS_msgget+0x39/0x40
[<ffffffff818e7bdb>] entry_SYSCALL_64_fastpath+0x13/0x8f
[<ffffffffffffffff>] 0xffffffffffffffff
Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
V2: Update description with original commit and cc stable
(Suggested by Manfred Spraul)
ipc/msg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ipc/msg.c b/ipc/msg.c
index 59559a2..43e9631 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -681,7 +681,7 @@ long do_msgsnd(int msqid, long mtype, void __user *mtext,
rcu_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;
--
2.8.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH V2 linux-next] ipc/msg.c: fix memory leak in do_msgsnd()
2016-08-01 11:40 [PATCH V2 linux-next] ipc/msg.c: fix memory leak in do_msgsnd() Fabian Frederick
@ 2016-08-01 12:24 ` Greg KH
2016-08-01 19:10 ` Davidlohr Bueso
2016-08-01 18:57 ` Davidlohr Bueso
1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2016-08-01 12:24 UTC (permalink / raw)
To: Fabian Frederick
Cc: Davidlohr Bueso, Manfred Spraul, stable, linux-kernel,
Andrew Morton
On Mon, Aug 01, 2016 at 01:40:58PM +0200, Fabian Frederick wrote:
> 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:
> [<ffffffff818e2c43>] kmemleak_alloc+0x23/0x40
> [<ffffffff81177f31>] kmem_cache_alloc_trace+0xe1/0x180
> [<ffffffff812d42af>] selinux_msg_queue_alloc_security+0x3f/0xd0
> [<ffffffff812cc6be>] security_msg_queue_alloc+0x2e/0x40
> [<ffffffff812b94ee>] newque+0x4e/0x150
> [<ffffffff812b8cb9>] ipcget+0x159/0x1b0
> [<ffffffff812b98d9>] SyS_msgget+0x39/0x40
> [<ffffffff818e7bdb>] entry_SYSCALL_64_fastpath+0x13/0x8f
> [<ffffffffffffffff>] 0xffffffffffffffff
>
> Signed-off-by: Fabian Frederick <fabf@skynet.be>
> ---
> V2: Update description with original commit and cc stable
> (Suggested by Manfred Spraul)
>
> ipc/msg.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
<formletter>
This is not the correct way to submit patches for inclusion in the
stable kernel tree. Please read Documentation/stable_kernel_rules.txt
for how to do this properly.
</formletter>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V2 linux-next] ipc/msg.c: fix memory leak in do_msgsnd()
2016-08-01 11:40 [PATCH V2 linux-next] ipc/msg.c: fix memory leak in do_msgsnd() Fabian Frederick
2016-08-01 12:24 ` Greg KH
@ 2016-08-01 18:57 ` Davidlohr Bueso
1 sibling, 0 replies; 4+ messages in thread
From: Davidlohr Bueso @ 2016-08-01 18:57 UTC (permalink / raw)
To: Fabian Frederick
Cc: Davidlohr Bueso, Manfred Spraul, stable, linux-kernel,
Andrew Morton
On Mon, 01 Aug 2016, Fabian Frederick wrote:
>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:
> [<ffffffff818e2c43>] kmemleak_alloc+0x23/0x40
> [<ffffffff81177f31>] kmem_cache_alloc_trace+0xe1/0x180
> [<ffffffff812d42af>] selinux_msg_queue_alloc_security+0x3f/0xd0
> [<ffffffff812cc6be>] security_msg_queue_alloc+0x2e/0x40
> [<ffffffff812b94ee>] newque+0x4e/0x150
> [<ffffffff812b8cb9>] ipcget+0x159/0x1b0
> [<ffffffff812b98d9>] SyS_msgget+0x39/0x40
> [<ffffffff818e7bdb>] entry_SYSCALL_64_fastpath+0x13/0x8f
> [<ffffffffffffffff>] 0xffffffffffffffff
>
>Signed-off-by: Fabian Frederick <fabf@skynet.be>
>---
>V2: Update description with original commit and cc stable
>(Suggested by Manfred Spraul)
Ideally we would have the fix for sem.c in the same patch, under, ie:
"sysv, ipc: fix security-layer leaking"
Just like with shm and msg, the only caller of ipc_rcu_free() should be a
failed security allocation in newary().
Thanks,
Davidlohr
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V2 linux-next] ipc/msg.c: fix memory leak in do_msgsnd()
2016-08-01 12:24 ` Greg KH
@ 2016-08-01 19:10 ` Davidlohr Bueso
0 siblings, 0 replies; 4+ messages in thread
From: Davidlohr Bueso @ 2016-08-01 19:10 UTC (permalink / raw)
To: Greg KH
Cc: Fabian Frederick, Davidlohr Bueso, Manfred Spraul, stable,
linux-kernel, Andrew Morton
On Mon, 01 Aug 2016, Greg KH wrote:
>This is not the correct way to submit patches for inclusion in the
>stable kernel tree. Please read Documentation/stable_kernel_rules.txt
>for how to do this properly.
I introduced this issue in 53dad6d3a8e (ipc: fix race with LSMs)
How about:
Cc: stable@kernel.org # v3.12
Thanks,
Davidlohr
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-08-01 19:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-01 11:40 [PATCH V2 linux-next] ipc/msg.c: fix memory leak in do_msgsnd() Fabian Frederick
2016-08-01 12:24 ` Greg KH
2016-08-01 19:10 ` Davidlohr Bueso
2016-08-01 18:57 ` Davidlohr Bueso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).