Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp2605862rwo; Sun, 23 Jul 2023 20:15:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlFz6k/v82WJSOE3it482ilj8gEQ1wQpYWISEf/YQ0tDRD9IlzjmuBjlJ3w/IPIw3FrWqdl/ X-Received: by 2002:a05:6358:2807:b0:132:d333:4a5c with SMTP id k7-20020a056358280700b00132d3334a5cmr3743913rwb.10.1690168518019; Sun, 23 Jul 2023 20:15:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690168517; cv=none; d=google.com; s=arc-20160816; b=XPlElNUsMH7xaWNTa4UFP8j2VHQW51cMoBwsgamruWsSjLU+tHOdJJs9cdpoJ09nd9 9LhOkzWAiKa9cVEcFEShWqKTUk0YddZpRHZ2Ea3r0md+X029vV9Bz1cd5bKdRDJnzLNx dEC2kXahY7UK0aeXMjFH/0L2/pvsBeRoSUZ2wDu3jcj6oA9R46+rdO3omWNbg8lbio+J X/GdYCYAgilcyDR5mny4gfKdFmf8JI2TICB2Qlgh2JxnS9SDLBspvxiUbNCAi/OB4g9y 3wgraHEfzCZCANKqYhrIFWzhEJQLQ0lJT99pZ98flfvypnbOmiZ43bNQBmmgCYt3R2H6 +T2A== 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=i3Ul/yib6AVpUBR82WT2XWQzdvG86SoceqyAVEO8xa4=; fh=Qx/z+48Pn9u2pjw63wnELbg1CDx/LM3ITZ91dVvjfak=; b=i5iAAd1WtuO8ObhBHM/l9ZluLYoAapr5/TuiPr9qqO7Ny2+Gae28a9kzGu/icT0SPr xaLx8dMMfgac8TvZ1sz1ltAMhkW0I3wEVzjiUKbAw3YkRNl2/r1QpoL3CZ5TAtrfrQbE W3A+y/T25V8p7DOadL1EvHIdHCYOhvQst0RvtBIzexYLB7tpzTryiBqzynAppESDBSVW 6TykUuoLBzS2W7NZio0WSriVtlbqEvlhZ7MOU5zPeiM5d5zK10chaxL4g5PQzG8t7Nh/ OJt/mK4rOJuj+CDISfVLHjUlBWVZMJU/YZM1RZz2u0yHDLdgVmR1tUOFL8eJ8+Wo/HXU kXYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hobKpHD4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i186-20020a636dc3000000b005577fd7efa4si6694323pgc.427.2023.07.23.20.15.05; Sun, 23 Jul 2023 20:15:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hobKpHD4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229545AbjGXCxL (ORCPT + 99 others); Sun, 23 Jul 2023 22:53:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229551AbjGXCxJ (ORCPT ); Sun, 23 Jul 2023 22:53:09 -0400 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AFC5C4 for ; Sun, 23 Jul 2023 19:53:08 -0700 (PDT) Received: by mail-ot1-x331.google.com with SMTP id 46e09a7af769-6b9c5362a51so3009338a34.0 for ; Sun, 23 Jul 2023 19:53:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690167187; x=1690771987; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=i3Ul/yib6AVpUBR82WT2XWQzdvG86SoceqyAVEO8xa4=; b=hobKpHD4tELSbF98E97BcgxRKfDSmmNBdxraOcygmOsuhC6MzBr601WutWaCExDpDK VKqSOIVPehUE39YZ392arCdQdSuyn4imYSFe+OG9rb/qLcsxQMKhoy9aLxzqV/OedpH+ IYqKAtR7FBD0NozRn7hDC/sx1NTYA3eZqmPJ/4rBrRR/U8u/K6tQlX+K4SojM4wGX4qf euO9NLQWlADfXWptlmq0E2rCHHvO8Ct8RUKdJAtfE0Xq/oJIGjbIhuhncs2cVUCi+Wf/ //argLKKwMOcaTOyFzlBXWgmbHyDMZjitmsKauhKid7YC7nDHUzqvDftyu8DluApK0cR gA/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690167187; x=1690771987; 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=i3Ul/yib6AVpUBR82WT2XWQzdvG86SoceqyAVEO8xa4=; b=Qaf48UfifCHePDAW2qOBZteWB1b5kxJretF2dF7tGAgf/+LDlnZQbWprtw7F8X8VsT JyVIiRzp7xhQfrss+sKTgK1aE/6cHyGhEhRswljFRwoFOn1gvMfD8uGsnzAJW3OmIqHw fyzDXdhGw2j5JBv6UYCD7Vy7NR5JCX6X0kNptKSEy0WrM0MJuzl01GsIpiZR15bq5ucx 5kcCVEVgabKyTWdewUQ2BRzY0DvTWdCU8a0q4tzveWeDjfMTfwU5zX4rlcRwEI138Vop a9qJou+4RgeHg6z7Tk+zHtRE7JgkYI1j3HLoNxMohlHfdF2FLRXwcUjoxUwe1kbguZ5Q 4cmQ== X-Gm-Message-State: ABy/qLbP2FD4ovaC+EoruNlsPWE4w3w4NbhPYSEKl/iKxO2QHPxXa2+f 6k0h0CuzNNZk4V6CxuEtyFCE+z0rUN5ylvHQoxPHug== X-Received: by 2002:a05:6808:ecc:b0:3a4:3a71:14dc with SMTP id q12-20020a0568080ecc00b003a43a7114dcmr10027133oiv.1.1690167187779; Sun, 23 Jul 2023 19:53:07 -0700 (PDT) MIME-Version: 1.0 References: <20230622085112.1521-1-masahisa.kojima@linaro.org> <20230622085112.1521-5-masahisa.kojima@linaro.org> <5fe03be6-8c95-0bfa-687d-68e7ddffd97c@siemens.com> In-Reply-To: From: Masahisa Kojima Date: Mon, 24 Jul 2023 11:52:56 +0900 Message-ID: Subject: Re: [PATCH v6 4/4] efivarfs: automatically update super block flag To: Ilias Apalodimas Cc: Jan Kiszka , Ard Biesheuvel , Jens Wiklander , Sumit Garg , linux-kernel@vger.kernel.org, op-tee@lists.trustedfirmware.org, Johan Hovold , Jeremy Kerr , linux-efi@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Ilias, Jan, On Fri, 23 Jun 2023 at 03:56, Ilias Apalodimas wrote: > > Hi Kojima-san, Jan > > On Thu, Jun 22, 2023 at 04:58:50PM +0200, Jan Kiszka wrote: > > On 22.06.23 10:51, Masahisa Kojima wrote: > > > efivar operation is updated when the tee_stmm_efi module is probed. > > > tee_stmm_efi module supports SetVariable runtime service, > > > but user needs to manually remount the efivarfs as RW to enable > > > the write access if the previous efivar operation does not support > > > SerVariable and efivarfs is mounted as read-only. > > > > > > This commit notifies the update of efivar operation to > > > efivarfs subsystem, then drops SB_RDONLY flag if the efivar > > > operation supports SetVariable. > > > > But it does not re-add it and prevents further requests to the TA (that > > will only cause panics there) when the daemon terminates, does it? > > It doesn't, but I think I got a better way out. Even what you suggest won't > solve the problem entirely. For the sake of context > - The kernel decides between the RO/RW depending on the SetVariable ptr > - The stmm *module* registers and swaps the RT calls -- and the ptr is now > valid. Note here that the module probe function will run only if the > supplicant is running > - Once the module is inserted the filesystem will be remounted even without > the supplicant running, which would not trigger an oops, but an hard to > decipher error message from OP-TEE. > > So even if we switch the permissions back to RO when the supplicant dies, > someone can still remount it as RW and trigger the same error. > > Which got me thinking and staring the TEE subsystem a bit more. The > supplicant is backed by a /dev file, which naturally has .open() and > .release() callbacks. Why don't we leave the module perform the initial > setup -- e.g talk to StMM and make sure it's there, setup the necessary > buffers etc and defer the actual swapping of the efivar ops and the > filesystem permissions there? I might 'feel' a bit weird, but as I > mentioned the module probe function only runs if the supplicant is running > anyway I think we are discussing two issues. 1) efivar ops is not restored when the tee-supplicant daemon terminates. The patch[1] sent by Sumit addresses this issue. Thanks to this patch, 'remove' callback of tee_stmm_efi_driver is called when the tee-supplicant daemon terminates, then restore the previous efivar ops and SB_RDONLY flag if necessary. 2) cause panic when someone remounts the efivarfs as RW even if SetVariable is not supported. [1] https://lore.kernel.org/all/20230607151435.92654-1-sumit.garg@linaro.org/ Thanks, Masahisa Kojima > > Cheers > /Ilias > > > > > Jan > > > > -- > > Siemens AG, Technology > > Competence Center Embedded Linux > >