Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
commit 8af877b110548408b1fdf7ddbed830be68d7fb05 Author: Linus Torvalds torvalds@linux-foundation.org Date: Tue Jan 8 09:16:21 2019 +0100
batman-adv: Remove 'type' argument from access_ok() function
Nobody has actually used the type (VERIFY_READ vs VERIFY_WRITE) argument of the user address range verification function since we got rid of the old racy i386-only code to walk page tables by hand.
It existed because the original 80386 would not honor the write protect bit when in kernel mode, so you had to do COW by hand before doing any user access. But we haven't supported that in a long time, and these days the 'type' argument is a purely historical artifact.
A discussion about extending 'user_access_begin()' to do the range checking resulted this patch, because there is no way we're going to move the old VERIFY_xyz interface to that model. And it's best done at the end of the merge window when I've done most of my merges, so let's just get this done once and for all.
Signed-off-by: Linus Torvalds torvalds@linux-foundation.org [sven@narfation.org: Added compat code] Signed-off-by: Sven Eckelmann sven@narfation.org
8af877b110548408b1fdf7ddbed830be68d7fb05 compat-include/linux/{compiler.h => uaccess.h} | 28 ++++++++++++++------------ net/batman-adv/icmp_socket.c | 2 +- net/batman-adv/log.c | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/compat-include/linux/compiler.h b/compat-include/linux/uaccess.h similarity index 62% copy from compat-include/linux/compiler.h copy to compat-include/linux/uaccess.h index f4a84b11..0cd56a60 100644 --- a/compat-include/linux/compiler.h +++ b/compat-include/linux/uaccess.h @@ -19,24 +19,26 @@ * of the Linux kernel. */
-#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_COMPILER_H_ -#define _NET_BATMAN_ADV_COMPAT_LINUX_COMPILER_H_ +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_UACCESS_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_UACCESS_H_
#include <linux/version.h> -#include_next <linux/compiler.h> +#include_next <linux/uaccess.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
-#ifndef READ_ONCE -#define READ_ONCE(x) ACCESS_ONCE(x) -#endif +static inline int batadv_access_ok(int type, const void __user *p, + unsigned long size) +{ + return access_ok(type, p, size); +}
-#ifndef WRITE_ONCE -#define WRITE_ONCE(x, val) ({ \ - ACCESS_ONCE(x) = (val); \ -}) +#ifdef access_ok +#undef access_ok #endif
-#endif /* < KERNEL_VERSION(3, 19, 0) */ +#define access_ok(addr, size) batadv_access_ok(VERIFY_WRITE, (addr), (size)) + +#endif /* < KERNEL_VERSION(5, 0, 0) */
-#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_COMPILER_H_ */ +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_UACCESS_H_ */ diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c index d34bb79e..9859abab 100644 --- a/net/batman-adv/icmp_socket.c +++ b/net/batman-adv/icmp_socket.c @@ -147,7 +147,7 @@ static ssize_t batadv_socket_read(struct file *file, char __user *buf, if (!buf || count < sizeof(struct batadv_icmp_packet)) return -EINVAL;
- if (!access_ok(VERIFY_WRITE, buf, count)) + if (!access_ok(buf, count)) return -EFAULT;
error = wait_event_interruptible(socket_client->queue_wait, diff --git a/net/batman-adv/log.c b/net/batman-adv/log.c index f97849a8..3e610df8 100644 --- a/net/batman-adv/log.c +++ b/net/batman-adv/log.c @@ -136,7 +136,7 @@ static ssize_t batadv_log_read(struct file *file, char __user *buf, if (count == 0) return 0;
- if (!access_ok(VERIFY_WRITE, buf, count)) + if (!access_ok(buf, count)) return -EFAULT;
error = wait_event_interruptible(debug_log->queue_wait,