From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-f72.google.com (mail-it0-f72.google.com [209.85.214.72]) by kanga.kvack.org (Postfix) with ESMTP id 1F0826B7AC1 for ; Thu, 6 Sep 2018 17:16:32 -0400 (EDT) Received: by mail-it0-f72.google.com with SMTP id h5-v6so15239962itb.3 for ; Thu, 06 Sep 2018 14:16:32 -0700 (PDT) Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id d1-v6sor3950804itj.44.2018.09.06.14.16.31 for (Google Transport Security); Thu, 06 Sep 2018 14:16:31 -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 Content-Type: text/plain; charset="UTF-8" Sender: owner-linux-mm@kvack.org List-ID: 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 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