Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1121612rdh; Fri, 27 Oct 2023 05:33:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8mEQzymZHvGCejGl+vgMY3PaE3LqpUbWfBYvVmBNKFGazgUgxEnjTBXNn6FtdR/bOB7Ny X-Received: by 2002:aca:f11:0:b0:3ae:5442:ed1b with SMTP id 17-20020aca0f11000000b003ae5442ed1bmr2307293oip.43.1698409985127; Fri, 27 Oct 2023 05:33:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698409985; cv=none; d=google.com; s=arc-20160816; b=vCbLa+CW79fiiBiITvjTpbH5prfqB2UTJxVKcKAoyI04pzAGmMpBVBQhAi+3Qrjt2L 9/Pm/oS/bb5vVpGLmgHE1uN7+BIVu7JEarwioHusCDxnWnWan/TWw3cyvWO+gRclu7xY sJEPKJl22dC6yVsSyIy9C91RWonRSr8Ea3GXigCoJHKV+bdqBvN1rAQbt7qPdHPBt8cY MJoZefSm9srbIYAGEdAxFeB3ci8XcVa53HiCtAiRI4EA3bjBQFiJqVED7Cep2TJzuPA4 GglGohwbBwXJwVCMhy68ArSDCNFWORaYUqaluNstGsEvxHyzYSXsGBjr5rB+DL2e6kpi 6TTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature:dkim-signature; bh=HvxWbzthnpwTJHQGpAFMeuyzUX9UF3xucGZ52VNHJhE=; fh=gsffAx4bKvrKspoFP3kOEaUOCPxr00pUrn7IjeAvksw=; b=GpGo1Q2mQ0SWseA8EVZcez/ad97c+2Br5IaPuBlAIXeeR/Ambh6hYmHlfyAhdtXwGR vvqRLoMjrK1Yn3GegBJLOI7dBfncAJi+hJL7INbL0HdpciThYjZNg85KFmjEzipcGkd1 i+Wb5ZFprQzlVkLrlQdexVEUBvZZKQ5auhJxHB+C8sQ9jT8WWNRKXnwykg00Qf+9rjUA HaiTij0WtWD/m2fbKpwummvgYOZvOHhRajZlLLitFL5i6UkKrmxXD+zuPyxHrDcByZjv E+7yiPB08pvulwLZyBgcvDwJruVz+Rjva4LqbmY89WFLEM9LjvmJd01ecH462SBEUKcP oGWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=ctsCWHut; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=ctsCWHut; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=hansenpartnership.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id r186-20020a2544c3000000b00d9f7fff4b45si2197703yba.200.2023.10.27.05.33.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 05:33:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=ctsCWHut; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=ctsCWHut; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=hansenpartnership.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id A535782EA15A; Fri, 27 Oct 2023 05:32:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345860AbjJ0Mcw (ORCPT + 99 others); Fri, 27 Oct 2023 08:32:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345740AbjJ0Mcs (ORCPT ); Fri, 27 Oct 2023 08:32:48 -0400 Received: from bedivere.hansenpartnership.com (bedivere.hansenpartnership.com [IPv6:2607:fcd0:100:8a00::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72E6910A; Fri, 27 Oct 2023 05:32:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hansenpartnership.com; s=20151216; t=1698409965; bh=PpcsZRP4hkvBDAQ2XBd6sP/O26p2Kk1rAGMQFr2SSuk=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References:From; b=ctsCWHutHWwQ1sLy/FSZlur/NzDKdS4FhnQk91SSqlKtQpuKSSP9F3F9+ccDP3RSc k7wwV3FZz788xRl02meyuLwKUEaz0IYI3U4hevEob4AvQCiOtAwr+kGANU4NOZMDNa NjKdEh601gp/Ls5OLps9nZeX910lVnHVNQhuAIrw= Received: from localhost (localhost [127.0.0.1]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id 7D48A1287460; Fri, 27 Oct 2023 08:32:45 -0400 (EDT) Received: from bedivere.hansenpartnership.com ([127.0.0.1]) by localhost (bedivere.hansenpartnership.com [127.0.0.1]) (amavis, port 10024) with ESMTP id T1MDS27-eUfW; Fri, 27 Oct 2023 08:32:45 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hansenpartnership.com; s=20151216; t=1698409965; bh=PpcsZRP4hkvBDAQ2XBd6sP/O26p2Kk1rAGMQFr2SSuk=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References:From; b=ctsCWHutHWwQ1sLy/FSZlur/NzDKdS4FhnQk91SSqlKtQpuKSSP9F3F9+ccDP3RSc k7wwV3FZz788xRl02meyuLwKUEaz0IYI3U4hevEob4AvQCiOtAwr+kGANU4NOZMDNa NjKdEh601gp/Ls5OLps9nZeX910lVnHVNQhuAIrw= Received: from lingrow.int.hansenpartnership.com (unknown [IPv6:2601:5c4:4302:c21::c14]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by bedivere.hansenpartnership.com (Postfix) with ESMTPSA id A1B7E1287462; Fri, 27 Oct 2023 08:32:43 -0400 (EDT) Message-ID: Subject: Re: [PATCH v3 4/6] tpm: Support TPM2 sized buffers (TPM2B) From: James Bottomley To: Jarkko Sakkinen , linux-integrity@vger.kernel.org Cc: keyrings@vger.kernel.org, William Roberts , Stefan Berger , David Howells , Jason Gunthorpe , Mimi Zohar , Peter Huewe , Paul Moore , James Morris , "Serge E. Hallyn" , Jerry Snitselaar , Mario Limonciello , Julien Gomes , open list , "open list:SECURITY SUBSYSTEM" Date: Fri, 27 Oct 2023 08:32:42 -0400 In-Reply-To: <20231024011531.442587-5-jarkko@kernel.org> References: <20231024011531.442587-1-jarkko@kernel.org> <20231024011531.442587-5-jarkko@kernel.org> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 27 Oct 2023 05:32:58 -0700 (PDT) On Tue, 2023-10-24 at 04:15 +0300, Jarkko Sakkinen wrote: > +++ b/drivers/char/tpm/tpm-buf.c > @@ -7,22 +7,32 @@ >  #include >   >  /** > - * tpm_buf_init() - Initialize from the heap > + * tpm_buf_init() - Initialize a TPM buffer >   * @buf:       A @tpm_buf > + * @sized:     Represent a sized buffer (TPM2B) > + * @alloc:     Allocate from the heap >   * >   * Initialize all structure fields to zero, allocate a page from the > heap, and >   * zero the bytes that the buffer headers will consume. >   * >   * Return: 0 or -ENOMEM >   */ > -int tpm_buf_init(struct tpm_buf *buf) > +int tpm_buf_init(struct tpm_buf *buf, bool alloc, bool sized) I think it creates a phenomenally confusing interface to use multiple booleans because, unlike flags, it's not self describing at point of use. The confusion is enormously heightened here by having the doc book arguments be the reverse of the actual function prototype (I just tripped over this). The alloc flag is particularly counter intuitive: if you pass in an allocated buffer, you expect to be responsible for freeing it again, but that's not how you use it; you really use it like a reset not an alloc, which looks odd because you already created a separate tpm_buf_reset function which can't be used in this case. Why not replace the alloc flags with two reset functions: one for TPM2B buffers and one for command buffers? James