Received: by 2002:ac8:7315:0:b0:429:955e:b7c6 with SMTP id x21csp208766qto; Fri, 26 Jan 2024 16:17:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IHXpvl7jd9nr5SxpLzEOnN8J+QMAPQ8QKY0VwQeH+PXAzjjJnA8MM3vA/BTrKzGed+DqjG+ X-Received: by 2002:a05:651c:198a:b0:2ce:fa00:9b0a with SMTP id bx10-20020a05651c198a00b002cefa009b0amr736246ljb.16.1706314660946; Fri, 26 Jan 2024 16:17:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706314660; cv=pass; d=google.com; s=arc-20160816; b=J+TS0PWqs96ofGZ7/4rAFIpBa9yUo+JUps0IXgQjlvleozmOyJLOe5TFp4ixW+60xd 7yBECon1mWb07qKZd29KfMmqTOUgw0Z+aEUCdez0LdVBbgfXRIj918wg48MwsABg+Y5n 1r8h0pzMfsyMQu+6OylJCISgoVXqpmLSJka7548Yod+w1TLhOUpphNVA8LAUtYLmn2Ah gPS7g5jvHKX7nWSd2jXteqPGh2FQSCVdlu3UM96bV00/hAIBzrKeBRePz6I3o041Ejz6 SMh+nL9dEzICBWA9TNtF3KLKj/fY0g28hkQNj6By2Wed8napg3zllGtfR8SjdpG2czSv OANA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=DMC6oNAj1F/qiIU2aT/CFQ/DN0Km6DOD7mBguvrMY/g=; fh=AlX9JwpdDw8dAShZ9nmCeb3BZGR9sV0gR643MTEaNQA=; b=o1D5w6ksLlgGrhC16bPCQCw3Bxe6RB+qhwTmJPcCGB+ImMZHQiMbN5D+Ux7PjdI+30 C6GcjO1c17PKktPeXzmgEzD7HMpFwk4M9eNYNcu4snI6cPM2d18QUz7XnNw/MlfovRwI QHcwDJFDfIdapGNolxE/w/TvQLF066OlzJDk3ZwRp2Z4dnVl8kPWrDokFT0b9jbDNeTp VvDxeeSiNfBzHBN3Rf0jNJp63mnGuWVANYqLFmBUDq/QCettvnd9DwESN4BTu7wnM5iI FjeLpXShsmvx9bdGmGURMyK/vHhTyK5n5+s9pS0BsUoAHV60iB2qyH+ADRiKwyISMzw2 t03w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jzSK9hU2; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-40922-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40922-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id i5-20020a50fc05000000b0055a52853f3bsi1070363edr.582.2024.01.26.16.17.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 16:17:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-40922-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jzSK9hU2; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-40922-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40922-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 95E901F23FD6 for ; Sat, 27 Jan 2024 00:16:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0AEAA39E; Sat, 27 Jan 2024 00:16:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="jzSK9hU2" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (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 C3A03199; Sat, 27 Jan 2024 00:16:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.55.52.120 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706314603; cv=none; b=DC47818iTAPz8hXUBwyQXI+TTNamHAT2reU89dRlfoV6zSn2PBGGVRynKx4lUS8hNOJFXhNoN9FeeFl2ZSZKkswZAfrjuzm2WGVgMVESs7a14ZNxCB+PdmwmXrqhXYcYFZ8H/c7mhgNc6duao8AAitBwxlV+8z0Gq6FnVA+ZtC4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706314603; c=relaxed/simple; bh=JE0M51hDt71bGoBDBFo9edm7n0oVInGu8hcf0iaynGo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=tTWW+m9atYJ3mFEoDiNGHsjeaalHhs5WbQMuK5PGMFEOauQQJg0VR7MVTOytne0qYUoWiZtuzhwJay/nXaiu5l/N7G9MiDfmfGqnF5r2VG4U7Co3NroxoX1qJufY90ii1IaFqLTNs7DNlkCyL1Ky6w4vqtuuu1b9LoLiWDGBtq0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=jzSK9hU2; arc=none smtp.client-ip=192.55.52.120 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706314600; x=1737850600; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version:content-transfer-encoding; bh=JE0M51hDt71bGoBDBFo9edm7n0oVInGu8hcf0iaynGo=; b=jzSK9hU2w5sGRtOKK6FKut4s3aeH5lh0GhwJEslf2EubwV20bOTOlgbh SXDh02TdOTkWN1s3dqHZrMkujFsZJtPuTGD7TIEZXnCs0PA1omrwJq0xD d1BHqjLA/rHFAqILNNtZmzvQRLPJHaW/Gi5UxtqjAOFZxJ80QIj4BtfoI dqXv0uEgSAWp2HvyBU6BNRXlpCTwftdmGR6UetQl7Ebwk/zseT1a4zcGS hPad0N6+NQnXOMc3xiInVzPesHaC/HdSaZslYvmxLFvptbZZmN+qCgKUN 0EkO+AjpzD1nmOO4FyiyJ9hHGfmYieSnRV+kWi8UTsB1q9fcuyaC5tSxw w==; X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="401480661" X-IronPort-AV: E=Sophos;i="6.05,220,1701158400"; d="scan'208";a="401480661" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2024 16:16:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="906468534" X-IronPort-AV: E=Sophos;i="6.05,220,1701158400"; d="scan'208";a="906468534" Received: from vcostago-desk1.jf.intel.com (HELO vcostago-desk1) ([10.54.70.67]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2024 16:16:37 -0800 From: Vinicius Costa Gomes To: Amir Goldstein Cc: brauner@kernel.org, hu1.chen@intel.com, miklos@szeredi.hu, malini.bhandaru@intel.com, tim.c.chen@intel.com, mikko.ylinen@intel.com, lizhen.you@intel.com, linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC v2 2/4] cred: Add a light version of override/revert_creds() In-Reply-To: References: <20240125235723.39507-1-vinicius.gomes@intel.com> <20240125235723.39507-3-vinicius.gomes@intel.com> Date: Fri, 26 Jan 2024 16:16:36 -0800 Message-ID: <87sf2j4om3.fsf@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Amir Goldstein writes: > On Fri, Jan 26, 2024 at 1:57=E2=80=AFAM Vinicius Costa Gomes > wrote: >> >> Add a light version of override/revert_creds(), this should only be >> used when the credentials in question will outlive the critical >> section and the critical section doesn't change the ->usage of the >> credentials. >> >> To make their usage less error prone, introduce cleanup guards asto be >> used like this: >> >> guard(cred)(credentials_to_override_and_restore); >> >> or this: >> >> scoped_guard(cred, credentials_to_override_and_restore) { >> /* with credentials overridden */ >> } >> >> Signed-off-by: Vinicius Costa Gomes > > You may add: > Reviewed-by: Amir Goldstein > > I would also add: > Suggested-by: Christian Brauner > Forgot about that one.=20 Cheers, --=20 Vinicius