Skip to content

Commit b0ea911

Browse files
edragain2ndgregkh
authored andcommitted
ipv4: reject undersized MTUs in ip_do_fragment()
commit c0726f0 upstream. ip_do_fragment() subtracts the IPv4 header length from the effective MTU and passes the resulting payload MTU to ip_frag_next(). If the effective MTU is smaller than hlen + 8, ip_frag_next() rounds the fragment payload length down to zero. The fragmentation state then never makes forward progress: state->left, state->ptr and state->offset stay unchanged while ip_do_fragment() keeps allocating and transmitting header-only fragments until the softlockup detector fires. This is reproducible with a route installed using "mtu lock 20", but it is also reproducible without route MTU lock, for example by forwarding a packet to a device whose MTU is 20. Fix it in ip_do_fragment() by rejecting mtu < hlen + 8 with -EMSGSIZE, matching the existing IPv6 fragmentation check. Fixes: 1da177e ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Reported-by: Vega <vega@nebusec.ai> Signed-off-by: Yong Wang <edragain@163.com> Signed-off-by: Ren Wei <weir@nebusec.ai> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Link: https://patch.msgid.link/8809ef6314b98913681b0b370a05a85c2b6cd579.1786599079.git.edragain@163.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent eab3eeb commit b0ea911

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

net/ipv4/ip_output.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,10 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
797797
*/
798798

799799
hlen = iph->ihl * 4;
800+
if (mtu < hlen + 8) {
801+
err = -EMSGSIZE;
802+
goto fail;
803+
}
800804
mtu = mtu - hlen; /* Size of data space */
801805
IPCB(skb)->flags |= IPSKB_FRAG_COMPLETE;
802806
ll_rs = LL_RESERVED_SPACE(rt->dst.dev);

0 commit comments

Comments
 (0)