]> git.ipfire.org Git - thirdparty/util-linux.git/commit - disk-utils/mkswap.c
mkswap: possible to crash with SELinux relabeling support
authorKaiGai Kohei <kaigai@kaigai.gr.jp>
Mon, 22 Oct 2007 08:30:19 +0000 (10:30 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 25 Oct 2007 19:50:36 +0000 (21:50 +0200)
commit71bf78844425d228de76db36c2f97e542c4c54fe
tree2477d9a347d02c60756f855e6a6de90abd7fb056
parent294940de300c20050aa80bf1511d7642a9bf4792
mkswap: possible to crash with SELinux relabeling support

When fgetfilecon() is failed with -ENODATA, this process does not
exit.  However, "oldcontext" is not initialized in this case, so
context_new() will be called with uninitialized "oldcontext" at the
next.

Finally, it makes a segmentation fault, because context_new() have to
refer an incorrect memory region.

The attached patch fixes this matter using matchpathcon().  If we
cannot obtain actual file context due to -ENODATA, a context which is
returned by matchpathcon() is applied as oldcontext.  Then, the type
of the context is relabeled to "swapfile_t" explicitly.

Signed-off-by: KaiGai Kohei <kaigai@kaigai.gr.jp>
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/mkswap.c