Skip to contentSkip to conversation

macvlan: validate flags

PATCH In review Michael S. Tsirkin 2 participants 2 messages Aug 5, 2013

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

PATCH v3 1/1 macvlan: validate flags

commit df8ef8f3aaa6692970a436204c4429210addb23a
macvlan: add FDB bridge ops and macvlan flags
added a flags field to macvlan, which can be controlled from userspace.
The idea is to make the interface future-proof so we can add flags and not new fields.

However, flags value isn't validated, as a result, userspace can't detect which flags are supported.

Cc "David S. Miller" <[email protected]>
Cc John Fastabend <[email protected]>

---

Changes from v2:
drop chunk in macvlan_common_newlink -
not necessary since macvlan_validate is always called first
Changes from v1:
tweaked commit message
no code changes

Please consider this patch for -stable.

The idea is by the time we add more flags, everyone has updated to a kernel that detects errors, so userspace will be able to detect supported flags cleanly.

 drivers/net/macvlan.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/macvlan.c +4 -0
index 18373b6..8445a94 100644
@@ -736,6 +736,10 @@ static int macvlan_validate(struct nlattr *tb[], struct nlattr *data[])
 			return -EADDRNOTAVAIL;
 	}
 
+	if (data && data[IFLA_MACVLAN_FLAGS] &&
+	    nla_get_u16(data[IFLA_MACVLAN_FLAGS]) & ~MACVLAN_FLAG_NOPROMISC)
+		return -EINVAL;
+
 	if (data && data[IFLA_MACVLAN_MODE]) {
 		switch (nla_get_u32(data[IFLA_MACVLAN_MODE])) {
 		case MACVLAN_MODE_PRIVATE:
Signature · 1 line
MST
maintainer
#1 lore raw

From: "Michael S. Tsirkin" <[email protected]>
Date: Mon, 5 Aug 2013 18:25:54 +0300

Quoted 7 lines

commit df8ef8f3aaa6692970a436204c4429210addb23a
macvlan: add FDB bridge ops and macvlan flags
added a flags field to macvlan, which can be controlled from userspace.
The idea is to make the interface future-proof so we can add flags and not new fields.

Quoted 6 lines

However, flags value isn't validated, as a result, userspace can't detect which flags are supported.

Cc "David S. Miller" <[email protected]>
Cc John Fastabend <[email protected]>

Applied and queued up for -stable, thanks.