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: <20100906005028.20775.2233.stgit@localhost.localdomain>
Date:	Mon, 06 Sep 2010 10:50:29 +1000
From:	NeilBrown <neilb@...e.de>
To:	Miklos Szeredi <miklos@...redi.hu>
Cc:	linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 04/10] ovl: initialise is_real before use.

The previous patch can use od->is_real before it is properly
initialised is llseek is called before readdir.
So factor out the initialisation of is_real and call it from both
readdir and llseek when f_pos is 0.

Signed-off-by: NeilBrown <neilb@...e.de>
---
 fs/overlayfs/overlayfs.c |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/fs/overlayfs/overlayfs.c b/fs/overlayfs/overlayfs.c
index 306de45..de854e1 100644
--- a/fs/overlayfs/overlayfs.c
+++ b/fs/overlayfs/overlayfs.c
@@ -240,6 +240,17 @@ static int ovl_fill_cache(struct path *realpath, struct ovl_cache_callback *cb,
 	return 0;
 }
 
+static void ovl_dir_reset(struct file *file)
+{
+	struct ovl_dir_file *od = file->private_data;
+	struct ovl_entry *ue = file->f_path.dentry->d_fsdata;
+
+	ovl_cache_free(od->cache);
+	od->cache = NULL;
+
+	od->is_real = (!ue->lowerpath.dentry || !ue->upperpath.dentry);
+}
+
 static int ovl_readdir(struct file *file, void *buf, filldir_t filler)
 {
 	struct ovl_dir_file *od = file->private_data;
@@ -248,14 +259,10 @@ static int ovl_readdir(struct file *file, void *buf, filldir_t filler)
 	loff_t off;
 	int res = 0;
 
-	if (!file->f_pos) {
-		ovl_cache_free(od->cache);
-		od->cache = NULL;
-		od->is_real = false;
-	}
+	if (!file->f_pos)
+		ovl_dir_reset(file);
 
-	if (od->is_real || !ue->lowerpath.dentry || !ue->upperpath.dentry) {
-		od->is_real = true;
+	if (od->is_real) {
 		res = vfs_readdir(od->realfile, filler, buf);
 		file->f_pos = od->realfile->f_pos;
 
@@ -307,6 +314,9 @@ static loff_t ovl_dir_llseek(struct file *file, loff_t offset, int origin)
 	loff_t res;
 	struct ovl_dir_file *od = file->private_data;
 
+	if (!file->f_pos)
+		ovl_dir_reset(file);
+
 	if (od->is_real) {
 		res = vfs_llseek(od->realfile, offset, origin);
 		file->f_pos = od->realfile->f_pos;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ