Re: [PATCH bpf-next v9 7/8] bpf: lsm: Add selftests for BPF_PROG_TYPE_LSM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 2, 2020 at 4:39 PM Jann Horn <jannh@xxxxxxxxxx> wrote:
>
> On Thu, Apr 2, 2020 at 1:53 PM KP Singh <kpsingh@xxxxxxxxxxxx> wrote:
> > On 02-Apr 07:15, Jann Horn wrote:
> [...]
> > > I suspect that you're using different versions of libc, or something's
> > > different in the memory layout, or something like that. The brk region
> > > is used for memory allocations using brk(), but memory allocations
> > > using mmap() land outside it. At least some versions of libc try to
> > > allocate memory for malloc() with brk(), then fall back to mmap() if
> > > that fails because there's something else behind the current end of
> > > the brk region; but I think there might also be versions of libc that
> > > directly use mmap() and don't even try to use brk().
> >
> > Yeah missed this that heap can also be allocated using mmap:
> [...]
> > I updated my test case to check for mmaps on the stack instead:
> [...]
> > +       is_stack = (vma->vm_start <= vma->vm_mm->start_stack &&
> > +                   vma->vm_end >= vma->vm_mm->start_stack);
> >
> > -       if (is_heap && monitored_pid == pid) {
> > +       if (is_stack && monitored_pid == pid) {
> >                 mprotect_count++;
> >                 ret = -EPERM;
> >         }
> >
> > and the the logic seems to work for me. Do you think we could use
> > this instead?
>
> Yeah, I think that should work. (Just keep in mind that a successful
> mprotect() operation will split the VMA into three VMAs - but that
> shouldn't be a problem here, since you only do it once per process,
> and since you're denying the operation, it won't go through anyway.)

Okay I will send a patch that fixes this test. Thanks everyone!

- KP



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux