Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1899672rdb; Tue, 20 Feb 2024 10:10:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVQa62GxsFK8KwPutlcSCOU8r/GVTNl6jgv2zGBmcKYAOvJ6Lvmr3/ZYW3IhuefzCeTU6YozkXkh8H4jQVdNBuS+MTfHu9Xaf4wz2FiNg== X-Google-Smtp-Source: AGHT+IEkT1E/vrat4T1mUtIkImwr4jBfwCzLRwG/YcPclKV45Cee07Od/FqO+xU5LVAxXJMskwyX X-Received: by 2002:a92:c5cd:0:b0:365:44:1edb with SMTP id s13-20020a92c5cd000000b0036500441edbmr13451243ilt.3.1708452613595; Tue, 20 Feb 2024 10:10:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708452613; cv=pass; d=google.com; s=arc-20160816; b=FCwH1fjVUROaurwLI39zk1NL4bzsEk3c5FSduP1EQRDaFTHzbb67lLMzjX4pS5F3OX yZk1Iui4D4WyJ+U4k2Ss89EPTnl2gXYPRL2TUyPwiuL5QGeqk6uL7DGvqyH79mhkdny3 cjisy6cFDhOdQAk/RcLw3hQT9IC8NNIcjLzpmEVCBglRp7KxKMxdlBvTKykBYm0Np+Sq /cQ+EuvbGkXvb7nRdKLJVTVNyycjPzjoGkxn56szmh8GN2Mn6nW1f3totZwl7PS+kKtN 6GY+8NyRpwwfh2z/dWy+d9vO+BpmdAjQGKRsQF3TfQzIAA/qeNtVmVN3XGUxDPSPHO95 dqNA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:references:from:subject:cc:to:message-id:date :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=V1n7deaM0++soYxUIRRf7KQtMG9pzmRBR7fY96D5swI=; fh=lDSWuRuSMumdSTzs0f5MZq39xJs29DsJyTNPhTSTKYA=; b=N7icN922RW6bxJwKp+4rnGUujkQGEqdJtGkHsKIebxtEM9hfnXWwMy8oxz+O7PQiM5 KpLR6ghtHlu38PemdKQtYwXieYkmL7766r5I/LRMyR8WRknY6EY2UsW2jwrT6MqOb3ln 02JNigp+RpM7/q8g9kqL/RlNAIWs9YMdXyfcUIqGUuzsey1zRiFSCNnc50CXLuNXMf+O 8hMdjQiHwBGh716TqL4qyyGZ5qT7aV2zNgirUPlVkOgTkS8AF78TNB86j5760nXGdDFG 5wYi6UtLB4neeKJvG/RTs5si6s74C5jn5kFPDvg376OXTmWi/FTD4mOXIhTntCZSytL3 MmFw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sE2pq2kb; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-2205-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2205-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u71-20020a63794a000000b005dc8762dce5si6668503pgc.51.2024.02.20.10.10.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 10:10:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-2205-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sE2pq2kb; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-2205-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2205-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E2E55285725 for ; Tue, 20 Feb 2024 18:00:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6457F77652; Tue, 20 Feb 2024 18:00:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sE2pq2kb" X-Original-To: linux-crypto@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2194476C70; Tue, 20 Feb 2024 18:00:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708452047; cv=none; b=E3RTSUCE9n+Tl8TKFO/TNNt07yzpvryBJPNsDGAE3Ak2VitEYBKf6Ym4fHijp3HkMDhzMGMN0oLxhGTgyxbg7s0EP1YwNPA3YHXUmpyZXJLD+dKixFDnB8d4pHsxDx0g6TkDFPhwNMYAKz3RaBD5LgXKXZOOoSk2zRS6ZPGisr8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708452047; c=relaxed/simple; bh=Dhhd422rIU7Fe28Juuz6Lqp97VGVe56qgQbVeLGmTwo=; h=Mime-Version:Content-Type:Date:Message-Id:To:Cc:Subject:From: References:In-Reply-To; b=S1dLlh3ariafzgWerzReowNy5YrYBcYNpF/CQ+pMPOQyN/sescT9nxXfSr9x+jz23ki+pq1vtTmYRQSvdgh+MLEWq6PVG3pKAY8HP8EbqkP3J/gLsWDaqNkXe+JS2A2w9zP/ENzwvfnIxKIOJyPLkBwRiPM7z6RxyV3F+Ymx5o0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sE2pq2kb; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCE93C433C7; Tue, 20 Feb 2024 18:00:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708452046; bh=Dhhd422rIU7Fe28Juuz6Lqp97VGVe56qgQbVeLGmTwo=; h=Date:To:Cc:Subject:From:References:In-Reply-To:From; b=sE2pq2kb3nMi2cd7Rf5ZtbeaUzyD/HXPZWq+4lPvT8MJjIjV5sF+CvpDstBY+TZP1 CbY7goMP47h+tHF+e274bjxghAGf+P8lhBsV3ySj8XytvyzNjO03IJT0JDp9PwCnCo lfHs2lmoOvHWuvcizBm6WT9Tsxo7xs9VXMJTDPodPEVko209DQlehJFwXNStQYNBeB N3vqQ0WCpcwti8AyMgKpFGYHrlSUC5E1lfAvizEPmBnJUZlSRL73OV5JGJrcaiCWiT tW6hPSU0PihaAP4nvNAfObkzEjZETVChMwdsErrR5qmwcaizkssUIXJirBRqLP8xZP mm4TGDShkdYkA== Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 20 Feb 2024 18:00:41 +0000 Message-Id: To: "Lukas Wunner" , "David Howells" , "Herbert Xu" , "David S. Miller" , "Jonathan Cameron" Cc: , , "Andy Shevchenko" , "Peter Zijlstra" , "Dan Williams" , "Ard Biesheuvel" , "Nick Desaulniers" , "Nathan Chancellor" Subject: Re: [PATCH v3] X.509: Introduce scope-based x509_certificate allocation From: "Jarkko Sakkinen" X-Mailer: aerc 0.15.2 References: <63cc7ab17a5064756e26e50bc605e3ff8914f05a.1708439875.git.lukas@wunner.de> In-Reply-To: <63cc7ab17a5064756e26e50bc605e3ff8914f05a.1708439875.git.lukas@wunner.de> On Tue Feb 20, 2024 at 3:10 PM UTC, Lukas Wunner wrote: > Add a DEFINE_FREE() clause for x509_certificate structs and use it in > x509_cert_parse() and x509_key_preparse(). These are the only functions > where scope-based x509_certificate allocation currently makes sense. > A third user will be introduced with the forthcoming SPDM library > (Security Protocol and Data Model) for PCI device authentication. I think you are adding scope-based memory management and not DEFINE_FREE(). Otherwise, this would be one-liner patch. I'm not sure if the last sentence adds more than clutter as this patch has nothing to do with SPDM changes per se. > Unlike most other DEFINE_FREE() clauses, this one checks for IS_ERR() > instead of NULL before calling x509_free_certificate() at end of scope. > That's because the "constructor" of x509_certificate structs, > x509_cert_parse(), returns a valid pointer or an ERR_PTR(), but never > NULL. > > I've compared the Assembler output before/after and they are identical, > save for the fact that gcc-12 always generates two return paths when > __cleanup() is used, one for the success case and one for the error case. Use passive as commit message is not a personal letter. > > In x509_cert_parse(), add a hint for the compiler that kzalloc() never > returns an ERR_PTR(). Otherwise the compiler adds a gratuitous IS_ERR() > check on return. Introduce a handy assume() macro for this which can be > re-used elsewhere in the kernel to provide hints for the compiler. Does not explain why it is "handy". I don't see a story here but instead I see bunch of disordered tecnical terms. We have the code diff for detailed technical stuff. The commit message should simply explain why we want this and what it does for us. And we zero care about PCI changes in the scope of this patch, especially since this is not part of such patch set. BR, Jarkko