lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221017192006.36398-3-saeed.mirzamohammadi@oracle.com>
Date:   Mon, 17 Oct 2022 12:20:03 -0700
From:   Saeed Mirzamohammadi <saeed.mirzamohammadi@...cle.com>
To:     unlisted-recipients:; (no To-header on input)
Cc:     linux-fsdevel@...r.kernel.org, viro@...iv.linux.org.uk,
        linux-kernel@...r.kernel.org, stable@...r.kernel.org,
        jason@...c4.com, saeed.mirzamohammadi@...cle.com,
        "Jason A. Donenfeld" <Jason@...c4.com>
Subject: [PATCH stable 2/5] fs: do not compare against ->llseek

From: "Jason A. Donenfeld" <Jason@...c4.com>

Now vfs_llseek() can simply check for FMODE_LSEEK; if it's set,
we know that ->llseek() won't be NULL and if it's not we should
just fail with -ESPIPE.

A couple of other places where we used to check for special
values of ->llseek() (somewhat inconsistently) switched to
checking FMODE_LSEEK.

Signed-off-by: Jason A. Donenfeld <Jason@...c4.com>
Signed-off-by: Al Viro <viro@...iv.linux.org.uk>
(cherry picked from commit 4e3299eaddffd9d7d5b8bae28ad700bb775f02d0)
Cc: stable@...r.kernel.org
Signed-off-by: Saeed Mirzamohammadi <saeed.mirzamohammadi@...cle.com>
---
 fs/coredump.c          |  4 ++--
 fs/overlayfs/copy_up.c |  3 +--
 fs/read_write.c        | 11 +++--------
 3 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/fs/coredump.c b/fs/coredump.c
index 26eb5a095832..04ce02e30e23 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -886,9 +886,9 @@ static int __dump_skip(struct coredump_params *cprm, size_t nr)
 {
 	static char zeroes[PAGE_SIZE];
 	struct file *file = cprm->file;
-	if (file->f_op->llseek && file->f_op->llseek != no_llseek) {
+	if (file->f_mode & FMODE_LSEEK) {
 		if (dump_interrupted() ||
-		    file->f_op->llseek(file, nr, SEEK_CUR) < 0)
+		    vfs_llseek(file, nr, SEEK_CUR) < 0)
 			return 0;
 		cprm->pos += nr;
 		return 1;
diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index e040970408d4..7636ec4d8b1c 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -226,8 +226,7 @@ static int ovl_copy_up_data(struct ovl_fs *ofs, struct path *old,
 	/* Couldn't clone, so now we try to copy the data */
 
 	/* Check if lower fs supports seek operation */
-	if (old_file->f_mode & FMODE_LSEEK &&
-	    old_file->f_op->llseek)
+	if (old_file->f_mode & FMODE_LSEEK)
 		skip_hole = true;
 
 	while (len) {
diff --git a/fs/read_write.c b/fs/read_write.c
index 8d3ec975514d..b64527211b32 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -290,14 +290,9 @@ EXPORT_SYMBOL(default_llseek);
 
 loff_t vfs_llseek(struct file *file, loff_t offset, int whence)
 {
-	loff_t (*fn)(struct file *, loff_t, int);
-
-	fn = no_llseek;
-	if (file->f_mode & FMODE_LSEEK) {
-		if (file->f_op->llseek)
-			fn = file->f_op->llseek;
-	}
-	return fn(file, offset, whence);
+	if (!(file->f_mode & FMODE_LSEEK))
+		return -ESPIPE;
+	return file->f_op->llseek(file, offset, whence);
 }
 EXPORT_SYMBOL(vfs_llseek);
 
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ