Browse code

linux-esx: implement f*xattrat family of syscalls

Change-Id: I3e150d6f91ae1d1e4e2adfb0c9ea9cbe80cb317d
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/3551
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Anish Swaminathan <anishs@vmware.com>

Alexey Makhalov authored on 2017/08/17 06:20:28
Showing 3 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:	Linux API header files
2 2
 Name:		linux-api-headers
3 3
 Version:	4.4.82
4
-Release:	1%{?dist}
4
+Release:	2%{?dist}
5 5
 License:	GPLv2
6 6
 URL:		http://www.kernel.org/
7 7
 Group:		System Environment/Kernel
... ...
@@ -10,10 +10,14 @@ Distribution: Photon
10 10
 Source0:    	http://www.kernel.org/pub/linux/kernel/v4.x/linux-%{version}.tar.xz
11 11
 %define sha1 linux=27a2c7d466ec5b93712a9e17fa564652a0c06142
12 12
 BuildArch:	noarch
13
+# From SPECS/linux and used by linux-esx only
14
+# It provides f*xattrat syscalls
15
+Patch0:       Implement-the-f-xattrat-family-of-functions.patch
13 16
 %description
14 17
 The Linux API Headers expose the kernel's API for use by Glibc.
15 18
 %prep
16 19
 %setup -q -n linux-%{version}
20
+%patch0 -p1
17 21
 %build
18 22
 make mrproper
19 23
 make headers_check
... ...
@@ -25,6 +29,8 @@ find /%{buildroot}%{_includedir} \( -name .install -o -name ..install.cmd \) -de
25 25
 %defattr(-,root,root)
26 26
 %{_includedir}/*
27 27
 %changelog
28
+*   Wed Aug 16 2017 Alexey Makhalov <amakhalov@vmware.com> 4.4.82-2
29
+-   Implement the f*xattrat family of syscalls
28 30
 *   Tue Aug 15 2017 Alexey Makhalov <amakhalov@vmware.com> 4.4.82-1
29 31
 -   Version update
30 32
 *   Fri Aug 11 2017 Alexey Makhalov <amakhalov@vmware.com> 4.4.81-1
31 33
new file mode 100644
... ...
@@ -0,0 +1,236 @@
0
+From dd6595e90768ea30a0a41d96ceb5da3cc1916bd2 Mon Sep 17 00:00:00 2001
1
+From: Alexey Makhalov <amakhalov@vmware.com>
2
+Date: Wed, 16 Aug 2017 21:14:17 +0000
3
+Subject: [PATCH] Implement the f*xattrat family of functions
4
+
5
+Inspired by https://lkml.org/lkml/2014/1/21/266
6
+---
7
+ arch/x86/entry/syscalls/syscall_32.tbl |   4 ++
8
+ arch/x86/entry/syscalls/syscall_64.tbl |   4 ++
9
+ fs/xattr.c                             | 123 +++++++++++++++++++++++++++++++++
10
+ include/linux/syscalls.h               |  11 ++-
11
+ 4 files changed, 141 insertions(+), 1 deletion(-)
12
+
13
+diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl
14
+index e62f440..11d05f9 100644
15
+--- a/arch/x86/entry/syscalls/syscall_32.tbl
16
+@@ -383,3 +383,7 @@
17
+ 374	i386	userfaultfd		sys_userfaultfd
18
+ 375	i386	membarrier		sys_membarrier
19
+ 376	i386	mlock2			sys_mlock2
20
++377	i386	fsetxattrat		sys_fsetxattrat
21
++378	i386	fgetxattrat		sys_fgetxattrat
22
++379	i386	flistxattrat		sys_flistxattrat
23
++380	i386	fremovexattrat		sys_fremovexattrat
24
+diff --git a/arch/x86/entry/syscalls/syscall_64.tbl b/arch/x86/entry/syscalls/syscall_64.tbl
25
+index 314a90b..3c2dfa1 100644
26
+--- a/arch/x86/entry/syscalls/syscall_64.tbl
27
+@@ -332,6 +332,10 @@
28
+ 323	common	userfaultfd		sys_userfaultfd
29
+ 324	common	membarrier		sys_membarrier
30
+ 325	common	mlock2			sys_mlock2
31
++326	common	fsetxattrat		sys_fsetxattrat
32
++327	common	fgetxattrat		sys_fgetxattrat
33
++328	common	flistxattrat		sys_flistxattrat
34
++329	common	fremovexattrat		sys_fremovexattrat
35
+ 
36
+ #
37
+ # x32-specific system call numbers start at 512 to avoid cache impact
38
+diff --git a/fs/xattr.c b/fs/xattr.c
39
+index f0da9d2..d5e4944 100644
40
+--- a/fs/xattr.c
41
+@@ -419,6 +419,41 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
42
+ 	return error;
43
+ }
44
+ 
45
++SYSCALL_DEFINE6(fsetxattrat, int, fd, const char __user *, pathname,
46
++		const char __user *, name, const void __user *, value,
47
++		size_t, size, int, flags)
48
++{
49
++	struct path path;
50
++	int error;
51
++	unsigned int lookup_flags = 0;
52
++
53
++	if (flags & ~(XATTR_CREATE | XATTR_REPLACE |
54
++		      AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH))
55
++		return -EINVAL;
56
++
57
++	if (!(flags & AT_SYMLINK_NOFOLLOW))
58
++		lookup_flags |= LOOKUP_FOLLOW;
59
++	if (flags & AT_EMPTY_PATH)
60
++		lookup_flags |= LOOKUP_EMPTY;
61
++
62
++retry:
63
++	error = user_path_at(fd, pathname, lookup_flags, &path);
64
++	if (error)
65
++		return error;
66
++	error = mnt_want_write(path.mnt);
67
++	if (!error) {
68
++		error = setxattr(path.dentry, name, value, size,
69
++				 flags & (XATTR_CREATE | XATTR_REPLACE));
70
++		mnt_drop_write(path.mnt);
71
++	}
72
++	path_put(&path);
73
++	if (retry_estale(error, lookup_flags)) {
74
++		lookup_flags |= LOOKUP_REVAL;
75
++		goto retry;
76
++	}
77
++	return error;
78
++}
79
++
80
+ /*
81
+  * Extended attribute GET operations
82
+  */
83
+@@ -513,6 +548,35 @@ SYSCALL_DEFINE4(fgetxattr, int, fd, const char __user *, name,
84
+ 	return error;
85
+ }
86
+ 
87
++SYSCALL_DEFINE6(fgetxattrat, int, fd, const char __user *, pathname,
88
++		const char __user *, name, void __user *, value, size_t, size,
89
++		int, flags)
90
++{
91
++	struct path path;
92
++	ssize_t error;
93
++	unsigned int lookup_flags = 0;
94
++
95
++	if (flags & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH))
96
++		return -EINVAL;
97
++
98
++	if (!(flags & AT_SYMLINK_NOFOLLOW))
99
++		lookup_flags |= LOOKUP_FOLLOW;
100
++	if (flags & AT_EMPTY_PATH)
101
++		lookup_flags |= LOOKUP_EMPTY;
102
++
103
++retry:
104
++	error = user_path_at(fd, pathname, lookup_flags, &path);
105
++	if (error)
106
++		return error;
107
++	error = getxattr(path.dentry, name, value, size);
108
++	path_put(&path);
109
++	if (retry_estale(error, lookup_flags)) {
110
++		lookup_flags |= LOOKUP_REVAL;
111
++		goto retry;
112
++	}
113
++	return error;
114
++}
115
++
116
+ /*
117
+  * Extended attribute LIST operations
118
+  */
119
+@@ -594,6 +658,34 @@ SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)
120
+ 	return error;
121
+ }
122
+ 
123
++SYSCALL_DEFINE5(flistxattrat, int, fd, const char __user *, pathname,
124
++		char __user *, list, size_t, size, int, flags)
125
++{
126
++	struct path path;
127
++	ssize_t error;
128
++	unsigned int lookup_flags = 0;
129
++
130
++	if (flags & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH))
131
++		return -EINVAL;
132
++
133
++	if (!(flags & AT_SYMLINK_NOFOLLOW))
134
++		lookup_flags |= LOOKUP_FOLLOW;
135
++	if (flags & AT_EMPTY_PATH)
136
++		lookup_flags |= LOOKUP_EMPTY;
137
++
138
++retry:
139
++	error = user_path_at(fd, pathname, lookup_flags, &path);
140
++	if (error)
141
++		return error;
142
++	error = listxattr(path.dentry, list, size);
143
++	path_put(&path);
144
++	if (retry_estale(error, lookup_flags)) {
145
++		lookup_flags |= LOOKUP_REVAL;
146
++		goto retry;
147
++	}
148
++	return error;
149
++}
150
++
151
+ /*
152
+  * Extended attribute REMOVE operations
153
+  */
154
+@@ -663,6 +755,37 @@ SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
155
+ 	return error;
156
+ }
157
+ 
158
++SYSCALL_DEFINE4(fremovexattrat, int, fd, const char __user *, pathname,
159
++		const char __user *, name, int, flags)
160
++{
161
++	struct path path;
162
++	int error;
163
++	unsigned int lookup_flags = 0;
164
++
165
++	if (flags & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH))
166
++		return -EINVAL;
167
++
168
++	if (!(flags & AT_SYMLINK_NOFOLLOW))
169
++		lookup_flags |= LOOKUP_FOLLOW;
170
++	if (flags & AT_EMPTY_PATH)
171
++		lookup_flags |= LOOKUP_EMPTY;
172
++
173
++retry:
174
++	error = user_path_at(fd, pathname, lookup_flags, &path);
175
++	if (error)
176
++		return error;
177
++	error = mnt_want_write(path.mnt);
178
++	if (!error) {
179
++		error = removexattr(path.dentry, name);
180
++		mnt_drop_write(path.mnt);
181
++	}
182
++	path_put(&path);
183
++	if (retry_estale(error, lookup_flags)) {
184
++		lookup_flags |= LOOKUP_REVAL;
185
++		goto retry;
186
++	}
187
++	return error;
188
++}
189
+ 
190
+ static const char *
191
+ strcmp_prefix(const char *a, const char *a_prefix)
192
+diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
193
+index c2b66a2..daf1856 100644
194
+--- a/include/linux/syscalls.h
195
+@@ -430,23 +430,32 @@ asmlinkage long sys_lsetxattr(const char __user *path, const char __user *name,
196
+ 			      const void __user *value, size_t size, int flags);
197
+ asmlinkage long sys_fsetxattr(int fd, const char __user *name,
198
+ 			      const void __user *value, size_t size, int flags);
199
++asmlinkage long sys_fsetxattrat(int fd, const char __user *pathname,
200
++				const char __user *name,
201
++				const void __user *value, size_t size, int flags);
202
+ asmlinkage long sys_getxattr(const char __user *path, const char __user *name,
203
+ 			     void __user *value, size_t size);
204
+ asmlinkage long sys_lgetxattr(const char __user *path, const char __user *name,
205
+ 			      void __user *value, size_t size);
206
+ asmlinkage long sys_fgetxattr(int fd, const char __user *name,
207
+ 			      void __user *value, size_t size);
208
++asmlinkage long sys_fgetxattrat(int fd, const char __user *pathname,
209
++				const char __user *name,
210
++				void __user *value, size_t size, int flags);
211
+ asmlinkage long sys_listxattr(const char __user *path, char __user *list,
212
+ 			      size_t size);
213
+ asmlinkage long sys_llistxattr(const char __user *path, char __user *list,
214
+ 			       size_t size);
215
+ asmlinkage long sys_flistxattr(int fd, char __user *list, size_t size);
216
++asmlinkage long sys_flistxattrat(int fd, const char __user *pathname,
217
++				 char __user *list, size_t size, int flags);
218
+ asmlinkage long sys_removexattr(const char __user *path,
219
+ 				const char __user *name);
220
+ asmlinkage long sys_lremovexattr(const char __user *path,
221
+ 				 const char __user *name);
222
+ asmlinkage long sys_fremovexattr(int fd, const char __user *name);
223
+-
224
++asmlinkage long sys_fremovexattrat(int fd, const char __user *pathname,
225
++				   const char __user *name, int flags);
226
+ asmlinkage long sys_brk(unsigned long brk);
227
+ asmlinkage long sys_mprotect(unsigned long start, size_t len,
228
+ 				unsigned long prot);
229
+-- 
230
+2.8.1
231
+
... ...
@@ -2,7 +2,7 @@
2 2
 Summary:       Kernel
3 3
 Name:          linux-esx
4 4
 Version:       4.4.82
5
-Release:       1%{?dist}
5
+Release:       2%{?dist}
6 6
 License:       GPLv2
7 7
 URL:           http://www.kernel.org/
8 8
 Group:         System Environment/Kernel
... ...
@@ -35,6 +35,7 @@ Patch20:       vmci-1.1.4.0-use-32bit-atomics-for-queue-headers.patch
35 35
 Patch21:       vmci-1.1.5.0-doorbell-create-and-destroy-fixes.patch
36 36
 Patch22:       net-9p-vsock.patch
37 37
 Patch23:       p9fs_dir_readdir-offset-support.patch
38
+Patch24:       Implement-the-f-xattrat-family-of-functions.patch
38 39
 
39 40
 BuildRequires: bc
40 41
 BuildRequires: kbd
... ...
@@ -95,6 +96,7 @@ The Linux package contains the Linux kernel doc files
95 95
 %patch21 -p1
96 96
 %patch22 -p1
97 97
 %patch23 -p1
98
+%patch24 -p1
98 99
 
99 100
 %build
100 101
 # patch vmw_balloon driver
... ...
@@ -183,6 +185,8 @@ ln -sf linux-%{uname_r}.cfg /boot/photon.cfg
183 183
 /usr/src/linux-headers-%{uname_r}
184 184
 
185 185
 %changelog
186
+*   Wed Aug 16 2017 Alexey Makhalov <amakhalov@vmware.com> 4.4.82-2
187
+-   Implement the f*xattrat family of syscalls
186 188
 *   Tue Aug 15 2017 Alexey Makhalov <amakhalov@vmware.com> 4.4.82-1
187 189
 -   Version update
188 190
 *   Fri Aug 11 2017 Alexey Makhalov <amakhalov@vmware.com> 4.4.81-1