Patch "can: bcm: fix warning in bcm_connect/proc_register" has been added to the 4.8-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
can: bcm: fix warning in bcm_connect/proc_register
to the 4.8-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
can-bcm-fix-warning-in-bcm_connect-proc_register.patch
and it can be found in the queue-4.8 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
deb507f91f1adbf64317ad24ac46c56eeccfb754Mon Sep 17 00:00:00 2001
From: Oliver Hartkopp <[email protected]>
Date: Mon, 24 Oct 2016 21:11:26 +0200
Subject: can: bcm: fix warning in bcm_connect/proc_register
From: Oliver Hartkopp <[email protected]>
commit deb507f91f1adbf64317ad24ac46c56eeccfb754 upstream.
Andrey Konovalov reported an issue with proc_register in bcm.c. As suggested by Cong Wang this patch adds a lock_sock() protection and a check for unsuccessful proc_create_data() in bcm_connect().
Reference: http://marc.info/?l=linux-netdev&m=147732648731237
--- net/can/bcm.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-)
net/can/bcm.c +23 -9
@@ -1549,24 +1549,31 @@ static int bcm_connect(struct socket *sostruct sockaddr_can *addr = (struct sockaddr_can *)uaddr;struct sock *sk = sock->sk;struct bcm_sock *bo =bcm_sk (sk); +int ret =0 ;if (len <sizeof (*addr))return -EINVAL ; -if (bo->bound) -return -EISCONN ; +lock_sock (sk); + +if (bo->bound) { + ret = -EISCONN ; + goto fail; + }/* bind a device to this socket */ if (addr->can_ifindex) {struct net_device *dev; dev =dev_get_by_index (&init_net, addr->can_ifindex); -if (!dev) -return -ENODEV ; - +if (!dev) { + ret = -ENODEV ; + goto fail; + }if (dev->type !=ARPHRD_CAN ) {dev_put (dev); -return -ENODEV ; + ret = -ENODEV ; + goto fail; } bo->ifindex = dev->ifindex;
@@ -1577,17 +1584,24 @@ static int bcm_connect(struct socket *so bo->ifindex =0 ; } - bo->bound =1 ; -if (proc_dir) {/* unique socket address as filename */ sprintf (bo->procname,"%lu" ,sock_i_ino (sk)); bo->bcm_proc_read =proc_create_data (bo->procname,0644 , proc_dir, &bcm_proc_fops, sk); +if (!bo->bcm_proc_read) { + ret = -ENOMEM ; + goto fail; + } } -return 0 ; + bo->bound =1 ; + +fail: +release_sock (sk); + +return ret; } static int bcm_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
Patches currently in stable-queue which might be from [email protected] are
queue-4.8/can-bcm-fix-warning-in-bcm_connect-proc_register.patch