* [PATCH] unix_diag: Fix incoming connections nla length
@ 2011-12-25 19:58 Pavel Emelyanov
2011-12-26 19:08 ` David Miller
2011-12-26 19:36 ` Eric Dumazet
0 siblings, 2 replies; 4+ messages in thread
From: Pavel Emelyanov @ 2011-12-25 19:58 UTC (permalink / raw)
To: David Miller, Linux Netdev List
The NLA_PUT macro should accept the actual attribute length, not
the amount of elements in array :(
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
---
net/unix/diag.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/net/unix/diag.c b/net/unix/diag.c
index 91d5782..39e44c9 100644
--- a/net/unix/diag.c
+++ b/net/unix/diag.c
@@ -72,7 +72,8 @@ static int sk_diag_dump_icons(struct sock *sk, struct sk_buff *nlskb)
if (sk->sk_state == TCP_LISTEN) {
spin_lock(&sk->sk_receive_queue.lock);
- buf = UNIX_DIAG_PUT(nlskb, UNIX_DIAG_ICONS, sk->sk_receive_queue.qlen);
+ buf = UNIX_DIAG_PUT(nlskb, UNIX_DIAG_ICONS,
+ sk->sk_receive_queue.qlen * sizeof(u32));
i = 0;
skb_queue_walk(&sk->sk_receive_queue, skb) {
struct sock *req, *peer;
--
1.5.5.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] unix_diag: Fix incoming connections nla length
2011-12-25 19:58 [PATCH] unix_diag: Fix incoming connections nla length Pavel Emelyanov
@ 2011-12-26 19:08 ` David Miller
2011-12-26 19:36 ` Eric Dumazet
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2011-12-26 19:08 UTC (permalink / raw)
To: xemul; +Cc: netdev
From: Pavel Emelyanov <xemul@parallels.com>
Date: Sun, 25 Dec 2011 23:58:05 +0400
> The NLA_PUT macro should accept the actual attribute length, not
> the amount of elements in array :(
>
> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] unix_diag: Fix incoming connections nla length
2011-12-25 19:58 [PATCH] unix_diag: Fix incoming connections nla length Pavel Emelyanov
2011-12-26 19:08 ` David Miller
@ 2011-12-26 19:36 ` Eric Dumazet
2011-12-26 19:42 ` David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2011-12-26 19:36 UTC (permalink / raw)
To: Pavel Emelyanov; +Cc: David Miller, Linux Netdev List
Le dimanche 25 décembre 2011 à 23:58 +0400, Pavel Emelyanov a écrit :
> The NLA_PUT macro should accept the actual attribute length, not
> the amount of elements in array :(
>
> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
>
> ---
> net/unix/diag.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/net/unix/diag.c b/net/unix/diag.c
> index 91d5782..39e44c9 100644
> --- a/net/unix/diag.c
> +++ b/net/unix/diag.c
> @@ -72,7 +72,8 @@ static int sk_diag_dump_icons(struct sock *sk, struct sk_buff *nlskb)
>
> if (sk->sk_state == TCP_LISTEN) {
> spin_lock(&sk->sk_receive_queue.lock);
> - buf = UNIX_DIAG_PUT(nlskb, UNIX_DIAG_ICONS, sk->sk_receive_queue.qlen);
> + buf = UNIX_DIAG_PUT(nlskb, UNIX_DIAG_ICONS,
> + sk->sk_receive_queue.qlen * sizeof(u32));
> i = 0;
> skb_queue_walk(&sk->sk_receive_queue, skb) {
> struct sock *req, *peer;
Hmm, I must say sk_diag_dump_icons() looks buggy, since it does :
if (peer)
buf[i++] = sock_i_ino(peer);
So we probably leak kernel memory content to user for the (!peer) case,
since we did :
UNIX_DIAG_PUT(nlskb, UNIX_DIAG_ICONS,
sk->sk_receive_queue.qlen * sizeof(u32));
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] unix_diag: Fix incoming connections nla length
2011-12-26 19:36 ` Eric Dumazet
@ 2011-12-26 19:42 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2011-12-26 19:42 UTC (permalink / raw)
To: eric.dumazet; +Cc: xemul, netdev
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Mon, 26 Dec 2011 20:36:12 +0100
> if (peer)
> buf[i++] = sock_i_ino(peer);
>
> So we probably leak kernel memory content to user for the (!peer) case,
> since we did :
>
> UNIX_DIAG_PUT(nlskb, UNIX_DIAG_ICONS,
> sk->sk_receive_queue.qlen * sizeof(u32));
I just commited the following fix for this, it probably takes less
effort to post a patch for this kind of bug than explain it don't
you think? :)
--------------------
unix: If we happen to find peer NULL when diag dumping, write zero.
Otherwise we leave uninitialized kernel memory in there.
Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
net/unix/diag.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/net/unix/diag.c b/net/unix/diag.c
index 39e44c9..c5bdbcb 100644
--- a/net/unix/diag.c
+++ b/net/unix/diag.c
@@ -86,8 +86,7 @@ static int sk_diag_dump_icons(struct sock *sk, struct sk_buff *nlskb)
*/
unix_state_lock_nested(req);
peer = unix_sk(req)->peer;
- if (peer)
- buf[i++] = sock_i_ino(peer);
+ buf[i++] = (peer ? sock_i_ino(peer) : 0);
unix_state_unlock(req);
}
spin_unlock(&sk->sk_receive_queue.lock);
--
1.7.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-12-26 19:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-25 19:58 [PATCH] unix_diag: Fix incoming connections nla length Pavel Emelyanov
2011-12-26 19:08 ` David Miller
2011-12-26 19:36 ` Eric Dumazet
2011-12-26 19:42 ` 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).