]> git.proxmox.com Git - mirror_qemu.git/commit
9pfs: local: link: don't follow symlinks
authorGreg Kurz <groug@kaod.org>
Sun, 26 Feb 2017 22:44:20 +0000 (23:44 +0100)
committerGreg Kurz <groug@kaod.org>
Tue, 28 Feb 2017 10:21:15 +0000 (11:21 +0100)
commitad0b46e6ac769b187cb4dcf0065675ef8a198a5e
tree1e09a595f88b4a6ca6f737d12eca5ad579ebe743
parent6dd4b1f1d026e478d9177b28169b377e212400f3
9pfs: local: link: don't follow symlinks

The local_link() callback is vulnerable to symlink attacks because it calls:

(1) link() which follows symbolic links for all path elements but the
    rightmost one
(2) local_create_mapped_attr_dir()->mkdir() which follows symbolic links
    for all path elements but the rightmost one

This patch converts local_link() to rely on opendir_nofollow() and linkat()
to fix (1), mkdirat() to fix (2).

This partly fixes CVE-2016-9602.

Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
hw/9pfs/9p-local.c