linux-unionfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ovl: Fix info leak in ovl_lookup_temp()
@ 2016-09-16  9:45 Richard Weinberger
  2016-09-16 20:36 ` Kees Cook
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Weinberger @ 2016-09-16  9:45 UTC (permalink / raw)
  To: miklos; +Cc: linux-unionfs, linux-kernel, keescook, Richard Weinberger

The function uses the memory address of a struct dentry as unique id.
While the address-based directory entry is only visible to root
it is IMHO still worth fixing since the temporary name does not have
to be a kernel address. It can be any unique number. Replace it by an
atomic integer which is allowed to wrap around.

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 fs/overlayfs/dir.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 1560fdc..6e00a08 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -14,6 +14,7 @@
 #include <linux/cred.h>
 #include <linux/posix_acl.h>
 #include <linux/posix_acl_xattr.h>
+#include <linux/atomic.h>
 #include "overlayfs.h"
 
 void ovl_cleanup(struct inode *wdir, struct dentry *wdentry)
@@ -37,8 +38,9 @@ struct dentry *ovl_lookup_temp(struct dentry *workdir, struct dentry *dentry)
 {
 	struct dentry *temp;
 	char name[20];
+	static atomic_t temp_id = ATOMIC_INIT(0);
 
-	snprintf(name, sizeof(name), "#%lx", (unsigned long) dentry);
+	snprintf(name, sizeof(name), "#%x", atomic_inc_return(&temp_id));
 
 	temp = lookup_one_len(name, workdir, strlen(name));
 	if (!IS_ERR(temp) && temp->d_inode) {
-- 
2.7.3

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

end of thread, other threads:[~2016-09-21 14:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-16  9:45 [PATCH] ovl: Fix info leak in ovl_lookup_temp() Richard Weinberger
2016-09-16 20:36 ` Kees Cook
2016-09-21 14:38   ` Miklos Szeredi

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).