From: Eric Dumazet <hidden> Date: 2016-06-30 12:56:27
From: Eric Dumazet <edumazet@google.com>
ether_addr_equal_64bits() requires some care about its arguments,
namely that 8 bytes might be read, even if last 2 byte values are not
used.
KASan detected a violation with null_mac_addr and lacpdu_mcast_addr
in bond_3ad.c
Fixes: 815117adaf5b ("bonding: use ether_addr_equal_unaligned for bond addr compare")
Fixes: bb54e58929f3 ("bonding: Verify RX LACPDU has proper dest mac-addr")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
---
drivers/net/bonding/bond_3ad.c | 11 +++++++----
drivers/net/bonding/bond_alb.c | 3 ---
include/net/bonding.h | 7 ++++++-
3 files changed, 13 insertions(+), 8 deletions(-)
On Thu, Jun 30, 2016 at 2:56 PM, Eric Dumazet [off-list ref] wrote:
quoted hunk
From: Eric Dumazet <edumazet@google.com>
ether_addr_equal_64bits() requires some care about its arguments,
namely that 8 bytes might be read, even if last 2 byte values are not
used.
KASan detected a violation with null_mac_addr and lacpdu_mcast_addr
in bond_3ad.c
Fixes: 815117adaf5b ("bonding: use ether_addr_equal_unaligned for bond addr compare")
Fixes: bb54e58929f3 ("bonding: Verify RX LACPDU has proper dest mac-addr")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
---
drivers/net/bonding/bond_3ad.c | 11 +++++++----
drivers/net/bonding/bond_alb.c | 3 ---
include/net/bonding.h | 7 ++++++-
3 files changed, 13 insertions(+), 8 deletions(-)
From: Nikolay Aleksandrov <hidden> Date: 2016-06-30 13:25:03
On 30/06/16 14:56, Eric Dumazet wrote:
From: Eric Dumazet <edumazet@google.com>
ether_addr_equal_64bits() requires some care about its arguments,
namely that 8 bytes might be read, even if last 2 byte values are not
used.
KASan detected a violation with null_mac_addr and lacpdu_mcast_addr
in bond_3ad.c
Fixes: 815117adaf5b ("bonding: use ether_addr_equal_unaligned for bond addr compare")
Fixes: bb54e58929f3 ("bonding: Verify RX LACPDU has proper dest mac-addr")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
---
drivers/net/bonding/bond_3ad.c | 11 +++++++----
drivers/net/bonding/bond_alb.c | 3 ---
include/net/bonding.h | 7 ++++++-
3 files changed, 13 insertions(+), 8 deletions(-)
Good catch,
Acked-by: Nikolay Aleksandrov <redacted>
From: Eric Dumazet <hidden> Date: 2016-06-30 13:25:56
On Thu, 2016-06-30 at 15:04 +0200, Dmitry Vyukov wrote:
On Thu, Jun 30, 2016 at 2:56 PM, Eric Dumazet [off-list ref] wrote:
quoted
From: Eric Dumazet <edumazet@google.com>
ether_addr_equal_64bits() requires some care about its arguments,
namely that 8 bytes might be read, even if last 2 byte values are not
used.
KASan detected a violation with null_mac_addr and lacpdu_mcast_addr
in bond_3ad.c
Fixes: 815117adaf5b ("bonding: use ether_addr_equal_unaligned for bond addr compare")
Fixes: bb54e58929f3 ("bonding: Verify RX LACPDU has proper dest mac-addr")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
---
drivers/net/bonding/bond_3ad.c | 11 +++++++----
drivers/net/bonding/bond_alb.c | 3 ---
include/net/bonding.h | 7 ++++++-
3 files changed, 13 insertions(+), 8 deletions(-)
@@ -101,11 +101,14 @@ enum ad_link_speed_type {#define MAC_ADDRESS_EQUAL(A, B) \ether_addr_equal_64bits((constu8*)A,(constu8*)B)-staticstructmac_addrnull_mac_addr={{0,0,0,0,0,0}};+staticconstu8null_mac_addr[ETH_ALEN]__long_aligned={+0,0,0,0,0,0+};
__long_aligned won't prevent KASAN from barking, it's still 6 bytes
but we are reading 8.
Can we please do "ETH_ALEN + 2" as below?
Really ?
sizeof(null_mac_addr) is 8, how KASan would decide it is 6 bytes ?
nm -v drivers/net/bonding/bonding.ko|grep -3 null_mac_addr
000000000000084a r __UNIQUE_ID_mode17
0000000000000850 r tmpl.46263
0000000000000860 r lacpdu_mcast_addr
0000000000000868 r null_mac_addr
0000000000000870 r mac_v6_allmcast
0000000000000878 r mac_bcast
0000000000000880 r slave_sysfs_ops
Same trick was used in
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=885a136c52a8871175477baf3903e1c38751b35a
On Thu, Jun 30, 2016 at 3:25 PM, Eric Dumazet [off-list ref] wrote:
On Thu, 2016-06-30 at 15:04 +0200, Dmitry Vyukov wrote:
quoted
On Thu, Jun 30, 2016 at 2:56 PM, Eric Dumazet [off-list ref] wrote:
quoted
From: Eric Dumazet <edumazet@google.com>
ether_addr_equal_64bits() requires some care about its arguments,
namely that 8 bytes might be read, even if last 2 byte values are not
used.
KASan detected a violation with null_mac_addr and lacpdu_mcast_addr
in bond_3ad.c
Fixes: 815117adaf5b ("bonding: use ether_addr_equal_unaligned for bond addr compare")
Fixes: bb54e58929f3 ("bonding: Verify RX LACPDU has proper dest mac-addr")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
---
drivers/net/bonding/bond_3ad.c | 11 +++++++----
drivers/net/bonding/bond_alb.c | 3 ---
include/net/bonding.h | 7 ++++++-
3 files changed, 13 insertions(+), 8 deletions(-)
@@ -101,11 +101,14 @@ enum ad_link_speed_type {#define MAC_ADDRESS_EQUAL(A, B) \ether_addr_equal_64bits((constu8*)A,(constu8*)B)-staticstructmac_addrnull_mac_addr={{0,0,0,0,0,0}};+staticconstu8null_mac_addr[ETH_ALEN]__long_aligned={+0,0,0,0,0,0+};
__long_aligned won't prevent KASAN from barking, it's still 6 bytes
but we are reading 8.
Can we please do "ETH_ALEN + 2" as below?
Really ?
sizeof(null_mac_addr) is 8, how KASan would decide it is 6 bytes ?
nm -v drivers/net/bonding/bonding.ko|grep -3 null_mac_addr
000000000000084a r __UNIQUE_ID_mode17
0000000000000850 r tmpl.46263
0000000000000860 r lacpdu_mcast_addr
0000000000000868 r null_mac_addr
0000000000000870 r mac_v6_allmcast
0000000000000878 r mac_bcast
0000000000000880 r slave_sysfs_ops
What does nm -S say?
I've tried to compile a sample program with gcc6 and
__attribute__((aligned(8))) does in fact force alignment of start of
the symbol, but size still stays 6. (and asan still barks on my test
program).
From: Eric Dumazet <hidden> Date: 2016-06-30 14:09:18
On Thu, 2016-06-30 at 15:35 +0200, Dmitry Vyukov wrote:
What does nm -S say?
I've tried to compile a sample program with gcc6 and
__attribute__((aligned(8))) does in fact force alignment of start of
the symbol, but size still stays 6. (and asan still barks on my test
program).
Right, but then it means I also need to change mac_bcast[] and
mac_v6_allmcast[] in bond_alb.c to avoid false positive.
(Technically, if their alignment is 8, we have 8 bytes there,
no way it could span 2 pages)
I'll send a v2.
From: Eric Dumazet <hidden> Date: 2016-06-30 14:13:47
From: Eric Dumazet <edumazet@google.com>
ether_addr_equal_64bits() requires some care about its arguments,
namely that 8 bytes might be read, even if last 2 byte values are not
used.
KASan detected a violation with null_mac_addr and lacpdu_mcast_addr
in bond_3ad.c
Same problem with mac_bcast[] and mac_v6_allmcast[] in bond_alb.c :
Although the 8-byte alignment was there, KASan would detect out
of bound accesses.
Fixes: 815117adaf5b ("bonding: use ether_addr_equal_unaligned for bond addr compare")
Fixes: bb54e58929f3 ("bonding: Verify RX LACPDU has proper dest mac-addr")
Fixes: 885a136c52a8 ("bonding: use compare_ether_addr_64bits() in ALB")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
---
drivers/net/bonding/bond_3ad.c | 11 +++++++----
drivers/net/bonding/bond_alb.c | 7 ++-----
include/net/bonding.h | 7 ++++++-
3 files changed, 15 insertions(+), 10 deletions(-)
On Thu, Jun 30, 2016 at 4:08 PM, Eric Dumazet [off-list ref] wrote:
On Thu, 2016-06-30 at 15:35 +0200, Dmitry Vyukov wrote:
quoted
What does nm -S say?
I've tried to compile a sample program with gcc6 and
__attribute__((aligned(8))) does in fact force alignment of start of
the symbol, but size still stays 6. (and asan still barks on my test
program).
Right, but then it means I also need to change mac_bcast[] and
mac_v6_allmcast[] in bond_alb.c to avoid false positive.
(Technically, if their alignment is 8, we have 8 bytes there,
no way it could span 2 pages)
On Thu, Jun 30, 2016 at 4:13 PM, Eric Dumazet [off-list ref] wrote:
quoted hunk
From: Eric Dumazet <edumazet@google.com>
ether_addr_equal_64bits() requires some care about its arguments,
namely that 8 bytes might be read, even if last 2 byte values are not
used.
KASan detected a violation with null_mac_addr and lacpdu_mcast_addr
in bond_3ad.c
Same problem with mac_bcast[] and mac_v6_allmcast[] in bond_alb.c :
Although the 8-byte alignment was there, KASan would detect out
of bound accesses.
Fixes: 815117adaf5b ("bonding: use ether_addr_equal_unaligned for bond addr compare")
Fixes: bb54e58929f3 ("bonding: Verify RX LACPDU has proper dest mac-addr")
Fixes: 885a136c52a8 ("bonding: use compare_ether_addr_64bits() in ALB")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
---
drivers/net/bonding/bond_3ad.c | 11 +++++++----
drivers/net/bonding/bond_alb.c | 7 ++-----
include/net/bonding.h | 7 ++++++-
3 files changed, 15 insertions(+), 10 deletions(-)
From: Nikolay Aleksandrov <hidden> Date: 2016-06-30 14:52:07
On 30/06/16 16:13, Eric Dumazet wrote:
From: Eric Dumazet <edumazet@google.com>
ether_addr_equal_64bits() requires some care about its arguments,
namely that 8 bytes might be read, even if last 2 byte values are not
used.
KASan detected a violation with null_mac_addr and lacpdu_mcast_addr
in bond_3ad.c
Same problem with mac_bcast[] and mac_v6_allmcast[] in bond_alb.c :
Although the 8-byte alignment was there, KASan would detect out
of bound accesses.
Fixes: 815117adaf5b ("bonding: use ether_addr_equal_unaligned for bond addr compare")
Fixes: bb54e58929f3 ("bonding: Verify RX LACPDU has proper dest mac-addr")
Fixes: 885a136c52a8 ("bonding: use compare_ether_addr_64bits() in ALB")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
---
drivers/net/bonding/bond_3ad.c | 11 +++++++----
drivers/net/bonding/bond_alb.c | 7 ++-----
include/net/bonding.h | 7 ++++++-
3 files changed, 15 insertions(+), 10 deletions(-)
+CC bonding maintainers
For v2,
Acked-by: Nikolay Aleksandrov <redacted>
From: Eric Dumazet <edumazet@google.com>
ether_addr_equal_64bits() requires some care about its arguments,
namely that 8 bytes might be read, even if last 2 byte values are not
used.
KASan detected a violation with null_mac_addr and lacpdu_mcast_addr
in bond_3ad.c
Same problem with mac_bcast[] and mac_v6_allmcast[] in bond_alb.c :
Although the 8-byte alignment was there, KASan would detect out
of bound accesses.
Fixes: 815117adaf5b ("bonding: use ether_addr_equal_unaligned for bond addr compare")
Fixes: bb54e58929f3 ("bonding: Verify RX LACPDU has proper dest mac-addr")
Fixes: 885a136c52a8 ("bonding: use compare_ether_addr_64bits() in ALB")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
---
drivers/net/bonding/bond_3ad.c | 11 +++++++----
drivers/net/bonding/bond_alb.c | 7 ++-----
include/net/bonding.h | 7 ++++++-
3 files changed, 15 insertions(+), 10 deletions(-)
From: David Miller <davem@davemloft.net> Date: 2016-07-01 10:07:24
From: Eric Dumazet <redacted>
Date: Thu, 30 Jun 2016 16:13:41 +0200
From: Eric Dumazet <edumazet@google.com>
ether_addr_equal_64bits() requires some care about its arguments,
namely that 8 bytes might be read, even if last 2 byte values are not
used.
KASan detected a violation with null_mac_addr and lacpdu_mcast_addr
in bond_3ad.c
Same problem with mac_bcast[] and mac_v6_allmcast[] in bond_alb.c :
Although the 8-byte alignment was there, KASan would detect out
of bound accesses.
Fixes: 815117adaf5b ("bonding: use ether_addr_equal_unaligned for bond addr compare")
Fixes: bb54e58929f3 ("bonding: Verify RX LACPDU has proper dest mac-addr")
Fixes: 885a136c52a8 ("bonding: use compare_ether_addr_64bits() in ALB")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>