提交 d3c54bf9 编写于 作者: G Greg Kurz 提交者: Michael Roth

9pfs: local: statfs: don't follow symlinks

The local_statfs() callback is vulnerable to symlink attacks because it
calls statfs() which follows symbolic links in all path elements.

This patch converts local_statfs() to rely on open_nofollow() and fstatfs()
instead.

This partly fixes CVE-2016-9602.
Signed-off-by: NGreg Kurz <groug@kaod.org>
Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
(cherry picked from commit 31e51d1c)
Signed-off-by: NGreg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
上级 91225c67
...@@ -1078,13 +1078,11 @@ static int local_fsync(FsContext *ctx, int fid_type, ...@@ -1078,13 +1078,11 @@ static int local_fsync(FsContext *ctx, int fid_type,
static int local_statfs(FsContext *s, V9fsPath *fs_path, struct statfs *stbuf) static int local_statfs(FsContext *s, V9fsPath *fs_path, struct statfs *stbuf)
{ {
char *buffer; int fd, ret;
int ret;
char *path = fs_path->data;
buffer = rpath(s, path); fd = local_open_nofollow(s, fs_path->data, O_RDONLY, 0);
ret = statfs(buffer, stbuf); ret = fstatfs(fd, stbuf);
g_free(buffer); close_preserve_errno(fd);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册