Skip to content

Commit

Permalink
smack: fix double free in smack_parse_opts_str()
Browse files Browse the repository at this point in the history
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 <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
fixes: 3bf2789 ("smack: allow mount opts setting over filesystems with binary mount data")
Cc: Vivek Trivedi <t.vivek@samsung.com>
Cc: Amit Sahrawat <a.sahrawat@samsung.com>
Cc: Casey Schaufler <casey@schaufler-ca.com>
  • Loading branch information
Tetsuo Handa authored and Casey Schaufler committed Apr 4, 2017
1 parent e4e55b4 commit c3c8dc9
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions security/smack/smack_lsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c3c8dc9

Please sign in to comment.