Patch "can: j1939: j1939_sk_bind(): return failure if netdev is down" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    can: j1939: j1939_sk_bind(): return failure if netdev is down

to the 5.4-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-j1939-j1939_sk_bind-return-failure-if-netdev-is-.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit c0f3f01e29cf2a07bf7fd78c441100782c31a8be
Author: Zhang Changzhong <zhangchangzhong@xxxxxxxxxx>
Date:   Mon Sep 7 14:31:48 2020 +0800

    can: j1939: j1939_sk_bind(): return failure if netdev is down
    
    [ Upstream commit 08c487d8d807535f509ed80c6a10ad90e6872139 ]
    
    When a netdev down event occurs after a successful call to
    j1939_sk_bind(), j1939_netdev_notify() can handle it correctly.
    
    But if the netdev already in down state before calling j1939_sk_bind(),
    j1939_sk_release() will stay in wait_event_interruptible() blocked
    forever. Because in this case, j1939_netdev_notify() won't be called and
    j1939_tp_txtimer() won't call j1939_session_cancel() or other function
    to clear session for ENETDOWN error, this lead to mismatch of
    j1939_session_get/put() and jsk->skb_pending will never decrease to
    zero.
    
    To reproduce it use following commands:
    1. ip link add dev vcan0 type vcan
    2. j1939acd -r 100,80-120 1122334455667788 vcan0
    3. presses ctrl-c and thread will be blocked forever
    
    This patch adds check for ndev->flags in j1939_sk_bind() to avoid this
    kind of situation and return with -ENETDOWN.
    
    Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
    Signed-off-by: Zhang Changzhong <zhangchangzhong@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/1599460308-18770-1-git-send-email-zhangchangzhong@xxxxxxxxxx
    Acked-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>
    Signed-off-by: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/can/j1939/socket.c b/net/can/j1939/socket.c
index bf9fd6ee88fe0..0470909605392 100644
--- a/net/can/j1939/socket.c
+++ b/net/can/j1939/socket.c
@@ -475,6 +475,12 @@ static int j1939_sk_bind(struct socket *sock, struct sockaddr *uaddr, int len)
 			goto out_release_sock;
 		}
 
+		if (!(ndev->flags & IFF_UP)) {
+			dev_put(ndev);
+			ret = -ENETDOWN;
+			goto out_release_sock;
+		}
+
 		priv = j1939_netdev_start(ndev);
 		dev_put(ndev);
 		if (IS_ERR(priv)) {



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux