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]
Date:   Mon, 12 Dec 2022 08:23:31 -0800
From:   Nhat Pham <>
To:     Al Viro <>
Subject: Re: [PATCH v2 3/4] cachestat: implement cachestat syscall

On Sat, Dec 10, 2022 at 3:51 PM Al Viro <> wrote:
> On Mon, Dec 05, 2022 at 09:51:39AM -0800, Nhat Pham wrote:
> > +     if (!access_ok(cstat, sizeof(struct cachestat)))
> > +             return -EFAULT;
> What for?  You are using copy_to_user() later, right?

Oh I didn't realize copy_to_user() would suffice - mincore also
has this check:

if (!access_ok(vec, pages))
       return -EFAULT;

(even though it also has a similar check with copy_to_user),
so I just erred on the side of safety and included it. If this is
redundant, I'll just remove it from the next version.

> > +     f = fdget(fd);
> > +     if (f.file) {
> It would be easier to read if you inverted the condition here.

Oh I think I tried

if (!f.file)
       return -EBADF;

here, but there are some mixing-code-with-decl warnings.
If I recall correctly, the problem is with this line:

XA_STATE(xas, &mapping->i_pages, first_index);

which is expanded into a declaration:

#define XA_STATE(name, array, index) \
struct xa_state name = __XA_STATE(array, index, 0, 0)

It requires a valid mapping though, which is
obtained from f.file:

struct address_space *mapping = f.file->f_mapping;

so it cannot be moved above the if(!f.file) check either...

Powered by blists - more mailing lists