Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 708f1816 authored by Paul Moore's avatar Paul Moore Committed by Gerrit - the friendly Code Review server
Browse files

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: e0007529 ("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: default avatarDmitry Vyukov <dvyukov@google.com>
Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
Git-commit: 023f108dcc187e34ef864bf10ed966cf25e14e2a
Git-repo: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git


Change-Id: I785159128b1f18a8508905f2fcbd4db1fd3c4c20
Signed-off-by: default avatarSachin Grover <sgrover@codeaurora.org>
parent 8d327f8f
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment