* [PATCH 2/10] Fix leaking of kernel heap addresses in net/
@ 2010-11-12 1:06 Dan Rosenberg
2010-11-12 1:17 ` Stephen Hemminger
2010-11-12 15:09 ` Ben Hutchings
0 siblings, 2 replies; 5+ messages in thread
From: Dan Rosenberg @ 2010-11-12 1:06 UTC (permalink / raw)
To: David S. Miller, Oliver Hartkopp, Alexey Kuznetsov, Urs Thuermann,
Hideaki
diff --git a/net/can/bcm.c b/net/can/bcm.c
index 08ffe9e..5960ad7 100644
--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -165,9 +165,16 @@ static int bcm_proc_show(struct seq_file *m, void *v)
struct bcm_sock *bo = bcm_sk(sk);
struct bcm_op *op;
- seq_printf(m, ">>> socket %p", sk->sk_socket);
- seq_printf(m, " / sk %p", sk);
- seq_printf(m, " / bo %p", bo);
+ /* Only expose kernel addresses to privileged readers */
+ if (capable(CAP_NET_ADMIN))
+ seq_printf(m, ">>> socket %p", sk->sk_socket);
+ seq_printf(m, " / sk %p", sk);
+ seq_printf(m, " / bo %p", bo);
+ else
+ seq_printf(m, ">>> socket %lu", sock_i_ino(sk));
+ seq_printf(m, " / sk %d", 0);
+ seq_printf(m, " / bo %d", 0);
+
seq_printf(m, " / dropped %lu", bo->dropped_usr_msgs);
seq_printf(m, " / bound %s", bcm_proc_getifname(ifname, bo->ifindex));
seq_printf(m, " <<<\n");
@@ -1520,8 +1527,8 @@ static int bcm_connect(struct socket *sock, struct sockaddr *uaddr, int len,
bo->bound = 1;
if (proc_dir) {
- /* unique socket address as filename */
- sprintf(bo->procname, "%p", sock);
+ /* unique socket inode as filename */
+ sprintf(bo->procname, "%lx", sock_i_ino(sk));
bo->bcm_proc_read = proc_create_data(bo->procname, 0644,
proc_dir,
&bcm_proc_fops, sk);
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/10] Fix leaking of kernel heap addresses in net/
2010-11-12 1:06 [PATCH 2/10] Fix leaking of kernel heap addresses in net/ Dan Rosenberg
@ 2010-11-12 1:17 ` Stephen Hemminger
2010-11-12 1:22 ` Dan Rosenberg
2010-11-12 15:09 ` Ben Hutchings
1 sibling, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2010-11-12 1:17 UTC (permalink / raw)
To: Dan Rosenberg
Cc: David S. Miller, Oliver Hartkopp, Alexey Kuznetsov, Urs Thuermann,
Hideaki YOSHIFUJI, Patrick McHardy, James Morris,
Remi Denis-Courmont, Pekka Savola (ipv6), Sridhar Samudrala,
Vlad Yasevich, Tejun Heo, Eric Dumazet, Li Zefan, Joe Perches,
Jamal Hadi Salim, Eric W. Biederman, Alexey Dobriyan, Jiri Pirko,
Johannes Berg, Daniel Lezcano, Pavel Emelyanov, socketcan-core
On Thu, 11 Nov 2010 20:06:59 -0500
Dan Rosenberg <drosenberg@vsecurity.com> wrote:
> diff --git a/net/can/bcm.c b/net/can/bcm.c
> index 08ffe9e..5960ad7 100644
> --- a/net/can/bcm.c
> +++ b/net/can/bcm.c
> @@ -165,9 +165,16 @@ static int bcm_proc_show(struct seq_file *m, void *v)
> struct bcm_sock *bo = bcm_sk(sk);
> struct bcm_op *op;
>
> - seq_printf(m, ">>> socket %p", sk->sk_socket);
> - seq_printf(m, " / sk %p", sk);
> - seq_printf(m, " / bo %p", bo);
> + /* Only expose kernel addresses to privileged readers */
> + if (capable(CAP_NET_ADMIN))
> + seq_printf(m, ">>> socket %p", sk->sk_socket);
> + seq_printf(m, " / sk %p", sk);
> + seq_printf(m, " / bo %p", bo);
> + else
> + seq_printf(m, ">>> socket %lu", sock_i_ino(sk));
> + seq_printf(m, " / sk %d", 0);
> + seq_printf(m, " / bo %d", 0);
> +
Printing different data based on security state seems like an ABI
nightmare.
--
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/10] Fix leaking of kernel heap addresses in net/
2010-11-12 1:17 ` Stephen Hemminger
@ 2010-11-12 1:22 ` Dan Rosenberg
0 siblings, 0 replies; 5+ messages in thread
From: Dan Rosenberg @ 2010-11-12 1:22 UTC (permalink / raw)
To: Stephen Hemminger
Cc: David S. Miller, Oliver Hartkopp, Alexey Kuznetsov, Urs Thuermann,
Hideaki YOSHIFUJI, Patrick McHardy, James Morris,
Remi Denis-Courmont, Pekka Savola (ipv6), Sridhar Samudrala,
Vlad Yasevich, Tejun Heo, Eric Dumazet, Li Zefan, Joe Perches,
Jamal Hadi Salim, Eric W. Biederman, Alexey Dobriyan, Jiri Pirko,
Johannes Berg, Daniel Lezcano, Pavel Emelyanov, socketcan-core
>
> Printing different data based on security state seems like an ABI
> nightmare.
>
I can't remove the data entirely, because that would seriously break the
ABI. I deliberately kept the same format so as not to break any
userspace programs relying on consistent output - are there really
programs that would break when they read a 0 instead of an address?
-Dan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/10] Fix leaking of kernel heap addresses in net/
2010-11-12 1:06 [PATCH 2/10] Fix leaking of kernel heap addresses in net/ Dan Rosenberg
2010-11-12 1:17 ` Stephen Hemminger
@ 2010-11-12 15:09 ` Ben Hutchings
2010-11-12 15:11 ` Dan Rosenberg
1 sibling, 1 reply; 5+ messages in thread
From: Ben Hutchings @ 2010-11-12 15:09 UTC (permalink / raw)
To: Dan Rosenberg
Cc: David S. Miller, Oliver Hartkopp, Alexey Kuznetsov, Urs Thuermann,
Hideaki YOSHIFUJI, Patrick McHardy, James Morris,
Remi Denis-Courmont, Pekka Savola (ipv6), Sridhar Samudrala,
Vlad Yasevich, Tejun Heo, Eric Dumazet, Li Zefan, Joe Perches,
Stephen Hemminger, Jamal Hadi Salim, Eric W. Biederman,
Alexey Dobriyan, Jiri Pirko, Johannes Berg, Daniel Lezcano,
Pavel
On Thu, 2010-11-11 at 20:06 -0500, Dan Rosenberg wrote:
> diff --git a/net/can/bcm.c b/net/can/bcm.c
> index 08ffe9e..5960ad7 100644
> --- a/net/can/bcm.c
> +++ b/net/can/bcm.c
[...]
> + seq_printf(m, ">>> socket %lu", sock_i_ino(sk));
Why decimal here...
[...]
> + /* unique socket inode as filename */
> + sprintf(bo->procname, "%lx", sock_i_ino(sk));
...and hexadecimal here?
Ben.
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/10] Fix leaking of kernel heap addresses in net/
2010-11-12 15:09 ` Ben Hutchings
@ 2010-11-12 15:11 ` Dan Rosenberg
0 siblings, 0 replies; 5+ messages in thread
From: Dan Rosenberg @ 2010-11-12 15:11 UTC (permalink / raw)
To: Ben Hutchings
Cc: David S. Miller, Oliver Hartkopp, Alexey Kuznetsov, Urs Thuermann,
Hideaki YOSHIFUJI, Patrick McHardy, James Morris,
Remi Denis-Courmont, Pekka Savola (ipv6), Sridhar Samudrala,
Vlad Yasevich, Tejun Heo, Eric Dumazet, Li Zefan, Joe Perches,
Stephen Hemminger, Jamal Hadi Salim, Eric W. Biederman,
Alexey Dobriyan, Jiri Pirko, Johannes Berg, Daniel Lezcano,
Pavel
> On Thu, 2010-11-11 at 20:06 -0500, Dan Rosenberg wrote:
> > diff --git a/net/can/bcm.c b/net/can/bcm.c
> > index 08ffe9e..5960ad7 100644
> > --- a/net/can/bcm.c
> > +++ b/net/can/bcm.c
> [...]
> > + seq_printf(m, ">>> socket %lu", sock_i_ino(sk));
>
> Why decimal here...
>
> [...]
> > + /* unique socket inode as filename */
> > + sprintf(bo->procname, "%lx", sock_i_ino(sk));
>
> ...and hexadecimal here?
>
> Ben.
>
You're right, it should be consistent. I avoided decimal in the /proc
filename because it may be too long - the next version will do the same
for the seq_print output.
-Dan
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-11-12 15:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-12 1:06 [PATCH 2/10] Fix leaking of kernel heap addresses in net/ Dan Rosenberg
2010-11-12 1:17 ` Stephen Hemminger
2010-11-12 1:22 ` Dan Rosenberg
2010-11-12 15:09 ` Ben Hutchings
2010-11-12 15:11 ` Dan Rosenberg
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).