Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp600819rdg; Tue, 10 Oct 2023 22:57:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEk8fah3NJkE/r+dOJsvJTRFAgV77ibBGHdjY/oOD7h/+44xDZ+Mdg79iZDlONCefXwapvh X-Received: by 2002:a05:6358:7e92:b0:143:5383:af8b with SMTP id o18-20020a0563587e9200b001435383af8bmr20631792rwn.11.1697003866707; Tue, 10 Oct 2023 22:57:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697003866; cv=none; d=google.com; s=arc-20160816; b=J8yNpQMtpINoHLn/c9Kl42M3AGKTKJrCa+rkDCDcUhCI23cSxHtgyYvoSQ/fSkJmTE 2Gl3jQJv9DQo5IelfKBAUxF9ojx83EoJQklh6vSplz7HgIWpCTrPKtwB93bYJfgEzJsf GJOAZrDCZfAo14GXgUmsjElgxJqPGdHirubzOV5MUSXbKAhvJ29mIto06tNjepKTNH36 aiB83BE7xPkO0FM09Neha/OmyvF2VFHNQEA231t0yslpyT6kWlyWqAwK004RMbfuXOy4 Ke8F7+pTU2qLGtjfgWht83BYzkMJ0axMfCq4HC8eSv+HFViEaOoE/QaswJK6VYTJJl2F IhYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=rpI7RMp4KwAd+fbis23QPkCG7JmUkdUenupCcGtFmrk=; fh=f5UyjC5PrCi2lDA+xJZtuRhGywk1v2m53NQP3Cmmqak=; b=CQLFCQRAzZ3PcjrQLlf8QyF/hXSwjp5UY0BQvhqMrugn80NeYCgzEtm1ZKO3rgKGL0 4rTU+Q9mHymM5DbhKslWeSau1QPS7sT/bCxWsV6HFieNPR8AHGtXLrt0CAUBb6HRHk2w 8nXRddSNZIX0NnCLHKRftms1d9+yUQP5ASfLXhLFqCvSAw/c+LLCaFM1ue2pCAyQKMHx IkRJJ0CRWRkZH5q7969bdFKn6bIa5k6nvBQ8lcMk0EIp87HZ4UyB3OtJJSmCM2lAOQwT 9EpXdG4064QDpEGEULvt1aO1v4tnhh6wmoL1sFT6CO7OcHUnV1I1oIJzE5CdKCKdNgqf EaRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ndSZ8oZk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id b18-20020a056a0002d200b0069335e0c824si10687164pft.204.2023.10.10.22.57.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 22:57:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ndSZ8oZk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 694D1801B722; Tue, 10 Oct 2023 22:57:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230001AbjJKF53 (ORCPT + 99 others); Wed, 11 Oct 2023 01:57:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229952AbjJKF51 (ORCPT ); Wed, 11 Oct 2023 01:57:27 -0400 Received: from mail-vs1-xe2d.google.com (mail-vs1-xe2d.google.com [IPv6:2607:f8b0:4864:20::e2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04AF894 for ; Tue, 10 Oct 2023 22:57:26 -0700 (PDT) Received: by mail-vs1-xe2d.google.com with SMTP id ada2fe7eead31-4577c1259c6so1088150137.3 for ; Tue, 10 Oct 2023 22:57:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697003845; x=1697608645; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=rpI7RMp4KwAd+fbis23QPkCG7JmUkdUenupCcGtFmrk=; b=ndSZ8oZk789qSeZqXXNRYV/bDpUXTHfGWNb/ZPU19hgUtuXb1wrVQrsK67XlAlUF/6 6C25PevA51cFO28ll35RROt8tv6oYymJQpKsBTPwHjao27+P7BIU52ANT0s2JQt42Mv8 dQxJZ/zM4WuBL2FeV6gCbTIfNEBf+55WkmqspBCzlUqc8vUj3HTiUaqPLeJzy1RHCqa/ ANKKvex6usXgR8MzLlL+hLHXJnwogBJ/Sy+7cJsCKESCyOYNa2zn2a678C8jwvIbg+Ms tJyHuGt8bXY/++eAUb/2OUGfnkGbI314PIFpLCc5JojoV4eBuGw7z6zEBabshNp5pkVx XCNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697003845; x=1697608645; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rpI7RMp4KwAd+fbis23QPkCG7JmUkdUenupCcGtFmrk=; b=drTYoGUXKwgrZW/NMKYFL28dI7nn8AUNd6VCsEvkvKKTHib/FC29Kp2ErgU25Yjw8d QjcY4LZsQin0vO12/PIlq1AloicoZgn0gifCUDo0bzSdQ3P5+78b8kIhYrmze3q9UbWj PwGDL+XvM3TsV2QsC+WOQspG8qHrPHLBwKZCwCgpJpWhO/0n8tDNzzM+Fi0WLX+WFoDY 1A3TepzVaYssng3a3RUIZNpjdkY7KwnPC2IH67StWrHRVpb+nlbtYbO3aie6/hITc/2X +Julz8pud6NI6Jxe/Bj7NuZJe3cHuKERDx9NcJf1P33S3WpKLVRlIN5QnJdT5y6s+qIz mGOQ== X-Gm-Message-State: AOJu0YyVdV2OcooW4a6ufelXkOez10zEg6k/jl8mrAN4IBImijb0KuD2 usUcua52sGEDf4TyiC4v84GbdUn6Qq5X7Sw0N6zm9RHdihUkfrdq X-Received: by 2002:a67:ed83:0:b0:452:7c1b:d57c with SMTP id d3-20020a67ed83000000b004527c1bd57cmr12788130vsp.28.1697003845032; Tue, 10 Oct 2023 22:57:25 -0700 (PDT) MIME-Version: 1.0 References: <20231010231616.3122392-1-jarkko@kernel.org> In-Reply-To: <20231010231616.3122392-1-jarkko@kernel.org> From: Sumit Garg Date: Wed, 11 Oct 2023 11:27:13 +0530 Message-ID: Subject: Re: [PATCH] KEYS: trusted: Rollback init_trusted() consistently To: Jarkko Sakkinen Cc: keyrings@vger.kernel.org, Linus Torvalds , stable@vger.kernel.org, James Bottomley , Mimi Zohar , David Howells , Paul Moore , James Morris , "Serge E. Hallyn" , "open list:KEYS-TRUSTED" , "open list:SECURITY SUBSYSTEM" , open list Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Tue, 10 Oct 2023 22:57:42 -0700 (PDT) X-Spam-Level: ** On Wed, 11 Oct 2023 at 04:46, Jarkko Sakkinen wrote: > > Do bind neither static calls nor trusted_key_exit() before a successful > init, in order to maintain a consistent state. In addition, depart the > init_trusted() in the case of a real error (i.e. getting back something > else than -ENODEV). > > Reported-by: Linus Torvalds > Closes: https://lore.kernel.org/linux-integrity/CAHk-=whOPoLaWM8S8GgoOPT7a2+nMH5h3TLKtn=R_3w4R1_Uvg@mail.gmail.com/ > Cc: stable@vger.kernel.org # v5.13+ > Fixes: 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework") > Signed-off-by: Jarkko Sakkinen > --- > security/keys/trusted-keys/trusted_core.c | 20 ++++++++++---------- > 1 file changed, 10 insertions(+), 10 deletions(-) > > diff --git a/security/keys/trusted-keys/trusted_core.c b/security/keys/trusted-keys/trusted_core.c > index 85fb5c22529a..fee1ab2c734d 100644 > --- a/security/keys/trusted-keys/trusted_core.c > +++ b/security/keys/trusted-keys/trusted_core.c > @@ -358,17 +358,17 @@ static int __init init_trusted(void) > if (!get_random) > get_random = kernel_get_random; > > - static_call_update(trusted_key_seal, > - trusted_key_sources[i].ops->seal); > - static_call_update(trusted_key_unseal, > - trusted_key_sources[i].ops->unseal); > - static_call_update(trusted_key_get_random, > - get_random); > - trusted_key_exit = trusted_key_sources[i].ops->exit; > - migratable = trusted_key_sources[i].ops->migratable; > - > ret = trusted_key_sources[i].ops->init(); > - if (!ret) > + if (!ret) { > + static_call_update(trusted_key_seal, trusted_key_sources[i].ops->seal); > + static_call_update(trusted_key_unseal, trusted_key_sources[i].ops->unseal); > + static_call_update(trusted_key_get_random, get_random); > + > + trusted_key_exit = trusted_key_sources[i].ops->exit; > + migratable = trusted_key_sources[i].ops->migratable; > + } > + > + if (!ret || ret != -ENODEV) As mentioned in the other thread, we should allow other trust sources to be initialized if the primary one fails. -Sumit > break; > } > > -- > 2.39.2 >