public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Fernando Fernandez Mancera <fmancera@suse.de>,
	Jakub Kicinski <kuba@kernel.org>, Sasha Levin <sashal@kernel.org>,
	davem@davemloft.net, dsahern@kernel.org, edumazet@google.com,
	pabeni@redhat.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH AUTOSEL 7.0-6.1] ipv4: validate IPV4_DEVCONF attributes properly
Date: Mon, 20 Apr 2026 09:19:10 -0400	[thread overview]
Message-ID: <20260420132314.1023554-156-sashal@kernel.org> (raw)
In-Reply-To: <20260420132314.1023554-1-sashal@kernel.org>

From: Fernando Fernandez Mancera <fmancera@suse.de>

[ Upstream commit fa8fca88714c3a4a74f972ed37328e2f0bbef9fa ]

As the IPV4_DEVCONF netlink attributes are not being validated, it is
possible to use netlink to set read-only values like mc_forwarding. In
addition, valid ranges are not being validated neither but that is less
relevant as they aren't in sysctl.

To avoid similar situations in the future, define a NLA policy for
IPV4_DEVCONF attributes which are nested in IFLA_INET_CONF.

Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
Link: https://patch.msgid.link/20260312142637.5704-1-fmancera@suse.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

LLM Generated explanations, may be completely bogus:

Good - confirmed that v6.12 has the same vulnerable code. The
RTM_SETLINK path requires `CAP_NET_ADMIN`, but this is available within
network namespaces (an unprivileged user can create a network namespace
and get CAP_NET_ADMIN there).

Now I have all the information I need to complete my analysis. Let me
compile the full assessment.

---

## PHASE 1: COMMIT MESSAGE FORENSICS

### Step 1.1: PARSE THE SUBJECT LINE
Record: [subsystem: ipv4] [action verb: validate] [Summary: Add proper
NLA validation policy for IPV4_DEVCONF netlink attributes nested in
IFLA_INET_CONF]

### Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
- **Signed-off-by**: Fernando Fernandez Mancera <fmancera@suse.de>
  (author)
- **Link**:
  https://patch.msgid.link/20260312142637.5704-1-fmancera@suse.de
- **Signed-off-by**: Jakub Kicinski <kuba@kernel.org> (net subsystem
  maintainer, applied it)
- No Fixes: tag (expected)
- No Cc: stable tag (expected)
- No Reported-by (the author found the issue themselves)

Record: Patch applied by Jakub Kicinski (net maintainer). No explicit
stable nomination. No Fixes tag (the bug exists since the original 2010
code, commit 9f0f7272ac95).

### Step 1.3: ANALYZE THE COMMIT BODY TEXT
The commit message clearly describes:
- **Bug**: IPV4_DEVCONF netlink attributes are not being validated
- **Consequence 1**: Read-only values like `mc_forwarding` can be set
  via netlink - this is a security bypass
- **Consequence 2**: Valid ranges are not enforced (less critical)
- **Fix approach**: Define a NLA policy for IPV4_DEVCONF attributes

Record: Bug = missing input validation on netlink attributes. Allows
bypassing read-only restrictions (mc_forwarding). mc_forwarding is
kernel-managed and should only be set by the multicast routing daemon
via ip_mroute_setsockopt(). Setting it directly breaks multicast routing
assumptions.

### Step 1.4: DETECT HIDDEN BUG FIXES
This is explicitly described as a validation/security fix. The word
"validate" in the subject and the clear description of the bypass make
this obviously a bug fix.

Record: This is a direct security/correctness fix, not a hidden one.

## PHASE 2: DIFF ANALYSIS - LINE BY LINE

### Step 2.1: INVENTORY THE CHANGES
- **File**: `net/ipv4/devinet.c` - single file modification
- **Added**: ~38 lines (new policy table `inet_devconf_policy`) + ~7
  lines (new validation code)
- **Removed**: ~10 lines (old manual validation loop)
- **Net change**: approximately +35 lines
- **Functions modified**: `inet_validate_link_af` (rewritten validation
  logic)
- **Scope**: Single-file, well-contained change

Record: 1 file changed, +45/-10 lines. Modified function:
`inet_validate_link_af`. New static const: `inet_devconf_policy`. Scope:
single-file surgical fix.

### Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
**Before**: `inet_validate_link_af` only checked that each nested
attribute had length >= 4 and a valid cfgid in range [1,
IPV4_DEVCONF_MAX]. No per-attribute validation, no rejection of read-
only fields, no range checking.

**After**: Uses `nla_parse_nested()` with a proper policy table
(`inet_devconf_policy`) that:
1. **Rejects** `MC_FORWARDING` writes via `NLA_REJECT`
2. **Range-validates** boolean attributes to {0,1}
3. **Range-validates** multi-value attributes (RP_FILTER: 0-2,
   ARP_IGNORE: 0-8, etc.)
4. **Type-validates** all attributes as NLA_U32

Record: Before = minimal bounds check only. After = full NLA policy-
based validation with per-attribute type, range, and reject rules.
Critical change: MC_FORWARDING is now NLA_REJECT.

### Step 2.3: IDENTIFY THE BUG MECHANISM
**Category**: Logic/correctness fix + Security fix (missing input
validation)

The bug mechanism:
1. User sends RTM_SETLINK with IFLA_AF_SPEC containing AF_INET with
   IFLA_INET_CONF
2. `inet_validate_link_af` only checked length and range of attribute
   IDs
3. `inet_set_link_af` called `ipv4_devconf_set(in_dev, nla_type(a),
   nla_get_u32(a))` for ALL attributes
4. `ipv4_devconf_set` directly writes to `in_dev->cnf.data[]` with
   WRITE_ONCE - no per-attribute filtering
5. This means mc_forwarding (a read-only sysctl at 0444 permissions)
   could be set via netlink
6. mc_forwarding is managed by the kernel's multicast routing subsystem
   and manipulated by ipmr.c

Record: Missing input validation allows bypassing read-only restrictions
via netlink. The `ipv4_devconf_set` function blindly sets any config
value. The old validate function only checked bounds, not per-attribute
rules.

### Step 2.4: ASSESS THE FIX QUALITY
- The fix is obviously correct: it uses the standard NLA policy
  mechanism
- It is well-contained: single file, one function modified, one policy
  table added
- Regression risk is low: the policy table is conservative (allows all
  previously-allowed valid inputs)
- The `nla_parse_nested()` (non-deprecated) enforces NLA_F_NESTED flag,
  which is slightly stricter than the old code. This is intentional and
  correct for modern netlink.
- Jakub Kicinski reviewed and applied it (net subsystem maintainer)

Record: Fix is obviously correct, uses standard kernel NLA policy
infrastructure. Low regression risk. Applied by the net subsystem
maintainer.

## PHASE 3: GIT HISTORY INVESTIGATION

### Step 3.1: BLAME THE CHANGED LINES
The vulnerable validation code was introduced in commit `9f0f7272ac9506`
(Thomas Graf, November 2010, v2.6.37-rc1). This code has been present in
the kernel for ~15 years and exists in ALL active stable trees.

Record: Buggy code from commit 9f0f7272ac95 (2010, v2.6.37-rc1). Present
in every stable tree.

### Step 3.2: FOLLOW THE FIXES TAG
No Fixes: tag present (the bug dates to the original 2010
implementation, so a Fixes tag would reference 9f0f7272ac95).

Record: N/A - no Fixes tag. Bug originates from commit 9f0f7272ac95.

### Step 3.3: CHECK FILE HISTORY
The `inet_validate_link_af` function has not been significantly modified
since its creation. The only changes were the addition of the `extack`
parameter (2021, commit 8679c31e0284) and a minor check adjustment
(commit a100243d95a60d, 2021). The core validation logic was untouched
for 15 years.

Record: Standalone fix. No dependencies on other patches. The function
is identical across v6.1, v6.6, and v6.12.

### Step 3.4: CHECK THE AUTHOR
Fernando Fernandez Mancera is a contributor from SUSE. He submitted
follow-up patches to also centralize devconf post-set actions, showing
deep understanding of the subsystem.

Record: Author is an active contributor. Follow-up series planned.

### Step 3.5: CHECK FOR DEPENDENCIES
This patch is standalone. The follow-up patches (centralize devconf
handling, handle post-set actions) are separate and NOT required for
this fix to work. This patch only adds validation; it does not change
the set behavior.

Record: No dependencies. Standalone fix. Can apply independently.

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

### Step 4.1: ORIGINAL PATCH DISCUSSION
Found at:
https://yhbt.net/lore/netdev/20260304180725.717a3f0d@kernel.org/T/

The patch went through v1 -> v2 (no changes) -> v3 (dropped Fixes tag,
adjusted MEDIUM_ID to NLA_S32) -> final applied version (addressed
Jakub's v3 review: NLA_POLICY_MIN for MEDIUM_ID, ARP_ACCEPT range 0-2).

Jakub Kicinski's v3 review asked two questions:
1. MEDIUM_ID validation type - fixed by using NLA_POLICY_MIN()
2. ARP_ACCEPT should accept 2 - fixed in final version

Record: Thread at yhbt.net mirror. Patch went v1->v3->applied. Jakub
reviewed v3, feedback addressed in applied version. Maintainer applied
it.

### Step 4.2: REVIEWER
Jakub Kicinski (net maintainer) reviewed and applied. All major net
maintainers were CC'd (horms, pabeni, edumazet, dsahern, davem).

Record: Net maintainer reviewed and applied. All relevant people were
CC'd.

### Step 4.3: BUG REPORT
No external bug report - author found the issue by code inspection.

### Step 4.4: RELATED PATCHES
Follow-up series (March 25, 2026): "centralize devconf sysctl handling"
+ "handle devconf post-set actions on netlink updates". These are NOT
required for this fix - they improve consistency of behavior when values
are set via netlink vs sysctl.

Record: Follow-up patches exist but are not prerequisites.

### Step 4.5: STABLE DISCUSSION
No specific stable mailing list discussion found. The v3 note says
"dropped the fixes tag" - suggesting the author initially considered
this a fix but removed the Fixes tag (perhaps because it traces back to
2010).

Record: No stable-specific discussion. Author initially had a Fixes tag
but dropped it.

## PHASE 5: CODE SEMANTIC ANALYSIS

### Step 5.1: KEY FUNCTIONS
- `inet_validate_link_af` - modified
- New: `inet_devconf_policy` static const policy table

### Step 5.2: TRACE CALLERS
`inet_validate_link_af` is called from `rtnetlink.c` via
`af_ops->validate_link_af(dev, af, extack)` at line 2752. This is in the
`do_validate_setlink` path, called during RTM_SETLINK processing.
RTM_SETLINK is a standard netlink message used by `ip link set`.

Record: Called from RTM_SETLINK path. Trigger: `ip link set dev <DEV>
...` with AF_INET options.

### Step 5.3: TRACE CALLEES
Uses `nla_parse_nested()` which validates against the policy and returns
error if validation fails. This is the standard kernel netlink
validation infrastructure.

### Step 5.4: CALL CHAIN
User space -> RTM_SETLINK -> rtnl_setlink() -> do_setlink() -> validate
loop -> inet_validate_link_af() -> if passes -> inet_set_link_af() ->
ipv4_devconf_set()

Reachable from: any process with CAP_NET_ADMIN (including unprivileged
users in a network namespace).

Record: Reachable from userspace via RTM_SETLINK. CAP_NET_ADMIN
required, but available in network namespaces.

### Step 5.5: SIMILAR PATTERNS
IPv6 has `inet6_validate_link_af` in `addrconf.c` which already has
proper validation.

Record: IPv6 equivalent already has proper validation. IPv4 was the
outlier.

## PHASE 6: CROSS-REFERENCING AND STABLE TREE ANALYSIS

### Step 6.1: BUGGY CODE IN STABLE TREES
The vulnerable code (commit 9f0f7272ac95 from 2010) exists in ALL stable
trees: v5.4.y, v5.10.y, v5.15.y, v6.1.y, v6.6.y, v6.12.y, etc.

Verified: `inet_validate_link_af` is identical in v6.1, v6.6, and v6.12.

Record: Bug exists in all active stable trees.

### Step 6.2: BACKPORT COMPLICATIONS
- For v6.1+: Patch should apply cleanly (verified code is identical)
- For v5.15: Needs minor adjustment - `IPV4_DEVCONF_ARP_EVICT_NOCARRIER`
  doesn't exist (added in v5.16), so that policy entry must be removed
- `NLA_POLICY_RANGE`, `NLA_REJECT`, `NLA_POLICY_MIN`, `nla_parse_nested`
  all exist since v4.20+

Record: Clean apply for v6.1+. Minor adjustment for v5.15 (remove
ARP_EVICT_NOCARRIER). All infrastructure available.

### Step 6.3: RELATED FIXES IN STABLE
No related fixes found.

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

### Step 7.1: SUBSYSTEM CRITICALITY
**Subsystem**: net/ipv4 (core IPv4 networking)
**Criticality**: CORE - affects all users (IPv4 is used by virtually
every system)

Record: CORE subsystem. IPv4 networking affects all users.

### Step 7.2: SUBSYSTEM ACTIVITY
`net/ipv4/devinet.c` is actively maintained with regular commits.

## PHASE 8: IMPACT AND RISK ASSESSMENT

### Step 8.1: WHO IS AFFECTED
All users. IPv4 networking is universal. Any system with network
namespaces enabled is particularly at risk because unprivileged users
can create network namespaces and gain CAP_NET_ADMIN there.

Record: Universal impact. Especially relevant for containerized
environments.

### Step 8.2: TRIGGER CONDITIONS
- **Trigger**: Send RTM_SETLINK netlink message with IFLA_AF_SPEC /
  AF_INET / IFLA_INET_CONF containing MC_FORWARDING attribute
- **Privilege**: CAP_NET_ADMIN (available in network namespaces, so
  effectively unprivileged)
- **Ease**: Trivial to trigger programmatically with a simple netlink
  socket

Record: Easy to trigger. CAP_NET_ADMIN in netns = effectively
unprivileged. Deterministic trigger (not a race).

### Step 8.3: FAILURE MODE SEVERITY
- **mc_forwarding bypass**: This is a read-only sysctl (0444) that
  should only be managed by the kernel's multicast routing subsystem.
  Setting it externally can corrupt multicast routing state, potentially
  leading to unexpected multicast forwarding behavior or denial of
  multicast routing.
- **Range validation bypass**: Out-of-range values for other devconf
  settings could cause unexpected networking behavior.
- **Security classification**: This is an access control bypass - a
  value that should be read-only can be written. While it requires
  CAP_NET_ADMIN, in containerized environments this is available to
  unprivileged users.

Record: Severity HIGH. Access control bypass for read-only network
configuration. Potential for multicast routing state corruption.

### Step 8.4: RISK-BENEFIT RATIO
**BENEFIT**: HIGH - Fixes input validation gap in core IPv4 networking
code that has existed for 15 years. Prevents unauthorized modification
of read-only network configuration.

**RISK**: LOW - The fix uses standard kernel NLA policy infrastructure.
The policy table is a new static const (no runtime allocation). The
validation function replacement is straightforward. The only behavioral
change is rejecting previously-accepted-but-invalid inputs (which is the
desired behavior).

Record: HIGH benefit, LOW risk. Favorable ratio.

## PHASE 9: FINAL SYNTHESIS

### Step 9.1: EVIDENCE COMPILATION

**FOR backporting:**
1. Fixes a real access control bypass (mc_forwarding writable despite
   being read-only sysctl)
2. Fixes missing input validation in core IPv4 networking code
3. Bug has existed since 2010 (v2.6.37-rc1), affects all stable trees
4. Small, contained fix - single file, uses standard NLA policy
   infrastructure
5. Applied by net subsystem maintainer (Jakub Kicinski)
6. Deterministic trigger, easy to exploit from network namespace
7. IPv4 networking is universal - affects all users
8. Patch applies cleanly to all recent stable trees (v6.1+)

**AGAINST backporting:**
1. No Fixes: tag (though author initially had one and dropped it since
   bug is from 2010)
2. No Cc: stable tag (expected)
3. Size is moderate (~45 lines added) due to the policy table
4. Submitted as net-next (not net), suggesting author didn't consider it
   urgent
5. Requires CAP_NET_ADMIN (though available in netns)

**UNRESOLVED:**
- Exact impact of writing mc_forwarding is limited (networking state
  corruption, not crash/security exploit per se)

### Step 9.2: STABLE RULES CHECKLIST
1. **Obviously correct and tested?** YES - uses standard NLA policy;
   reviewed by net maintainer
2. **Fixes a real bug?** YES - access control bypass for read-only
   devconf values
3. **Important issue?** YES - security-relevant input validation in core
   networking
4. **Small and contained?** YES - single file, well-understood change
5. **No new features or APIs?** YES - only adds validation, no new user-
   visible behavior
6. **Can apply to stable?** YES - cleanly to v6.1+ (minor adjustment for
   v5.15)

### Step 9.3: EXCEPTION CATEGORIES
Not an exception category - this is a standard bug fix.

### Step 9.4: DECISION
This commit fixes a real access control bypass in core IPv4 networking
that has existed since 2010. It prevents unauthorized modification of
read-only network configuration values (mc_forwarding) via netlink. The
fix is small, uses standard kernel infrastructure, was reviewed by the
net subsystem maintainer, and applies cleanly to all active stable
trees. While it requires CAP_NET_ADMIN, this is available in network
namespaces, making it relevant for containerized environments. The risk-
benefit ratio strongly favors backporting.

## Verification

- [Phase 1] Parsed tags: Signed-off-by Fernando Fernandez Mancera +
  Jakub Kicinski. Link to patch.msgid.link.
- [Phase 2] Diff analysis: +45/-10 lines in single file. Adds
  inet_devconf_policy static const with NLA_REJECT for MC_FORWARDING.
  Rewrites inet_validate_link_af to use nla_parse_nested with policy.
- [Phase 3] git blame: Buggy code introduced in commit 9f0f7272ac95
  (2010, v2.6.37-rc1), present in all stable trees.
- [Phase 3] git show v6.1/v6.6/v6.12: inet_validate_link_af is identical
  across all stable trees - patch applies cleanly.
- [Phase 3] git show v5.15 include/uapi/linux/ip.h:
  IPV4_DEVCONF_ARP_EVICT_NOCARRIER not present (added v5.16) - minor
  adjustment needed.
- [Phase 4] Found original discussion at yhbt.net mirror: patch went
  v1->v3->applied. Jakub reviewed v3 with two comments (MEDIUM_ID and
  ARP_ACCEPT), both addressed in final version.
- [Phase 4] Follow-up series (centralize devconf handling) exists but is
  not a dependency.
- [Phase 5] Traced call chain: userspace -> RTM_SETLINK ->
  rtnl_setlink() -> do_setlink() -> inet_validate_link_af() ->
  inet_set_link_af() -> ipv4_devconf_set(). CAP_NET_ADMIN required but
  available in network namespaces.
- [Phase 5] Verified ipv4_devconf_set() blindly writes to cnf.data[]
  with WRITE_ONCE (include/linux/inetdevice.h:67-73).
- [Phase 5] Verified MC_FORWARDING is managed by ipmr.c
  (IPV4_DEVCONF(in_dev->cnf, MC_FORWARDING)++ / --).
- [Phase 6] Verified NLA_POLICY_RANGE exists since v4.20 (commit
  3e48be05f3c7), NLA_REJECT since similar era. All infrastructure
  available in all stable trees.
- [Phase 6] RTM_SETLINK permission: line 6921 of rtnetlink.c checks
  `netlink_net_capable(skb, CAP_NET_ADMIN)`, confirmed userspace-
  reachable.
- [Phase 7] Subsystem: net/ipv4 = CORE, affects all users.
- [Phase 8] Failure mode: access control bypass, read-only value
  writable. Severity: HIGH.
- UNVERIFIED: Exact security implications of writing arbitrary
  mc_forwarding values (could not find CVE or explicit exploit
  analysis). However, the principle of read-only bypass is itself
  security-relevant.

**YES**

 net/ipv4/devinet.c | 55 +++++++++++++++++++++++++++++++++++++---------
 1 file changed, 45 insertions(+), 10 deletions(-)

diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 537bb6c315d2e..58fe7cb69545c 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -2063,12 +2063,50 @@ static const struct nla_policy inet_af_policy[IFLA_INET_MAX+1] = {
 	[IFLA_INET_CONF]	= { .type = NLA_NESTED },
 };
 
+static const struct nla_policy inet_devconf_policy[IPV4_DEVCONF_MAX + 1] = {
+	[IPV4_DEVCONF_FORWARDING]	= NLA_POLICY_RANGE(NLA_U32, 0, 1),
+	[IPV4_DEVCONF_MC_FORWARDING]	= { .type = NLA_REJECT },
+	[IPV4_DEVCONF_PROXY_ARP]	= NLA_POLICY_RANGE(NLA_U32, 0, 1),
+	[IPV4_DEVCONF_ACCEPT_REDIRECTS]	= NLA_POLICY_RANGE(NLA_U32, 0, 1),
+	[IPV4_DEVCONF_SECURE_REDIRECTS]	= NLA_POLICY_RANGE(NLA_U32, 0, 1),
+	[IPV4_DEVCONF_SEND_REDIRECTS]	= NLA_POLICY_RANGE(NLA_U32, 0, 1),
+	[IPV4_DEVCONF_SHARED_MEDIA]	= NLA_POLICY_RANGE(NLA_U32, 0, 1),
+	[IPV4_DEVCONF_RP_FILTER]	= NLA_POLICY_RANGE(NLA_U32, 0, 2),
+	[IPV4_DEVCONF_ACCEPT_SOURCE_ROUTE] = NLA_POLICY_RANGE(NLA_U32, 0, 1),
+	[IPV4_DEVCONF_BOOTP_RELAY]	= NLA_POLICY_RANGE(NLA_U32, 0, 1),
+	[IPV4_DEVCONF_LOG_MARTIANS]	= NLA_POLICY_RANGE(NLA_U32, 0, 1),
+	[IPV4_DEVCONF_TAG]		= { .type = NLA_U32 },
+	[IPV4_DEVCONF_ARPFILTER]	= NLA_POLICY_RANGE(NLA_U32, 0, 1),
+	[IPV4_DEVCONF_MEDIUM_ID]	= NLA_POLICY_MIN(NLA_S32, -1),
+	[IPV4_DEVCONF_NOXFRM]		= NLA_POLICY_RANGE(NLA_U32, 0, 1),
+	[IPV4_DEVCONF_NOPOLICY]		= NLA_POLICY_RANGE(NLA_U32, 0, 1),
+	[IPV4_DEVCONF_FORCE_IGMP_VERSION] = NLA_POLICY_RANGE(NLA_U32, 0, 3),
+	[IPV4_DEVCONF_ARP_ANNOUNCE]	= NLA_POLICY_RANGE(NLA_U32, 0, 2),
+	[IPV4_DEVCONF_ARP_IGNORE]	= NLA_POLICY_RANGE(NLA_U32, 0, 8),
+	[IPV4_DEVCONF_PROMOTE_SECONDARIES] = NLA_POLICY_RANGE(NLA_U32, 0, 1),
+	[IPV4_DEVCONF_ARP_ACCEPT]	= NLA_POLICY_RANGE(NLA_U32, 0, 2),
+	[IPV4_DEVCONF_ARP_NOTIFY]	= NLA_POLICY_RANGE(NLA_U32, 0, 1),
+	[IPV4_DEVCONF_ACCEPT_LOCAL]	= NLA_POLICY_RANGE(NLA_U32, 0, 1),
+	[IPV4_DEVCONF_SRC_VMARK]	= NLA_POLICY_RANGE(NLA_U32, 0, 1),
+	[IPV4_DEVCONF_PROXY_ARP_PVLAN]	= NLA_POLICY_RANGE(NLA_U32, 0, 1),
+	[IPV4_DEVCONF_ROUTE_LOCALNET]	= NLA_POLICY_RANGE(NLA_U32, 0, 1),
+	[IPV4_DEVCONF_BC_FORWARDING]	= NLA_POLICY_RANGE(NLA_U32, 0, 1),
+	[IPV4_DEVCONF_IGMPV2_UNSOLICITED_REPORT_INTERVAL] = { .type = NLA_U32 },
+	[IPV4_DEVCONF_IGMPV3_UNSOLICITED_REPORT_INTERVAL] = { .type = NLA_U32 },
+	[IPV4_DEVCONF_IGNORE_ROUTES_WITH_LINKDOWN] =
+		NLA_POLICY_RANGE(NLA_U32, 0, 1),
+	[IPV4_DEVCONF_DROP_UNICAST_IN_L2_MULTICAST] =
+		NLA_POLICY_RANGE(NLA_U32, 0, 1),
+	[IPV4_DEVCONF_DROP_GRATUITOUS_ARP] = NLA_POLICY_RANGE(NLA_U32, 0, 1),
+	[IPV4_DEVCONF_ARP_EVICT_NOCARRIER] = NLA_POLICY_RANGE(NLA_U32, 0, 1),
+};
+
 static int inet_validate_link_af(const struct net_device *dev,
 				 const struct nlattr *nla,
 				 struct netlink_ext_ack *extack)
 {
-	struct nlattr *a, *tb[IFLA_INET_MAX+1];
-	int err, rem;
+	struct nlattr *tb[IFLA_INET_MAX + 1], *nested_tb[IPV4_DEVCONF_MAX + 1];
+	int err;
 
 	if (dev && !__in_dev_get_rtnl(dev))
 		return -EAFNOSUPPORT;
@@ -2079,15 +2117,12 @@ static int inet_validate_link_af(const struct net_device *dev,
 		return err;
 
 	if (tb[IFLA_INET_CONF]) {
-		nla_for_each_nested(a, tb[IFLA_INET_CONF], rem) {
-			int cfgid = nla_type(a);
+		err = nla_parse_nested(nested_tb, IPV4_DEVCONF_MAX,
+				       tb[IFLA_INET_CONF], inet_devconf_policy,
+				       extack);
 
-			if (nla_len(a) < 4)
-				return -EINVAL;
-
-			if (cfgid <= 0 || cfgid > IPV4_DEVCONF_MAX)
-				return -EINVAL;
-		}
+		if (err < 0)
+			return err;
 	}
 
 	return 0;
-- 
2.53.0


  parent reply	other threads:[~2026-04-20 13:27 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260420132314.1023554-1-sashal@kernel.org>
2026-04-20 13:16 ` [PATCH AUTOSEL 7.0-5.10] FDDI: defxx: Rate-limit memory allocation errors Sasha Levin
2026-04-20 13:16 ` [PATCH AUTOSEL 6.18] xsk: fix XDP_UMEM_SG_FLAG issues Sasha Levin
2026-04-20 13:17 ` [PATCH AUTOSEL 7.0-5.10] net: rose: reject truncated CLEAR_REQUEST frames in state machines Sasha Levin
2026-04-20 13:17 ` [PATCH AUTOSEL 6.18] netfilter: nfnetlink_queue: nfqnl_instance GFP_ATOMIC -> GFP_KERNEL_ACCOUNT allocation Sasha Levin
2026-04-20 13:17 ` [PATCH AUTOSEL 7.0-6.18] net: mana: hardening: Validate adapter_mtu from MANA_QUERY_DEV_CONFIG Sasha Levin
2026-04-20 13:17 ` [PATCH AUTOSEL 7.0-5.10] enic: add V2 SR-IOV VF device ID Sasha Levin
2026-04-20 13:17 ` [PATCH AUTOSEL 7.0-6.6] ipv6: move IFA_F_PERMANENT percpu allocation in process scope Sasha Levin
2026-04-20 13:17 ` [PATCH AUTOSEL 6.18] netfilter: nfnetlink_log: initialize nfgenmsg in NLMSG_DONE terminator Sasha Levin
2026-04-20 13:17 ` [PATCH AUTOSEL 6.18] net: increase IP_TUNNEL_RECURSION_LIMIT to 5 Sasha Levin
2026-04-20 13:17 ` [PATCH AUTOSEL 7.0-6.1] net: lan743x: fix SGMII detection on PCI1xxxx B0+ during warm reset Sasha Levin
2026-04-20 13:17 ` [PATCH AUTOSEL 7.0-5.10] vmxnet3: Suppress page allocation warning for massive Rx Data ring Sasha Levin
2026-04-20 13:17 ` [PATCH AUTOSEL 6.18] xfrm: Wait for RCU readers during policy netns exit Sasha Levin
2026-04-20 13:18 ` [PATCH AUTOSEL 6.18] ixgbe: stop re-reading flash on every get_drvinfo for e610 Sasha Levin
2026-04-20 13:18 ` [PATCH AUTOSEL 6.18] devlink: Fix incorrect skb socket family dumping Sasha Levin
2026-04-20 13:18 ` [PATCH AUTOSEL 7.0-6.12] net: sfp: add quirk for ZOERAX SFP-2.5G-T Sasha Levin
2026-04-20 13:18 ` [PATCH AUTOSEL 7.0-6.18] ipv6: discard fragment queue earlier if there is malformed datagram Sasha Levin
2026-04-20 13:18 ` [PATCH AUTOSEL 6.18] af_unix: read UNIX_DIAG_VFS data under unix_state_lock Sasha Levin
2026-04-20 13:18 ` [PATCH AUTOSEL 6.18] ipv4: nexthop: allocate skb dynamically in rtm_get_nexthop() Sasha Levin
2026-04-20 13:18 ` [PATCH AUTOSEL 6.18] xfrm: fix refcount leak in xfrm_migrate_policy_find Sasha Levin
2026-04-20 13:18 ` [PATCH AUTOSEL 6.18] selftests: net: bridge_vlan_mcast: wait for h1 before querier check Sasha Levin
2026-04-20 13:18 ` [PATCH AUTOSEL 6.18] xsk: tighten UMEM headroom validation to account for tailroom and min frame Sasha Levin
2026-04-20 13:18 ` [PATCH AUTOSEL 7.0-5.15] gve: fix SW coalescing when hw-GRO is used Sasha Levin
2026-04-20 13:19 ` [PATCH AUTOSEL 6.18] netfilter: ip6t_eui64: reject invalid MAC header for all packets Sasha Levin
2026-04-20 13:19 ` [PATCH AUTOSEL 6.18] l2tp: Drop large packets with UDP encap Sasha Levin
2026-04-20 13:19 ` [PATCH AUTOSEL 7.0-5.10] net: ethernet: ravb: Disable interrupts when closing device Sasha Levin
2026-04-20 13:19 ` [PATCH AUTOSEL 7.0] dsa: tag_mxl862xx: set dsa_default_offload_fwd_mark() Sasha Levin
2026-04-20 13:34   ` Daniel Golle
2026-04-20 13:19 ` Sasha Levin [this message]
2026-04-20 13:19 ` [PATCH AUTOSEL 6.18] ipv4: nexthop: avoid duplicate NHA_HW_STATS_ENABLE on nexthop group dump Sasha Levin
2026-04-20 13:19 ` [PATCH AUTOSEL 6.18] net: ipa: fix event ring index not programmed for IPA v5.0+ Sasha Levin
2026-04-20 13:19 ` [PATCH AUTOSEL 7.0-5.10] net: core: allow netdev_upper_get_next_dev_rcu from bh context Sasha Levin
2026-04-20 13:19 ` [PATCH AUTOSEL 6.18] net: txgbe: leave space for null terminators on property_entry Sasha Levin
2026-04-20 13:19 ` [PATCH AUTOSEL 7.0-5.10] net: initialize sk_rx_queue_mapping in sk_clone() Sasha Levin
2026-04-20 13:19 ` [PATCH AUTOSEL 7.0-6.19] gve: Advertise NETIF_F_GRO_HW instead of NETIF_F_LRO Sasha Levin
2026-04-20 13:19 ` [PATCH AUTOSEL 6.18] netfilter: conntrack: add missing netlink policy validations Sasha Levin
2026-04-20 13:19 ` [PATCH AUTOSEL 6.18] rtnetlink: add missing netlink_ns_capable() check for peer netns Sasha Levin
2026-04-20 13:19 ` [PATCH AUTOSEL 6.18] ipv6: ioam: fix potential NULL dereferences in __ioam6_fill_trace_data() Sasha Levin
2026-04-20 13:20 ` [PATCH AUTOSEL 7.0-6.1] net: sched: cls_u32: Avoid memcpy() false-positive warning in u32_init_knode() Sasha Levin
2026-04-20 13:20 ` [PATCH AUTOSEL 6.18] xsk: respect tailroom for ZC setups Sasha Levin
2026-04-20 13:20 ` [PATCH AUTOSEL 7.0-6.18] tcp: use WRITE_ONCE() for tsoffset in tcp_v6_connect() Sasha Levin
2026-04-20 13:20 ` [PATCH AUTOSEL 6.18] net: mdio: realtek-rtl9300: use scoped device_for_each_child_node loop Sasha Levin
2026-04-20 13:20 ` [PATCH AUTOSEL 7.0-6.12] net: ethernet: mtk_eth_soc: avoid writing to ESW registers on MT7628 Sasha Levin
2026-04-20 13:20 ` [PATCH AUTOSEL 6.18] ipvs: fix NULL deref in ip_vs_add_service error path Sasha Levin
2026-04-20 13:20 ` [PATCH AUTOSEL 7.0-6.18] net: hsr: emit notification for PRP slave2 changed hw addr on port deletion Sasha Levin
2026-04-20 13:20 ` [PATCH AUTOSEL 7.0-5.10] net: hamradio: scc: validate bufsize in SIOCSCCSMEM ioctl Sasha Levin
2026-04-20 13:20 ` [PATCH AUTOSEL 6.18] xfrm: account XFRMA_IF_ID in aevent size calculation Sasha Levin
2026-04-20 13:20 ` [PATCH AUTOSEL 6.18] netfilter: nft_set_pipapo_avx2: don't return non-matching entry on expiry Sasha Levin
2026-04-20 13:20 ` [PATCH AUTOSEL 6.18] bridge: guard local VLAN-0 FDB helpers against NULL vlan group Sasha Levin
2026-04-20 13:21 ` [PATCH AUTOSEL 7.0-5.10] net: hamradio: bpqether: validate frame length in bpq_rcv() Sasha Levin
2026-04-20 13:21 ` [PATCH AUTOSEL 6.18] netfilter: ctnetlink: ensure safe access to master conntrack Sasha Levin
2026-04-20 13:21 ` [PATCH AUTOSEL 7.0-6.18] hinic3: Add msg_send_lock for message sending concurrecy Sasha Levin
2026-04-20 13:21 ` [PATCH AUTOSEL 7.0] netfilter: require Ethernet MAC header before using eth_hdr() Sasha Levin
2026-04-20 13:21 ` [PATCH AUTOSEL 6.18] net: sched: act_csum: validate nested VLAN headers Sasha Levin
2026-04-20 13:21 ` [PATCH AUTOSEL 6.18] net: ipa: fix GENERIC_CMD register field masks for IPA v5.0+ Sasha Levin
2026-04-20 13:21 ` [PATCH AUTOSEL 6.18] dt-bindings: net: Fix Tegra234 MGBE PTP clock Sasha Levin
2026-04-20 13:21 ` [PATCH AUTOSEL 6.18] net: ioam6: fix OOB and missing lock Sasha Levin
2026-04-20 13:21 ` [PATCH AUTOSEL 6.18] ipv4: icmp: fix null-ptr-deref in icmp_build_probe() Sasha Levin
2026-04-20 13:21 ` [PATCH AUTOSEL 6.18] nfc: s3fwrn5: allocate rx skb before consuming bytes Sasha Levin
2026-04-20 13:21 ` [PATCH AUTOSEL 6.18] xsk: validate MTU against usable frame size on bind Sasha Levin
2026-04-20 13:21 ` [PATCH AUTOSEL 6.18] xfrm_user: fix info leak in build_mapping() Sasha Levin
2026-04-20 13:22 ` [PATCH AUTOSEL 6.18] net: lapbether: handle NETDEV_PRE_TYPE_CHANGE Sasha Levin
2026-04-20 13:22 ` [PATCH AUTOSEL 6.18] net: airoha: Fix memory leak in airoha_qdma_rx_process() Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260420132314.1023554-156-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=fmancera@suse.de \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=patches@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox