From: Tetsuo Handa Date: Fri, 24 Mar 2017 11:42:05 +0000 (+0900) Subject: smack: fix double free in smack_parse_opts_str() X-Git-Tag: v4.12-rc1~123^2~5^2~1 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=c3c8dc9f13e2e13013822ee54a529a6fe284f1e1;p=uclinux-h8%2Flinux.git smack: fix double free in smack_parse_opts_str() smack_parse_opts_str() calls kfree(opts->mnt_opts) when kcalloc() for opts->mnt_opts_flags failed. But it should not have called it because security_free_mnt_opts() will call kfree(opts->mnt_opts). Signed-off-by: Tetsuo Handa Signed-off-by: Casey Schaufler fixes: 3bf2789cad9e6573 ("smack: allow mount opts setting over filesystems with binary mount data") Cc: Vivek Trivedi Cc: Amit Sahrawat Cc: Casey Schaufler --- diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index 927e60e622d1..658f5d8c7e76 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -695,10 +695,8 @@ static int smack_parse_opts_str(char *options, opts->mnt_opts_flags = kcalloc(NUM_SMK_MNT_OPTS, sizeof(int), GFP_KERNEL); - if (!opts->mnt_opts_flags) { - kfree(opts->mnt_opts); + if (!opts->mnt_opts_flags) goto out_err; - } if (fsdefault) { opts->mnt_opts[num_mnt_opts] = fsdefault;