]> git.baikalelectronics.ru Git - kernel.git/commit
CRED: Fix memory and refcount leaks upon security_prepare_creds() failure
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Mon, 7 Feb 2011 13:36:16 +0000 (13:36 +0000)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 7 Feb 2011 22:04:00 +0000 (14:04 -0800)
commitdc4f5d7b382f7d5d834dc2fdf5398ef33ee39429
tree00a16a9440fb1d522160a404c97ed327f77a92a1
parent99bc03962b28b4a77b92f0aa3d6c4a5173da7a79
CRED: Fix memory and refcount leaks upon security_prepare_creds() failure

In prepare_kernel_cred() since 2.6.29, put_cred(new) is called without
assigning new->usage when security_prepare_creds() returned an error.  As a
result, memory for new and refcount for new->{user,group_info,tgcred} are
leaked because put_cred(new) won't call __put_cred() unless old->usage == 1.

Fix these leaks by assigning new->usage (and new->subscribers which was added
in 2.6.32) before calling security_prepare_creds().

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
kernel/cred.c