From patchwork Tue Jun 23 19:56:14 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: 223144 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=-10.0 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 85E39C433E1 for ; Tue, 23 Jun 2020 21:27:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B6EB20724 for ; Tue, 23 Jun 2020 21:27:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592947661; bh=m/2JE2rT+Paibu0VmyrxoGCzTRL7oQHg/PwXjAzflgg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=wV4kMmVuCAcoig33yVVlkInhhpYBQrDsGMdhds5FfEIY/+jjUbBjsHlb3LAZkaCnI k+L/Xwk4aYJUjnr7d6k1W+NyHUImZeovrd/p0b+KpRDP1Woj0bNQNRBqkwtIF3/vMK xW0WoaxZd1ke9ky0INA220Fqxy0xq1bAP7AK1wTA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389229AbgFWV1k (ORCPT ); Tue, 23 Jun 2020 17:27:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:60332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388539AbgFWUQj (ORCPT ); Tue, 23 Jun 2020 16:16:39 -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 A81542073E; Tue, 23 Jun 2020 20:16:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592943399; bh=m/2JE2rT+Paibu0VmyrxoGCzTRL7oQHg/PwXjAzflgg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EPh2U70HUg13bZz1i0uT2hiu9MGvzvCHpfDjB+PevFGG69bbJxwKRn4ZaoHRy0OEL o/CfucACeNZReS9RtdKvB+CXxid3MFsWWE4cD3++uZqbaIz0X0XomJWS1nB0u8Jx0f W3DaLu640koJG5kCeTJj5ajDWD3gRuVkKmokMfIc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lorenz Bauer , Alexei Starovoitov , Jakub Sitnicki , Sasha Levin Subject: [PATCH 5.7 377/477] bpf: sockmap: Dont attach programs to UDP sockets Date: Tue, 23 Jun 2020 21:56:14 +0200 Message-Id: <20200623195425.352558802@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195407.572062007@linuxfoundation.org> References: <20200623195407.572062007@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 [ Upstream commit f6fede8569689dd31e7b0ed15024b25e5ce2e2e5 ] The stream parser infrastructure isn't set up to deal with UDP sockets, so we mustn't try to attach programs to them. I remember making this change at some point, but I must have lost it while rebasing or something similar. Fixes: 7b98cd42b049 ("bpf: sockmap: Add UDP support") Signed-off-by: Lorenz Bauer Signed-off-by: Alexei Starovoitov Acked-by: Jakub Sitnicki Link: https://lore.kernel.org/bpf/20200611172520.327602-1-lmb@cloudflare.com Signed-off-by: Sasha Levin --- net/core/sock_map.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/net/core/sock_map.c b/net/core/sock_map.c index 050bfac97cfb5..7e858c1dd7113 100644 --- a/net/core/sock_map.c +++ b/net/core/sock_map.c @@ -417,10 +417,7 @@ static int sock_map_get_next_key(struct bpf_map *map, void *key, void *next) return 0; } -static bool sock_map_redirect_allowed(const struct sock *sk) -{ - return sk->sk_state != TCP_LISTEN; -} +static bool sock_map_redirect_allowed(const struct sock *sk); static int sock_map_update_common(struct bpf_map *map, u32 idx, struct sock *sk, u64 flags) @@ -501,6 +498,11 @@ static bool sk_is_udp(const struct sock *sk) sk->sk_protocol == IPPROTO_UDP; } +static bool sock_map_redirect_allowed(const struct sock *sk) +{ + return sk_is_tcp(sk) && sk->sk_state != TCP_LISTEN; +} + static bool sock_map_sk_is_suitable(const struct sock *sk) { return sk_is_tcp(sk) || sk_is_udp(sk);