From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E649E32E147; Mon, 27 Oct 2025 19:00:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761591633; cv=none; b=cnYkO1VWtDfGGrlSoF7Ki7ASR/6rzUwMXKJSLoVi5AolH4psBs/7px6VHfMV7eSLA6u/FPozM38TaYR/sHIpPys85FMQMSbXQNE+A8jB4YddC3sgjrJxaHAmBjrtw7x82dgW1WqEblRn478UegCBVP9W+46TSv3l6ut9io+hal0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761591633; c=relaxed/simple; bh=Nj6UDt+G3eq30yj8IxYV1IwhV7QC8NUmeIyFIaVcrb8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sjcxIdD/Y+hsagYs89VnnbizNRVZtKsb3+b3a6Vkpio8ZUDelaF39OvXcE4L1q6fe2IRBoUiyz+5jW1Ka0jZ73xPqIVensBeJsueL/1MnufaYnGdxZ2cZqEyNodWf3Ns9wOhY2gpCUuV36Vk/OMLS3G/PlRQtxJMER/gOXE9Kc0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kgmIwx9w; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="kgmIwx9w" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E0A2C113D0; Mon, 27 Oct 2025 19:00:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1761591632; bh=Nj6UDt+G3eq30yj8IxYV1IwhV7QC8NUmeIyFIaVcrb8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kgmIwx9w/Bj/LMmNzD5Esm1Jqp0vNr1aznIE21oJNVKZlx5XeiGsrJUnjSjr3x1t0 BaesViNsld6DpFqnZi3nMDnnKvJiTTFir8UPryxwvQrxhFXAp/+Lz7iRkQLtwZixKt eBI1H3jBO2Nf62UizPvA9bzNWTQrfOmECUQfukzQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Ahern , Nikolay Aleksandrov , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 272/332] net: rtnetlink: add bulk delete support flag Date: Mon, 27 Oct 2025 19:35:25 +0100 Message-ID: <20251027183532.046593504@linuxfoundation.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251027183524.611456697@linuxfoundation.org> References: <20251027183524.611456697@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nikolay Aleksandrov [ Upstream commit a6cec0bcd34264be8887791594be793b3f12719f ] Add a new rtnl flag (RTNL_FLAG_BULK_DEL_SUPPORTED) which is used to verify that the delete operation allows bulk object deletion. Also emit a warning if anyone tries to set it for non-delete kind. Suggested-by: David Ahern Signed-off-by: Nikolay Aleksandrov Signed-off-by: David S. Miller Stable-dep-of: bf29555f5bdc ("rtnetlink: Allow deleting FDB entries in user namespace") Signed-off-by: Sasha Levin --- include/net/rtnetlink.h | 3 ++- net/core/rtnetlink.c | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h index 030fc7eef7401..e893b1f21913e 100644 --- a/include/net/rtnetlink.h +++ b/include/net/rtnetlink.h @@ -10,7 +10,8 @@ typedef int (*rtnl_doit_func)(struct sk_buff *, struct nlmsghdr *, typedef int (*rtnl_dumpit_func)(struct sk_buff *, struct netlink_callback *); enum rtnl_link_flags { - RTNL_FLAG_DOIT_UNLOCKED = BIT(0), + RTNL_FLAG_DOIT_UNLOCKED = BIT(0), + RTNL_FLAG_BULK_DEL_SUPPORTED = BIT(1), }; enum rtnl_kinds { diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 2cd4990ac8bc3..d861744940c6f 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -214,6 +214,8 @@ static int rtnl_register_internal(struct module *owner, if (dumpit) link->dumpit = dumpit; + WARN_ON(rtnl_msgtype_kind(msgtype) != RTNL_KIND_DEL && + (flags & RTNL_FLAG_BULK_DEL_SUPPORTED)); link->flags |= flags; /* publish protocol:msgtype */ @@ -5594,6 +5596,12 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, } flags = link->flags; + if (kind == RTNL_KIND_DEL && (nlh->nlmsg_flags & NLM_F_BULK) && + !(flags & RTNL_FLAG_BULK_DEL_SUPPORTED)) { + NL_SET_ERR_MSG(extack, "Bulk delete is not supported"); + goto err_unlock; + } + if (flags & RTNL_FLAG_DOIT_UNLOCKED) { doit = link->doit; rcu_read_unlock(); -- 2.51.0