Revision 501a90c945103e8627406763dac418f20f3837b2 authored by Eric Dumazet on 06 December 2019, 04:43:46 UTC, committed by David S. Miller on 07 December 2019, 19:55:11 UTC
syzbot was once again able to crash a host by setting a very small mtu
on loopback device.

Let's make inetdev_valid_mtu() available in include/net/ip.h,
and use it in ip_setup_cork(), so that we protect both ip_append_page()
and __ip_append_data()

Also add a READ_ONCE() when the device mtu is read.

Pairs this lockless read with one WRITE_ONCE() in __dev_set_mtu(),
even if other code paths might write over this field.

Add a big comment in include/linux/netdevice.h about dev->mtu
needing READ_ONCE()/WRITE_ONCE() annotations.

Hopefully we will add the missing ones in followup patches.

[1]

refcount_t: saturated; leaking memory.
WARNING: CPU: 0 PID: 9464 at lib/refcount.c:22 refcount_warn_saturate+0x138/0x1f0 lib/refcount.c:22
Kernel panic - not syncing: panic_on_warn set ...
CPU: 0 PID: 9464 Comm: syz-executor850 Not tainted 5.4.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x197/0x210 lib/dump_stack.c:118
 panic+0x2e3/0x75c kernel/panic.c:221
 __warn.cold+0x2f/0x3e kernel/panic.c:582
 report_bug+0x289/0x300 lib/bug.c:195
 fixup_bug arch/x86/kernel/traps.c:174 [inline]
 fixup_bug arch/x86/kernel/traps.c:169 [inline]
 do_error_trap+0x11b/0x200 arch/x86/kernel/traps.c:267
 do_invalid_op+0x37/0x50 arch/x86/kernel/traps.c:286
 invalid_op+0x23/0x30 arch/x86/entry/entry_64.S:1027
RIP: 0010:refcount_warn_saturate+0x138/0x1f0 lib/refcount.c:22
Code: 06 31 ff 89 de e8 c8 f5 e6 fd 84 db 0f 85 6f ff ff ff e8 7b f4 e6 fd 48 c7 c7 e0 71 4f 88 c6 05 56 a6 a4 06 01 e8 c7 a8 b7 fd <0f> 0b e9 50 ff ff ff e8 5c f4 e6 fd 0f b6 1d 3d a6 a4 06 31 ff 89
RSP: 0018:ffff88809689f550 EFLAGS: 00010286
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffffff815e4336 RDI: ffffed1012d13e9c
RBP: ffff88809689f560 R08: ffff88809c50a3c0 R09: fffffbfff15d31b1
R10: fffffbfff15d31b0 R11: ffffffff8ae98d87 R12: 0000000000000001
R13: 0000000000040100 R14: ffff888099041104 R15: ffff888218d96e40
 refcount_add include/linux/refcount.h:193 [inline]
 skb_set_owner_w+0x2b6/0x410 net/core/sock.c:1999
 sock_wmalloc+0xf1/0x120 net/core/sock.c:2096
 ip_append_page+0x7ef/0x1190 net/ipv4/ip_output.c:1383
 udp_sendpage+0x1c7/0x480 net/ipv4/udp.c:1276
 inet_sendpage+0xdb/0x150 net/ipv4/af_inet.c:821
 kernel_sendpage+0x92/0xf0 net/socket.c:3794
 sock_sendpage+0x8b/0xc0 net/socket.c:936
 pipe_to_sendpage+0x2da/0x3c0 fs/splice.c:458
 splice_from_pipe_feed fs/splice.c:512 [inline]
 __splice_from_pipe+0x3ee/0x7c0 fs/splice.c:636
 splice_from_pipe+0x108/0x170 fs/splice.c:671
 generic_splice_sendpage+0x3c/0x50 fs/splice.c:842
 do_splice_from fs/splice.c:861 [inline]
 direct_splice_actor+0x123/0x190 fs/splice.c:1035
 splice_direct_to_actor+0x3b4/0xa30 fs/splice.c:990
 do_splice_direct+0x1da/0x2a0 fs/splice.c:1078
 do_sendfile+0x597/0xd00 fs/read_write.c:1464
 __do_sys_sendfile64 fs/read_write.c:1525 [inline]
 __se_sys_sendfile64 fs/read_write.c:1511 [inline]
 __x64_sys_sendfile64+0x1dd/0x220 fs/read_write.c:1511
 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x441409
Code: e8 ac e8 ff ff 48 83 c4 18 c3 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 eb 08 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fffb64c4f78 EFLAGS: 00000246 ORIG_RAX: 0000000000000028
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000441409
RDX: 0000000000000000 RSI: 0000000000000006 RDI: 0000000000000005
RBP: 0000000000073b8a R08: 0000000000000010 R09: 0000000000000010
R10: 0000000000010001 R11: 0000000000000246 R12: 0000000000402180
R13: 0000000000402210 R14: 0000000000000000 R15: 0000000000000000
Kernel Offset: disabled
Rebooting in 86400 seconds..

Fixes: 1470ddf7f8ce ("inet: Remove explicit write references to sk/inet in ip_append_data")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 0e49409
History
File Mode Size
asymmetric_keys
async_tx
842.c -rw-r--r-- 3.7 KB
Kconfig -rw-r--r-- 54.9 KB
Makefile -rw-r--r-- 7.4 KB
acompress.c -rw-r--r-- 4.5 KB
adiantum.c -rw-r--r-- 20.9 KB
aead.c -rw-r--r-- 7.2 KB
aegis.h -rw-r--r-- 1.8 KB
aegis128-core.c -rw-r--r-- 13.2 KB
aegis128-neon-inner.c -rw-r--r-- 6.3 KB
aegis128-neon.c -rw-r--r-- 1.9 KB
aes_generic.c -rw-r--r-- 57.8 KB
aes_ti.c -rw-r--r-- 2.0 KB
af_alg.c -rw-r--r-- 25.5 KB
ahash.c -rw-r--r-- 16.3 KB
akcipher.c -rw-r--r-- 4.0 KB
algapi.c -rw-r--r-- 27.8 KB
algboss.c -rw-r--r-- 6.1 KB
algif_aead.c -rw-r--r-- 15.8 KB
algif_hash.c -rw-r--r-- 9.6 KB
algif_rng.c -rw-r--r-- 5.2 KB
algif_skcipher.c -rw-r--r-- 9.9 KB
ansi_cprng.c -rw-r--r-- 10.7 KB
anubis.c -rw-r--r-- 27.8 KB
api.c -rw-r--r-- 13.7 KB
arc4.c -rw-r--r-- 1.8 KB
authenc.c -rw-r--r-- 14.0 KB
authencesn.c -rw-r--r-- 15.1 KB
blake2b_generic.c -rw-r--r-- 9.3 KB
blake2s_generic.c -rw-r--r-- 5.0 KB
blowfish_common.c -rw-r--r-- 15.5 KB
blowfish_generic.c -rw-r--r-- 3.2 KB
camellia_generic.c -rw-r--r-- 34.3 KB
cast5_generic.c -rw-r--r-- 20.5 KB
cast6_generic.c -rw-r--r-- 9.1 KB
cast_common.c -rw-r--r-- 12.9 KB
cbc.c -rw-r--r-- 2.3 KB
ccm.c -rw-r--r-- 24.6 KB
cfb.c -rw-r--r-- 6.1 KB
chacha20poly1305.c -rw-r--r-- 18.7 KB
chacha_generic.c -rw-r--r-- 3.9 KB
cipher.c -rw-r--r-- 3.1 KB
cmac.c -rw-r--r-- 7.5 KB
compress.c -rw-r--r-- 1.1 KB
crc32_generic.c -rw-r--r-- 3.7 KB
crc32c_generic.c -rw-r--r-- 4.2 KB
crct10dif_common.c -rw-r--r-- 3.6 KB
crct10dif_generic.c -rw-r--r-- 3.1 KB
cryptd.c -rw-r--r-- 29.6 KB
crypto_engine.c -rw-r--r-- 12.2 KB
crypto_null.c -rw-r--r-- 5.3 KB
crypto_user_base.c -rw-r--r-- 12.0 KB
crypto_user_stat.c -rw-r--r-- 9.6 KB
ctr.c -rw-r--r-- 10.1 KB
cts.c -rw-r--r-- 12.0 KB
curve25519-generic.c -rw-r--r-- 2.2 KB
deflate.c -rw-r--r-- 7.7 KB
des_generic.c -rw-r--r-- 3.4 KB
dh.c -rw-r--r-- 4.7 KB
dh_helper.c -rw-r--r-- 3.4 KB
drbg.c -rw-r--r-- 59.2 KB
ecb.c -rw-r--r-- 2.4 KB
ecc.c -rw-r--r-- 38.3 KB
ecc.h -rw-r--r-- 7.6 KB
ecc_curve_defs.h -rw-r--r-- 1.9 KB
ecdh.c -rw-r--r-- 3.9 KB
ecdh_helper.c -rw-r--r-- 2.1 KB
echainiv.c -rw-r--r-- 4.3 KB
ecrdsa.c -rw-r--r-- 8.3 KB
ecrdsa_defs.h -rw-r--r-- 7.2 KB
ecrdsa_params.asn1 -rw-r--r-- 142 bytes
ecrdsa_pub_key.asn1 -rw-r--r-- 57 bytes
essiv.c -rw-r--r-- 18.4 KB
fcrypt.c -rw-r--r-- 18.0 KB
fips.c -rw-r--r-- 1.7 KB
gcm.c -rw-r--r-- 31.9 KB
geniv.c -rw-r--r-- 4.2 KB
gf128mul.c -rw-r--r-- 12.4 KB
ghash-generic.c -rw-r--r-- 4.9 KB
hash_info.c -rw-r--r-- 1.9 KB
hmac.c -rw-r--r-- 6.5 KB
internal.h -rw-r--r-- 3.4 KB
jitterentropy-kcapi.c -rw-r--r-- 5.6 KB
jitterentropy.c -rw-r--r-- 19.1 KB
jitterentropy.h -rw-r--r-- 643 bytes
keywrap.c -rw-r--r-- 9.5 KB
khazad.c -rw-r--r-- 51.8 KB
kpp.c -rw-r--r-- 2.7 KB
lrw.c -rw-r--r-- 10.7 KB
lz4.c -rw-r--r-- 3.3 KB
lz4hc.c -rw-r--r-- 3.4 KB
lzo-rle.c -rw-r--r-- 3.4 KB
lzo.c -rw-r--r-- 3.3 KB
md4.c -rw-r--r-- 5.9 KB
md5.c -rw-r--r-- 7.4 KB
memneq.c -rw-r--r-- 6.1 KB
michael_mic.c -rw-r--r-- 3.6 KB
nhpoly1305.c -rw-r--r-- 7.8 KB
ofb.c -rw-r--r-- 2.4 KB
pcbc.c -rw-r--r-- 4.7 KB
pcrypt.c -rw-r--r-- 9.1 KB
poly1305_generic.c -rw-r--r-- 3.0 KB
proc.c -rw-r--r-- 2.5 KB
ripemd.h -rw-r--r-- 1013 bytes
rmd128.c -rw-r--r-- 10.0 KB
rmd160.c -rw-r--r-- 12.4 KB
rmd256.c -rw-r--r-- 10.3 KB
rmd320.c -rw-r--r-- 12.8 KB
rng.c -rw-r--r-- 4.7 KB
rsa-pkcs1pad.c -rw-r--r-- 17.8 KB
rsa.c -rw-r--r-- 5.3 KB
rsa_helper.c -rw-r--r-- 4.0 KB
rsaprivkey.asn1 -rw-r--r-- 316 bytes
rsapubkey.asn1 -rw-r--r-- 82 bytes
salsa20_generic.c -rw-r--r-- 6.0 KB
scatterwalk.c -rw-r--r-- 2.0 KB
scompress.c -rw-r--r-- 6.8 KB
seed.c -rw-r--r-- 17.2 KB
seqiv.c -rw-r--r-- 5.0 KB
serpent_generic.c -rw-r--r-- 21.4 KB
sha1_generic.c -rw-r--r-- 2.4 KB
sha256_generic.c -rw-r--r-- 3.3 KB
sha3_generic.c -rw-r--r-- 8.0 KB
sha512_generic.c -rw-r--r-- 7.8 KB
shash.c -rw-r--r-- 14.5 KB
simd.c -rw-r--r-- 13.6 KB
skcipher.c -rw-r--r-- 25.8 KB
sm3_generic.c -rw-r--r-- 4.1 KB
sm4_generic.c -rw-r--r-- 6.3 KB
streebog_generic.c -rw-r--r-- 57.6 KB
tcrypt.c -rw-r--r-- 78.7 KB
tcrypt.h -rw-r--r-- 4.2 KB
tea.c -rw-r--r-- 6.5 KB
testmgr.c -rw-r--r-- 135.2 KB
testmgr.h -rw-r--r-- 1.2 MB
tgr192.c -rw-r--r-- 30.3 KB
twofish_common.c -rw-r--r-- 37.2 KB
twofish_generic.c -rw-r--r-- 5.6 KB
vmac.c -rw-r--r-- 18.8 KB
wp512.c -rw-r--r-- 59.8 KB
xcbc.c -rw-r--r-- 6.6 KB
xor.c -rw-r--r-- 3.4 KB
xts.c -rw-r--r-- 11.9 KB
xxhash_generic.c -rw-r--r-- 2.5 KB
zstd.c -rw-r--r-- 5.0 KB

back to top