From patchwork Wed Nov 16 15:37:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luis Henriques X-Patchwork-Id: 21122 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp208261wru; Wed, 16 Nov 2022 07:37:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf6W5SNonkc0E+p32n5WBr0+yiBRYwmyhIUEVTh1tRZ2R3GjDBzZc7loOn8cPzDu9vz3gbIA X-Received: by 2002:a17:907:b60f:b0:78d:9f25:6103 with SMTP id vl15-20020a170907b60f00b0078d9f256103mr18222880ejc.168.1668613070461; Wed, 16 Nov 2022 07:37:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668613070; cv=none; d=google.com; s=arc-20160816; b=MEWaLBd1Si3sbgPTao56u3d/nYIrWjkHeZK1iNWC6XpqtaRg0u09Fi2cccUlvm02Kh Z9bg9A8M8mf5fGLWb37QYrL35MB2wk+ruIykXG60jGapcF9tfpWxkmPqPHJm7NSWD6Ko IUOyvisuBfS4xU5bsF1+nOM1ipHBbMMaA4yn/cVRVbKvoDRl8vqjZcvTqqi7euwO5Oy7 Agum5EXi0lvleyG6tHUqtlnqXmhfr9gnA3SlayqPZV4WR801Mxr0pfaUvgPxZZQO0g/b Bc0c25EIU4G5FtQ645PBZyhpxI+aDhxK5oYi+qmI+8jgS2LfUov3uRgDV88R7QT81LIt OlUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=dXEbhPN++fKE2vgAqmHjFf/FhFXA2Mf+lSNZdDPIEpM=; b=Hqu+OMJF7gsw4lvtms5i515PO47jTa6Zi65j8azY0N8o6NlIAHMRfMZGmLo/EfxnmS CLine9vQnevpgzj1DhPkNvewFpZ1ijdmCbQEVPX8noVbtw2alVRemA8NHukRX56K/lmb SjgVo6KKZLjTf+bRSVwG++hhK0u0ueAGQjIh/1ZrBisiUgRJQYLyJ+NSs1hQV4FCV820 6a58uNS6kbFntB3IqvceqyjOlCYprCcQFmy8MewTSf0i6nUKdr85fk5E4FC8V/khp0iX EpMUTFijRaefxe1r8QfkTvkT4iNsByFoYAx44qiF0jOkljihKLwfZ4TEnfh09FYqYetr qIWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=do6TaNFx; dkim=neutral (no key) header.i=@suse.de; 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=suse.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w1-20020a17090652c100b0078849a014e9si11731881ejn.196.2022.11.16.07.37.26; Wed, 16 Nov 2022 07:37:50 -0800 (PST) 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=@suse.de header.s=susede2_rsa header.b=do6TaNFx; dkim=neutral (no key) header.i=@suse.de; 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=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232682AbiKPPgM (ORCPT + 99 others); Wed, 16 Nov 2022 10:36:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229834AbiKPPgK (ORCPT ); Wed, 16 Nov 2022 10:36:10 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D66A514D0C; Wed, 16 Nov 2022 07:36:09 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 8F7731F94F; Wed, 16 Nov 2022 15:36:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1668612968; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dXEbhPN++fKE2vgAqmHjFf/FhFXA2Mf+lSNZdDPIEpM=; b=do6TaNFxSrVKbQKNRcNQ4tb5s4GHUZ/m4Ig6UqPJVDrW+Gv7/+glG/zrWCkpiZ7xL4cVz9 ItHgbOnlgqgxP5JgoiPz84jv2tan0bvQOCailaqzwuF769tmf6FQRI9ujOhfkAxsKhTMaP JPXooClhyHefw5M8ad6P5wyTrWweLVc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1668612968; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dXEbhPN++fKE2vgAqmHjFf/FhFXA2Mf+lSNZdDPIEpM=; b=AWWQ7AITmGeDBUCEwyA24p/ifT98EBITIaVfLuUNrQ7T6V1TFPF4cicxqiXD1dBmqlZ0xn JVImG02lsWbdMrDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 23BE913480; Wed, 16 Nov 2022 15:36:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id hldKBWgDdWMJcgAAMHmgww (envelope-from ); Wed, 16 Nov 2022 15:36:08 +0000 Received: from localhost (brahms.olymp [local]) by brahms.olymp (OpenSMTPD) with ESMTPA id 576d7e49; Wed, 16 Nov 2022 15:37:07 +0000 (UTC) From: =?utf-8?q?Lu=C3=ADs_Henriques?= To: Xiubo Li , Ilya Dryomov , Jeff Layton Cc: ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Lu?= =?utf-8?q?=C3=ADs_Henriques?= Subject: [PATCH] ceph: make sure directories aren't complete after setting crypt context Date: Wed, 16 Nov 2022 15:37:03 +0000 Message-Id: <20221116153703.27292-1-lhenriques@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749667618863725601?= X-GMAIL-MSGID: =?utf-8?q?1749667618863725601?= When setting a directory's crypt context, __ceph_dir_clear_complete() needs to be used otherwise, if it was complete before, any old dentry that's still around will be valid. Signed-off-by: Luís Henriques --- Hi! Here's a simple way to trigger the bug this patch is fixing: # cd /cephfs # ls mydir nKRhofOAVNsAwVLvDw7a0c9ypsjbZfK3n0Npnmni6j0 # ls mydir/nKRhofOAVNsAwVLvDw7a0c9ypsjbZfK3n0Npnmni6j0/ Cyuer5xT+kBlEPgtwAqSj0WK2taEljP5vHZ,D8VXCJ8 u+46b2XVCt7Obpz0gznZyNLRj79Q2l4KmkwbKOzdQKw # fscrypt unlock mydir # touch /mnt/test/mydir/mysubdir/file touch: cannot touch '/mnt/test/mydir/mysubdir/file': No such file or directory fs/ceph/crypto.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/ceph/crypto.c b/fs/ceph/crypto.c index 35a2ccfe6899..dc1557967032 100644 --- a/fs/ceph/crypto.c +++ b/fs/ceph/crypto.c @@ -87,6 +87,10 @@ static int ceph_crypt_get_context(struct inode *inode, void *ctx, size_t len) return -ERANGE; memcpy(ctx, cfa->cfa_blob, ctxlen); + + /* Directory isn't complete anymore */ + if (S_ISDIR(inode->i_mode) && __ceph_dir_is_complete(ci)) + __ceph_dir_clear_complete(ci); return ctxlen; }