-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
can-isotp: pass a sockptr_t into ->setsockopt - for Linux 5.9+
Following upstream commit a7b75c5a8c41 ("net: pass a sockptr_t into ->setsockopt") Signed-off-by: Oliver Hartkopp <[email protected]>
- Loading branch information
Showing
1 changed file
with
10 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,17 +71,17 @@ | |
#include <net/sock.h> | ||
#include <net/net_namespace.h> | ||
|
||
#define CAN_ISOTP_VERSION "20200525" | ||
#define CAN_ISOTP_VERSION "20200812" | ||
static __initdata const char banner[] = | ||
KERN_INFO "can: isotp protocol (rev " CAN_ISOTP_VERSION " alpha)\n"; | ||
KERN_INFO "can: isotp protocol (rev " CAN_ISOTP_VERSION ")\n"; | ||
|
||
MODULE_DESCRIPTION("PF_CAN isotp 15765-2:2016 protocol"); | ||
MODULE_LICENSE("Dual BSD/GPL"); | ||
MODULE_AUTHOR("Oliver Hartkopp <[email protected]>"); | ||
MODULE_ALIAS("can-proto-6"); | ||
|
||
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,4,0) | ||
#error This module needs Kernel 5.4 or newer | ||
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,9,0) | ||
#error This module needs Kernel 5.9 or newer | ||
#endif | ||
|
||
#define DBG(fmt, args...) (printk( KERN_DEBUG "can-isotp: %s: " fmt, \ | ||
|
@@ -1146,7 +1146,7 @@ static int isotp_getname(struct socket *sock, struct sockaddr *uaddr, int peer) | |
} | ||
|
||
static int isotp_setsockopt(struct socket *sock, int level, int optname, | ||
char __user *optval, unsigned int optlen) | ||
sockptr_t optval, unsigned int optlen) | ||
{ | ||
struct sock *sk = sock->sk; | ||
struct isotp_sock *so = isotp_sk(sk); | ||
|
@@ -1163,7 +1163,7 @@ static int isotp_setsockopt(struct socket *sock, int level, int optname, | |
if (optlen != sizeof(struct can_isotp_options)) | ||
return -EINVAL; | ||
|
||
if (copy_from_user(&so->opt, optval, optlen)) | ||
if (copy_from_sockptr(&so->opt, optval, optlen)) | ||
return -EFAULT; | ||
|
||
/* no separate rx_ext_address is given => use ext_address */ | ||
|
@@ -1175,23 +1175,23 @@ static int isotp_setsockopt(struct socket *sock, int level, int optname, | |
if (optlen != sizeof(struct can_isotp_fc_options)) | ||
return -EINVAL; | ||
|
||
if (copy_from_user(&so->rxfc, optval, optlen)) | ||
if (copy_from_sockptr(&so->rxfc, optval, optlen)) | ||
return -EFAULT; | ||
break; | ||
|
||
case CAN_ISOTP_TX_STMIN: | ||
if (optlen != sizeof(__u32)) | ||
return -EINVAL; | ||
|
||
if (copy_from_user(&so->force_tx_stmin, optval, optlen)) | ||
if (copy_from_sockptr(&so->force_tx_stmin, optval, optlen)) | ||
return -EFAULT; | ||
break; | ||
|
||
case CAN_ISOTP_RX_STMIN: | ||
if (optlen != sizeof(__u32)) | ||
return -EINVAL; | ||
|
||
if (copy_from_user(&so->force_rx_stmin, optval, optlen)) | ||
if (copy_from_sockptr(&so->force_rx_stmin, optval, optlen)) | ||
return -EFAULT; | ||
break; | ||
|
||
|
@@ -1201,7 +1201,7 @@ static int isotp_setsockopt(struct socket *sock, int level, int optname, | |
else { | ||
struct can_isotp_ll_options ll; | ||
|
||
if (copy_from_user(&ll, optval, optlen)) | ||
if (copy_from_sockptr(&ll, optval, optlen)) | ||
return -EFAULT; | ||
|
||
/* check for correct ISO 11898-1 DLC data lentgh */ | ||
|