4.9.207-stable review
Subsystems (5)
Greg Kroah-Hartman
maintainerPATCH 180/199 tipc: fix ordering of tipc module init and exit routine
In reply to Greg Kroah-HartmanFrom: Taehee Yoo <[email protected]>
[ Upstream commit 9cf1cd8ee3ee09ef2859017df2058e2f53c5347f ]
In order to set/get/dump, the tipc uses the generic netlink infrastructure. So, when tipc module is inserted, init function calls genl_register_family().
After genl_register_family(), set/get/dump commands are immediately allowed and these callbacks internally use the net_generic. net_generic is allocated by register_pernet_device() but this is called after genl_register_family() in the __init function. So, these callbacks would use un-initialized net_generic.
Test commands:
#SHELL1
while :
do
modprobe tipc
modprobe -rv tipc
done
#SHELL2
while :
do
tipc link list
done
Splat looks like:
[ 59.616322][ T2788] kasan: CONFIG_KASAN_INLINE enabled [ 59.617234][ T2788] kasan: GPF could be caused by NULL-ptr deref or user memory access [ 59.618398][ T2788] general protection fault: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN PTI [ 59.619389][ T2788] CPU: 3 PID: 2788 Comm: tipc Not tainted 5.4.0+ #194 [ 59.620231][ T2788] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 [ 59.621428][ T2788] RIP: 0010:tipc_bcast_get_broadcast_mode+0x131/0x310 [tipc] [ 59.622379][ T2788] Code: c7 c6 ef 8b 38 c0 65 ff 0d 84 83 c9 3f e8 d7 a5 f2 e3 48 8d bb 38 11 00 00 48 b8 00 00 00 00 [ 59.622550][ T2780] NET: Registered protocol family 30 [ 59.624627][ T2788] RSP: 0018:ffff88804b09f578 EFLAGS: 00010202 [ 59.624630][ T2788] RAX: dffffc0000000000 RBX: 0000000000000011 RCX: 000000008bc66907 [ 59.624631][ T2788] RDX: 0000000000000229 RSI: 000000004b3cf4cc RDI: 0000000000001149 [ 59.624633][ T2788] RBP: ffff88804b09f588 R08: 0000000000000003 R09: fffffbfff4fb3df1 [ 59.624635][ T2788] R10: fffffbfff50318f8 R11: ffff888066cadc18 R12: ffffffffa6cc2f40 [ 59.624637][ T2788] R13: 1ffff11009613eba R14: ffff8880662e9328 R15: ffff8880662e9328 [ 59.624639][ T2788] FS: 00007f57d8f7b740(0000) GS:ffff88806cc00000(0000) knlGS:0000000000000000 [ 59.624645][ T2788] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 59.625875][ T2780] tipc: Started in single node mode [ 59.626128][ T2788] CR2: 00007f57d887a8c0 CR3: 000000004b140002 CR4: 00000000000606e0 [ 59.633991][ T2788] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 59.635195][ T2788] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 59.636478][ T2788] Call Trace: [ 59.637025][ T2788] tipc_nl_add_bc_link+0x179/0x1470 [tipc] [ 59.638219][ T2788] ? lock_downgrade+0x6e0/0x6e0 [ 59.638923][ T2788] ? __tipc_nl_add_link+0xf90/0xf90 [tipc] [ 59.639533][ T2788] ? tipc_nl_node_dump_link+0x318/0xa50 [tipc] [ 59.640160][ T2788] ? mutex_lock_io_nested+0x1380/0x1380 [ 59.640746][ T2788] tipc_nl_node_dump_link+0x4fd/0xa50 [tipc] [ 59.641356][ T2788] ? tipc_nl_node_reset_link_stats+0x340/0x340 [tipc] [ 59.642088][ T2788] ? __skb_ext_del+0x270/0x270 [ 59.642594][ T2788] genl_lock_dumpit+0x85/0xb0 [ 59.643050][ T2788] netlink_dump+0x49c/0xed0 [ 59.643529][ T2788] ? __netlink_sendskb+0xc0/0xc0 [ 59.644044][ T2788] ? __netlink_dump_start+0x190/0x800 [ 59.644617][ T2788] ? __mutex_unlock_slowpath+0xd0/0x670 [ 59.645177][ T2788] __netlink_dump_start+0x5a0/0x800 [ 59.645692][ T2788] genl_rcv_msg+0xa75/0xe90 [ 59.646144][ T2788] ? __lock_acquire+0xdfe/0x3de0 [ 59.646692][ T2788] ? genl_family_rcv_msg_attrs_parse+0x320/0x320 [ 59.647340][ T2788] ? genl_lock_dumpit+0xb0/0xb0 [ 59.647821][ T2788] ? genl_unlock+0x20/0x20 [ 59.648290][ T2788] ? genl_parallel_done+0xe0/0xe0 [ 59.648787][ T2788] ? find_held_lock+0x39/0x1d0 [ 59.649276][ T2788] ? genl_rcv+0x15/0x40 [ 59.649722][ T2788] ? lock_contended+0xcd0/0xcd0 [ 59.650296][ T2788] netlink_rcv_skb+0x121/0x350 [ 59.650828][ T2788] ? genl_family_rcv_msg_attrs_parse+0x320/0x320 [ 59.651491][ T2788] ? netlink_ack+0x940/0x940 [ 59.651953][ T2788] ? lock_acquire+0x164/0x3b0 [ 59.652449][ T2788] genl_rcv+0x24/0x40 [ 59.652841][ T2788] netlink_unicast+0x421/0x600
[ ... ]
--- net/tipc/core.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)
net/tipc/core.c +15 -14
@@ -116,14 +116,6 @@ static int __init tipc_init(void) sysctl_tipc_rmem[1 ] =RCVBUF_DEF ; sysctl_tipc_rmem[2 ] =RCVBUF_MAX ; - err =tipc_netlink_start (); -if (err) - goto out_netlink; - - err =tipc_netlink_compat_start (); -if (err) - goto out_netlink_compat; - err =tipc_register_sysctl ();if (err) goto out_sysctl;
@@ -144,8 +136,21 @@ static int __init tipc_init(void)if (err) goto out_bearer; + err =tipc_netlink_start (); +if (err) + goto out_netlink; + + err =tipc_netlink_compat_start (); +if (err) + goto out_netlink_compat; +pr_info ("Started in single node mode\n" );return 0 ; + +out_netlink_compat: +tipc_netlink_stop (); +out_netlink: +tipc_bearer_cleanup (); out_bearer:unregister_pernet_device (&tipc_topsrv_net_ops); out_pernet_topsrv:
@@ -155,22 +160,18 @@ out_socket: out_pernet:tipc_unregister_sysctl (); out_sysctl: -tipc_netlink_compat_stop (); -out_netlink_compat: -tipc_netlink_stop (); -out_netlink:pr_err ("Unable to start in single node mode\n" );return err; } static void __exit tipc_exit(void) { +tipc_netlink_compat_stop (); +tipc_netlink_stop ();tipc_bearer_cleanup ();unregister_pernet_device (&tipc_topsrv_net_ops);tipc_socket_stop ();unregister_pernet_device (&tipc_net_ops); -tipc_netlink_stop (); -tipc_netlink_compat_stop ();tipc_unregister_sysctl ();pr_info ("Deactivated\n" );
Greg Kroah-Hartman
maintainerPATCH 181/199 inet: protect against too small mtu values.
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 501a90c945103e8627406763dac418f20f3837b2 ]
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..
--- include/linux/netdevice.h | 5 +++++ include/net/ip.h | 5 +++++ net/core/dev.c | 3 ++- net/ipv4/devinet.c | 5 ----- net/ipv4/ip_output.c | 14 +++++++++----- 5 files changed, 21 insertions(+), 11 deletions(-)
include/linux/netdevice.h +5 -0
@@ -1730,6 +1730,11 @@ struct net_device {unsigned char if_port;unsigned char dma; +/* Note : dev->mtu is often read without holding a lock. +* Writers usually hold RTNL. +* It is recommended to use READ_ONCE() to annotate the reads, +* and to use WRITE_ONCE() to annotate the writes. +*/ unsigned int mtu;unsigned short type;unsigned short hard_header_len;
include/net/ip.h +5 -0
@@ -620,4 +620,9 @@ extern int sysctl_icmp_msgs_burst;int ip_misc_proc_init (void );#endif +static inline bool inetdev_valid_mtu (unsigned int mtu) +{ +return likely (mtu >=IPV4_MIN_MTU ); +} +#endif /* _IP_H */
net/core/dev.c +2 -1
@@ -6584,7 +6584,8 @@ static int __dev_set_mtu(struct net_deviif (ops->ndo_change_mtu)return ops->ndo_change_mtu (dev, new_mtu); - dev->mtu = new_mtu; +/* Pairs with all the lockless reads of dev->mtu in the stack */ +WRITE_ONCE (dev->mtu, new_mtu);return 0 ; }
net/ipv4/devinet.c +0 -5
@@ -1386,11 +1386,6 @@ skip: } } -static bool inetdev_valid_mtu (unsigned int mtu) -{ -return mtu >=IPV4_MIN_MTU ; -} -static void inetdev_send_gratuitous_arp (struct net_device *dev,struct in_device *in_dev)
net/ipv4/ip_output.c +9 -5
@@ -1159,13 +1159,17 @@ static int ip_setup_cork(struct sock *sk rt = *rtp;if (unlikely (!rt))return -EFAULT ; -/* -* We steal reference to this route, caller should not release it -*/ - *rtp =NULL ; + cork->fragsize =ip_sk_use_pmtu (sk) ? -dst_mtu (&rt->dst) : rt->dst.dev->mtu; +dst_mtu (&rt->dst) :READ_ONCE (rt->dst.dev->mtu); + +if (!inetdev_valid_mtu (cork->fragsize)) +return -ENETUNREACH ; + cork->dst = &rt->dst; +/* We stole this route, caller should not release it. */ + *rtp =NULL ; + cork->length =0 ; cork->ttl = ipc->ttl; cork->tos = ipc->tos;
Greg Kroah-Hartman
maintainerPATCH 182/199 tcp: fix rejected syncookies due to stale timestamps
In reply to Greg Kroah-HartmanFrom: Guillaume Nault <[email protected]>
[ Upstream commit 04d26e7b159a396372646a480f4caa166d1b6720 ]
If no synflood happens for a long enough period of time, then the synflood timestamp isn't refreshed and jiffies can advance so much that time_after32() can't accurately compare them any more.
Therefore, we can end up in a situation where time_after32(now, last_overflow + HZ) returns false, just because these two values are too far apart. In that case, the synflood timestamp isn't updated as it should be, which can trick tcp_synq_no_recent_overflow() into rejecting valid syncookies.
For example, let's consider the following scenario on a system with HZ=1000:
* The synflood timestamp is 0, either because that's the timestamp of the last synflood or, more commonly, because we're working with a freshly created socket.
* We receive a new SYN, which triggers synflood protection. Let's say
that this happens when jiffies == 2147484649 (that is,
'synflood timestamp' + HZ + 2^31 + 1). * Then tcp_synq_overflow() doesn't update the synflood timestamp, because time_after32(2147484649, 1000) returns false. With:
- 2147484649: the value of jiffies, aka. 'now'.
- 1000: the value of 'last_overflow' + HZ.
* A bit later, we receive the ACK completing the 3WHS. But cookie_v[46]_check() rejects it because tcp_synq_no_recent_overflow() says that we're not under synflood. That's because time_after32(2147484649, 120000) returns false.
With:
- 2147484649: the value of jiffies, aka. 'now'.
- 120000: the value of 'last_overflow' + TCP_SYNCOOKIE_VALID.
Of course, in reality jiffies would have increased a bit, but this condition will last for the next 119 seconds, which is far enough to accommodate for jiffie's growth.
Fix this by updating the overflow timestamp whenever jiffies isn't within the [last_overflow, last_overflow + HZ] range. That shouldn't have any performance impact since the update still happens at most once per second.
Now we're guaranteed to have fresh timestamps while under synflood, so tcp_synq_no_recent_overflow() can safely use it with time_after32() in such situations.
Stale timestamps can still make tcp_synq_no_recent_overflow() return the wrong verdict when not under synflood. This will be handled in the next patch.
For 64 bits architectures, the problem was introduced with the conversion of ->tw_ts_recent_stamp to 32 bits integer by commit cca9bab1b72c ("tcp: use monotonic timestamps for PAWS"). The problem has always been there on 32 bits architectures.
--- include/linux/time.h | 12 ++++++++++++ include/net/tcp.h | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-)
include/linux/time.h +12 -0
@@ -275,4 +275,16 @@ static __always_inline void timespec_add a->tv_nsec = ns; } +/** +* time_between32 - check if a 32-bit timestamp is within a given time range +* @t: the time which may be within [l,h] +* @l: the lower bound of the range +* @h: the higher bound of the range +* +* time_before32(t, l, h) returns true if @l <= @t <= @h. All operands are +* treated as 32-bit integers. +* +* Equivalent to !(time_before32(@t, @l) || time_after32(@t, @h)). +*/ +#define time_between32 (t, l, h) ((u32)(h) - (u32)(l) >= (u32)(t) - (u32)(l))#endif
include/net/tcp.h +1 -1
@@ -497,7 +497,7 @@ static inline void tcp_synq_overflow(conunsigned long last_overflow =tcp_sk (sk)->rx_opt.ts_recent_stamp;unsigned long now = jiffies; -if (time_after (now, last_overflow +HZ )) +if (!time_between32 (now, last_overflow, last_overflow +HZ ))tcp_sk (sk)->rx_opt.ts_recent_stamp = now; }
Greg Kroah-Hartman
maintainerPATCH 183/199 tcp: tighten acceptance of ACKs not matching a child socket
In reply to Greg Kroah-HartmanFrom: Guillaume Nault <[email protected]>
[ Upstream commit cb44a08f8647fd2e8db5cc9ac27cd8355fa392d8 ]
When no synflood occurs, the synflood timestamp isn't updated. Therefore it can be so old that time_after32() can consider it to be in the future.
That's a problem for tcp_synq_no_recent_overflow() as it may report that a recent overflow occurred while, in fact, it's just that jiffies has grown past 'last_overflow' + TCP_SYNCOOKIE_VALID + 2^31.
Spurious detection of recent overflows lead to extra syncookie verification in cookie_v[46]_check(). At that point, the verification should fail and the packet dropped. But we should have dropped the packet earlier as we didn't even send a syncookie.
Let's refine tcp_synq_no_recent_overflow() to report a recent overflow only if jiffies is within the
[last_overflow, last_overflow + TCP_SYNCOOKIE_VALID] interval. This way, no spurious recent overflow is reported when jiffies wraps and 'last_overflow' becomes in the future from the point of view of time_after32().
However, if jiffies wraps and enters the
[last_overflow, last_overflow + TCP_SYNCOOKIE_VALID] interval (with 'last_overflow' being a stale synflood timestamp), then tcp_synq_no_recent_overflow() still erroneously reports an overflow. In such cases, we have to rely on syncookie verification to drop the packet. We unfortunately have no way to differentiate between a fresh and a stale syncookie timestamp.
In practice, using last_overflow as lower bound is problematic. If the synflood timestamp is concurrently updated between the time we read jiffies and the moment we store the timestamp in 'last_overflow', then 'now' becomes smaller than 'last_overflow' and tcp_synq_no_recent_overflow() returns true, potentially dropping a valid syncookie.
Reading jiffies after loading the timestamp could fix the problem, but that'd require a memory barrier. Let's just accommodate for potential timestamp growth instead and extend the interval using 'last_overflow - HZ' as lower bound.
--- include/net/tcp.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
include/net/tcp.h +9 -1
@@ -506,7 +506,15 @@ static inline bool tcp_synq_no_recent_ov {unsigned long last_overflow =tcp_sk (sk)->rx_opt.ts_recent_stamp; -return time_after (jiffies, last_overflow +TCP_SYNCOOKIE_VALID ); +/* If last_overflow <= jiffies <= last_overflow + TCP_SYNCOOKIE_VALID, +* then we're under synflood. However, we have to use +* 'last_overflow - HZ' as lower bound. That's because a concurrent +* tcp_synq_overflow() could update .ts_recent_stamp after we read +* jiffies but before we store .ts_recent_stamp into last_overflow, +* which could lead to rejecting a valid syncookie. +*/ +return !time_between32 (jiffies, last_overflow -HZ , + last_overflow +TCP_SYNCOOKIE_VALID ); }static inline u32 tcp_cookie_time (void )
Greg Kroah-Hartman
maintainerPATCH 184/199 tcp: Protect accesses to .ts_recent_stamp with {READ,WRITE}_ONCE()
In reply to Greg Kroah-HartmanFrom: Guillaume Nault <[email protected]>
[ Upstream commit 721c8dafad26ccfa90ff659ee19755e3377b829d ]
Syncookies borrow the ->rx_opt.ts_recent_stamp field to store the timestamp of the last synflood. Protect them with READ_ONCE() and WRITE_ONCE() since reads and writes aren't serialised.
Use of .rx_opt.ts_recent_stamp for storing the synflood timestamp was introduced by a0f82f64e269 ("syncookies: remove last_synq_overflow from struct tcp_sock"). But unprotected accesses were already there when timestamp was stored in .last_synq_overflow.
--- include/net/tcp.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/net/tcp.h +3 -3
@@ -494,17 +494,17 @@ struct sock *cookie_v4_check(struct sock*/ static inline void tcp_synq_overflow (const struct sock *sk) { -unsigned long last_overflow =tcp_sk (sk)->rx_opt.ts_recent_stamp; +unsigned long last_overflow =READ_ONCE (tcp_sk (sk)->rx_opt.ts_recent_stamp);unsigned long now = jiffies;if (!time_between32 (now, last_overflow, last_overflow +HZ )) -tcp_sk (sk)->rx_opt.ts_recent_stamp = now; +WRITE_ONCE (tcp_sk (sk)->rx_opt.ts_recent_stamp, now); }/* syncookies: no recent synqueue overflow on this listening socket? */ static inline bool tcp_synq_no_recent_overflow (const struct sock *sk) { -unsigned long last_overflow =tcp_sk (sk)->rx_opt.ts_recent_stamp; +unsigned long last_overflow =READ_ONCE (tcp_sk (sk)->rx_opt.ts_recent_stamp);/* If last_overflow <= jiffies <= last_overflow + TCP_SYNCOOKIE_VALID, * then we're under synflood. However, we have to use
Greg Kroah-Hartman
maintainerPATCH 185/199 Revert "regulator: Defer init completion for a while after late_initcall"
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
This reverts commit 8b8c8d69b1a31004517d4c71a490f47bdf3405a2 which is commit 55576cf1853798e86f620766e23b604c9224c19c upstream.
It's causing "odd" interactions with older kernels, so it probably isn't a good idea to cause timing changes there. This has been reported to cause oopses on Pixel devices.
--- drivers/regulator/core.c | 42 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 31 deletions(-)
drivers/regulator/core.c +11 -31
@@ -4452,7 +4452,7 @@ static int __init regulator_init(void)/* init early to allow our consumers to complete system booting */ core_initcall (regulator_init); -static int regulator_late_cleanup (struct device *dev,void *data) +static int __init regulator_late_cleanup (struct device *dev,void *data) {struct regulator_dev *rdev =dev_to_rdev (dev);const struct regulator_ops *ops = rdev->desc->ops;
@@ -4501,9 +4501,18 @@ unlock:return 0 ; } -static void regulator_init_complete_work_function (struct work_struct *work) +static int __init regulator_init_complete (void ) {/* +* Since DT doesn't provide an idiomatic mechanism for +* enabling full constraints and since it's much more natural +* with DT to provide them just assume that a DT enabled +* system has full constraints. +*/ +if (of_have_populated_dt ()) + has_full_constraints = true; + +/* * Regulators may had failed to resolve their input supplies * when were registered, either because the input supply was * not registered yet or because its parent device was not
@@ -4520,35 +4529,6 @@ static void regulator_init_complete_work*/ class_for_each_device (®ulator_class,NULL ,NULL , regulator_late_cleanup); -} - -static DECLARE_DELAYED_WORK(regulator_init_complete_work, - regulator_init_complete_work_function); - -static int __init regulator_init_complete (void ) -{ -/* -* Since DT doesn't provide an idiomatic mechanism for -* enabling full constraints and since it's much more natural -* with DT to provide them just assume that a DT enabled -* system has full constraints. -*/ -if (of_have_populated_dt ()) - has_full_constraints = true; - -/* -* We punt completion for an arbitrary amount of time since -* systems like distros will load many drivers from userspace -* so consumers might not always be ready yet, this is -* particularly an issue with laptops where this might bounce -* the display off then on. Ideally we'd get a notification -* from userspace when this happens but we don't so just wait -* a bit and hope we waited long enough. It'd be better if -* we'd only do this on systems that need it, and a kernel -* command line option might be useful. -*/ -schedule_delayed_work (®ulator_init_complete_work, -msecs_to_jiffies (30000 ));return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 186/199 PCI: Fix Intel ACS quirk UPDCR register address
In reply to Greg Kroah-HartmanFrom: Steffen Liebergeld <[email protected]>
commit d8558ac8c93d429d65d7490b512a3a67e559d0d4 upstream.
According to documentation [0] the correct offset for the Upstream Peer Decode Configuration Register (UPDCR) is 0x1014. It was previously defined as 0x1114.
d99321b63b1f ("PCI: Enable quirks for PCIe ACS on Intel PCH root ports") intended to enforce isolation between PCI devices allowing them to be put into separate IOMMU groups. Due to the wrong register offset the intended isolation was not fully enforced. This is fixed with this patch.
Please note that I did not test this patch because I have no hardware that implements this register.
[0] https://www.intel.com/content/dam/www/public/us/en/documents/datasheets/4th-gen-core-family-mobile-i-o-datasheet.pdf (page 325)
--- drivers/pci/quirks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/quirks.c +1 -1
@@ -4446,7 +4446,7 @@ int pci_dev_specific_acs_enabled(struct#define INTEL_BSPR_REG_BPPD (1 << 9)/* Upstream Peer Decode Configuration Register */ -#define INTEL_UPDCR_REG 0x1114 +#define INTEL_UPDCR_REG 0x1014/* 5:0 Peer Decode Enable bits */ #define INTEL_UPDCR_REG_MASK 0x3f
Greg Kroah-Hartman
maintainerPATCH 187/199 PCI/MSI: Fix incorrect MSI-X masking on resume
In reply to Greg Kroah-HartmanFrom: Jian-Hong Pan <[email protected]>
commit e045fa29e89383c717e308609edd19d2fd29e1be upstream.
When a driver enables MSI-X, msix_program_entries() reads the MSI-X Vector Control register for each vector and saves it in desc->masked. Each register is 32 bits and bit 0 is the actual Mask bit.
When we restored these registers during resume, we previously set the Mask bit if *any* bit in desc->masked was set instead of when the Mask bit itself was set:
pci_restore_state
pci_restore_msi_state
__pci_restore_msix_state
for_each_pci_msi_entry
msix_mask_irq(entry, entry->masked) <-- entire u32 word
__pci_msix_desc_mask_irq(desc, flag)
mask_bits = desc->masked & ~PCI_MSIX_ENTRY_CTRL_MASKBIT
if (flag) <-- testing entire u32, not just bit 0
mask_bits |= PCI_MSIX_ENTRY_CTRL_MASKBIT
writel(mask_bits, desc_addr + PCI_MSIX_ENTRY_VECTOR_CTRL)This means that after resume, MSI-X vectors were masked when they shouldn't be, which leads to timeouts like this:
nvme nvme0: I/O 978 QID 3 timeout, completion polled
On resume, set the Mask bit only when the saved Mask bit from suspend was set.
This should remove the need for 19ea025e1d28 ("nvme: Add quirk for Kingston NVME SSD running FW E8FK11.T").
--- drivers/pci/msi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/msi.c +1 -1
@@ -230,7 +230,7 @@ u32 __pci_msix_desc_mask_irq(struct msi_return 0 ; mask_bits &= ~PCI_MSIX_ENTRY_CTRL_MASKBIT ; -if (flag) +if (flag &PCI_MSIX_ENTRY_CTRL_MASKBIT ) mask_bits |=PCI_MSIX_ENTRY_CTRL_MASKBIT ;writel (mask_bits,pci_msix_desc_addr (desc) +PCI_MSIX_ENTRY_VECTOR_CTRL );
Greg Kroah-Hartman
maintainerPATCH 188/199 xtensa: fix TLB sanity checker
In reply to Greg Kroah-HartmanFrom: Max Filippov <[email protected]>
commit 36de10c4788efc6efe6ff9aa10d38cb7eea4c818 upstream.
Virtual and translated addresses retrieved by the xtensa TLB sanity checker must be consistent, i.e. correspond to the same state of the checked TLB entry. KASAN shadow memory is mapped dynamically using auto-refill TLB entries and thus may change TLB state between the virtual and translated address retrieval, resulting in false TLB insanity report.
Move read_xtlb_translation close to read_xtlb_virtual to make sure that read values are consistent.
--- arch/xtensa/mm/tlb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/xtensa/mm/tlb.c +2 -2
@@ -218,6 +218,8 @@ static int check_tlb_entry(unsigned w, uunsigned tlbidx = w | (e <<PAGE_SHIFT );unsigned r0 = dtlb ?read_dtlb_virtual (tlbidx) :read_itlb_virtual (tlbidx); +unsigned r1 = dtlb ? +read_dtlb_translation (tlbidx) :read_itlb_translation (tlbidx);unsigned vpn = (r0 &PAGE_MASK ) | (e <<PAGE_SHIFT );unsigned pte =get_pte_for_vaddr (vpn);unsigned mm_asid = (get_rasid_register () >>8 ) &ASID_MASK ;
@@ -233,8 +235,6 @@ static int check_tlb_entry(unsigned w, u }if (tlb_asid == mm_asid) { -unsigned r1 = dtlb ?read_dtlb_translation (tlbidx) : -read_itlb_translation (tlbidx);if ((pte ^ r1) &PAGE_MASK ) {pr_err ("%cTLB: way: %u, entry: %u, mapping: %08x->%08x, PTE: %08x\n" , dtlb ?'D' :'I' , w, e, r0, r1, pte);
Greg Kroah-Hartman
maintainerPATCH 189/199 CIFS: Respect O_SYNC and O_DIRECT flags during reconnect
In reply to Greg Kroah-HartmanFrom: Pavel Shilovsky <[email protected]>
commit 44805b0e62f15e90d233485420e1847133716bdc upstream.
Currently the client translates O_SYNC and O_DIRECT flags into corresponding SMB create options when openning a file. The problem is that on reconnect when the file is being re-opened the client doesn't set those flags and it causes a server to reject re-open requests because create options don't match. The latter means that any subsequent system call against that open file fail until a share is re-mounted.
Fix this by properly setting SMB create options when re-openning files after reconnects.
--- fs/cifs/file.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/cifs/file.c +7 -0
@@ -722,6 +722,13 @@ cifs_reopen_file(struct cifsFileInfo *cfif (backup_cred (cifs_sb)) create_options |=CREATE_OPEN_BACKUP_INTENT ; +/* O_SYNC also has bit for O_DSYNC so following check picks up either */ +if (cfile->f_flags &O_SYNC ) + create_options |=CREATE_WRITE_THROUGH ; + +if (cfile->f_flags &O_DIRECT ) + create_options |=CREATE_NO_BUFFER ; +if (server->ops->get_lease_key) server->ops->get_lease_key (inode, &cfile->fid);
Greg Kroah-Hartman
maintainerPATCH 190/199 ARM: dts: s3c64xx: Fix init order of clock providers
In reply to Greg Kroah-HartmanFrom: Lihua Yao <[email protected]>
commit d60d0cff4ab01255b25375425745c3cff69558ad upstream.
fin_pll is the parent of clock-controller@7e00f000, specify the dependency to ensure proper initialization order of clock providers.
without this patch:
[ 0.000000] S3C6410 clocks: apll = 0, mpll = 0 [ 0.000000] epll = 0, arm_clk = 0
with this patch:
[ 0.000000] S3C6410 clocks: apll = 532000000, mpll = 532000000 [ 0.000000] epll = 24000000, arm_clk = 532000000
--- arch/arm/boot/dts/s3c6410-mini6410.dts | 4 ++++ arch/arm/boot/dts/s3c6410-smdk6410.dts | 4 ++++ 2 files changed, 8 insertions(+)
arch/arm/boot/dts/s3c6410-mini6410.dts +4 -0
@@ -167,6 +167,10 @@ }; }; +&clocks { + clocks = <&fin_pll>; +}; + &sdhci0 { pinctrl-names = "default"; pinctrl-0 = <&sd0_clk>, <&sd0_cmd>, <&sd0_cd>, <&sd0_bus4>;
arch/arm/boot/dts/s3c6410-smdk6410.dts +4 -0
@@ -71,6 +71,10 @@ }; }; +&clocks { + clocks = <&fin_pll>; +}; + &sdhci0 { pinctrl-names = "default"; pinctrl-0 = <&sd0_clk>, <&sd0_cmd>, <&sd0_cd>, <&sd0_bus4>;
Greg Kroah-Hartman
maintainerPATCH 191/199 ARM: tegra: Fix FLOW_CTLR_HALT register clobbering by tegra_resume()
In reply to Greg Kroah-HartmanFrom: Dmitry Osipenko <[email protected]>
commit d70f7d31a9e2088e8a507194354d41ea10062994 upstream.
There is an unfortunate typo in the code that results in writing to FLOW_CTLR_HALT instead of FLOW_CTLR_CSR.
--- arch/arm/mach-tegra/reset-handler.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/mach-tegra/reset-handler.S +3 -3
@@ -56,16 +56,16 @@ ENTRY(tegra_resume) cmp r6, #TEGRA20 beq 1f @ Yes /* Clear the flow controller flags for this CPU. */ - cpu_to_csr_reg r1, r0 + cpu_to_csr_reg r3, r0 mov32 r2, TEGRA_FLOW_CTRL_BASE - ldr r1, [r2, r1] + ldr r1, [r2, r3] /* Clear event & intr flag */ orr r1, r1, \ #FLOW_CTRL_CSR_INTR_FLAG | FLOW_CTRL_CSR_EVENT_FLAG movw r0, #0x3FFD @ enable, cluster_switch, immed, bitmaps @ & ext flags for CPU power mgnt bic r1, r1, r0 - str r1, [r2] + str r1, [r2, r3] 1: mov32 r9, 0xc09
Greg Kroah-Hartman
maintainerPATCH 192/199 vfio/pci: call irq_bypass_unregister_producer() before freeing irq
In reply to Greg Kroah-HartmanFrom: Jiang Yi <[email protected]>
commit d567fb8819162099035e546b11a736e29c2af0ea upstream.
Since irq_bypass_register_producer() is called after request_irq(), we should do tear-down in reverse order: irq_bypass_unregister_producer() then free_irq().
Specifically free_irq() may release resources required by the irqbypass del_producer() callback. Notably an example provided by Marc Zyngier on arm64 with GICv4 that he indicates has the potential to wedge the hardware:
free_irq(irq)
__free_irq(irq)
irq_domain_deactivate_irq(irq)
its_irq_domain_deactivate()
[unmap the VLPI from the ITS]
kvm_arch_irq_bypass_del_producer(cons, prod)
kvm_vgic_v4_unset_forwarding(kvm, irq, ...)
its_unmap_vlpi(irq)
[Unmap the VLPI from the ITS (again), remap the original LPI]
--- drivers/vfio/pci/vfio_pci_intrs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vfio/pci/vfio_pci_intrs.c +1 -1
@@ -297,8 +297,8 @@ static int vfio_msi_set_vector_signal(st irq =pci_irq_vector (pdev, vector);if (vdev->ctx[vector].trigger) { -free_irq (irq, vdev->ctx[vector].trigger);irq_bypass_unregister_producer (&vdev->ctx[vector].producer); +free_irq (irq, vdev->ctx[vector].trigger);kfree (vdev->ctx[vector].name);eventfd_ctx_put (vdev->ctx[vector].trigger); vdev->ctx[vector].trigger =NULL ;
Greg Kroah-Hartman
maintainerPATCH 193/199 dma-buf: Fix memory leak in sync_file_merge()
In reply to Greg Kroah-HartmanFrom: Navid Emamdoost <[email protected]>
commit 6645d42d79d33e8a9fe262660a75d5f4556bbea9 upstream.
In the implementation of sync_file_merge() the allocated sync_file is leaked if number of fences overflows. Release sync_file by goto err.
--- drivers/dma-buf/sync_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma-buf/sync_file.c +1 -1
@@ -204,7 +204,7 @@ static struct sync_file *sync_file_merge a_fences =get_fences (a, &a_num_fences); b_fences =get_fences (b, &b_num_fences);if (a_num_fences >INT_MAX - b_num_fences) -return NULL ; + goto err; num_fences = a_num_fences + b_num_fences;
Greg Kroah-Hartman
maintainerPATCH 194/199 dm btree: increase rebalance threshold in __rebalance2()
In reply to Greg Kroah-HartmanFrom: Hou Tao <[email protected]>
commit 474e559567fa631dea8fb8407ab1b6090c903755 upstream.
We got the following warnings from thin_check during thin-pool setup:
$ thin_check /dev/vdb
examining superblock
examining devices tree
missing devices: [1, 84]
too few entries in btree_node: 41, expected at least 42 (block 138, max_entries = 126)
examining mapping treeThe phenomenon is the number of entries in one node of details_info tree is less than (max_entries / 3). And it can be easily reproduced by the following procedures:
$ new a thin pool
$ presume the max entries of details_info tree is 126
$ new 127 thin devices (e.g. 1~127) to make the root node being full
and then split
$ remove the first 43 (e.g. 1~43) thin devices to make the children
reblance repeatedly
$ stop the thin pool
$ thin_checkThe root cause is that the B-tree removal procedure in __rebalance2() doesn't guarantee the invariance: the minimal number of entries in non-root node should be >= (max_entries / 3).
Simply fix the problem by increasing the rebalance threshold to make sure the number of entries in each child will be greater than or equal to (max_entries / 3 + 1), so no matter which child is used for removal, the number will still be valid.
--- drivers/md/persistent-data/dm-btree-remove.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/md/persistent-data/dm-btree-remove.c +7 -1
@@ -203,7 +203,13 @@ static void __rebalance2(struct dm_btreestruct btree_node *right = r->n;uint32_t nr_left =le32_to_cpu (left->header.nr_entries);uint32_t nr_right =le32_to_cpu (right->header.nr_entries); -unsigned threshold =2 *merge_threshold (left) +1 ; +/* +* Ensure the number of entries in each child will be greater +* than or equal to (max_entries / 3 + 1), so no matter which +* child is used for removal, the number will still be not +* less than (max_entries / 3). +*/ +unsigned int threshold =2 * (merge_threshold (left) +1 );if (nr_left + nr_right < threshold) {/*
Greg Kroah-Hartman
maintainerPATCH 195/199 scsi: iscsi: Fix a potential deadlock in the timeout handler
In reply to Greg Kroah-HartmanFrom: Bart Van Assche <[email protected]>
commit 5480e299b5ae57956af01d4839c9fc88a465eeab upstream.
Some time ago the block layer was modified such that timeout handlers are called from thread context instead of interrupt context. Make it safe to run the iSCSI timeout handler in thread context. This patch fixes the following lockdep complaint:
================================
WARNING: inconsistent lock state
5.5.1-dbg+ #11 Not tainted
--------------------------------
inconsistent {IN-SOFTIRQ-W} -> {SOFTIRQ-ON-W} usage.
kworker/7:1H/206 [HC0[0]:SC0[0]:HE1:SE1] takes:ffff88802d9827e8 (&(&session->frwd_lock)->rlock){+.?.}, at: iscsi_eh_cmd_timed_out+0xa6/0x6d0 [libiscsi] {IN-SOFTIRQ-W} state was registered at:
lock_acquire+0x106/0x240 _raw_spin_lock+0x38/0x50 iscsi_check_transport_timeouts+0x3e/0x210 [libiscsi] call_timer_fn+0x132/0x470 __run_timers.part.0+0x39f/0x5b0 run_timer_softirq+0x63/0xc0 __do_softirq+0x12d/0x5fd irq_exit+0xb3/0x110 smp_apic_timer_interrupt+0x131/0x3d0 apic_timer_interrupt+0xf/0x20 default_idle+0x31/0x230 arch_cpu_idle+0x13/0x20 default_idle_call+0x53/0x60 do_idle+0x38a/0x3f0 cpu_startup_entry+0x24/0x30 start_secondary+0x222/0x290 secondary_startup_64+0xa4/0xb0 irq event stamp: 1383705 hardirqs last enabled at (1383705): [<ffffffff81aace5c>] _raw_spin_unlock_irq+0x2c/0x50 hardirqs last disabled at (1383704): [<ffffffff81aacb98>] _raw_spin_lock_irq+0x18/0x50 softirqs last enabled at (1383690): [<ffffffffa0e2efea>] iscsi_queuecommand+0x76a/0xa20 [libiscsi] softirqs last disabled at (1383682): [<ffffffffa0e2e998>] iscsi_queuecommand+0x118/0xa20 [libiscsi]
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
----
lock(&(&session->frwd_lock)->rlock);
<Interrupt>
lock(&(&session->frwd_lock)->rlock);*** DEADLOCK ***
2 locks held by kworker/7:1H/206:
#0: ffff8880d57bf928 ((wq_completion)kblockd){+.+.}, at: process_one_work+0x472/0xab0 #1: ffff88802b9c7de8 ((work_completion)(&q->timeout_work)){+.+.}, at: process_one_work+0x476/0xab0
stack backtrace: CPU: 7 PID: 206 Comm: kworker/7:1H Not tainted 5.5.1-dbg+ #11 Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 Workqueue: kblockd blk_mq_timeout_work Call Trace: dump_stack+0xa5/0xe6 print_usage_bug.cold+0x232/0x23b mark_lock+0x8dc/0xa70 __lock_acquire+0xcea/0x2af0 lock_acquire+0x106/0x240 _raw_spin_lock+0x38/0x50 iscsi_eh_cmd_timed_out+0xa6/0x6d0 [libiscsi] scsi_times_out+0xf4/0x440 [scsi_mod] scsi_timeout+0x1d/0x20 [scsi_mod] blk_mq_check_expired+0x365/0x3a0 bt_iter+0xd6/0xf0 blk_mq_queue_tag_busy_iter+0x3de/0x650 blk_mq_timeout_work+0x1af/0x380 process_one_work+0x56d/0xab0 worker_thread+0x7a/0x5d0 kthread+0x1bc/0x210 ret_from_fork+0x24/0x30
--- drivers/scsi/libiscsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/libiscsi.c +2 -2
@@ -1982,7 +1982,7 @@ static enum blk_eh_timer_return iscsi_ehISCSI_DBG_EH (session,"scsi cmd %p timedout\n" , sc); -spin_lock (&session->frwd_lock); +spin_lock_bh (&session->frwd_lock); task = (struct iscsi_task *)sc->SCp.ptr;if (!task) {/*
@@ -2109,7 +2109,7 @@ static enum blk_eh_timer_return iscsi_eh done:if (task) task->last_timeout = jiffies; -spin_unlock (&session->frwd_lock); +spin_unlock_bh (&session->frwd_lock);ISCSI_DBG_EH (session,"return %s\n" , rc ==BLK_EH_RESET_TIMER ?"timer reset" :"shutdown or nh" );return rc;
Greg Kroah-Hartman
maintainerPATCH 196/199 drm/radeon: fix r1xx/r2xx register checker for POT textures
In reply to Greg Kroah-HartmanFrom: Alex Deucher <[email protected]>
commit 008037d4d972c9c47b273e40e52ae34f9d9e33e7 upstream.
Shift and mask were reversed. Noticed by chance.
--- drivers/gpu/drm/radeon/r100.c | 4 ++-- drivers/gpu/drm/radeon/r200.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/radeon/r100.c +2 -2
@@ -1824,8 +1824,8 @@ static int r100_packet0_check(struct rad track->textures[i].use_pitch =1 ; }else { track->textures[i].use_pitch =0 ; - track->textures[i].width =1 << ((idx_value >>RADEON_TXFORMAT_WIDTH_SHIFT ) &RADEON_TXFORMAT_WIDTH_MASK ); - track->textures[i].height =1 << ((idx_value >>RADEON_TXFORMAT_HEIGHT_SHIFT ) &RADEON_TXFORMAT_HEIGHT_MASK ); + track->textures[i].width =1 << ((idx_value &RADEON_TXFORMAT_WIDTH_MASK ) >>RADEON_TXFORMAT_WIDTH_SHIFT ); + track->textures[i].height =1 << ((idx_value &RADEON_TXFORMAT_HEIGHT_MASK ) >>RADEON_TXFORMAT_HEIGHT_SHIFT ); }if (idx_value &RADEON_TXFORMAT_CUBIC_MAP_ENABLE ) track->textures[i].tex_coord_type =2 ;
drivers/gpu/drm/radeon/r200.c +2 -2
@@ -476,8 +476,8 @@ int r200_packet0_check(struct radeon_cs_ track->textures[i].use_pitch =1 ; }else { track->textures[i].use_pitch =0 ; - track->textures[i].width =1 << ((idx_value >>RADEON_TXFORMAT_WIDTH_SHIFT ) &RADEON_TXFORMAT_WIDTH_MASK ); - track->textures[i].height =1 << ((idx_value >>RADEON_TXFORMAT_HEIGHT_SHIFT ) &RADEON_TXFORMAT_HEIGHT_MASK ); + track->textures[i].width =1 << ((idx_value &RADEON_TXFORMAT_WIDTH_MASK ) >>RADEON_TXFORMAT_WIDTH_SHIFT ); + track->textures[i].height =1 << ((idx_value &RADEON_TXFORMAT_HEIGHT_MASK ) >>RADEON_TXFORMAT_HEIGHT_SHIFT ); }if (idx_value &R200_TXFORMAT_LOOKUP_DISABLE ) track->textures[i].lookup_disable = true;
Greg Kroah-Hartman
maintainerPATCH 197/199 xhci: fix USB3 device initiated resume race with roothub autosuspend
In reply to Greg Kroah-HartmanFrom: Mathias Nyman <[email protected]>
commit 057d476fff778f1d3b9f861fdb5437ea1a3cfc99 upstream.
A race in xhci USB3 remote wake handling may force device back to suspend after it initiated resume siganaling, causing a missed resume event or warm reset of device.
When a USB3 link completes resume signaling and goes to enabled (UO) state a interrupt is issued and the interrupt handler will clear the bus_state->port_remote_wakeup resume flag, allowing bus suspend.
If the USB3 roothub thread just finished reading port status before the interrupt, finding ports still in suspended (U3) state, but hasn't yet started suspending the hub, then the xhci interrupt handler will clear the flag that prevented roothub suspend and allow bus to suspend, forcing all port links back to suspended (U3) state.
Example case:usb_runtime_suspend() # because all ports still show suspended U3
usb_suspend_both()
hub_suspend(); # successful as hub->wakeup_bits not set yet
==> INTERRUPT
xhci_irq()
handle_port_status()
clear bus_state->port_remote_wakeup
usb_wakeup_notification()
sets hub->wakeup_bits;
kick_hub_wq()<== END INTERRUPT
hcd_bus_suspend()
xhci_bus_suspend() # success as port_remote_wakeup bits cleared
Fix this by increasing roothub usage count during port resume to prevent roothub autosuspend, and by making sure bus_state->port_remote_wakeup flag is only cleared after resume completion is visible, i.e. after xhci roothub returned U0 or other non-U3 link state link on a get port status request.
Issue rootcaused by Chiasheng Lee
--- drivers/usb/host/xhci-hub.c | 8 ++++++++ drivers/usb/host/xhci-ring.c | 6 +----- drivers/usb/host/xhci.h | 1 + 3 files changed, 10 insertions(+), 5 deletions(-)
drivers/usb/host/xhci-hub.c +8 -0
@@ -760,6 +760,14 @@ static u32 xhci_get_port_status(struct u status |=USB_PORT_STAT_C_BH_RESET <<16 ;if ((raw_port_status &PORT_CEC )) status |=USB_PORT_STAT_C_CONFIG_ERROR <<16 ; + +/* USB3 remote wake resume signaling completed */ +if (bus_state->port_remote_wakeup & (1 << wIndex) && + (raw_port_status &PORT_PLS_MASK ) !=XDEV_RESUME && + (raw_port_status &PORT_PLS_MASK ) !=XDEV_RECOVERY ) { + bus_state->port_remote_wakeup &= ~(1 << wIndex); +usb_hcd_end_port_resume (&hcd->self, wIndex); + } }if (hcd->speed <HCD_USB3 ) {
drivers/usb/host/xhci-ring.c +1 -5
@@ -1609,9 +1609,6 @@ static void handle_port_status(struct xhusb_hcd_resume_root_hub (hcd); } -if (hcd->speed >=HCD_USB3 && (temp &PORT_PLS_MASK ) ==XDEV_INACTIVE ) - bus_state->port_remote_wakeup &= ~(1 << faked_port_index); -if ((temp &PORT_PLC ) && (temp &PORT_PLS_MASK ) ==XDEV_RESUME ) {xhci_dbg (xhci,"port resume event for port %d\n" , port_id);
@@ -1630,6 +1627,7 @@ static void handle_port_status(struct xh bus_state->port_remote_wakeup |=1 << faked_port_index;xhci_test_and_clear_bit (xhci, port_array, faked_port_index,PORT_PLC ); +usb_hcd_start_port_resume (&hcd->self, faked_port_index);xhci_set_link_state (xhci, port_array, faked_port_index,XDEV_U0 );/* Need to wait until the next link state change
@@ -1667,8 +1665,6 @@ static void handle_port_status(struct xhif (slot_id && xhci->devs[slot_id])xhci_ring_device (xhci, slot_id);if (bus_state->port_remote_wakeup & (1 << faked_port_index)) { - bus_state->port_remote_wakeup &= - ~(1 << faked_port_index);xhci_test_and_clear_bit (xhci, port_array, faked_port_index,PORT_PLC ); usb_wakeup_notification(hcd->self.root_hub,
drivers/usb/host/xhci.h +1 -0
@@ -316,6 +316,7 @@ struct xhci_op_regs {#define XDEV_U3 (0x3 << 5)#define XDEV_INACTIVE (0x6 << 5)#define XDEV_POLLING (0x7 << 5) +#define XDEV_RECOVERY (0x8 << 5)#define XDEV_COMP_MODE (0xa << 5)#define XDEV_RESUME (0xf << 5)/* true: port has power (see HCC_PPC) */
Greg Kroah-Hartman
maintainerPATCH 198/199 net: stmmac: use correct DMA buffer size in the RX descriptor
In reply to Greg Kroah-HartmanFrom: Aaro Koskinen <[email protected]>
commit 583e6361414903c5206258a30e5bd88cb03c0254 upstream.
We always program the maximum DMA buffer size into the receive descriptor, although the allocated size may be less. E.g. with the default MTU size we allocate only 1536 bytes. If somebody sends us a bigger frame, then memory may get corrupted.
Fix by using exact buffer sizes.
[acj: backport to v4.9 -stable :
- adjust context
- skipped the section modifying non-existent functions in dwxgmac2_descs.c and hwif.h ]
--- drivers/net/ethernet/stmicro/stmmac/common.h | 2 - drivers/net/ethernet/stmicro/stmmac/descs_com.h | 23 +++++++++++++-------- drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c | 2 - drivers/net/ethernet/stmicro/stmmac/enh_desc.c | 10 ++++++--- drivers/net/ethernet/stmicro/stmmac/norm_desc.c | 10 ++++++--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 ++--- 6 files changed, 34 insertions(+), 19 deletions(-)
drivers/net/ethernet/stmicro/stmmac/common.h +1 -1
@@ -354,7 +354,7 @@ struct dma_features {struct stmmac_desc_ops {/* DMA RX descriptor ring initialization */ void (*init_rx_desc) (struct dma_desc *p,int disable_rx_ic,int mode, -int end); +int end,int bfsize);/* DMA TX descriptor ring initialization */ void (*init_tx_desc) (struct dma_desc *p,int mode,int end);
drivers/net/ethernet/stmicro/stmmac/descs_com.h +15 -8
@@ -33,11 +33,14 @@/* Specific functions used for Ring mode */ /* Enhanced descriptors */ -static inline void ehn_desc_rx_set_on_ring (struct dma_desc *p,int end) +static inline void ehn_desc_rx_set_on_ring (struct dma_desc *p,int end, +int bfsize) { - p->des1 |=cpu_to_le32 (((BUF_SIZE_8KiB -1 ) - <<ERDES1_BUFFER2_SIZE_SHIFT ) - &ERDES1_BUFFER2_SIZE_MASK ); +if (bfsize == BUF_SIZE_16KiB) + p->des1 |=cpu_to_le32 ((BUF_SIZE_8KiB + <<ERDES1_BUFFER2_SIZE_SHIFT ) + &ERDES1_BUFFER2_SIZE_MASK ); +if (end) p->des1 |=cpu_to_le32 (ERDES1_END_RING );
@@ -63,11 +66,15 @@ static inline void enh_set_tx_desc_len_o }/* Normal descriptors */ -static inline void ndesc_rx_set_on_ring (struct dma_desc *p,int end) +static inline void ndesc_rx_set_on_ring (struct dma_desc *p,int end,int bfsize) { - p->des1 |=cpu_to_le32 (((BUF_SIZE_2KiB -1 ) - <<RDES1_BUFFER2_SIZE_SHIFT ) - &RDES1_BUFFER2_SIZE_MASK ); +if (bfsize >= BUF_SIZE_2KiB) { +int bfsize2; + + bfsize2 =min (bfsize - BUF_SIZE_2KiB +1 , BUF_SIZE_2KiB -1 ); + p->des1 |=cpu_to_le32 ((bfsize2 <<RDES1_BUFFER2_SIZE_SHIFT ) + &RDES1_BUFFER2_SIZE_MASK ); + }if (end) p->des1 |=cpu_to_le32 (RDES1_END_RING );
drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c +1 -1
@@ -289,7 +289,7 @@ exit: }static void dwmac4_rd_init_rx_desc (struct dma_desc *p,int disable_rx_ic, -int mode,int end) +int mode,int end,int bfsize) { p->des3 =cpu_to_le32 (RDES3_OWN |RDES3_BUFFER1_VALID_ADDR );
drivers/net/ethernet/stmicro/stmmac/enh_desc.c +7 -3
@@ -269,15 +269,19 @@ static int enh_desc_get_rx_status(void * }static void enh_desc_init_rx_desc (struct dma_desc *p,int disable_rx_ic, -int mode,int end) +int mode,int end,int bfsize) { +int bfsize1; + p->des0 |=cpu_to_le32 (RDES0_OWN ); - p->des1 |=cpu_to_le32 ((BUF_SIZE_8KiB -1 ) &ERDES1_BUFFER1_SIZE_MASK ); + + bfsize1 =min (bfsize, BUF_SIZE_8KiB); + p->des1 |=cpu_to_le32 (bfsize1 &ERDES1_BUFFER1_SIZE_MASK );if (mode ==STMMAC_CHAIN_MODE )ehn_desc_rx_set_on_chain (p);else -ehn_desc_rx_set_on_ring (p, end); +ehn_desc_rx_set_on_ring (p, end, bfsize);if (disable_rx_ic) p->des1 |=cpu_to_le32 (ERDES1_DISABLE_IC );
drivers/net/ethernet/stmicro/stmmac/norm_desc.c +7 -3
@@ -137,15 +137,19 @@ static int ndesc_get_rx_status(void *dat }static void ndesc_init_rx_desc (struct dma_desc *p,int disable_rx_ic,int mode, -int end) +int end,int bfsize) { +int bfsize1; + p->des0 |=cpu_to_le32 (RDES0_OWN ); - p->des1 |=cpu_to_le32 ((BUF_SIZE_2KiB -1 ) &RDES1_BUFFER1_SIZE_MASK ); + + bfsize1 =min (bfsize, BUF_SIZE_2KiB -1 ); + p->des1 |=cpu_to_le32 (bfsize1 &RDES1_BUFFER1_SIZE_MASK );if (mode ==STMMAC_CHAIN_MODE )ndesc_rx_set_on_chain (p, end);else -ndesc_rx_set_on_ring (p, end); +ndesc_rx_set_on_ring (p, end, bfsize);if (disable_rx_ic) p->des1 |=cpu_to_le32 (RDES1_DISABLE_IC );
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +3 -3
@@ -956,11 +956,11 @@ static void stmmac_clear_descriptors(strif (priv->extend_desc) priv->hw->desc->init_rx_desc (&priv->dma_erx[i].basic, priv->use_riwt, priv->mode, - (i ==DMA_RX_SIZE -1 )); + (i ==DMA_RX_SIZE -1 ), priv->dma_buf_sz);else priv->hw->desc->init_rx_desc (&priv->dma_rx[i], priv->use_riwt, priv->mode, - (i ==DMA_RX_SIZE -1 )); + (i ==DMA_RX_SIZE -1 ), priv->dma_buf_sz);for (i =0 ; i <DMA_TX_SIZE ; i++)if (priv->extend_desc) priv->hw->desc->init_tx_desc(&priv->dma_etx[i].basic,
@@ -2479,7 +2479,7 @@ static inline void stmmac_rx_refill(struwmb ();if (unlikely (priv->synopsys_id >=DWMAC_CORE_4_00 )) - priv->hw->desc->init_rx_desc (p, priv->use_riwt,0 ,0 ); + priv->hw->desc->init_rx_desc (p, priv->use_riwt,0 ,0 , priv->dma_buf_sz);else priv->hw->desc->set_rx_owner (p);
Greg Kroah-Hartman
maintainerPATCH 199/199 net: stmmac: dont stop NAPI processing when dropping a packet
In reply to Greg Kroah-HartmanFrom: Aaro Koskinen <[email protected]>
commit 07b3975352374c3f5ebb4a42ef0b253fe370542d upstream.
Currently, if we drop a packet, we exit from NAPI loop before the budget is consumed. In some situations this will make the RX processing stall e.g. when flood pinging the system with oversized packets, as the errorneous packets are not dropped efficiently.
If we drop a packet, we should just continue to the next one as long as the budget allows.
[acj: backport v4.9 -stable
-adjust context]
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +7 -7
@@ -2499,8 +2499,7 @@ static inline void stmmac_rx_refill(stru*/ static int stmmac_rx (struct stmmac_priv *priv,int limit) { -unsigned int entry = priv->cur_rx; -unsigned int next_entry; +unsigned int next_entry = priv->cur_rx;unsigned int count =0 ;int coe = priv->hw->rx_csum;
@@ -2516,10 +2515,12 @@ static int stmmac_rx(struct stmmac_priv priv->hw->desc->display_ring (rx_head,DMA_RX_SIZE , true); }while (count < limit) { -int status; +int entry, status;struct dma_desc *p;struct dma_desc *np; + entry = next_entry; +if (priv->extend_desc) p = (struct dma_desc *)(priv->dma_erx + entry);else
@@ -2584,7 +2585,7 @@ static int stmmac_rx(struct stmmac_priv priv->dev->name, frame_len, priv->dma_buf_sz); priv->dev->stats.rx_length_errors++; -break ; +continue ; }/* ACS is set; GMAC core strips PAD/FCS for IEEE 802.3
@@ -2615,7 +2616,7 @@ static int stmmac_rx(struct stmmac_privdev_warn (priv->device,"packet dropped\n" ); priv->dev->stats.rx_dropped++; -break ; +continue ; } dma_sync_single_for_cpu(priv->device,
@@ -2638,7 +2639,7 @@ static int stmmac_rx(struct stmmac_privpr_err ("%s: Inconsistent Rx chain\n" , priv->dev->name); priv->dev->stats.rx_dropped++; -break ; +continue ; }prefetch (skb->data -NET_IP_ALIGN ); priv->rx_skbuff[entry] =NULL ;
@@ -2672,7 +2673,6 @@ static int stmmac_rx(struct stmmac_priv priv->dev->stats.rx_packets++; priv->dev->stats.rx_bytes += frame_len; } - entry = next_entry; }stmmac_rx_refill (priv);
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.9.207 release. There are 199 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat, 21 Dec 2019 18:24:44 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.207-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.9.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.9.207 release. There are 199 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat, 21 Dec 2019 18:24:44 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.207-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.9.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.
Summary
------------------------------------------------------------------------
kernel: 4.9.207-rc1
git repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
git branch: linux-4.9.y
git commit: c87cf142499122d38d7dc3cb92c9e9072d646591
git describe: v4.9.206-200-gc87cf1424991
Test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-4.9-oe/build/v4.9.206-200-gc87cf1424991
No regressions (compared to build v4.9.206)
No fixes (compared to build v4.9.206)
Ran 23314 total tests in the following environments and test suites.
Environments
--------------
- dragonboard-410c - arm64
- hi6220-hikey - arm64
- i386
- juno-r2 - arm64
- qemu_arm
- qemu_arm64
- qemu_i386
- qemu_x86_64
- x15 - arm
- x86_64
Test Suites
-----------
* build
* install-android-platform-tools-r2600
* linux-log-parser
* ltp-cap_bounds-tests
* ltp-commands-tests
* ltp-containers-tests
* ltp-cpuhotplug-tests
* ltp-cve-tests
* ltp-dio-tests
* ltp-fcntl-locktests-tests
* ltp-filecaps-tests
* ltp-fs_bind-tests
* ltp-fs_perms_simple-tests
* ltp-fsx-tests
* ltp-hugetlb-tests
* ltp-io-tests
* ltp-ipc-tests
* ltp-math-tests
* ltp-mm-tests
* ltp-nptl-tests
* ltp-pty-tests
* ltp-sched-tests
* ltp-securebits-tests
* ltp-syscalls-tests
* perf
* spectre-meltdown-checker-test
* v4l2-compliance
* kselftest
* libhugetlbfs
* ltp-fs-tests
* network-basic-tests
* ltp-open-posix-tests
* prep-tmp-disk
* kvm-unit-tests
* kselftest-vsyscall-mode-native
* ssuite
Signature · 2 lines
Linaro LKFT https://lkft.linaro.org
Jon Hunter
maintainerQuoted 14 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.9.207 release. There are 199 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat, 21 Dec 2019 18:24:44 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.207-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.9.y
and the diffstat can be found below.
Quoted 5 lines
thanks,
greg k-h
-------------
All tests are passing for Tegra ...
Test results for stable-v4.9:
8 builds: 8 pass, 0 fail
16 boots: 16 pass, 0 fail
24 tests: 24 pass, 0 failLinux version: 4.9.207-rc1-gc87cf1424991
Boards tested: tegra124-jetson-tk1, tegra20-ventana,
tegra210-p2371-2180, tegra30-cardhu-a04
Cheers
Jon
Signature · 1 line
nvpublic
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.9.207 release. There are 199 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat, 21 Dec 2019 18:24:44 +0000. Anything received after that time might be too late.
Build results:
total: 172 pass: 172 fail: 0 Qemu test results: total: 359 pass: 359 fail: 0
Guenter