On Tue, May 19, 2020 at 7:38 AM Andrii Nakryiko <andriin@xxxxxx> wrote: > As discussed in [0], it's dangerous to allow mapping BPF map, that's meant to > be frozen and is read-only on BPF program side, because that allows user-space > to actually store a writable view to the page even after it is frozen. This is > exacerbated by BPF verifier making a strong assumption that contents of such > frozen map will remain unchanged. To prevent this, disallow mapping > BPF_F_RDONLY_PROG mmap()'able BPF maps as writable, ever. > > [0] https://lore.kernel.org/bpf/CAEf4BzYGWYhXdp6BJ7_=9OQPJxQpgug080MMjdSB72i9R+5c6g@xxxxxxxxxxxxxx/ > > Suggested-by: Jann Horn <jannh@xxxxxxxxxx> > Fixes: fc9702273e2e ("bpf: Add mmap() support for BPF_MAP_TYPE_ARRAY") > Signed-off-by: Andrii Nakryiko <andriin@xxxxxx> Reviewed-by: Jann Horn <jannh@xxxxxxxxxx>