From patchwork Fri Mar 15 14:53:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Sindholt X-Patchwork-Id: 13593583 Received: from wirbelwind.zhasha.com (wirbelwind.zhasha.com [78.109.210.80]) (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 70193381B4 for ; Fri, 15 Mar 2024 14:53:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.109.210.80 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710514420; cv=none; b=Bz+Zg/OhqIxyrwYkHGNuGqvIa4iW6G5wTQTJHzcvJrhzNzmYUCIfOTHOshmrN/nRLKPzQQxI1dEaFaOtwiP8i46htKapd6BYojr7NBeyylCN1WC/fW79dceDa+j3fOv6eLi5b1O6r6vKS4+iMwQmV604dsUWiIfXbW5GbdTp4Mg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710514420; c=relaxed/simple; bh=52zKLsKuVu414HKsZvISZAM9V23SW81LDNg1enp36JE=; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type; b=TjEFJrrVFRxJljfi7/rqMW6qveM0Xzoo8dZqGAS6YanRdQbboB0Z8wFRSB6oJJcySov7ZQ4WbQuzECJ0ZrkjQfJT85mAe0U6Rd7aBQceHR+VfyaQui8OO+eplphD/jfwulWC12lFyhZxQxOR2rHSn8ms93KsSMyou5iz+NK1eSM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=zhasha.com; spf=pass smtp.mailfrom=zhasha.com; dkim=pass (1024-bit key) header.d=zhasha.com header.i=@zhasha.com header.b=YTOxGd6r; arc=none smtp.client-ip=78.109.210.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=zhasha.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zhasha.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=zhasha.com header.i=@zhasha.com header.b="YTOxGd6r" Received: from eclair (unknown [77.72.50.149]) by wirbelwind.zhasha.com (Postfix) with ESMTPSA id E8F98325384 for ; Fri, 15 Mar 2024 15:53:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zhasha.com; s=wirbelwind; t=1710514410; bh=HLfjg/xUXZQJ+v1yTRbhMuPDMEHqOkYEgSuRM91LW+U=; h=Date:From:To:Subject; b=YTOxGd6rs3wuEc2KcOWNCAb2GIXNCH3X8AdDrGR+pmQs1AkEAXY4nMaY8lmqT/NSW lpo2Te0lJ53kKPN8QrN7YxL7GCleugCIXIyKcTjbBZFRZZeIQ86iq/F17gGH0MBv2o mhGEk8BOLYvJcKuVhxTwSD3rrcAnaVdI/zmno90U= Date: Fri, 15 Mar 2024 15:53:29 +0100 From: Joakim Sindholt To: v9fs@lists.linux.dev Subject: [PATCH 1/4] fs/9p: only translate RWX permissions for plain 9P2000 Message-ID: <20240315155329.61e33be0@eclair> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.39; x86_64-gentoo-linux-musl) Precedence: bulk X-Mailing-List: v9fs@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Garbage in plain 9P2000's perm bits is allowed through, which causes it to be able to set (among others) the suid bit. This was presumably not the intent since the unix extended bits are handled explicitly and conditionally on .u. From 2d9f6cc6b3163d4991aaa6d799c554edd07a6c0a Mon Sep 17 00:00:00 2001 From: Joakim Sindholt Date: Fri, 15 Mar 2024 15:13:21 +0100 Subject: [PATCH 1/4] fs/9p: only translate RWX permissions for plain 9P2000 --- fs/9p/vfs_inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 32572982f72e..1180d1453a5a 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -83,7 +83,7 @@ static int p9mode2perm(struct v9fs_session_info *v9ses, int res; int mode = stat->mode; - res = mode & S_IALLUGO; + res = mode & S_IRWXUGO; if (v9fs_proto_dotu(v9ses)) { if ((mode & P9_DMSETUID) == P9_DMSETUID) res |= S_ISUID; From patchwork Fri Mar 15 14:57:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Sindholt X-Patchwork-Id: 13593586 Received: from wirbelwind.zhasha.com (wirbelwind.zhasha.com [78.109.210.80]) (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 C006C3BB32 for ; Fri, 15 Mar 2024 14:57:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.109.210.80 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710514657; cv=none; b=DSIu2J7grMtHET9ktCtwEirr91za/fJDYwE09xidcU0pYHbT41GrodwydItBR1lnzvptl0TVpyVuiLWmF40S2+pj5lEDxEHfWSxe+M9Ouj75dIpD11gWLKZeIxZWUjiFMsSjC7X+6v1A5z73cU2MwVyFofoKBxrb0fe4+s9o45U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710514657; c=relaxed/simple; bh=nEVu7fuCd0Axxn/NgWSBiIiasktgmSEMoWeTjYO3hW0=; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type; b=m5v4P0bc4/rTUUq5BD84EKVHsus/zldIaVEweYexNh6f0Q+LBbqcJ4iINGRuJYW8pEVFLoOKbT6qyV0gCU9QJOSIWpyZVEuMQjuE4RTbWEnWKaVPI3KnXmkFlxxmDX+5iiHche6W/3kYx57oqSgSCZb4xOXa502PT+YmCWQKotg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=zhasha.com; spf=pass smtp.mailfrom=zhasha.com; dkim=pass (1024-bit key) header.d=zhasha.com header.i=@zhasha.com header.b=b0r8S5ma; arc=none smtp.client-ip=78.109.210.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=zhasha.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zhasha.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=zhasha.com header.i=@zhasha.com header.b="b0r8S5ma" Received: from eclair (unknown [77.72.50.149]) by wirbelwind.zhasha.com (Postfix) with ESMTPSA id 41D86325384 for ; Fri, 15 Mar 2024 15:57:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zhasha.com; s=wirbelwind; t=1710514653; bh=ululPH4EOvh4Rs+hKocpC1akmNCQtsJPs78WVZwWFeI=; h=Date:From:To:Subject; b=b0r8S5maNlFTvvmMD9X7WRYEa4IxQP1AqWgYhsgYpfPLZybvlS3BHGdW69nCi+SyP saX+IBP2nYzpsePWWXoqF5rF6IShY3LIXa8Z2EkjaXxG3TFbkYGmGbb6wazzaugPkz PGMb4YE3c5EqEoN4kh4HZDNxv9BeD33dE4YCGPFk= Date: Fri, 15 Mar 2024 15:57:32 +0100 From: Joakim Sindholt To: v9fs@lists.linux.dev Subject: [PATCH 2/4] fs/9p: drop inodes immediately on non-.L too Message-ID: <20240315155732.77dabf51@eclair> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.39; x86_64-gentoo-linux-musl) Precedence: bulk X-Mailing-List: v9fs@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 I assume this was an oversight but non-.L v9fs doesn't currently have the drop_inode callback declared. This causes effectively unbounded growth of the inode table and after a good while it becomes enormously expensive to look through all the qid matches. From e47d28e0fdc42819e7d7ce9d5e7f5bc8f189aee1 Mon Sep 17 00:00:00 2001 From: Joakim Sindholt Date: Fri, 15 Mar 2024 15:13:48 +0100 Subject: [PATCH 2/4] fs/9p: drop inodes immediately on non-.L too --- fs/9p/vfs_super.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c index 941f7d0e0bfa..23cc67f29af2 100644 --- a/fs/9p/vfs_super.c +++ b/fs/9p/vfs_super.c @@ -310,6 +310,7 @@ static const struct super_operations v9fs_super_ops = { .alloc_inode = v9fs_alloc_inode, .free_inode = v9fs_free_inode, .statfs = simple_statfs, + .drop_inode = v9fs_drop_inode, .evict_inode = v9fs_evict_inode, .show_options = v9fs_show_options, .umount_begin = v9fs_umount_begin, From patchwork Fri Mar 15 15:00:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Sindholt X-Patchwork-Id: 13593587 Received: from wirbelwind.zhasha.com (wirbelwind.zhasha.com [78.109.210.80]) (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 CE2ED288DB for ; Fri, 15 Mar 2024 15:00:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.109.210.80 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710514826; cv=none; b=sCrKcWijxITnqZJM79Lsb9QHPlx0ChW5xvgHOHXw7QBjSFh9RBTFVB7b7kMZkQocOL1putahoz9BzwmNQSrOjDPz5sXtazUnYSkBFAcYexGt75739gkl/Z+uCgc4ZbAoVFvB5eb4jOE7VOyQTCVy0tqv5dTQqyEuS9cxZ0XBaIs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710514826; c=relaxed/simple; bh=U/t5JdSj1At5NyGpm1NteCiuKbxvHb34wkUCXrXTB0Q=; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type; b=Dw7Igqw8MLCATMKTAu8b0ux7AVfPBCtoWbygcOK7Zi2ZPo2w6YUVc5RdGW5cPbgxXbAp+cC3TxjODL4hfOSi+Xq46gvVyhUVsRtZxJqSpYFyGTM+QAJp1UATnHLinBMuM3w7m07Sw7zMn/+8xu+lOxITxOwRBP21eoTMhOCSRXk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=zhasha.com; spf=pass smtp.mailfrom=zhasha.com; dkim=pass (1024-bit key) header.d=zhasha.com header.i=@zhasha.com header.b=XAYalJjf; arc=none smtp.client-ip=78.109.210.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=zhasha.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zhasha.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=zhasha.com header.i=@zhasha.com header.b="XAYalJjf" Received: from eclair (unknown [77.72.50.149]) by wirbelwind.zhasha.com (Postfix) with ESMTPSA id 94A3D325384 for ; Fri, 15 Mar 2024 16:00:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zhasha.com; s=wirbelwind; t=1710514819; bh=r3v10BIBZ3mmuS7/Ve2m/PKl2dhu67IxrlFhRJSL8PE=; h=Date:From:To:Subject; b=XAYalJjfs0v/NTVlCHCJzW+UQBfwWJw40cODfCHx1HxyEnezcwjlgf88+okbk9j1Y qGka42PV44myi1VqGTttPxQhhIRnb/ro+QcKeU92yTTCZ/t/nEanbU80ZoRLPl0bV4 FpVZuauaZxRddnTOf4/qAV60AXY8B5AlE2ynH+B8= Date: Fri, 15 Mar 2024 16:00:19 +0100 From: Joakim Sindholt To: v9fs@lists.linux.dev Subject: [PATCH 3/4] fs/9p: translate O_TRUNC into OTRUNC Message-ID: <20240315160019.2c273cd4@eclair> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.39; x86_64-gentoo-linux-musl) Precedence: bulk X-Mailing-List: v9fs@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This one hits both 9P2000 and .u as it appears v9fs has never translated the O_TRUNC flag. From 108c0a96284563812dcb701f52bc5ef554f281fc Mon Sep 17 00:00:00 2001 From: Joakim Sindholt Date: Fri, 15 Mar 2024 15:18:09 +0100 Subject: [PATCH 3/4] fs/9p: translate O_TRUNC into OTRUNC --- fs/9p/vfs_inode.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 1180d1453a5a..8f2e0fcfb303 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -178,6 +178,9 @@ int v9fs_uflags2omode(int uflags, int extended) break; } + if (uflags & O_TRUNC) + ret |= P9_OTRUNC; + if (extended) { if (uflags & O_EXCL) ret |= P9_OEXCL; From patchwork Fri Mar 15 15:07:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Sindholt X-Patchwork-Id: 13593594 Received: from wirbelwind.zhasha.com (wirbelwind.zhasha.com [78.109.210.80]) (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 43E2C18EA8 for ; Fri, 15 Mar 2024 15:07:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.109.210.80 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710515256; cv=none; b=PE4dpBsLjqNoS2bIjUdHgw4f8W9A+pKnEpjQxrlJBHDQMYd9e/7eC3NSreVN7SiM0xubfAwKbIZnp5k5zhu3MQGgYcQbgh4iEfrV72Ml7V0pmWSEf1SucD8JcUSSWW0s/qh+O8IzO+NkI1pGEReYcKQkRjqgZyR6ibrEY7t8YPs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710515256; c=relaxed/simple; bh=xAlwaMTLrAqn5JDuJUjWSgUI3T8P5MmTp9lu8Qes24A=; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type; b=VmJZLzK1ETuYLd/J2OPPZBGHhR5+JIgvHsxTbzkZiJUhIfoBHtnNcFImGt5eN68Hnkbj7YlGBYWLmzyXczwhiJ92kwJVAezdg2TzzUgST5Ns1cc3Rb5LOHt/mKA8G4jLmRkmHDR5D0+64HpcieyQ9DhdShvO6zxRI81Pczn4IoA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=zhasha.com; spf=pass smtp.mailfrom=zhasha.com; dkim=pass (1024-bit key) header.d=zhasha.com header.i=@zhasha.com header.b=w3e9H2gB; arc=none smtp.client-ip=78.109.210.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=zhasha.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zhasha.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=zhasha.com header.i=@zhasha.com header.b="w3e9H2gB" Received: from eclair (unknown [77.72.50.149]) by wirbelwind.zhasha.com (Postfix) with ESMTPSA id 6173E325384 for ; Fri, 15 Mar 2024 16:07:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zhasha.com; s=wirbelwind; t=1710515249; bh=uHAg2i8BiREE1/hVf6UEHSVHbuy7lJ15VwnJzCn/EII=; h=Date:From:To:Subject; b=w3e9H2gB6rZKTaIh9y6eRKG48qNTdOqsux+Ful28sOvc3f3UoqWAVRtg+j34Y7Bit 5h1BrntvRrXHShIG/DFHYU641LuAJhFPl60jbzrZ0lVTY++1muEkW9nKAoEG0u2bI3 Pnvq/GdIuWsDMTyv66bx81To5n5+ZZTNLHFcW168= Date: Fri, 15 Mar 2024 16:07:28 +0100 From: Joakim Sindholt To: v9fs@lists.linux.dev Subject: [PATCH 4/4] fs/9p: fix the cache always being enabled on files with qid flags Message-ID: <20240315160728.647c299b@eclair> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.39; x86_64-gentoo-linux-musl) Precedence: bulk X-Mailing-List: v9fs@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 I'm not sure why this check was ever here. After updating to 6.6 I suddenly found caching had been turned on by default and neither cache=none nor the new directio would turn it off. After walking through the new code very manually I realized that it's because the caching has to be, in effect, turned off explicitly by setting P9L_DIRECT and whenever a file has a flag, in my case QTAPPEND, it doesn't get set. #define QTDIR 0x80 #define QTAPPEND 0x40 #define QTEXCL 0x20 #define QTAUTH 0x08 #define QTTMP 0x04 #define QTFILE 0x00 Setting aside QTDIR which seems to ignore the new fid->mode entirely, the rest of these either should be subject to the same cache rules as every other QTFILE or perhaps very explicitly not cached in the case of QTAUTH. From 7ee510d31c0b6074dbd8bc27c1fb86f12270f851 Mon Sep 17 00:00:00 2001 From: Joakim Sindholt Date: Fri, 15 Mar 2024 15:19:10 +0100 Subject: [PATCH 4/4] fs/9p: fix the cache always being enabled on files with qid flags --- fs/9p/fid.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/fs/9p/fid.h b/fs/9p/fid.h index 29281b7c3887..0d6138bee2a3 100644 --- a/fs/9p/fid.h +++ b/fs/9p/fid.h @@ -49,9 +49,6 @@ static inline struct p9_fid *v9fs_fid_clone(struct dentry *dentry) static inline void v9fs_fid_add_modes(struct p9_fid *fid, unsigned int s_flags, unsigned int s_cache, unsigned int f_flags) { - if (fid->qid.type != P9_QTFILE) - return; - if ((!s_cache) || ((fid->qid.version == 0) && !(s_flags & V9FS_IGNORE_QV)) || (s_flags & V9FS_DIRECT_IO) || (f_flags & O_DIRECT)) {