public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] stat: don't fail if the major number is >= 256
@ 2022-04-11 14:43 Mikulas Patocka
  2022-04-11 15:03 ` Matthew Wilcox
  2022-04-11 16:30 ` Linus Torvalds
  0 siblings, 2 replies; 15+ messages in thread
From: Mikulas Patocka @ 2022-04-11 14:43 UTC (permalink / raw)
  To: Linus Torvalds, Alexander Viro; +Cc: linux-fsdevel, linux-kernel

If you run a program compiled with OpenWatcom for Linux on a filesystem on 
NVMe, all "stat" syscalls fail with -EOVERFLOW. The reason is that the 
NVMe driver allocates a device with the major number 259 and it doesn't 
pass the "old_valid_dev" test.

This patch removes the tests - it's better to wrap around than to return
an error. (note that cp_old_stat also doesn't report an error and wraps
the number around)

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

---
 fs/stat.c |    6 ------
 1 file changed, 6 deletions(-)

Index: linux-5.17.2/fs/stat.c
===================================================================
--- linux-5.17.2.orig/fs/stat.c	2022-04-10 21:39:27.000000000 +0200
+++ linux-5.17.2/fs/stat.c	2022-04-10 21:42:43.000000000 +0200
@@ -334,7 +334,6 @@ SYSCALL_DEFINE2(fstat, unsigned int, fd,
 #  define choose_32_64(a,b) b
 #endif
 
-#define valid_dev(x)  choose_32_64(old_valid_dev(x),true)
 #define encode_dev(x) choose_32_64(old_encode_dev,new_encode_dev)(x)
 
 #ifndef INIT_STRUCT_STAT_PADDING
@@ -345,8 +344,6 @@ static int cp_new_stat(struct kstat *sta
 {
 	struct stat tmp;
 
-	if (!valid_dev(stat->dev) || !valid_dev(stat->rdev))
-		return -EOVERFLOW;
 #if BITS_PER_LONG == 32
 	if (stat->size > MAX_NON_LFS)
 		return -EOVERFLOW;
@@ -644,9 +641,6 @@ static int cp_compat_stat(struct kstat *
 {
 	struct compat_stat tmp;
 
-	if (!old_valid_dev(stat->dev) || !old_valid_dev(stat->rdev))
-		return -EOVERFLOW;
-
 	memset(&tmp, 0, sizeof(tmp));
 	tmp.st_dev = old_encode_dev(stat->dev);
 	tmp.st_ino = stat->ino;


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2022-04-12 23:41 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-11 14:43 [PATCH] stat: don't fail if the major number is >= 256 Mikulas Patocka
2022-04-11 15:03 ` Matthew Wilcox
2022-04-11 15:16   ` Christoph Hellwig
2022-04-11 16:30 ` Linus Torvalds
2022-04-11 17:13   ` Mikulas Patocka
2022-04-12  5:37     ` Linus Torvalds
2022-04-12  5:41       ` Christoph Hellwig
2022-04-12  5:47         ` Linus Torvalds
2022-04-12  5:52           ` Christoph Hellwig
2022-04-12  6:49       ` Linus Torvalds
2022-04-12  8:19       ` Andreas Schwab
2022-04-12  9:41       ` [PATCH] stat: fix inconsistency between struct stat and struct compat_stat Mikulas Patocka
2022-04-12 16:30         ` Linus Torvalds
2022-04-12 17:42           ` Mikulas Patocka
2022-04-12 23:25             ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox