[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGXu5j+9ozB07MMtwZjL6ATtSFyvawX0pM4K0S4h1A6L8+uarA@mail.gmail.com>
Date: Fri, 16 Sep 2016 13:36:09 -0700
From: Kees Cook <keescook@...omium.org>
To: Richard Weinberger <richard@....at>
Cc: Miklos Szeredi <miklos@...redi.hu>, linux-unionfs@...r.kernel.org,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] ovl: Fix info leak in ovl_lookup_temp()
On Fri, Sep 16, 2016 at 2:45 AM, Richard Weinberger <richard@....at> wrote:
> 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@....at>
Nice catch!
Reviewed-by: Kees Cook <keescook@...omium.org>
We'll have to remember this for when atomic_t wrap checking gets added
to mark this as "intended to wrap".
Thanks,
-Kees
> ---
> 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
>
--
Kees Cook
Nexus Security
Powered by blists - more mailing lists