public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: vt6655: preserve address space by not casting
@ 2014-06-13 10:11 Martin Kepplinger
  2014-06-16  7:55 ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Martin Kepplinger @ 2014-06-13 10:11 UTC (permalink / raw)
  To: gregkh; +Cc: forest, devel, linux-kernel, Martin Kepplinger

Fix the sparse error: cast removes address space of expression.
---
Is that even correct? I haven't signed-off on it yet.
ethtool_ioctl() takes a (void *) as user data, dereferenced and assigend to u32.
applies to next-20140611

 drivers/staging/vt6655/device_main.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index 1d3908d..15b2ee5 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -3067,7 +3067,7 @@ static int  device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {
 		break;
 
 	case SIOCETHTOOL:
-		return ethtool_ioctl(dev, (void *)rq->ifr_data);
+		return ethtool_ioctl(dev, &rq->ifr_data);
 		// All other calls are currently unsupported
 
 	default:
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: vt6655: preserve address space by not casting
  2014-06-13 10:11 [PATCH] staging: vt6655: preserve address space by not casting Martin Kepplinger
@ 2014-06-16  7:55 ` Dan Carpenter
  2014-06-17 12:32   ` [PATCH v2] staging: vt6655: preserve address space in ethtool_ioctl() Martin Kepplinger
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2014-06-16  7:55 UTC (permalink / raw)
  To: Martin Kepplinger; +Cc: gregkh, devel, forest, linux-kernel

On Fri, Jun 13, 2014 at 12:11:51PM +0200, Martin Kepplinger wrote:
> Fix the sparse error: cast removes address space of expression.
> ---
> Is that even correct?

It's correct but not complete.

vt6655 impliment their own versions of ethtool_ioctl() when they should
be using the standard versions.

The vt6655 version of ethtool_ioctl() should be annotated so it's marked
that the second parameter is marked as a __user pointer.  It doesn't
print a Sparse warning because at a certain point Sparse just says:
"warning: too many warnings" and gives up.

> I haven't signed-off on it yet.
> ethtool_ioctl() takes a (void *) as user data, dereferenced and assigend to u32.
> applies to next-20140611

It doesn't dereference the pointer.  You are getting mixed up with the
vt6656 version of ethtool_ioctl() I think?  You're not allowed to
dereference __user pointers.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] staging: vt6655: preserve address space in ethtool_ioctl()
  2014-06-16  7:55 ` Dan Carpenter
@ 2014-06-17 12:32   ` Martin Kepplinger
  2014-06-17 12:40     ` [PATCH v3] " Martin Kepplinger
  0 siblings, 1 reply; 5+ messages in thread
From: Martin Kepplinger @ 2014-06-17 12:32 UTC (permalink / raw)
  To: dan.carpenter; +Cc: gregkh, devel, forest, linux-kernel, Martin Kepplinger

Fix the sparse error: cast removes address space of expression and
add __user annotation to the driver's ethtool_ioctl().

Signed-off-by: Martin Kepplinger <martink@posteo.de>
---
Beyond that, how would you include socket.c's ethtool_ioctl() here?

thanks for looking at these tiny changes.

 drivers/staging/vt6655/device_main.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index 1d3908d..740690e 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -3067,7 +3067,7 @@ static int  device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {
 		break;
 
 	case SIOCETHTOOL:
-		return ethtool_ioctl(dev, (void *)rq->ifr_data);
+		return ethtool_ioctl(dev, &rq->ifr_data);
 		// All other calls are currently unsupported
 
 	default:
@@ -3103,7 +3103,7 @@ static int  device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {
 	return rc;
 }
 
-static int ethtool_ioctl(struct net_device *dev, void *useraddr)
+static int ethtool_ioctl(struct net_device *dev, void __user *useraddr)
 {
 	u32 ethcmd;
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v3] staging: vt6655: preserve address space in ethtool_ioctl()
  2014-06-17 12:32   ` [PATCH v2] staging: vt6655: preserve address space in ethtool_ioctl() Martin Kepplinger
@ 2014-06-17 12:40     ` Martin Kepplinger
  2014-06-19 23:37       ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Martin Kepplinger @ 2014-06-17 12:40 UTC (permalink / raw)
  To: dan.carpenter; +Cc: gregkh, devel, forest, linux-kernel, Martin Kepplinger

Fix the sparse error: cast removes address space of expression and
add __user annotation to the driver's ethtool_ioctl().

Signed-off-by: Martin Kepplinger <martink@posteo.de>
---
I think I forgot to change the declaration on top.

 drivers/staging/vt6655/device_main.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index 1d3908d..81c9932 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -302,7 +302,7 @@ static int  device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev);
 //2008-0714<Add>by Mike Liu
 static bool device_release_WPADEV(PSDevice pDevice);
 
-static int  ethtool_ioctl(struct net_device *dev, void *useraddr);
+static int  ethtool_ioctl(struct net_device *dev, void __user *useraddr);
 static int  device_rx_srv(PSDevice pDevice, unsigned int uIdx);
 static int  device_tx_srv(PSDevice pDevice, unsigned int uIdx);
 static bool device_alloc_rx_buf(PSDevice pDevice, PSRxDesc pDesc);
@@ -3067,7 +3067,7 @@ static int  device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {
 		break;
 
 	case SIOCETHTOOL:
-		return ethtool_ioctl(dev, (void *)rq->ifr_data);
+		return ethtool_ioctl(dev, &rq->ifr_data);
 		// All other calls are currently unsupported
 
 	default:
@@ -3103,7 +3103,7 @@ static int  device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {
 	return rc;
 }
 
-static int ethtool_ioctl(struct net_device *dev, void *useraddr)
+static int ethtool_ioctl(struct net_device *dev, void __user *useraddr)
 {
 	u32 ethcmd;
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] staging: vt6655: preserve address space in ethtool_ioctl()
  2014-06-17 12:40     ` [PATCH v3] " Martin Kepplinger
@ 2014-06-19 23:37       ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2014-06-19 23:37 UTC (permalink / raw)
  To: Martin Kepplinger; +Cc: dan.carpenter, devel, forest, linux-kernel

On Tue, Jun 17, 2014 at 02:40:27PM +0200, Martin Kepplinger wrote:
> Fix the sparse error: cast removes address space of expression and
> add __user annotation to the driver's ethtool_ioctl().
> 
> Signed-off-by: Martin Kepplinger <martink@posteo.de>
> ---
> I think I forgot to change the declaration on top.

Someone else did this change just before you did, sorry :(


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-06-19 23:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-13 10:11 [PATCH] staging: vt6655: preserve address space by not casting Martin Kepplinger
2014-06-16  7:55 ` Dan Carpenter
2014-06-17 12:32   ` [PATCH v2] staging: vt6655: preserve address space in ethtool_ioctl() Martin Kepplinger
2014-06-17 12:40     ` [PATCH v3] " Martin Kepplinger
2014-06-19 23:37       ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox