Netdev List
 help / color / mirror / Atom feed
* [PATCH] devinet_ioctl(): Set ret to 0 when breaking out of the switch-case
@ 2018-01-29  4:48 Christoph Paasch
  2018-01-29  5:16 ` Christoph Paasch
  0 siblings, 1 reply; 2+ messages in thread
From: Christoph Paasch @ 2018-01-29  4:48 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Al Viro, Christoph Hellwig

Commit 03aef17bb79b ("devinet_ioctl(): take copyin/copyout to caller")
introduced a regression when using ifconfig. ifconfig doesn't show the
address anymore. The reason is that the above patch changed the flow in
devinet_ioctl(), where we break; and end up returning ret. ret however
is set to -EADDRNOTAVAIL, which later on prevents the copy_to_user() in
inet_ioctl().

Thus, when we break in devinet_ioctl() we have to set ret to 0 to
properly return out of devinet_ioctl.

Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>
Fixes: 03aef17bb79b ("devinet_ioctl(): take copyin/copyout to caller")
Signed-off-by: Christoph Paasch <cpaasch@apple.com>
---
 net/ipv4/devinet.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index e056c0067f2c..942dbc73def0 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1049,18 +1049,22 @@ int devinet_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr)
 	switch (cmd) {
 	case SIOCGIFADDR:	/* Get interface address */
 		sin->sin_addr.s_addr = ifa->ifa_local;
+		ret = 0;
 		break;
 
 	case SIOCGIFBRDADDR:	/* Get the broadcast address */
 		sin->sin_addr.s_addr = ifa->ifa_broadcast;
+		ret = 0;
 		break;
 
 	case SIOCGIFDSTADDR:	/* Get the destination address */
 		sin->sin_addr.s_addr = ifa->ifa_address;
+		ret = 0;
 		break;
 
 	case SIOCGIFNETMASK:	/* Get the netmask for the interface */
 		sin->sin_addr.s_addr = ifa->ifa_mask;
+		ret = 0;
 		break;
 
 	case SIOCSIFFLAGS:
-- 
2.16.1

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

* Re: [PATCH] devinet_ioctl(): Set ret to 0 when breaking out of the switch-case
  2018-01-29  4:48 [PATCH] devinet_ioctl(): Set ret to 0 when breaking out of the switch-case Christoph Paasch
@ 2018-01-29  5:16 ` Christoph Paasch
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Paasch @ 2018-01-29  5:16 UTC (permalink / raw)
  To: Christoph Paasch; +Cc: David Miller, netdev, Al Viro, Christoph Hellwig

On Sun, Jan 28, 2018 at 8:48 PM, Christoph Paasch <cpaasch@apple.com> wrote:
> Commit 03aef17bb79b ("devinet_ioctl(): take copyin/copyout to caller")
> introduced a regression when using ifconfig. ifconfig doesn't show the
> address anymore. The reason is that the above patch changed the flow in
> devinet_ioctl(), where we break; and end up returning ret. ret however
> is set to -EADDRNOTAVAIL, which later on prevents the copy_to_user() in
> inet_ioctl().
>
> Thus, when we break in devinet_ioctl() we have to set ret to 0 to
> properly return out of devinet_ioctl.
>
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Cc: Christoph Hellwig <hch@lst.de>
> Fixes: 03aef17bb79b ("devinet_ioctl(): take copyin/copyout to caller")
> Signed-off-by: Christoph Paasch <cpaasch@apple.com>
> ---
>  net/ipv4/devinet.c | 4 ++++
>  1 file changed, 4 insertions(+)

Oh, I hadn't seen that a fix was already posted this morning at
https://patchwork.ozlabs.org/patch/866817/.

You can disregard this patch here. Sorry for the noise.


Christoph

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

end of thread, other threads:[~2018-01-29  5:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-29  4:48 [PATCH] devinet_ioctl(): Set ret to 0 when breaking out of the switch-case Christoph Paasch
2018-01-29  5:16 ` Christoph Paasch

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