Skip to content

Commit

Permalink
can: j1939: transport: j1939_simple_recv(): ignore local J1939 messag…
Browse files Browse the repository at this point in the history
…es send not by J1939 stack

In current J1939 stack implementation, we process all locally send
messages as own messages. Even if it was send by CAN_RAW socket.

To reproduce it use following commands:
testj1939 -P -r can0:0x80 &
cansend can0 18238040#0123

This step will trigger false positive not critical warning:
j1939_simple_recv: Received already invalidated message

With this patch we add additional check to make sure, related skb is own
echo message.

Fixes: 9d71dd0 ("can: add support of SAE J1939 protocol")
Signed-off-by: Oleksij Rempel <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Marc Kleine-Budde <[email protected]>
  • Loading branch information
olerem authored and marckleinebudde committed Aug 14, 2020
1 parent 38ba8b9 commit b43e3a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions net/can/j1939/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ static int j1939_sk_init(struct sock *sk)
spin_lock_init(&jsk->sk_session_queue_lock);
INIT_LIST_HEAD(&jsk->sk_session_queue);
sk->sk_destruct = j1939_sk_sock_destruct;
sk->sk_protocol = CAN_J1939;

return 0;
}
Expand Down
4 changes: 4 additions & 0 deletions net/can/j1939/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -2017,6 +2017,10 @@ void j1939_simple_recv(struct j1939_priv *priv, struct sk_buff *skb)
if (!skb->sk)
return;

if (skb->sk->sk_family != AF_CAN ||
skb->sk->sk_protocol != CAN_J1939)
return;

j1939_session_list_lock(priv);
session = j1939_session_get_simple(priv, skb);
j1939_session_list_unlock(priv);
Expand Down

0 comments on commit b43e3a8

Please sign in to comment.