lkml.org 
[lkml]   [2020]   [Aug]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH bpf-next v2] bpf: fix segmentation fault of test_progs
On Mon, Aug 10, 2020 at 8:40 AM Jianlin Lv <Jianlin.Lv@arm.com> wrote:
>
> test_progs reports the segmentation fault as below
>
> $ sudo ./test_progs -t mmap --verbose
> test_mmap:PASS:skel_open_and_load 0 nsec
> ......
> test_mmap:PASS:adv_mmap1 0 nsec
> test_mmap:PASS:adv_mmap2 0 nsec
> test_mmap:PASS:adv_mmap3 0 nsec
> test_mmap:PASS:adv_mmap4 0 nsec
> Segmentation fault
>
> This issue was triggered because mmap() and munmap() used inconsistent
> length parameters; mmap() creates a new mapping of 3*page_size, but the
> length parameter set in the subsequent re-map and munmap() functions is
> 4*page_size; this leads to the destruction of the process space.
>
> To fix this issue, first create 4 pages of anonymous mapping,then do all
> the mmap() with MAP_FIXED.
>
> Another issue is that when unmap the second page fails, the length
> parameter to delete tmp1 mappings should be 4*page_size.
>
> Signed-off-by: Jianlin Lv <Jianlin.Lv@arm.com>
> ---

LGTM, thanks for the fix!

Acked-by: Andrii Nakryiko <andriin@fb.com>

> v2:
> - Update commit messages
> - Create 4 pages of anonymous mapping that serve the subsequent mmap()
> ---
> tools/testing/selftests/bpf/prog_tests/mmap.c | 19 +++++++++++++------
> 1 file changed, 13 insertions(+), 6 deletions(-)
>

[...]

\
 
 \ /
  Last update: 2020-08-11 02:24    [W:0.665 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site