From bd3aa5d4a56ee39b26f84b37deced41359eb1bde Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sat, 29 Aug 2020 21:16:47 +0000 Subject: [PATCH] iscsi-scst: Port to Linux kernel v5.9 In Linux kernel v5.9 use of the KERNEL_SOCKPTR() function is mandatory when calling setsockopt(). Implement that function for kernels before v5.9. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9149 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/conn.c | 2 +- iscsi-scst/kernel/iscsi.c | 2 +- scst/include/backport.h | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/iscsi-scst/kernel/conn.c b/iscsi-scst/kernel/conn.c index a0bc04379..1cce72f68 100644 --- a/iscsi-scst/kernel/conn.c +++ b/iscsi-scst/kernel/conn.c @@ -791,7 +791,7 @@ static int conn_setup_sock(struct iscsi_conn *conn) oldfs = get_fs(); set_fs(KERNEL_DS); conn->sock->ops->setsockopt(conn->sock, SOL_TCP, TCP_NODELAY, - (void __force __user *)&opt, sizeof(opt)); + KERNEL_SOCKPTR(&opt), sizeof(opt)); set_fs(oldfs); out: diff --git a/iscsi-scst/kernel/iscsi.c b/iscsi-scst/kernel/iscsi.c index 7209251d2..be3831332 100644 --- a/iscsi-scst/kernel/iscsi.c +++ b/iscsi-scst/kernel/iscsi.c @@ -2895,7 +2895,7 @@ static inline void set_cork(struct socket *sock, int on) oldfs = get_fs(); set_fs(KERNEL_DS); sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, - (void __force __user *)&opt, sizeof(opt)); + KERNEL_SOCKPTR(&opt), sizeof(opt)); set_fs(oldfs); return; } diff --git a/scst/include/backport.h b/scst/include/backport.h index 194bd4bbf..0358636d4 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -1727,6 +1727,16 @@ static inline struct kmem_cache *kmem_cache_create_usercopy(const char *name, sizeof_field(struct __struct, __field), NULL) #endif +/* */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 9, 0) +/* See also commit ba423fdaa589 ("net: add a new sockptr_t type") # v5.9 */ +static inline void __user *KERNEL_SOCKPTR(void *p) +{ + return (void __force __user *)p; +} +#endif + /* */ #ifndef sizeof_field