Re: ima_mmap_file returning 0 to userspace as mmap result.

From: Dave Jones
Date: Thu Jun 05 2014 - 12:21:27 EST


On Thu, Jun 05, 2014 at 11:56:58AM -0400, Dave Jones wrote:
> On Thu, Jun 05, 2014 at 06:40:36AM +0200, Michael Kerrisk (man-pages) wrote:
> > On 06/05/2014 01:31 AM, Dave Jones wrote:
> > > I just noticed that trinity was freaking out in places when mmap was
> > > returning zero. This surprised me, because I had the mmap_min_addr
> > > sysctl set to 64k, so it wasn't a MAP_FIXED mapping that did it.
> > >
> > > There's no mention of this return value in the man page, so I dug
> > > into the kernel code, and it appears that we do..
> > >
> > > sys_mmap
> > > vm_mmap_pgoff
> > > security_mmap_file
> > > ima_file_mmap <- returns 0 if not PROT_EXEC
> > >
> > > and then the 0 gets propagated up as a retval all the way to userspace.
>
> I just realised that this affects even kernels with CONFIG_IMA unset,
> because there we just do 'return 0' unconditionally.
>
> Also, it appears that kernels with CONFIG_SECURITY unset will also
> return a zero for the same reason.

Hang on, I was misreading that whole security_mmap_file ret handling code.
There's something else at work here. I'll dig and get a reproducer.

Dave

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/