This is a note to let you know that I've just added the patch titled ipv4: better IP_MAX_MTU enforcement to the 4.9-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: ipv4-better-ip_max_mtu-enforcement.patch and it can be found in the queue-4.9 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From foo@baz Thu Aug 24 17:44:02 PDT 2017 From: Eric Dumazet <edumazet@xxxxxxxxxx> Date: Wed, 16 Aug 2017 11:09:12 -0700 Subject: ipv4: better IP_MAX_MTU enforcement From: Eric Dumazet <edumazet@xxxxxxxxxx> [ Upstream commit c780a049f9bf442314335372c9abc4548bfe3e44 ] While working on yet another syzkaller report, I found that our IP_MAX_MTU enforcements were not properly done. gcc seems to reload dev->mtu for min(dev->mtu, IP_MAX_MTU), and final result can be bigger than IP_MAX_MTU :/ This is a problem because device mtu can be changed on other cpus or threads. While this patch does not fix the issue I am working on, it is probably worth addressing it. Signed-off-by: Eric Dumazet <edumazet@xxxxxxxxxx> Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- include/net/ip.h | 4 ++-- net/ipv4/route.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) --- a/include/net/ip.h +++ b/include/net/ip.h @@ -339,7 +339,7 @@ static inline unsigned int ip_dst_mtu_ma !forwarding) return dst_mtu(dst); - return min(dst->dev->mtu, IP_MAX_MTU); + return min(READ_ONCE(dst->dev->mtu), IP_MAX_MTU); } static inline unsigned int ip_skb_dst_mtu(struct sock *sk, @@ -351,7 +351,7 @@ static inline unsigned int ip_skb_dst_mt return ip_dst_mtu_maybe_forward(skb_dst(skb), forwarding); } - return min(skb_dst(skb)->dev->mtu, IP_MAX_MTU); + return min(READ_ONCE(skb_dst(skb)->dev->mtu), IP_MAX_MTU); } u32 ip_idents_reserve(u32 hash, int segs); --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -1247,7 +1247,7 @@ static unsigned int ipv4_mtu(const struc if (mtu) return mtu; - mtu = dst->dev->mtu; + mtu = READ_ONCE(dst->dev->mtu); if (unlikely(dst_metric_locked(dst, RTAX_MTU))) { if (rt->rt_uses_gateway && mtu > 576) Patches currently in stable-queue which might be from edumazet@xxxxxxxxxx are queue-4.9/ipv4-fix-null-dereference-in-free_fib_info_rcu.patch queue-4.9/tcp-when-rearming-rto-if-rto-time-is-in-past-then-fire-rto-asap.patch queue-4.9/ipv4-better-ip_max_mtu-enforcement.patch queue-4.9/dccp-defer-ccid_hc_tx_delete-at-dismantle-time.patch queue-4.9/tipc-fix-use-after-free.patch queue-4.9/af_key-do-not-use-gfp_kernel-in-atomic-contexts.patch queue-4.9/ipv6-repair-fib6-tree-in-failure-case.patch queue-4.9/dccp-purge-write-queue-in-dccp_destroy_sock.patch queue-4.9/ipv6-reset-fn-rr_ptr-when-replacing-route.patch queue-4.9/ptr_ring-use-kmalloc_array.patch queue-4.9/net_sched-sfq-update-hierarchical-backlog-when-drop-packet.patch