Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1148793imm; Thu, 6 Sep 2018 16:37:52 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbYJfuVJ/cj+eJYe/I7aeuC9J7A3clM8IDijn3zEW0+MXcpGg6wetX1uSAkctt9myzfqsAZ X-Received: by 2002:a17:902:704c:: with SMTP id h12-v6mr5125500plt.237.1536277072079; Thu, 06 Sep 2018 16:37:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536277072; cv=none; d=google.com; s=arc-20160816; b=h/vYL8x1iyeGe7bw+D2rg9euNMg4vCuczQPgp/g08TqC0MQS+gK26UjrQx1hAQxmrB gVnY4hZZuiCKIaWQMVg4fj+Ca1Q+bTcpe542p6H2Gu3AuWipTP6o67TTQ8C7+3d/WKmi pm9G+IuFzOfrhqDuV0PUE7MhFTnj16W+PwTNBH6qnw0I9tjEO/hpRsSrgqlHH+GFROhp ObWJeOby2VtDcusEhCVNYcWKWfsXWL/aP9HPuWvl94sKL++7v6vdQqDQP20lbhIKNSaM LpAiNi8fKuA2W0rclHJXBKXaZA0RAZ0+JdFS0swxEEHfAhXERIjlgfHoruFIgsQcmDbD IrPA== 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:dkim-signature; bh=Dl23JlZFX2N7Sk84NoMV3OPQFJEMkQOyjltXomwmaAk=; b=rbr/ofn6oCNijXcxwus+hSfErA32u3B7exOZzew+gGzeAvCEX9ySepM8+dCYayjAFx S+thb/g/CnHVdDxc0SgNHOWAmDoPkcAwbMwN50Umy0vb5TcmZt0dMBWJelsC1McoBsHm TApB+6xrISrH9F3lgdvyjXRDqNkW5c8zc9Exg0PJG0P6XDzT1jbqI60CMIzIkYW6OCOw 4S4s7ArcntSrbibUbMBiYio5yF3pze6mg2dfzwjdDcYyic/qIbOl71z8R0rRoa5v+fZL q84hZaKGh1hmK7W0EiZg5N7OBFDGfulcqxKikEAo++D3HS5/rHnZYAf0EPHJRGCWQmaS zlSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YAaynUjv; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i26-v6si6786042pgn.589.2018.09.06.16.37.30; Thu, 06 Sep 2018 16:37:52 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YAaynUjv; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728242AbeIGDqv (ORCPT + 99 others); Thu, 6 Sep 2018 23:46:51 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:44122 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726265AbeIGDqv (ORCPT ); Thu, 6 Sep 2018 23:46:51 -0400 Received: by mail-wr1-f67.google.com with SMTP id v16-v6so13023046wro.11; Thu, 06 Sep 2018 16:09:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Dl23JlZFX2N7Sk84NoMV3OPQFJEMkQOyjltXomwmaAk=; b=YAaynUjvKkyQfly30qkqyo2Dy1pfAavEQdQJi/KbXzv7XP/vd4xGwfeeBTdcG0e3gj 5df9MhwkzL2NlkCDOXl2kp5PSHoJdgjS0WKmpwmgAukGR3R6JxfDaHBH7vci/dj7y8R2 fCfFo2RkWSp1t53mHNkBQ6e4W2AtwGQxyv4ZCSMDjlVb98zKjNQUKvy7zAOqqBmdiVeT 28z6c9T0068WL+Ik7O5SqO/aIKruRhnHbTHzsoBjIftXznPyhCPzF/srLxzSv/2Lagb5 GY36rGiFjaxWp5dWee4MbZB835UOmJl9PmSjvn49+5F+iCfDeaq5vMEOIduC9jB54OpM 9hDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Dl23JlZFX2N7Sk84NoMV3OPQFJEMkQOyjltXomwmaAk=; b=SMDxJBbKBF4A2o+lfr60DG67d2NARqshCNiPwAfmaq4YOKKE/Ca3v+LcueX+IrSkal M/qLzZVyhDbWpxRrt2FzyKu2BBJuhr8owcM/V5ssUxDmsQXN4IMNlhxsJqawrfm9hRO5 KiZixrVcd6RmAKOFOO+yKzgYIf5DyhAfuQyiw7dwglrFcuP2WZstMeVckGmYD8mGBOXA jAk1a1b/kXzVrk9zSnVBtIx3Jt5mQ9H+T0PdeijIenPdmEsupUvPhbEj0fmy+NE7mbcV yfQ4JPPfJ1S8bmWLlP1MVUfEPBGZbkuQGliuXCBmdm5WEq+7ZaoC8qZwOd6E30tlXajZ BSSA== X-Gm-Message-State: APzg51C5qdlvBdqvU7cRaOeR9hlY/VYC+i5RIiV29254vgibqbZV9ZON RqLJbrbPS57rSQw7SLVudYE= X-Received: by 2002:adf:de85:: with SMTP id w5-v6mr4419021wrl.270.1536275342271; Thu, 06 Sep 2018 16:09:02 -0700 (PDT) Received: from ltop.local ([2a02:a03f:4006:df00:f830:4b56:d713:5075]) by smtp.gmail.com with ESMTPSA id z21-v6sm3939460wmi.29.2018.09.06.16.09.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Sep 2018 16:09:01 -0700 (PDT) Date: Fri, 7 Sep 2018 01:08:59 +0200 From: Luc Van Oostenryck To: Linus Torvalds Cc: Andrey Konovalov , Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Al Viro , Kees Cook , Kate Stewart , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A. Shutemov" , Shuah Khan , linux-arm-kernel , "open list:DOCUMENTATION" , linux-mm , linux-arch , "open list:KERNEL SELFTEST FRAMEWORK" , Linux Kernel Mailing List , Dmitry Vyukov , Kostya Serebryany , eugenis@google.com, Lee.Smith@arm.com, Ramana Radhakrishnan , Jacob.Bramley@arm.com, Ruben.Ayrapetyan@arm.com, cpandya@codeaurora.org Subject: Re: [PATCH v6 11/11] arm64: annotate user pointers casts detected by sparse Message-ID: <20180906230858.psedqdai3dw2cvvl@ltop.local> References: <5d54526e5ff2e5ad63d0dfdd9ab17cf359afa4f2.1535629099.git.andreyknvl@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180622 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 06, 2018 at 02:16:19PM -0700, Linus Torvalds wrote: > On Thu, Sep 6, 2018 at 2:13 PM Linus Torvalds > wrote: > > > > So for example: > > > > > static inline compat_uptr_t ptr_to_compat(void __user *uptr) > > > { > > > - return (u32)(unsigned long)uptr; > > > + return (u32)(__force unsigned long)uptr; > > > } > > > > this actually looks correct. > > Side note: I do think that while the above is correct, the rest of the > patch shows that we might be better off simply not havign the warning > for address space changes at all for the "cast a pointer to an integer > type" case. > > When you cast to a non-pointer type, the address space issue simply > doesn't exist at all, so the warning makes less sense. > > It's really just he "pointer to one address space" being cast to > "pointer to another address space" that should really warn, and that > might need that "__force" thing. > > Hmm? So maybe a sparse change is better for most of that patch. Unless I'm misunderstanding something, I don't think there is anything to change for this specific point. Sparse don't warn (by default) on "cast from pointer with address space to integer", as it always been the case, I think. I think it's the good choice. It's just that recently, I've added a new flag -Wcast-from-as [1], defaulting to 'no', specifically to *detect* these cast because of these tagged pointers. Note: I tend to think more and more that __force is simply too strong and weaker form, like __force_as and __force_bitwise would be more appropriate. -- Luc Van Oostenryck [1] d96da358c ("stricter warning for explicit cast to ulong")