]> Git Repo - qemu.git/blame - hw/9pfs/virtio-9p-xattr-user.c
rtl8139: skip offload on short TCP header (CVE-2015-5165)
[qemu.git] / hw / 9pfs / virtio-9p-xattr-user.c
CommitLineData
fc22118d
AK
1/*
2 * Virtio 9p user. xattr callback
3 *
4 * Copyright IBM, Corp. 2010
5 *
6 * Authors:
7 * Aneesh Kumar K.V <[email protected]>
8 *
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
11 *
12 */
13
14#include <sys/types.h>
0d09e41a 15#include "hw/virtio/virtio.h"
fc22118d 16#include "virtio-9p.h"
353ac78d 17#include "fsdev/file-op-9p.h"
fc22118d
AK
18#include "virtio-9p-xattr.h"
19
20
21static ssize_t mp_user_getxattr(FsContext *ctx, const char *path,
22 const char *name, void *value, size_t size)
23{
4fa4ce71
CG
24 char *buffer;
25 ssize_t ret;
26
fc22118d
AK
27 if (strncmp(name, "user.virtfs.", 12) == 0) {
28 /*
29 * Don't allow fetch of user.virtfs namesapce
30 * in case of mapped security
31 */
32 errno = ENOATTR;
33 return -1;
34 }
4fa4ce71
CG
35 buffer = rpath(ctx, path);
36 ret = lgetxattr(buffer, name, value, size);
37 g_free(buffer);
38 return ret;
fc22118d
AK
39}
40
41static ssize_t mp_user_listxattr(FsContext *ctx, const char *path,
42 char *name, void *value, size_t size)
43{
44 int name_size = strlen(name) + 1;
45 if (strncmp(name, "user.virtfs.", 12) == 0) {
70fc55eb
AK
46
47 /* check if it is a mapped posix acl */
48 if (strncmp(name, "user.virtfs.system.posix_acl_", 29) == 0) {
49 /* adjust the name and size */
50 name += 12;
51 name_size -= 12;
52 } else {
53 /*
54 * Don't allow fetch of user.virtfs namesapce
55 * in case of mapped security
56 */
57 return 0;
58 }
fc22118d
AK
59 }
60 if (!value) {
61 return name_size;
62 }
63
64 if (size < name_size) {
65 errno = ERANGE;
66 return -1;
67 }
68
9238c209
JM
69 /* name_size includes the trailing NUL. */
70 memcpy(value, name, name_size);
fc22118d
AK
71 return name_size;
72}
73
74static int mp_user_setxattr(FsContext *ctx, const char *path, const char *name,
75 void *value, size_t size, int flags)
76{
4fa4ce71
CG
77 char *buffer;
78 int ret;
79
fc22118d
AK
80 if (strncmp(name, "user.virtfs.", 12) == 0) {
81 /*
82 * Don't allow fetch of user.virtfs namesapce
83 * in case of mapped security
84 */
85 errno = EACCES;
86 return -1;
87 }
4fa4ce71
CG
88 buffer = rpath(ctx, path);
89 ret = lsetxattr(buffer, name, value, size, flags);
90 g_free(buffer);
91 return ret;
fc22118d
AK
92}
93
94static int mp_user_removexattr(FsContext *ctx,
95 const char *path, const char *name)
96{
4fa4ce71
CG
97 char *buffer;
98 int ret;
99
fc22118d
AK
100 if (strncmp(name, "user.virtfs.", 12) == 0) {
101 /*
102 * Don't allow fetch of user.virtfs namesapce
103 * in case of mapped security
104 */
105 errno = EACCES;
106 return -1;
107 }
4fa4ce71
CG
108 buffer = rpath(ctx, path);
109 ret = lremovexattr(buffer, name);
110 g_free(buffer);
111 return ret;
fc22118d
AK
112}
113
114XattrOperations mapped_user_xattr = {
115 .name = "user.",
116 .getxattr = mp_user_getxattr,
117 .setxattr = mp_user_setxattr,
118 .listxattr = mp_user_listxattr,
119 .removexattr = mp_user_removexattr,
120};
121
122XattrOperations passthrough_user_xattr = {
123 .name = "user.",
124 .getxattr = pt_getxattr,
125 .setxattr = pt_setxattr,
126 .listxattr = pt_listxattr,
127 .removexattr = pt_removexattr,
128};
This page took 0.373142 seconds and 4 git commands to generate.