Received: by 10.192.165.148 with SMTP id m20csp3239116imm; Mon, 23 Apr 2018 03:09:15 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/CES2vfklOFWi/pdp054use2aqqUnFeQfkk92mMTHbs94e6LIW7dtmcQhE35gyHyU02YuI X-Received: by 10.98.242.6 with SMTP id m6mr19669440pfh.170.1524478155005; Mon, 23 Apr 2018 03:09:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524478154; cv=none; d=google.com; s=arc-20160816; b=GZRtCLOfvFFRyXf8VqabkDAKTsYSa9l4jmD4OhzkfHrA8QY52ZeYi3gEccNO+xA1dx 3KSrvZCgUW8RgjloUugWpM7YjPt9cDAWHImJI4VPMGdpi6hE69wdi+Z9cIQSK/fN21pC c15NlQ6kFsQk6/mKw7feVySoViDPPK/Du/jzecmtJj8u76ruKgxR0VW6zlB6z+VLDC9G /UJiTAu0Gwji3Rdl55TU6B+tg4RBUrwX9U/00J6Zigwt8PA54u6LeFNPMxXxYyJfJxXx CnfEKXtBbst9x0/6Bt9Y3EScJVH3Jh8asyatv8pRRntsaz6ukAZ3akIVG+RFreM/PwF0 yGMg== 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:arc-authentication-results; bh=b+h/bY4jTq77WHyTQnplKv6HAOlz6MkEZbwFW4yWeEo=; b=g+TZF0yx2FduadBnft1Z7ce0VjWdyIBpTYU5Fz9dCytDBwAJOAbmQ1qsSgMCZYhjI1 3d/NYdA36sNZRndJpHLDK5jzJ2ZnvP6QgxKjqtS0v09U5gmpfI4AvitedzNcdlfBInLR 8Yy2PWIGA83v9IXMmM03lGmC4cratK3Jq5K3RHDUDHjD+HmbR07taKxXd2pvGc2enH94 ImO5a31FqV1FH1AYzP7x8XaD53TNMV6ShiVhIaYwE9ie9gT81CBhIAV84aD6sFgo+TbX ZRD2GErQ1q1wsNT1VU/JAgP6jLM5Yz5ql31NLvhA3MLWOVcJZoba5/5+gRpLISHtAezh BMww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Kn8eMVAk; 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 s1si1301681pgq.282.2018.04.23.03.09.00; Mon, 23 Apr 2018 03:09:14 -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=Kn8eMVAk; 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 S1754579AbeDWKGm (ORCPT + 99 others); Mon, 23 Apr 2018 06:06:42 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:37656 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754078AbeDWKGh (ORCPT ); Mon, 23 Apr 2018 06:06:37 -0400 Received: by mail-wr0-f195.google.com with SMTP id f14-v6so39571644wre.4; Mon, 23 Apr 2018 03:06:36 -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=b+h/bY4jTq77WHyTQnplKv6HAOlz6MkEZbwFW4yWeEo=; b=Kn8eMVAkZkPBy7+VjH90V3r+gH+ksqXCk28MwbjMQeFgo2HpD8VrUuX3YR6S2E2sdw qx2goMrFT9xvXZVYJoXrt6lR7WLSX0pAWgG/D/7KTUFgHI+G3+Nerj5p+D/ieGKrWij+ 4giRIBNxNKJrciXLMvxVAGlWqZGpbWRybfLGvycjLqM+zgHXpooMtO5Z8KxtnAzsPNSx s/PwBXK+HGz4c288EAizR1LIKvtFY28s3gEel2sHWCeQSdq3+M0RZGL3cr9xV0VHdmLe xAVNlufWXwYiFwV/340GVDWrc2WL5dW2kVMqD83WXGoCr3NO7MBJcWl1IVvA8sImI/J5 P1hQ== 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=b+h/bY4jTq77WHyTQnplKv6HAOlz6MkEZbwFW4yWeEo=; b=hsjWh4zu++cp/sRH5MHMPBf/X207t4j/72U3eUnA21NGZ0WaCkuf3gd90kk+u45Sl/ 1ez0I+Y368xtbzE3zLg/A8riOxdSDlJTauWXUGDzTap30NfNYpTykl2h2I9uyhHlJNGZ FN2I8N2BrEo08oqk3iBtYPQ5LcF04PTyH9FLaTu8b1aERfOMY42EfQdRyKKX7wIYh6Si 8V5Kw56g8BBS+0QSghIWf0MNEBGyW1W6iWkJCSMdDx0Us5fKS1w3gcpUkEfjhZd4A2j6 sUBQXWFUyRw/KJttm9krsKIn2VZRmUwSidH+s1Er4SS9CC2XIZQjzCP9bcODgbqV0enp BjPw== X-Gm-Message-State: ALQs6tDIdIeGEvV793CrFcdcvpQHDm86/mWOaOBtHgv/gD7jbBGVcFC0 UAVhsWul7YOFtUbE+fWJPJo= X-Received: by 10.80.222.205 with SMTP id d13mr27583576edl.76.1524477996290; Mon, 23 Apr 2018 03:06:36 -0700 (PDT) Received: from ltop.local ([2a02:a03f:4028:3a00:dd06:6a31:bdfc:8f01]) by smtp.gmail.com with ESMTPSA id l9sm7777148edk.9.2018.04.23.03.06.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Apr 2018 03:06:35 -0700 (PDT) Date: Mon, 23 Apr 2018 12:06:32 +0200 From: Luc Van Oostenryck To: Thiebaud Weksteen Cc: jgg@ziepe.ca, Christopher Li , Jarkko Sakkinen , Nayna Jain , linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sparse@vger.kernel.org, Josh Triplett Subject: Re: [PATCH v2 1/4] tpm: Add explicit endianness cast Message-ID: <20180423100629.effueb6i7q3hmhu3@ltop.local> References: <20180412101350.210547-1-tweek@google.com> <20180412101350.210547-2-tweek@google.com> <20180417030202.GA30624@ziepe.ca> <20180417140013.GA2029@ziepe.ca> <20180420145740.GC30433@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180323 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 23, 2018 at 09:22:06AM +0000, Thiebaud Weksteen wrote: > On Fri, Apr 20, 2018 at 4:57 PM Jason Gunthorpe wrote: > > > On Thu, Apr 19, 2018 at 01:09:12PM +0000, Thiebaud Weksteen wrote: > > > On Tue, Apr 17, 2018 at 4:00 PM Jason Gunthorpe wrote: > > > > > > > On Tue, Apr 17, 2018 at 08:32:33AM +0000, Thiebaud Weksteen wrote: > > > > > On Tue, Apr 17, 2018 at 5:02 AM Jason Gunthorpe > wrote: > > > > > > > > > > > On Thu, Apr 12, 2018 at 12:13:47PM +0200, Thiebaud Weksteen wrote: > > > > > > > Signed-off-by: Thiebaud Weksteen > > > > > > > drivers/char/tpm/tpm_eventlog_of.c | 4 ++-- > > > > > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > > > > > > > > > diff --git a/drivers/char/tpm/tpm_eventlog_of.c > > > > > b/drivers/char/tpm/tpm_eventlog_of.c > > > > > > > index 96fd5646f866..d74568d58a66 100644 > > > > > > > +++ b/drivers/char/tpm/tpm_eventlog_of.c > > > > > > > @@ -56,8 +56,8 @@ int tpm_read_log_of(struct tpm_chip *chip) > > > > > > > * but physical tpm needs the conversion. > > > > > > > */ > > > > > > > if (of_property_match_string(np, "compatible", > "IBM,vtpm") < > > > 0) { > > > > > > > - size = be32_to_cpup(sizep); > > > > > > > - base = be64_to_cpup(basep); > > > > > > > + size = be32_to_cpup((__be32 *)sizep); > > > > > > > + base = be64_to_cpup((__be64 *)basep); > > > > > > > > > > > Er, no.. change the definitions of sizep and basep to be __be > > > > > > > > > > > Jason > > > > > > > > > > Please read the comment before the condition. sizep and > > > > > basep may contain either little endian or big endian and this block > is > > > used > > > > > to adjust that. Let me know if there is a better way for handling > this. > > > > > > > Well a cast like that will throw sparse warnings, you need __force at > > > > least > > > > > > I don't think so. Since the variable is only defined as u32*, no > specific > > > warning is generated. I've used `make C=2 drivers/char/tpm/` with this > > > patch applied and no new warning is being triggered. Interesting. > > I'm surprised to hear you say that.. Same for me. > > Sparse is supposed to require force on all cast that change the > > annotation, and there are many examples in the kernel that have force > > in that case. Yes, sparse is supposed to warn in such cases and the __force is there to quiets the warning when it is known that the cast is in fact correct. > +linux-sparse@vger.kernel.org and sparse@chrisli.org for a sanity check. > > If you look at the man page of sparse, under the bitwise option, it states: > "Sparse will warn on [...] any conversion of one restricted type into > another, except via a cast that includes __attribute__((force)).". In our > case, it is a conversion from unrestricted to restricted which does not > fall in this category. The man page is not very clear here. It must be understood in the context where each use of '__bitwise' will create a new *distinct* type. Given this and the normal type checking, sparse should warn "on any conversion of one restricted type into another *or* between a restricted and the corresponding plain/unrestricted type" (or consider that an 'unrestricted type' is 'a restricted type with no restriction', which is, I think, what was meant here). The fact that sparse doesn't warn in your case is clearly a bug in sparse's type checking. Regards, -- Luc Van Oostenryck