Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4723088pxb; Tue, 5 Oct 2021 09:01:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTG0ELh22t3BhtOgt0dZwN63OiXm6aSFwou+oqdOG0rnP1hNn9W93ftw+oUTPfCRiC9BmJ X-Received: by 2002:a17:90a:c703:: with SMTP id o3mr4715005pjt.176.1633449676335; Tue, 05 Oct 2021 09:01:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633449676; cv=none; d=google.com; s=arc-20160816; b=rUJHAb/EHMxp0zmoA4EOfWeQZ++YD1aCo/CXzUyE/EoxFj2jRO/TjZRfkwh7nM4syR TM0fc4BQ8j/v6YsGmC83jn2LNHz52pPdJ0QyrQJ3uVp0SCsWiN5TjdxaL4PBYQAE6YHw MCI/Hzep+6ieNryRHoiJYlN7ts98oTeUL4IHGdD/drU/V+iLpBf8WwZKVkQAILdZGwGD HfL2uMZPf6Rd8kauK6wCq+OcrSHYvu05vO4k/CnDNB0WOaP/AnyeUptuMEtw8A/N9sTi 4gY+rLb7T2NCT8opr3m29aG4HGbJtoXNwr+5zqTyurQLBZZCboBP9JqzOeqr1TAXiSWW avJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=UDA7Ug5CQn0NsAH25DueFW3X7E4E9Q65L0C2XytkJhU=; b=0qCHQk2VcGvX6stl9kN0Zwywcs1hgvkkpNBj0JpyM4KqYiUbEX2ltfZidoL/NwK3dP uM21SP9cPLiZSQrs5ZGbI5YXdxJzkVJll6rzdgTSPTmvoT6RtYi+V5DayBMH1Pz+Iw6t o6ZNyajd7wkYhEqQxB/6AVzywC20G+nzchi/jkN+50r2im1n/omfZNK+/rGQaZJfnnqA 9hQ/mKjQ4BUsdkO49AtNGFaZq9AY7hZpQsUcwsSkkpbmQNFJCmYHPalWQTwrjOoIgvOb HJyLjFBoz+5VhO3QKCSYpFe1fkoZ/rhISvlKacyzsYdSD9jnjbU0POqRKDjdhgDNeOpB UhtQ== 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 b3si23850171pgq.262.2021.10.05.09.01.01; Tue, 05 Oct 2021 09:01:16 -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 S236227AbhJEQAL (ORCPT + 99 others); Tue, 5 Oct 2021 12:00:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:48634 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234282AbhJEQAL (ORCPT ); Tue, 5 Oct 2021 12:00:11 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B6D4C61166; Tue, 5 Oct 2021 15:58:18 +0000 (UTC) Date: Tue, 5 Oct 2021 11:58:17 -0400 From: Steven Rostedt To: Mathieu Desnoyers Cc: linux-kernel , Linus Torvalds , Paul , Josh Triplett , Lai Jiangshan , "Joel Fernandes, Google" , Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , "David S. Miller" , Hideaki YOSHIFUJI , David Ahern , Jakub Kicinski , rcu , netfilter-devel , coreteam@netfilter.org, netdev Subject: Re: [RFC][PATCH] rcu: Use typeof(p) instead of typeof(*p) * Message-ID: <20211005115817.2e1b57bd@gandalf.local.home> In-Reply-To: <505004021.2637.1633446912223.JavaMail.zimbra@efficios.com> References: <20211005094728.203ecef2@gandalf.local.home> <505004021.2637.1633446912223.JavaMail.zimbra@efficios.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 5 Oct 2021 11:15:12 -0400 (EDT) Mathieu Desnoyers wrote: > ----- On Oct 5, 2021, at 9:47 AM, rostedt rostedt@goodmis.org wrote: > [...] > > #define rcu_dereference_raw(p) \ > > ({ \ > > /* Dependency order vs. p above. */ \ > > typeof(p) ________p1 = READ_ONCE(p); \ > > - ((typeof(*p) __force __kernel *)(________p1)); \ > > + ((typeof(p) __force __kernel)(________p1)); \ > > }) > > AFAIU doing so removes validation that @p is indeed a pointer, so a user might mistakenly > try to use rcu_dereference() on an integer, and get away with it. I'm not sure we want to > loosen this check. I wonder if there might be another way to achieve the same check without > requiring the structure to be declared, e.g. with __builtin_types_compatible_p ? Is that really an issue? Because you would be assigning it to an integer. x = rcu_dereference_raw(y); And that just makes 'x' a copy of 'y' and not really a reference to it, thus if you don't have a pointer, it's just a fancy READ_ONCE(y). -- Steve