Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp801245pxa; Wed, 5 Aug 2020 13:07:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAlV6PrHJYph0jVfFOaVPS7c8fJdt72m5xijDnmNgeK5PV+cp5wXDyeIkcJOVowWnep9CZ X-Received: by 2002:a17:906:2f07:: with SMTP id v7mr1007689eji.313.1596658032637; Wed, 05 Aug 2020 13:07:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596658032; cv=none; d=google.com; s=arc-20160816; b=aM4VXB0OhQrPYyGGkpKTG3qvSuHeXYTJ4OYCbGKT6w1D3vH9keKedPI7dP/ggjUakt MEKhl158CcaJ1jlC6J3/YpaE9ljkG8gaB1P8Jbn6XFh+8EdOWmFqXaS5Nde4mDjZCbyT anBFZu7mwvGv3O2X8QcOuwg6Se7ecSDc/gJOi2hh/RbY12kT/4+Z4v9MWbrTIAVnpWFJ UR24I72ni57kmDDEu8NC4Jj9grxbwCEkUv8dAS0fd1nsg8knIGJRiDWuMN9UTXWDfFt7 AeSS/CoOQeE8QJAvLL+ska+9kS2qa2HAhswQYBwcOKgz9tYRz6gNsC9XeWCt8oj/13s2 JXoQ== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/g02GwBZHNikZEg7D0oN2wB5Et9ujmi97KFZBcn93zY=; b=aZLar5Byb8OOJRmxo9UmE6MGDriiB2iuRnp5DEvXGafrMm+caA436e1RwzFKz7BvsF IbNqhAQqMAWDxdA/ZhhZUkLMTrzqnFJWnPmpZ4oO14HUXHVKuS2YB1N4cvn7iIxcUg30 gtSCNkT68zwCVF/3BwNBXJ1Va+orW2PspF75XOOsE5/TlUDSJsOZO9OEw2Bc4EUNw+JZ JmbJBLeordl8+C7ZYBdOQAHaCz89/AFqat4RK3T3xDsbZd2jgJTWVD4b+ECy0pw6olFM axmTULbEM6gUPmnLgBW6tW2uFWaY5jpdlHxK5IQ2b8Bqwg28Tia1I29uyw3YLxpdtmCE YdMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gg+itV+r; 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 d11si1741592edh.571.2020.08.05.13.06.49; Wed, 05 Aug 2020 13:07:12 -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=@kernel.org header.s=default header.b=gg+itV+r; 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 S1729753AbgHEUGc (ORCPT + 99 others); Wed, 5 Aug 2020 16:06:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:49790 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726987AbgHEQel (ORCPT ); Wed, 5 Aug 2020 12:34:41 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D6BF823382; Wed, 5 Aug 2020 15:52:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596642779; bh=POF6DDiHm8atPTslFXz0sLdllxBBkRKfAFe2q0FnobE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gg+itV+r90Y6NJdDD0QLTkJ1Kak0FRXZ1l7TGvxe1R8a9uw9RgtkSHAPofHqaJw/Y 1kfFJYrMLT50fYMskW4NFimBq87Cw1pu+F4LC7g7AYzxmbGq/dzaG39dOw2fBK0ZxZ 0/Hc0BV0vhJVkOApRnPkaVwf8x0y2Q6nM4bXMomU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin KaFai Lau , Lorenz Bauer , Daniel Borkmann , Jakub Sitnicki Subject: [PATCH 5.4 8/9] selftests: bpf: Fix detach from sockmap tests Date: Wed, 5 Aug 2020 17:52:45 +0200 Message-Id: <20200805153507.423308944@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200805153507.053638231@linuxfoundation.org> References: <20200805153507.053638231@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lorenz Bauer commit f43cb0d672aa8eb09bfdb779de5900c040487d1d upstream. Fix sockmap tests which rely on old bpf_prog_dispatch behaviour. In the first case, the tests check that detaching without giving a program succeeds. Since these are not the desired semantics, invert the condition. In the second case, the clean up code doesn't supply the necessary program fds. Fixes: bb0de3131f4c ("bpf: sockmap: Require attach_bpf_fd when detaching a program") Reported-by: Martin KaFai Lau Signed-off-by: Lorenz Bauer Signed-off-by: Daniel Borkmann Reviewed-by: Jakub Sitnicki Link: https://lore.kernel.org/bpf/20200709115151.75829-1-lmb@cloudflare.com Signed-off-by: Greg Kroah-Hartman --- tools/testing/selftests/bpf/test_maps.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/tools/testing/selftests/bpf/test_maps.c +++ b/tools/testing/selftests/bpf/test_maps.c @@ -793,19 +793,19 @@ static void test_sockmap(unsigned int ta } err = bpf_prog_detach(fd, BPF_SK_SKB_STREAM_PARSER); - if (err) { + if (!err) { printf("Failed empty parser prog detach\n"); goto out_sockmap; } err = bpf_prog_detach(fd, BPF_SK_SKB_STREAM_VERDICT); - if (err) { + if (!err) { printf("Failed empty verdict prog detach\n"); goto out_sockmap; } err = bpf_prog_detach(fd, BPF_SK_MSG_VERDICT); - if (err) { + if (!err) { printf("Failed empty msg verdict prog detach\n"); goto out_sockmap; } @@ -1094,19 +1094,19 @@ static void test_sockmap(unsigned int ta assert(status == 0); } - err = bpf_prog_detach(map_fd_rx, __MAX_BPF_ATTACH_TYPE); + err = bpf_prog_detach2(parse_prog, map_fd_rx, __MAX_BPF_ATTACH_TYPE); if (!err) { printf("Detached an invalid prog type.\n"); goto out_sockmap; } - err = bpf_prog_detach(map_fd_rx, BPF_SK_SKB_STREAM_PARSER); + err = bpf_prog_detach2(parse_prog, map_fd_rx, BPF_SK_SKB_STREAM_PARSER); if (err) { printf("Failed parser prog detach\n"); goto out_sockmap; } - err = bpf_prog_detach(map_fd_rx, BPF_SK_SKB_STREAM_VERDICT); + err = bpf_prog_detach2(verdict_prog, map_fd_rx, BPF_SK_SKB_STREAM_VERDICT); if (err) { printf("Failed parser prog detach\n"); goto out_sockmap;