linux-unionfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ovl: null dereference possibility fixup
@ 2020-06-21 12:27 youngjun
  2020-06-21 13:36 ` Amir Goldstein
  0 siblings, 1 reply; 2+ messages in thread
From: youngjun @ 2020-06-21 12:27 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: linux-unionfs, youngjun

lowerdentry could be NULL, and dereferenced by calling d_inode.
code flow which described below
shows possibility of null dereference in ovl_get_inode.

(export.c) ovl_lower_fh_to_d
|_(export.c) ovl_get_dentry(sb, upper, NULL, NULL);
 |_(export.c) ovl_obtain_alias (sb, upper, NULL, NULL);
  |_(inode.c) ovl_get_inode(sb, &oip);
   |_(in ovl_get_inode) realinode = d_inode(lowerdentry);

Fixes: 09d8b586731bf("ovl: move __upperdentry to ovl_inode")
Signed-off-by: youngjun <her0gyugyu@gmail.com>
---
 fs/overlayfs/inode.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 8be6cd264f66..53d82ef68ba8 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -958,8 +958,10 @@ struct inode *ovl_get_inode(struct super_block *sb,
 	unsigned long ino = 0;
 	int err = oip->newinode ? -EEXIST : -ENOMEM;
 
-	if (!realinode)
+	if (!realinode && lowerdentry)
 		realinode = d_inode(lowerdentry);
+	else
+		return ERR_PTR(-EINVAL);
 
 	/*
 	 * Copy up origin (lower) may exist for non-indexed upper, but we must
-- 
2.17.1


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

end of thread, other threads:[~2020-06-21 13:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-21 12:27 [PATCH] ovl: null dereference possibility fixup youngjun
2020-06-21 13:36 ` Amir Goldstein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).