let import_iovec deal with compat_iovecs as well v2
Subsystems (24)
Hi Al,
this series changes import_iovec to transparently deal with comat iovec structures, and then cleanups up a lot of code dupliation.
Changes since v1:
- improve a commit message
- drop a pointless unlikely
- drop the PF_FORCE_COMPAT flag
- add a few more cleanups (including two from David Laight)
Diffstat:
arch/arm64/include/asm/unistd32.h | 10 arch/mips/kernel/syscalls/syscall_n32.tbl | 10 arch/mips/kernel/syscalls/syscall_o32.tbl | 10 arch/parisc/kernel/syscalls/syscall.tbl | 10 arch/powerpc/kernel/syscalls/syscall.tbl | 10 arch/s390/kernel/syscalls/syscall.tbl | 10 arch/sparc/kernel/syscalls/syscall.tbl | 10 arch/x86/entry/syscall_x32.c | 5 arch/x86/entry/syscalls/syscall_32.tbl | 10 arch/x86/entry/syscalls/syscall_64.tbl | 10 block/scsi_ioctl.c | 12 drivers/scsi/sg.c | 9 fs/aio.c | 38 -- fs/io_uring.c | 20 - fs/read_write.c | 362 +-------------------- fs/splice.c | 57 --- include/linux/compat.h | 24 - include/linux/fs.h | 11 include/linux/uio.h | 10 include/uapi/asm-generic/unistd.h | 12 lib/iov_iter.c | 161 +++++++-- mm/process_vm_access.c | 85 ---- net/compat.c | 4 security/keys/compat.c | 37 -- security/keys/internal.h | 5 security/keys/keyctl.c | 2 tools/include/uapi/asm-generic/unistd.h | 12 tools/perf/arch/powerpc/entry/syscalls/syscall.tbl | 10 tools/perf/arch/s390/entry/syscalls/syscall.tbl | 10 tools/perf/arch/x86/entry/syscalls/syscall_64.tbl | 10 30 files changed, 280 insertions(+), 706 deletions(-)
PATCH 1/11 compat.h: fix a spelling error in <linux/compat.h>
There is no compat_sys_readv64v2 syscall, only a compat_sys_preadv64v2 one.
--- include/linux/compat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/compat.h +1 -1
@@ -812,7 +812,7 @@ asmlinkage ssize_t compat_sys_pwritev2(compat_ulong_t fd,const struct compat_iovec __user *vec, compat_ulong_t vlen, u32 pos_low, u32 pos_high, rwf_t flags);#ifdef __ARCH_WANT_COMPAT_SYS_PREADV64V2 -asmlinkage long compat_sys_readv64v2 (unsigned long fd, +asmlinkage long compat_sys_preadv64v2 (unsigned long fd,const struct compat_iovec __user *vec,unsigned long vlen,loff_t pos,rwf_t flags);#endif
Signature · 1 line
2.28.0
PATCH 2/11 mm: call import_iovec() instead of rw_copy_check_uvector() in process_vm_rw()
In reply to Christoph HellwigFrom: David Laight <[email protected]>
This is the only direct call of rw_copy_check_uvector(). Removing it will allow rw_copy_check_uvector() to be inlined into import_iovec(), while only paying a minor price by setting up an otherwise unused iov_iter in the process_vm_readv/process_vm_writev syscalls that aren't in a super hot path.
[hch: expanded the commit log, pass CHECK_IOVEC_ONLY instead of 0 for the
compat case, handle CHECK_IOVEC_ONLY in iov_iter_init]
--- lib/iov_iter.c | 2 +- mm/process_vm_access.c | 33 ++++++++++++++++++--------------- 2 files changed, 19 insertions(+), 16 deletions(-)
lib/iov_iter.c +1 -1
@@ -443,7 +443,7 @@ void iov_iter_init(struct iov_iter *i, unsigned int direction, const struct iovec *iov, unsigned long nr_segs, size_t count) { - WARN_ON(direction & ~(READ | WRITE)); + WARN_ON(direction & ~(READ | WRITE | CHECK_IOVEC_ONLY)); direction &=READ |WRITE ;/* It will get better. Eventually... */
mm/process_vm_access.c +18 -15
@@ -264,7 +264,7 @@ static ssize_t process_vm_rw(pid_t pid,struct iovec iovstack_r[UIO_FASTIOV ];struct iovec *iov_l = iovstack_l;struct iovec *iov_r = iovstack_r; -struct iov_iter iter; +struct iov_iter iter_l, iter_r;ssize_t rc;int dir = vm_write ?WRITE :READ ;
@@ -272,23 +272,25 @@ static ssize_t process_vm_rw(pid_t pid,return -EINVAL ;/* Check iovecs */ - rc =import_iovec (dir, lvec, liovcnt,UIO_FASTIOV , &iov_l, &iter); + rc =import_iovec (dir, lvec, liovcnt,UIO_FASTIOV , &iov_l, &iter_l);if (rc <0 )return rc; -if (!iov_iter_count (&iter)) +if (!iov_iter_count (&iter_l)) goto free_iovecs; - rc =rw_copy_check_uvector (CHECK_IOVEC_ONLY , rvec, riovcnt,UIO_FASTIOV , - iovstack_r, &iov_r); + rc =import_iovec (CHECK_IOVEC_ONLY , rvec, riovcnt,UIO_FASTIOV , &iov_r, + &iter_r);if (rc <=0 ) goto free_iovecs; - rc =process_vm_rw_core (pid, &iter, iov_r, riovcnt, flags, vm_write); + rc =process_vm_rw_core (pid, &iter_l, iter_r.iov, iter_r.nr_segs, + flags, vm_write); free_iovecs:if (iov_r != iovstack_r)kfree (iov_r); -kfree (iov_l); +if (iov_l != iovstack_l) +kfree (iov_l);return rc; }
@@ -322,30 +324,31 @@ compat_process_vm_rw(compat_pid_t pid,struct iovec iovstack_r[UIO_FASTIOV ];struct iovec *iov_l = iovstack_l;struct iovec *iov_r = iovstack_r; -struct iov_iter iter; +struct iov_iter iter_l, iter_r;ssize_t rc = -EFAULT ;int dir = vm_write ?WRITE :READ ;if (flags !=0 )return -EINVAL ; - rc =compat_import_iovec (dir, lvec, liovcnt,UIO_FASTIOV , &iov_l, &iter); + rc =compat_import_iovec (dir, lvec, liovcnt,UIO_FASTIOV , &iov_l, &iter_l);if (rc <0 )return rc; -if (!iov_iter_count (&iter)) +if (!iov_iter_count (&iter_l)) goto free_iovecs; - rc =compat_rw_copy_check_uvector (CHECK_IOVEC_ONLY , rvec, riovcnt, -UIO_FASTIOV , iovstack_r, - &iov_r); + rc =compat_import_iovec (CHECK_IOVEC_ONLY , rvec, riovcnt,UIO_FASTIOV , + &iov_r, &iter_r);if (rc <=0 ) goto free_iovecs; - rc =process_vm_rw_core (pid, &iter, iov_r, riovcnt, flags, vm_write); + rc =process_vm_rw_core (pid, &iter_l, iter_r.iov, iter_r.nr_segs, + flags, vm_write); free_iovecs:if (iov_r != iovstack_r)kfree (iov_r); -kfree (iov_l); +if (iov_l != iovstack_l) +kfree (iov_l);return rc; }
Signature · 1 line
2.28.0
Re: [PATCH 02/11] mm: call import_iovec() instead of rw_copy_check_uvector() in process_vm_rw()
lib/iov_iter.c void iov_iter_init(struct iov_iter *i, unsigned int direction, · line 446
Quoted 3 lines · Christoph Hellwig
{
lib/iov_iter.c +1
-1-WARN_ON (direction & ~(READ |WRITE )); +WARN_ON (direction & ~(READ |WRITE |CHECK_IOVEC_ONLY ));
This is now a no-op because:
include/linux/fs.h:#define CHECK_IOVEC_ONLY -1
I'd suggest we renumber it to 2?
(READ is 0, WRITE is 1. This WARN_ON should probably be
WARN_ON(direction > CHECK_IOVEC_ONLY)
Al Viro
maintainerRe: [PATCH 02/11] mm: call import_iovec() instead of rw_copy_check_uvector() in process_vm_rw()
In reply to Christoph HellwigQuoted 9 lines · Christoph Hellwig
From: David Laight <[email protected]>
This is the only direct call of
rw_copy_check_uvector(). Removing it will allowrw_copy_check_uvector()to be inlined intoimport_iovec(), while only paying a minor price by setting up an otherwise unusediov_iterin the process_vm_readv/process_vm_writev syscalls that aren't in a super hot path.
lib/iov_iter.c void iov_iter_init(struct iov_iter *i, unsigned int direction, · line 447
Quoted 6 lines
lib/iov_iter.c +1
-1@@ -443,7 +443,7 @@ void iov_iter_init(struct iov_iter *i, unsigned int direction, const struct iovec *iov, unsigned long nr_segs, size_t count) { - WARN_ON(direction & ~(READ | WRITE)); + WARN_ON(direction & ~(READ | WRITE | CHECK_IOVEC_ONLY)); direction &=READ |WRITE ;
Ugh...
mm/process_vm_access.c static ssize_t process_vm_rw(pid_t pid, · line 287
Quoted 10 lines
mm/process_vm_access.c +2
-2- rc =rw_copy_check_uvector (CHECK_IOVEC_ONLY , rvec, riovcnt,UIO_FASTIOV , - iovstack_r, &iov_r); + rc =import_iovec (CHECK_IOVEC_ONLY , rvec, riovcnt,UIO_FASTIOV , &iov_r, + &iter_r);mm/process_vm_access.c +2
-1if (rc <=0 ) goto free_iovecs; - rc =process_vm_rw_core (pid, &iter, iov_r, riovcnt, flags, vm_write); + rc =process_vm_rw_core (pid, &iter_l, iter_r.iov, iter_r.nr_segs, + flags, vm_write);
... and ugh^2, since now you are not only setting a meaningless iov_iter, you are creating a new place that pokes directly into struct iov_iter guts.
Sure, moving rw_copy_check_uvector() over to lib/iov_iter.c makes sense. But I would rather split the access_ok()-related checks out of that thing and bury CHECK_IOVEC_ONLY.
Step 1: move the damn thing to lib/iov_iter.c (same as you do, but without making it static)
Step 2: split it in two:
ssize_t rw_copy_check_uvector(const struct iovec __user * uvector,
unsigned long nr_segs, unsigned long fast_segs, struct iovec *fast_pointer,
struct iovec **ret_pointer)
{
unsigned long seg;
ssize_t ret;
struct iovec *iov = fast_pointer;
*ret_pointer = fast_pointer;
/*
* SuS says "The readv() function *may* fail if the iovcnt argument
* was less than or equal to 0, or greater than {IOV_MAX}. Linux has
* traditionally returned zero for zero segments, so...
*/
if (nr_segs = 0)
return 0;
/*
* First get the "struct iovec" from user memory and
* verify all the pointers
*/
if (nr_segs > UIO_MAXIOV)
return -EINVAL;
if (nr_segs > fast_segs) {
iov = kmalloc_array(nr_segs, sizeof(struct iovec), GFP_KERNEL);
if (!iov)
return -ENOMEM;
*ret_pointer = iov;
}
if (copy_from_user(iov, uvector, nr_segs*sizeof(*uvector)))
return -EFAULT;
/*
* According to the Single Unix Specification we should return EINVAL
* if an element length is < 0 when cast to ssize_t or if the
* total length would overflow the ssize_t return value of the
* system call.
*
* Linux caps all read/write calls to MAX_RW_COUNT, and avoids the
* overflow case.
*/
ret = 0;
for (seg = 0; seg < nr_segs; seg++) {
void __user *buf = iov[seg].iov_base;
ssize_t len = (ssize_t)iov[seg].iov_len;
/* see if we we're about to use an invalid len or if
* it's about to overflow ssize_t */
if (len < 0)
return -EINVAL;
if (len > MAX_RW_COUNT - ret) {
len = MAX_RW_COUNT - ret;
iov[seg].iov_len = len;
}
ret += len;
}
return ret;
}/*
* This is merely an early sanity check; we do _not_ rely upon
* it when we get to the actual memory accesses.
*/
static bool check_iovecs(const struct iovec *iov, int nr_segs)
{
for (seg = 0; seg < nr_segs; seg++) {
void __user *buf = iov[seg].iov_base;
ssize_t len = (ssize_t)iov[seg].iov_len;
if (unlikely(!access_ok(buf, len)))
return false;
}
return true;
}ssize_t import_iovec(int type, const struct iovec __user * uvector,
unsigned nr_segs, unsigned fast_segs, struct iovec **iov, struct iov_iter *i)
{
struct iovec *p;
ssize_t n;
n = rw_copy_check_uvector(uvector, nr_segs, fast_segs, *iov, &p);
if (n > 0 && !check_iovecs(p, nr_segs))
n = -EFAULT;
if (n < 0) {
if (p != *iov)
kfree(p);
*iov = NULL;
return n;
}
iov_iter_init(i, type, p, nr_segs, n);
*iov = p = *iov ? NULL : p;
return n;
}kill CHECK_IOVEC_ONLY and use rw_copy_check_uvector() without the type argument in mm/process_vm_access.c
Saner that way, IMO...
RE: [PATCH 02/11] mm: call import_iovec() instead of rw_copy_check_uvector() in process_vm_rw()
From: Al Viro
Quoted 51 lines
Sent: 21 September 2020 16:02
Quoted 9 lines · Christoph Hellwig
From: David Laight <[email protected]>
This is the only direct call of
rw_copy_check_uvector(). Removing it will allowrw_copy_check_uvector()to be inlined intoimport_iovec(), while only paying a minor price by setting up an otherwise unusediov_iterin the process_vm_readv/process_vm_writev syscalls that aren't in a super hot path.lib/iov_iter.c void iov_iter_init(struct iov_iter *i, unsigned int direction, · line 447
Quoted 6 lines
lib/iov_iter.c +1
-1@@ -443,7 +443,7 @@ void iov_iter_init(struct iov_iter *i, unsigned int direction, const struct iovec *iov, unsigned long nr_segs, size_t count) { - WARN_ON(direction & ~(READ | WRITE)); + WARN_ON(direction & ~(READ | WRITE | CHECK_IOVEC_ONLY)); direction &=READ |WRITE ;Ugh...
mm/process_vm_access.c static ssize_t process_vm_rw(pid_t pid, · line 287
Quoted 10 lines
mm/process_vm_access.c +2
-2- rc =rw_copy_check_uvector (CHECK_IOVEC_ONLY , rvec, riovcnt,UIO_FASTIOV , - iovstack_r, &iov_r); + rc =import_iovec (CHECK_IOVEC_ONLY , rvec, riovcnt,UIO_FASTIOV , &iov_r, + &iter_r);mm/process_vm_access.c +2
-1if (rc <=0 ) goto free_iovecs; - rc =process_vm_rw_core (pid, &iter, iov_r, riovcnt, flags, vm_write); + rc =process_vm_rw_core (pid, &iter_l, iter_r.iov, iter_r.nr_segs, + flags, vm_write);... and ugh^2, since now you are not only setting a meaningless
iov_iter, you are creating a new place that pokes directly into structiov_iterguts.Sure, moving
rw_copy_check_uvector()over tolib/iov_iter.cmakes sense. But I would rather split the access_ok()-related checks out of that thing and buryCHECK_IOVEC_ONLY.Step 1: move the damn thing to
lib/iov_iter.c(same as you do, but without making it static)Step 2: split it in two:
ssize_trw_copy_check_uvector(const struct iovec__user* uvector,
unsigned longnr_segs, unsigned longfast_segs, struct iovec*fast_pointer,
struct iovec **ret_pointer){ unsigned long seg;
...
Quoted 23 lines
ret = 0; for (seg = 0; seg < nr_segs; seg++) { void __user *buf = iov[seg].iov_base; ssize_t len = (ssize_t)iov[seg].iov_len; /* see if we we're about to use an invalid len or if * it's about to overflow ssize_t */ if (len < 0) return -EINVAL; if (len > MAX_RW_COUNT - ret) { len = MAX_RW_COUNT - ret; iov[seg].iov_len = len; } ret += len; } return ret; }/*
* This is merely an early sanity check; we do _not_ rely upon
* it when we get to the actual memory accesses.
*/
static boolcheck_iovecs(const struct iovec *iov, int nr_segs)
Quoted 10 lines
{
for (seg = 0; seg < nr_segs; seg++) {
void __user *buf = iov[seg].iov_base;
ssize_t len = (ssize_t)iov[seg].iov_len;
if (unlikely(!access_ok(buf, len)))
return false;
}
return true;
}You really don't want to be looping through the array twice. In fact you don't really want to be doing all those tests at all. This code makes a significant fraction of the not-insignificant difference between the 'costs' of send() and sendmsg().
I think the 'length' check can be optimised to do something like:
for (...) {
ssize_t len = (ssize_t)iov[seg].iov_len;
ret += len;
len_hi += (unsigned long)len >> 20;
}
if (len_hi) {
/* Something potentially odd in the lengths.
* Might just be a very long fragment.
* Check the individial values. */
Add the exiting loop here.
}
David-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Al Viro
maintainerRe: [PATCH 02/11] mm: call import_iovec() instead of rw_copy_check_uvector() in process_vm_rw()
Quoted 1 line · David Laight
You really don't want to be looping through the array twice.
Profiles, please.
Quoted 12 lines
I think the 'length' check can be optimised to do something like:
for (...) { ssize_t len = (ssize_t)iov[seg].iov_len; ret += len; len_hi += (unsigned long)len >> 20; } if (len_hi) { /* Something potentially odd in the lengths. * Might just be a very long fragment. * Check the individial values. */ Add the exiting loop here. }
Far too ugly to live.
RE: [PATCH 02/11] mm: call import_iovec() instead of rw_copy_check_uvector() in process_vm_rw()
From: Al Viro
Quoted 7 lines
Sent: 21 September 2020 16:30
Quoted 1 line · David Laight
You really don't want to be looping through the array twice.
Profiles, please.
I did some profiling of send() v sendmsg() much earlier in the year. I can't remember the exact details but the extra cost of sendmsg() is far more than you might expect.
(I was timing sending fully built IPv4 UDP packets using a raw socket.)
About half the difference does away if you change the copy_from_user() to __copy_from_user() when reading the struct msghdr and iov[] from userspace (user copy hardening is expensive).
The rest is just code path, my gut feeling is that a lot of that is in import_iovec().
Remember semdmsg() is likely to be called with an iov count of 1.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Al Viro
maintainerRe: [PATCH 02/11] mm: call import_iovec() instead of rw_copy_check_uvector() in process_vm_rw()
Quoted 9 lines · David Laight
From: Al Viro
Quoted 7 lines
Sent: 21 September 2020 16:30
Quoted 1 line · David Laight
You really don't want to be looping through the array twice.
Profiles, please.
Quoted 8 lines
I did some profiling of
send()vsendmsg()much earlier in the year. I can't remember the exact details but the extra cost ofsendmsg()is far more than you might expect.
(I was timing sending fully built IPv4 UDP packets using a raw socket.)About half the difference does away if you change the
copy_from_user()to__copy_from_user()when reading the struct msghdr and iov[] from userspace (user copy hardening is expensive).
Wha...? So the difference is within 4 times the overhead of the hardening checks done for one call of copy_from_user()?
Quoted 4 lines
The rest is just code path, my gut feeling is that a lot of that is in
import_iovec().Remember
semdmsg()is likely to be called with an iov count of 1.
... which makes that loop unlikely to be noticable in the entire mess, whether you pass it once or twice. IOW, unless you can show profiles where that loop is sufficiently hot or if you can show the timings change from splitting it in two, I'll remain very sceptical about that assertion.
Re: [PATCH 02/11] mm: call import_iovec() instead of rw_copy_check_uvector() in process_vm_rw()
In reply to Al ViroQuoted 5 lines · Al Viro
Quoted 1 line · David Laight
You really don't want to be looping through the array twice.
Profiles, please.
Given that the iov array should be cache hot I'd be surprised to see a huge difference.
PATCH 3/11 iov_iter: move rw_copy_check_uvector() into lib/iov_iter.c and mark it static
In reply to Christoph HellwigFrom: David Laight <[email protected]>
This lets the compiler inline it into import_iovec() generating much better code.
[hch: drop the now pointless kerneldoc for a static function, and update
a few other comments]
--- fs/read_write.c | 179 ----------------------------------------- include/linux/compat.h | 6 -- include/linux/fs.h | 11 +-- lib/iov_iter.c | 150 +++++++++++++++++++++++++++++++++- 4 files changed, 151 insertions(+), 195 deletions(-)
fs/read_write.c +0 -179
@@ -752,185 +752,6 @@ static ssize_t do_loop_readv_writev(struct file *filp, struct iov_iter *iter,return ret; } -/** -* rw_copy_check_uvector() - Copy an array of &struct iovec from userspace -* into the kernel and check that it is valid. -* -* @type: One of %CHECK_IOVEC_ONLY, %READ, or %WRITE. -* @uvector: Pointer to the userspace array. -* @nr_segs: Number of elements in userspace array. -* @fast_segs: Number of elements in @fast_pointer. -* @fast_pointer: Pointer to (usually small on-stack) kernel array. -* @ret_pointer: (output parameter) Pointer to a variable that will point to -* either @fast_pointer, a newly allocated kernel array, or NULL, -* depending on which array was used. -* -* This function copies an array of &struct iovec of @nr_segs from -* userspace into the kernel and checks that each element is valid (e.g. -* it does not point to a kernel address or cause overflow by being too -* large, etc.). -* -* As an optimization, the caller may provide a pointer to a small -* on-stack array in @fast_pointer, typically %UIO_FASTIOV elements long -* (the size of this array, or 0 if unused, should be given in @fast_segs). -* -* @ret_pointer will always point to the array that was used, so the -* caller must take care not to call kfree() on it e.g. in case the -* @fast_pointer array was used and it was allocated on the stack. -* -* Return: The total number of bytes covered by the iovec array on success -* or a negative error code on error. -*/ -ssize_t rw_copy_check_uvector (int type,const struct iovec __user * uvector, -unsigned long nr_segs,unsigned long fast_segs, -struct iovec *fast_pointer, -struct iovec **ret_pointer) -{ -unsigned long seg; -ssize_t ret; -struct iovec *iov = fast_pointer; - -/* -* SuS says "The readv() function *may* fail if the iovcnt argument -* was less than or equal to 0, or greater than {IOV_MAX}. Linux has -* traditionally returned zero for zero segments, so... -*/ -if (nr_segs =0 ) { - ret =0 ; - goto out; - } - -/* -* First get the "struct iovec" from user memory and -* verify all the pointers -*/ -if (nr_segs >UIO_MAXIOV ) { - ret = -EINVAL ; - goto out; - } -if (nr_segs > fast_segs) { - iov =kmalloc_array (nr_segs,sizeof (struct iovec ),GFP_KERNEL ); -if (iov =NULL ) { - ret = -ENOMEM ; - goto out; - } - } -if (copy_from_user (iov, uvector, nr_segs*sizeof (*uvector))) { - ret = -EFAULT ; - goto out; - } - -/* -* According to the Single Unix Specification we should return EINVAL -* if an element length is < 0 when cast to ssize_t or if the -* total length would overflow the ssize_t return value of the -* system call. -* -* Linux caps all read/write calls to MAX_RW_COUNT, and avoids the -* overflow case. -*/ - ret =0 ; -for (seg =0 ; seg < nr_segs; seg++) { -void __user *buf = iov[seg].iov_base; -ssize_t len = (ssize_t )iov[seg].iov_len; - -/* see if we we're about to use an invalid len or if -* it's about to overflow ssize_t */ -if (len <0 ) { - ret = -EINVAL ; - goto out; - } -if (type >=0 - &&unlikely (!access_ok (buf, len))) { - ret = -EFAULT ; - goto out; - } -if (len >MAX_RW_COUNT - ret) { - len =MAX_RW_COUNT - ret; - iov[seg].iov_len = len; - } - ret += len; - } -out: - *ret_pointer = iov; -return ret; -} - -#ifdef CONFIG_COMPAT -ssize_t compat_rw_copy_check_uvector (int type, -const struct compat_iovec __user *uvector,unsigned long nr_segs, -unsigned long fast_segs,struct iovec *fast_pointer, -struct iovec **ret_pointer) -{ -compat_ssize_t tot_len; -struct iovec *iov = *ret_pointer = fast_pointer; -ssize_t ret =0 ; -int seg; - -/* -* SuS says "The readv() function *may* fail if the iovcnt argument -* was less than or equal to 0, or greater than {IOV_MAX}. Linux has -* traditionally returned zero for zero segments, so... -*/ -if (nr_segs =0 ) - goto out; - - ret = -EINVAL ; -if (nr_segs >UIO_MAXIOV ) - goto out; -if (nr_segs > fast_segs) { - ret = -ENOMEM ; - iov =kmalloc_array (nr_segs,sizeof (struct iovec ),GFP_KERNEL ); -if (iov =NULL ) - goto out; - } - *ret_pointer = iov; - - ret = -EFAULT ; -if (!access_ok (uvector, nr_segs*sizeof (*uvector))) - goto out; - -/* -* Single unix specification: -* We should -EINVAL if an element length is not >= 0 and fitting an -* ssize_t. -* -* In Linux, the total length is limited to MAX_RW_COUNT, there is -* no overflow possibility. -*/ - tot_len =0 ; - ret = -EINVAL ; -for (seg =0 ; seg < nr_segs; seg++) { -compat_uptr_t buf; -compat_ssize_t len; - -if (__get_user (len, &uvector->iov_len) || -__get_user (buf, &uvector->iov_base)) { - ret = -EFAULT ; - goto out; - } -if (len <0 )/* size_t not fitting in compat_ssize_t .. */ - goto out; -if (type >=0 && - !access_ok (compat_ptr (buf), len)) { - ret = -EFAULT ; - goto out; - } -if (len >MAX_RW_COUNT - tot_len) - len =MAX_RW_COUNT - tot_len; - tot_len += len; - iov->iov_base =compat_ptr (buf); - iov->iov_len = (compat_size_t ) len; - uvector++; - iov++; - } - ret = tot_len; - -out: -return ret; -} -#endif -static ssize_t do_iter_read (struct file *file,struct iov_iter *iter,loff_t *pos,rwf_t flags) {
include/linux/compat.h +0 -6
@@ -451,12 +451,6 @@ extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,struct epoll_event ;/* fortunately, this one is fixed-layout */ -extern ssize_t compat_rw_copy_check_uvector (int type, -const struct compat_iovec __user *uvector, -unsigned long nr_segs, -unsigned long fast_segs,struct iovec *fast_pointer, -struct iovec **ret_pointer); -extern void __user *compat_alloc_user_space (unsigned long len);int compat_restore_altstack (const compat_stack_t __user *uss);
include/linux/fs.h +2 -9
@@ -179,10 +179,8 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset,#define FMODE_BUF_RASYNC ((__force fmode_t)0x40000000)/* -* Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector -* that indicates that they should check the contents of the iovec are -* valid, but not check the memory that the iovec elements -* points too. +* Flag for import_iovec that indicates that it should check the contents of the +* iovec is valid, but not check the memory that the iovec elements points too. */ #define CHECK_IOVEC_ONLY -1
@@ -1887,11 +1885,6 @@ static inline int call_mmap(struct file *file, struct vm_area_struct *vma)return file->f_op->mmap (file, vma); } -ssize_t rw_copy_check_uvector (int type,const struct iovec __user * uvector, -unsigned long nr_segs,unsigned long fast_segs, -struct iovec *fast_pointer, -struct iovec **ret_pointer); -extern ssize_t vfs_read (struct file *,char __user *,size_t ,loff_t *);extern ssize_t vfs_write (struct file *,const char __user *,size_t ,loff_t *); extern ssize_t vfs_readv(struct file *, const struct iovec __user *,
lib/iov_iter.c +149 -1
167 lines not on this page · raw message
Signature · 1 line
2.28.0
PATCH 4/11 iov_iter: explicitly check for CHECK_IOVEC_ONLY in rw_copy_check_uvector
In reply to Christoph HellwigExplicitly check for the magic value insted of implicitly relying on
its numeric representation. Also drop the rather pointless unlikely
annotation.
--- lib/iov_iter.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
lib/iov_iter.c +2 -3
@@ -1709,8 +1709,7 @@ static ssize_t rw_copy_check_uvector(int type, ret = -EINVAL ; goto out; } -if (type >=0 - &&unlikely (!access_ok (buf, len))) { +if (type !=CHECK_IOVEC_ONLY && !access_ok (buf, len)) { ret = -EFAULT ; goto out; }
@@ -1824,7 +1823,7 @@ static ssize_t compat_rw_copy_check_uvector(int type, }if (len <0 )/* size_t not fitting in compat_ssize_t .. */ goto out; -if (type >=0 && +if (type !=CHECK_IOVEC_ONLY && !access_ok (compat_ptr (buf), len)) { ret = -EFAULT ; goto out;
Signature · 1 line
2.28.0
RE: [PATCH 04/11] iov_iter: explicitly check for CHECK_IOVEC_ONLY in rw_copy_check_uvector
From: Christoph Hellwig
Quoted 35 lines
Sent: 21 September 2020 15:34
Explicitly check for the magic value insted of implicitly relying on
its numeric representation. Also drop the rather pointless unlikely
annotation.Signed-off-by Christoph Hellwig <[email protected]>--- lib/iov_iter.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)lib/iov_iter.c +2
-4@@ -1709,8 +1709,7 @@ static ssize_t rw_copy_check_uvector(int type, ret = -EINVAL ; goto out; } -if (type >=0 - &&unlikely (!access_ok (buf, len))) { +if (type !=CHECK_IOVEC_ONLY && !access_ok (buf, len)) { ret = -EFAULT ; goto out; }@@ -1824,7 +1823,7 @@ static ssize_t compat_rw_copy_check_uvector(int type, }if (len <0 )/* size_t not fitting in compat_ssize_t .. */ goto out; -if (type >=0 && +if (type !=CHECK_IOVEC_ONLY && !access_ok (compat_ptr (buf), len)) { ret = -EFAULT ; goto out; --
Quoted 1 line
2.28.0
I've actually no idea:
1) Why there is an access_ok() check here.
It will be repeated by the user copy functions.
2) Why it isn't done when called from mm/process_vm_access.c. Ok, the addresses refer to a different process, but they must still be valid user addresses.
Is 2 a legacy from when access_ok() actually checked that the addresses were mapped into the process's address space?
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Al Viro
maintainerRe: [PATCH 04/11] iov_iter: explicitly check for CHECK_IOVEC_ONLY in rw_copy_check_uvector
Quoted 3 lines · David Laight
I've actually no idea:
1) Why there is anaccess_ok()check here. It will be repeated by the user copy functions.
Early sanity check.
Quoted 6 lines
2) Why it isn't done when called from
mm/process_vm_access.c. Ok, the addresses refer to a different process, but they must still be valid user addresses.Is 2 a legacy from when
access_ok()actually checked that the addresses were mapped into the process's address space?
It never did. 2 is for the situation when a 32bit process accesses 64bit one; addresses that are perfectly legitimate for 64bit userland (and fitting into the first 4Gb of address space, so they can be represented by 32bit pointers just fine) might be rejected by access_ok() if the caller is 32bit.
RE: [PATCH 04/11] iov_iter: explicitly check for CHECK_IOVEC_ONLY in rw_copy_check_uvector
From: Al Viro
Quoted 13 lines
Sent: 21 September 2020 16:11
Quoted 3 lines · David Laight
I've actually no idea:
1) Why there is anaccess_ok()check here. It will be repeated by the user copy functions.Early sanity check.
Quoted 4 lines
2) Why it isn't done when called from
mm/process_vm_access.c. Ok, the addresses refer to a different process, but they must still be valid user addresses.
Quoted 8 lines
Quoted 2 lines
Is 2 a legacy from when
access_ok()actually checked that the addresses were mapped into the process's address space?It never did. 2 is for the situation when a 32bit process accesses 64bit one; addresses that are perfectly legitimate for 64bit userland (and fitting into the first 4Gb of address space, so they can be represented by 32bit pointers just fine) might be rejected by
access_ok()if the caller is 32bit.
Can't 32 bit processes on a 64bit system access all the way to 4GB? Mapping things by default above 3GB will probably break things. But there is no reason to disallow explicit maps.
And in any case access_ok() can use the same limit as it does for 64bit processes - the page fault handler will sort it all out.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Al Viro
maintainerRe: [PATCH 04/11] iov_iter: explicitly check for CHECK_IOVEC_ONLY in rw_copy_check_uvector
In reply to Christoph HellwigQuoted 3 lines · Christoph Hellwig
Explicitly check for the magic value insted of implicitly relying on
its numeric representation. Also drop the rather pointless unlikely
annotation.
See above - I would rather have CHECK_IOVEC_ONLY gone.
The reason for doing these access_ok() in the same loop is fairly weak, especially since you are checking type on each iteration. Might as well do that in a separate loop afterwards.
PATCH 5/11 iov_iter: merge the compat case into rw_copy_check_uvector
In reply to Christoph HellwigStop duplicating the iovec verify code, and instead add add a __import_iovec helper that does the whole verify and import, but takes a bool compat to decided on the native or compat layout. This also ends up massively simplifying the calling conventions.
--- lib/iov_iter.c | 195 ++++++++++++++++++------------------------------- 1 file changed, 70 insertions(+), 125 deletions(-)
lib/iov_iter.c +69 -125
@@ -10,6 +10,7 @@#include <net/checksum.h> #include <linux/scatterlist.h> #include <linux/instrumented.h> +#include <linux/compat.h> #define PIPE_PARANOIA /* for now */
@@ -1650,43 +1651,76 @@ const void *dup_iter(struct iov_iter *new, struct iov_iter *old, gfp_t flags) }EXPORT_SYMBOL (dup_iter); -static ssize_t rw_copy_check_uvector (int type, -const struct iovec __user *uvector,unsigned long nr_segs, -unsigned long fast_segs,struct iovec *fast_pointer, -struct iovec **ret_pointer) +static int compat_copy_iovecs_from_user (struct iovec *iov, +const struct iovec __user *uvector,unsigned long nr_segs) +{ + const struct compat_iovec __user *uiov + (const struct compat_iovec __user *)uvector; +unsigned long i; +int ret = -EFAULT ; + +if (!user_access_begin (uvector, nr_segs *sizeof (*uvector))) +return -EFAULT ; + +for (i =0 ; i < nr_segs; i++) { +compat_uptr_t buf; +compat_ssize_t len; + +unsafe_get_user (len, &uiov[i].iov_len, out); +unsafe_get_user (buf, &uiov[i].iov_base, out); + +/* check for compat_size_t not fitting in compat_ssize_t .. */ +if (len <0 ) { + ret = -EINVAL ; + goto out; + } + iov[i].iov_base =compat_ptr (buf); + iov[i].iov_len = len; + } + ret =0 ; +out: +user_access_end (); +return ret; +} + +static ssize_t __import_iovec (int type,const struct iovec __user *uvector, +unsigned nr_segs,unsigned fast_segs,struct iovec **iovp, +struct iov_iter *i,bool compat) { +struct iovec *iov = *iovp;unsigned long seg; -ssize_t ret; -struct iovec *iov = fast_pointer; +ssize_t ret =0 ;/* * SuS says "The readv() function *may* fail if the iovcnt argument * was less than or equal to 0, or greater than {IOV_MAX}. Linux has * traditionally returned zero for zero segments, so... */ -if (nr_segs =0 ) { - ret =0 ; - goto out; - } +if (nr_segs =0 ) + goto done;/* * First get the "struct iovec" from user memory and * verify all the pointers */ -if (nr_segs >UIO_MAXIOV ) { - ret = -EINVAL ; - goto out; - } + ret = -EINVAL ; +if (nr_segs >UIO_MAXIOV ) + goto fail;if (nr_segs > fast_segs) { + ret = -ENOMEM ; iov =kmalloc_array (nr_segs,sizeof (struct iovec ),GFP_KERNEL ); -if (iov =NULL ) { - ret = -ENOMEM ; - goto out; - } +if (!iov) + goto fail; } -if (copy_from_user (iov, uvector, nr_segs*sizeof (*uvector))) { + +if (compat) { + ret =compat_copy_iovecs_from_user (iov, uvector, nr_segs); +if (ret) + goto fail; + }else { ret = -EFAULT ; - goto out; +if (copy_from_user (iov, uvector, nr_segs *sizeof (*uvector))) + goto fail; }/*
@@ -1707,11 +1741,11 @@ static ssize_t rw_copy_check_uvector(int type,* it's about to overflow ssize_t */ if (len <0 ) { ret = -EINVAL ; - goto out; + goto fail; }if (type !=CHECK_IOVEC_ONLY && !access_ok (buf, len)) { ret = -EFAULT ; - goto out; + goto fail; }if (len >MAX_RW_COUNT - ret) { len =MAX_RW_COUNT - ret;
@@ -1719,8 +1753,17 @@ static ssize_t rw_copy_check_uvector(int type, } ret += len; } -out: - *ret_pointer = iov; +done: +iov_iter_init (i, type, iov, nr_segs, ret); +if (iov = *iovp) + *iovp =NULL ; +else + *iovp = iov; +return ret; +fail: +if (iov != *iovp) +kfree (iov); + *iovp =NULL ;return ret; }
@@ -1750,116 +1793,18 @@ ssize_t import_iovec(int type, const struct iovec __user * uvector, unsigned nr_segs, unsigned fast_segs, struct iovec **iov, struct iov_iter *i) { - ssize_t n; -struct iovec *p; - n =rw_copy_check_uvector (type, uvector, nr_segs, fast_segs, - *iov, &p); -if (n <0 ) { -if (p != *iov) -kfree (p); - *iov =NULL ; -return n; - } -iov_iter_init (i, type, p, nr_segs, n); - *iov = p = *iov ?NULL : p; -return n; + return __import_iovec(type, uvector, nr_segs, fast_segs, iov, i, false); }EXPORT_SYMBOL (import_iovec);#ifdef CONFIG_COMPAT -#include <linux/compat.h> - -static ssize_t compat_rw_copy_check_uvector (int type, -const struct compat_iovec __user *uvector,unsigned long nr_segs, -unsigned long fast_segs,struct iovec *fast_pointer, -struct iovec **ret_pointer) -{ -compat_ssize_t tot_len; -struct iovec *iov = *ret_pointer = fast_pointer; -ssize_t ret =0 ; -int seg; - -/* -* SuS says "The readv() function *may* fail if the iovcnt argument -* was less than or equal to 0, or greater than {IOV_MAX}. Linux has -* traditionally returned zero for zero segments, so... -*/ -if (nr_segs =0 ) - goto out; - - ret = -EINVAL ; -if (nr_segs >UIO_MAXIOV ) - goto out; -if (nr_segs > fast_segs) { - ret = -ENOMEM ; - iov =kmalloc_array (nr_segs,sizeof (struct iovec ),GFP_KERNEL ); -if (iov =NULL ) - goto out; - } - *ret_pointer = iov; - - ret = -EFAULT ; -if (!access_ok (uvector, nr_segs*sizeof (*uvector))) - goto out; - -/* -* Single unix specification: -* We should -EINVAL if an element length is not >= 0 and fitting an -* ssize_t. -* -* In Linux, the total length is limited to MAX_RW_COUNT, there is -* no overflow possibility. -*/ - tot_len =0 ; - ret = -EINVAL ; -for (seg =0 ; seg < nr_segs; seg++) { -compat_uptr_t buf; -compat_ssize_t len; - -if (__get_user (len, &uvector->iov_len) || -__get_user (buf, &uvector->iov_base)) { - ret = -EFAULT ; - goto out; - } -if (len <0 )/* size_t not fitting in compat_ssize_t .. */ - goto out; -if (type !=CHECK_IOVEC_ONLY && - !access_ok (compat_ptr (buf), len)) { - ret = -EFAULT ; - goto out; - } -if (len >MAX_RW_COUNT - tot_len) - len =MAX_RW_COUNT - tot_len; - tot_len += len; - iov->iov_base =compat_ptr (buf); - iov->iov_len = (compat_size_t ) len; - uvector++; - iov++; - } - ret = tot_len; - -out: -return ret; -} -ssize_t compat_import_iovec (int type,const struct compat_iovec __user * uvector,unsigned nr_segs,unsigned fast_segs,struct iovec **iov,struct iov_iter *i) { -ssize_t n; -struct iovec *p; - n =compat_rw_copy_check_uvector (type, uvector, nr_segs, fast_segs, - *iov, &p); -if (n <0 ) { -if (p != *iov) -kfree (p); - *iov =NULL ; -return n; - } -iov_iter_init (i, type, p, nr_segs, n); - *iov = p = *iov ?NULL : p; -return n; +return __import_iovec (type, (const struct iovec __user *)uvector, + nr_segs, fast_segs, iov, i, true); }EXPORT_SYMBOL (compat_import_iovec);#endif
Signature · 1 line
2.28.0
Al Viro
maintainerRe: [PATCH 05/11] iov_iter: merge the compat case into rw_copy_check_uvector
lib/iov_iter.c const void *dup_iter(struct iov_iter *new, struct iov_iter *old, gfp_t flags) · line 1658
Quoted 5 lines · Christoph Hellwig
lib/iov_iter.c +5
-0+static int compat_copy_iovecs_from_user (struct iovec *iov, +const struct iovec __user *uvector,unsigned long nr_segs) +{ + const struct compat_iovec __user *uiov > + (const struct compat_iovec __user *)uvector; +unsigned long i;
^^^^
Huh?
RE: [PATCH 05/11] iov_iter: merge the compat case into rw_copy_check_uvector
In reply to Christoph HellwigFrom: Christoph Hellwig <[email protected]>
Quoted 32 lines
Sent: 21 September 2020 15:34
Stop duplicating the iovec verify code, and instead add add a
__import_iovechelper that does the whole verify and import, but takes a bool compat to decided on the native or compat layout. This also ends up massively simplifying the calling conventions.Signed-off-by Christoph Hellwig <[email protected]>--- lib/iov_iter.c | 195 ++++++++++++++++++------------------------------- 1 file changed, 70 insertions(+), 125 deletions(-)lib/iov_iter.c +1
-4@@ -10,6 +10,7 @@#include <net/checksum.h> #include <linux/scatterlist.h> #include <linux/instrumented.h> +#include <linux/compat.h> #define PIPE_PARANOIA /* for now */ @@ -1650,43 +1651,76 @@ const void *dup_iter(struct iov_iter *new, struct iov_iter *old, gfp_t flags) }EXPORT_SYMBOL (dup_iter); -static ssize_t rw_copy_check_uvector (int type, -const struct iovec __user *uvector,unsigned long nr_segs, -unsigned long fast_segs,struct iovec *fast_pointer, -struct iovec **ret_pointer)
lib/iov_iter.c const void *dup_iter(struct iov_iter *new, struct iov_iter *old, gfp_t flags) · line 1663
Quoted 10 lines
lib/iov_iter.c +10
-0+static int compat_copy_iovecs_from_user (struct iovec *iov, +const struct iovec __user *uvector,unsigned long nr_segs) +{ +const struct compat_iovec __user *uiov = + (const struct compat_iovec __user *)uvector; +unsigned long i; +int ret = -EFAULT ; + +if (!user_access_begin (uvector, nr_segs *sizeof (*uvector))) +return -EFAULT ;
I little bit late, but the above isn't quite right.
It should be sizeof(*iouv) - the length is double what it should be.
Not that access_ok() can fail for compat addresses and the extra length won't matter for architectures that need the address/length to open an address hole into userspace.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
PATCH 6/11 iov_iter: handle the compat case in import_iovec
In reply to Christoph HellwigUse in compat_syscall to import either native or the compat iovecs, and remove the now superflous compat_import_iovec, which removes the need for special compat logic in most callers. Only io_uring needs special treatment given that it can call import_iovec from kernel threads acting on behalf of native or compat syscalls. Expose the low-level __import_iovec helper and use it in io_uring to explicitly pick a iovec layout.
--- block/scsi_ioctl.c | 12 ++---------- drivers/scsi/sg.c | 9 +-------- fs/aio.c | 38 ++++++++++++++------------------------ fs/io_uring.c | 20 ++++++++------------ fs/read_write.c | 6 ++++-- fs/splice.c | 2 +- include/linux/uio.h | 10 +++------- lib/iov_iter.c | 17 +++-------------- mm/process_vm_access.c | 7 ++++--- net/compat.c | 4 ++-- security/keys/compat.c | 5 ++--- 11 files changed, 44 insertions(+), 86 deletions(-)
block/scsi_ioctl.c +2 -10
@@ -333,16 +333,8 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,struct iov_iter i;struct iovec *iov =NULL ; -#ifdef CONFIG_COMPAT -if (in_compat_syscall ()) - ret =compat_import_iovec (rq_data_dir (rq), - hdr->dxferp, hdr->iovec_count, -0 , &iov, &i); - else -#endif - ret =import_iovec (rq_data_dir (rq), - hdr->dxferp, hdr->iovec_count, -0 , &iov, &i); + ret =import_iovec (rq_data_dir (rq), hdr->dxferp, + hdr->iovec_count,0 , &iov, &i);if (ret <0 ) goto out_free_cdb;
drivers/scsi/sg.c +1 -8
@@ -1820,14 +1820,7 @@ sg_start_req(Sg_request *srp, unsigned char *cmd)struct iovec *iov =NULL ;struct iov_iter i; -#ifdef CONFIG_COMPAT -if (in_compat_syscall ()) - res =compat_import_iovec (rw, hp->dxferp, iov_count, -0 , &iov, &i); - else -#endif - res =import_iovec (rw, hp->dxferp, iov_count, -0 , &iov, &i); + res =import_iovec (rw, hp->dxferp, iov_count,0 , &iov, &i);if (res <0 )return res;
fs/aio.c +14 -24
@@ -1478,8 +1478,7 @@ static int aio_prep_rw(struct kiocb *req, const struct iocb *iocb) }static ssize_t aio_setup_rw (int rw,const struct iocb *iocb, -struct iovec **iovec,bool vectored,bool compat, -struct iov_iter *iter) +struct iovec **iovec,bool vectored,struct iov_iter *iter) {void __user *buf = (void __user *)(uintptr_t )iocb->aio_buf;size_t len = iocb->aio_nbytes;
@@ -1489,11 +1488,6 @@ static ssize_t aio_setup_rw(int rw, const struct iocb *iocb, *iovec =NULL ;return ret; } -#ifdef CONFIG_COMPAT -if (compat) -return compat_import_iovec (rw, buf, len,UIO_FASTIOV , iovec, - iter); -#endif return import_iovec (rw, buf, len,UIO_FASTIOV , iovec, iter); }
@@ -1517,8 +1511,7 @@ static inline void aio_rw_done(struct kiocb *req, ssize_t ret) } } -static int aio_read (struct kiocb *req,const struct iocb *iocb, -bool vectored,bool compat) +static int aio_read (struct kiocb *req,const struct iocb *iocb,bool vectored) {struct iovec inline_vecs[UIO_FASTIOV ], *iovec = inline_vecs;struct iov_iter iter;
@@ -1535,7 +1528,7 @@ static int aio_read(struct kiocb *req, const struct iocb *iocb,if (unlikely (!file->f_op->read_iter))return -EINVAL ; - ret =aio_setup_rw (READ , iocb, &iovec, vectored, compat, &iter); + ret =aio_setup_rw (READ , iocb, &iovec, vectored, &iter);if (ret <0 )return ret; ret =rw_verify_area (READ , file, &req->ki_pos,iov_iter_count (&iter));
@@ -1545,8 +1538,7 @@ static int aio_read(struct kiocb *req, const struct iocb *iocb,return ret; } -static int aio_write (struct kiocb *req,const struct iocb *iocb, -bool vectored,bool compat) +static int aio_write (struct kiocb *req,const struct iocb *iocb,bool vectored) {struct iovec inline_vecs[UIO_FASTIOV ], *iovec = inline_vecs;struct iov_iter iter;
@@ -1563,7 +1555,7 @@ static int aio_write(struct kiocb *req, const struct iocb *iocb,if (unlikely (!file->f_op->write_iter))return -EINVAL ; - ret =aio_setup_rw (WRITE , iocb, &iovec, vectored, compat, &iter); + ret =aio_setup_rw (WRITE , iocb, &iovec, vectored, &iter);if (ret <0 )return ret; ret =rw_verify_area (WRITE , file, &req->ki_pos,iov_iter_count (&iter));
@@ -1799,8 +1791,7 @@ static int aio_poll(struct aio_kiocb *aiocb, const struct iocb *iocb) }static int __io_submit_one (struct kioctx *ctx,const struct iocb *iocb, -struct iocb __user *user_iocb,struct aio_kiocb *req, -bool compat) +struct iocb __user *user_iocb,struct aio_kiocb *req) { req->ki_filp =fget (iocb->aio_fildes);if (unlikely (!req->ki_filp))
@@ -1833,13 +1824,13 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb,switch (iocb->aio_lio_opcode) {case IOCB_CMD_PREAD : -return aio_read (&req->rw, iocb, false, compat); +return aio_read (&req->rw, iocb, false);case IOCB_CMD_PWRITE : -return aio_write (&req->rw, iocb, false, compat); +return aio_write (&req->rw, iocb, false);case IOCB_CMD_PREADV : -return aio_read (&req->rw, iocb, true, compat); +return aio_read (&req->rw, iocb, true);case IOCB_CMD_PWRITEV : -return aio_write (&req->rw, iocb, true, compat); +return aio_write (&req->rw, iocb, true);case IOCB_CMD_FSYNC :return aio_fsync (&req->fsync, iocb, false);case IOCB_CMD_FDSYNC :
@@ -1852,8 +1843,7 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb, } } -static int io_submit_one (struct kioctx *ctx,struct iocb __user *user_iocb, -bool compat) +static int io_submit_one (struct kioctx *ctx,struct iocb __user *user_iocb) {struct aio_kiocb *req;struct iocb iocb;
@@ -1882,7 +1872,7 @@ static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,if (unlikely (!req))return -EAGAIN ; - err =__io_submit_one (ctx, &iocb, user_iocb, req, compat); + err =__io_submit_one (ctx, &iocb, user_iocb, req);/* Done with the synchronous reference */ iocb_put (req);
@@ -1941,7 +1931,7 @@ SYSCALL_DEFINE3(io_submit, aio_context_t, ctx_id, long, nr,break ; } - ret =io_submit_one (ctx, user_iocb, false); + ret =io_submit_one (ctx, user_iocb);if (ret)break ; }
@@ -1983,7 +1973,7 @@ COMPAT_SYSCALL_DEFINE3(io_submit, compat_aio_context_t, ctx_id,break ; } - ret =io_submit_one (ctx,compat_ptr (user_iocb), true); + ret =io_submit_one (ctx,compat_ptr (user_iocb));if (ret)break ; }
fs/io_uring.c +8 -12
@@ -2837,13 +2837,8 @@ static ssize_t __io_import_iovec(int rw, struct io_kiocb *req,return ret; } -#ifdef CONFIG_COMPAT -if (req->ctx->compat) -return compat_import_iovec (rw, buf, sqe_len,UIO_FASTIOV , - iovec, iter); -#endif - -return import_iovec (rw, buf, sqe_len,UIO_FASTIOV , iovec, iter); +return __import_iovec (rw, buf, sqe_len,UIO_FASTIOV , iovec, iter, + req->ctx->compat); } static ssize_t io_import_iovec(int rw, struct io_kiocb *req,
@@ -4179,8 +4174,9 @@ static int __io_recvmsg_copy_hdr(struct io_kiocb *req, sr->len); iomsg->iov =NULL ; }else { - ret =import_iovec (READ , uiov, iov_len,UIO_FASTIOV , - &iomsg->iov, &iomsg->msg.msg_iter); + ret =__import_iovec (READ , uiov, iov_len,UIO_FASTIOV , + &iomsg->iov, &iomsg->msg.msg_iter, + false);if (ret >0 ) ret =0 ; }
@@ -4220,9 +4216,9 @@ static int __io_compat_recvmsg_copy_hdr(struct io_kiocb *req, sr->len = iomsg->iov[0 ].iov_len; iomsg->iov =NULL ; }else { - ret =compat_import_iovec (READ , uiov, len,UIO_FASTIOV , - &iomsg->iov, - &iomsg->msg.msg_iter); + ret =__import_iovec (READ , (struct iovec __user *)uiov, len, +UIO_FASTIOV , &iomsg->iov, + &iomsg->msg.msg_iter, true);if (ret <0 )return ret; }
fs/read_write.c +4 -2
@@ -1078,7 +1078,8 @@ static size_t compat_readv(struct file *file,struct iov_iter iter;ssize_t ret; - ret =compat_import_iovec (READ , vec, vlen,UIO_FASTIOV , &iov, &iter); + ret =import_iovec (READ , (const struct iovec __user *)vec, vlen, +UIO_FASTIOV , &iov, &iter);if (ret >=0 ) { ret =do_iter_read (file, &iter, pos, flags);kfree (iov);
@@ -1186,7 +1187,8 @@ static size_t compat_writev(struct file *file,struct iov_iter iter;ssize_t ret; - ret =compat_import_iovec (WRITE , vec, vlen,UIO_FASTIOV , &iov, &iter); + ret =import_iovec (WRITE , (const struct iovec __user *)vec, vlen, +UIO_FASTIOV , &iov, &iter);if (ret >=0 ) {file_start_write (file); ret =do_iter_write (file, &iter, pos, flags);
fs/splice.c +1 -1
@@ -1387,7 +1387,7 @@ COMPAT_SYSCALL_DEFINE4(vmsplice, int, fd, const struct compat_iovec __user *, ioif (error)return error; - error =compat_import_iovec (type, iov32, nr_segs, + error =import_iovec (type, (struct iovec __user *)iov32, nr_segs,ARRAY_SIZE (iovstack), &iov, &iter);if (error >=0 ) { error =do_vmsplice (f.file, &iter, flags);
include/linux/uio.h +3 -7
@@ -269,13 +269,9 @@ size_t hash_and_copy_to_iter(const void *addr, size_t bytes, void *hashp,ssize_t import_iovec (int type,const struct iovec __user * uvector,unsigned nr_segs,unsigned fast_segs,struct iovec **iov,struct iov_iter *i); - -#ifdef CONFIG_COMPAT -struct compat_iovec ; -ssize_t compat_import_iovec (int type,const struct compat_iovec __user * uvector, -unsigned nr_segs,unsigned fast_segs, -struct iovec **iov,struct iov_iter *i); -#endif +ssize_t __import_iovec (int type,const struct iovec __user *uvector, +unsigned nr_segs,unsigned fast_segs,struct iovec **iovp, +struct iov_iter *i,bool compat);int import_single_range (int type,void __user *buf,size_t len,struct iovec *iov,struct iov_iter *i);
lib/iov_iter.c +3 -14
@@ -1683,7 +1683,7 @@ static int compat_copy_iovecs_from_user(struct iovec *iov,return ret; } -static ssize_t __import_iovec (int type,const struct iovec __user *uvector, +ssize_t __import_iovec (int type,const struct iovec __user *uvector,unsigned nr_segs,unsigned fast_segs,struct iovec **iovp,struct iov_iter *i,bool compat) {
@@ -1793,22 +1793,11 @@ ssize_t import_iovec(int type, const struct iovec __user * uvector, unsigned nr_segs, unsigned fast_segs, struct iovec **iov, struct iov_iter *i) { - return __import_iovec(type, uvector, nr_segs, fast_segs, iov, i, false); + return __import_iovec(type, uvector, nr_segs, fast_segs, iov, i, +in_compat_syscall ()); }EXPORT_SYMBOL (import_iovec); -#ifdef CONFIG_COMPAT -ssize_t compat_import_iovec (int type, -const struct compat_iovec __user * uvector, -unsigned nr_segs,unsigned fast_segs, -struct iovec **iov,struct iov_iter *i) -{ -return __import_iovec (type, (const struct iovec __user *)uvector, - nr_segs, fast_segs, iov, i, true); -} -EXPORT_SYMBOL (compat_import_iovec); -#endif -int import_single_range (int rw,void __user *buf,size_t len,struct iovec *iov,struct iov_iter *i) {
mm/process_vm_access.c +4 -3
@@ -331,13 +331,14 @@ compat_process_vm_rw(compat_pid_t pid,if (flags !=0 )return -EINVAL ; - rc =compat_import_iovec (dir, lvec, liovcnt,UIO_FASTIOV , &iov_l, &iter_l); + rc =import_iovec (dir, (const struct iovec __user *)iov_l, liovcnt, +UIO_FASTIOV , &iov_l, &iter_l);if (rc <0 )return rc;if (!iov_iter_count (&iter_l)) goto free_iovecs; - rc =compat_import_iovec (CHECK_IOVEC_ONLY , rvec, riovcnt,UIO_FASTIOV , - &iov_r, &iter_r); + rc =import_iovec (CHECK_IOVEC_ONLY , iov_r, riovcnt,UIO_FASTIOV , &iov_r, + &iter_r);if (rc <=0 ) goto free_iovecs;
net/compat.c +2 -2
@@ -98,8 +98,8 @@ int get_compat_msghdr(struct msghdr *kmsg,if (err)return err; - err =compat_import_iovec (save_addr ?READ :WRITE ,compat_ptr (ptr), - len,UIO_FASTIOV , iov, &kmsg->msg_iter); + err =import_iovec (save_addr ?READ :WRITE ,compat_ptr (ptr), len, +UIO_FASTIOV , iov, &kmsg->msg_iter);return err <0 ? err :0 ; }
security/keys/compat.c +2 -3
@@ -33,9 +33,8 @@ static long compat_keyctl_instantiate_key_iov(if (!_payload_iov) ioc =0 ; - ret =compat_import_iovec (WRITE , _payload_iov, ioc, -ARRAY_SIZE (iovstack), &iov, - &from); + ret =import_iovec (WRITE , (const struct iovec __user *)_payload_iov, + ioc,ARRAY_SIZE (iovstack), &iov, &from);if (ret <0 )return ret;
Signature · 1 line
2.28.0
Al Viro
maintainerRe: [PATCH 06/11] iov_iter: handle the compat case in import_iovec
Quoted 7 lines · Christoph Hellwig
Use in
compat_syscallto import either native or the compat iovecs, and remove the now superflouscompat_import_iovec, which removes the need for special compat logic in most callers. Onlyio_uringneeds special treatment given that it can callimport_iovecfrom kernel threads acting on behalf of native or compat syscalls. Expose the low-level__import_iovechelper and use it inio_uringto explicitly pick a iovec layout.
fs/aio.c part is not obvious... Might be better to use __import_iovec() there as well and leave the rest of aio.c changes to followup.
lib/iov_iter.c static int compat_copy_iovecs_from_user(struct iovec *iov, · line 1689
Quoted 11 lines
lib/iov_iter.c +1
-1@@ -1683,7 +1683,7 @@ static int compat_copy_iovecs_from_user(struct iovec *iov,return ret; } -static ssize_t __import_iovec (int type,const struct iovec __user *uvector, +ssize_t __import_iovec (int type,const struct iovec __user *uvector,unsigned nr_segs,unsigned fast_segs,struct iovec **iovp,struct iov_iter *i,bool compat) {
Don't make it static in the first place, perhaps?
PATCH 7/11 fs: remove various compat readv/writev helpers
In reply to Christoph HellwigNow that import_iovec handles compat iovecs as well, all the duplicated code in the compat readv/writev helpers is not needed. Remove them and switch the compat syscall handlers to use the native helpers.
--- fs/read_write.c | 179 ++++++++---------------------------------------- 1 file changed, 30 insertions(+), 149 deletions(-)
fs/read_write.c +30 -149
@@ -1068,226 +1068,107 @@ SYSCALL_DEFINE6(pwritev2, unsigned long, fd, const struct iovec __user *, vec,return do_pwritev (fd, vec, vlen, pos, flags); } +/* +* Various compat syscalls. Note that they all pretend to take a native +* iovec - import_iovec will properly treat those as compat_iovecs based on +* in_compat_syscall(). +*/ #ifdef CONFIG_COMPAT -static size_t compat_readv (struct file *file, -const struct compat_iovec __user *vec, -unsigned long vlen,loff_t *pos,rwf_t flags) -{ -struct iovec iovstack[UIO_FASTIOV ]; -struct iovec *iov = iovstack; -struct iov_iter iter; -ssize_t ret; - - ret =import_iovec (READ , (const struct iovec __user *)vec, vlen, -UIO_FASTIOV , &iov, &iter); -if (ret >=0 ) { - ret =do_iter_read (file, &iter, pos, flags); -kfree (iov); - } -if (ret >0 ) -add_rchar (current, ret); -inc_syscr (current); -return ret; -} - -static size_t do_compat_readv (compat_ulong_t fd, -const struct compat_iovec __user *vec, -compat_ulong_t vlen,rwf_t flags) -{ -struct fd f =fdget_pos (fd); -ssize_t ret; -loff_t pos; - -if (!f.file) -return -EBADF ; - pos = f.file->f_pos; - ret =compat_readv (f.file, vec, vlen, &pos, flags); -if (ret >=0 ) - f.file->f_pos = pos; -fdput_pos (f); -return ret; - -} -COMPAT_SYSCALL_DEFINE3 (readv, compat_ulong_t, fd, - const struct compat_iovec __user *,vec, + const struct iovec __user *, vec, compat_ulong_t, vlen) { -return do_compat_readv (fd, vec, vlen,0 ); -} - -static long do_compat_preadv64 (unsigned long fd, -const struct compat_iovec __user *vec, -unsigned long vlen,loff_t pos,rwf_t flags) -{ -struct fd f; -ssize_t ret; - -if (pos <0 ) -return -EINVAL ; - f =fdget (fd); -if (!f.file) -return -EBADF ; - ret = -ESPIPE ; -if (f.file->f_mode &FMODE_PREAD ) - ret =compat_readv (f.file, vec, vlen, &pos, flags); -fdput (f); -return ret; +return do_readv (fd, vec, vlen,0 ); }#ifdef __ARCH_WANT_COMPAT_SYS_PREADV64 COMPAT_SYSCALL_DEFINE4(preadv64, unsigned long, fd, - const struct compat_iovec __user *,vec, + const struct iovec __user *, vec, unsigned long, vlen, loff_t, pos) { -return do_compat_preadv64 (fd, vec, vlen, pos,0 ); +return do_preadv (fd, vec, vlen, pos,0 ); }#endif COMPAT_SYSCALL_DEFINE5 (preadv, compat_ulong_t, fd, - const struct compat_iovec __user *,vec, + const struct iovec __user *, vec, compat_ulong_t, vlen, u32, pos_low, u32, pos_high) {loff_t pos = ((loff_t )pos_high <<32 ) | pos_low; -return do_compat_preadv64 (fd, vec, vlen, pos,0 ); +return do_preadv (fd, vec, vlen, pos,0 ); }#ifdef __ARCH_WANT_COMPAT_SYS_PREADV64V2 COMPAT_SYSCALL_DEFINE5(preadv64v2, unsigned long, fd, - const struct compat_iovec __user *,vec, + const struct iovec __user *, vec, unsigned long, vlen, loff_t, pos, rwf_t, flags) {if (pos =-1 ) -return do_compat_readv (fd, vec, vlen, flags); - -return do_compat_preadv64 (fd, vec, vlen, pos, flags); +return do_readv (fd, vec, vlen, flags); +return do_preadv (fd, vec, vlen, pos, flags); }#endif COMPAT_SYSCALL_DEFINE6 (preadv2, compat_ulong_t, fd, - const struct compat_iovec __user *,vec, + const struct iovec __user *, vec, compat_ulong_t, vlen, u32, pos_low, u32, pos_high, rwf_t, flags) {loff_t pos = ((loff_t )pos_high <<32 ) | pos_low;if (pos =-1 ) -return do_compat_readv (fd, vec, vlen, flags); - -return do_compat_preadv64 (fd, vec, vlen, pos, flags); -} - -static size_t compat_writev (struct file *file, -const struct compat_iovec __user *vec, -unsigned long vlen,loff_t *pos,rwf_t flags) -{ -struct iovec iovstack[UIO_FASTIOV ]; -struct iovec *iov = iovstack; -struct iov_iter iter; -ssize_t ret; - - ret =import_iovec (WRITE , (const struct iovec __user *)vec, vlen, -UIO_FASTIOV , &iov, &iter); -if (ret >=0 ) { -file_start_write (file); - ret =do_iter_write (file, &iter, pos, flags); -file_end_write (file); -kfree (iov); - } -if (ret >0 ) -add_wchar (current, ret); -inc_syscw (current); -return ret; -} - -static size_t do_compat_writev (compat_ulong_t fd, -const struct compat_iovec __user * vec, -compat_ulong_t vlen,rwf_t flags) -{ -struct fd f =fdget_pos (fd); -ssize_t ret; -loff_t pos; - -if (!f.file) -return -EBADF ; - pos = f.file->f_pos; - ret =compat_writev (f.file, vec, vlen, &pos, flags); -if (ret >=0 ) - f.file->f_pos = pos; -fdput_pos (f); -return ret; +return do_readv (fd, vec, vlen, flags); +return do_preadv (fd, vec, vlen, pos, flags); }COMPAT_SYSCALL_DEFINE3 (writev, compat_ulong_t, fd, - const struct compat_iovec __user *, vec, + const struct iovec __user *, vec, compat_ulong_t, vlen) { -return do_compat_writev (fd, vec, vlen,0 ); -} - -static long do_compat_pwritev64 (unsigned long fd, -const struct compat_iovec __user *vec, -unsigned long vlen,loff_t pos,rwf_t flags) -{ -struct fd f; -ssize_t ret; - -if (pos <0 ) -return -EINVAL ; - f =fdget (fd); -if (!f.file) -return -EBADF ; - ret = -ESPIPE ; -if (f.file->f_mode &FMODE_PWRITE ) - ret =compat_writev (f.file, vec, vlen, &pos, flags); -fdput (f); -return ret; +return do_writev (fd, vec, vlen,0 ); }#ifdef __ARCH_WANT_COMPAT_SYS_PWRITEV64 COMPAT_SYSCALL_DEFINE4(pwritev64, unsigned long, fd, - const struct compat_iovec __user *,vec, + const struct iovec __user *, vec, unsigned long, vlen, loff_t, pos) { -return do_compat_pwritev64 (fd, vec, vlen, pos,0 ); +return do_pwritev (fd, vec, vlen, pos,0 ); }#endif COMPAT_SYSCALL_DEFINE5 (pwritev, compat_ulong_t, fd, - const struct compat_iovec __user *,vec, + const struct iovec __user *,vec, compat_ulong_t, vlen, u32, pos_low, u32, pos_high) {loff_t pos = ((loff_t )pos_high <<32 ) | pos_low; -return do_compat_pwritev64 (fd, vec, vlen, pos,0 ); +return do_pwritev (fd, vec, vlen, pos,0 ); }#ifdef __ARCH_WANT_COMPAT_SYS_PWRITEV64V2 COMPAT_SYSCALL_DEFINE5(pwritev64v2, unsigned long, fd, - const struct compat_iovec __user *,vec, + const struct iovec __user *, vec, unsigned long, vlen, loff_t, pos, rwf_t, flags) {if (pos =-1 ) -return do_compat_writev (fd, vec, vlen, flags); - -return do_compat_pwritev64 (fd, vec, vlen, pos, flags); +return do_writev (fd, vec, vlen, flags); +return do_pwritev (fd, vec, vlen, pos, flags); }#endif COMPAT_SYSCALL_DEFINE6 (pwritev2, compat_ulong_t, fd, - const struct compat_iovec __user *,vec, + const struct iovec __user *,vec, compat_ulong_t, vlen, u32, pos_low, u32, pos_high, rwf_t, flags) {loff_t pos = ((loff_t )pos_high <<32 ) | pos_low;if (pos =-1 ) -return do_compat_writev (fd, vec, vlen, flags); - -return do_compat_pwritev64 (fd, vec, vlen, pos, flags); +return do_writev (fd, vec, vlen, flags); +return do_pwritev (fd, vec, vlen, pos, flags); } - -#endif +#endif /* CONFIG_COMPAT */ static ssize_t do_sendfile (int out_fd,int in_fd,loff_t *ppos,size_t count,loff_t max)
Signature · 1 line
2.28.0
PATCH 8/11 fs: remove the compat readv/writev syscalls
In reply to Christoph HellwigNow that import_iovec handles compat iovecs, the native readv and writev syscalls can be used for the compat case as well.
--- arch/arm64/include/asm/unistd32.h | 4 ++-- arch/mips/kernel/syscalls/syscall_n32.tbl | 4 ++-- arch/mips/kernel/syscalls/syscall_o32.tbl | 4 ++-- arch/parisc/kernel/syscalls/syscall.tbl | 4 ++-- arch/powerpc/kernel/syscalls/syscall.tbl | 4 ++-- arch/s390/kernel/syscalls/syscall.tbl | 4 ++-- arch/sparc/kernel/syscalls/syscall.tbl | 4 ++-- arch/x86/entry/syscall_x32.c | 2 ++ arch/x86/entry/syscalls/syscall_32.tbl | 4 ++-- arch/x86/entry/syscalls/syscall_64.tbl | 4 ++-- fs/read_write.c | 14 -------------- include/linux/compat.h | 4 ---- include/uapi/asm-generic/unistd.h | 4 ++-- tools/include/uapi/asm-generic/unistd.h | 4 ++-- tools/perf/arch/powerpc/entry/syscalls/syscall.tbl | 4 ++-- tools/perf/arch/s390/entry/syscalls/syscall.tbl | 4 ++-- tools/perf/arch/x86/entry/syscalls/syscall_64.tbl | 4 ++-- 17 files changed, 30 insertions(+), 46 deletions(-)
arch/arm64/include/asm/unistd32.h +2 -2
@@ -301,9 +301,9 @@ __SYSCALL(__NR_flock, sys_flock)#define __NR_msync 144 __SYSCALL(__NR_msync, sys_msync)#define __NR_readv 145 -__SYSCALL(__NR_readv, compat_sys_readv) +__SYSCALL(__NR_readv, sys_readv)#define __NR_writev 146 -__SYSCALL(__NR_writev, compat_sys_writev) +__SYSCALL(__NR_writev, sys_writev)#define __NR_getsid 147 __SYSCALL(__NR_getsid, sys_getsid)#define __NR_fdatasync 148
arch/mips/kernel/syscalls/syscall_n32.tbl +2 -2
@@ -25,8 +25,8 @@ 15 n32 ioctl compat_sys_ioctl 16 n32 pread64 sys_pread64 17 n32 pwrite64 sys_pwrite64 -18 n32 readv compat_sys_readv -19 n32 writev compat_sys_writev +18 n32 readv sys_readv +19 n32 writev sys_writev 20 n32 access sys_access 21 n32 pipe sysm_pipe 22 n32 _newselect compat_sys_select
arch/mips/kernel/syscalls/syscall_o32.tbl +2 -2
@@ -156,8 +156,8 @@ 142 o32 _newselect sys_select compat_sys_select 143 o32 flock sys_flock 144 o32 msync sys_msync -145 o32 readv sys_readv compat_sys_readv -146 o32 writev sys_writev compat_sys_writev +145 o32 readv sys_readv +146 o32 writev sys_writev 147 o32 cacheflush sys_cacheflush 148 o32 cachectl sys_cachectl 149 o32 sysmips __sys_sysmips
arch/parisc/kernel/syscalls/syscall.tbl +2 -2
@@ -159,8 +159,8 @@ 142 common _newselect sys_select compat_sys_select 143 common flock sys_flock 144 common msync sys_msync -145 common readv sys_readv compat_sys_readv -146 common writev sys_writev compat_sys_writev +145 common readv sys_readv +146 common writev sys_writev 147 common getsid sys_getsid 148 common fdatasync sys_fdatasync 149 common _sysctl sys_ni_syscall
arch/powerpc/kernel/syscalls/syscall.tbl +2 -2
@@ -193,8 +193,8 @@ 142 common _newselect sys_select compat_sys_select 143 common flock sys_flock 144 common msync sys_msync -145 common readv sys_readv compat_sys_readv -146 common writev sys_writev compat_sys_writev +145 common readv sys_readv +146 common writev sys_writev 147 common getsid sys_getsid 148 common fdatasync sys_fdatasync 149 nospu _sysctl sys_ni_syscall
arch/s390/kernel/syscalls/syscall.tbl +2 -2
@@ -134,8 +134,8 @@ 142 64 select sys_select - 143 common flock sys_flock sys_flock 144 common msync sys_msync sys_msync -145 common readv sys_readv compat_sys_readv -146 common writev sys_writev compat_sys_writev +145 common readv sys_readv sys_readv +146 common writev sys_writev sys_writev 147 common getsid sys_getsid sys_getsid 148 common fdatasync sys_fdatasync sys_fdatasync 149 common _sysctl - -
arch/sparc/kernel/syscalls/syscall.tbl +2 -2
@@ -149,8 +149,8 @@ 117 common getrusage sys_getrusage compat_sys_getrusage 118 common getsockopt sys_getsockopt sys_getsockopt 119 common getcwd sys_getcwd -120 common readv sys_readv compat_sys_readv -121 common writev sys_writev compat_sys_writev +120 common readv sys_readv +121 common writev sys_writev 122 common settimeofday sys_settimeofday compat_sys_settimeofday 123 32 fchown sys_fchown16 123 64 fchown sys_fchown
arch/x86/entry/syscall_x32.c +2 -0
@@ -12,6 +12,8 @@* Reuse the 64-bit entry points for the x32 versions that occupy different * slots in the syscall table. */ +#define __x32_sys_readv __x64_sys_readv +#define __x32_sys_writev __x64_sys_writev#define __x32_sys_getsockopt __x64_sys_getsockopt#define __x32_sys_setsockopt __x64_sys_setsockopt
arch/x86/entry/syscalls/syscall_32.tbl +2 -2
@@ -156,8 +156,8 @@ 142 i386 _newselect sys_select compat_sys_select 143 i386 flock sys_flock 144 i386 msync sys_msync -145 i386 readv sys_readv compat_sys_readv -146 i386 writev sys_writev compat_sys_writev +145 i386 readv sys_readv +146 i386 writev sys_writev 147 i386 getsid sys_getsid 148 i386 fdatasync sys_fdatasync 149 i386 _sysctl sys_ni_syscall
arch/x86/entry/syscalls/syscall_64.tbl +2 -2
@@ -371,8 +371,8 @@ 512 x32 rt_sigaction compat_sys_rt_sigaction 513 x32 rt_sigreturn compat_sys_x32_rt_sigreturn 514 x32 ioctl compat_sys_ioctl -515 x32 readv compat_sys_readv -516 x32 writev compat_sys_writev +515 x32 readv sys_readv +516 x32 writev sys_writev 517 x32 recvfrom compat_sys_recvfrom 518 x32 sendmsg compat_sys_sendmsg 519 x32 recvmsg compat_sys_recvmsg
fs/read_write.c +0 -14
@@ -1074,13 +1074,6 @@ SYSCALL_DEFINE6(pwritev2, unsigned long, fd, const struct iovec __user *, vec,* in_compat_syscall(). */ #ifdef CONFIG_COMPAT -COMPAT_SYSCALL_DEFINE3 (readv, compat_ulong_t, fd, - const struct iovec __user *, vec, - compat_ulong_t, vlen) -{ -return do_readv (fd, vec, vlen,0 ); -} -#ifdef __ARCH_WANT_COMPAT_SYS_PREADV64 COMPAT_SYSCALL_DEFINE4(preadv64, unsigned long, fd, const struct iovec __user *, vec,
@@ -1122,13 +1115,6 @@ COMPAT_SYSCALL_DEFINE6(preadv2, compat_ulong_t, fd,return do_preadv (fd, vec, vlen, pos, flags); } -COMPAT_SYSCALL_DEFINE3 (writev, compat_ulong_t, fd, - const struct iovec __user *, vec, - compat_ulong_t, vlen) -{ -return do_writev (fd, vec, vlen,0 ); -} -#ifdef __ARCH_WANT_COMPAT_SYS_PWRITEV64 COMPAT_SYSCALL_DEFINE4(pwritev64, unsigned long, fd, const struct iovec __user *, vec,
include/linux/compat.h +0 -4
@@ -545,10 +545,6 @@ asmlinkage long compat_sys_getdents(unsigned int fd,/* fs/read_write.c */ asmlinkage long compat_sys_lseek (unsigned int ,compat_off_t ,unsigned int ); -asmlinkage ssize_t compat_sys_readv(compat_ulong_t fd, -const struct compat_iovec __user *vec,compat_ulong_t vlen); -asmlinkage ssize_t compat_sys_writev(compat_ulong_t fd, -const struct compat_iovec __user *vec,compat_ulong_t vlen);/* No generic prototype for pread64 and pwrite64 */ asmlinkage ssize_t compat_sys_preadv(compat_ulong_t fd, const struct compat_iovec __user *vec,
include/uapi/asm-generic/unistd.h +2 -2
@@ -207,9 +207,9 @@ __SYSCALL(__NR_read, sys_read)#define __NR_write 64 __SYSCALL(__NR_write, sys_write)#define __NR_readv 65 -__SC_COMP(__NR_readv, sys_readv, compat_sys_readv) +__SC_COMP(__NR_readv, sys_readv, sys_readv)#define __NR_writev 66 -__SC_COMP(__NR_writev, sys_writev, compat_sys_writev) +__SC_COMP(__NR_writev, sys_writev, sys_writev)#define __NR_pread64 67 __SC_COMP(__NR_pread64, sys_pread64, compat_sys_pread64)#define __NR_pwrite64 68
tools/include/uapi/asm-generic/unistd.h +2 -2
@@ -207,9 +207,9 @@ __SYSCALL(__NR_read, sys_read)#define __NR_write 64 __SYSCALL(__NR_write, sys_write)#define __NR_readv 65 -__SC_COMP(__NR_readv, sys_readv, compat_sys_readv) +__SC_COMP(__NR_readv, sys_readv, sys_readv)#define __NR_writev 66 -__SC_COMP(__NR_writev, sys_writev, compat_sys_writev) +__SC_COMP(__NR_writev, sys_writev, sys_writev)#define __NR_pread64 67 __SC_COMP(__NR_pread64, sys_pread64, compat_sys_pread64)#define __NR_pwrite64 68
tools/perf/arch/powerpc/entry/syscalls/syscall.tbl +2 -2
@@ -189,8 +189,8 @@ 142 common _newselect sys_select compat_sys_select 143 common flock sys_flock 144 common msync sys_msync -145 common readv sys_readv compat_sys_readv -146 common writev sys_writev compat_sys_writev +145 common readv sys_readv +146 common writev sys_writev 147 common getsid sys_getsid 148 common fdatasync sys_fdatasync 149 nospu _sysctl sys_ni_syscall
tools/perf/arch/s390/entry/syscalls/syscall.tbl +2 -2
@@ -134,8 +134,8 @@ 142 64 select sys_select - 143 common flock sys_flock sys_flock 144 common msync sys_msync compat_sys_msync -145 common readv sys_readv compat_sys_readv -146 common writev sys_writev compat_sys_writev +145 common readv sys_readv +146 common writev sys_writev 147 common getsid sys_getsid sys_getsid 148 common fdatasync sys_fdatasync sys_fdatasync 149 common _sysctl - -
tools/perf/arch/x86/entry/syscalls/syscall_64.tbl +2 -2
@@ -371,8 +371,8 @@ 512 x32 rt_sigaction compat_sys_rt_sigaction 513 x32 rt_sigreturn compat_sys_x32_rt_sigreturn 514 x32 ioctl compat_sys_ioctl -515 x32 readv compat_sys_readv -516 x32 writev compat_sys_writev +515 x32 readv sys_readv +516 x32 writev sys_writev 517 x32 recvfrom compat_sys_recvfrom 518 x32 sendmsg compat_sys_sendmsg 519 x32 recvmsg compat_sys_recvmsg
Signature · 1 line
2.28.0
PATCH 9/11 fs: remove compat_sys_vmsplice
In reply to Christoph HellwigNow that import_iovec handles compat iovecs, the native vmsplice syscall can be used for the compat case as well.
--- arch/arm64/include/asm/unistd32.h | 2 +- arch/mips/kernel/syscalls/syscall_n32.tbl | 2 +- arch/mips/kernel/syscalls/syscall_o32.tbl | 2 +- arch/parisc/kernel/syscalls/syscall.tbl | 2 +- arch/powerpc/kernel/syscalls/syscall.tbl | 2 +- arch/s390/kernel/syscalls/syscall.tbl | 2 +- arch/sparc/kernel/syscalls/syscall.tbl | 2 +- arch/x86/entry/syscall_x32.c | 1 + arch/x86/entry/syscalls/syscall_32.tbl | 2 +- arch/x86/entry/syscalls/syscall_64.tbl | 2 +- fs/splice.c | 57 +++++-------------- include/linux/compat.h | 4 -- include/uapi/asm-generic/unistd.h | 2 +- tools/include/uapi/asm-generic/unistd.h | 2 +- .../arch/powerpc/entry/syscalls/syscall.tbl | 2 +- .../perf/arch/s390/entry/syscalls/syscall.tbl | 2 +- .../arch/x86/entry/syscalls/syscall_64.tbl | 2 +- 17 files changed, 28 insertions(+), 62 deletions(-)
arch/arm64/include/asm/unistd32.h +1 -1
@@ -697,7 +697,7 @@ __SYSCALL(__NR_sync_file_range2, compat_sys_aarch32_sync_file_range2)#define __NR_tee 342 __SYSCALL(__NR_tee, sys_tee)#define __NR_vmsplice 343 -__SYSCALL(__NR_vmsplice, compat_sys_vmsplice) +__SYSCALL(__NR_vmsplice, sys_vmsplice)#define __NR_move_pages 344 __SYSCALL(__NR_move_pages, compat_sys_move_pages)#define __NR_getcpu 345
arch/mips/kernel/syscalls/syscall_n32.tbl +1 -1
@@ -278,7 +278,7 @@ 267 n32 splice sys_splice 268 n32 sync_file_range sys_sync_file_range 269 n32 tee sys_tee -270 n32 vmsplice compat_sys_vmsplice +270 n32 vmsplice sys_vmsplice 271 n32 move_pages compat_sys_move_pages 272 n32 set_robust_list compat_sys_set_robust_list 273 n32 get_robust_list compat_sys_get_robust_list
arch/mips/kernel/syscalls/syscall_o32.tbl +1 -1
@@ -318,7 +318,7 @@ 304 o32 splice sys_splice 305 o32 sync_file_range sys_sync_file_range sys32_sync_file_range 306 o32 tee sys_tee -307 o32 vmsplice sys_vmsplice compat_sys_vmsplice +307 o32 vmsplice sys_vmsplice 308 o32 move_pages sys_move_pages compat_sys_move_pages 309 o32 set_robust_list sys_set_robust_list compat_sys_set_robust_list 310 o32 get_robust_list sys_get_robust_list compat_sys_get_robust_list
arch/parisc/kernel/syscalls/syscall.tbl +1 -1
@@ -330,7 +330,7 @@ 292 32 sync_file_range parisc_sync_file_range 292 64 sync_file_range sys_sync_file_range 293 common tee sys_tee -294 common vmsplice sys_vmsplice compat_sys_vmsplice +294 common vmsplice sys_vmsplice 295 common move_pages sys_move_pages compat_sys_move_pages 296 common getcpu sys_getcpu 297 common epoll_pwait sys_epoll_pwait compat_sys_epoll_pwait
arch/powerpc/kernel/syscalls/syscall.tbl +1 -1
@@ -369,7 +369,7 @@ 282 common unshare sys_unshare 283 common splice sys_splice 284 common tee sys_tee -285 common vmsplice sys_vmsplice compat_sys_vmsplice +285 common vmsplice sys_vmsplice 286 common openat sys_openat compat_sys_openat 287 common mkdirat sys_mkdirat 288 common mknodat sys_mknodat
arch/s390/kernel/syscalls/syscall.tbl +1 -1
@@ -316,7 +316,7 @@ 306 common splice sys_splice sys_splice 307 common sync_file_range sys_sync_file_range compat_sys_s390_sync_file_range 308 common tee sys_tee sys_tee -309 common vmsplice sys_vmsplice compat_sys_vmsplice +309 common vmsplice sys_vmsplice sys_vmsplice 310 common move_pages sys_move_pages compat_sys_move_pages 311 common getcpu sys_getcpu sys_getcpu 312 common epoll_pwait sys_epoll_pwait compat_sys_epoll_pwait
arch/sparc/kernel/syscalls/syscall.tbl +1 -1
@@ -38,7 +38,7 @@ 23 64 setuid sys_setuid 24 32 getuid sys_getuid16 24 64 getuid sys_getuid -25 common vmsplice sys_vmsplice compat_sys_vmsplice +25 common vmsplice sys_vmsplice 26 common ptrace sys_ptrace compat_sys_ptrace 27 common alarm sys_alarm 28 common sigaltstack sys_sigaltstack compat_sys_sigaltstack
arch/x86/entry/syscall_x32.c +1 -0
@@ -16,6 +16,7 @@#define __x32_sys_writev __x64_sys_writev#define __x32_sys_getsockopt __x64_sys_getsockopt#define __x32_sys_setsockopt __x64_sys_setsockopt +#define __x32_sys_vmsplice __x64_sys_vmsplice#define __SYSCALL_64 (nr, sym)
arch/x86/entry/syscalls/syscall_32.tbl +1 -1
@@ -327,7 +327,7 @@ 313 i386 splice sys_splice 314 i386 sync_file_range sys_ia32_sync_file_range 315 i386 tee sys_tee -316 i386 vmsplice sys_vmsplice compat_sys_vmsplice +316 i386 vmsplice sys_vmsplice 317 i386 move_pages sys_move_pages compat_sys_move_pages 318 i386 getcpu sys_getcpu 319 i386 epoll_pwait sys_epoll_pwait
arch/x86/entry/syscalls/syscall_64.tbl +1 -1
@@ -388,7 +388,7 @@ 529 x32 waitid compat_sys_waitid 530 x32 set_robust_list compat_sys_set_robust_list 531 x32 get_robust_list compat_sys_get_robust_list -532 x32 vmsplice compat_sys_vmsplice +532 x32 vmsplice sys_vmsplice 533 x32 move_pages compat_sys_move_pages 534 x32 preadv compat_sys_preadv64 535 x32 pwritev compat_sys_pwritev64
fs/splice.c +13 -44
86 lines not on this page · raw message
include/linux/compat.h +0 -4
@@ -597,10 +597,6 @@ asmlinkage long compat_sys_signalfd4(int ufd,const compat_sigset_t __user *sigmask, compat_size_t sigsetsize, int flags); -/* fs/splice.c */ -asmlinkage long compat_sys_vmsplice (int fd,const struct compat_iovec __user *, -unsigned int nr_segs,unsigned int flags); -/* fs/stat.c */ asmlinkage long compat_sys_newfstatat(unsigned int dfd, const char __user *filename,
include/uapi/asm-generic/unistd.h +1 -1
@@ -237,7 +237,7 @@ __SC_COMP(__NR_signalfd4, sys_signalfd4, compat_sys_signalfd4)/* fs/splice.c */ #define __NR_vmsplice 75 -__SC_COMP(__NR_vmsplice, sys_vmsplice, compat_sys_vmsplice) +__SYSCALL(__NR_vmsplice, sys_vmsplice)#define __NR_splice 76 __SYSCALL(__NR_splice, sys_splice)#define __NR_tee 77
tools/include/uapi/asm-generic/unistd.h +1 -1
@@ -237,7 +237,7 @@ __SC_COMP(__NR_signalfd4, sys_signalfd4, compat_sys_signalfd4)/* fs/splice.c */ #define __NR_vmsplice 75 -__SC_COMP(__NR_vmsplice, sys_vmsplice, compat_sys_vmsplice) +__SYSCALL(__NR_vmsplice, sys_vmsplice)#define __NR_splice 76 __SYSCALL(__NR_splice, sys_splice)#define __NR_tee 77
tools/perf/arch/powerpc/entry/syscalls/syscall.tbl +1 -1
@@ -363,7 +363,7 @@ 282 common unshare sys_unshare 283 common splice sys_splice 284 common tee sys_tee -285 common vmsplice sys_vmsplice compat_sys_vmsplice +285 common vmsplice sys_vmsplice 286 common openat sys_openat compat_sys_openat 287 common mkdirat sys_mkdirat 288 common mknodat sys_mknodat
tools/perf/arch/s390/entry/syscalls/syscall.tbl +1 -1
@@ -316,7 +316,7 @@ 306 common splice sys_splice compat_sys_splice 307 common sync_file_range sys_sync_file_range compat_sys_s390_sync_file_range 308 common tee sys_tee compat_sys_tee -309 common vmsplice sys_vmsplice compat_sys_vmsplice +309 common vmsplice sys_vmsplice sys_vmsplice 310 common move_pages sys_move_pages compat_sys_move_pages 311 common getcpu sys_getcpu compat_sys_getcpu 312 common epoll_pwait sys_epoll_pwait compat_sys_epoll_pwait
tools/perf/arch/x86/entry/syscalls/syscall_64.tbl +1 -1
@@ -388,7 +388,7 @@ 529 x32 waitid compat_sys_waitid 530 x32 set_robust_list compat_sys_set_robust_list 531 x32 get_robust_list compat_sys_get_robust_list -532 x32 vmsplice compat_sys_vmsplice +532 x32 vmsplice sys_vmsplice 533 x32 move_pages compat_sys_move_pages 534 x32 preadv compat_sys_preadv64 535 x32 pwritev compat_sys_pwritev64
Signature · 1 line
2.28.0
PATCH 10/11 mm: remove compat_process_vm_{readv,writev}
In reply to Christoph HellwigNow that import_iovec handles compat iovecs, the native syscalls can be used for the compat case as well.
--- arch/arm64/include/asm/unistd32.h | 4 +- arch/mips/kernel/syscalls/syscall_n32.tbl | 4 +- arch/mips/kernel/syscalls/syscall_o32.tbl | 4 +- arch/parisc/kernel/syscalls/syscall.tbl | 4 +- arch/powerpc/kernel/syscalls/syscall.tbl | 4 +- arch/s390/kernel/syscalls/syscall.tbl | 4 +- arch/sparc/kernel/syscalls/syscall.tbl | 4 +- arch/x86/entry/syscall_x32.c | 2 + arch/x86/entry/syscalls/syscall_32.tbl | 4 +- arch/x86/entry/syscalls/syscall_64.tbl | 4 +- include/linux/compat.h | 8 --- include/uapi/asm-generic/unistd.h | 6 +- mm/process_vm_access.c | 71 ------------------- tools/include/uapi/asm-generic/unistd.h | 6 +- .../arch/powerpc/entry/syscalls/syscall.tbl | 4 +- .../perf/arch/s390/entry/syscalls/syscall.tbl | 4 +- .../arch/x86/entry/syscalls/syscall_64.tbl | 4 +- 17 files changed, 30 insertions(+), 111 deletions(-)
arch/arm64/include/asm/unistd32.h +2 -2
@@ -763,9 +763,9 @@ __SYSCALL(__NR_sendmmsg, compat_sys_sendmmsg)#define __NR_setns 375 __SYSCALL(__NR_setns, sys_setns)#define __NR_process_vm_readv 376 -__SYSCALL(__NR_process_vm_readv, compat_sys_process_vm_readv) +__SYSCALL(__NR_process_vm_readv, sys_process_vm_readv)#define __NR_process_vm_writev 377 -__SYSCALL(__NR_process_vm_writev, compat_sys_process_vm_writev) +__SYSCALL(__NR_process_vm_writev, sys_process_vm_writev)#define __NR_kcmp 378 __SYSCALL(__NR_kcmp, sys_kcmp)#define __NR_finit_module 379
arch/mips/kernel/syscalls/syscall_n32.tbl +2 -2
@@ -317,8 +317,8 @@ 306 n32 syncfs sys_syncfs 307 n32 sendmmsg compat_sys_sendmmsg 308 n32 setns sys_setns -309 n32 process_vm_readv compat_sys_process_vm_readv -310 n32 process_vm_writev compat_sys_process_vm_writev +309 n32 process_vm_readv sys_process_vm_readv +310 n32 process_vm_writev sys_process_vm_writev 311 n32 kcmp sys_kcmp 312 n32 finit_module sys_finit_module 313 n32 sched_setattr sys_sched_setattr
arch/mips/kernel/syscalls/syscall_o32.tbl +2 -2
@@ -356,8 +356,8 @@ 342 o32 syncfs sys_syncfs 343 o32 sendmmsg sys_sendmmsg compat_sys_sendmmsg 344 o32 setns sys_setns -345 o32 process_vm_readv sys_process_vm_readv compat_sys_process_vm_readv -346 o32 process_vm_writev sys_process_vm_writev compat_sys_process_vm_writev +345 o32 process_vm_readv sys_process_vm_readv +346 o32 process_vm_writev sys_process_vm_writev 347 o32 kcmp sys_kcmp 348 o32 finit_module sys_finit_module 349 o32 sched_setattr sys_sched_setattr
arch/parisc/kernel/syscalls/syscall.tbl +2 -2
@@ -372,8 +372,8 @@ 327 common syncfs sys_syncfs 328 common setns sys_setns 329 common sendmmsg sys_sendmmsg compat_sys_sendmmsg -330 common process_vm_readv sys_process_vm_readv compat_sys_process_vm_readv -331 common process_vm_writev sys_process_vm_writev compat_sys_process_vm_writev +330 common process_vm_readv sys_process_vm_readv +331 common process_vm_writev sys_process_vm_writev 332 common kcmp sys_kcmp 333 common finit_module sys_finit_module 334 common sched_setattr sys_sched_setattr
arch/powerpc/kernel/syscalls/syscall.tbl +2 -2
@@ -449,8 +449,8 @@ 348 common syncfs sys_syncfs 349 common sendmmsg sys_sendmmsg compat_sys_sendmmsg 350 common setns sys_setns -351 nospu process_vm_readv sys_process_vm_readv compat_sys_process_vm_readv -352 nospu process_vm_writev sys_process_vm_writev compat_sys_process_vm_writev +351 nospu process_vm_readv sys_process_vm_readv +352 nospu process_vm_writev sys_process_vm_writev 353 nospu finit_module sys_finit_module 354 nospu kcmp sys_kcmp 355 common sched_setattr sys_sched_setattr
arch/s390/kernel/syscalls/syscall.tbl +2 -2
@@ -347,8 +347,8 @@ 337 common clock_adjtime sys_clock_adjtime sys_clock_adjtime32 338 common syncfs sys_syncfs sys_syncfs 339 common setns sys_setns sys_setns -340 common process_vm_readv sys_process_vm_readv compat_sys_process_vm_readv -341 common process_vm_writev sys_process_vm_writev compat_sys_process_vm_writev +340 common process_vm_readv sys_process_vm_readv sys_process_vm_readv +341 common process_vm_writev sys_process_vm_writev sys_process_vm_writev 342 common s390_runtime_instr sys_s390_runtime_instr sys_s390_runtime_instr 343 common kcmp sys_kcmp sys_kcmp 344 common finit_module sys_finit_module sys_finit_module
arch/sparc/kernel/syscalls/syscall.tbl +2 -2
@@ -406,8 +406,8 @@ 335 common syncfs sys_syncfs 336 common sendmmsg sys_sendmmsg compat_sys_sendmmsg 337 common setns sys_setns -338 common process_vm_readv sys_process_vm_readv compat_sys_process_vm_readv -339 common process_vm_writev sys_process_vm_writev compat_sys_process_vm_writev +338 common process_vm_readv sys_process_vm_readv +339 common process_vm_writev sys_process_vm_writev 340 32 kern_features sys_ni_syscall sys_kern_features 340 64 kern_features sys_kern_features 341 common kcmp sys_kcmp
arch/x86/entry/syscall_x32.c +2 -0
@@ -17,6 +17,8 @@#define __x32_sys_getsockopt __x64_sys_getsockopt#define __x32_sys_setsockopt __x64_sys_setsockopt#define __x32_sys_vmsplice __x64_sys_vmsplice +#define __x32_sys_process_vm_readv __x64_sys_process_vm_readv +#define __x32_sys_process_vm_writev __x64_sys_process_vm_writev#define __SYSCALL_64 (nr, sym)
arch/x86/entry/syscalls/syscall_32.tbl +2 -2
@@ -358,8 +358,8 @@ 344 i386 syncfs sys_syncfs 345 i386 sendmmsg sys_sendmmsg compat_sys_sendmmsg 346 i386 setns sys_setns -347 i386 process_vm_readv sys_process_vm_readv compat_sys_process_vm_readv -348 i386 process_vm_writev sys_process_vm_writev compat_sys_process_vm_writev +347 i386 process_vm_readv sys_process_vm_readv +348 i386 process_vm_writev sys_process_vm_writev 349 i386 kcmp sys_kcmp 350 i386 finit_module sys_finit_module 351 i386 sched_setattr sys_sched_setattr
arch/x86/entry/syscalls/syscall_64.tbl +2 -2
@@ -395,8 +395,8 @@ 536 x32 rt_tgsigqueueinfo compat_sys_rt_tgsigqueueinfo 537 x32 recvmmsg compat_sys_recvmmsg_time64 538 x32 sendmmsg compat_sys_sendmmsg -539 x32 process_vm_readv compat_sys_process_vm_readv -540 x32 process_vm_writev compat_sys_process_vm_writev +539 x32 process_vm_readv sys_process_vm_readv +540 x32 process_vm_writev sys_process_vm_writev 541 x32 setsockopt sys_setsockopt 542 x32 getsockopt sys_getsockopt 543 x32 io_setup compat_sys_io_setup
include/linux/compat.h +0 -8
@@ -780,14 +780,6 @@ asmlinkage long compat_sys_open_by_handle_at(int mountdirfd, int flags);asmlinkage long compat_sys_sendmmsg (int fd,struct compat_mmsghdr __user *mmsg,unsigned vlen,unsigned int flags); -asmlinkage ssize_t compat_sys_process_vm_readv(compat_pid_t pid, -const struct compat_iovec __user *lvec, -compat_ulong_t liovcnt,const struct compat_iovec __user *rvec, -compat_ulong_t riovcnt,compat_ulong_t flags); -asmlinkage ssize_t compat_sys_process_vm_writev(compat_pid_t pid, -const struct compat_iovec __user *lvec, -compat_ulong_t liovcnt,const struct compat_iovec __user *rvec, -compat_ulong_t riovcnt,compat_ulong_t flags);asmlinkage long compat_sys_execveat (int dfd,const char __user *filename,const compat_uptr_t __user *argv,const compat_uptr_t __user *envp,int flags);
include/uapi/asm-generic/unistd.h +2 -4
@@ -727,11 +727,9 @@ __SYSCALL(__NR_setns, sys_setns)#define __NR_sendmmsg 269 __SC_COMP(__NR_sendmmsg, sys_sendmmsg, compat_sys_sendmmsg)#define __NR_process_vm_readv 270 -__SC_COMP (__NR_process_vm_readv, sys_process_vm_readv, \ - compat_sys_process_vm_readv) +__SYSCALL(__NR_process_vm_readv, sys_process_vm_readv)#define __NR_process_vm_writev 271 -__SC_COMP (__NR_process_vm_writev, sys_process_vm_writev, \ - compat_sys_process_vm_writev) +__SYSCALL(__NR_process_vm_writev, sys_process_vm_writev)#define __NR_kcmp 272 __SYSCALL(__NR_kcmp, sys_kcmp)#define __NR_finit_module 273
mm/process_vm_access.c +0 -71
80 lines not on this page · raw message
tools/include/uapi/asm-generic/unistd.h +2 -4
@@ -727,11 +727,9 @@ __SYSCALL(__NR_setns, sys_setns)#define __NR_sendmmsg 269 __SC_COMP(__NR_sendmmsg, sys_sendmmsg, compat_sys_sendmmsg)#define __NR_process_vm_readv 270 -__SC_COMP (__NR_process_vm_readv, sys_process_vm_readv, \ - compat_sys_process_vm_readv) +__SYSCALL(__NR_process_vm_readv, sys_process_vm_readv)#define __NR_process_vm_writev 271 -__SC_COMP (__NR_process_vm_writev, sys_process_vm_writev, \ - compat_sys_process_vm_writev) +__SYSCALL(__NR_process_vm_writev, sys_process_vm_writev)#define __NR_kcmp 272 __SYSCALL(__NR_kcmp, sys_kcmp)#define __NR_finit_module 273
tools/perf/arch/powerpc/entry/syscalls/syscall.tbl +2 -2
@@ -443,8 +443,8 @@ 348 common syncfs sys_syncfs 349 common sendmmsg sys_sendmmsg compat_sys_sendmmsg 350 common setns sys_setns -351 nospu process_vm_readv sys_process_vm_readv compat_sys_process_vm_readv -352 nospu process_vm_writev sys_process_vm_writev compat_sys_process_vm_writev +351 nospu process_vm_readv sys_process_vm_readv +352 nospu process_vm_writev sys_process_vm_writev 353 nospu finit_module sys_finit_module 354 nospu kcmp sys_kcmp 355 common sched_setattr sys_sched_setattr
tools/perf/arch/s390/entry/syscalls/syscall.tbl +2 -2
@@ -347,8 +347,8 @@ 337 common clock_adjtime sys_clock_adjtime compat_sys_clock_adjtime 338 common syncfs sys_syncfs sys_syncfs 339 common setns sys_setns sys_setns -340 common process_vm_readv sys_process_vm_readv compat_sys_process_vm_readv -341 common process_vm_writev sys_process_vm_writev compat_sys_process_vm_writev +340 common process_vm_readv sys_process_vm_readv sys_process_vm_readv +341 common process_vm_writev sys_process_vm_writev sys_process_vm_writev 342 common s390_runtime_instr sys_s390_runtime_instr sys_s390_runtime_instr 343 common kcmp sys_kcmp compat_sys_kcmp 344 common finit_module sys_finit_module compat_sys_finit_module
tools/perf/arch/x86/entry/syscalls/syscall_64.tbl +2 -2
@@ -395,8 +395,8 @@ 536 x32 rt_tgsigqueueinfo compat_sys_rt_tgsigqueueinfo 537 x32 recvmmsg compat_sys_recvmmsg_time64 538 x32 sendmmsg compat_sys_sendmmsg -539 x32 process_vm_readv compat_sys_process_vm_readv -540 x32 process_vm_writev compat_sys_process_vm_writev +539 x32 process_vm_readv sys_process_vm_readv +540 x32 process_vm_writev sys_process_vm_writev 541 x32 setsockopt sys_setsockopt 542 x32 getsockopt sys_getsockopt 543 x32 io_setup compat_sys_io_setup
Signature · 1 line
2.28.0
PATCH 11/11 security/keys: remove compat_keyctl_instantiate_key_iov
In reply to Christoph HellwigNow that import_iovec handles compat iovecs, the native version of keyctl_instantiate_key_iov can be used for the compat case as well.
--- security/keys/compat.c | 36 ++---------------------------------- security/keys/internal.h | 5 ----- security/keys/keyctl.c | 2 +- 3 files changed, 3 insertions(+), 40 deletions(-)
security/keys/compat.c +2 -34
@@ -11,38 +11,6 @@#include <linux/slab.h> #include "internal.h" -/* -* Instantiate a key with the specified compatibility multipart payload and -* link the key into the destination keyring if one is given. -* -* The caller must have the appropriate instantiation permit set for this to -* work (see keyctl_assume_authority). No other permissions are required. -* -* If successful, 0 will be returned. -*/ -static long compat_keyctl_instantiate_key_iov ( -key_serial_t id, -const struct compat_iovec __user *_payload_iov, -unsigned ioc, -key_serial_t ringid) -{ -struct iovec iovstack[UIO_FASTIOV ], *iov = iovstack; -struct iov_iter from; -long ret; - -if (!_payload_iov) - ioc =0 ; - - ret =import_iovec (WRITE , (const struct iovec __user *)_payload_iov, - ioc,ARRAY_SIZE (iovstack), &iov, &from); -if (ret <0 ) -return ret; - - ret =keyctl_instantiate_key_common (id, &from, ringid); -kfree (iov); -return ret; -} -/* * The key control system call, 32-bit compatibility version for 64-bit archs */
@@ -113,8 +81,8 @@ COMPAT_SYSCALL_DEFINE5(keyctl, u32, option,return keyctl_reject_key (arg2, arg3, arg4, arg5);case KEYCTL_INSTANTIATE_IOV : -return compat_keyctl_instantiate_key_iov ( - arg2,compat_ptr (arg3), arg4, arg5); +return keyctl_instantiate_key_iov (arg2,compat_ptr (arg3), arg4, + arg5);case KEYCTL_INVALIDATE :return keyctl_invalidate_key (arg2);
security/keys/internal.h +0 -5
@@ -262,11 +262,6 @@ extern long keyctl_instantiate_key_iov(key_serial_t, const struct iovec __user *, unsigned, key_serial_t);extern long keyctl_invalidate_key (key_serial_t ); - -struct iov_iter ; -extern long keyctl_instantiate_key_common (key_serial_t , -struct iov_iter *, -key_serial_t );extern long keyctl_restrict_keyring (key_serial_t id,const char __user *_type,const char __user *_restriction);
security/keys/keyctl.c +1 -1
@@ -1164,7 +1164,7 @@ static int keyctl_change_reqkey_auth(struct key *key)* * If successful, 0 will be returned. */ -long keyctl_instantiate_key_common (key_serial_t id, +static long keyctl_instantiate_key_common (key_serial_t id,struct iov_iter *from,key_serial_t ringid) {
Signature · 1 line
2.28.0