On Tue, Jun 6, 2017 at 3:32 PM, Paul Moore <pmoore@xxxxxxxxxx> wrote: > From: Paul Moore <paul@xxxxxxxxxxxxxx> > > 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@xxxxxxxxxxxxxxx > Cc: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx> > Reported-by: Dmitry Vyukov <dvyukov@xxxxxxxxxx> > Signed-off-by: Paul Moore <paul@xxxxxxxxxxxxxx> > --- > security/selinux/hooks.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) FYI, I just merged this into selinux/stable-4.12. -- paul moore www.paul-moore.com