lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181221090958.GE2735@kadam>
Date:   Fri, 21 Dec 2018 12:09:58 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     Casey Schaufler <casey@...aufler-ca.com>,
        Al Viro <viro@...iv.linux.org.uk>
Cc:     James Morris <jmorris@...ei.org>,
        "Serge E. Hallyn" <serge@...lyn.com>,
        linux-security-module@...r.kernel.org,
        linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: [PATCH] smack: Fix a memory leak in smack_add_opt()

The function is leaking "opts" on the error paths.

Fixes: 90e3b564ab93 ("smack: take the guts of smack_parse_opts_str() into a new helper")
Signed-off-by: Dan Carpenter <dan.carpenter@...cle.com>
---
 security/smack/smack_lsm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 2adafc1018d9..4e9cdb942677 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -604,13 +604,13 @@ static int smack_add_opt(int token, const char *s, void **mnt_opts)
 {
 	struct smack_mnt_opts *opts = *mnt_opts;
 
+	if (!s)
+		return -ENOMEM;
 	if (!opts) {
 		opts = kzalloc(sizeof(struct smack_mnt_opts), GFP_KERNEL);
 		if (!opts)
 			return -ENOMEM;
 	}
-	if (!s)
-		return -ENOMEM;
 
 	switch (token) {
 	case Opt_fsdefault:
@@ -643,6 +643,8 @@ static int smack_add_opt(int token, const char *s, void **mnt_opts)
 	return 0;
 
 out_opt_err:
+	if (opts != *mnt_opts)
+		kfree(opts);
 	pr_warn("Smack: duplicate mount options\n");
 	return -EINVAL;
 }
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ