提交 b003fc0d 编写于 作者: G Greg Kurz

9pfs: fix vulnerability in openat_dir() and local_unlinkat_common()

We should pass O_NOFOLLOW otherwise openat() will follow symlinks and make
QEMU vulnerable.

While here, we also fix local_unlinkat_common() to use openat_dir() for
the same reasons (it was a leftover in the original patchset actually).

This fixes CVE-2016-9602.
Signed-off-by: NGreg Kurz <groug@kaod.org>
Reviewed-by: NDaniel P. Berrange <berrange@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
上级 918112c0
...@@ -960,7 +960,7 @@ static int local_unlinkat_common(FsContext *ctx, int dirfd, const char *name, ...@@ -960,7 +960,7 @@ static int local_unlinkat_common(FsContext *ctx, int dirfd, const char *name,
if (flags == AT_REMOVEDIR) { if (flags == AT_REMOVEDIR) {
int fd; int fd;
fd = openat(dirfd, name, O_RDONLY | O_DIRECTORY | O_PATH); fd = openat_dir(dirfd, name);
if (fd == -1) { if (fd == -1) {
goto err_out; goto err_out;
} }
......
...@@ -27,7 +27,8 @@ static inline int openat_dir(int dirfd, const char *name) ...@@ -27,7 +27,8 @@ static inline int openat_dir(int dirfd, const char *name)
#else #else
#define OPENAT_DIR_O_PATH 0 #define OPENAT_DIR_O_PATH 0
#endif #endif
return openat(dirfd, name, O_DIRECTORY | O_RDONLY | OPENAT_DIR_O_PATH); return openat(dirfd, name,
O_DIRECTORY | O_RDONLY | O_NOFOLLOW | OPENAT_DIR_O_PATH);
} }
static inline int openat_file(int dirfd, const char *name, int flags, static inline int openat_file(int dirfd, const char *name, int flags,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册