Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp61098img; Tue, 19 Mar 2019 17:55:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0lHCnZYuF6Kkvi2XnUqlIx3jmJG1lge6coxxjiHhYjeOxhywkvyZ8i6pNMa08nEu6S3xG X-Received: by 2002:a63:88c3:: with SMTP id l186mr4783159pgd.148.1553043300261; Tue, 19 Mar 2019 17:55:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553043300; cv=none; d=google.com; s=arc-20160816; b=iQlCHFm1WBh6NvwNWbA4FrmsSn85+UKs3XZc6L/9RKp6EH+i5fUa52ecpJ2ip/ZHTq 0tjPqgvE++P94/NquU1YRcf6CguW/47doYg3VrSvyPGlIcmrGD583ovJvq9QyylW9mHr vxjIe8ODnNQCeH03h6I79JMaurATNFhj2PA4zVlBKurx3etMbDgIbVNu5UXxetUt2Y96 Y3+8Jz+Cfaa5xGBxfo5N/j8PNAj7ysoFbNWOdtkR1D31F7gfp8UNrKTiHjvOsHPlrShb 2ymMavCz/iHRsbX/QCoOt28CMnuBmXmDMYwfZqHabmGHEtds0GxuuNrKoPSwNR2LL544 9qtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=A6gxBtHB16sRMGM4kOCsJvs8cpaxSC7qj71mFe7s3qw=; b=JJz5f93FBVkXk0LgbMxDENopsCs2SEakQltXAFG7Bc5139XI/zfkfshcYiAVXZ5JQt /ernrDVqm01eXpxPjx2rZVYdytV7o2yifzsZFH6Rt+fxNrJn6pYsYt+q9JUVMhmkKSNu dH4C3kex6eziccEd84r2EGpBOvIA0m5dB04aC11mgEECSPhM3sZRpOzOa7WQh/U3fvMm 05gCPxcE4ysHNMM5nczig8n1zJJ4IFd+wlJF/MkgyI7yedbHk5GNuh6RyIj2SFj52LoQ eNCardCKujrjRupB/tZAlzb2+AEs/WP+87SCekVvHvdjhCoZKMx39l18yidmg82pDoou ugWA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n8si311063pgq.119.2019.03.19.17.54.45; Tue, 19 Mar 2019 17:55:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727483AbfCTAyC (ORCPT + 99 others); Tue, 19 Mar 2019 20:54:02 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:54459 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727047AbfCTAyC (ORCPT ); Tue, 19 Mar 2019 20:54:02 -0400 X-IronPort-AV: E=Sophos;i="5.60,246,1549900800"; d="scan'208";a="57180373" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 20 Mar 2019 08:53:57 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id C7A4C4CD445B; Wed, 20 Mar 2019 08:53:26 +0800 (CST) Received: from [10.167.226.33] (10.167.226.33) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 20 Mar 2019 08:54:00 +0800 Subject: Re: [PATCH v3] net: xfrm: Add '_rcu' tag for rcu protected pointer in netns_xfrm To: Steffen Klassert , Eric Dumazet CC: , , , References: <1551923648-17656-1-git-send-email-suyj.fnst@cn.fujitsu.com> <20190311101006.GK3758@gauss3.secunet.de> <20190319151503.GW6035@gauss3.secunet.de> From: "Su Yanjun " Message-ID: <91cf303a-7d44-2c15-8b7a-8b2eb797a234@cn.fujitsu.com> Date: Wed, 20 Mar 2019 08:53:54 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.3 MIME-Version: 1.0 In-Reply-To: <20190319151503.GW6035@gauss3.secunet.de> Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.33] X-yoursite-MailScanner-ID: C7A4C4CD445B.AA078 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: suyj.fnst@cn.fujitsu.com X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/3/19 23:15, Steffen Klassert wrote: > On Mon, Mar 18, 2019 at 10:22:46AM -0700, Eric Dumazet wrote: >> >> On 03/11/2019 03:10 AM, Steffen Klassert wrote: >>> On Wed, Mar 06, 2019 at 08:54:08PM -0500, Su Yanjun wrote: >>>> For rcu protected pointers, we'd better add '__rcu' for them. >>>> >>>> Once added '__rcu' tag for rcu protected pointer, the sparse tool reports >>>> warnings. >>>> >>>> net/xfrm/xfrm_user.c:1198:39: sparse: expected struct sock *sk >>>> net/xfrm/xfrm_user.c:1198:39: sparse: got struct sock [noderef] *nlsk >>>> [...] >>>> >>>> So introduce a new wrapper function of nlmsg_unicast to handle type >>>> conversions. >>>> >>>> This patch also fixes a direct access of a rcu protected socket. >>>> >>>> Fixes: be33690d8fcf("[XFRM]: Fix aevent related crash") >>>> Signed-off-by: Su Yanjun >>> Patch applied, thanks! >>> >> Has this patch ever been tested ? > I had this on your testing system and it did > not complain. But maybe my testcases did not > trigger that codepath. Su, can you answer > on Eric question? > Firs of all, I didn't produce it on my test machine. Maybe we need recompile the kernel with Eric Dumazet's advise. CONFIG_LOCKDEP=y CONFIG_PROVE_RCU=y The second the code path indeed doesn't do as below: rcu_read_lock() rcu_dereference() ... rcu_read_unlock() All rcu_dereference are in the follow code path: xfrm_user_rcv_msg link->doit(skb, nlh, attrs) rcu_dereference() I think we can add rcu protection for nlsock xfrm_user_rcv_msg rcu_read_lock() link->doit(skb, nlh, attrs) rcu_read_unlock() Any advise?