All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_match()
@ 2018-01-24 22:49 Eric Dumazet
  2018-01-24 23:19 ` Florian Westphal
  2018-01-24 23:49 ` [PATCH net] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_match() Pablo Neira Ayuso
  0 siblings, 2 replies; 9+ messages in thread
From: Eric Dumazet @ 2018-01-24 22:49 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netdev, netfilter-devel, Florian Westphal

From: Eric Dumazet <edumazet@google.com>

It looks like syzbot found its way into netfilter territory.

Issue here is that @name comes from user space and might
not be null terminated.

Out-of-bound reads happen, KASAN is not happy.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
---
No Fixes: tag, bug seems to be a day-0 one.

diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index 55802e97f906d1987ed78b4296584deb38e5f876..8516dc459b539342f44d2b2b3e21b140677c7826 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -210,6 +210,9 @@ xt_request_find_match(uint8_t nfproto, const char *name, uint8_t revision)
 {
 	struct xt_match *match;
 
+	if (strnlen(name, XT_EXTENSION_MAXNAMELEN) == XT_EXTENSION_MAXNAMELEN)
+		return ERR_PTR(-EINVAL);
+
 	match = xt_find_match(nfproto, name, revision);
 	if (IS_ERR(match)) {
 		request_module("%st_%s", xt_prefix[nfproto], name);


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

* Re: [PATCH net] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_match()
  2018-01-24 22:49 [PATCH net] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_match() Eric Dumazet
@ 2018-01-24 23:19 ` Florian Westphal
  2018-01-24 23:50   ` Pablo Neira Ayuso
  2018-01-24 23:49 ` [PATCH net] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_match() Pablo Neira Ayuso
  1 sibling, 1 reply; 9+ messages in thread
From: Florian Westphal @ 2018-01-24 23:19 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: Pablo Neira Ayuso, netdev, netfilter-devel, Florian Westphal

Eric Dumazet <eric.dumazet@gmail.com> wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> It looks like syzbot found its way into netfilter territory.

Excellent.  This will sure allow to find and fix more bugs :-)

> Issue here is that @name comes from user space and might
> not be null terminated.

Indeed, thanks for fixing this Eric.

xt_find_target() and xt_find_table_lock() might have similar issues.

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

* Re: [PATCH net] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_match()
  2018-01-24 22:49 [PATCH net] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_match() Eric Dumazet
  2018-01-24 23:19 ` Florian Westphal
@ 2018-01-24 23:49 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 9+ messages in thread
From: Pablo Neira Ayuso @ 2018-01-24 23:49 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: netdev, netfilter-devel, Florian Westphal

On Wed, Jan 24, 2018 at 02:49:48PM -0800, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> It looks like syzbot found its way into netfilter territory.
> 
> Issue here is that @name comes from user space and might
> not be null terminated.
> 
> Out-of-bound reads happen, KASAN is not happy.

Applied, thanks Eric.

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

* Re: [PATCH net] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_match()
  2018-01-24 23:19 ` Florian Westphal
@ 2018-01-24 23:50   ` Pablo Neira Ayuso
  2018-01-25  0:13     ` Pablo Neira Ayuso
  0 siblings, 1 reply; 9+ messages in thread
From: Pablo Neira Ayuso @ 2018-01-24 23:50 UTC (permalink / raw)
  To: Florian Westphal; +Cc: Eric Dumazet, netdev, netfilter-devel

On Thu, Jan 25, 2018 at 12:19:52AM +0100, Florian Westphal wrote:
> Eric Dumazet <eric.dumazet@gmail.com> wrote:
> > From: Eric Dumazet <edumazet@google.com>
> > 
> > It looks like syzbot found its way into netfilter territory.
> 
> Excellent.  This will sure allow to find and fix more bugs :-)
> 
> > Issue here is that @name comes from user space and might
> > not be null terminated.
> 
> Indeed, thanks for fixing this Eric.
> 
> xt_find_target() and xt_find_table_lock() might have similar issues.

I'm going to keep back this patch then, it would be good if we can
find this in one single patch.

Thanks.

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

* Re: [PATCH net] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_match()
  2018-01-24 23:50   ` Pablo Neira Ayuso
@ 2018-01-25  0:13     ` Pablo Neira Ayuso
  2018-01-25  1:13       ` Eric Dumazet
  2018-01-25  1:16       ` [PATCH v2 net] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_{match|target} Eric Dumazet
  0 siblings, 2 replies; 9+ messages in thread
From: Pablo Neira Ayuso @ 2018-01-25  0:13 UTC (permalink / raw)
  To: Florian Westphal; +Cc: Eric Dumazet, netdev, netfilter-devel

On Thu, Jan 25, 2018 at 12:50:56AM +0100, Pablo Neira Ayuso wrote:
> On Thu, Jan 25, 2018 at 12:19:52AM +0100, Florian Westphal wrote:
> > Eric Dumazet <eric.dumazet@gmail.com> wrote:
> > > From: Eric Dumazet <edumazet@google.com>
> > > 
> > > It looks like syzbot found its way into netfilter territory.
> > 
> > Excellent.  This will sure allow to find and fix more bugs :-)
> > 
> > > Issue here is that @name comes from user space and might
> > > not be null terminated.
> > 
> > Indeed, thanks for fixing this Eric.
> > 
> > xt_find_target() and xt_find_table_lock() might have similar issues.
> 
> I'm going to keep back this patch then, it would be good if we can
> find this in one single patch.

s/find/fix/

Sorry.

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

* Re: [PATCH net] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_match()
  2018-01-25  0:13     ` Pablo Neira Ayuso
@ 2018-01-25  1:13       ` Eric Dumazet
  2018-01-25  1:16       ` [PATCH v2 net] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_{match|target} Eric Dumazet
  1 sibling, 0 replies; 9+ messages in thread
From: Eric Dumazet @ 2018-01-25  1:13 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Florian Westphal; +Cc: netdev, netfilter-devel

On Thu, 2018-01-25 at 01:13 +0100, Pablo Neira Ayuso wrote:
> On Thu, Jan 25, 2018 at 12:50:56AM +0100, Pablo Neira Ayuso wrote:
> > On Thu, Jan 25, 2018 at 12:19:52AM +0100, Florian Westphal wrote:
> > > Eric Dumazet <eric.dumazet@gmail.com> wrote:
> > > > From: Eric Dumazet <edumazet@google.com>
> > > > 
> > > > It looks like syzbot found its way into netfilter territory.
> > > 
> > > Excellent.  This will sure allow to find and fix more bugs :-)
> > > 
> > > > Issue here is that @name comes from user space and might
> > > > not be null terminated.
> > > 
> > > Indeed, thanks for fixing this Eric.
> > > 
> > > xt_find_target() and xt_find_table_lock() might have similar issues.
> > 
> > I'm going to keep back this patch then, it would be good if we can
> > find this in one single patch.
> 
> s/find/fix/
> 
> Sorry.


Ok, but apparently you partially fixed this recently :/

Commits 78b79876761b8 and b301f25387599 took care of
xt_find_table_lock() it seems.

I'll send a V2 including xt_request_find_target()

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

* [PATCH v2 net] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_{match|target}
  2018-01-25  0:13     ` Pablo Neira Ayuso
  2018-01-25  1:13       ` Eric Dumazet
@ 2018-01-25  1:16       ` Eric Dumazet
  2018-01-25  6:09         ` Florian Westphal
  2018-01-25 11:33         ` Pablo Neira Ayuso
  1 sibling, 2 replies; 9+ messages in thread
From: Eric Dumazet @ 2018-01-25  1:16 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Florian Westphal; +Cc: netdev, netfilter-devel

From: Eric Dumazet <edumazet@google.com>

It looks like syzbot found its way into netfilter territory.

Issue here is that @name comes from user space and might
not be null terminated.

Out-of-bound reads happen, KASAN is not happy.

v2 added similar fix for xt_request_find_target(),
as Florian advised.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
---
No Fixes: tag, bug seems to be a day-0 one.

 net/netfilter/x_tables.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index 55802e97f906d1987ed78b4296584deb38e5f876..ecffc51ce83b07c063a0db67cdb33d9bf48a75ac 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -210,6 +210,9 @@ xt_request_find_match(uint8_t nfproto, const char *name, uint8_t revision)
 {
 	struct xt_match *match;
 
+	if (strnlen(name, XT_EXTENSION_MAXNAMELEN) == XT_EXTENSION_MAXNAMELEN)
+		return ERR_PTR(-EINVAL);
+
 	match = xt_find_match(nfproto, name, revision);
 	if (IS_ERR(match)) {
 		request_module("%st_%s", xt_prefix[nfproto], name);
@@ -252,6 +255,9 @@ struct xt_target *xt_request_find_target(u8 af, const char *name, u8 revision)
 {
 	struct xt_target *target;
 
+	if (strnlen(name, XT_EXTENSION_MAXNAMELEN) == XT_EXTENSION_MAXNAMELEN)
+		return ERR_PTR(-EINVAL);
+
 	target = xt_find_target(af, name, revision);
 	if (IS_ERR(target)) {
 		request_module("%st_%s", xt_prefix[af], name);

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

* Re: [PATCH v2 net] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_{match|target}
  2018-01-25  1:16       ` [PATCH v2 net] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_{match|target} Eric Dumazet
@ 2018-01-25  6:09         ` Florian Westphal
  2018-01-25 11:33         ` Pablo Neira Ayuso
  1 sibling, 0 replies; 9+ messages in thread
From: Florian Westphal @ 2018-01-25  6:09 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: Pablo Neira Ayuso, Florian Westphal, netdev, netfilter-devel

Eric Dumazet <eric.dumazet@gmail.com> wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> It looks like syzbot found its way into netfilter territory.
> 
> Issue here is that @name comes from user space and might
> not be null terminated.
> 
> Out-of-bound reads happen, KASAN is not happy.
> 
> v2 added similar fix for xt_request_find_target(),
> as Florian advised.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Reported-by: syzbot <syzkaller@googlegroups.com>

Thanks a lot Eric!

Acked-by: Florian Westphal <fw@strlen.de>

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

* Re: [PATCH v2 net] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_{match|target}
  2018-01-25  1:16       ` [PATCH v2 net] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_{match|target} Eric Dumazet
  2018-01-25  6:09         ` Florian Westphal
@ 2018-01-25 11:33         ` Pablo Neira Ayuso
  1 sibling, 0 replies; 9+ messages in thread
From: Pablo Neira Ayuso @ 2018-01-25 11:33 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: Florian Westphal, netdev, netfilter-devel

On Wed, Jan 24, 2018 at 05:16:09PM -0800, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> It looks like syzbot found its way into netfilter territory.
> 
> Issue here is that @name comes from user space and might
> not be null terminated.
> 
> Out-of-bound reads happen, KASAN is not happy.
> 
> v2 added similar fix for xt_request_find_target(),
> as Florian advised.

Applied, thanks Eric.

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

end of thread, other threads:[~2018-01-25 11:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-24 22:49 [PATCH net] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_match() Eric Dumazet
2018-01-24 23:19 ` Florian Westphal
2018-01-24 23:50   ` Pablo Neira Ayuso
2018-01-25  0:13     ` Pablo Neira Ayuso
2018-01-25  1:13       ` Eric Dumazet
2018-01-25  1:16       ` [PATCH v2 net] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_{match|target} Eric Dumazet
2018-01-25  6:09         ` Florian Westphal
2018-01-25 11:33         ` Pablo Neira Ayuso
2018-01-24 23:49 ` [PATCH net] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_match() Pablo Neira Ayuso

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.