Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4724393rdh; Wed, 29 Nov 2023 08:58:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IEpHYUwyNi9R55cli7tExeTr3a7W/5NvuPkQ+3Id9VEzUeUd4dbYVgyVGzw+1RNhTNm46jm X-Received: by 2002:a05:6a20:d90e:b0:18b:d17c:6af2 with SMTP id jd14-20020a056a20d90e00b0018bd17c6af2mr24865996pzb.57.1701277083588; Wed, 29 Nov 2023 08:58:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701277083; cv=none; d=google.com; s=arc-20160816; b=NeG0uxhrFnss8Ga244q4+83arHZ+dXTqoZv+/ysxb/9/+2DSToMs9QpWe5eL41p7/0 UbuUw+ud8iPR0SKzhCghRkLILs+8/RmqoZjbekMW1aBIWT6affZ5H4YskOsV+qNJ7wDa O8COcWCFr7yIcyOH+P6/EPv5Fh8qB7dtuoLtnK73R+qfkPGeJ/ErbIIT/vJHJ1mrYWdc y35qnoWt/Wow7mCD6lqnKScl2T7oFkkMbao0ZDivXsHi9tifMYF14OpCaxXWaUE/aOoF GsJd8DbrIAZai3pUYWgc4S9jf6H+GEbCWr6gzgaNYu8i4tAvki1qUkaewWPsYPX+MqI+ dbsA== 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=H1xPXn0VYaTrAb1Nt5Hiecyvp9SYb9ivj7o6hsBOhvw=; fh=Yk/Quc8tqIb7VaGeTLaGy5uds5Cbik8MTMk6yfuC1TU=; b=nmEl6Nuy54X8F+f+jvZA5Crm/HLqh0fhFypZLdBbz7U/ezU/UTfTUHKCCHxtz1JWHG xKgdAZZIkRjTZ6eHuiCB7vNky69o58VNYg66YVqAwCngiah7seJ67XnAkui986lW7lW4 Ark/xNf5m8vHv/S4Ga5XKMq4F+cdO0ZFqgEzTp4Pvpgh/qZatUWMebnIFDRl52bAaf9g bXylAYF6WGuluBJed0y/60+4BwN3NP5vyLTj8SqH7uIISUjnGWeN/8f7DF4MVCyxB8Qh xNr4YVFGSvNDA6q4ra0qu0nKRmioqfE7pVihbgLs+3BGGb9XQjEDfj+IpfQU7iSVyoff UGHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=Pv4S8DPZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id r31-20020a635d1f000000b005bd039e5a04si98431pgb.622.2023.11.29.08.58.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 08:58:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=Pv4S8DPZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 7430180C9C81; Wed, 29 Nov 2023 08:58:02 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233614AbjK2Q5j (ORCPT + 99 others); Wed, 29 Nov 2023 11:57:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232977AbjK2Q5a (ORCPT ); Wed, 29 Nov 2023 11:57:30 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECFDED1 for ; Wed, 29 Nov 2023 08:57:35 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4079ed65582so52155025e9.1 for ; Wed, 29 Nov 2023 08:57:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=google; t=1701277054; x=1701881854; 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=H1xPXn0VYaTrAb1Nt5Hiecyvp9SYb9ivj7o6hsBOhvw=; b=Pv4S8DPZMX5/yJB6NyJjYkxlQmb6aEawoms8eFOetLImorKodqBHQbb4dRD9ES12ua xxEkrlFkMLaEGLDY4ygW5OAE68wVYm3/cGKPZR3qCE1r0nspXmSlgEKKR2+lge3lcpjq aOXEwW5xrcvf45wyHz5L1MzvN0U9mcipwT/PF3jBPiM+k5vb1S0NuwWb1A1y7TINcZF6 aOzeNVzSFw+VRIn8pUYuPsV0D5whxrSE/skGnNEB5X2+dQH/pO5FEVRI26iWXlU+ZTrg nY6nilz2Ewl5HUk7Bm6BZ/sDAQYVo2Tc459NTJN2h7bQXnP7fqSZtAeNKYqi+ZDSP0XP 6CUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701277054; x=1701881854; 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=H1xPXn0VYaTrAb1Nt5Hiecyvp9SYb9ivj7o6hsBOhvw=; b=nyZ4z1u15VnQ+T9YWQy1uz+0a/Nk2jtLs42kg5dsyyts6rmNQpNqlai2uZT+aaJQa8 PZ0gxjL53P181ckY+aPQPwxEEvahpot9KxjJneQbQynAJ+5N3QqDRgi/m4dlwBaGe5AL ihQoYIZJUz/9WyXej8E6gHmvz+hIdK6ELUxc35IZnFApOp53Rt2EIhbUxe9a1zFRQWDp y7wJfEY8vpt+J6+zZ2t8Yy53+3kuamCDw47xhaGYdqW7a7kCsQwNqMGoO4sC6HpE4G3a 4LRKFAjIrWhimFtlM9EmNKCvhbxcfNEahoTMs6w//UoPIUYogI55WMD9J1ANorHw22eZ U1Yw== X-Gm-Message-State: AOJu0YwTreJDc1O+J0GKi6KsFcI9q3WfB4K9M+fuPgBNXP3M+WRVWWC1 VK/fj751MPCaGYVykqX5DXr9KKFQVd3BaL5PgKc= X-Received: by 2002:a05:600c:4507:b0:40b:338b:5f10 with SMTP id t7-20020a05600c450700b0040b338b5f10mr14391772wmo.32.1701277054520; Wed, 29 Nov 2023 08:57:34 -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.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 08:57:33 -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 4/7] net/tcp: Allow removing current/rnext TCP-AO keys on TCP_LISTEN sockets Date: Wed, 29 Nov 2023 16:57:18 +0000 Message-ID: <20231129165721.337302-5-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=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,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 lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 29 Nov 2023 08:58:02 -0800 (PST) TCP_LISTEN sockets are not connected to any peer, so having current_key/rnext_key doesn't make sense. The userspace may falter over this issue by setting current or rnext TCP-AO key before listen() syscall. setsockopt(TCP_AO_DEL_KEY) doesn't allow removing a key that is in use (in accordance to RFC 5925), so it might be inconvenient to have keys that can be destroyed only with listener socket. Fixes: 4954f17ddefc ("net/tcp: Introduce TCP_AO setsockopt()s") Signed-off-by: Dmitry Safonov --- net/ipv4/tcp_ao.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_ao.c b/net/ipv4/tcp_ao.c index c8be1d526eac..bf41be6d4721 100644 --- a/net/ipv4/tcp_ao.c +++ b/net/ipv4/tcp_ao.c @@ -1818,8 +1818,16 @@ static int tcp_ao_del_cmd(struct sock *sk, unsigned short int family, if (!new_rnext) return -ENOENT; } - if (cmd.del_async && sk->sk_state != TCP_LISTEN) - return -EINVAL; + if (sk->sk_state == TCP_LISTEN) { + /* Cleaning up possible "stale" current/rnext keys state, + * that may have preserved from TCP_CLOSE, before sys_listen() + */ + ao_info->current_key = NULL; + ao_info->rnext_key = NULL; + } else { + if (cmd.del_async) + return -EINVAL; + } if (family == AF_INET) { struct sockaddr_in *sin = (struct sockaddr_in *)&cmd.addr; -- 2.43.0