Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Harsh Shandilya <harsh@prjkt.io>
To: stable@vger.kernel.org
Cc: Theodore Ts'o <tytso@mit.edu>, Harsh Shandilya <harsh@prjkt.io>
Subject: [PATCH 4/4] ext4: force revalidation of directory pointer after seekdir(2)
Date: Sat, 21 Apr 2018 03:56:12 +0530	[thread overview]
Message-ID: <20180420222612.18881-5-harsh@prjkt.io> (raw)
In-Reply-To: <20180420222612.18881-1-harsh@prjkt.io>

From: Theodore Ts'o <tytso@mit.edu>

A malicious user could force the directory pointer to be in an invalid
spot by using seekdir(2).  Use the mechanism we already have to notice
if the directory has changed since the last time we called
ext4_readdir() to force a revalidation of the pointer.

Reported-by: syzbot+1236ce66f79263e8a862@syzkaller.appspotmail.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@vger.kernel.org

Signed-off-by: Harsh Shandilya <harsh@prjkt.io>
---
 fs/ext4/dir.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
index c24143ea9c08..99f72558b33a 100644
--- a/fs/ext4/dir.c
+++ b/fs/ext4/dir.c
@@ -320,13 +320,15 @@ static loff_t ext4_dir_llseek(struct file *file, loff_t offset, int whence)
 {
 	struct inode *inode = file->f_mapping->host;
 	int dx_dir = is_dx_dir(inode);
-	loff_t htree_max = ext4_get_htree_eof(file);
+	loff_t ret, htree_max = ext4_get_htree_eof(file);
 
 	if (likely(dx_dir))
-		return generic_file_llseek_size(file, offset, whence,
+		ret = generic_file_llseek_size(file, offset, whence,
 						    htree_max, htree_max);
 	else
-		return ext4_llseek(file, offset, whence);
+		ret = ext4_llseek(file, offset, whence);
+	file->f_version = inode_peek_iversion(inode) - 1;
+	return ret;
 }
 
 /*
-- 
2.15.0.2308.g658a28aa74af

  parent reply	other threads:[~2018-04-20 22:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-20 22:26 [PATCH 0/4] 4.17-rc1 stable tagged ext4 patches for 3.18.y Harsh Shandilya
2018-04-20 22:26 ` [PATCH 1/4] ext4: add validity checks for bitmap block numbers Harsh Shandilya
2018-04-21 12:28   ` [PATCH 1/3] " Harsh Shandilya
2018-04-20 22:26 ` [PATCH 2/4] ext4: fail ext4_iget for root directory if unallocated Harsh Shandilya
2018-04-21 12:28   ` [PATCH 2/3] " Harsh Shandilya
2018-04-20 22:26 ` [PATCH 3/4] ext4: don't allow r/w mounts if metadata blocks overlap the superblock Harsh Shandilya
2018-04-21 12:29   ` [PATCH 3/3] " Harsh Shandilya
2018-04-21 20:07     ` Theodore Y. Ts'o
2018-04-22  2:30       ` Harsh Shandilya
2018-04-22  4:01         ` Theodore Y. Ts'o
2018-04-22  4:04           ` Harsh Shandilya
2018-04-20 22:26 ` Harsh Shandilya [this message]
2018-04-20 23:23 ` [PATCH 0/4] 4.17-rc1 stable tagged ext4 patches for 3.18.y Harsh Shandilya
2018-04-21 12:21 ` [PATCH 0/3] " Harsh Shandilya

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180420222612.18881-5-harsh@prjkt.io \
    --to=harsh@prjkt.io \
    --cc=stable@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox