Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1692068 > unrolled thread
| Started by | Colin King <colin.king@canonical.com> |
|---|---|
| First post | 2017-07-19 19:50 +0200 |
| Last post | 2017-07-20 07:50 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] net: tehuti: don't process data if it has not been copied from userspace Colin King <colin.king@canonical.com> - 2017-07-19 19:50 +0200
Re: [PATCH] net: tehuti: don't process data if it has not been copied from userspace David Miller <davem@davemloft.net> - 2017-07-20 07:50 +0200
| From | Colin King <colin.king@canonical.com> |
|---|---|
| Date | 2017-07-19 19:50 +0200 |
| Subject | [PATCH] net: tehuti: don't process data if it has not been copied from userspace |
| Message-ID | <u51gK-3tP-21@gated-at.bofh.it> |
From: Colin Ian King <colin.king@canonical.com>
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>
---
drivers/net/ethernet/tehuti/tehuti.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/tehuti/tehuti.c b/drivers/net/ethernet/tehuti/tehuti.c
index 711fbbbc4b1f..163d8d16bc24 100644
--- a/drivers/net/ethernet/tehuti/tehuti.c
+++ b/drivers/net/ethernet/tehuti/tehuti.c
@@ -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))
--
2.11.0
[toc] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2017-07-20 07:50 +0200 |
| Subject | Re: [PATCH] net: tehuti: don't process data if it has not been copied from userspace |
| Message-ID | <u5cvv-2QZ-5@gated-at.bofh.it> |
| In reply to | #1692068 |
From: Colin King <colin.king@canonical.com>
Date: Wed, 19 Jul 2017 18:46:59 +0100
> From: Colin Ian King <colin.king@canonical.com>
>
> 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>
Yeah this is the safest change for now, applied.
Francois added the register address range checking a year after the
driver was added, so maybe someone used this facility.
It should have been done via ethtool getregs...
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web