batman-adv: reject oversized global TT response buffers
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 batman-adv: reject oversized global TT response buffers
From: Ruide Cao <[email protected]>
batadv_tt_prepare_tvlv_global_data() builds the allocation length for a global TT response in 16-bit temporaries. When a remote originator advertises a large enough global TT, the TT payload length plus the VLAN header offset can exceed 65535 and wrap before kmalloc().
The full-table response path still uses the original TT payload length when it fills tt_change, so the wrapped allocation is too small and batadv_tt_prepare_tvlv_global_data() writes past the end of the heap object before the later packet-size check runs.
Fix this by rejecting TT responses whose TVLV value length cannot fit in the 16-bit TVLV payload length field.
--- net/batman-adv/translation-table.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
net/batman-adv/translation-table.c +7 -2
@@ -798,8 +798,8 @@ batadv_tt_prepare_tvlv_global_data(struct batadv_orig_node *orig_node, {u16 num_vlan =0 ;u16 num_entries =0 ; -u16 change_offset; -u16 tvlv_len; +u16 tvlv_len =0 ; +unsigned int change_offset;struct batadv_tvlv_tt_vlan_data *tt_vlan;struct batadv_orig_node_vlan *vlan;u8 *tt_change_ptr;
@@ -816,6 +816,11 @@ batadv_tt_prepare_tvlv_global_data(struct batadv_orig_node *orig_node,if (*tt_len <0 ) *tt_len =batadv_tt_len (num_entries); +if (change_offset >U16_MAX || *tt_len >U16_MAX - change_offset) { + *tt_len =0 ; + goto out; + } + tvlv_len = *tt_len; tvlv_len += change_offset;
Signature · 1 line
2.34.1
Quoted 1 line · Ren Wei
batman-adv: reject oversized global TT response buffers
Applied, thanks!
[1/1] batman-adv: reject oversized global TT response buffers
https://git.open-mesh.org/linux-merge.git/commit/?h=batadv/net&id=3a359bf5c61d52e7f09754108309d637532164a6
Best regards,
Signature · 1 line
Sven Eckelmann <[email protected]>