]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit
selinux: fix double free in selinux_parse_opts_str()
authorPaul Moore <paul@paul-moore.com>
Wed, 7 Jun 2017 20:48:19 +0000 (16:48 -0400)
committerJames Morris <james.l.morris@oracle.com>
Tue, 13 Jun 2017 07:34:22 +0000 (17:34 +1000)
commit023f108dcc187e34ef864bf10ed966cf25e14e2a
tree6617c918c09d44b648db90e921844c9604de66f5
parent63f700aab4c11d46626de3cd051dae56cf7e9056
selinux: fix double free in selinux_parse_opts_str()

This patch is based on a discussion generated by an earlier patch
from Tetsuo Handa:

* https://marc.info/?t=149035659300001&r=1&w=2

The double free problem involves the mnt_opts field of the
security_mnt_opts struct, selinux_parse_opts_str() frees the memory
on error, but doesn't set the field to NULL so if the caller later
attempts to call security_free_mnt_opts() we trigger the problem.

In order to play it safe we change selinux_parse_opts_str() to call
security_free_mnt_opts() on error instead of free'ing the memory
directly.  This should ensure that everything is handled correctly,
regardless of what the caller may do.

Fixes: e0007529893c1c06 ("LSM/SELinux: Interfaces to allow FS to control mount options")
Cc: stable@vger.kernel.org
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
security/selinux/hooks.c