* return 0 when MSG_OOB in ping_recvmsg
@ 2012-02-21 22:50 Dave Jones
2012-02-21 22:59 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Dave Jones @ 2012-02-21 22:50 UTC (permalink / raw)
To: netdev
If a packet causes the 'if (flags & MSG_OOB)' test this function does first
thing is true, it returns an uninitialised variable from the stack.
There may be a better return code for this failure, but returning
'0 bytes copied' seems better than just returning garbage.
Signed-off-by: Dave Jones <davej@redhat.com>
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index aea5a19..0823562 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -626,7 +626,7 @@ static int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
struct inet_sock *isk = inet_sk(sk);
struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;
struct sk_buff *skb;
- int copied, err;
+ int copied, err = 0;
pr_debug("ping_recvmsg(sk=%p,sk->num=%u)\n", isk, isk->inet_num);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: return 0 when MSG_OOB in ping_recvmsg
2012-02-21 22:50 return 0 when MSG_OOB in ping_recvmsg Dave Jones
@ 2012-02-21 22:59 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2012-02-21 22:59 UTC (permalink / raw)
To: davej; +Cc: netdev
From: Dave Jones <davej@redhat.com>
Date: Tue, 21 Feb 2012 17:50:59 -0500
> If a packet causes the 'if (flags & MSG_OOB)' test this function does first
> thing is true, it returns an uninitialised variable from the stack.
>
> There may be a better return code for this failure, but returning
> '0 bytes copied' seems better than just returning garbage.
>
> Signed-off-by: Dave Jones <davej@redhat.com>
It should return something initialized, for sure, but more appropriate
is -EOPNOTSUPP as is consistent with this file's sendsmg() implementation
as well as the sendmsg and recvmsg methods from net/ipv4/raw.c upon which
these were modelled.
So that's the change I'll commit, thanks Dave!
--------------------
ipv4: ping: Fix recvmsg MSG_OOB error handling.
Don't return an uninitialized variable as the error, return
-EOPNOTSUPP instead.
Reported-by: Dave Jones <davej@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
net/ipv4/ping.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index aea5a19..b072386 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -630,6 +630,7 @@ static int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
pr_debug("ping_recvmsg(sk=%p,sk->num=%u)\n", isk, isk->inet_num);
+ err = -EOPNOTSUPP;
if (flags & MSG_OOB)
goto out;
--
1.7.7.6
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-02-21 22:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-21 22:50 return 0 when MSG_OOB in ping_recvmsg Dave Jones
2012-02-21 22:59 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).