[PATCH net-next 1/1] driver: ipvlan: Add the sanity check for ipvlan mode

Subsystems: networking drivers, the rest

STALE3538d

2 messages, 2 authors, 2016-11-28 · open the first message on its own page

[PATCH net-next 1/1] driver: ipvlan: Add the sanity check for ipvlan mode

From: <hidden>
Date: 2016-11-28 13:25:27

From: Gao Feng <redacted>

The ipvlan mode variable "nval" is from userspace, so the ipvlan codes
should check if the mode variable "nval" is valid.

Signed-off-by: Gao Feng <redacted>
---
 drivers/net/ipvlan/ipvlan_main.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
index ab90b22..537b5a9 100644
--- a/drivers/net/ipvlan/ipvlan_main.c
+++ b/drivers/net/ipvlan/ipvlan_main.c
@@ -65,6 +65,9 @@ static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval)
 	struct net_device *mdev = port->dev;
 	int err = 0;
 
+	if (nval >= IPVLAN_MODE_MAX)
+		return -EINVAL;
+
 	ASSERT_RTNL();
 	if (port->mode != nval) {
 		if (nval == IPVLAN_MODE_L3S) {
-- 
1.9.1

Re: [PATCH net-next 1/1] driver: ipvlan: Add the sanity check for ipvlan mode

From: Mahesh Bandewar (महेश बंडेवार) <hidden>
Date: 2016-11-28 19:08:24

On Mon, Nov 28, 2016 at 5:23 AM,  [off-list ref] wrote:
quoted hunk
From: Gao Feng <redacted>

The ipvlan mode variable "nval" is from userspace, so the ipvlan codes
should check if the mode variable "nval" is valid.

Signed-off-by: Gao Feng <redacted>
---
 drivers/net/ipvlan/ipvlan_main.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
index ab90b22..537b5a9 100644
--- a/drivers/net/ipvlan/ipvlan_main.c
+++ b/drivers/net/ipvlan/ipvlan_main.c
@@ -65,6 +65,9 @@ static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval)
        struct net_device *mdev = port->dev;
        int err = 0;

+       if (nval >= IPVLAN_MODE_MAX)
+               return -EINVAL;
+
I'm curious to know how you encountered this issue? The values are
validated in ipvlan_nl_validate() and it should fail at that time
itself.
        ASSERT_RTNL();
        if (port->mode != nval) {
                if (nval == IPVLAN_MODE_L3S) {
--
1.9.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help