Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1681529imm; Mon, 3 Sep 2018 06:51:07 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbhVEN/jZxk4QkC1hw9ZGpw4J6oaKG4QiQj1t841j56zjtW5Gk8AQsCy6ufazgOz2VqwIuz X-Received: by 2002:a17:902:142:: with SMTP id 60-v6mr27746133plb.146.1535982667888; Mon, 03 Sep 2018 06:51:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535982667; cv=none; d=google.com; s=arc-20160816; b=fr1LN8m+rA3/uoACYj92F3FA1m6a97HD49DyvtU5On2G98DECyDJ4XrcFl7b2LqtBV 9JB4M9gWfb1pFe9k9mQgvtxuLssLjXuX3GB6hRioGN9BtYMTNOE87HU26WO3vrU9L2MK P7b8pWY5nMbo9u7RN/C5CaQOUzmyZAnd0Q0DWEXIN7zAoVigywFXSKcNHGNDTZn5wd7U y6JL4FLvVeNGTfBcxFhwlCXVJ5WZHnjaC1yFJTb1y3fHbVd9gC+bEeLYnMmo6cij8Fts y2dSB4f0uI6onAZcWUkvkTteo3/3io9QdqUB4VLrGrGMedrmY60wzbp69+LOm4px3+wT al0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=Xp787pdSYzRr4BaaWJkNr5DJNLr8LKs20b6Pobhqtxs=; b=Zpgf0MwRsMKfk0ufD/qYb+6biwSe1j7moiYp0JG78kdl9UnJ+HvWuw9DroztQN6zXS i9/pa1NpAUfZZxzLuRqN6u77aIKtigbecQnlaOoonpAYuwWmKe1zgD0m11lUZiqJu4Lu ELoTYu5ERuhVdbHO/IciDzAc6sId++Lm1Icnqp5l5pYWwEptVYPlQWaihx+CRxgLnJ3Z b0bPlyTCX7y2pQRZPJltvuIExWvK2/avTTqzuBUIi4GTkbIsE1oZz6DdL1R+BgPCYdD0 NpVe73TknNRlweSHKrGr5jyvas3o6U7HSbybNp2tgLVYhhXCcQMT87vdx2sZg7L8en+T SSMQ== ARC-Authentication-Results: i=1; mx.google.com; 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 1-v6si18840918plr.326.2018.09.03.06.50.52; Mon, 03 Sep 2018 06:51:07 -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; 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 S1727569AbeICSKC (ORCPT + 99 others); Mon, 3 Sep 2018 14:10:02 -0400 Received: from foss.arm.com ([217.140.101.70]:56418 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727057AbeICSKB (ORCPT ); Mon, 3 Sep 2018 14:10:01 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8168580D; Mon, 3 Sep 2018 06:49:44 -0700 (PDT) Received: from [10.4.13.84] (e119884-lin.Emea.Arm.com [10.4.13.84]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D3EBF3F557; Mon, 3 Sep 2018 06:49:39 -0700 (PDT) Subject: Re: [PATCH v6 11/11] arm64: annotate user pointers casts detected by sparse To: Andrey Konovalov , Al Viro Cc: Mark Rutland , Kate Stewart , linux-doc@vger.kernel.org, Catalin Marinas , Will Deacon , Kostya Serebryany , linux-kselftest@vger.kernel.org, Chintan Pandya , Shuah Khan , Ingo Molnar , linux-arch@vger.kernel.org, Jacob Bramley , Linux ARM , Evgeniy Stepanov , Kees Cook , Ruben Ayrapetyan , Ramana Radhakrishnan , Dmitry Vyukov , Linux Memory Management List , Greg Kroah-Hartman , LKML , Luc Van Oostenryck , Lee Smith , Andrew Morton , Robin Murphy , "Kirill A . Shutemov" References: <5d54526e5ff2e5ad63d0dfdd9ab17cf359afa4f2.1535629099.git.andreyknvl@google.com> <20180831081123.6mo62xnk54pvlxmc@ltop.local> <20180831134244.GB19965@ZenIV.linux.org.uk> From: Vincenzo Frascino Message-ID: <01cadefd-c929-cb45-500d-7043cf3943f6@arm.com> Date: Mon, 3 Sep 2018 14:49:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/09/18 13:34, Andrey Konovalov wrote: > On Fri, Aug 31, 2018 at 3:42 PM, Al Viro wrote: >> On Fri, Aug 31, 2018 at 10:11:24AM +0200, Luc Van Oostenryck wrote: >>> On Thu, Aug 30, 2018 at 01:41:16PM +0200, Andrey Konovalov wrote: >>>> This patch adds __force annotations for __user pointers casts detected by >>>> sparse with the -Wcast-from-as flag enabled (added in [1]). >>>> >>>> [1] https://github.com/lucvoo/sparse-dev/commit/5f960cb10f56ec2017c128ef9d16060e0145f292 >>> >>> Hi, >>> >>> It would be nice to have some explanation for why these added __force >>> are useful. > > I'll add this in the next version, thanks! > >> It would be even more useful if that series would either deal with >> the noise for real ("that's what we intend here, that's what we intend there, >> here's a primitive for such-and-such kind of cases, here we actually >> ought to pass __user pointer instead of unsigned long", etc.) or left it >> unmasked. >> >> As it is, __force says only one thing: "I know the code is doing >> the right thing here". That belongs in primitives, and I do *not* mean the >> #define cast_to_ulong(x) ((__force unsigned long)(x)) >> kind. >> >> Folks, if you don't want to deal with that - leave the warnings be. >> They do carry more information than "someone has slapped __force in that place". >> >> Al, very annoyed by that kind of information-hiding crap... > > This patch only adds __force to hide the reports I've looked at and > decided that the code does the right thing. The cases where this is > not the case are handled by the previous patches in the patchset. I'll > this to the patch description as well. Is that OK? > I think as well that we should make explicit the information that __force is hiding. A possible solution could be defining some new address spaces and use them where it is relevant in the kernel. Something like: # define __compat_ptr __attribute__((noderef, address_space(5))) # define __tagged_ptr __attribute__((noderef, address_space(6))) In this way sparse can still identify the casting and trigger a warning. We could at that point modify sparse to ignore these conversions when a specific flag is passed (i.e. -Wignore-compat-ptr, -Wignore-tagged-ptr) to exclude from the generated warnings the ones we have already dealt with. What do you think about this approach? > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel > -- Regards, Vincenzo