Re: [PATCH] net/mlx5: allocate enough space in

5 messages, 2 authors, 2018-10-22 · open the first message on its own page

Re: [PATCH] net/mlx5: allocate enough space in

From: Or Gerlitz <hidden>
Date: 2018-10-21 04:49:16

On Fri, Oct 19, 2018 at 11:08 PM Dan Carpenter [off-list ref] wrote:
FDB_MAX_CHAIN is 3.  We wanted to allocate enough memory to hold four
structs but there are missing parentheses so we only allocate enough
memory for three structs and the first byte of the fourth one.
yeah, seems that we were wrong here and the fix is correct, at some
point I saw Kasan
screams but it was gone later, let me look, thanks for pointing it out.


quoted hunk
Fixes: 328edb499f99 ("net/mlx5: Split FDB fast path prio to multiple namespaces")
Signed-off-by: Dan Carpenter <redacted>
---
 drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
index 67ba4c975d81..9d73eb955f75 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
@@ -2470,7 +2470,7 @@ static int init_fdb_root_ns(struct mlx5_flow_steering *steering)
                return -ENOMEM;

        steering->fdb_sub_ns = kzalloc(sizeof(steering->fdb_sub_ns) *
-                                      FDB_MAX_CHAIN + 1, GFP_KERNEL);
+                                      (FDB_MAX_CHAIN + 1), GFP_KERNEL);
        if (!steering->fdb_sub_ns)
                return -ENOMEM;

--
2.11.0

Re: [PATCH] net/mlx5: allocate enough space in

From: Or Gerlitz <hidden>
Date: 2018-10-21 19:10:33

On Sat, Oct 20, 2018 at 11:37 PM Or Gerlitz [off-list ref] wrote:
On Fri, Oct 19, 2018 at 11:08 PM Dan Carpenter [off-list ref] wrote:
quoted
FDB_MAX_CHAIN is 3.  We wanted to allocate enough memory to hold four
structs but there are missing parentheses so we only allocate enough
memory for three structs and the first byte of the fourth one.
yeah, seems that we were wrong here and the fix is correct, at some
point I saw Kasan screams but it was gone later, let me look, thanks for pointing it out.
OK, here's the kasan note:

[  289.005141] BUG: KASAN: slab-out-of-bounds in
mlx5_init_fs+0x6a7/0x1176 [mlx5_core]
[  289.005244] Write of size 8 at addr ffff8806cfb70e58 by task modprobe/6186

my .config was like this w.r.t kasan:

CONFIG_KASAN_SHADOW_OFFSET=0xdffffc0000000000
CONFIG_HAVE_ARCH_KASAN=y
CONFIG_KASAN=y
# CONFIG_KASAN_EXTRA is not set
CONFIG_KASAN_OUTLINE=y
# CONFIG_KASAN_INLINE is not set
# CONFIG_TEST_KASAN is not set

where now, when I changed it to be:

CONFIG_KASAN_SHADOW_OFFSET=0xdffffc0000000000
CONFIG_HAVE_ARCH_KASAN=y
CONFIG_KASAN=y
CONFIG_KASAN_EXTRA=y
# CONFIG_KASAN_OUTLINE is not set
CONFIG_KASAN_INLINE=y
# CONFIG_TEST_KASAN is not set

Kasan is there to spot the bug.

I will re-post your patch, this time to netdev since the original
commit is there
and so should be the fix, thanks for reporting/fixing!

Or.

Re: [PATCH] net/mlx5: allocate enough space in

From: Dan Carpenter <hidden>
Date: 2018-10-22 13:40:48

On Sun, Oct 21, 2018 at 01:56:26PM +0300, Or Gerlitz wrote:
I will re-post your patch, this time to netdev since the original
commit is there
and so should be the fix, thanks for reporting/fixing!
I didn't realize it had been posted to netdev already so I deliberately
left that off the CC.  If Dave hasn't applied the original (he probably
has now because he is so quick) then it's fine by me if you fold them
together.

regards,
dan carpenter

Re: [PATCH] net/mlx5: allocate enough space in

From: Or Gerlitz <hidden>
Date: 2018-10-22 14:36:03

On Mon, Oct 22, 2018 at 8:23 AM Dan Carpenter [off-list ref] wrote:
On Sun, Oct 21, 2018 at 01:56:26PM +0300, Or Gerlitz wrote:
quoted
I will re-post your patch, this time to netdev since the original
commit is there
and so should be the fix, thanks for reporting/fixing!
I didn't realize it had been posted to netdev already so I deliberately
left that off the CC.  If Dave hasn't applied the original (he probably
you didn't post it to netdev, I don't see how he could have got it

has now because he is so quick) then it's fine by me if you fold them
together.

regards,
dan carpenter

Re: [PATCH] net/mlx5: allocate enough space in

From: Dan Carpenter <hidden>
Date: 2018-10-22 14:58:25

On Mon, Oct 22, 2018 at 09:18:43AM +0300, Or Gerlitz wrote:
On Mon, Oct 22, 2018 at 8:23 AM Dan Carpenter [off-list ref] wrote:
quoted
On Sun, Oct 21, 2018 at 01:56:26PM +0300, Or Gerlitz wrote:
quoted
I will re-post your patch, this time to netdev since the original
commit is there
and so should be the fix, thanks for reporting/fixing!
I didn't realize it had been posted to netdev already so I deliberately
left that off the CC.  If Dave hasn't applied the original (he probably
you didn't post it to netdev, I don't see how he could have got it
I meant commit 328edb499f99 ("net/mlx5: Split FDB fast path prio to
multiple namespaces").  It turns out that Dave has applied that, but I
was expecting to see his S-o-B on it.

It's hard for me to know which tree patches are applied to.

Also I see that I screwed up the subject.  Thanks for fixing that.

regards,
dan carpenter
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help