Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp416486pxa; Tue, 11 Aug 2020 06:23:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzK+5mmSqfwk8fqmfpgnHvjN7esPWSGw0KHzB47t4LNe+Enc02B9H7r988lhYmd3r6uIAN2 X-Received: by 2002:aa7:dd15:: with SMTP id i21mr26238815edv.153.1597152238386; Tue, 11 Aug 2020 06:23:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597152238; cv=none; d=google.com; s=arc-20160816; b=XrPEVP/6p8XBJfqmaCkem6RDvsYWwTzFq4sH4Q+ss2PZw2AI8OID5iBBMJ6DzKOpUJ ti6aYsG2tioysFy3rtIyOmy0ZtSxdzAo8m6XDWzHSWUGjibcbaTYZGFD4Y6Y+Nn+zC0l fTPJh5L4tviZ6mb/y++aokdC3/lZRPOghsfEExH2cpcXpiRoYURdnNvGTTN11dOnbGQ1 tPS7dJciuzfAvCUA8oal5iy9hBs4xXtW5nNfu2yZNM25uik/gLTND0t+GJC3A2LrT6zJ oJnxO4BPCe3tWidLIMBmTb9lbe3EFLLC/yPzdReDQyD25SyLJWC6CEBpg+fxAlxnhab5 r4YQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=FljVWC1dsqdl5dX3vB8HhrbuBbWd424hxFpcSPVpc2Q=; b=ViHCF4/aTMfvyV1LsPtzrgVxWt24H0yh+F9EguUDhiyRpvV8JiEyKuOGQkaqBPxm7H 4G8s0AzOLWM+WnrM0D0kVnSbynYRph2BrLWh+Y1GE9+11XGi9VztJJP0pzR+Ua9CVesr RItud/Muy2IQvRLI+67kYx5GT3mekC9hgUKRjZlPJtf7Jfik65gjMgcLxNBeOLiie/h+ UzzKaholWnBjhbmt/Z66j0nvQzuG4boQVWFziEmdV3VQooDgEP1AsQdPWlr7Rv5mjmzj NB2g+uTt+Xe51jakeZ+nTipLOn+jLtZJDoflvAs6XV291Sg9RI+qcn89slyts2youH5t FLww== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bi17si10424991edb.75.2020.08.11.06.23.34; Tue, 11 Aug 2020 06:23:58 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728705AbgHKNUM (ORCPT + 99 others); Tue, 11 Aug 2020 09:20:12 -0400 Received: from www62.your-server.de ([213.133.104.62]:59496 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728516AbgHKNUM (ORCPT ); Tue, 11 Aug 2020 09:20:12 -0400 Received: from sslproxy05.your-server.de ([78.46.172.2]) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1k5UC8-0004uL-KX; Tue, 11 Aug 2020 15:20:00 +0200 Received: from [178.196.57.75] (helo=pc-9.home) by sslproxy05.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k5UC8-000Bp1-Dr; Tue, 11 Aug 2020 15:20:00 +0200 Subject: Re: [PATCH bpf-next v2] bpf: fix segmentation fault of test_progs To: Jianlin Lv , bpf@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, ast@kernel.org, yhs@fb.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org References: <20200807172016.150952-1-Jianlin.Lv@arm.com> <20200810153940.125508-1-Jianlin.Lv@arm.com> From: Daniel Borkmann Message-ID: <066bc6b8-8e08-e473-b454-4544e99ad7e0@iogearbox.net> Date: Tue, 11 Aug 2020 15:19:59 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20200810153940.125508-1-Jianlin.Lv@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.102.4/25900/Mon Aug 10 14:44:29 2020) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/10/20 5:39 PM, 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 Applied, thanks!