Browse code

kernels: Add the f*xattrat family of syscalls

Change-Id: I897ac0d148572a64554f813ff09e9312168c49b7
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/5176
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Srivatsa S. Bhat <srivatsab@vmware.com>

Alexey Makhalov authored on 2018/05/22 06:03:11
Showing 6 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:	Linux API header files
2 2
 Name:		linux-api-headers
3 3
 Version:	4.9.101
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,12 @@ Distribution: Photon
10 10
 Source0:        http://www.kernel.org/pub/linux/kernel/v4.x/linux-%{version}.tar.xz
11 11
 %define sha1 linux=12b399649df63355823d482fd91711b1be3e7f1b
12 12
 BuildArch:	noarch
13
+Patch0:         Implement-the-f-xattrat-family-of-functions.patch
13 14
 %description
14 15
 The Linux API Headers expose the kernel's API for use by Glibc.
15 16
 %prep
16 17
 %setup -q -n linux-%{version}
18
+%patch0 -p1
17 19
 %build
18 20
 make mrproper
19 21
 make headers_check
... ...
@@ -25,6 +27,8 @@ find /%{buildroot}%{_includedir} \( -name .install -o -name ..install.cmd \) -de
25 25
 %defattr(-,root,root)
26 26
 %{_includedir}/*
27 27
 %changelog
28
+*   Mon May 21 2018 Alexey Makhalov <amakhalov@vmware.com> 4.9.101-2
29
+-   Add the f*xattrat family of syscalls.
28 30
 *   Mon May 21 2018 Srivatsa S. Bhat <srivatsa@csail.mit.edu> 4.9.101-1
29 31
 -   Update to version 4.9.101
30 32
 *   Wed May 09 2018 Srivatsa S. Bhat <srivatsa@csail.mit.edu> 4.9.99-1
31 33
new file mode 100644
... ...
@@ -0,0 +1,228 @@
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_64.tbl |   4 ++
8
+ fs/xattr.c                             | 123 +++++++++++++++++++++++++++++++++
9
+ include/linux/syscalls.h               |  11 ++-
10
+ 4 files changed, 141 insertions(+), 1 deletion(-)
11
+
12
+diff --git a/arch/x86/entry/syscalls/syscall_64.tbl b/arch/x86/entry/syscalls/syscall_64.tbl
13
+index 314a90b..3c2dfa1 100644
14
+--- a/arch/x86/entry/syscalls/syscall_64.tbl
15
+@@ -339,6 +339,14 @@
16
+ 330	common	pkey_alloc		sys_pkey_alloc
17
+ 331	common	pkey_free		sys_pkey_free
18
+ 
19
++
20
++#
21
++# Photon OS specific syscalls.
22
++#
23
++508	common	fsetxattrat		sys_fsetxattrat
24
++509	common	fgetxattrat		sys_fgetxattrat
25
++510	common	flistxattrat		sys_flistxattrat
26
++511	common	fremovexattrat		sys_fremovexattrat
27
+ #
28
+ # x32-specific system call numbers start at 512 to avoid cache impact
29
+ # for native 64-bit operation.
30
+diff --git a/fs/xattr.c b/fs/xattr.c
31
+index f0da9d2..d5e4944 100644
32
+--- a/fs/xattr.c
33
+@@ -419,6 +419,41 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
34
+ 	return error;
35
+ }
36
+ 
37
++SYSCALL_DEFINE6(fsetxattrat, int, fd, const char __user *, pathname,
38
++		const char __user *, name, const void __user *, value,
39
++		size_t, size, int, flags)
40
++{
41
++	struct path path;
42
++	int error;
43
++	unsigned int lookup_flags = 0;
44
++
45
++	if (flags & ~(XATTR_CREATE | XATTR_REPLACE |
46
++		      AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH))
47
++		return -EINVAL;
48
++
49
++	if (!(flags & AT_SYMLINK_NOFOLLOW))
50
++		lookup_flags |= LOOKUP_FOLLOW;
51
++	if (flags & AT_EMPTY_PATH)
52
++		lookup_flags |= LOOKUP_EMPTY;
53
++
54
++retry:
55
++	error = user_path_at(fd, pathname, lookup_flags, &path);
56
++	if (error)
57
++		return error;
58
++	error = mnt_want_write(path.mnt);
59
++	if (!error) {
60
++		error = setxattr(path.dentry, name, value, size,
61
++				 flags & (XATTR_CREATE | XATTR_REPLACE));
62
++		mnt_drop_write(path.mnt);
63
++	}
64
++	path_put(&path);
65
++	if (retry_estale(error, lookup_flags)) {
66
++		lookup_flags |= LOOKUP_REVAL;
67
++		goto retry;
68
++	}
69
++	return error;
70
++}
71
++
72
+ /*
73
+  * Extended attribute GET operations
74
+  */
75
+@@ -513,6 +548,35 @@ SYSCALL_DEFINE4(fgetxattr, int, fd, const char __user *, name,
76
+ 	return error;
77
+ }
78
+ 
79
++SYSCALL_DEFINE6(fgetxattrat, int, fd, const char __user *, pathname,
80
++		const char __user *, name, void __user *, value, size_t, size,
81
++		int, flags)
82
++{
83
++	struct path path;
84
++	ssize_t error;
85
++	unsigned int lookup_flags = 0;
86
++
87
++	if (flags & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH))
88
++		return -EINVAL;
89
++
90
++	if (!(flags & AT_SYMLINK_NOFOLLOW))
91
++		lookup_flags |= LOOKUP_FOLLOW;
92
++	if (flags & AT_EMPTY_PATH)
93
++		lookup_flags |= LOOKUP_EMPTY;
94
++
95
++retry:
96
++	error = user_path_at(fd, pathname, lookup_flags, &path);
97
++	if (error)
98
++		return error;
99
++	error = getxattr(path.dentry, name, value, size);
100
++	path_put(&path);
101
++	if (retry_estale(error, lookup_flags)) {
102
++		lookup_flags |= LOOKUP_REVAL;
103
++		goto retry;
104
++	}
105
++	return error;
106
++}
107
++
108
+ /*
109
+  * Extended attribute LIST operations
110
+  */
111
+@@ -594,6 +658,34 @@ SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)
112
+ 	return error;
113
+ }
114
+ 
115
++SYSCALL_DEFINE5(flistxattrat, int, fd, const char __user *, pathname,
116
++		char __user *, list, size_t, size, int, flags)
117
++{
118
++	struct path path;
119
++	ssize_t error;
120
++	unsigned int lookup_flags = 0;
121
++
122
++	if (flags & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH))
123
++		return -EINVAL;
124
++
125
++	if (!(flags & AT_SYMLINK_NOFOLLOW))
126
++		lookup_flags |= LOOKUP_FOLLOW;
127
++	if (flags & AT_EMPTY_PATH)
128
++		lookup_flags |= LOOKUP_EMPTY;
129
++
130
++retry:
131
++	error = user_path_at(fd, pathname, lookup_flags, &path);
132
++	if (error)
133
++		return error;
134
++	error = listxattr(path.dentry, list, size);
135
++	path_put(&path);
136
++	if (retry_estale(error, lookup_flags)) {
137
++		lookup_flags |= LOOKUP_REVAL;
138
++		goto retry;
139
++	}
140
++	return error;
141
++}
142
++
143
+ /*
144
+  * Extended attribute REMOVE operations
145
+  */
146
+@@ -663,6 +755,38 @@ SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
147
+ 	return error;
148
+ }
149
+ 
150
++SYSCALL_DEFINE4(fremovexattrat, int, fd, const char __user *, pathname,
151
++		const char __user *, name, int, flags)
152
++{
153
++	struct path path;
154
++	int error;
155
++	unsigned int lookup_flags = 0;
156
++
157
++	if (flags & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH))
158
++		return -EINVAL;
159
++
160
++	if (!(flags & AT_SYMLINK_NOFOLLOW))
161
++		lookup_flags |= LOOKUP_FOLLOW;
162
++	if (flags & AT_EMPTY_PATH)
163
++		lookup_flags |= LOOKUP_EMPTY;
164
++
165
++retry:
166
++	error = user_path_at(fd, pathname, lookup_flags, &path);
167
++	if (error)
168
++		return error;
169
++	error = mnt_want_write(path.mnt);
170
++	if (!error) {
171
++		error = removexattr(path.dentry, name);
172
++		mnt_drop_write(path.mnt);
173
++	}
174
++	path_put(&path);
175
++	if (retry_estale(error, lookup_flags)) {
176
++		lookup_flags |= LOOKUP_REVAL;
177
++		goto retry;
178
++	}
179
++	return error;
180
++}
181
++
182
+ /*
183
+  * Combine the results of the list() operation from every xattr_handler in the
184
+  * list.
185
+diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
186
+index c2b66a2..daf1856 100644
187
+--- a/include/linux/syscalls.h
188
+@@ -430,23 +430,32 @@ asmlinkage long sys_lsetxattr(const char __user *path, const char __user *name,
189
+ 			      const void __user *value, size_t size, int flags);
190
+ asmlinkage long sys_fsetxattr(int fd, const char __user *name,
191
+ 			      const void __user *value, size_t size, int flags);
192
++asmlinkage long sys_fsetxattrat(int fd, const char __user *pathname,
193
++				const char __user *name,
194
++				const void __user *value, size_t size, int flags);
195
+ asmlinkage long sys_getxattr(const char __user *path, const char __user *name,
196
+ 			     void __user *value, size_t size);
197
+ asmlinkage long sys_lgetxattr(const char __user *path, const char __user *name,
198
+ 			      void __user *value, size_t size);
199
+ asmlinkage long sys_fgetxattr(int fd, const char __user *name,
200
+ 			      void __user *value, size_t size);
201
++asmlinkage long sys_fgetxattrat(int fd, const char __user *pathname,
202
++				const char __user *name,
203
++				void __user *value, size_t size, int flags);
204
+ asmlinkage long sys_listxattr(const char __user *path, char __user *list,
205
+ 			      size_t size);
206
+ asmlinkage long sys_llistxattr(const char __user *path, char __user *list,
207
+ 			       size_t size);
208
+ asmlinkage long sys_flistxattr(int fd, char __user *list, size_t size);
209
++asmlinkage long sys_flistxattrat(int fd, const char __user *pathname,
210
++				 char __user *list, size_t size, int flags);
211
+ asmlinkage long sys_removexattr(const char __user *path,
212
+ 				const char __user *name);
213
+ asmlinkage long sys_lremovexattr(const char __user *path,
214
+ 				 const char __user *name);
215
+ asmlinkage long sys_fremovexattr(int fd, const char __user *name);
216
+-
217
++asmlinkage long sys_fremovexattrat(int fd, const char __user *pathname,
218
++				   const char __user *name, int flags);
219
+ asmlinkage long sys_brk(unsigned long brk);
220
+ asmlinkage long sys_mprotect(unsigned long start, size_t len,
221
+ 				unsigned long prot);
222
+-- 
223
+2.8.1
224
+
... ...
@@ -2,7 +2,7 @@
2 2
 Summary:        Kernel
3 3
 Name:           linux-aws
4 4
 Version:        4.9.101
5
-Release:        1%{?kat_build:.%kat_build}%{?dist}
5
+Release:        2%{?kat_build:.%kat_build}%{?dist}
6 6
 License:    	GPLv2
7 7
 URL:        	http://www.kernel.org/
8 8
 Group:        	System Environment/Kernel
... ...
@@ -21,6 +21,7 @@ Patch4:         x86-vmware-log-kmsg-dump-on-panic.patch
21 21
 Patch5:         double-tcp_mem-limits.patch
22 22
 Patch6:         linux-4.9-sysctl-sched_weighted_cpuload_uses_rla.patch
23 23
 Patch7:         linux-4.9-watchdog-Disable-watchdog-on-virtual-machines.patch
24
+Patch8:         Implement-the-f-xattrat-family-of-functions.patch
24 25
 Patch9:         SUNRPC-Do-not-reuse-srcport-for-TIME_WAIT-socket.patch
25 26
 Patch10:        SUNRPC-xs_bind-uses-ip_local_reserved_ports.patch
26 27
 Patch11:        vsock-transport-for-9p.patch
... ...
@@ -256,6 +257,7 @@ This package contains the 'perf' performance analysis tools for Linux kernel.
256 256
 %patch5 -p1
257 257
 %patch6 -p1
258 258
 %patch7 -p1
259
+%patch8 -p1
259 260
 %patch9 -p1
260 261
 %patch10 -p1
261 262
 %patch11 -p1
... ...
@@ -557,6 +559,8 @@ ln -sf %{name}-%{uname_r}.cfg /boot/photon.cfg
557 557
 /usr/share/doc/*
558 558
 
559 559
 %changelog
560
+*   Mon May 21 2018 Alexey Makhalov <amakhalov@vmware.com> 4.9.101-2
561
+-   Add the f*xattrat family of syscalls.
560 562
 *   Mon May 21 2018 Srivatsa S. Bhat <srivatsa@csail.mit.edu> 4.9.101-1
561 563
 -   Update to version 4.9.101 and fix CVE-2018-3639.
562 564
 *   Wed May 09 2018 Srivatsa S. Bhat <srivatsa@csail.mit.edu> 4.9.99-1
... ...
@@ -2,7 +2,7 @@
2 2
 Summary:        Kernel
3 3
 Name:           linux-esx
4 4
 Version:        4.9.101
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
... ...
@@ -21,6 +21,7 @@ Patch4:         x86-vmware-log-kmsg-dump-on-panic.patch
21 21
 Patch5:         double-tcp_mem-limits.patch
22 22
 Patch6:         linux-4.9-sysctl-sched_weighted_cpuload_uses_rla.patch
23 23
 Patch7:         linux-4.9-watchdog-Disable-watchdog-on-virtual-machines.patch
24
+Patch8:         Implement-the-f-xattrat-family-of-functions.patch
24 25
 Patch9:         SUNRPC-Do-not-reuse-srcport-for-TIME_WAIT-socket.patch
25 26
 Patch10:        SUNRPC-xs_bind-uses-ip_local_reserved_ports.patch
26 27
 Patch11:        vsock-transport-for-9p.patch
... ...
@@ -172,6 +173,7 @@ The Linux package contains the Linux kernel doc files
172 172
 %patch5 -p1
173 173
 %patch6 -p1
174 174
 %patch7 -p1
175
+%patch8 -p1
175 176
 %patch9 -p1
176 177
 %patch10 -p1
177 178
 %patch11 -p1
... ...
@@ -364,6 +366,8 @@ ln -sf linux-%{uname_r}.cfg /boot/photon.cfg
364 364
 /usr/src/linux-headers-%{uname_r}
365 365
 
366 366
 %changelog
367
+*   Mon May 21 2018 Alexey Makhalov <amakhalov@vmware.com> 4.9.101-2
368
+-   Add the f*xattrat family of syscalls.
367 369
 *   Mon May 21 2018 Srivatsa S. Bhat <srivatsa@csail.mit.edu> 4.9.101-1
368 370
 -   Update to version 4.9.101 and fix CVE-2018-3639.
369 371
 *   Wed May 09 2018 Srivatsa S. Bhat <srivatsa@csail.mit.edu> 4.9.99-1
... ...
@@ -2,7 +2,7 @@
2 2
 Summary:        Kernel
3 3
 Name:           linux-secure
4 4
 Version:        4.9.101
5
-Release:        1%{?kat_build:.%kat_build}%{?dist}
5
+Release:        2%{?kat_build:.%kat_build}%{?dist}
6 6
 License:        GPLv2
7 7
 URL:            http://www.kernel.org/
8 8
 Group:          System Environment/Kernel
... ...
@@ -23,6 +23,7 @@ Patch4:         x86-vmware-log-kmsg-dump-on-panic.patch
23 23
 Patch5:         double-tcp_mem-limits.patch
24 24
 Patch6:         linux-4.9-sysctl-sched_weighted_cpuload_uses_rla.patch
25 25
 Patch7:         linux-4.9-watchdog-Disable-watchdog-on-virtual-machines.patch
26
+Patch8:         Implement-the-f-xattrat-family-of-functions.patch
26 27
 Patch9:         SUNRPC-Do-not-reuse-srcport-for-TIME_WAIT-socket.patch
27 28
 Patch10:        SUNRPC-xs_bind-uses-ip_local_reserved_ports.patch
28 29
 Patch11:        vsock-transport-for-9p.patch
... ...
@@ -224,6 +225,7 @@ EOF
224 224
 %patch5 -p1
225 225
 %patch6 -p1
226 226
 %patch7 -p1
227
+%patch8 -p1
227 228
 %patch9 -p1
228 229
 %patch10 -p1
229 230
 %patch11 -p1
... ...
@@ -453,6 +455,8 @@ ln -sf linux-%{uname_r}.cfg /boot/photon.cfg
453 453
 /usr/src/linux-headers-%{uname_r}
454 454
 
455 455
 %changelog
456
+*   Mon May 21 2018 Alexey Makhalov <amakhalov@vmware.com> 4.9.101-2
457
+-   Add the f*xattrat family of syscalls.
456 458
 *   Mon May 21 2018 Srivatsa S. Bhat <srivatsa@csail.mit.edu> 4.9.101-1
457 459
 -   Update to version 4.9.101 and fix CVE-2018-3639.
458 460
 *   Wed May 09 2018 Srivatsa S. Bhat <srivatsa@csail.mit.edu> 4.9.99-1
... ...
@@ -2,7 +2,7 @@
2 2
 Summary:        Kernel
3 3
 Name:           linux
4 4
 Version:        4.9.101
5
-Release:        1%{?kat_build:.%kat_build}%{?dist}
5
+Release:        2%{?kat_build:.%kat_build}%{?dist}
6 6
 License:    	GPLv2
7 7
 URL:        	http://www.kernel.org/
8 8
 Group:        	System Environment/Kernel
... ...
@@ -24,6 +24,7 @@ Patch4:         x86-vmware-log-kmsg-dump-on-panic.patch
24 24
 Patch5:         double-tcp_mem-limits.patch
25 25
 Patch6:         linux-4.9-sysctl-sched_weighted_cpuload_uses_rla.patch
26 26
 Patch7:         linux-4.9-watchdog-Disable-watchdog-on-virtual-machines.patch
27
+Patch8:         Implement-the-f-xattrat-family-of-functions.patch
27 28
 Patch9:         SUNRPC-Do-not-reuse-srcport-for-TIME_WAIT-socket.patch
28 29
 Patch10:        SUNRPC-xs_bind-uses-ip_local_reserved_ports.patch
29 30
 Patch11:        vsock-transport-for-9p.patch
... ...
@@ -215,6 +216,7 @@ This package contains the 'perf' performance analysis tools for Linux kernel.
215 215
 %patch5 -p1
216 216
 %patch6 -p1
217 217
 %patch7 -p1
218
+%patch8 -p1
218 219
 %patch9 -p1
219 220
 %patch10 -p1
220 221
 %patch11 -p1
... ...
@@ -479,6 +481,8 @@ ln -sf %{name}-%{uname_r}.cfg /boot/photon.cfg
479 479
 /usr/share/doc/*
480 480
 
481 481
 %changelog
482
+*   Mon May 21 2018 Alexey Makhalov <amakhalov@vmware.com> 4.9.101-2
483
+-   Add the f*xattrat family of syscalls.
482 484
 *   Mon May 21 2018 Srivatsa S. Bhat <srivatsa@csail.mit.edu> 4.9.101-1
483 485
 -   Update to version 4.9.101 and fix CVE-2018-3639.
484 486
 *   Wed May 09 2018 Srivatsa S. Bhat <srivatsa@csail.mit.edu> 4.9.99-1