Skip to content

Commit

Permalink
can-isotp: pass a sockptr_t into ->setsockopt - for Linux 5.9+
Browse files Browse the repository at this point in the history
Following upstream commit a7b75c5a8c41
("net: pass a sockptr_t into ->setsockopt")

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
  • Loading branch information
hartkopp committed Aug 12, 2020
1 parent d50a200 commit 98986fc
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions net/can/isotp.c
Expand Up @@ -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 <socketcan@hartkopp.net>");
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, \
Expand Down Expand Up @@ -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);
Expand All @@ -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 */
Expand All @@ -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;

Expand All @@ -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 */
Expand Down

0 comments on commit 98986fc

Please sign in to comment.