All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kallsyms: don't leak address when printing symbol
@ 2017-11-09  1:50 ` Tobin C. Harding
  0 siblings, 0 replies; 15+ messages in thread
From: Tobin C. Harding @ 2017-11-09  1:50 UTC (permalink / raw)
  To: kernel-hardening
  Cc: Tobin C. Harding, Jason A. Donenfeld, Theodore Ts'o,
	Linus Torvalds, Kees Cook, Paolo Bonzini, Tycho Andersen,
	Roberts, William C, Tejun Heo, Jordan Glover, Greg KH,
	Petr Mladek, Joe Perches, Ian Campbell, Sergey Senozhatsky,
	Catalin Marinas, Will Deacon, Steven Rostedt, Chris Fries,
	Dave Weinstein, Daniel Micay, Djalal Harouni, Paul E. McKenney,
	Andy Lutomirski, Peter Zijlstra, David Miller,
	Network Development, linux-kernel

Currently if a pointer is printed using %p[ssB] and the symbol is not
found (kallsyms_lookup() fails) then we print the actual address. This
leaks kernel addresses. We should instead print something _safe_.

Print "<no-symbol>" instead of kernel address.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 kernel/kallsyms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 127e7cfafa55..182e7592be9c 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -390,7 +390,7 @@ static int __sprint_symbol(char *buffer, unsigned long address,
 	address += symbol_offset;
 	name = kallsyms_lookup(address, &size, &offset, &modname, buffer);
 	if (!name)
-		return sprintf(buffer, "0x%lx", address - symbol_offset);
+		return sprintf(buffer, "<no-symbol>");
 
 	if (name != buffer)
 		strcpy(buffer, name);
-- 
2.7.4

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

* [PATCH] kallsyms: don't leak address when printing symbol
@ 2017-11-09  1:50 ` Tobin C. Harding
  0 siblings, 0 replies; 15+ messages in thread
From: Tobin C. Harding @ 2017-11-09  1:50 UTC (permalink / raw)
  To: kernel-hardening
  Cc: Tobin C. Harding, Jason A. Donenfeld, Theodore Ts'o,
	Linus Torvalds, Kees Cook, Paolo Bonzini, Tycho Andersen,
	Roberts, William C, Tejun Heo, Jordan Glover, Greg KH,
	Petr Mladek, Joe Perches, Ian Campbell, Sergey Senozhatsky,
	Catalin Marinas, Will Deacon, Steven Rostedt, Chris Fries,
	Dave Weinstein

Currently if a pointer is printed using %p[ssB] and the symbol is not
found (kallsyms_lookup() fails) then we print the actual address. This
leaks kernel addresses. We should instead print something _safe_.

Print "<no-symbol>" instead of kernel address.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 kernel/kallsyms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 127e7cfafa55..182e7592be9c 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -390,7 +390,7 @@ static int __sprint_symbol(char *buffer, unsigned long address,
 	address += symbol_offset;
 	name = kallsyms_lookup(address, &size, &offset, &modname, buffer);
 	if (!name)
-		return sprintf(buffer, "0x%lx", address - symbol_offset);
+		return sprintf(buffer, "<no-symbol>");
 
 	if (name != buffer)
 		strcpy(buffer, name);
-- 
2.7.4

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

* [kernel-hardening] [PATCH] kallsyms: don't leak address when printing symbol
@ 2017-11-09  1:50 ` Tobin C. Harding
  0 siblings, 0 replies; 15+ messages in thread
From: Tobin C. Harding @ 2017-11-09  1:50 UTC (permalink / raw)
  To: kernel-hardening
  Cc: Tobin C. Harding, Jason A. Donenfeld, Theodore Ts'o,
	Linus Torvalds, Kees Cook, Paolo Bonzini, Tycho Andersen,
	Roberts, William C, Tejun Heo, Jordan Glover, Greg KH,
	Petr Mladek, Joe Perches, Ian Campbell, Sergey Senozhatsky,
	Catalin Marinas, Will Deacon, Steven Rostedt, Chris Fries,
	Dave Weinstein, Daniel Micay, Djalal Harouni, Paul E. McKenney,
	Andy Lutomirski, Peter Zijlstra, David Miller,
	Network Development, linux-kernel

Currently if a pointer is printed using %p[ssB] and the symbol is not
found (kallsyms_lookup() fails) then we print the actual address. This
leaks kernel addresses. We should instead print something _safe_.

Print "<no-symbol>" instead of kernel address.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 kernel/kallsyms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 127e7cfafa55..182e7592be9c 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -390,7 +390,7 @@ static int __sprint_symbol(char *buffer, unsigned long address,
 	address += symbol_offset;
 	name = kallsyms_lookup(address, &size, &offset, &modname, buffer);
 	if (!name)
-		return sprintf(buffer, "0x%lx", address - symbol_offset);
+		return sprintf(buffer, "<no-symbol>");
 
 	if (name != buffer)
 		strcpy(buffer, name);
-- 
2.7.4

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

* Re: [PATCH] kallsyms: don't leak address when printing symbol
  2017-11-09  1:50 ` Tobin C. Harding
  (?)
@ 2017-11-09  3:35   ` Steven Rostedt
  -1 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2017-11-09  3:35 UTC (permalink / raw)
  To: Tobin C. Harding
  Cc: kernel-hardening, Jason A. Donenfeld, Theodore Ts'o,
	Linus Torvalds, Kees Cook, Paolo Bonzini, Tycho Andersen,
	Roberts, William C, Tejun Heo, Jordan Glover, Greg KH,
	Petr Mladek, Joe Perches, Ian Campbell, Sergey Senozhatsky,
	Catalin Marinas, Will Deacon, Chris Fries, Dave Weinstein,
	Daniel Micay, Djalal Harouni, Paul E. McKenney, Andy Lutomirski,
	Peter Zijlstra, David Miller, Network Development, linux-kernel

On Thu,  9 Nov 2017 12:50:29 +1100
"Tobin C. Harding" <me@tobin.cc> wrote:

> Currently if a pointer is printed using %p[ssB] and the symbol is not
> found (kallsyms_lookup() fails) then we print the actual address. This
> leaks kernel addresses. We should instead print something _safe_.
> 
> Print "<no-symbol>" instead of kernel address.

Ug, ftrace requires this to work as is, as it uses it to print some
addresses that may or may not be a symbol.

If anything, can this return a success or failure if it were to find a
symbol or not, and then something like ftrace could decide to use %x if
it does not.

And yes, ftrace leaks kernel addresses all over the place, that's just
the nature of tracing the kernel.

-- Steve


> 
> Signed-off-by: Tobin C. Harding <me@tobin.cc>
> ---
>  kernel/kallsyms.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
> index 127e7cfafa55..182e7592be9c 100644
> --- a/kernel/kallsyms.c
> +++ b/kernel/kallsyms.c
> @@ -390,7 +390,7 @@ static int __sprint_symbol(char *buffer, unsigned long address,
>  	address += symbol_offset;
>  	name = kallsyms_lookup(address, &size, &offset, &modname, buffer);
>  	if (!name)
> -		return sprintf(buffer, "0x%lx", address - symbol_offset);
> +		return sprintf(buffer, "<no-symbol>");
>  
>  	if (name != buffer)
>  		strcpy(buffer, name);

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

* Re: [PATCH] kallsyms: don't leak address when printing symbol
@ 2017-11-09  3:35   ` Steven Rostedt
  0 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2017-11-09  3:35 UTC (permalink / raw)
  To: Tobin C. Harding
  Cc: kernel-hardening, Jason A. Donenfeld, Theodore Ts'o,
	Linus Torvalds, Kees Cook, Paolo Bonzini, Tycho Andersen,
	Roberts, William C, Tejun Heo, Jordan Glover, Greg KH,
	Petr Mladek, Joe Perches, Ian Campbell, Sergey Senozhatsky,
	Catalin Marinas, Will Deacon, Chris Fries, Dave Weinstein,
	Daniel Micay

On Thu,  9 Nov 2017 12:50:29 +1100
"Tobin C. Harding" <me@tobin.cc> wrote:

> Currently if a pointer is printed using %p[ssB] and the symbol is not
> found (kallsyms_lookup() fails) then we print the actual address. This
> leaks kernel addresses. We should instead print something _safe_.
> 
> Print "<no-symbol>" instead of kernel address.

Ug, ftrace requires this to work as is, as it uses it to print some
addresses that may or may not be a symbol.

If anything, can this return a success or failure if it were to find a
symbol or not, and then something like ftrace could decide to use %x if
it does not.

And yes, ftrace leaks kernel addresses all over the place, that's just
the nature of tracing the kernel.

-- Steve


> 
> Signed-off-by: Tobin C. Harding <me@tobin.cc>
> ---
>  kernel/kallsyms.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
> index 127e7cfafa55..182e7592be9c 100644
> --- a/kernel/kallsyms.c
> +++ b/kernel/kallsyms.c
> @@ -390,7 +390,7 @@ static int __sprint_symbol(char *buffer, unsigned long address,
>  	address += symbol_offset;
>  	name = kallsyms_lookup(address, &size, &offset, &modname, buffer);
>  	if (!name)
> -		return sprintf(buffer, "0x%lx", address - symbol_offset);
> +		return sprintf(buffer, "<no-symbol>");
>  
>  	if (name != buffer)
>  		strcpy(buffer, name);

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

* [kernel-hardening] Re: [PATCH] kallsyms: don't leak address when printing symbol
@ 2017-11-09  3:35   ` Steven Rostedt
  0 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2017-11-09  3:35 UTC (permalink / raw)
  To: Tobin C. Harding
  Cc: kernel-hardening, Jason A. Donenfeld, Theodore Ts'o,
	Linus Torvalds, Kees Cook, Paolo Bonzini, Tycho Andersen,
	Roberts, William C, Tejun Heo, Jordan Glover, Greg KH,
	Petr Mladek, Joe Perches, Ian Campbell, Sergey Senozhatsky,
	Catalin Marinas, Will Deacon, Chris Fries, Dave Weinstein,
	Daniel Micay, Djalal Harouni, Paul E. McKenney, Andy Lutomirski,
	Peter Zijlstra, David Miller, Network Development, linux-kernel

On Thu,  9 Nov 2017 12:50:29 +1100
"Tobin C. Harding" <me@tobin.cc> wrote:

> Currently if a pointer is printed using %p[ssB] and the symbol is not
> found (kallsyms_lookup() fails) then we print the actual address. This
> leaks kernel addresses. We should instead print something _safe_.
> 
> Print "<no-symbol>" instead of kernel address.

Ug, ftrace requires this to work as is, as it uses it to print some
addresses that may or may not be a symbol.

If anything, can this return a success or failure if it were to find a
symbol or not, and then something like ftrace could decide to use %x if
it does not.

And yes, ftrace leaks kernel addresses all over the place, that's just
the nature of tracing the kernel.

-- Steve


> 
> Signed-off-by: Tobin C. Harding <me@tobin.cc>
> ---
>  kernel/kallsyms.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
> index 127e7cfafa55..182e7592be9c 100644
> --- a/kernel/kallsyms.c
> +++ b/kernel/kallsyms.c
> @@ -390,7 +390,7 @@ static int __sprint_symbol(char *buffer, unsigned long address,
>  	address += symbol_offset;
>  	name = kallsyms_lookup(address, &size, &offset, &modname, buffer);
>  	if (!name)
> -		return sprintf(buffer, "0x%lx", address - symbol_offset);
> +		return sprintf(buffer, "<no-symbol>");
>  
>  	if (name != buffer)
>  		strcpy(buffer, name);

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

* Re: [PATCH] kallsyms: don't leak address when printing symbol
  2017-11-09  3:35   ` Steven Rostedt
  (?)
@ 2017-11-09  4:23     ` Sergey Senozhatsky
  -1 siblings, 0 replies; 15+ messages in thread
From: Sergey Senozhatsky @ 2017-11-09  4:23 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Tobin C. Harding, kernel-hardening, Jason A. Donenfeld,
	Theodore Ts'o, Linus Torvalds, Kees Cook, Paolo Bonzini,
	Tycho Andersen, Roberts, William C, Tejun Heo, Jordan Glover,
	Greg KH, Petr Mladek, Joe Perches, Ian Campbell,
	Sergey Senozhatsky, Catalin Marinas, Will Deacon, Chris Fries,
	Dave Weinstein, Daniel Micay, Djalal Harouni, Paul E. McKenney,
	Andy Lutomirski, Peter Zijlstra, David Miller,
	Network Development, linux-kernel

On (11/08/17 22:35), Steven Rostedt wrote:
> On Thu,  9 Nov 2017 12:50:29 +1100
> "Tobin C. Harding" <me@tobin.cc> wrote:
> 
> > Currently if a pointer is printed using %p[ssB] and the symbol is not
> > found (kallsyms_lookup() fails) then we print the actual address. This
> > leaks kernel addresses. We should instead print something _safe_.
> > 
> > Print "<no-symbol>" instead of kernel address.
> 
> Ug, ftrace requires this to work as is, as it uses it to print some
> addresses that may or may not be a symbol.
> 
> If anything, can this return a success or failure if it were to find a
> symbol or not, and then something like ftrace could decide to use %x if
> it does not.
> 
> And yes, ftrace leaks kernel addresses all over the place, that's just
> the nature of tracing the kernel.
> 

agree, I kinda suspect that that "0x%lx" sometimes can be useful.
at least one can tell if the frame is from modules or kernel, and
objdump it may be.

	-ss

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

* Re: [PATCH] kallsyms: don't leak address when printing symbol
@ 2017-11-09  4:23     ` Sergey Senozhatsky
  0 siblings, 0 replies; 15+ messages in thread
From: Sergey Senozhatsky @ 2017-11-09  4:23 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Tobin C. Harding, kernel-hardening, Jason A. Donenfeld,
	Theodore Ts'o, Linus Torvalds, Kees Cook, Paolo Bonzini,
	Tycho Andersen, Roberts, William C, Tejun Heo, Jordan Glover,
	Greg KH, Petr Mladek, Joe Perches, Ian Campbell,
	Sergey Senozhatsky, Catalin Marinas, Will Deacon, Chris Fries,
	Dave Weinstein

On (11/08/17 22:35), Steven Rostedt wrote:
> On Thu,  9 Nov 2017 12:50:29 +1100
> "Tobin C. Harding" <me@tobin.cc> wrote:
> 
> > Currently if a pointer is printed using %p[ssB] and the symbol is not
> > found (kallsyms_lookup() fails) then we print the actual address. This
> > leaks kernel addresses. We should instead print something _safe_.
> > 
> > Print "<no-symbol>" instead of kernel address.
> 
> Ug, ftrace requires this to work as is, as it uses it to print some
> addresses that may or may not be a symbol.
> 
> If anything, can this return a success or failure if it were to find a
> symbol or not, and then something like ftrace could decide to use %x if
> it does not.
> 
> And yes, ftrace leaks kernel addresses all over the place, that's just
> the nature of tracing the kernel.
> 

agree, I kinda suspect that that "0x%lx" sometimes can be useful.
at least one can tell if the frame is from modules or kernel, and
objdump it may be.

	-ss

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

* [kernel-hardening] Re: [PATCH] kallsyms: don't leak address when printing symbol
@ 2017-11-09  4:23     ` Sergey Senozhatsky
  0 siblings, 0 replies; 15+ messages in thread
From: Sergey Senozhatsky @ 2017-11-09  4:23 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Tobin C. Harding, kernel-hardening, Jason A. Donenfeld,
	Theodore Ts'o, Linus Torvalds, Kees Cook, Paolo Bonzini,
	Tycho Andersen, Roberts, William C, Tejun Heo, Jordan Glover,
	Greg KH, Petr Mladek, Joe Perches, Ian Campbell,
	Sergey Senozhatsky, Catalin Marinas, Will Deacon, Chris Fries,
	Dave Weinstein, Daniel Micay, Djalal Harouni, Paul E. McKenney,
	Andy Lutomirski, Peter Zijlstra, David Miller,
	Network Development, linux-kernel

On (11/08/17 22:35), Steven Rostedt wrote:
> On Thu,  9 Nov 2017 12:50:29 +1100
> "Tobin C. Harding" <me@tobin.cc> wrote:
> 
> > Currently if a pointer is printed using %p[ssB] and the symbol is not
> > found (kallsyms_lookup() fails) then we print the actual address. This
> > leaks kernel addresses. We should instead print something _safe_.
> > 
> > Print "<no-symbol>" instead of kernel address.
> 
> Ug, ftrace requires this to work as is, as it uses it to print some
> addresses that may or may not be a symbol.
> 
> If anything, can this return a success or failure if it were to find a
> symbol or not, and then something like ftrace could decide to use %x if
> it does not.
> 
> And yes, ftrace leaks kernel addresses all over the place, that's just
> the nature of tracing the kernel.
> 

agree, I kinda suspect that that "0x%lx" sometimes can be useful.
at least one can tell if the frame is from modules or kernel, and
objdump it may be.

	-ss

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

* Re: [PATCH] kallsyms: don't leak address when printing symbol
  2017-11-09  3:35   ` Steven Rostedt
  (?)
@ 2017-11-09  5:45     ` Tobin C. Harding
  -1 siblings, 0 replies; 15+ messages in thread
From: Tobin C. Harding @ 2017-11-09  5:45 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: kernel-hardening, Jason A. Donenfeld, Theodore Ts'o,
	Linus Torvalds, Kees Cook, Paolo Bonzini, Tycho Andersen,
	Roberts, William C, Tejun Heo, Jordan Glover, Greg KH,
	Petr Mladek, Joe Perches, Ian Campbell, Sergey Senozhatsky,
	Catalin Marinas, Will Deacon, Chris Fries, Dave Weinstein,
	Daniel Micay, Djalal Harouni, Paul E. McKenney, Andy Lutomirski,
	Peter Zijlstra, David Miller, Network Development, linux-kernel

On Wed, Nov 08, 2017 at 10:35:55PM -0500, Steven Rostedt wrote:
> On Thu,  9 Nov 2017 12:50:29 +1100
> "Tobin C. Harding" <me@tobin.cc> wrote:
> 
> > Currently if a pointer is printed using %p[ssB] and the symbol is not
> > found (kallsyms_lookup() fails) then we print the actual address. This
> > leaks kernel addresses. We should instead print something _safe_.
> > 
> > Print "<no-symbol>" instead of kernel address.
> 
> Ug, ftrace requires this to work as is, as it uses it to print some
> addresses that may or may not be a symbol.
> 
> If anything, can this return a success or failure if it were to find a
> symbol or not, and then something like ftrace could decide to use %x if
> it does not.

Thanks for the feed back Steve. Propagating the error back up through
the call chain may require a little bit of thought so we don't upset the
apple cart. sprint_symbol() never currently (as far as I can see)
returns an error. I can go through the other callers of sprint_symbol()
(there aren't many) and check if it is going to upset anything.

> And yes, ftrace leaks kernel addresses all over the place, that's just
> the nature of tracing the kernel.

Would it be good for you (for this change and future changes aimed at
closing leaks) if any changes like this include patches to ftrace to
maintain the current behaviour?

You have been on the CC list for the printk hashing and what not since
the start I believe so you know I'm a noob, feel free to scream bloody
murder if I'm breaching protocol.

thanks,
Tobin.

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

* Re: [PATCH] kallsyms: don't leak address when printing symbol
@ 2017-11-09  5:45     ` Tobin C. Harding
  0 siblings, 0 replies; 15+ messages in thread
From: Tobin C. Harding @ 2017-11-09  5:45 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: kernel-hardening, Jason A. Donenfeld, Theodore Ts'o,
	Linus Torvalds, Kees Cook, Paolo Bonzini, Tycho Andersen,
	Roberts, William C, Tejun Heo, Jordan Glover, Greg KH,
	Petr Mladek, Joe Perches, Ian Campbell, Sergey Senozhatsky,
	Catalin Marinas, Will Deacon, Chris Fries, Dave Weinstein,
	Daniel Micay

On Wed, Nov 08, 2017 at 10:35:55PM -0500, Steven Rostedt wrote:
> On Thu,  9 Nov 2017 12:50:29 +1100
> "Tobin C. Harding" <me@tobin.cc> wrote:
> 
> > Currently if a pointer is printed using %p[ssB] and the symbol is not
> > found (kallsyms_lookup() fails) then we print the actual address. This
> > leaks kernel addresses. We should instead print something _safe_.
> > 
> > Print "<no-symbol>" instead of kernel address.
> 
> Ug, ftrace requires this to work as is, as it uses it to print some
> addresses that may or may not be a symbol.
> 
> If anything, can this return a success or failure if it were to find a
> symbol or not, and then something like ftrace could decide to use %x if
> it does not.

Thanks for the feed back Steve. Propagating the error back up through
the call chain may require a little bit of thought so we don't upset the
apple cart. sprint_symbol() never currently (as far as I can see)
returns an error. I can go through the other callers of sprint_symbol()
(there aren't many) and check if it is going to upset anything.

> And yes, ftrace leaks kernel addresses all over the place, that's just
> the nature of tracing the kernel.

Would it be good for you (for this change and future changes aimed at
closing leaks) if any changes like this include patches to ftrace to
maintain the current behaviour?

You have been on the CC list for the printk hashing and what not since
the start I believe so you know I'm a noob, feel free to scream bloody
murder if I'm breaching protocol.

thanks,
Tobin.

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

* [kernel-hardening] Re: [PATCH] kallsyms: don't leak address when printing symbol
@ 2017-11-09  5:45     ` Tobin C. Harding
  0 siblings, 0 replies; 15+ messages in thread
From: Tobin C. Harding @ 2017-11-09  5:45 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: kernel-hardening, Jason A. Donenfeld, Theodore Ts'o,
	Linus Torvalds, Kees Cook, Paolo Bonzini, Tycho Andersen,
	Roberts, William C, Tejun Heo, Jordan Glover, Greg KH,
	Petr Mladek, Joe Perches, Ian Campbell, Sergey Senozhatsky,
	Catalin Marinas, Will Deacon, Chris Fries, Dave Weinstein,
	Daniel Micay, Djalal Harouni, Paul E. McKenney, Andy Lutomirski,
	Peter Zijlstra, David Miller, Network Development, linux-kernel

On Wed, Nov 08, 2017 at 10:35:55PM -0500, Steven Rostedt wrote:
> On Thu,  9 Nov 2017 12:50:29 +1100
> "Tobin C. Harding" <me@tobin.cc> wrote:
> 
> > Currently if a pointer is printed using %p[ssB] and the symbol is not
> > found (kallsyms_lookup() fails) then we print the actual address. This
> > leaks kernel addresses. We should instead print something _safe_.
> > 
> > Print "<no-symbol>" instead of kernel address.
> 
> Ug, ftrace requires this to work as is, as it uses it to print some
> addresses that may or may not be a symbol.
> 
> If anything, can this return a success or failure if it were to find a
> symbol or not, and then something like ftrace could decide to use %x if
> it does not.

Thanks for the feed back Steve. Propagating the error back up through
the call chain may require a little bit of thought so we don't upset the
apple cart. sprint_symbol() never currently (as far as I can see)
returns an error. I can go through the other callers of sprint_symbol()
(there aren't many) and check if it is going to upset anything.

> And yes, ftrace leaks kernel addresses all over the place, that's just
> the nature of tracing the kernel.

Would it be good for you (for this change and future changes aimed at
closing leaks) if any changes like this include patches to ftrace to
maintain the current behaviour?

You have been on the CC list for the printk hashing and what not since
the start I believe so you know I'm a noob, feel free to scream bloody
murder if I'm breaching protocol.

thanks,
Tobin.

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

* Re: [PATCH] kallsyms: don't leak address when printing symbol
  2017-11-09  5:45     ` Tobin C. Harding
  (?)
@ 2017-11-09 18:15       ` Steven Rostedt
  -1 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2017-11-09 18:15 UTC (permalink / raw)
  To: Tobin C. Harding
  Cc: kernel-hardening, Jason A. Donenfeld, Theodore Ts'o,
	Linus Torvalds, Kees Cook, Paolo Bonzini, Tycho Andersen,
	Roberts, William C, Tejun Heo, Jordan Glover, Greg KH,
	Petr Mladek, Joe Perches, Ian Campbell, Sergey Senozhatsky,
	Catalin Marinas, Will Deacon, Chris Fries, Dave Weinstein,
	Daniel Micay, Djalal Harouni, Paul E. McKenney, Andy Lutomirski,
	Peter Zijlstra, David Miller, Network Development, linux-kernel

On Thu, 9 Nov 2017 16:45:48 +1100
"Tobin C. Harding" <me@tobin.cc> wrote:

> On Wed, Nov 08, 2017 at 10:35:55PM -0500, Steven Rostedt wrote:
> > On Thu,  9 Nov 2017 12:50:29 +1100
> > "Tobin C. Harding" <me@tobin.cc> wrote:
> >   
> > > Currently if a pointer is printed using %p[ssB] and the symbol is not
> > > found (kallsyms_lookup() fails) then we print the actual address. This
> > > leaks kernel addresses. We should instead print something _safe_.
> > > 
> > > Print "<no-symbol>" instead of kernel address.  
> > 
> > Ug, ftrace requires this to work as is, as it uses it to print some
> > addresses that may or may not be a symbol.
> > 
> > If anything, can this return a success or failure if it were to find a
> > symbol or not, and then something like ftrace could decide to use %x if
> > it does not.  
> 
> Thanks for the feed back Steve. Propagating the error back up through
> the call chain may require a little bit of thought so we don't upset the
> apple cart. sprint_symbol() never currently (as far as I can see)
> returns an error. I can go through the other callers of sprint_symbol()
> (there aren't many) and check if it is going to upset anything.

As the functions are currently void, adding a return value if it
doesn't print the symbol shouldn't break anything, unless the other
users required an address as well. Which stack traces might!

> 
> > And yes, ftrace leaks kernel addresses all over the place, that's just
> > the nature of tracing the kernel.  
> 
> Would it be good for you (for this change and future changes aimed at
> closing leaks) if any changes like this include patches to ftrace to
> maintain the current behaviour?
> 
> You have been on the CC list for the printk hashing and what not since
> the start I believe so you know I'm a noob, feel free to scream bloody
> murder if I'm breaching protocol.

No, you have been fine. I've been quickly scanning your patches looking
for things like this. Please keep Ccing me. I'm currently busy fighting
other fires, but I try to at least take a quick look at patches like
this. I may not reply, but you are on my radar ;-)

-- Steve

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

* Re: [PATCH] kallsyms: don't leak address when printing symbol
@ 2017-11-09 18:15       ` Steven Rostedt
  0 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2017-11-09 18:15 UTC (permalink / raw)
  To: Tobin C. Harding
  Cc: kernel-hardening, Jason A. Donenfeld, Theodore Ts'o,
	Linus Torvalds, Kees Cook, Paolo Bonzini, Tycho Andersen,
	Roberts, William C, Tejun Heo, Jordan Glover, Greg KH,
	Petr Mladek, Joe Perches, Ian Campbell, Sergey Senozhatsky,
	Catalin Marinas, Will Deacon, Chris Fries, Dave Weinstein,
	Daniel Micay

On Thu, 9 Nov 2017 16:45:48 +1100
"Tobin C. Harding" <me@tobin.cc> wrote:

> On Wed, Nov 08, 2017 at 10:35:55PM -0500, Steven Rostedt wrote:
> > On Thu,  9 Nov 2017 12:50:29 +1100
> > "Tobin C. Harding" <me@tobin.cc> wrote:
> >   
> > > Currently if a pointer is printed using %p[ssB] and the symbol is not
> > > found (kallsyms_lookup() fails) then we print the actual address. This
> > > leaks kernel addresses. We should instead print something _safe_.
> > > 
> > > Print "<no-symbol>" instead of kernel address.  
> > 
> > Ug, ftrace requires this to work as is, as it uses it to print some
> > addresses that may or may not be a symbol.
> > 
> > If anything, can this return a success or failure if it were to find a
> > symbol or not, and then something like ftrace could decide to use %x if
> > it does not.  
> 
> Thanks for the feed back Steve. Propagating the error back up through
> the call chain may require a little bit of thought so we don't upset the
> apple cart. sprint_symbol() never currently (as far as I can see)
> returns an error. I can go through the other callers of sprint_symbol()
> (there aren't many) and check if it is going to upset anything.

As the functions are currently void, adding a return value if it
doesn't print the symbol shouldn't break anything, unless the other
users required an address as well. Which stack traces might!

> 
> > And yes, ftrace leaks kernel addresses all over the place, that's just
> > the nature of tracing the kernel.  
> 
> Would it be good for you (for this change and future changes aimed at
> closing leaks) if any changes like this include patches to ftrace to
> maintain the current behaviour?
> 
> You have been on the CC list for the printk hashing and what not since
> the start I believe so you know I'm a noob, feel free to scream bloody
> murder if I'm breaching protocol.

No, you have been fine. I've been quickly scanning your patches looking
for things like this. Please keep Ccing me. I'm currently busy fighting
other fires, but I try to at least take a quick look at patches like
this. I may not reply, but you are on my radar ;-)

-- Steve

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

* [kernel-hardening] Re: [PATCH] kallsyms: don't leak address when printing symbol
@ 2017-11-09 18:15       ` Steven Rostedt
  0 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2017-11-09 18:15 UTC (permalink / raw)
  To: Tobin C. Harding
  Cc: kernel-hardening, Jason A. Donenfeld, Theodore Ts'o,
	Linus Torvalds, Kees Cook, Paolo Bonzini, Tycho Andersen,
	Roberts, William C, Tejun Heo, Jordan Glover, Greg KH,
	Petr Mladek, Joe Perches, Ian Campbell, Sergey Senozhatsky,
	Catalin Marinas, Will Deacon, Chris Fries, Dave Weinstein,
	Daniel Micay, Djalal Harouni, Paul E. McKenney, Andy Lutomirski,
	Peter Zijlstra, David Miller, Network Development, linux-kernel

On Thu, 9 Nov 2017 16:45:48 +1100
"Tobin C. Harding" <me@tobin.cc> wrote:

> On Wed, Nov 08, 2017 at 10:35:55PM -0500, Steven Rostedt wrote:
> > On Thu,  9 Nov 2017 12:50:29 +1100
> > "Tobin C. Harding" <me@tobin.cc> wrote:
> >   
> > > Currently if a pointer is printed using %p[ssB] and the symbol is not
> > > found (kallsyms_lookup() fails) then we print the actual address. This
> > > leaks kernel addresses. We should instead print something _safe_.
> > > 
> > > Print "<no-symbol>" instead of kernel address.  
> > 
> > Ug, ftrace requires this to work as is, as it uses it to print some
> > addresses that may or may not be a symbol.
> > 
> > If anything, can this return a success or failure if it were to find a
> > symbol or not, and then something like ftrace could decide to use %x if
> > it does not.  
> 
> Thanks for the feed back Steve. Propagating the error back up through
> the call chain may require a little bit of thought so we don't upset the
> apple cart. sprint_symbol() never currently (as far as I can see)
> returns an error. I can go through the other callers of sprint_symbol()
> (there aren't many) and check if it is going to upset anything.

As the functions are currently void, adding a return value if it
doesn't print the symbol shouldn't break anything, unless the other
users required an address as well. Which stack traces might!

> 
> > And yes, ftrace leaks kernel addresses all over the place, that's just
> > the nature of tracing the kernel.  
> 
> Would it be good for you (for this change and future changes aimed at
> closing leaks) if any changes like this include patches to ftrace to
> maintain the current behaviour?
> 
> You have been on the CC list for the printk hashing and what not since
> the start I believe so you know I'm a noob, feel free to scream bloody
> murder if I'm breaching protocol.

No, you have been fine. I've been quickly scanning your patches looking
for things like this. Please keep Ccing me. I'm currently busy fighting
other fires, but I try to at least take a quick look at patches like
this. I may not reply, but you are on my radar ;-)

-- Steve

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

end of thread, other threads:[~2017-11-09 18:15 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-09  1:50 [PATCH] kallsyms: don't leak address when printing symbol Tobin C. Harding
2017-11-09  1:50 ` [kernel-hardening] " Tobin C. Harding
2017-11-09  1:50 ` Tobin C. Harding
2017-11-09  3:35 ` Steven Rostedt
2017-11-09  3:35   ` [kernel-hardening] " Steven Rostedt
2017-11-09  3:35   ` Steven Rostedt
2017-11-09  4:23   ` Sergey Senozhatsky
2017-11-09  4:23     ` [kernel-hardening] " Sergey Senozhatsky
2017-11-09  4:23     ` Sergey Senozhatsky
2017-11-09  5:45   ` Tobin C. Harding
2017-11-09  5:45     ` [kernel-hardening] " Tobin C. Harding
2017-11-09  5:45     ` Tobin C. Harding
2017-11-09 18:15     ` Steven Rostedt
2017-11-09 18:15       ` [kernel-hardening] " Steven Rostedt
2017-11-09 18:15       ` Steven Rostedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.