mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-25 21:24:08 +08:00
linux-can-fixes-for-5.13-20210512
-----BEGIN PGP SIGNATURE----- iQFHBAABCgAxFiEEK3kIWJt9yTYMP3ehqclaivrt76kFAmCbfrsTHG1rbEBwZW5n dXRyb25peC5kZQAKCRCpyVqK+u3vqRUTB/9tORTrJ2x43hVPVVUqR50c4izuKyTi 5q66+P7SBh4n0HHwaZnUBTyGEnC0u2UcdmtHTXswcBP1vSd2+PlP9HNwOAuQP+Ng uSzJEZ1usmOd8PCpN3WRBaQ8poCRaX2ifwc4s9xnOMUf5mZMx3vkgZgApMz5pScc IpqM09NdEsMkmGFpfttjPi32tnC2FpK9L3f2B1DzmSC8IaZyawI5jj+l9DKsxFoG mwlBx1IGqmICvAS5LvZWvypnDmSP652RaHQ2ZCp1oEzLhbCugKKIvyed1C0L0KGC A7YaAbR/OwMBdrSaWStANzBSFfNTPrXGCfOcKdIaoR8elR47D7qc/02l =QTJ/ -----END PGP SIGNATURE----- Merge tag 'linux-can-fixes-for-5.13-20210512' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can Marc Kleine-Budde says: ==================== pull-request: can 2021-05-12 this is a pull request of a single patch for net/master. The patch is by Norbert Slusarek and it fixes a race condition in the CAN ISO-TP socket between isotp_bind() and isotp_setsockopt(). ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
364642ae80
@ -1062,19 +1062,6 @@ static int isotp_bind(struct socket *sock, struct sockaddr *uaddr, int len)
|
||||
if (len < ISOTP_MIN_NAMELEN)
|
||||
return -EINVAL;
|
||||
|
||||
/* do not register frame reception for functional addressing */
|
||||
if (so->opt.flags & CAN_ISOTP_SF_BROADCAST)
|
||||
do_rx_reg = 0;
|
||||
|
||||
/* do not validate rx address for functional addressing */
|
||||
if (do_rx_reg) {
|
||||
if (addr->can_addr.tp.rx_id == addr->can_addr.tp.tx_id)
|
||||
return -EADDRNOTAVAIL;
|
||||
|
||||
if (addr->can_addr.tp.rx_id & (CAN_ERR_FLAG | CAN_RTR_FLAG))
|
||||
return -EADDRNOTAVAIL;
|
||||
}
|
||||
|
||||
if (addr->can_addr.tp.tx_id & (CAN_ERR_FLAG | CAN_RTR_FLAG))
|
||||
return -EADDRNOTAVAIL;
|
||||
|
||||
@ -1083,6 +1070,23 @@ static int isotp_bind(struct socket *sock, struct sockaddr *uaddr, int len)
|
||||
|
||||
lock_sock(sk);
|
||||
|
||||
/* do not register frame reception for functional addressing */
|
||||
if (so->opt.flags & CAN_ISOTP_SF_BROADCAST)
|
||||
do_rx_reg = 0;
|
||||
|
||||
/* do not validate rx address for functional addressing */
|
||||
if (do_rx_reg) {
|
||||
if (addr->can_addr.tp.rx_id == addr->can_addr.tp.tx_id) {
|
||||
err = -EADDRNOTAVAIL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (addr->can_addr.tp.rx_id & (CAN_ERR_FLAG | CAN_RTR_FLAG)) {
|
||||
err = -EADDRNOTAVAIL;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
if (so->bound && addr->can_ifindex == so->ifindex &&
|
||||
addr->can_addr.tp.rx_id == so->rxid &&
|
||||
addr->can_addr.tp.tx_id == so->txid)
|
||||
@ -1164,16 +1168,13 @@ static int isotp_getname(struct socket *sock, struct sockaddr *uaddr, int peer)
|
||||
return ISOTP_MIN_NAMELEN;
|
||||
}
|
||||
|
||||
static int isotp_setsockopt(struct socket *sock, int level, int optname,
|
||||
static int isotp_setsockopt_locked(struct socket *sock, int level, int optname,
|
||||
sockptr_t optval, unsigned int optlen)
|
||||
{
|
||||
struct sock *sk = sock->sk;
|
||||
struct isotp_sock *so = isotp_sk(sk);
|
||||
int ret = 0;
|
||||
|
||||
if (level != SOL_CAN_ISOTP)
|
||||
return -EINVAL;
|
||||
|
||||
if (so->bound)
|
||||
return -EISCONN;
|
||||
|
||||
@ -1248,6 +1249,22 @@ static int isotp_setsockopt(struct socket *sock, int level, int optname,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int isotp_setsockopt(struct socket *sock, int level, int optname,
|
||||
sockptr_t optval, unsigned int optlen)
|
||||
|
||||
{
|
||||
struct sock *sk = sock->sk;
|
||||
int ret;
|
||||
|
||||
if (level != SOL_CAN_ISOTP)
|
||||
return -EINVAL;
|
||||
|
||||
lock_sock(sk);
|
||||
ret = isotp_setsockopt_locked(sock, level, optname, optval, optlen);
|
||||
release_sock(sk);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int isotp_getsockopt(struct socket *sock, int level, int optname,
|
||||
char __user *optval, int __user *optlen)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user