Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1559009

Re: [PATCH] can: Fix kernel panic at security_sock_rcv_skb

From Oliver Hartkopp <socketcan@hartkopp.net>
Newsgroups linux.kernel
Subject Re: [PATCH] can: Fix kernel panic at security_sock_rcv_skb
Date 2017-01-14 15:00 +0100
Message-ID <sZx29-6CR-1@gated-at.bofh.it> (permalink)
References <sYHdg-CK-3@gated-at.bofh.it> <sYIVH-1G5-1@gated-at.bofh.it> <sYNiF-4mX-3@gated-at.bofh.it> <sYQzV-6d7-45@gated-at.bofh.it> <sZnvQ-Zl-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hello Eric,

On 01/14/2017 04:43 AM, Liu Shuo wrote:
> On Thu 12.Jan'17 at 17:33:38 +0100, Oliver Hartkopp wrote:
>> On 01/12/2017 02:01 PM, Eric Dumazet wrote:

>>> The main problem seems that the sockets themselves are not RCU
>>> protected.
>>>
>>> If CAN uses RCU for delivery, then sockets should be freed only after
>>> one RCU grace period.
>>>
>>> On recent kernels, following patch could help :
>>>
>>
>> Thanks Eric!
>>
>> @Liu ShuoX: Can you check if Eric's suggestion fixes the issue in your
>> setup?
> Sorry for late reply. I was OOO yesterday.
> With Eric's hint, i just found his patch that "net: add SOCK_RCU_FREE
> socket flag" in the latest kernel. With backporting this one plus Eric's
> following patch, it fixs my failure.

what would be the best approach to fix this issue - even in stable kernels?

E.g. would this change be ok for a stable as a quick fix?

diff --git a/net/can/af_can.c b/net/can/af_can.c
index 1108079d934f..6b974c2b66ef 100644
--- a/net/can/af_can.c
+++ b/net/can/af_can.c
@@ -112,6 +112,7 @@ EXPORT_SYMBOL(can_ioctl);

  static void can_sock_destruct(struct sock *sk)
  {
+       synchronize_rcu();
         skb_queue_purge(&sk->sk_receive_queue);
  }

And once this arrived in the mainline tree your suggested patch could be 
applied?

In any case we should not forget to give Reported-by credits to Liu.

Best regards,
Oliver

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] can: Fix kernel panic at security_sock_rcv_skb Liu ShuoX <shuo.a.liu@intel.com> - 2017-01-12 07:40 +0100
  Re: [PATCH] can: Fix kernel panic at security_sock_rcv_skb Oliver Hartkopp <socketcan@hartkopp.net> - 2017-01-12 09:30 +0100
    Re: [PATCH] can: Fix kernel panic at security_sock_rcv_skb Eric Dumazet <eric.dumazet@gmail.com> - 2017-01-12 14:10 +0100
      Re: [PATCH] can: Fix kernel panic at security_sock_rcv_skb Oliver Hartkopp <socketcan@hartkopp.net> - 2017-01-12 17:40 +0100
        Re: [PATCH] can: Fix kernel panic at security_sock_rcv_skb Liu Shuo <shuo.a.liu@intel.com> - 2017-01-14 04:50 +0100
          Re: [PATCH] can: Fix kernel panic at security_sock_rcv_skb Oliver Hartkopp <socketcan@hartkopp.net> - 2017-01-14 15:00 +0100
            Re: [PATCH] can: Fix kernel panic at security_sock_rcv_skb Eric Dumazet <eric.dumazet@gmail.com> - 2017-01-14 18:40 +0100

csiph-web