Skip to contentSkip to conversation

net: bridge: Bounce invalid boolopts

PATCH Applied Petr Machata 3 participants 3 messages Sep 5, 2025 – Sep 9, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: bridge: Bounce invalid boolopts

The bridge driver currently tolerates options that it does not recognize. Instead, it should bounce them.

Fixes a428afe82f98 ("net: bridge: add support for user-controlled bool options")
---
 net/bridge/br.c | 7 +++++++
 1 file changed, 7 insertions(+)
net/bridge/br.c +7 -0
index 4bfaf543835a..512872a2ef81 100644
@@ -346,6 +346,13 @@ int br_boolopt_multi_toggle(struct net_bridge *br,
 	int err = 0;
 	int opt_id;
 
+	opt_id = find_next_bit(&bitmap, BITS_PER_LONG, BR_BOOLOPT_MAX);
+	if (opt_id != BITS_PER_LONG) {
+		NL_SET_ERR_MSG_FMT_MOD(extack, "Unknown boolean option %d",
+				       opt_id);
+		return -EINVAL;
+	}
+
 	for_each_set_bit(opt_id, &bitmap, BR_BOOLOPT_MAX) {
 		bool on = !!(bm->optval & BIT(opt_id));
 
Signature · 1 line
2.49.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 18 lines · Petr Machata

The bridge driver currently tolerates options that it does not recognize. Instead, it should bounce them.

Fixes a428afe82f98 ("net: bridge: add support for user-controlled bool options")
---
  net/bridge/br.c | 7 +++++++
  1 file changed, 7 insertions(+)
net/bridge/br.c +0 -0
index 4bfaf543835a..512872a2ef81 100644
@@ -346,6 +346,13 @@ int br_boolopt_multi_toggle(struct net_bridge *br,
  	int err = 0;
  	int opt_id;
 

net/bridge/br.c int br_boolopt_multi_toggle(struct net_bridge *br, · line 358

Quoted 10 lines
net/bridge/br.c +7 -0
+	opt_id = find_next_bit(&bitmap, BITS_PER_LONG, BR_BOOLOPT_MAX);
+	if (opt_id != BITS_PER_LONG) {
+		NL_SET_ERR_MSG_FMT_MOD(extack, "Unknown boolean option %d",
+				       opt_id);
+		return -EINVAL;
+	}
+
  	for_each_set_bit(opt_id, &bitmap, BR_BOOLOPT_MAX) {
  		bool on = !!(bm->optval & BIT(opt_id));
 

IIRC at the time we did this was on purpose, the mask that is returned should show which options were actually set without disrupting the call.

Anyway I'm ok with returning an error for such options as well, thanks!

#2 lore raw
In reply to Petr Machata
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Fri, 5 Sep 2025 13:12:33 +0200 you wrote:

The bridge driver currently tolerates options that it does not recognize. Instead, it should bounce them.

Fixes a428afe82f98 ("net: bridge: add support for user-controlled bool options")

[...]

Here is the summary with links:
- [net] net: bridge: Bounce invalid boolopts

    https://git.kernel.org/netdev/net/c/8625f5748fea

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html