From patchwork Mon Feb 10 12:31:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 231746 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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham 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 10FB7C352A3 for ; Mon, 10 Feb 2020 13:18:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D4C3120714 for ; Mon, 10 Feb 2020 13:18:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581340714; bh=UUQFGP3pj9DJoqDSltpk18FQw+I+6J/hACUTurBQtEw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=c7zYNpA0fUMy475bA7G03MXvYi4Bw4vqo/dyI1VRvhO8yslY4yUHmyyiiAiobIK+5 2N6YgGaNZ+11K3DLHSplCOxNNY+a8XCeZD+xyYOwlaKFswQwUy40LiWGu8BljI4ugp URvnH8ELmlabpckijdveZ9JHLQPmETZEF5BGIm8E= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729090AbgBJNSd (ORCPT ); Mon, 10 Feb 2020 08:18:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:60254 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728931AbgBJMhw (ORCPT ); Mon, 10 Feb 2020 07:37:52 -0500 Received: from localhost (unknown [209.37.97.194]) (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 A16EE2173E; Mon, 10 Feb 2020 12:37:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338271; bh=UUQFGP3pj9DJoqDSltpk18FQw+I+6J/hACUTurBQtEw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PugDUQyrlTw+izVuxfmFE8HvKywGcQHDNn2OYOqLBntRznvt3oKPMUpkxyPp3lhCm Z7MWkLvJsqnA8oZRtH1SynVmUNolhqG4fdV25nl5iyss5OUISw81W1E0h9Jna0MhSP 7JXf3rjViDNy1h6uERwiouxVtDqJDEJHNH/bZzAk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lorenz Bauer , Daniel Borkmann , Jakub Sitnicki , Martin KaFai Lau , John Fastabend Subject: [PATCH 5.4 154/309] selftests: bpf: Ignore FIN packets for reuseport tests Date: Mon, 10 Feb 2020 04:31:50 -0800 Message-Id: <20200210122421.038025035@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122406.106356946@linuxfoundation.org> References: <20200210122406.106356946@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Lorenz Bauer commit 8bec4f665e0baecb5f1b683379fc10b3745eb612 upstream. The reuseport tests currently suffer from a race condition: FIN packets count towards DROP_ERR_SKB_DATA, since they don't contain a valid struct cmd. Tests will spuriously fail depending on whether check_results is called before or after the FIN is processed. Exit the BPF program early if FIN is set. Fixes: 91134d849a0e ("bpf: Test BPF_PROG_TYPE_SK_REUSEPORT") Signed-off-by: Lorenz Bauer Signed-off-by: Daniel Borkmann Reviewed-by: Jakub Sitnicki Acked-by: Martin KaFai Lau Acked-by: John Fastabend Link: https://lore.kernel.org/bpf/20200124112754.19664-3-lmb@cloudflare.com Signed-off-by: Greg Kroah-Hartman --- tools/testing/selftests/bpf/progs/test_select_reuseport_kern.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/tools/testing/selftests/bpf/progs/test_select_reuseport_kern.c +++ b/tools/testing/selftests/bpf/progs/test_select_reuseport_kern.c @@ -113,6 +113,12 @@ int _select_by_skb_data(struct sk_reusep data_check.skb_ports[0] = th->source; data_check.skb_ports[1] = th->dest; + if (th->fin) + /* The connection is being torn down at the end of a + * test. It can't contain a cmd, so return early. + */ + return SK_PASS; + if ((th->doff << 2) + sizeof(*cmd) > data_check.len) GOTO_DONE(DROP_ERR_SKB_DATA); if (bpf_skb_load_bytes(reuse_md, th->doff << 2, &cmd_copy,