Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next] filter: do not output bpf image address for security reason
@ 2013-05-17 23:31 Eric Dumazet
  2013-05-17 23:42 ` Joe Perches
  2013-05-18  1:11 ` Ben Hutchings
  0 siblings, 2 replies; 8+ messages in thread
From: Eric Dumazet @ 2013-05-17 23:31 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Daniel Borkmann

From: Eric Dumazet <edumazet@google.com>

Do not leak starting address of BPF JIT code, as it might help
intruders to perform an attack.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Daniel Borkmann <dborkman@redhat.com>
---
 include/linux/filter.h |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/linux/filter.h b/include/linux/filter.h
index c050dcc..08cda1c 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -58,10 +58,11 @@ extern void bpf_jit_free(struct sk_filter *fp);
 static inline void bpf_jit_dump(unsigned int flen, unsigned int proglen,
 				u32 pass, void *image)
 {
-	pr_err("flen=%u proglen=%u pass=%u image=%p\n",
-	       flen, proglen, pass, image);
+	/* Do not output address (image) for security reason */
+	pr_err("flen=%u proglen=%u pass=%u image=10\n",
+	       flen, proglen, pass);
 	if (image)
-		print_hex_dump(KERN_ERR, "JIT code: ", DUMP_PREFIX_ADDRESS,
+		print_hex_dump(KERN_ERR, "JIT code: ", DUMP_PREFIX_OFFSET,
 			       16, 1, image, proglen, false);
 }
 #define SK_RUN_FILTER(FILTER, SKB) (*FILTER->bpf_func)(SKB, FILTER->insns)

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

* Re: [PATCH net-next] filter: do not output bpf image address for security reason
  2013-05-17 23:31 Eric Dumazet
@ 2013-05-17 23:42 ` Joe Perches
  2013-05-17 23:48   ` Eric Dumazet
  2013-05-18  1:11 ` Ben Hutchings
  1 sibling, 1 reply; 8+ messages in thread
From: Joe Perches @ 2013-05-17 23:42 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, netdev, Daniel Borkmann

On Fri, 2013-05-17 at 16:31 -0700, Eric Dumazet wrote:
> Do not leak starting address of BPF JIT code, as it might help
> intruders to perform an attack.
[]
> diff --git a/include/linux/filter.h b/include/linux/filter.h
[]
> @@ -58,10 +58,11 @@ extern void bpf_jit_free(struct sk_filter *fp);
>  static inline void bpf_jit_dump(unsigned int flen, unsigned int proglen,
>  				u32 pass, void *image)
>  {
> -	pr_err("flen=%u proglen=%u pass=%u image=%p\n",
> -	       flen, proglen, pass, image);
> +	/* Do not output address (image) for security reason */
> +	pr_err("flen=%u proglen=%u pass=%u image=10\n",
> +	       flen, proglen, pass);

[]

Are stable equivalents for versions before commit 79617801ea0
necessary?

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

* Re: [PATCH net-next] filter: do not output bpf image address for security reason
  2013-05-17 23:42 ` Joe Perches
@ 2013-05-17 23:48   ` Eric Dumazet
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Dumazet @ 2013-05-17 23:48 UTC (permalink / raw)
  To: Joe Perches; +Cc: David Miller, netdev, Daniel Borkmann

On Fri, 2013-05-17 at 16:42 -0700, Joe Perches wrote:

> Are stable equivalents for versions before commit 79617801ea0
> necessary?
> 

I do not think so.

In order to get these messages printed, the admin had to specifically do

echo 2 >/proc/sys/net/core/bpf_jit_enable

And quite frankly I doubt anybody would need to do such thing, but
netdev guys writing/patching BPF JIT

And even with these messages printed, you need some bug in the kernel
allowing an exploit.

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

* Re: [PATCH net-next] filter: do not output bpf image address for security reason
  2013-05-17 23:31 Eric Dumazet
  2013-05-17 23:42 ` Joe Perches
@ 2013-05-18  1:11 ` Ben Hutchings
  2013-05-18  1:27   ` David Miller
  2013-05-18  2:55   ` Eric Dumazet
  1 sibling, 2 replies; 8+ messages in thread
From: Ben Hutchings @ 2013-05-18  1:11 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, netdev, Daniel Borkmann

On Fri, 2013-05-17 at 16:31 -0700, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> Do not leak starting address of BPF JIT code, as it might help
> intruders to perform an attack.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Daniel Borkmann <dborkman@redhat.com>
> ---
>  include/linux/filter.h |    7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/filter.h b/include/linux/filter.h
> index c050dcc..08cda1c 100644
> --- a/include/linux/filter.h
> +++ b/include/linux/filter.h
> @@ -58,10 +58,11 @@ extern void bpf_jit_free(struct sk_filter *fp);
>  static inline void bpf_jit_dump(unsigned int flen, unsigned int proglen,
>  				u32 pass, void *image)
>  {
> -	pr_err("flen=%u proglen=%u pass=%u image=%p\n",
> -	       flen, proglen, pass, image);
> +	/* Do not output address (image) for security reason */
> +	pr_err("flen=%u proglen=%u pass=%u image=10\n",

Not "%pK"?

Ben.

> +	       flen, proglen, pass);
>  	if (image)
> -		print_hex_dump(KERN_ERR, "JIT code: ", DUMP_PREFIX_ADDRESS,
> +		print_hex_dump(KERN_ERR, "JIT code: ", DUMP_PREFIX_OFFSET,
>  			       16, 1, image, proglen, false);
>  }
>  #define SK_RUN_FILTER(FILTER, SKB) (*FILTER->bpf_func)(SKB, FILTER->insns)


-- 
Ben Hutchings, Staff Engineer, Solarflare
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] 8+ messages in thread

* Re: [PATCH net-next] filter: do not output bpf image address for security reason
  2013-05-18  1:11 ` Ben Hutchings
@ 2013-05-18  1:27   ` David Miller
  2013-05-18  2:55   ` Eric Dumazet
  1 sibling, 0 replies; 8+ messages in thread
From: David Miller @ 2013-05-18  1:27 UTC (permalink / raw)
  To: bhutchings; +Cc: eric.dumazet, netdev, dborkman

From: Ben Hutchings <bhutchings@solarflare.com>
Date: Sat, 18 May 2013 02:11:18 +0100

> On Fri, 2013-05-17 at 16:31 -0700, Eric Dumazet wrote:
>> @@ -58,10 +58,11 @@ extern void bpf_jit_free(struct sk_filter *fp);
>>  static inline void bpf_jit_dump(unsigned int flen, unsigned int proglen,
>>  				u32 pass, void *image)
>>  {
>> -	pr_err("flen=%u proglen=%u pass=%u image=%p\n",
>> -	       flen, proglen, pass, image);
>> +	/* Do not output address (image) for security reason */
>> +	pr_err("flen=%u proglen=%u pass=%u image=10\n",
> 
> Not "%pK"?

Yes, that's the acceptable way to deal with this issue.

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

* Re: [PATCH net-next] filter: do not output bpf image address for security reason
  2013-05-18  1:11 ` Ben Hutchings
  2013-05-18  1:27   ` David Miller
@ 2013-05-18  2:55   ` Eric Dumazet
  1 sibling, 0 replies; 8+ messages in thread
From: Eric Dumazet @ 2013-05-18  2:55 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: David Miller, netdev, Daniel Borkmann

On Sat, 2013-05-18 at 02:11 +0100, Ben Hutchings wrote:

> Not "%pK"?
> 

Yes, thanks for the suggestion.

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

* [PATCH net-next] filter: do not output bpf image address for security reason
@ 2013-05-18  2:57 Eric Dumazet
  2013-05-20  6:57 ` David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Dumazet @ 2013-05-18  2:57 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Ben Hutchings, Daniel Borkmann

From: Eric Dumazet <edumazet@google.com>

Do not leak starting address of BPF JIT code for non root users,
as it might help intruders to perform an attack.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Ben Hutchings <bhutchings@solarflare.com>
Cc: Daniel Borkmann <dborkman@redhat.com>
---
v2: use %pK as Ben suggestion

 include/linux/filter.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/filter.h b/include/linux/filter.h
index c050dcc..56a6b7f 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -58,10 +58,10 @@ extern void bpf_jit_free(struct sk_filter *fp);
 static inline void bpf_jit_dump(unsigned int flen, unsigned int proglen,
 				u32 pass, void *image)
 {
-	pr_err("flen=%u proglen=%u pass=%u image=%p\n",
+	pr_err("flen=%u proglen=%u pass=%u image=%pK\n",
 	       flen, proglen, pass, image);
 	if (image)
-		print_hex_dump(KERN_ERR, "JIT code: ", DUMP_PREFIX_ADDRESS,
+		print_hex_dump(KERN_ERR, "JIT code: ", DUMP_PREFIX_OFFSET,
 			       16, 1, image, proglen, false);
 }
 #define SK_RUN_FILTER(FILTER, SKB) (*FILTER->bpf_func)(SKB, FILTER->insns)

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

* Re: [PATCH net-next] filter: do not output bpf image address for security reason
  2013-05-18  2:57 [PATCH net-next] filter: do not output bpf image address for security reason Eric Dumazet
@ 2013-05-20  6:57 ` David Miller
  0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2013-05-20  6:57 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev, bhutchings, dborkman

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 17 May 2013 19:57:37 -0700

> From: Eric Dumazet <edumazet@google.com>
> 
> Do not leak starting address of BPF JIT code for non root users,
> as it might help intruders to perform an attack.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Applied.

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

end of thread, other threads:[~2013-05-20  6:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-18  2:57 [PATCH net-next] filter: do not output bpf image address for security reason Eric Dumazet
2013-05-20  6:57 ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2013-05-17 23:31 Eric Dumazet
2013-05-17 23:42 ` Joe Perches
2013-05-17 23:48   ` Eric Dumazet
2013-05-18  1:11 ` Ben Hutchings
2013-05-18  1:27   ` David Miller
2013-05-18  2:55   ` Eric Dumazet

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