]> git.kernelconcepts.de Git - karo-tx-linux.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)
committerAK <andi@firstfloor.org>
Thu, 31 Mar 2011 18:58:05 +0000 (11:58 -0700)
commita633f63ce3ccfae3e15d092a25b19e39dc4b33c4
tree7fe163eedd381e597f20d5e51239eae7cd927d7d
parent1e1d5bf10f0ee5550bcbfd14dd944a526a68a93e
CRED: Fix memory and refcount leaks upon security_prepare_creds() failure

commit fb2b2a1d37f80cc818fd4487b510f4e11816e5e1 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
kernel/cred.c