Received: by 2002:a05:7412:9c07:b0:fa:6e18:a558 with SMTP id lr7csp14510rdb; Fri, 26 Jan 2024 16:37:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IF7Iv8rDWH45waY0wAKHTIoTp46dPhB93l0tPcKe0PlCB3I0guymnM1ZOQn1JJxmijSqN62 X-Received: by 2002:a5b:dcb:0:b0:dbd:2162:b14a with SMTP id t11-20020a5b0dcb000000b00dbd2162b14amr579476ybr.102.1706315835822; Fri, 26 Jan 2024 16:37:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706315835; cv=pass; d=google.com; s=arc-20160816; b=w2P++I0BJ44MpkujaioLppf4IsrVjhRdaRZk0veCL4/GrzZ1noTH6Cbq7d16OLOszs FZ/tTP3L58j5ys3GmxCLo0uY+x2nvxd2DfoINxnPJbX/bOu9TPj3vTq6QHYJ07b1l67b AYCvuUEtLsIuo5XLb069MNzG3P+45+wvE4j53cdCSv2bfzp0AWq9AUA6BxV/Uxw+WLiP 5Sgzvjyg9nSuvKnCpOFDocNbHS8r6/tABcyz25dGFsX0muEa2cWVhNthlnXIQoKP5sMw lULBFvg1OIlsemJyz/iRhPN309CsHBfFC28MKPyGhbtMOOPyaLvckzJczl6u9epxJYB/ zqlA== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature :dkim-signature:dkim-signature; bh=NWLoWz7nxQVTABtxNVN2ddgKtqXgJeF/RFCQQ5mld/o=; fh=M648oune0DwZmCHpgeKmdqyNG9Pnhrh1APj5VeeCjyQ=; b=mWKNbQjmzWnuJ2UyBbhtWL3utLchTWzcdQz+AgwyOs0aBpPgDDv8WgfdjS7MlgPf2f Akh9OM40Y8ycRjDM3DUEPTjQgSqakwOKzGqwEKYlIFJF86ddIJk8cFbN9JCBv17bdfV0 AOzpzUHSp4LnENKjTVvKyQUf8FkrfWFEbLhreoeEtv91he5d5D6/xcaC5vPpEwvrNSTZ wUnuJuFMS0f8aDioOEfGA1IfHxHQyMIb8wq+yI8o0FnewlKa5S3ICo9CXQkwnO57O5yB b7OVtBD4X/ljrqNiNdoXhxrvQHojVGQjIgYDPX4+M+PCrlWhjc7uQUtWu7IZs0v27sj7 uyYA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=jMMuXVkp; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=jMMuXVkp; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-ext4+bounces-938-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-ext4+bounces-938-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id l72-20020a633e4b000000b005d54ef5dd07si1936668pga.161.2024.01.26.16.37.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 16:37:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-938-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=jMMuXVkp; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=jMMuXVkp; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-ext4+bounces-938-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-ext4+bounces-938-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id EFBDAB27429 for ; Sat, 27 Jan 2024 00:11:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DAB2A20F2; Sat, 27 Jan 2024 00:10:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="jMMuXVkp"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="HRpyaj48"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="jMMuXVkp"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="HRpyaj48" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB0B11FAF; Sat, 27 Jan 2024 00:10:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706314229; cv=none; b=Ot8+BPbn4Jo0FNePnO8UvBSwg02ayQvH0cHCZAWmUpkI/teWhDsdZcjkcemjlX7+z58DWUYAim+ATnELifG0OGlrY6ITKLg5liu2MVZGqhkhchJ78nEcVKZ6kj0/qDYfYiPVnP7Fr5pJuLzMFff1uekO48kPbaVpKmOv+GI779E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706314229; c=relaxed/simple; bh=bqvR1ioSLEXM1TsuTdhMpzk64b5FBELlWtE3yTRwBsg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B29nCR5Tz7DKhSmBkeC2BcAVAIrNzXgrT9sjPat+Wt1ZWP38ogS7sIqU8AdSOAnMQsTXIU+BITbxOJs0h0C+oJaoXHRt8wwW1i8JLY/8G+nLaoYq51RVoFMYQg38zStBUwwtIqyKCKfs5DWN8aTrrcBbbKFPNw9TsQliVkoQVjE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=jMMuXVkp; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=HRpyaj48; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=jMMuXVkp; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=HRpyaj48; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D895F223A6; Sat, 27 Jan 2024 00:10:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706314225; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NWLoWz7nxQVTABtxNVN2ddgKtqXgJeF/RFCQQ5mld/o=; b=jMMuXVkpSpbPSJxsV3MIjpN6PGjfubZ2/yXiclzMuEn0RJNV9FUELM/eMcRAhjLkAL9pTG IU7BYBF2OWVU6w2Vrl05xIiweBOS6zDsA9CSfLUvD3FnJjO5XLc+/uXs/T0Ex2fFUfQ6br XQGGlOF6kFKeS60bvyB14zgEnzj4dpU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706314225; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NWLoWz7nxQVTABtxNVN2ddgKtqXgJeF/RFCQQ5mld/o=; b=HRpyaj48NjSzHXdDa6Gt0uYnYFpLRilg5TqLOPVIa1y18+WKa4LXJsYesyDmW017tzf4Eb DmE0jXrcLBbZ2rAA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706314225; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NWLoWz7nxQVTABtxNVN2ddgKtqXgJeF/RFCQQ5mld/o=; b=jMMuXVkpSpbPSJxsV3MIjpN6PGjfubZ2/yXiclzMuEn0RJNV9FUELM/eMcRAhjLkAL9pTG IU7BYBF2OWVU6w2Vrl05xIiweBOS6zDsA9CSfLUvD3FnJjO5XLc+/uXs/T0Ex2fFUfQ6br XQGGlOF6kFKeS60bvyB14zgEnzj4dpU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706314225; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NWLoWz7nxQVTABtxNVN2ddgKtqXgJeF/RFCQQ5mld/o=; b=HRpyaj48NjSzHXdDa6Gt0uYnYFpLRilg5TqLOPVIa1y18+WKa4LXJsYesyDmW017tzf4Eb DmE0jXrcLBbZ2rAA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 3C87613998; Sat, 27 Jan 2024 00:10:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id GC/iN/BJtGVWEQAAD6G6ig (envelope-from ); Sat, 27 Jan 2024 00:10:24 +0000 From: Gabriel Krisman Bertazi To: ebiggers@kernel.org, viro@zeniv.linux.org.uk, jaegeuk@kernel.org, tytso@mit.edu Cc: amir73il@gmail.com, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH v4 02/12] fscrypt: Factor out a helper to configure the lookup dentry Date: Fri, 26 Jan 2024 21:10:02 -0300 Message-ID: <20240127001013.2845-3-krisman@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240127001013.2845-1-krisman@suse.de> References: <20240127001013.2845-1-krisman@suse.de> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: *** X-Spam-Score: 3.70 X-Spamd-Result: default: False [3.70 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_SEVEN(0.00)[9]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[gmail.com,vger.kernel.org,lists.sourceforge.net,suse.de]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.00)[14.58%] X-Spam-Flag: NO Both fscrypt_prepare_lookup_dentry_partial and fscrypt_prepare_lookup_dentry will set DCACHE_NOKEY_NAME for dentries when the key is not available. Extract out a helper to set this flag in a single place, in preparation to also add the optimization that will disable ->d_revalidate if possible. Signed-off-by: Gabriel Krisman Bertazi --- fs/crypto/hooks.c | 18 ++++++++---------- include/linux/fscrypt.h | 10 ++++++++++ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/fs/crypto/hooks.c b/fs/crypto/hooks.c index 52504dd478d3..71463cef08f9 100644 --- a/fs/crypto/hooks.c +++ b/fs/crypto/hooks.c @@ -102,11 +102,8 @@ int __fscrypt_prepare_lookup(struct inode *dir, struct dentry *dentry, if (err && err != -ENOENT) return err; - if (fname->is_nokey_name) { - spin_lock(&dentry->d_lock); - dentry->d_flags |= DCACHE_NOKEY_NAME; - spin_unlock(&dentry->d_lock); - } + fscrypt_prepare_lookup_dentry(dentry, fname->is_nokey_name); + return err; } EXPORT_SYMBOL_GPL(__fscrypt_prepare_lookup); @@ -131,12 +128,13 @@ EXPORT_SYMBOL_GPL(__fscrypt_prepare_lookup); int fscrypt_prepare_lookup_partial(struct inode *dir, struct dentry *dentry) { int err = fscrypt_get_encryption_info(dir, true); + bool is_nokey_name = false; + + if (!err && !fscrypt_has_encryption_key(dir)) + is_nokey_name = true; + + fscrypt_prepare_lookup_dentry(dentry, is_nokey_name); - if (!err && !fscrypt_has_encryption_key(dir)) { - spin_lock(&dentry->d_lock); - dentry->d_flags |= DCACHE_NOKEY_NAME; - spin_unlock(&dentry->d_lock); - } return err; } EXPORT_SYMBOL_GPL(fscrypt_prepare_lookup_partial); diff --git a/include/linux/fscrypt.h b/include/linux/fscrypt.h index 12f9e455d569..68ca8706483a 100644 --- a/include/linux/fscrypt.h +++ b/include/linux/fscrypt.h @@ -948,6 +948,16 @@ static inline int fscrypt_prepare_rename(struct inode *old_dir, return 0; } +static inline void fscrypt_prepare_lookup_dentry(struct dentry *dentry, + bool is_nokey_name) +{ + if (is_nokey_name) { + spin_lock(&dentry->d_lock); + dentry->d_flags |= DCACHE_NOKEY_NAME; + spin_unlock(&dentry->d_lock); + } +} + /** * fscrypt_prepare_lookup() - prepare to lookup a name in a possibly-encrypted * directory -- 2.43.0