Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp23199pxa; Mon, 10 Aug 2020 17:27:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzh83i3/9A/jDVLe6rabZVBVcZwZbXTyHWNkQx6C4DLr+ptRXpspEU89Y2hPwJUfnUKnxAF X-Received: by 2002:a05:6402:68b:: with SMTP id f11mr24379367edy.353.1597105670651; Mon, 10 Aug 2020 17:27:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597105670; cv=none; d=google.com; s=arc-20160816; b=dt3rDD+W9Htkuo0rDgQyTpxI+yt7M/waw+3gP2NoNZrhCRyN6/Rq42SkGxHM8VFKET lEnjqwudpFPA6/9907/nLIzNP/kYWrv8diuuvWxKjYpl6E26jZO2KmITHHF9cf/tU3j5 MtCu1SM7CqsgFBP9rPX4VVN16kkw6z5hr2nJWyBlTDoSQeGvvdMXasBsom6QObSO0Hhd bg+T8Gv+hbq5gMpw6nDOlmelobu1Vr7fagNe9z+jNd046ORNV+DUlDJd0sFrjikh8bai bl59Ec4h+ZigA0jMZlV9UJLC9vzf9BwrQ3J6bsiFofAUuiRjIHZoPtSOOOWJoDoZom7o 3MbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Ca9q074Qlxhxt0Jwpd7kmjuPwS3utHOAz98pmV2gWBw=; b=CE5uSi8AYzC3sW/ZCm3Fs2N18w3nKlETWYhgu5hVYlNTkO7898rYORTQCibzWEe+eh ktZynRadDrn6fVTxBJcNSMhaKXd/7M87wALivd0qWCade4cH0c3AJpVfGCJoiv8TqXSS a2/gFRZMOeEHKIo//wSi3Vde3SiJ1ex6XhVb1Z7+gJjSVfFCY5CQQ1Sz26GUPvYp5wMs f1MpHt1/JlWGZE4I4dMvwtwydEtAKui1vONN/h67Zexo3X9UqyUQmlxqdoswvY2z9uMD Uyua97I+PoZ7WJ/082xT8P5neVkfdBXxdwmBM55C6dA4qggimx1K92p3+FgbCYYTK1oX VdFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kbWoWtvq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o12si11422766edr.362.2020.08.10.17.27.27; Mon, 10 Aug 2020 17:27:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kbWoWtvq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728121AbgHKAYL (ORCPT + 99 others); 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-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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) > [...]