Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp621077rdh; Thu, 26 Oct 2023 10:56:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEu5/EEnDlH3UPi+NBkvZs+bC+phiPm6TpbVzQzyLCD+g6HCZR1NQTkS34XYj8pZGxyRYlu X-Received: by 2002:a81:eb14:0:b0:5ae:f116:48c4 with SMTP id n20-20020a81eb14000000b005aef11648c4mr150307ywm.37.1698343012231; Thu, 26 Oct 2023 10:56:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698343012; cv=none; d=google.com; s=arc-20160816; b=G3XT26A9eHt6G3yO/aB5IDzqpccd4HPyjwssCnS3hflM946Atmz8SGNjmCKYzSoJyZ L7g5lzcYNPyibSe1UT937OuHeks9jL/rx68c50nX6JKQWkE3j2XFDL9i+DSKppkgXbAi BfZ8+ZMxisD0gh+5vUBgGEbUpOHIXY239KaXjNiX7iR52FDtS5EfJebZc79euR/DWUEC X1eKJ57h+HWS8xDI9amnI+NyYazEhpLd2av5ug6OBaYBKnVZ0Qqb6+dKxA5GATffvIFB /pc3TLSOV9YyO3UlgyQabpmEo9h5TcQCK5Clg2hy1xu7ELyblUZIE5mccjIokr4FwZbR FvHA== 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=fPBUYGi6KzqkH7gSPAh5r/7J11TSh2PK8BbHHqK/AeY=; fh=yLKvJwTVWI3uRHYVDy4HpuwLRX25/prPR98uWu/asEs=; b=uotAPZwPfFlHvky/KASw9P0UkMUl42bxD6H0pYjhYWYUaEKbjRTFWgO64tfuaqWH+v IL0bNRQ8KgjYF3NjNB8+GBWEnLfidEES0R40qhlX1d62q86KBZIKTZXkloC+3aKvV/Cl /bBM6mYchNVk98Vowym2KOHItkmQgRDUXlhJGQREQAWzjve7+h7sX66Q0bZqKzVbP038 vWmxH9lAxPC1swn6FksXj4hWG/6utW4IqJ/JJTGD/7QVjOwhGoq59mYUmYjr+xa6iAoa zhlyqkIOI6ZhzWg6IsAT1D5A9h5DCAs0doe0cZxlBKDWgpF9Xqg4mFzQS0TApv4pcuBE 0FIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=XJoRIE5+; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=XJoRIE5+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id y125-20020a0def83000000b005a87ec8f16bsi15782129ywe.545.2023.10.26.10.56.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 10:56:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=XJoRIE5+; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=XJoRIE5+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 009CD80FC1BF; Thu, 26 Oct 2023 10:56:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231547AbjJZR4E (ORCPT + 99 others); Thu, 26 Oct 2023 13:56:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229649AbjJZR4C (ORCPT ); Thu, 26 Oct 2023 13:56:02 -0400 Received: from bedivere.hansenpartnership.com (bedivere.hansenpartnership.com [96.44.175.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34BB11A2 for ; Thu, 26 Oct 2023 10:55:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hansenpartnership.com; s=20151216; t=1698342959; bh=AoxGJ+wBYwrKrdP9vB2wZ9O/z3R0MKu7k+bX0EK20fE=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References:From; b=XJoRIE5+yAGK/Q0gi9XmPd3BMMF0qnoW0dXzrr8Al9EPjhL22fFTei3Vt8lI+AnHC iyPxjppUrDbRPhVDPQbbPR0f3t131ZcTfycp64GEz9PmG3hTHVYqBUDlQUwHi7k+OG QvUR7S4Vz/0HNOljG0VAf+JfzpzIwp1TGGKbNP5U= Received: from localhost (localhost [127.0.0.1]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id 9A4251286BB1; Thu, 26 Oct 2023 13:55:59 -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 WV6ZavWvzbtC; Thu, 26 Oct 2023 13:55:59 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hansenpartnership.com; s=20151216; t=1698342959; bh=AoxGJ+wBYwrKrdP9vB2wZ9O/z3R0MKu7k+bX0EK20fE=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References:From; b=XJoRIE5+yAGK/Q0gi9XmPd3BMMF0qnoW0dXzrr8Al9EPjhL22fFTei3Vt8lI+AnHC iyPxjppUrDbRPhVDPQbbPR0f3t131ZcTfycp64GEz9PmG3hTHVYqBUDlQUwHi7k+OG QvUR7S4Vz/0HNOljG0VAf+JfzpzIwp1TGGKbNP5U= 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) server-digest SHA256) (Client did not present a certificate) by bedivere.hansenpartnership.com (Postfix) with ESMTPSA id 1181A1286B29; Thu, 26 Oct 2023 13:55:57 -0400 (EDT) Message-ID: Subject: Re: [PATCH v3 1/6] tpm: Move buffer handling from static inlines to real functions From: James Bottomley To: Jerry Snitselaar , Jarkko Sakkinen Cc: linux-integrity@vger.kernel.org, keyrings@vger.kernel.org, William Roberts , Stefan Berger , David Howells , Jason Gunthorpe , Mimi Zohar , Peter Huewe , Mario Limonciello , Julien Gomes , open list Date: Thu, 26 Oct 2023 13:55:55 -0400 In-Reply-To: References: <20231024011531.442587-1-jarkko@kernel.org> <20231024011531.442587-2-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 fry.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 (fry.vger.email [0.0.0.0]); Thu, 26 Oct 2023 10:56:14 -0700 (PDT) On Thu, 2023-10-26 at 10:10 -0700, Jerry Snitselaar wrote: > On Wed, Oct 25, 2023 at 08:35:55PM +0300, Jarkko Sakkinen wrote: > > On Wed Oct 25, 2023 at 12:03 PM EEST, Jerry Snitselaar wrote: > > > Reviewed-by: Jerry Snitselaar > > > > On Wed, 2023-10-25 at 02:03 -0700, Jerry Snitselaar wrote: > > > Reviewed-by: Jerry Snitselaar > > > > > > > Thanks I'll add it to the next round. > > > > For the tpm_buf_read(), I was thinking along the lines of: > > > > /** > >  * tpm_buf_read() - Read from a TPM buffer > >  * @buf:        &tpm_buf instance > >  * @pos:        position within the buffer > >  * @count:      the number of bytes to read > >  * @output:     the output buffer > >  * > >  * Read bytes from a TPM buffer, and update the position. Returns > > false when the > >  * amount of bytes requested would overflow the buffer, which is > > expected to > >  * only happen in the case of hardware failure. > >  */ > > static bool tpm_buf_read(const struct tpm_buf *buf, off_t *pos, > > size_t count, void *output) > > { > >         off_t next = *pos + count; > > > >         if (next >= buf->length) { > >                 pr_warn("%s: %lu >= %lu\n", __func__, next, > > *offset); > >                 return false; > >         } > > > >         memcpy(output, &buf->data[*pos], count); > >         *offset = next; > >         return true; > > } > > > > BR, Jarkko > > > > Then the callers will check, and return -EIO? Really, no, why would we do that? The initial buffer is a page and no TPM currently can have a command that big, so if the buffer overflows, it's likely a programming error (failure to terminate loop or something) rather than a runtime one (a user actually induced a command that big and wanted it to be sent to the TPM). The only reason you might need to check is the no-alloc case and you passed in a much smaller buffer, but even there, I would guess it will come down to a coding fault not a possible runtime error. James