Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1592500ybt; Thu, 18 Jun 2020 12:20:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCvGboLw+tFX8O8HdHVRCY86dajQfFQYFTA088NW9AoZIm7ginrs2J/jqxiw9BLG2SNqYS X-Received: by 2002:a17:906:a387:: with SMTP id k7mr216365ejz.408.1592508021377; Thu, 18 Jun 2020 12:20:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592508021; cv=none; d=google.com; s=arc-20160816; b=IJockhry+Y5M8L3g5Ib1tKczrtFJnMWvNbWw0IidYdcOiVcEar2/gN5snzE7dgzoGm ykibEjMjkgY2+6aRd+ZyzNpHZBi3IR2S70p75f5un0ImuMRRTsutH58TdGylYQJPv2oZ N3QG5l30AyLI6eX/7IeERBfxzvlDG56NVcaYMEh9jbdQtqNXJUTQrsSCCvkKS02kAf6Q iC3OSuQ4T8l5qXOKJXOrP/VFj1wq5PUXQUwO3JFTzKkj5f4wmhIFeVEiekfXQD3f3gdh 5OwrTz/S8QR5bknwcK5/GjELnz5nyph/ZMYO6IKPquze9GVMwP4Xy/Fzl/C2bgN7fZ6n Ko3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=nKEglG+VkY5k2r4b6pOjNT2aku/EL+cTcx9OPXsQOPk=; b=iGyuxJ074PsL+HumxKpvFXFZMM2fow9PnnsIU1tHg9gbVwMfEwIlTqNZuoOB4dSiLn E3dZAFLyxs7Lgp/XvcsZrKfqWnCNeP9eRL8YToc4B7rEihsciWvkbq4SBgUwsKQLB6xE XzmvPilg5d4RDZ0VYmEDM/lI1dvNj8zNvpHXhcSuI0AqVvfy9BRvlfu7KD5U+CHRbjLy MK8poH613uCF75Cvi5e83aB0ja5RjUeQRxuh03Az7Xm1/t+9ZkHAjKYIUgSi3LOsiV45 STxt3CqDnssXuaZ0VFmWF0ECnJgDI7eVTIyKJrjlXie0rR9XrQ7QqDDKnxEvKeFwS5i4 BdDA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gg12si2347685ejb.27.2020.06.18.12.19.58; Thu, 18 Jun 2020 12:20:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730263AbgFRTI1 (ORCPT + 99 others); Thu, 18 Jun 2020 15:08:27 -0400 Received: from nautica.notk.org ([91.121.71.147]:34180 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728071AbgFRTI1 (ORCPT ); Thu, 18 Jun 2020 15:08:27 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id EA9E8C01C; Thu, 18 Jun 2020 21:08:22 +0200 (CEST) Date: Thu, 18 Jun 2020 21:08:07 +0200 From: Dominique Martinet To: Alexander Kapshuk Cc: ericvh@gmail.com, lucho@ionkov.net, davem@davemloft.net, kuba@kernel.org, v9fs-developer@lists.sourceforge.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net/9p: Fix sparse rcu warnings in client.c Message-ID: <20200618190807.GA20699@nautica> References: <20200618183310.5352-1-alexander.kapshuk@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200618183310.5352-1-alexander.kapshuk@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Alexander Kapshuk wrote on Thu, Jun 18, 2020: > Address sparse nonderef rcu warnings: > net/9p/client.c:790:17: warning: incorrect type in argument 1 (different address spaces) > net/9p/client.c:790:17: expected struct spinlock [usertype] *lock > net/9p/client.c:790:17: got struct spinlock [noderef] * > net/9p/client.c:792:48: warning: incorrect type in argument 1 (different address spaces) > net/9p/client.c:792:48: expected struct spinlock [usertype] *lock > net/9p/client.c:792:48: got struct spinlock [noderef] * > net/9p/client.c:872:17: warning: incorrect type in argument 1 (different address spaces) > net/9p/client.c:872:17: expected struct spinlock [usertype] *lock > net/9p/client.c:872:17: got struct spinlock [noderef] * > net/9p/client.c:874:48: warning: incorrect type in argument 1 (different address spaces) > net/9p/client.c:874:48: expected struct spinlock [usertype] *lock > net/9p/client.c:874:48: got struct spinlock [noderef] * > > Signed-off-by: Alexander Kapshuk Thanks for this patch. From what I can see, there are tons of other parts of the code doing the same noderef access pattern to access current->sighand->siglock and I don't see much doing that. A couple of users justify this by saying SLAB_TYPESAFE_BY_RCU ensures we'll always get a usable lock which won't be reinitialized however we access it... It's a bit dubious we'll get the same lock than unlock to me, so I agree to some change though. After a second look I think we should use something like the following: if (!lock_task_sighand(current, &flags)) warn & skip (or some error, we'd null deref if this happened currently); recalc_sigpending(); unlock_task_sighand(current, &flags); As you can see, the rcu_read_lock() isn't kept until the unlock so I'm not sure it will be enough to please sparse, but I've convinced myself current->sighand cannot change while we hold the lock and there just are too many such patterns in the kernel. Please let me know if I missed something or if there is an ongoing effort to change how this works; I'll wait for a v2. -- Dominique