Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp600006rdg; Tue, 10 Oct 2023 22:55:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHyuRvHt7gHAhW24wYiAeHt9eawjbBPPsg2FedO1e2KAJI8BRE8MfsRHTk63Au0tYqCwN8k X-Received: by 2002:a05:6358:1ca:b0:145:6433:8224 with SMTP id e10-20020a05635801ca00b0014564338224mr18765584rwa.18.1697003705298; Tue, 10 Oct 2023 22:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697003705; cv=none; d=google.com; s=arc-20160816; b=nR7iNOGCb4qXREv/BaEBRIwF7ody6IDx8k7G9ppD9fqS1ypJ+0JWxl0WPHjbMogi5p ncXA6pSC9orVrrKgFLXgeDwJtEOWFeQssjPjwd89ZLPK5eIq5FHCDuxUPbN30iq6dt3c cX3mcwQ3Noa6951uGQEQSDfGjI6drZaI5L7j9ohlFCtBeUYNDqdbTfcMTeQ1wwwuyPLR aazDqea1cl0Y/SNvoxGMKRvRIcvviqnXyoBUnZzspd2appGipFx44YxgKGQXH79hVY0F SjSenQ4AZGNuKwvowDLzWl5zWtscroD9P/miVnXQc8fBtMnMtshJsPnVX2E6m2e2zyty l7XQ== 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=vPU2MuLb43jGuGxMy78ARcGnL6uCt8vs2fvYLKygEqI=; fh=nT7pOR7RFeCQqBaezHGpjT1h5wj+w8VA8wIhndTJ7DE=; b=SAiSfTIa44LbGaOBfDwLVs8JU9DqT3YB85SCwhxJ01CbmhW1BYxaFuSblWMZ41SeUq wegfYuG8gnwGhN5+kOEoPJQIIhMWfKchNtgqt0LVQwV137329RqVbshS1tjJJZ/xeZgM nH5ahJBT9/Gf9JcBJqx2pFJBC4j6++nq9Plrr1Zgh+/GOo1iEN2UcmSqBbGW8jAUUz7r G5hBhzrj4gUKcBHPWRfLGEK81LkbvuaMGaa/glzMnc9tFu1E4nVc8ha2bo+i4r2OAYSS TQO5KjChWzq32YHPaMNTd9090FtRClUWvWYIEbeyJZe632HYEMY39ERgHd6SFvxcL63r tHsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UO9YJNMs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id b9-20020a63d809000000b0058989aa1a1fsi11248096pgh.758.2023.10.10.22.55.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 22:55:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UO9YJNMs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 41FED83BEDD4; Tue, 10 Oct 2023 22:55:01 -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 S1343792AbjJKFyn (ORCPT + 99 others); Wed, 11 Oct 2023 01:54:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229940AbjJKFym (ORCPT ); Wed, 11 Oct 2023 01:54:42 -0400 Received: from mail-ua1-x929.google.com (mail-ua1-x929.google.com [IPv6:2607:f8b0:4864:20::929]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A98399B for ; Tue, 10 Oct 2023 22:54:40 -0700 (PDT) Received: by mail-ua1-x929.google.com with SMTP id a1e0cc1a2514c-7b07548b085so2722549241.2 for ; Tue, 10 Oct 2023 22:54:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697003680; x=1697608480; 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=vPU2MuLb43jGuGxMy78ARcGnL6uCt8vs2fvYLKygEqI=; b=UO9YJNMsBxqKTs2rsCAskp7YsbkHeQpeChT/yjck6G7P5sDVTq+PGs//siwRipiynG 5i9N47wRGifMvxfFIo+UXqTGdeSwBbbNFX3g6kuXuY5MoNZxeCau++3MptZZjzInPerM SW8o+7AT56a2uV2f0mR886u0i9InYMO0uLzccdSEcMFC8EegFLRPEoRS4eSY6Y5s77te +mc98IVjDDIKzooUTLUz2Km6jQ6Q0KV4uNb9P03opgwVCRJm+o1FnG5LGWs9KpYrP1yg CiqFK1+GNbrnZOqVTGvz1hRlIbBJr5nbiIta0TKKyeoH+2sFLdEr5SatsCRGTBDiqTi2 /IBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697003680; x=1697608480; 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=vPU2MuLb43jGuGxMy78ARcGnL6uCt8vs2fvYLKygEqI=; b=UKaPqpwAX9bTNxNv/t/b+dOZp8h2Lpo8M6CNqNQ4xgc4VZIMji3nC4DkdAHEuKLmWV 67nkLoAOQ1QW8qBjV+dAswEVOsAMgDqjcDW/IUy8+6anEnPYDMglG8UMyeWsq5Vlca+A K3R5RkmWz2XdvpWNnIMQITTF4BMZJbWcO+y1qClEPp1oBPptMsavTTRCgSX3Z20alJhw y4T//6sf/O6XpdZVFYR0RS411qZkh4h6ASjxdN3sJAD7BSaEu6Vn+LN5zhBdx5N+Kw0J eIMOZm18KcqOL2HDgoL+XFsd2dDDtTgyEpheXtBDtndkqst/tTr1LS7JHsVQJS+T8kN9 xn+w== X-Gm-Message-State: AOJu0YwEjTWbQZoKzGoL2trgTAHt3q4YfiMVhUlXwKZRvoDRlZ/u5fpj REYi/k5yqW7sRFVEpy3Y21GsCy4dDGZmqXGcvEOlIg== X-Received: by 2002:a67:fb59:0:b0:452:72ed:7020 with SMTP id e25-20020a67fb59000000b0045272ed7020mr19309017vsr.32.1697003679734; Tue, 10 Oct 2023 22:54:39 -0700 (PDT) MIME-Version: 1.0 References: <20231006051801.423973-1-sumit.garg@linaro.org> <8a8c14694d5ff62e385163bf0852fd3adb675087.camel@kernel.org> In-Reply-To: <8a8c14694d5ff62e385163bf0852fd3adb675087.camel@kernel.org> From: Sumit Garg Date: Wed, 11 Oct 2023 11:24:28 +0530 Message-ID: Subject: Re: [PATCH v2] KEYS: trusted: Remove redundant static calls usage To: Jarkko Sakkinen Cc: Linus Torvalds , David Howells , peterz@infradead.org, zohar@linux.ibm.com, linux-kernel@vger.kernel.org, linux-integrity@vger.kernel.org, jejb@linux.ibm.com, David.Kaplan@amd.com, bp@alien8.de, mingo@kernel.org, x86@kernel.org, regressions@leemhuis.info, Hyeonggon Yoo <42.hyeyoo@gmail.com> 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 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]); Tue, 10 Oct 2023 22:55:01 -0700 (PDT) X-Spam-Level: ** On Wed, 11 Oct 2023 at 00:35, Jarkko Sakkinen wrote: > > On Tue, 2023-10-10 at 11:28 -0700, Linus Torvalds wrote: > > On Thu, 5 Oct 2023 at 22:18, Sumit Garg wrote: > > > > > > Static calls invocations aren't well supported from module __init and > > > __exit functions. Especially the static call from cleanup_trusted() led > > > to a crash on x86 kernel with CONFIG_DEBUG_VIRTUAL=y. > > > > > > However, the usage of static call invocations for trusted_key_init() > > > and trusted_key_exit() don't add any value from either a performance or > > > security perspective. Hence switch to use indirect function calls instead. > > > > I applied this patch to my tree, since it is a fix for the issue, and > > doesn't change any logic otherwise. > > > > However, I do note that the code logic is completely broken. It was > > broken before too, and apparently causes no problems, but it's still > > wrong. > > > > That's a separate issue, and would want a separate patch, but since I > > noticed it when applying this one, I'm replying here: > > > > > + trusted_key_exit = trusted_key_sources[i].ops->exit; > > > migratable = trusted_key_sources[i].ops->migratable; > > > > > > - ret = static_call(trusted_key_init)(); > > > + ret = trusted_key_sources[i].ops->init(); > > > if (!ret) > > > break; > > > > Note how this sets "trusted_key_exit" even when the ->init() function fails. > > Sumit, can you remind me why this continues *on any failure*? We should give other trust sources a chance to register for trusted keys if the primary one fails. -Sumit > > E.g. something like this would make more sense to me: > > ret = trusted_key_sources[i].ops->init(); > 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); > static_call_update(trusted_key_exit, trusted_key_sources[i].ops->exit); > migratable = trusted_key_sources[i].ops->migratable; > break; > } > > if (ret != -ENODEV) > break; > ` > BR, Jarkko