[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 22/28] 9pfs: local: chmod: don't follow symli
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH v2 22/28] 9pfs: local: chmod: don't follow symlinks |
Date: |
Mon, 27 Feb 2017 13:17:53 +0000 |
User-agent: |
Mutt/1.7.1 (2016-10-04) |
On Sun, Feb 26, 2017 at 11:44:28PM +0100, Greg Kurz wrote:
> The local_chmod() callback is vulnerable to symlink attacks because it
> calls:
>
> (1) chmod() which follows symbolic links for all path elements
> (2) local_set_xattr()->setxattr() which follows symbolic links for all
> path elements
> (3) local_set_mapped_file_attr() which calls in turn local_fopen() and
> mkdir(), both functions following symbolic links for all path
> elements but the rightmost one
>
> We would need fchmodat() to implement AT_SYMLINK_NOFOLLOW to fix (1). This
> isn't the case on linux unfortunately: the kernel doesn't even have a flags
> argument to the syscall :-\ It is impossible to fix it in userspace in
> a race-free manner. This patch hence converts local_chmod() to rely on
> open_nofollow() and fchmod(). This fixes the vulnerability but introduces
> a limitation: the target file must readable and/or writable for the call
> to openat() to succeed.
>
> It introduces a local_set_xattrat() replacement to local_set_xattr()
> based on fsetxattrat() to fix (2), and a local_set_mapped_file_attrat()
> replacement to local_set_mapped_file_attr() based on local_fopenat()
> and mkdirat() to fix (3). No effort is made to factor out code because
> both local_set_xattr() and local_set_mapped_file_attr() will be dropped
> when all users have been converted to use the "at" versions.
>
> This partly fixes CVE-2016-9602.
>
> Signed-off-by: Greg Kurz <address@hidden>
> ---
> v2: - use openat_dir()
> - updated the changelog and added a comment for fchmod()
> ---
> hw/9pfs/9p-local.c | 178
> +++++++++++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 167 insertions(+), 11 deletions(-)
Reviewed-by: Stefan Hajnoczi <address@hidden>
signature.asc
Description: PGP signature
- [Qemu-devel] [PATCH v2 13/28] 9pfs: local: utimensat: don't follow symlinks, (continued)
- [Qemu-devel] [PATCH v2 13/28] 9pfs: local: utimensat: don't follow symlinks, Greg Kurz, 2017/02/26
- [Qemu-devel] [PATCH v2 14/28] 9pfs: local: statfs: don't follow symlinks, Greg Kurz, 2017/02/26
- [Qemu-devel] [PATCH v2 15/28] 9pfs: local: truncate: don't follow symlinks, Greg Kurz, 2017/02/26
- [Qemu-devel] [PATCH v2 16/28] 9pfs: local: readlink: don't follow symlinks, Greg Kurz, 2017/02/26
- [Qemu-devel] [PATCH v2 17/28] 9pfs: local: lstat: don't follow symlinks, Greg Kurz, 2017/02/26
- [Qemu-devel] [PATCH v2 18/28] 9pfs: local: renameat: don't follow symlinks, Greg Kurz, 2017/02/26
- [Qemu-devel] [PATCH v2 19/28] 9pfs: local: rename: use renameat, Greg Kurz, 2017/02/26
- [Qemu-devel] [PATCH v2 20/28] 9pfs: local: improve error handling in link op, Greg Kurz, 2017/02/26
- [Qemu-devel] [PATCH v2 21/28] 9pfs: local: link: don't follow symlinks, Greg Kurz, 2017/02/26
- [Qemu-devel] [PATCH v2 22/28] 9pfs: local: chmod: don't follow symlinks, Greg Kurz, 2017/02/26
- Re: [Qemu-devel] [PATCH v2 22/28] 9pfs: local: chmod: don't follow symlinks,
Stefan Hajnoczi <=
- [Qemu-devel] [PATCH v2 23/28] 9pfs: local: chown: don't follow symlinks, Greg Kurz, 2017/02/26
- [Qemu-devel] [PATCH v2 24/28] 9pfs: local: symlink: don't follow symlinks, Greg Kurz, 2017/02/26
- [Qemu-devel] [PATCH v2 25/28] 9pfs: local: mknod: don't follow symlinks, Greg Kurz, 2017/02/26
- [Qemu-devel] [PATCH v2 26/28] 9pfs: local: mkdir: don't follow symlinks, Greg Kurz, 2017/02/26
- [Qemu-devel] [PATCH v2 27/28] 9pfs: local: open2: don't follow symlinks, Greg Kurz, 2017/02/26
- [Qemu-devel] [PATCH v2 28/28] 9pfs: local: drop unused code, Greg Kurz, 2017/02/26
- Re: [Qemu-devel] [PATCH v2 00/28] 9pfs: local: fix vulnerability to symlink attacks, Greg Kurz, 2017/02/26
- Re: [Qemu-devel] [PATCH v2 00/28] Series short description, Stefan Hajnoczi, 2017/02/27