Re: [RFC PATCH] asm/generic: introduce if_nospec and nospec_barrier

From: Alexey Dobriyan
Date: Fri Jan 05 2018 - 05:33:57 EST


Al Viro wrote:
> > > No, the concern is that an fd value >= fdt->max_fds may cause the cpu
> > > to read arbitrary memory addresses relative to files->fdt and
> > > userspace can observe that it got loaded.
> >
> > Yes. And all that might reveal is the value of files->fdt. Who cares?
>
> Sorry, s/files->fdt/files->fdt->fd/. Still the same question - what information
> would that extract and how would attacker use that?

Al, paper exploit requires second data dependent load but they only do it
for easy demonstration.

struct file *file = (fd < fdt->max_fds) ? fdt->fd[fd] : NULL;
if (file && (file->f_mode & mask))
...

Speculative "struct file *" can be anything.
If ->f_mode access happens cacheline will be primed.
If pointer is userspace address nothing will happen because of SMAP.

Now you know that some data past fdtable looks like canonical kernel
address.