net: tftp: sanitize tftp block size, especially for TX
authorRasmus Villemoes <rasmus.villemoes@prevas.dk>
Fri, 14 Oct 2022 17:43:42 +0000 (19:43 +0200)
committerTom Rini <trini@konsulko.com>
Mon, 28 Nov 2022 18:06:39 +0000 (13:06 -0500)
commit087648b5df8db0d4786ff86e61e7616ebc181cf4
tree9e0635e1420af60923b95b421b9436dd2e018da3
parent4b8c44e39c9eb1717831e3b3f31c33e0932b0767
net: tftp: sanitize tftp block size, especially for TX

U-Boot does not support IP fragmentation on TX (and unless
CONFIG_IP_DEFRAG is set, neither on RX). So the blocks we send must
fit in a single ethernet packet.

Currently, if tftpblocksize is set to something like 5000 and I
tftpput a large enough file, U-Boot crashes because we overflow
net_tx_packet (which only has room for 1500 bytes plus change).

Similarly, if tftpblocksize is set to something larger than what we
can actually receive (e.g. 50000, with NET_MAXDEFRAG being 16384), any
tftp get just hangs because we never receive any packets.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
net/tftp.c