From mboxrd@z Thu Jan 1 00:00:00 1970 From: ebiederm@xmission.com (Eric W. Biederman) Subject: [PATCH 01/42] sysfs: Don't leak secdata when a sysfs_dirent is freed. Date: Tue, 03 Nov 2009 03:02:12 -0800 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: , To: Greg Kroah-Hartman Return-path: Received: from out02.mta.xmission.com ([166.70.13.232]:33433 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752260AbZKCLCN (ORCPT ); Tue, 3 Nov 2009 06:02:13 -0500 Cc: sds@tycho.nsa.gov, jmorris@namei.org, casey@schaufler-ca.com, linux-security-module@vger.kernel.org Sender: linux-fsdevel-owner@vger.kernel.org List-ID: While refreshing my sysfs patches I noticed a leak in the secdata implementation. We don't free the secdata when we free the sysfs dirent. This is a bug in 2.6.32-rc5 that we really should close. Signed-off-by: Eric W. Biederman --- fs/sysfs/dir.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index 5fad489..e020183 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "sysfs.h" DEFINE_MUTEX(sysfs_mutex); @@ -285,6 +286,9 @@ void release_sysfs_dirent(struct sysfs_dirent * sd) sysfs_put(sd->s_symlink.target_sd); if (sysfs_type(sd) & SYSFS_COPY_NAME) kfree(sd->s_name); + if (sd->s_iattr && sd->s_iattr->ia_secdata) + security_release_secctx(sd->s_iattr->ia_secdata, + sd->s_iattr->ia_secdata_len); kfree(sd->s_iattr); sysfs_free_ino(sd->s_ino); kmem_cache_free(sysfs_dir_cachep, sd); -- 1.6.5.2.143.g8cc62