From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mail.toke.dk (Postfix) with ESMTPS id BEF749E6471 for ; Wed, 1 Feb 2023 19:13:04 +0100 (CET) Authentication-Results: mail.toke.dk; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=eGH2GV/N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675275183; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=aBiZv6kgolXZRi0uzRYeVBHuWMhXVUDzRvu/mO7RexM=; b=eGH2GV/NjaccfZDCJPHKEJlVgQ2XOYxfgTb+pasJT3Kdj5mUriewhi072XurhhEcuHGSLb RQPyZXqt1K9e5J9lzgMrVuIUINf00G/zXS+w8wDlvayzoL4s29DH6CO6NJcENWTCtALQcK 09SXRcxML5PCKIzU//Bg/0bNLVBbfsQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-114-0RFGbqu5NZOl6jNmgqUKWQ-1; Wed, 01 Feb 2023 13:12:57 -0500 X-MC-Unique: 0RFGbqu5NZOl6jNmgqUKWQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2BC2B855308; Wed, 1 Feb 2023 18:12:56 +0000 (UTC) Received: from firesoul.localdomain (ovpn-208-9.brq.redhat.com [10.40.208.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id D93A82026D4B; Wed, 1 Feb 2023 18:12:55 +0000 (UTC) Received: from [192.168.42.3] (localhost [IPv6:::1]) by firesoul.localdomain (Postfix) with ESMTP id B44AD300005EE; Wed, 1 Feb 2023 19:12:54 +0100 (CET) From: Jesper Dangaard Brouer To: bpf@vger.kernel.org, Stanislav Fomichev Date: Wed, 01 Feb 2023 19:12:54 +0100 Message-ID: <167527517464.938135.13750760520577765269.stgit@firesoul> User-Agent: StGit/1.4 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Message-ID-Hash: ND3LRQKRZNI5SVLIELOC6WT3EGKZQOIZ X-Message-ID-Hash: ND3LRQKRZNI5SVLIELOC6WT3EGKZQOIZ X-MailFrom: brouer@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Jesper Dangaard Brouer , netdev@vger.kernel.org, martin.lau@kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, dsahern@gmail.com, willemb@google.com, void@manifault.com, kuba@kernel.org, xdp-hints@xdp-project.net X-Mailman-Version: 3.3.8 Precedence: list Subject: [xdp-hints] [PATCH bpf-next V1] selftests/bpf: fix unmap bug in prog_tests/xdp_metadata.c List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The function close_xsk() unmap via munmap() the wrong memory pointer. The call xsk_umem__delete(xsk->umem) have already freed xsk->umem. Thus the call to munmap(xsk->umem, UMEM_SIZE) will have unpredictable behavior that can lead to Segmentation fault elsewhere, as man page explain subsequent references to these pages will generate SIGSEGV. Fixes: e2a46d54d7a1 ("selftests/bpf: Verify xdp_metadata xdp->af_xdp path") Reported-by: Martin KaFai Lau Signed-off-by: Jesper Dangaard Brouer --- .../selftests/bpf/prog_tests/xdp_metadata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c b/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c index e033d48288c0..241909d71c7e 100644 --- a/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c +++ b/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c @@ -121,7 +121,7 @@ static void close_xsk(struct xsk *xsk) xsk_umem__delete(xsk->umem); if (xsk->socket) xsk_socket__delete(xsk->socket); - munmap(xsk->umem, UMEM_SIZE); + munmap(xsk->umem_area, UMEM_SIZE); } static void ip_csum(struct iphdr *iph)