Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4724486rdh; Wed, 29 Nov 2023 08:58:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IEt/cF2TJ6c3AbNFWv4vuPWZl2qZJ4XEg/xhtroP19lhiv7Q4tB2I/GcWwWF2aNIBpNYfN2 X-Received: by 2002:a17:903:2585:b0:1cf:68c8:7a18 with SMTP id jb5-20020a170903258500b001cf68c87a18mr22979184plb.14.1701277093924; Wed, 29 Nov 2023 08:58:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701277093; cv=none; d=google.com; s=arc-20160816; b=VstPTjbdL4sgeiHO5m6nFGiXWd92ZarF2qwuWpjVRARcvKz5Hnve/sJoHSYG3D+XGL 6WfEbUzk6To2pWW7zn0dOLrsapPb5FbD2NkF/OUnTdvHUXEjjlmkW58hJ96nVr2jYDxS lvCN2z4f8ZRrSr/fPbjtBRxZRwhYcds3b7qGHf0pmvM+sI22v4LOVvt28yhtv+EQPmRl NuooWQZP/NIjsMKzgGhDavfga7o8QefeDs9HwzeUZxGMZWlziaDPHplZiFK/Dlez+z0g p4/i55cEOydDIxZPs3Rr1BILHSK8enicPVnNuayBvdD/ephWO44LGa6sg7qK4sZpAqME v78g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dH55LyAvyZzawnq9+CybIblcEgwIvM5k9Dss3KgMZik=; fh=Yk/Quc8tqIb7VaGeTLaGy5uds5Cbik8MTMk6yfuC1TU=; b=u/h7Z+sy9KHyfXyFs9dU1np8SxfOXddXlmOPb2kIMR+ENDAnSfBANIj1Qm/Ts+l9ma WHZhGqZ9bARYGXxn7Fsc3Y1Z3p7ieXGsJHpARig3IOi2E/T43IrJP/8e2WHKBf5w/sa4 Sq14nmlpOJjLmCBgB2zLWNjgeMfout6p/mIgkjsMJag5szMIfUMwynb11UN3jgYw9g5w WisTGwc8XpVZy2CdE3PhrRZ8iLkfh1SYbY3md2lgPNiK+IEnKs6ii07zlALgYZ8f8u1d uIN93lJEboou3v3AK7Ley2ru02SP+UJUMtb1IqkACpaLZw6nRVkzHEBR8/r4tieZYCJO qi6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=j8pc+UZD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=arista.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id z10-20020a170903018a00b001cfb4ceb73bsi10803112plg.569.2023.11.29.08.58.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 08:58:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=j8pc+UZD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=arista.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 4579D8039DD9; Wed, 29 Nov 2023 08:58:02 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233023AbjK2Q5e (ORCPT + 99 others); Wed, 29 Nov 2023 11:57:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232705AbjK2Q52 (ORCPT ); Wed, 29 Nov 2023 11:57:28 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94985B6 for ; Wed, 29 Nov 2023 08:57:34 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-40b4c2ef5cdso17684885e9.2 for ; Wed, 29 Nov 2023 08:57:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=google; t=1701277053; x=1701881853; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dH55LyAvyZzawnq9+CybIblcEgwIvM5k9Dss3KgMZik=; b=j8pc+UZDa62f/c+qFGBN5Mz3r305vAeUpt+nQs/rEajQI0OBe0Lj3D97baonnDOx+Z NS4Gc8kKoqJJN9MH39t9F9v3n0hPHyeVmWAYKytsaReDiBvBzyvKYXMWXjAgpqVABa4u QOYIxo6bdySjZJS/ZTzo/1G2QcyD3fsu29NKbgpUJiNgRogtzD4SNqeeGQfa/4MuiShV 2rEGFviYteUyBPOgtsNoVxNQppAtgRSKDefibt7Cl9hv634x1GoopC7B+veQ+oqgmVFs XnAQc+8C2Z9TLeJfk+PaqGI0T4zW2Z04ZLOcjWVS65tJdK4r8LO6CT/rcs+y93x0jFF6 y6PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701277053; x=1701881853; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dH55LyAvyZzawnq9+CybIblcEgwIvM5k9Dss3KgMZik=; b=LRfigpOkNOMV7H9dzqIcTvfJYK+k+iTq5Pt+T6+MkAGh3/MRKFoLW+gZ/7hW82mvHl aHXI3ehFxhnTrdS+RsDVsDEB+ItLZn7v9ljKNG5+vO+iUXm/aA0Bp3frTxocGPn0s2A/ jE/OEMSY1kfbTAyVXe0uxAAB7rYxz3kYcE6UayD7Y9zbm3UM0TZJBUqHKuGraSigPvVy r9uy+Hrz5jt2GzpvrYBVlokSRQr1/aPDxW88Xxpb6fH3T+hvZlCs9fOIOYPEeMUekwWz VuQYLJFf36LRAfS2WoXKNXyYQepbn7CYi5mvoPAz+9oNSD5TJdJsgcEFYAktnqARBEYe hfjA== X-Gm-Message-State: AOJu0YxDLAZSJzf7vux3MQrla6uw7z4MoUDoJVaNbGb2nSznS/ZmIXGF u9ef2KhpuJFrTHh+bYqipdHm6A== X-Received: by 2002:a05:600c:548f:b0:40b:4a7f:c9ca with SMTP id iv15-20020a05600c548f00b0040b4a7fc9camr4714881wmb.34.1701277053177; Wed, 29 Nov 2023 08:57:33 -0800 (PST) Received: from Mindolluin.ire.aristanetworks.com ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id s20-20020a05600c45d400b003fe1fe56202sm2876823wmo.33.2023.11.29.08.57.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 08:57:32 -0800 (PST) From: Dmitry Safonov To: David Ahern , Eric Dumazet , Paolo Abeni , Jakub Kicinski , "David S. Miller" Cc: linux-kernel@vger.kernel.org, Dmitry Safonov , Dmitry Safonov <0x7f454c46@gmail.com>, Francesco Ruggeri , Salam Noureddine , Simon Horman , netdev@vger.kernel.org Subject: [PATCH v4 3/7] net/tcp: Limit TCP_AO_REPAIR to non-listen sockets Date: Wed, 29 Nov 2023 16:57:17 +0000 Message-ID: <20231129165721.337302-4-dima@arista.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231129165721.337302-1-dima@arista.com> References: <20231129165721.337302-1-dima@arista.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 29 Nov 2023 08:58:02 -0800 (PST) Listen socket is not an established TCP connection, so setsockopt(TCP_AO_REPAIR) doesn't have any impact. Restrict this uAPI for listen sockets. Fixes: faadfaba5e01 ("net/tcp: Add TCP_AO_REPAIR") Signed-off-by: Dmitry Safonov --- net/ipv4/tcp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 53bcc17c91e4..b1fe4eb01829 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -3594,6 +3594,10 @@ int do_tcp_setsockopt(struct sock *sk, int level, int optname, break; case TCP_AO_REPAIR: + if (!tcp_can_repair_sock(sk)) { + err = -EPERM; + break; + } err = tcp_ao_set_repair(sk, optval, optlen); break; #ifdef CONFIG_TCP_AO @@ -4293,6 +4297,8 @@ int do_tcp_getsockopt(struct sock *sk, int level, } #endif case TCP_AO_REPAIR: + if (!tcp_can_repair_sock(sk)) + return -EPERM; return tcp_ao_get_repair(sk, optval, optlen); case TCP_AO_GET_KEYS: case TCP_AO_INFO: { -- 2.43.0