mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-23 11:04:44 +08:00
linux-can-fixes-for-5.12-20210329
-----BEGIN PGP SIGNATURE----- iQFHBAABCgAxFiEEK3kIWJt9yTYMP3ehqclaivrt76kFAmBhh4cTHG1rbEBwZW5n dXRyb25peC5kZQAKCRCpyVqK+u3vqT0uCACG3TrFXLFVo3VB+EaMKttdjD+KlfnA zABhon47XEHuNaxfYRy9BUjwbz3ig6e0qYd3I23G02dQaLTFyoQmx5msquVS1LoW 3H4D+VtWNdOspJn3N/cG+JJmPeZRON40EzFRFgKElg+IhanuxOox5IVtt68azNaj Kpx9+dlLla26P1xIFnrppfs0V19fHcr9nM1c+u5s2c1kuQyHgI2gNqZL6Ot+uGVv YyqQKQCQagXpTIM7Z1DC8ehclhpJABkwzQxWb8C6O6fldV3PVaJ8G9QXdjtCX/Jh 4ZJR7LDFMQBIcUrQycyxw9rpIlyLGbIdgCSShcCDZMJE0xYsV19RbgUs =Ru5R -----END PGP SIGNATURE----- Merge tag 'linux-can-fixes-for-5.12-20210329' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can Marc Kleine-Budde says: ==================== pull-request: can 2021-03-29 this is a pull request of 3 patches for net/master. The two patch are by Oliver Hartkopp. He fixes length check in the proto_ops::getname callback for the CAN RAW, BCM and ISOTP protocols, which were broken by the introduction of the J1939 protocol. The last patch is by me and fixes the a BUILD_BUG_ON() check which triggers on ARCH=arm with CONFIG_AEABI unset. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
f4c848db16
@ -113,7 +113,7 @@ struct can_frame {
|
||||
*/
|
||||
__u8 len;
|
||||
__u8 can_dlc; /* deprecated */
|
||||
};
|
||||
} __attribute__((packed)); /* disable padding added in some ABIs */
|
||||
__u8 __pad; /* padding */
|
||||
__u8 __res0; /* reserved / padding */
|
||||
__u8 len8_dlc; /* optional DLC for 8 byte payload length (9 .. 15) */
|
||||
|
@ -86,6 +86,8 @@ MODULE_LICENSE("Dual BSD/GPL");
|
||||
MODULE_AUTHOR("Oliver Hartkopp <oliver.hartkopp@volkswagen.de>");
|
||||
MODULE_ALIAS("can-proto-2");
|
||||
|
||||
#define BCM_MIN_NAMELEN CAN_REQUIRED_SIZE(struct sockaddr_can, can_ifindex)
|
||||
|
||||
/*
|
||||
* easy access to the first 64 bit of can(fd)_frame payload. cp->data is
|
||||
* 64 bit aligned so the offset has to be multiples of 8 which is ensured
|
||||
@ -1292,7 +1294,7 @@ static int bcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
|
||||
/* no bound device as default => check msg_name */
|
||||
DECLARE_SOCKADDR(struct sockaddr_can *, addr, msg->msg_name);
|
||||
|
||||
if (msg->msg_namelen < CAN_REQUIRED_SIZE(*addr, can_ifindex))
|
||||
if (msg->msg_namelen < BCM_MIN_NAMELEN)
|
||||
return -EINVAL;
|
||||
|
||||
if (addr->can_family != AF_CAN)
|
||||
@ -1534,7 +1536,7 @@ static int bcm_connect(struct socket *sock, struct sockaddr *uaddr, int len,
|
||||
struct net *net = sock_net(sk);
|
||||
int ret = 0;
|
||||
|
||||
if (len < CAN_REQUIRED_SIZE(*addr, can_ifindex))
|
||||
if (len < BCM_MIN_NAMELEN)
|
||||
return -EINVAL;
|
||||
|
||||
lock_sock(sk);
|
||||
@ -1616,8 +1618,8 @@ static int bcm_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
|
||||
sock_recv_ts_and_drops(msg, sk, skb);
|
||||
|
||||
if (msg->msg_name) {
|
||||
__sockaddr_check_size(sizeof(struct sockaddr_can));
|
||||
msg->msg_namelen = sizeof(struct sockaddr_can);
|
||||
__sockaddr_check_size(BCM_MIN_NAMELEN);
|
||||
msg->msg_namelen = BCM_MIN_NAMELEN;
|
||||
memcpy(msg->msg_name, skb->cb, msg->msg_namelen);
|
||||
}
|
||||
|
||||
|
@ -77,6 +77,8 @@ MODULE_LICENSE("Dual BSD/GPL");
|
||||
MODULE_AUTHOR("Oliver Hartkopp <socketcan@hartkopp.net>");
|
||||
MODULE_ALIAS("can-proto-6");
|
||||
|
||||
#define ISOTP_MIN_NAMELEN CAN_REQUIRED_SIZE(struct sockaddr_can, can_addr.tp)
|
||||
|
||||
#define SINGLE_MASK(id) (((id) & CAN_EFF_FLAG) ? \
|
||||
(CAN_EFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG) : \
|
||||
(CAN_SFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG))
|
||||
@ -986,7 +988,8 @@ static int isotp_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
|
||||
sock_recv_timestamp(msg, sk, skb);
|
||||
|
||||
if (msg->msg_name) {
|
||||
msg->msg_namelen = sizeof(struct sockaddr_can);
|
||||
__sockaddr_check_size(ISOTP_MIN_NAMELEN);
|
||||
msg->msg_namelen = ISOTP_MIN_NAMELEN;
|
||||
memcpy(msg->msg_name, skb->cb, msg->msg_namelen);
|
||||
}
|
||||
|
||||
@ -1056,7 +1059,7 @@ static int isotp_bind(struct socket *sock, struct sockaddr *uaddr, int len)
|
||||
int notify_enetdown = 0;
|
||||
int do_rx_reg = 1;
|
||||
|
||||
if (len < CAN_REQUIRED_SIZE(struct sockaddr_can, can_addr.tp))
|
||||
if (len < ISOTP_MIN_NAMELEN)
|
||||
return -EINVAL;
|
||||
|
||||
/* do not register frame reception for functional addressing */
|
||||
@ -1152,13 +1155,13 @@ static int isotp_getname(struct socket *sock, struct sockaddr *uaddr, int peer)
|
||||
if (peer)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
memset(addr, 0, sizeof(*addr));
|
||||
memset(addr, 0, ISOTP_MIN_NAMELEN);
|
||||
addr->can_family = AF_CAN;
|
||||
addr->can_ifindex = so->ifindex;
|
||||
addr->can_addr.tp.rx_id = so->rxid;
|
||||
addr->can_addr.tp.tx_id = so->txid;
|
||||
|
||||
return sizeof(*addr);
|
||||
return ISOTP_MIN_NAMELEN;
|
||||
}
|
||||
|
||||
static int isotp_setsockopt(struct socket *sock, int level, int optname,
|
||||
|
@ -60,6 +60,8 @@ MODULE_LICENSE("Dual BSD/GPL");
|
||||
MODULE_AUTHOR("Urs Thuermann <urs.thuermann@volkswagen.de>");
|
||||
MODULE_ALIAS("can-proto-1");
|
||||
|
||||
#define RAW_MIN_NAMELEN CAN_REQUIRED_SIZE(struct sockaddr_can, can_ifindex)
|
||||
|
||||
#define MASK_ALL 0
|
||||
|
||||
/* A raw socket has a list of can_filters attached to it, each receiving
|
||||
@ -394,7 +396,7 @@ static int raw_bind(struct socket *sock, struct sockaddr *uaddr, int len)
|
||||
int err = 0;
|
||||
int notify_enetdown = 0;
|
||||
|
||||
if (len < CAN_REQUIRED_SIZE(*addr, can_ifindex))
|
||||
if (len < RAW_MIN_NAMELEN)
|
||||
return -EINVAL;
|
||||
if (addr->can_family != AF_CAN)
|
||||
return -EINVAL;
|
||||
@ -475,11 +477,11 @@ static int raw_getname(struct socket *sock, struct sockaddr *uaddr,
|
||||
if (peer)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
memset(addr, 0, sizeof(*addr));
|
||||
memset(addr, 0, RAW_MIN_NAMELEN);
|
||||
addr->can_family = AF_CAN;
|
||||
addr->can_ifindex = ro->ifindex;
|
||||
|
||||
return sizeof(*addr);
|
||||
return RAW_MIN_NAMELEN;
|
||||
}
|
||||
|
||||
static int raw_setsockopt(struct socket *sock, int level, int optname,
|
||||
@ -739,7 +741,7 @@ static int raw_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
|
||||
if (msg->msg_name) {
|
||||
DECLARE_SOCKADDR(struct sockaddr_can *, addr, msg->msg_name);
|
||||
|
||||
if (msg->msg_namelen < CAN_REQUIRED_SIZE(*addr, can_ifindex))
|
||||
if (msg->msg_namelen < RAW_MIN_NAMELEN)
|
||||
return -EINVAL;
|
||||
|
||||
if (addr->can_family != AF_CAN)
|
||||
@ -832,8 +834,8 @@ static int raw_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
|
||||
sock_recv_ts_and_drops(msg, sk, skb);
|
||||
|
||||
if (msg->msg_name) {
|
||||
__sockaddr_check_size(sizeof(struct sockaddr_can));
|
||||
msg->msg_namelen = sizeof(struct sockaddr_can);
|
||||
__sockaddr_check_size(RAW_MIN_NAMELEN);
|
||||
msg->msg_namelen = RAW_MIN_NAMELEN;
|
||||
memcpy(msg->msg_name, skb->cb, msg->msg_namelen);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user