Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1059208imm; Thu, 6 Sep 2018 14:45:21 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbdleIkmnRyuGhhYr+r3XxQE+FTo5jmGXQTTqfFY5IMI5y8FCk1+Vxh3KvyzcW72BaTpq5K X-Received: by 2002:a62:1314:: with SMTP id b20-v6mr5230406pfj.230.1536270321400; Thu, 06 Sep 2018 14:45:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536270321; cv=none; d=google.com; s=arc-20160816; b=pgH8UKpj0AUDBDx1f6fpWglH2JLRv+eAJKnfpI7RC9+Q/VJw7c9p0Il4HExglZOADq GyvmbZ9dlf5Up4WrSrO7K6h86X4FwdajtAEKylEIUKao/mF3GUmBtgMVosNsZJdxdeKN FvFrkxgQ8jSjf2J4DIP9gJBz3qwkBBC4kFQiUehOiiKC1LNIRipknKSNqKqaBLlIKObL D8cS/Amh78oFyy3sPZjU4CD/i6arCgcuv43mvGN3F2Hf1ZBB18QWaSDr7D/VS9+Xai91 OOSYn6ppx5fY7dtxLVxtmk8nBTimWdcfg6dnWThBrj1qYYOuqdM0f5ayidA6I7LTK2Mt L5dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=J1RiOacWWjO2kJqUAa8v4HQtOgf41LcgCrGvyVmkTCY=; b=vB71X7sDrd7cKSldAc3QXFpOdulwozM6caeUiGbX2a/uDWztqKFYLjwhu0hb8UMtNB sPdmvfFGoWqICft8cuGlo8MVon/LIL66HEPW+J089EZMXLWblhJYwof5R6KCVWu0oxmq gm28ZQCW1YmEZo7cCJdAaaLQ5K2Wlbj61Y8tZKTp5Oblh2YwhW88NmmGLppGoT7Qd0Vj g91MmpGhdAJCrjOAkAnLtNAOsPB/LmoADZ10mUp7dodo8J0/MiF+Ljb0vNWNbFxNQFzk reHFEqZ8gZ22kNPKRCVqfkFNRlsk4CZoVzCC0BIcmtNgIbsLxGg+OAI6GwprpcY46rW/ IeZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=S9RpkC1W; 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 i21-v6si6231101pgb.81.2018.09.06.14.45.05; Thu, 06 Sep 2018 14:45:21 -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=@linux-foundation.org header.s=google header.b=S9RpkC1W; 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 S1728799AbeIGBxv (ORCPT + 99 others); Thu, 6 Sep 2018 21:53:51 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:38763 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726031AbeIGBxv (ORCPT ); Thu, 6 Sep 2018 21:53:51 -0400 Received: by mail-it0-f68.google.com with SMTP id p129-v6so17109203ite.3; Thu, 06 Sep 2018 14:16:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=J1RiOacWWjO2kJqUAa8v4HQtOgf41LcgCrGvyVmkTCY=; b=S9RpkC1Wf4WofPxwkH6NTo/1yYHGCQp9BmP0CbwKsxHcR4iTp6sroU0iS9nXY+Fgcs Kj5jWgGAj0nfUJlY8JYbc7TpLYXh00g/eNENVcu6dsdxqWj5YafRbbv5tcxwgkp7A0jX YFNDwyVksPDoulzZj9J14kOoYA4krfkFoFxK0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=J1RiOacWWjO2kJqUAa8v4HQtOgf41LcgCrGvyVmkTCY=; b=gocf6IeQQ8EW7RzQTvjuF3MqCxGNBngfoc3+mh0kDg0U+bCMIrC6OCip1rupZEQo/y gXhqu+VJv8/5gFrOyIC0V+2fD6mb/7oxRCyWDm3sXp6EFLzdAJY1VY0IGW3ZpzXvMkPy Dyv/Ca3GsLBv9rI4zYmvY1h0WLWaBltMxjwSxOmllX+3nqSTdK3OnUKYoYyaLxQZzBGd SfRoTrLwcMisbOBPIkiq+3tWClGMXvOBmdTt85hOvpM+ll2Icx5+ZiiKoIc5ISNEwUcb F919U6TRInssVvmQeqO5RAdgVDLbGo6qltur5/vE0ZwTckWb0b3il3PKDYZ1MkQbh14l T5tw== X-Gm-Message-State: APzg51AzD6DCQCGFXgoHI8Esi4hRj2LdRt93dP88xq38o/oSrg7z1Ha/ evE0ilokh9qrsF/EUQTgJntowFVQ5eLu135F0Ps= X-Received: by 2002:a24:3046:: with SMTP id q67-v6mr4578345itq.9.1536268590932; Thu, 06 Sep 2018 14:16:30 -0700 (PDT) MIME-Version: 1.0 References: <5d54526e5ff2e5ad63d0dfdd9ab17cf359afa4f2.1535629099.git.andreyknvl@google.com> In-Reply-To: From: Linus Torvalds Date: Thu, 6 Sep 2018 14:16:19 -0700 Message-ID: Subject: Re: [PATCH v6 11/11] arm64: annotate user pointers casts detected by sparse To: Andrey Konovalov Cc: 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Linus