]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
net: tehuti: don't process data if it has not been copied from userspace
authorColin Ian King <colin.king@canonical.com>
Wed, 19 Jul 2017 17:46:59 +0000 (18:46 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 20 Jul 2017 05:48:02 +0000 (22:48 -0700)
The array data is only populated with valid information from userspace
if cmd != SIOCDEVPRIVATE, other cases the array contains garbage on
the stack. The subsequent switch statement acts on a subcommand in
data[0] which could be any garbage value if cmd is SIOCDEVPRIVATE which
seems incorrect to me.  Instead, just return EOPNOTSUPP for the case
where cmd == SIOCDEVPRIVATE to avoid this issue.

As a side note, I suspect that the original intention of the code
was for this ioctl to work just for cmd == SIOCDEVPRIVATE (and the
current logic is reversed). However, I don't wont to change the current
semantics in case any userspace code relies on this existing behaviour.

Detected by CoverityScan, CID#139647 ("Uninitialized scalar variable")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/tehuti/tehuti.c

index 711fbbbc4b1f724fcebdaec80eda2eec1eef8551..163d8d16bc245b48a10390d7706b21fd603489a4 100644 (file)
@@ -654,6 +654,8 @@ static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd)
                        RET(-EFAULT);
                }
                DBG("%d 0x%x 0x%x\n", data[0], data[1], data[2]);
+       } else {
+               return -EOPNOTSUPP;
        }
 
        if (!capable(CAP_SYS_RAWIO))