]> www.infradead.org Git - users/dwmw2/qemu.git/commit
9pfs: local: lsetxattr: don't follow symlinks
authorGreg Kurz <groug@kaod.org>
Sun, 26 Feb 2017 22:42:43 +0000 (23:42 +0100)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Thu, 16 Mar 2017 17:07:22 +0000 (12:07 -0500)
commited6083afc2df439578f00ae6c47338cb2203eaf1
treeb7ecd3f9ea67b48473a1cf9f56143adffabc018b
parentd10142c11bdcecebe97fd834a834167053b7a05c
9pfs: local: lsetxattr: don't follow symlinks

The local_lsetxattr() callback is vulnerable to symlink attacks because
it calls lsetxattr() which follows symbolic links in all path elements but
the rightmost one.

This patch introduces a helper to emulate the non-existing fsetxattrat()
function: it is implemented with /proc/self/fd which provides a trusted
path that can be safely passed to lsetxattr().

local_lsetxattr() is converted to use this helper and opendir_nofollow().

This partly fixes CVE-2016-9602.

Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
(cherry picked from commit 3e36aba757f76673007a80b3cd56a4062c2e3462)
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
hw/9pfs/9p-posix-acl.c
hw/9pfs/9p-util.h
hw/9pfs/9p-xattr-user.c
hw/9pfs/9p-xattr.c
hw/9pfs/9p-xattr.h