From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751094AbdANDpD (ORCPT ); Fri, 13 Jan 2017 22:45:03 -0500 Received: from mga03.intel.com ([134.134.136.65]:39597 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750808AbdANDpB (ORCPT ); Fri, 13 Jan 2017 22:45:01 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,225,1477983600"; d="scan'208";a="52865219" Date: Sat, 14 Jan 2017 11:43:30 +0800 From: Liu Shuo To: Oliver Hartkopp Cc: Eric Dumazet , linux-kernel@vger.kernel.org, yanmin_zhang@linux.intel.com, shuox.liu@gmail.com, Zhang Yanmin , "He, Bo" , Marc Kleine-Budde , "David S. Miller" , "open list:CAN NETWORK LAYER" , "open list:NETWORKING [GENERAL]" Subject: Re: [PATCH] can: Fix kernel panic at security_sock_rcv_skb Message-ID: <20170114034330.GA30070@shuo-desktop.sh.intel.com> References: <1484202799-7287-1-git-send-email-shuo.a.liu@intel.com> <0e458012-e97b-298d-296e-ed25e35689a0@hartkopp.net> <1484226099.15816.25.camel@edumazet-glaptop3.roam.corp.google.com> <9e6817a0-65b3-ed16-4616-f8e55aee09c4@hartkopp.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <9e6817a0-65b3-ed16-4616-f8e55aee09c4@hartkopp.net> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 12.Jan'17 at 17:33:38 +0100, Oliver Hartkopp wrote: >On 01/12/2017 02:01 PM, Eric Dumazet wrote: >>On Thu, 2017-01-12 at 09:22 +0100, Oliver Hartkopp wrote: > >>>But my main concern is: >>> >>>The reason why can_rx_delete_receiver() was introduced was the need to >>>remove a huge number of receivers with can_rx_unregister(). >>> >>>When you call synchronize_rcu() after each receiver removal this would >>>potentially lead to a big performance issue when e.g. closing CAN_RAW >>>sockets with a high number of receivers. >>> >>>So the idea was to remove/unlink the receiver hlist_del_rcu(&r->list) >>>and also kmem_cache_free(rcv_cache, r) by some rcu mechanism - so that >>>all elements are cleaned up by rcu at a later point. >>> >>>Is it possible that the problems emerge due to hlist_del_rcu(&r->list) >>>and you accidently fix it with your introduced synchronize_rcu()? >> >>I agree this patch does not fix the root cause. >> >>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. Thanks Eric and Oliver! Shuo > >Best regards, >Oliver