diff mbox series

batman-adv: initialize "struct batadv_tvlv_tt_vlan_data"->reserved field

Message ID 20210405053306.3437-1-penguin-kernel@I-love.SAKURA.ne.jp
State New
Headers show
Series batman-adv: initialize "struct batadv_tvlv_tt_vlan_data"->reserved field | expand

Commit Message

Tetsuo Handa April 5, 2021, 5:33 a.m. UTC
KMSAN found uninitialized value at batadv_tt_prepare_tvlv_local_data()
[1], for commit ced72933a5e8ab52 ("batman-adv: use CRC32C instead of CRC16
in TT code") inserted 'reserved' field into "struct batadv_tvlv_tt_data"
and commit 7ea7b4a142758dea ("batman-adv: make the TT CRC logic VLAN
specific") moved that field to "struct batadv_tvlv_tt_vlan_data" but left
that field uninitialized.

Although this patch passed "#syz test:" check, there might be similar bugs
remaining. It might be better to proactively use __GFP_ZERO than trying to
find uninitialized fields in this module.

[1] https://syzkaller.appspot.com/bug?id=07f3e6dba96f0eb3cabab986adcd8a58b9bdbe9d

Reported-by: syzbot <syzbot+50ee810676e6a089487b@syzkaller.appspotmail.com>
Tested-by: syzbot <syzbot+50ee810676e6a089487b@syzkaller.appspotmail.com>
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Fixes: ced72933a5e8ab52 ("batman-adv: use CRC32C instead of CRC16 in TT code")
Fixes: 7ea7b4a142758dea ("batman-adv: make the TT CRC logic VLAN specific")
---
 net/batman-adv/translation-table.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Sven Eckelmann April 5, 2021, 10:06 a.m. UTC | #1
On Monday, 5 April 2021 12:02:02 CEST Tetsuo Handa wrote:
[...]
> > Thanks but this patch is incomplete. Please also fix 
> > batadv_tt_prepare_tvlv_global_data (exactly the same way)
> 
> Indeed. Hmm, batadv_send_tt_request() is already using kzalloc().
> Which approach ( "->reserved = 0" or "kzalloc()") do you prefer for
> batadv_tt_prepare_tvlv_global_data() and batadv_tt_prepare_tvlv_local_data() ?


Lets stick with the approach you've used in your v1 version  - "->reserved = 0"

Kind regards,
	Sven
diff mbox series

Patch

diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index f8761281aab0..eb82576557e6 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -973,6 +973,7 @@  batadv_tt_prepare_tvlv_local_data(struct batadv_priv *bat_priv,
 
 		tt_vlan->vid = htons(vlan->vid);
 		tt_vlan->crc = htonl(vlan->tt.crc);
+		tt_vlan->reserved = 0;
 
 		tt_vlan++;
 	}