From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BAC4AC433E0 for ; Tue, 11 Aug 2020 00:24:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 936AA20734 for ; Tue, 11 Aug 2020 00:24:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kbWoWtvq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728129AbgHKAYL (ORCPT ); Mon, 10 Aug 2020 20:24:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725969AbgHKAYL (ORCPT ); Mon, 10 Aug 2020 20:24:11 -0400 Received: from mail-yb1-xb42.google.com (mail-yb1-xb42.google.com [IPv6:2607:f8b0:4864:20::b42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 143BFC06174A; Mon, 10 Aug 2020 17:24:11 -0700 (PDT) Received: by mail-yb1-xb42.google.com with SMTP id x10so6095047ybj.13; Mon, 10 Aug 2020 17:24:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Ca9q074Qlxhxt0Jwpd7kmjuPwS3utHOAz98pmV2gWBw=; b=kbWoWtvqq93GLzHIaqR7TuBaSEebZpq0IjeF+lXhxObaNPwapq4KaJK1fDzSakOPMR O9CD3R6bHSJxkj22koO8hCQy0IVNBMCyAP8WEt5QFmVEf1K48IOKOzdsiSAj9ZD3I6kj YI62xvIovfi3sSbT/VU2vjKC53Xzw7iQbc5rHwM8J/4SvFYMLGCVXZoaeINO4RoMp+Bx 4ItrZ1c7VFWhpC9d2YVdDn10KsfqRTtaJ/Tz3H1sXd8l6tGpQAWOvtAf6ls3wSnAflut 5zgmkCtUhdC/9lGuanSjgQWXvVTHdzjpbOCOMWR+t+CIlZe1WLuMjahy0pGK9Qchh6L1 y7vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Ca9q074Qlxhxt0Jwpd7kmjuPwS3utHOAz98pmV2gWBw=; b=cBZy4k4Dwr5YqEb0NzAImZ/2Fp7VXMUJhA3gH+T+cs8t0CDJnkXbGDqp63D8yH7nuE 4BQ+PuZvAZQkb1sw9gcH+cZQ8SZzPX9Z98jCj56Xw6DlHWZPtX/KBe4yMsEhWdaFtzDf Pi3Z+hRIh+RS9oBVOocb+eEEim1/hq8hfsIiQSb+KPTCXMClwM0ylbPrkzdFgCn7G7/N SxLFYRmY81r2Zo//NsnIvuyxLlbcZ+lFtZuZab5x9PdSqApz61/VSlmeSdu2FdWOH5e9 99YCz6a4Rt0YEobKKLT8D/htOmtAw0oGsUiJuopcoR2SeLcsh1zn1phbkFjzFPVFKXsk j+nw== X-Gm-Message-State: AOAM530VnXjd3Z6I9B9u7oaxqjRuTXlMts9fO4ztWND6PMaMKfFqEyGv TNk8r7n2nUBSJRuNxkDYm30ySw8tD9En2XlD7s0= X-Google-Smtp-Source: ABdhPJwTfsnLFwZLuC3suF9ncPk3LSJXppF8IcN/EC0+7l4ACCVMuQCqX2CPRNWRF48JbUQWtbWJ5zlK9ptjIHSwub0= X-Received: by 2002:a25:2ad3:: with SMTP id q202mr42541149ybq.27.1597105450335; Mon, 10 Aug 2020 17:24:10 -0700 (PDT) MIME-Version: 1.0 References: <20200807172016.150952-1-Jianlin.Lv@arm.com> <20200810153940.125508-1-Jianlin.Lv@arm.com> In-Reply-To: <20200810153940.125508-1-Jianlin.Lv@arm.com> From: Andrii Nakryiko Date: Mon, 10 Aug 2020 17:23:59 -0700 Message-ID: Subject: Re: [PATCH bpf-next v2] bpf: fix segmentation fault of test_progs To: Jianlin Lv Cc: bpf , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Yonghong Song , open list , Networking Content-Type: text/plain; charset="UTF-8" Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Mon, Aug 10, 2020 at 8:40 AM Jianlin Lv 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 > --- LGTM, thanks for the fix! Acked-by: Andrii Nakryiko > 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(-) > [...]