lists.openwall.net   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  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:   Thu, 17 Dec 2020 21:23:56 -0800
From:   Alexei Starovoitov <alexei.starovoitov@...il.com>
To:     Song Liu <songliubraving@...com>
Cc:     "bpf@...r.kernel.org" <bpf@...r.kernel.org>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "ast@...nel.org" <ast@...nel.org>,
        "daniel@...earbox.net" <daniel@...earbox.net>,
        "andrii@...nel.org" <andrii@...nel.org>,
        "john.fastabend@...il.com" <john.fastabend@...il.com>,
        "kpsingh@...omium.org" <kpsingh@...omium.org>,
        Kernel Team <Kernel-team@...com>
Subject: Re: [PATCH v2 bpf-next 1/4] bpf: introduce task_vma bpf_iter

On Thu, Dec 17, 2020 at 8:33 PM Song Liu <songliubraving@...com> wrote:
> >
> > ahh. I missed that. Makes sense.
> > vm_file needs to be accurate, but vm_area_struct should be accessed as ptr_to_btf_id.
>
> Passing pointer of vm_area_struct into BPF will be tricky. For example, shall we
> allow the user to access vma->vm_file? IIUC, with ptr_to_btf_id the verifier will
> allow access of vma->vm_file as a valid pointer to struct file. However, since the
> vma might be freed, vma->vm_file could point to random data.

I don't think so. The proposed patch will do get_file() on it.
There is actually no need to assign it into a different variable.
Accessing it via vma->vm_file is safe and cleaner.

> >> [1] ff9f47f6f00c ("mm: proc: smaps_rollup: do not stall write attempts on mmap_lock")
> >
> > Thanks for this link. With "if (mmap_lock_is_contended())" check it should work indeed.
>
> To make sure we are on the same page: I am using slightly different mechanism in
> task_vma_iter, which doesn't require checking mmap_lock_is_contended(). In the
> smaps_rollup case, the code only unlock mmap_sem when the lock is contended. In
> task_iter, we always unlock mmap_sem between two iterations. This is because we
> don't want to hold mmap_sem while calling the BPF program, which may sleep (calling
> bpf_d_path).

That part is clear. I had to look into mmap_read_lock_killable() implementation
to realize that it's checking for lock_is_contended after acquiring
and releasing
if there is a contention. So it's the same behavior at the end.

Powered by blists - more mailing lists