3.16.57-rc1 review
Subsystems (16)
PATCH 285/410 batman-adv: Fix internal interface indices types
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit f22e08932c2960f29b5e828e745c9f3fb7c1bb86 upstream.
batman-adv uses internal indices for each enabled and active interface. It is currently used by the B.A.T.M.A.N. IV algorithm to identifify the correct position in the ogm_cnt bitmaps.
The type for the number of enabled interfaces (which defines the next interface index) was set to char. This type can be (depending on the architecture) either signed (limiting batman-adv to 127 active slave interfaces) or unsigned (limiting batman-adv to 255 active slave interfaces).
This limit was not correctly checked when an interface was enabled and thus an overflow happened. This was only catched on systems with the signed char type when the B.A.T.M.A.N. IV code tried to resize its counter arrays with a negative size.
The if_num interface index was only a s16 and therefore significantly smaller than the ifindex (int) used by the code net code.
Both &batadv_hard_iface->if_num and &batadv_priv->num_ifaces must be (unsigned) int to support the same number of slave interfaces as the net core code. And the interface activation code must check the number of active slave interfaces to avoid integer overflows.
[bwh: Backported to 3.16:
- Drop changes in batadv_iv_ogm_{drop_bcast_{own,sum}_entry,orig_get}()
- Adjust context]
---
net/batman-adv/bat_iv_ogm.c +9 -7
@@ -105,7 +105,7 @@ static void batadv_iv_ogm_orig_free(stru* Returns 0 on success, a negative error code otherwise. */ static int batadv_iv_ogm_orig_add_if (struct batadv_orig_node *orig_node, -int max_if_num) +unsigned int max_if_num) {void *data_ptr;size_t data_size, old_size;
@@ -150,7 +150,8 @@ unlock:* Returns 0 on success, a negative error code otherwise. */ static int batadv_iv_ogm_orig_del_if (struct batadv_orig_node *orig_node, -int max_if_num,int del_if_num) +unsigned int max_if_num, +unsigned int del_if_num) {int chunk_size, ret = -ENOMEM , if_offset;void *data_ptr =NULL ;
@@ -867,7 +868,7 @@ batadv_iv_ogm_slide_own_bcast_window(struint32_t i;size_t word_index;uint8_t *w; -int if_num; +unsigned int if_num;for (i =0 ; i < hash->size; i++) { head = &hash->table[i];
@@ -977,7 +978,7 @@ batadv_iv_ogm_orig_update(struct batadv_struct batadv_neigh_node *neigh_node =NULL , *tmp_neigh_node =NULL ;struct batadv_neigh_node *router =NULL ;struct batadv_orig_node *orig_node_tmp; -int if_num; +unsigned int if_num;uint8_t sum_orig, sum_neigh;uint8_t *neigh_addr;uint8_t tq_avg;
@@ -1134,7 +1135,8 @@ static int batadv_iv_ogm_calc_tq(structuint8_t total_count;uint8_t orig_eq_count, neigh_rq_count, neigh_rq_inv, tq_own;unsigned int neigh_rq_inv_cube, neigh_rq_max_cube; -int if_num, ret =0 ; +unsigned int if_num; +int ret =0 ;unsigned int tq_asym_penalty, inv_asym_penalty;unsigned int combined_tq;unsigned int tq_iface_penalty;
@@ -1641,9 +1643,9 @@ static void batadv_iv_ogm_process(constif (is_my_orig) {unsigned long *word; -int offset; +size_t offset;int32_t bit_pos; -int16_t if_num; +unsigned int if_num;uint8_t *weight; orig_neigh_node = batadv_iv_ogm_orig_get(bat_priv,
net/batman-adv/hard-interface.c +7 -2
@@ -411,6 +411,11 @@ int batadv_hardif_enable_interface(struc hard_iface->soft_iface = soft_iface; bat_priv =netdev_priv (hard_iface->soft_iface); +if (bat_priv->num_ifaces >=UINT_MAX ) { + ret = -ENOSPC ; + goto err_dev; + } + ret =netdev_master_upper_dev_link (hard_iface->net_dev, soft_iface);if (ret) goto err_dev;
@@ -514,7 +519,7 @@ void batadv_hardif_disable_interface(strdev_put (hard_iface->soft_iface);/* nobody uses this interface anymore */ -if (!bat_priv->num_ifaces) { +if (bat_priv->num_ifaces ==0 ) {batadv_gw_check_client_stop (bat_priv);if (autodel ==BATADV_IF_CLEANUP_AUTO )
@@ -571,7 +576,7 @@ batadv_hardif_add_interface(struct net_dif (ret) goto free_if; - hard_iface->if_num =-1 ; + hard_iface->if_num =0 ; hard_iface->net_dev = net_dev; hard_iface->soft_iface =NULL ; hard_iface->if_status =BATADV_IF_NOT_IN_USE ;
net/batman-adv/originator.c +2 -2
@@ -1069,7 +1069,7 @@ out: }int batadv_orig_hash_add_if (struct batadv_hard_iface *hard_iface, -int max_if_num) +unsigned int max_if_num) {struct batadv_priv *bat_priv =netdev_priv (hard_iface->soft_iface);struct batadv_algo_ops *bao = bat_priv->bat_algo_ops;
@@ -1105,7 +1105,7 @@ err: }int batadv_orig_hash_del_if (struct batadv_hard_iface *hard_iface, -int max_if_num) +unsigned int max_if_num) {struct batadv_priv *bat_priv =netdev_priv (hard_iface->soft_iface);struct batadv_hashtable *hash = bat_priv->orig_hash;
net/batman-adv/originator.h +2 -2
@@ -58,9 +58,9 @@ void batadv_orig_ifinfo_free_ref(structint batadv_orig_seq_print_text (struct seq_file *seq,void *offset);int batadv_orig_hardif_seq_print_text (struct seq_file *seq,void *offset);int batadv_orig_hash_add_if (struct batadv_hard_iface *hard_iface, -int max_if_num); +unsigned int max_if_num);int batadv_orig_hash_del_if (struct batadv_hard_iface *hard_iface, -int max_if_num); +unsigned int max_if_num);struct batadv_orig_node_vlan *batadv_orig_node_vlan_new (struct batadv_orig_node *orig_node,unsigned short vid);
net/batman-adv/types.h +5 -4
@@ -89,7 +89,7 @@ struct batadv_hard_iface_bat_iv {*/ struct batadv_hard_iface {struct list_head list; -int16_t if_num; +unsigned int if_num;char if_status;struct net_device *net_dev;uint8_t num_bcasts;
@@ -795,7 +795,7 @@ struct batadv_priv {atomic_t bcast_seqno;atomic_t bcast_queue_left;atomic_t batman_queue_left; -char num_ifaces; +unsigned int num_ifaces;struct kobject *mesh_obj;struct dentry *debug_dir;struct hlist_head forw_bat_list;
@@ -1166,9 +1166,10 @@ struct batadv_algo_ops { struct batadv_hard_iface *hard_iface);void (*bat_orig_free)(struct batadv_orig_node *orig_node);int (*bat_orig_add_if)(struct batadv_orig_node *orig_node, -int max_if_num); +unsigned int max_if_num);int (*bat_orig_del_if)(struct batadv_orig_node *orig_node, -int max_if_num,int del_if_num); +unsigned int max_if_num, +unsigned int del_if_num); };/**
PATCH 286/410 clocksource/drivers/fsl_ftm_timer: Fix error return checking
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Colin Ian King <[email protected]>
commit f287eb9013ccf199cbfa4eabd80c36fedfc15a73 upstream.
The error checks on freq for a negative error return always fails because freq is unsigned and can never be negative. Fix this by making freq a signed long.
Detected with Coccinelle:
drivers/clocksource/fsl_ftm_timer.c:287:5-9: WARNING: Unsigned expression compared with zero: freq <= 0 drivers/clocksource/fsl_ftm_timer.c:291:5-9: WARNING: Unsigned expression compared with zero: freq <= 0
--- drivers/clocksource/fsl_ftm_timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/fsl_ftm_timer.c +1 -1
@@ -282,7 +282,7 @@ static int __init __ftm_clk_init(structstatic unsigned long __init ftm_clk_init (struct device_node *np) { -unsigned long freq; +long freq; freq =__ftm_clk_init (np,"ftm-evt-counter-en" ,"ftm-evt" );if (freq <=0 )
PATCH 287/410 l2tp: remove l2tp_tunnel_count and l2tp_session_count
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Nault <[email protected]>
commit c7fa745d988812c4dea7dbc645f025c5bfa4917e upstream.
These variables have never been used.
--- net/l2tp/l2tp_core.c | 10 ---------- 1 file changed, 10 deletions(-)
net/l2tp/l2tp_core.c +0 -10
@@ -99,8 +99,6 @@ struct l2tp_skb_cb {#define L2TP_SKB_CB (skb) ((struct l2tp_skb_cb *) &skb->cb[sizeof(struct inet_skb_parm)]) -static atomic_t l2tp_tunnel_count; -static atomic_t l2tp_session_count;static struct workqueue_struct *l2tp_wq;/* per-net private data for this module */
@@ -419,10 +417,6 @@ int l2tp_session_register(struct l2tp_sehlist_add_head (&session->hlist, head);write_unlock_bh (&tunnel->hlist_lock); -/* Ignore management session in session count value */ -if (session->session_id !=0 ) -atomic_inc (&l2tp_session_count); -return 0 ; err_tlock_pnlock:
@@ -1327,7 +1321,6 @@ static void l2tp_tunnel_destruct(structspin_lock_bh (&pn->l2tp_tunnel_list_lock);list_del_rcu (&tunnel->list);spin_unlock_bh (&pn->l2tp_tunnel_list_lock); -atomic_dec (&l2tp_tunnel_count);l2tp_tunnel_closeall (tunnel);
@@ -1749,7 +1742,6 @@ int l2tp_tunnel_create(struct net *net,/* Add tunnel to our list */ INIT_LIST_HEAD (&tunnel->list); -atomic_inc (&l2tp_tunnel_count);/* Bump the reference count. The tunnel context is deleted * only when this drops to zero. Must be done before list insertion
@@ -1795,8 +1787,6 @@ void l2tp_session_free(struct l2tp_sessiif (tunnel) {BUG_ON (tunnel->magic !=L2TP_TUNNEL_MAGIC ); -if (session->session_id !=0 ) -atomic_dec (&l2tp_session_count);sock_put (tunnel->sock); session->tunnel =NULL ;l2tp_tunnel_dec_refcount (tunnel);
PATCH 288/410 l2tp: don't close sessions in l2tp_tunnel_destruct()
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Nault <[email protected]>
commit 765924e362d12f87786060b98a49abd91e11ea96 upstream.
Sessions are already removed by the proto ->destroy() handlers, and
since commit f3c66d4e144a ("l2tp: prevent creation of sessions on terminated tunnels"), we're guaranteed that no new session can be created afterwards.
Furthermore, l2tp_tunnel_closeall() can sleep when there are sessions left to close. So we really shouldn't call it in a ->sk_destruct() handler, as it can be used from atomic context.
--- net/l2tp/l2tp_core.c | 2 -- 1 file changed, 2 deletions(-)
net/l2tp/l2tp_core.c +0 -2
@@ -1322,8 +1322,6 @@ static void l2tp_tunnel_destruct(structlist_del_rcu (&tunnel->list);spin_unlock_bh (&pn->l2tp_tunnel_list_lock); -l2tp_tunnel_closeall (tunnel); - tunnel->sock =NULL ;l2tp_tunnel_dec_refcount (tunnel);
PATCH 289/410 l2tp: avoid using ->tunnel_sock for getting session's parent tunnel
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Nault <[email protected]>
commit 7198c77aa05560c257ee377ec1f4796812121580 upstream.
Sessions don't need to use l2tp_sock_to_tunnel(xxx->tunnel_sock) for accessing their parent tunnel. They have the .tunnel field in the l2tp_session structure for that. Furthermore, in all these cases, the session is registered, so we're guaranteed that .tunnel isn't NULL and that the session properly holds a reference on the tunnel.
--- net/l2tp/l2tp_ppp.c | 66 +++++++++------------------------------------ 1 file changed, 12 insertions(+), 54 deletions(-)
net/l2tp/l2tp_ppp.c +12 -54
@@ -312,7 +312,6 @@ static int pppol2tp_sendmsg(struct kiocbint error;struct l2tp_session *session;struct l2tp_tunnel *tunnel; -struct pppol2tp_session *ps;int uhlen; error = -ENOTCONN ;
@@ -325,10 +324,7 @@ static int pppol2tp_sendmsg(struct kiocbif (session ==NULL ) goto error; - ps =l2tp_session_priv (session); - tunnel =l2tp_sock_to_tunnel (ps->tunnel_sock); -if (tunnel ==NULL ) - goto error_put_sess; + tunnel = session->tunnel; uhlen = (tunnel->encap ==L2TP_ENCAPTYPE_UDP ) ?sizeof (struct udphdr ) :0 ;
@@ -339,7 +335,7 @@ static int pppol2tp_sendmsg(struct kiocbsizeof (ppph) + total_len, 0, GFP_KERNEL);if (!skb) - goto error_put_sess_tun; + goto error_put_sess;/* Reserve space for headers. */ skb_reserve (skb,NET_SKB_PAD );
@@ -358,20 +354,17 @@ static int pppol2tp_sendmsg(struct kiocb total_len);if (error <0 ) {kfree_skb (skb); - goto error_put_sess_tun; + goto error_put_sess; }local_bh_disable ();l2tp_xmit_skb (session, skb, session->hdr_len);local_bh_enable (); -sock_put (ps->tunnel_sock);sock_put (sk);return total_len; -error_put_sess_tun: -sock_put (ps->tunnel_sock); error_put_sess:sock_put (sk); error:
@@ -396,10 +389,8 @@ static int pppol2tp_xmit(struct ppp_chan {static const u8 ppph[2 ] = {0xff ,0x03 };struct sock *sk = (struct sock *) chan->private; -struct sock *sk_tun;struct l2tp_session *session;struct l2tp_tunnel *tunnel; -struct pppol2tp_session *ps;int uhlen, headroom;if (sock_flag (sk,SOCK_DEAD ) || !(sk->sk_state &PPPOX_CONNECTED ))
@@ -410,13 +401,7 @@ static int pppol2tp_xmit(struct ppp_chanif (session ==NULL ) goto abort; - ps =l2tp_session_priv (session); - sk_tun = ps->tunnel_sock; -if (sk_tun ==NULL ) - goto abort_put_sess; - tunnel =l2tp_sock_to_tunnel (sk_tun); -if (tunnel ==NULL ) - goto abort_put_sess; + tunnel = session->tunnel; uhlen = (tunnel->encap ==L2TP_ENCAPTYPE_UDP ) ?sizeof (struct udphdr ) :0 ; headroom = NET_SKB_PAD +
@@ -425,7 +410,7 @@ static int pppol2tp_xmit(struct ppp_chan session->hdr_len +/* L2TP header */ sizeof (ppph);/* PPP header */ if (skb_cow_head (skb, headroom)) - goto abort_put_sess_tun; + goto abort_put_sess;/* Setup PPP header */ __skb_push (skb,sizeof (ppph));
@@ -436,12 +421,10 @@ static int pppol2tp_xmit(struct ppp_chanl2tp_xmit_skb (session, skb, session->hdr_len);local_bh_enable (); -sock_put (sk_tun);sock_put (sk); +return 1 ; -abort_put_sess_tun: -sock_put (sk_tun); abort_put_sess:sock_put (sk); abort:
@@ -938,9 +921,7 @@ static int pppol2tp_getname(struct socke goto end; pls =l2tp_session_priv (session); - tunnel =l2tp_sock_to_tunnel (pls->tunnel_sock); -if (tunnel ==NULL ) - goto end_put_sess; + tunnel = session->tunnel; inet =inet_sk (tunnel->sock);if ((tunnel->version ==2 ) && (tunnel->sock->sk_family ==AF_INET )) {
@@ -1020,8 +1001,6 @@ static int pppol2tp_getname(struct socke *usockaddr_len = len; error =0 ; -sock_put (pls->tunnel_sock); -end_put_sess:sock_put (sk); end:return error;
@@ -1262,7 +1241,6 @@ static int pppol2tp_ioctl(struct socketstruct sock *sk = sock->sk;struct l2tp_session *session;struct l2tp_tunnel *tunnel; -struct pppol2tp_session *ps;int err;if (!sk)
@@ -1286,16 +1264,10 @@ static int pppol2tp_ioctl(struct socket/* Special case: if session's session_id is zero, treat ioctl as a * tunnel ioctl */ - ps =l2tp_session_priv (session);if ((session->session_id ==0 ) && (session->peer_session_id ==0 )) { - err = -EBADF ; - tunnel =l2tp_sock_to_tunnel (ps->tunnel_sock); -if (tunnel ==NULL ) - goto end_put_sess; - + tunnel = session->tunnel; err =pppol2tp_tunnel_ioctl (tunnel, cmd, arg); -sock_put (ps->tunnel_sock); goto end_put_sess; }
@@ -1421,7 +1393,6 @@ static int pppol2tp_setsockopt(struct sostruct sock *sk = sock->sk;struct l2tp_session *session;struct l2tp_tunnel *tunnel; -struct pppol2tp_session *ps;int val;int err;
@@ -1446,20 +1417,14 @@ static int pppol2tp_setsockopt(struct so/* Special case: if session_id == 0x0000, treat as operation on tunnel */ - ps =l2tp_session_priv (session);if ((session->session_id ==0 ) && (session->peer_session_id ==0 )) { - err = -EBADF ; - tunnel =l2tp_sock_to_tunnel (ps->tunnel_sock); -if (tunnel ==NULL ) - goto end_put_sess; - + tunnel = session->tunnel; err =pppol2tp_tunnel_setsockopt (sk, tunnel, optname, val); -sock_put (ps->tunnel_sock); - }else + }else { err =pppol2tp_session_setsockopt (sk, session, optname, val); + } -end_put_sess:sock_put (sk); end:return err;
@@ -1547,7 +1512,6 @@ static int pppol2tp_getsockopt(struct sostruct l2tp_tunnel *tunnel;int val, len;int err; -struct pppol2tp_session *ps;if (level !=SOL_PPPOL2TP )return -EINVAL ;
@@ -1571,16 +1535,10 @@ static int pppol2tp_getsockopt(struct so goto end;/* Special case: if session_id == 0x0000, treat as operation on tunnel */ - ps =l2tp_session_priv (session);if ((session->session_id ==0 ) && (session->peer_session_id ==0 )) { - err = -EBADF ; - tunnel =l2tp_sock_to_tunnel (ps->tunnel_sock); -if (tunnel ==NULL ) - goto end_put_sess; - + tunnel = session->tunnel; err =pppol2tp_tunnel_getsockopt (sk, tunnel, optname, &val); -sock_put (ps->tunnel_sock);if (err) goto end_put_sess; }else {
PATCH 290/410 l2tp: don't use inet_shutdown on tunnel destroy
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Chapman <[email protected]>
commit 76a6abdb2513ad4ea0ded55d2c66160491f2e848 upstream.
Previously, if a tunnel was closed, we called inet_shutdown to mark the socket as unconnected such that userspace would get errors and then close the socket. This could race with userspace closing the socket. Instead, leave userspace to close the socket in its own time (our tunnel will be detached anyway).
BUG: unable to handle kernel NULL pointer dereference at 00000000000000a0 IP: __lock_acquire+0x263/0x1630 PGD 0 P4D 0 Oops: 0000 [#1] SMP KASAN Modules linked in: CPU: 2 PID: 42 Comm: kworker/u8:2 Not tainted 4.15.0-rc7+ #129 Workqueue: l2tp l2tp_tunnel_del_work RIP: 0010:__lock_acquire+0x263/0x1630 RSP: 0018:ffff88001a37fc70 EFLAGS: 00010002 RAX: 0000000000000001 RBX: 0000000000000088 RCX: 0000000000000000 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: ffff88001a37fd18 R08: 0000000000000001 R09: 0000000000000000 R10: 0000000000000000 R11: 00000000000076fd R12: 00000000000000a0 R13: ffff88001a3722c0 R14: 0000000000000001 R15: 0000000000000000 FS: 0000000000000000(0000) GS:ffff88001ad00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000000000a0 CR3: 000000001730b000 CR4: 00000000000006e0 Call Trace: ? __lock_acquire+0xc77/0x1630 ? console_trylock+0x11/0xa0 lock_acquire+0x117/0x230 ? lock_sock_nested+0x3a/0xa0 _raw_spin_lock_bh+0x3a/0x50 ? lock_sock_nested+0x3a/0xa0 lock_sock_nested+0x3a/0xa0 inet_shutdown+0x33/0xf0 l2tp_tunnel_del_work+0x60/0xef process_one_work+0x1ea/0x5f0 ? process_one_work+0x162/0x5f0 worker_thread+0x48/0x3e0 ? trace_hardirqs_on+0xd/0x10 kthread+0x108/0x140 ? process_one_work+0x5f0/0x5f0 ? kthread_stop+0x2a0/0x2a0 ret_from_fork+0x24/0x30 Code: 00 41 81 ff ff 1f 00 00 0f 87 7a 13 00 00 45 85 f6 49 8b 85 68 08 00 00 0f 84 ae 03 00 00 c7 44 24 18 00 00 00 00 e9 f0 00 00 00 <49> 81 3c 24 80 93 3f 83 b8 00 00 00 00 44 0f 44 c0 83 fe 01 0f RIP: __lock_acquire+0x263/0x1630 RSP: ffff88001a37fc70
CR2: 00000000000000a0
--- net/l2tp/l2tp_core.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
net/l2tp/l2tp_core.c +2 -9
@@ -1415,17 +1415,10 @@ static void l2tp_tunnel_del_work(struct sock = sk->sk_socket; -/* If the tunnel socket was created by userspace, then go through the -* inet layer to shut the socket down, and let userspace close it. -* Otherwise, if we created the socket directly within the kernel, use +/* If the tunnel socket was created within the kernel, use * the sk API to release it here. -* In either case the tunnel resources are freed in the socket -* destructor when the tunnel socket goes away. */ -if (tunnel->fd >=0 ) { -if (sock) -inet_shutdown (sock,2 ); - }else { +if (tunnel->fd <0 ) {if (sock)kernel_sock_shutdown (sock,SHUT_RDWR );sk_release_kernel (sk);
PATCH 291/410 l2tp: don't use inet_shutdown on ppp session destroy
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Chapman <[email protected]>
commit 225eb26489d05c679a4c4197ffcb81c81e9dcaf4 upstream.
Previously, if a ppp session was closed, we called inet_shutdown to mark the socket as unconnected such that userspace would get errors and then close the socket. This could race with userspace closing the socket. Instead, leave userspace to close the socket in its own time (our session will be detached anyway).
BUG: KASAN: use-after-free in inet_shutdown+0x5d/0x1c0 Read of size 4 at addr ffff880010ea3ac0 by task syzbot_347bd5ac/8296 CPU: 3 PID: 8296 Comm: syzbot_347bd5ac Not tainted 4.16.0-rc1+ #91 Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 Call Trace: dump_stack+0x101/0x157 ? inet_shutdown+0x5d/0x1c0 print_address_description+0x78/0x260 ? inet_shutdown+0x5d/0x1c0 kasan_report+0x240/0x360 __asan_load4+0x78/0x80 inet_shutdown+0x5d/0x1c0 ? pppol2tp_show+0x80/0x80 pppol2tp_session_close+0x68/0xb0 l2tp_tunnel_closeall+0x199/0x210 ? udp_v6_flush_pending_frames+0x90/0x90 l2tp_udp_encap_destroy+0x6b/0xc0 ? l2tp_tunnel_del_work+0x2e0/0x2e0 udpv6_destroy_sock+0x8c/0x90 sk_common_release+0x47/0x190 udp_lib_close+0x15/0x20 inet_release+0x85/0xd0 inet6_release+0x43/0x60 sock_release+0x53/0x100 ? sock_alloc_file+0x260/0x260 sock_close+0x1b/0x20 __fput+0x19f/0x380 ____fput+0x1a/0x20 task_work_run+0xd2/0x110 exit_to_usermode_loop+0x18d/0x190 do_syscall_64+0x389/0x3b0 entry_SYSCALL_64_after_hwframe+0x26/0x9b RIP: 0033:0x7fe240a45259 RSP: 002b:00007fe241132df8 EFLAGS: 00000297 ORIG_RAX: 0000000000000003 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 00007fe240a45259 RDX: 00007fe240a45259 RSI: 0000000000000000 RDI: 00000000000000a5 RBP: 00007fe241132e20 R08: 00007fe241133700 R09: 0000000000000000 R10: 00007fe241133700 R11: 0000000000000297 R12: 0000000000000000 R13: 00007ffc49aff84f R14: 0000000000000000 R15: 00007fe241141040 Allocated by task 8331: save_stack+0x43/0xd0 kasan_kmalloc+0xad/0xe0 kasan_slab_alloc+0x12/0x20 kmem_cache_alloc+0x144/0x3e0 sock_alloc_inode+0x22/0x130 alloc_inode+0x3d/0xf0 new_inode_pseudo+0x1c/0x90 sock_alloc+0x30/0x110 __sock_create+0xaa/0x4c0 SyS_socket+0xbe/0x130 do_syscall_64+0x128/0x3b0 entry_SYSCALL_64_after_hwframe+0x26/0x9b Freed by task 8314: save_stack+0x43/0xd0 __kasan_slab_free+0x11a/0x170 kasan_slab_free+0xe/0x10 kmem_cache_free+0x88/0x2b0 sock_destroy_inode+0x49/0x50 destroy_inode+0x77/0xb0 evict+0x285/0x340 iput+0x429/0x530 dentry_unlink_inode+0x28c/0x2c0 __dentry_kill+0x1e3/0x2f0 dput.part.21+0x500/0x560 dput+0x24/0x30 __fput+0x2aa/0x380 ____fput+0x1a/0x20 task_work_run+0xd2/0x110 exit_to_usermode_loop+0x18d/0x190 do_syscall_64+0x389/0x3b0 entry_SYSCALL_64_after_hwframe+0x26/0x9b
--- net/l2tp/l2tp_ppp.c | 10 ---------- 1 file changed, 10 deletions(-)
net/l2tp/l2tp_ppp.c +0 -10
@@ -441,16 +441,6 @@ abort:*/ static void pppol2tp_session_close (struct l2tp_session *session) { -struct sock *sk; - -BUG_ON (session->magic !=L2TP_SESSION_MAGIC ); - - sk =pppol2tp_session_get_sock (session); -if (sk) { -if (sk->sk_socket) -inet_shutdown (sk->sk_socket,SEND_SHUTDOWN ); -sock_put (sk); - } }/* Really kill the session socket. (Called from sock_put() if
PATCH 292/410 l2tp: fix races with tunnel socket close
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Chapman <[email protected]>
commit d00fa9adc528c1b0e64d532556764852df8bd7b9 upstream.
The tunnel socket tunnel->sock (struct sock) is accessed when preparing a new ppp session on a tunnel at pppol2tp_session_init. If the socket is closed by a thread while another is creating a new session, the threads race. In pppol2tp_connect, the tunnel object may be created if the pppol2tp socket is associated with the special session_id 0 and the tunnel socket is looked up using the provided fd. When handling this, pppol2tp_connect cannot sock_hold the tunnel socket to prevent it being destroyed during pppol2tp_connect since this may itself may race with the socket being destroyed. Doing sockfd_lookup in pppol2tp_connect isn't sufficient to prevent tunnel->sock going away either because a given tunnel socket fd may be reused between calls to pppol2tp_connect. Instead, have l2tp_tunnel_create sock_hold the tunnel socket before it does sockfd_put. This ensures that the tunnel's socket is always extant while the tunnel object exists. Hold a ref on the socket until the tunnel is destroyed and ensure that all tunnel destroy paths go through a common function (l2tp_tunnel_delete) since this will do the final sock_put to release the tunnel socket.
Since the tunnel's socket is now guaranteed to exist if the tunnel exists, we no longer need to use sockfd_lookup via l2tp_sock_to_tunnel to derive the tunnel from the socket since this is always sk_user_data.
Also, sessions no longer sock_hold the tunnel socket since sessions already hold a tunnel ref and the tunnel sock will not be freed until the tunnel is freed. Removing these sock_holds in l2tp_session_register avoids a possible sock leak in the pppol2tp_connect error path if l2tp_session_register succeeds but attaching a ppp channel fails. The pppol2tp_connect error path could have been fixed instead and have the sock ref dropped when the session is freed, but doing a sock_put of the tunnel socket when the session is freed would require a new session_free callback. It is simpler to just remove the sock_hold of the tunnel socket in l2tp_session_register, now that the tunnel socket lifetime is guaranteed.
Finally, some init code in l2tp_tunnel_create is reordered to ensure that the new tunnel object's refcount is set and the tunnel socket ref is taken before the tunnel socket destructor callbacks are set.
kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] SMP KASAN Modules linked in: CPU: 0 PID: 4360 Comm: syzbot_19c09769 Not tainted 4.16.0-rc2+ #34 Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 RIP: 0010:pppol2tp_session_init+0x1d6/0x500 RSP: 0018:ffff88001377fb40 EFLAGS: 00010212 RAX: dffffc0000000000 RBX: ffff88001636a940 RCX: ffffffff84836c1d RDX: 0000000000000045 RSI: 0000000055976744 RDI: 0000000000000228 RBP: ffff88001377fb60 R08: ffffffff84836bc8 R09: 0000000000000002 R10: ffff88001377fab8 R11: 0000000000000001 R12: 0000000000000000 R13: ffff88001636aac8 R14: ffff8800160f81c0 R15: 1ffff100026eff76 FS: 00007ffb3ea66700(0000) GS:ffff88001a400000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000020e77000 CR3: 0000000016261000 CR4: 00000000000006f0 Call Trace: pppol2tp_connect+0xd18/0x13c0 ? pppol2tp_session_create+0x170/0x170 ? __might_fault+0x115/0x1d0 ? lock_downgrade+0x860/0x860 ? __might_fault+0xe5/0x1d0 ? security_socket_connect+0x8e/0xc0 SYSC_connect+0x1b6/0x310 ? SYSC_bind+0x280/0x280 ? __do_page_fault+0x5d1/0xca0 ? up_read+0x1f/0x40 ? __do_page_fault+0x3c8/0xca0 SyS_connect+0x29/0x30 ? SyS_accept+0x40/0x40 do_syscall_64+0x1e0/0x730 ? trace_hardirqs_off_thunk+0x1a/0x1c entry_SYSCALL_64_after_hwframe+0x42/0xb7 RIP: 0033:0x7ffb3e376259 RSP: 002b:00007ffeda4f6508 EFLAGS: 00000202 ORIG_RAX: 000000000000002a RAX: ffffffffffffffda RBX: 0000000020e77012 RCX: 00007ffb3e376259 RDX: 000000000000002e RSI: 0000000020e77000 RDI: 0000000000000004 RBP: 00007ffeda4f6540 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000400b60 R13: 00007ffeda4f6660 R14: 0000000000000000 R15: 0000000000000000 Code: 80 3d b0 ff 06 02 00 0f 84 07 02 00 00 e8 13 d6 db fc 49 8d bc 24 28 02 00 00 48 b8 00 00 00 00 00 fc ff df 48 89 f
a 48 c1 ea 03 <80> 3c 02 00 0f 85 ed 02 00 00 4d 8b a4 24 28 02 00 00 e8 13 16
--- net/l2tp/l2tp_core.c | 117 +++++++++++++------------------------------ net/l2tp/l2tp_core.h | 23 +-------- net/l2tp/l2tp_ip.c | 10 ++-- net/l2tp/l2tp_ip6.c | 8 ++- 4 files changed, 42 insertions(+), 116 deletions(-)
net/l2tp/l2tp_core.c +34 -83
@@ -135,51 +135,6 @@ l2tp_session_id_hash_2(struct l2tp_net * } -/* Lookup the tunnel socket, possibly involving the fs code if the socket is -* owned by userspace. A struct sock returned from this function must be -* released using l2tp_tunnel_sock_put once you're done with it. -*/ -static struct sock *l2tp_tunnel_sock_lookup (struct l2tp_tunnel *tunnel) -{ -int err =0 ; -struct socket *sock =NULL ; -struct sock *sk =NULL ; - -if (!tunnel) - goto out; - -if (tunnel->fd >=0 ) { -/* Socket is owned by userspace, who might be in the process -* of closing it. Look the socket up using the fd to ensure -* consistency. -*/ - sock =sockfd_lookup (tunnel->fd, &err); -if (sock) - sk = sock->sk; - }else { -/* Socket is owned by kernelspace */ - sk = tunnel->sock; -sock_hold (sk); - } - -out: -return sk; -} - -/* Drop a reference to a tunnel socket obtained via. l2tp_tunnel_sock_put */ -static void l2tp_tunnel_sock_put (struct sock *sk) -{ -struct l2tp_tunnel *tunnel =l2tp_sock_to_tunnel (sk); -if (tunnel) { -if (tunnel->fd >=0 ) { -/* Socket is owned by userspace */ -sockfd_put (sk->sk_socket); - } -sock_put (sk); - } -sock_put (sk); -} -/* Lookup a session by id in the global session list */ static struct l2tp_session *l2tp_session_find_2 (struct net *net,u32 session_id)
@@ -241,6 +196,13 @@ struct l2tp_session *l2tp_session_find(s }EXPORT_SYMBOL_GPL (l2tp_session_find); +void l2tp_tunnel_free (struct l2tp_tunnel *tunnel) +{ +sock_put (tunnel->sock); +/* the tunnel is freed in the socket destructor */ +} +EXPORT_SYMBOL (l2tp_tunnel_free); +/* Lookup a tunnel. A new reference is held on the returned tunnel. */ struct l2tp_tunnel *l2tp_tunnel_get (const struct net *net,u32 tunnel_id) {
@@ -405,13 +367,11 @@ int l2tp_session_register(struct l2tp_se }l2tp_tunnel_inc_refcount (tunnel); -sock_hold (tunnel->sock);hlist_add_head_rcu (&session->global_hlist, g_head);spin_unlock_bh (&pn->l2tp_session_hlist_lock); }else {l2tp_tunnel_inc_refcount (tunnel); -sock_hold (tunnel->sock); }hlist_add_head (&session->hlist, head);
@@ -1051,7 +1011,7 @@ int l2tp_udp_encap_recv(struct sock *sk, {struct l2tp_tunnel *tunnel; - tunnel =l2tp_sock_to_tunnel (sk); + tunnel =l2tp_tunnel (sk);if (tunnel ==NULL ) goto pass_up;
@@ -1059,13 +1019,10 @@ int l2tp_udp_encap_recv(struct sock *sk, tunnel->name, skb->len);if (l2tp_udp_recv_core (tunnel, skb, tunnel->recv_payload_hook)) - goto pass_up_put; + goto pass_up; -sock_put (sk);return 0 ; -pass_up_put: -sock_put (sk); pass_up:return 1 ; }
@@ -1299,7 +1256,6 @@ static void l2tp_tunnel_destruct(structl2tp_info (tunnel,L2TP_MSG_CONTROL ,"%s: closing...\n" , tunnel->name); -/* Disable udp encapsulation */ switch (tunnel->encap) {case L2TP_ENCAPTYPE_UDP :
@@ -1322,12 +1278,11 @@ static void l2tp_tunnel_destruct(structlist_del_rcu (&tunnel->list);spin_unlock_bh (&pn->l2tp_tunnel_list_lock); - tunnel->sock =NULL ; -l2tp_tunnel_dec_refcount (tunnel); -/* Call the original destructor */ if (sk->sk_destruct) (*sk->sk_destruct)(sk); + +kfree_rcu (tunnel, rcu); end:return ; }
@@ -1391,30 +1346,22 @@ EXPORT_SYMBOL_GPL(l2tp_tunnel_closeall);/* Tunnel socket destroy hook for UDP encapsulation */ static void l2tp_udp_encap_destroy (struct sock *sk) { -struct l2tp_tunnel *tunnel =l2tp_sock_to_tunnel (sk); -if (tunnel) { -l2tp_tunnel_closeall (tunnel); -sock_put (sk); - } +struct l2tp_tunnel *tunnel =l2tp_tunnel (sk); + +if (tunnel) +l2tp_tunnel_delete (tunnel); }/* Workqueue tunnel deletion function */ static void l2tp_tunnel_del_work (struct work_struct *work) { -struct l2tp_tunnel *tunnel =NULL ; -struct socket *sock =NULL ; -struct sock *sk =NULL ; - - tunnel = container_of(work, struct l2tp_tunnel, del_work); + struct l2tp_tunnel *tunnel = container_of(work, struct l2tp_tunnel, + del_work); +struct sock *sk = tunnel->sock; +struct socket *sock = sk->sk_socket;l2tp_tunnel_closeall (tunnel); - sk =l2tp_tunnel_sock_lookup (tunnel); -if (!sk) - goto out; - - sock = sk->sk_socket; -/* If the tunnel socket was created within the kernel, use * the sk API to release it here. */
@@ -1424,8 +1371,10 @@ static void l2tp_tunnel_del_work(structsk_release_kernel (sk); } -l2tp_tunnel_sock_put (sk); -out: +/* drop initial ref */ +l2tp_tunnel_dec_refcount (tunnel); + +/* drop workqueue ref */ l2tp_tunnel_dec_refcount (tunnel); }
@@ -1717,13 +1666,22 @@ int l2tp_tunnel_create(struct net *net, sk->sk_user_data = tunnel; +/* Bump the reference count. The tunnel context is deleted +* only when this drops to zero. A reference is also held on +* the tunnel socket to ensure that it is not released while +* the tunnel is extant. Must be done before sk_destruct is +* set. +*/ +atomic_set (&tunnel->ref_count,1 ); +sock_hold (sk); + tunnel->sock = sk; + tunnel->fd = fd; +/* Hook on the tunnel socket destructor so that we can cleanup * if the tunnel socket goes away. */ tunnel->old_sk_destruct = sk->sk_destruct; sk->sk_destruct = &l2tp_tunnel_destruct; - tunnel->sock = sk; - tunnel->fd = fd;lockdep_set_class_and_name (&sk->sk_lock.slock, &l2tp_socket_class,"l2tp_sock" ); sk->sk_allocation =GFP_ATOMIC ;
@@ -1733,11 +1691,6 @@ int l2tp_tunnel_create(struct net *net,/* Add tunnel to our list */ INIT_LIST_HEAD (&tunnel->list); - -/* Bump the reference count. The tunnel context is deleted -* only when this drops to zero. Must be done before list insertion -*/ -l2tp_tunnel_inc_refcount (tunnel);spin_lock_bh (&pn->l2tp_tunnel_list_lock);list_add_rcu (&tunnel->list, &pn->l2tp_tunnel_list);spin_unlock_bh (&pn->l2tp_tunnel_list_lock);
@@ -1778,8 +1731,6 @@ void l2tp_session_free(struct l2tp_sessiif (tunnel) {BUG_ON (tunnel->magic !=L2TP_TUNNEL_MAGIC ); -sock_put (tunnel->sock); - session->tunnel =NULL ;l2tp_tunnel_dec_refcount (tunnel); }
net/l2tp/l2tp_core.h +2 -21
@@ -229,27 +229,8 @@ static inline void *l2tp_session_priv(streturn &session->priv[0 ]; } -static inline struct l2tp_tunnel *l2tp_sock_to_tunnel (struct sock *sk) -{ -struct l2tp_tunnel *tunnel; - -if (sk ==NULL ) -return NULL ; - -sock_hold (sk); - tunnel = (struct l2tp_tunnel *)(sk->sk_user_data); -if (tunnel ==NULL ) { -sock_put (sk); - goto out; - } - -BUG_ON (tunnel->magic !=L2TP_TUNNEL_MAGIC ); - -out: -return tunnel; -} -struct l2tp_tunnel *l2tp_tunnel_get (const struct net *net,u32 tunnel_id); +void l2tp_tunnel_free (struct l2tp_tunnel *tunnel); struct l2tp_session *l2tp_session_get(const struct net *net, struct l2tp_tunnel *tunnel,
@@ -303,7 +284,7 @@ static inline void l2tp_tunnel_inc_refcostatic inline void l2tp_tunnel_dec_refcount (struct l2tp_tunnel *tunnel) {if (atomic_dec_and_test (&tunnel->ref_count)) -kfree_rcu (tunnel, rcu); +l2tp_tunnel_free (tunnel); }/* Session reference counts. Incremented when code obtains a reference
net/l2tp/l2tp_ip.c +3 -7
@@ -234,17 +234,13 @@ static void l2tp_ip_close(struct sock *sstatic void l2tp_ip_destroy_sock (struct sock *sk) {struct sk_buff *skb; -struct l2tp_tunnel *tunnel =l2tp_sock_to_tunnel (sk); +struct l2tp_tunnel *tunnel = sk->sk_user_data;while ((skb =__skb_dequeue_tail (&sk->sk_write_queue)) !=NULL )kfree_skb (skb); -if (tunnel) { -l2tp_tunnel_closeall (tunnel); -sock_put (sk); - } - -sk_refcnt_debug_dec (sk); +if (tunnel) +l2tp_tunnel_delete (tunnel); }static int l2tp_ip_bind (struct sock *sk,struct sockaddr *uaddr,int addr_len)
net/l2tp/l2tp_ip6.c +3 -5
@@ -246,16 +246,14 @@ static void l2tp_ip6_close(struct sock *static void l2tp_ip6_destroy_sock (struct sock *sk) { -struct l2tp_tunnel *tunnel =l2tp_sock_to_tunnel (sk); +struct l2tp_tunnel *tunnel = sk->sk_user_data;lock_sock (sk);ip6_flush_pending_frames (sk);release_sock (sk); -if (tunnel) { -l2tp_tunnel_closeall (tunnel); -sock_put (sk); - } +if (tunnel) +l2tp_tunnel_delete (tunnel);inet6_destroy_sock (sk); }
PATCH 293/410 l2tp: fix race in pppol2tp_release with session object destroy
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Chapman <[email protected]>
commit d02ba2a6110c530a32926af8ad441111774d2893 upstream.
pppol2tp_release uses call_rcu to put the final ref on its socket. But the session object doesn't hold a ref on the session socket so may be freed while the pppol2tp_put_sk RCU callback is scheduled. Fix this by having the session hold a ref on its socket until the session is destroyed. It is this ref that is dropped via call_rcu.
Sessions are also deleted via l2tp_tunnel_closeall. This must now also put the final ref via call_rcu. So move the call_rcu call site into pppol2tp_session_close so that this happens in both destroy paths. A common destroy path should really be implemented, perhaps with l2tp_tunnel_closeall calling l2tp_session_delete like pppol2tp_release does, but this will be looked at later.
ODEBUG: activate active (active state 1) object type: rcu_head hint: (null)
WARNING: CPU: 3 PID: 13407 at lib/debugobjects.c:291 debug_print_object+0x166/0x220 Modules linked in: CPU: 3 PID: 13407 Comm: syzbot_19c09769 Not tainted 4.16.0-rc2+ #38 Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 RIP: 0010:debug_print_object+0x166/0x220 RSP: 0018:ffff880013647a00 EFLAGS: 00010082 RAX: dffffc0000000008 RBX: 0000000000000003 RCX: ffffffff814d3333 RDX: 0000000000000000 RSI: 0000000000000001 RDI: ffff88001a59f6d0 RBP: ffff880013647a40 R08: 0000000000000000 R09: 0000000000000001 R10: ffff8800136479a8 R11: 0000000000000000 R12: 0000000000000001 R13: ffffffff86161420 R14: ffffffff85648b60 R15: 0000000000000000 FS: 0000000000000000(0000) GS:ffff88001a580000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000020e77000 CR3: 0000000006022000 CR4: 00000000000006e0 Call Trace: debug_object_activate+0x38b/0x530 ? debug_object_assert_init+0x3b0/0x3b0 ? __mutex_unlock_slowpath+0x85/0x8b0 ? pppol2tp_session_destruct+0x110/0x110 __call_rcu.constprop.66+0x39/0x890 ? __call_rcu.constprop.66+0x39/0x890 call_rcu_sched+0x17/0x20 pppol2tp_release+0x2c7/0x440 ? fcntl_setlk+0xca0/0xca0 ? sock_alloc_file+0x340/0x340 sock_release+0x92/0x1e0 sock_close+0x1b/0x20 __fput+0x296/0x6e0 ____fput+0x1a/0x20 task_work_run+0x127/0x1a0 do_exit+0x7f9/0x2ce0 ? SYSC_connect+0x212/0x310 ? mm_update_next_owner+0x690/0x690 ? up_read+0x1f/0x40 ? __do_page_fault+0x3c8/0xca0 do_group_exit+0x10d/0x330 ? do_group_exit+0x330/0x330 SyS_exit_group+0x22/0x30 do_syscall_64+0x1e0/0x730 ? trace_hardirqs_off_thunk+0x1a/0x1c entry_SYSCALL_64_after_hwframe+0x42/0xb7 RIP: 0033:0x7f362e471259 RSP: 002b:00007ffe389abe08 EFLAGS: 00000202 ORIG_RAX: 00000000000000e7 RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f362e471259 RDX: 00007f362e471259 RSI: 000000000000002e RDI: 0000000000000000 RBP: 00007ffe389abe30 R08: 0000000000000000 R09: 00007f362e944270 R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000400b60 R13: 00007ffe389abf50 R14: 0000000000000000 R15: 0000000000000000 Code: 8d 3c dd a0 8f 64 85 48 89 fa 48 c1 ea 03 80 3c 02 00 75 7b 48 8b 14 dd a0 8f 64 85 4c 89 f6 48 c7 c7 20 85 64 85 e
8 2a 55 14 ff <0f> 0b 83 05 ad 2a 68 04 01 48 83 c4 18 5b 41 5c 41 5d 41 5e 41
--- net/l2tp/l2tp_ppp.c | 52 +++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 25 deletions(-)
net/l2tp/l2tp_ppp.c +27 -25
@@ -437,10 +437,28 @@ abort:* Session (and tunnel control) socket create/destroy. *****************************************************************************/ +static void pppol2tp_put_sk (struct rcu_head *head) +{ +struct pppol2tp_session *ps; + + ps =container_of (head,typeof (*ps), rcu); +sock_put (ps->__sk); +} +/* Called by l2tp_core when a session socket is being closed. */ static void pppol2tp_session_close (struct l2tp_session *session) { +struct pppol2tp_session *ps; + + ps =l2tp_session_priv (session); +mutex_lock (&ps->sk_lock); + ps->__sk =rcu_dereference_protected (ps->sk, +lockdep_is_held (&ps->sk_lock)); +RCU_INIT_POINTER (ps->sk,NULL ); +if (ps->__sk) +call_rcu (&ps->rcu, pppol2tp_put_sk); +mutex_unlock (&ps->sk_lock); }/* Really kill the session socket. (Called from sock_put() if
@@ -460,14 +478,6 @@ static void pppol2tp_session_destruct(st } } -static void pppol2tp_put_sk (struct rcu_head *head) -{ -struct pppol2tp_session *ps; - - ps =container_of (head,typeof (*ps), rcu); -sock_put (ps->__sk); -} -/* Called when the PPPoX socket (session) is closed. */ static int pppol2tp_release (struct socket *sock)
@@ -491,26 +501,17 @@ static int pppol2tp_release(struct sockesock_orphan (sk); sock->sk =NULL ; +/* If the socket is associated with a session, +* l2tp_session_delete will call pppol2tp_session_close which +* will drop the session's ref on the socket. +*/ session =pppol2tp_sock_to_session (sk); - -if (session !=NULL ) { -struct pppol2tp_session *ps; - +if (session) {l2tp_session_delete (session); - - ps =l2tp_session_priv (session); -mutex_lock (&ps->sk_lock); - ps->__sk =rcu_dereference_protected (ps->sk, -lockdep_is_held (&ps->sk_lock)); -RCU_INIT_POINTER (ps->sk,NULL ); -mutex_unlock (&ps->sk_lock); -call_rcu (&ps->rcu, pppol2tp_put_sk); - -/* Rely on the sock_put() call at the end of the function for -* dropping the reference held by pppol2tp_sock_to_session(). -* The last reference will be dropped by pppol2tp_put_sk(). -*/ +/* drop the ref obtained by pppol2tp_sock_to_session */ +sock_put (sk); } +release_sock (sk);/* This will delete the session context via
@@ -815,6 +816,7 @@ static int pppol2tp_connect(struct socke out_no_ppp:/* This is how we get the session context from the socket. */ +sock_hold (sk); sk->sk_user_data = session;rcu_assign_pointer (ps->sk, sk);mutex_unlock (&ps->sk_lock);
PATCH 294/410 l2tp: fix tunnel lookup use-after-free race
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Chapman <[email protected]>
commit 28f5bfb819195ad9c2eb9486babe7b0e4efe925f upstream.
l2tp_tunnel_get walks the tunnel list to find a matching tunnel instance and if a match is found, its refcount is increased before returning the tunnel pointer. But when tunnel objects are destroyed, they are on the tunnel list after their refcount hits zero. Fix this by moving the code that removes the tunnel from the tunnel list from the tunnel socket destructor into in the l2tp_tunnel_delete path, before the tunnel refcount is decremented.
refcount_t: increment on 0; use-after-free.
WARNING: CPU: 3 PID: 13507 at lib/refcount.c:153 refcount_inc+0x47/0x50 Modules linked in: CPU: 3 PID: 13507 Comm: syzbot_6e6a5ec8 Not tainted 4.16.0-rc2+ #36 Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 RIP: 0010:refcount_inc+0x47/0x50 RSP: 0018:ffff8800136ffb20 EFLAGS: 00010286 RAX: dffffc0000000008 RBX: ffff880017068e68 RCX: ffffffff814d3333 RDX: 0000000000000000 RSI: ffff88001a59f6d8 RDI: ffff88001a59f6d8 RBP: ffff8800136ffb28 R08: 0000000000000000 R09: 0000000000000000 R10: ffff8800136ffab0 R11: 0000000000000000 R12: ffff880017068e50 R13: 0000000000000000 R14: ffff8800174da800 R15: 0000000000000004 FS: 00007f403ab1e700(0000) GS:ffff88001a580000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000205fafd2 CR3: 0000000016770000 CR4: 00000000000006e0 Call Trace: l2tp_tunnel_get+0x2dd/0x4e0 pppol2tp_connect+0x428/0x13c0 ? pppol2tp_session_create+0x170/0x170 ? __might_fault+0x115/0x1d0 ? lock_downgrade+0x860/0x860 ? __might_fault+0xe5/0x1d0 ? security_socket_connect+0x8e/0xc0 SYSC_connect+0x1b6/0x310 ? SYSC_bind+0x280/0x280 ? __do_page_fault+0x5d1/0xca0 ? up_read+0x1f/0x40 ? __do_page_fault+0x3c8/0xca0 SyS_connect+0x29/0x30 ? SyS_accept+0x40/0x40 do_syscall_64+0x1e0/0x730 ? trace_hardirqs_off_thunk+0x1a/0x1c entry_SYSCALL_64_after_hwframe+0x42/0xb7 RIP: 0033:0x7f403a42f259 RSP: 002b:00007f403ab1dee8 EFLAGS: 00000296 ORIG_RAX: 000000000000002a RAX: ffffffffffffffda RBX: 00000000205fafe4 RCX: 00007f403a42f259 RDX: 000000000000002e RSI: 00000000205fafd2 RDI: 0000000000000004 RBP: 00007f403ab1df20 R08: 00007f403ab1e700 R09: 0000000000000000 R10: 00007f403ab1e700 R11: 0000000000000296 R12: 0000000000000000 R13: 00007ffc81906cbf R14: 0000000000000000 R15: 00007f403ab2b040 Code: 3b ff 5b 5d c3 e8 ca 5f 3b ff 80 3d 49 8e 66 04 00 75 ea e8 bc 5f 3b ff 48 c7 c7 60 69 64 85 c6 05 34 8e 66 04 01 e8 59 49 15 ff <0f> 0b eb ce 0f 1f 44 00 00 55 48 89 e5 41 56 41 55 41 54 53 49
--- net/l2tp/l2tp_core.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
net/l2tp/l2tp_core.c +7 -7
@@ -1249,7 +1249,6 @@ EXPORT_SYMBOL_GPL(l2tp_xmit_skb);static void l2tp_tunnel_destruct (struct sock *sk) {struct l2tp_tunnel *tunnel =l2tp_tunnel (sk); -struct l2tp_net *pn;if (tunnel ==NULL ) goto end;
@@ -1272,12 +1271,6 @@ static void l2tp_tunnel_destruct(struct sk->sk_destruct = tunnel->old_sk_destruct; sk->sk_user_data =NULL ; -/* Remove the tunnel struct from the tunnel list */ - pn =l2tp_pernet (tunnel->l2tp_net); -spin_lock_bh (&pn->l2tp_tunnel_list_lock); -list_del_rcu (&tunnel->list); -spin_unlock_bh (&pn->l2tp_tunnel_list_lock); -/* Call the original destructor */ if (sk->sk_destruct) (*sk->sk_destruct)(sk);
@@ -1359,6 +1352,7 @@ static void l2tp_tunnel_del_work(struct del_work);struct sock *sk = tunnel->sock;struct socket *sock = sk->sk_socket; +struct l2tp_net *pn;l2tp_tunnel_closeall (tunnel);
@@ -1371,6 +1365,12 @@ static void l2tp_tunnel_del_work(structsk_release_kernel (sk); } +/* Remove the tunnel struct from the tunnel list */ + pn =l2tp_pernet (tunnel->l2tp_net); +spin_lock_bh (&pn->l2tp_tunnel_list_lock); +list_del_rcu (&tunnel->list); +spin_unlock_bh (&pn->l2tp_tunnel_list_lock); +/* drop initial ref */ l2tp_tunnel_dec_refcount (tunnel);
PATCH 295/410 tpm_tis: fix potential buffer overruns caused by bit glitches on the bus
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jeremy Boone <[email protected]>
commit 6bb320ca4a4a7b5b3db8c8d7250cc40002046878 upstream.
Discrete TPMs are often connected over slow serial buses which, on some platforms, can have glitches causing bit flips. In all the driver _recv() functions, we need to use a u32 to unmarshal the response size, otherwise a bit flip of the 31st bit would cause the expected variable to go negative, which would then try to read a huge amount of data. Also sanity check that the expected amount of data is large enough for the TPM header.
--- drivers/char/tpm/tpm_tis.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/char/tpm/tpm_tis.c +3 -2
@@ -234,7 +234,8 @@ static int recv_data(struct tpm_chip *chstatic int tpm_tis_recv (struct tpm_chip *chip,u8 *buf,size_t count) {int size =0 ; -int expected, status; +int status; +u32 expected;if (count <TPM_HEADER_SIZE ) { size = -EIO ;
@@ -249,7 +250,7 @@ static int tpm_tis_recv(struct tpm_chip } expected =be32_to_cpu (*(__be32 *) (buf +2 )); -if (expected > count) { +if (expected > count || expected <TPM_HEADER_SIZE ) { size = -EIO ; goto out; }
PATCH 296/410 tpm_i2c_nuvoton: fix potential buffer overruns caused by bit glitches on the bus
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jeremy Boone <[email protected]>
commit f9d4d9b5a5ef2f017bc344fb65a58a902517173b upstream.
Discrete TPMs are often connected over slow serial buses which, on some platforms, can have glitches causing bit flips. In all the driver _recv() functions, we need to use a u32 to unmarshal the response size, otherwise a bit flip of the 31st bit would cause the expected variable to go negative, which would then try to read a huge amount of data. Also sanity check that the expected amount of data is large enough for the TPM header.
--- drivers/char/tpm/tpm_i2c_nuvoton.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/char/tpm/tpm_i2c_nuvoton.c +6 -2
@@ -267,7 +267,11 @@ static int i2c_nuvoton_recv(struct tpm_cstruct device *dev = chip->dev;struct i2c_client *client =to_i2c_client (dev);s32 rc; -int expected, status, burst_count, retries, size =0 ; +int status; +int burst_count; +int retries; +int size =0 ; +u32 expected;if (count <TPM_HEADER_SIZE ) {i2c_nuvoton_ready (chip);/* return to idle */
@@ -309,7 +313,7 @@ static int i2c_nuvoton_recv(struct tpm_c* to machine native */ expected =be32_to_cpu (*(__be32 *) (buf +2 )); -if (expected > count) { +if (expected > count || expected < size) {dev_err (dev,"%s() expected > count\n" , __func__); size = -EIO ;continue ;
PATCH 297/410 tpm_i2c_infineon: fix potential buffer overruns caused by bit glitches on the bus
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jeremy Boone <[email protected]>
commit 9b8cb28d7c62568a5916bdd7ea1c9176d7f8f2ed upstream.
Discrete TPMs are often connected over slow serial buses which, on some platforms, can have glitches causing bit flips. In all the driver _recv() functions, we need to use a u32 to unmarshal the response size, otherwise a bit flip of the 31st bit would cause the expected variable to go negative, which would then try to read a huge amount of data. Also sanity check that the expected amount of data is large enough for the TPM header.
--- drivers/char/tpm/tpm_i2c_infineon.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/char/tpm/tpm_i2c_infineon.c +3 -2
@@ -436,7 +436,8 @@ static int recv_data(struct tpm_chip *chstatic int tpm_tis_i2c_recv (struct tpm_chip *chip,u8 *buf,size_t count) {int size =0 ; -int expected, status; +int status; +u32 expected;if (count <TPM_HEADER_SIZE ) { size = -EIO ;
@@ -451,7 +452,7 @@ static int tpm_tis_i2c_recv(struct tpm_c } expected =be32_to_cpu (*(__be32 *)(buf +2 )); -if ((size_t ) expected > count) { +if (((size_t ) expected > count) || (expected <TPM_HEADER_SIZE )) { size = -EIO ; goto out; }
PATCH 298/410 tpm: fix potential buffer overruns caused by bit glitches on the bus
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jeremy Boone <[email protected]>
commit 3be23274755ee85771270a23af7691dc9b3a95db upstream.
Discrete TPMs are often connected over slow serial buses which, on some platforms, can have glitches causing bit flips. If a bit does flip it could cause an overrun if it's in one of the size parameters, so sanity check that we're not overrunning the provided buffer when doing a memcpy().
--- drivers/char/tpm/tpm-interface.c | 4 ++++ drivers/char/tpm/tpm2-cmd.c | 4 ++++ 2 files changed, 8 insertions(+)
drivers/char/tpm/tpm-interface.c +4 -0
@@ -1029,6 +1029,10 @@ int tpm_get_random(u32 chip_num, u8 *outbreak ; recd =be32_to_cpu (tpm_cmd.params.getrandom_out.rng_data_len); +if (recd > num_bytes) { + total = -EFAULT ; +break ; + }memcpy (dest, tpm_cmd.params.getrandom_out.rng_data, recd); dest += recd;
PATCH 299/410 mmc: sdhci: Allow override of mmc host operations
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
commit bf60e592a1af4d6f65dd54593250183f14360eed upstream.
In the past, fixes for specific hardware devices were implemented in sdhci using quirks. That approach is no longer accepted because the growing number of quirks was starting to make the code difficult to understand and maintain.
One alternative to quirks, is to allow drivers to override the default mmc host operations. This patch makes it easy to do that, and it is needed for a subsequent bug fix, for which separate patches are provided.
--- drivers/mmc/host/sdhci.c | 3 ++- include/linux/mmc/sdhci.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +2 -1
@@ -2781,6 +2781,8 @@ struct sdhci_host *sdhci_alloc_host(stru host =mmc_priv (mmc); host->mmc = mmc; + host->mmc_host_ops = sdhci_ops; + mmc->ops = &host->mmc_host_ops;return host; }
@@ -2939,7 +2941,6 @@ int sdhci_add_host(struct sdhci_host *ho/* * Set host parameters. */ - mmc->ops = &sdhci_ops; mmc->f_max = host->max_clk;if (host->ops->get_min_clock) mmc->f_min = host->ops->get_min_clock (host);
include/linux/mmc/sdhci.h +1 -0
@@ -109,6 +109,7 @@ struct sdhci_host {/* Internal data */ struct mmc_host *mmc;/* MMC structure */ +struct mmc_host_ops mmc_host_ops;/* MMC host ops */ u64 dma_mask;/* custom DMA mask */ #if defined(CONFIG_LEDS_CLASS ) || defined(CONFIG_LEDS_CLASS_MODULE )
PATCH 300/410 mmc: sdhci: export sdhci_execute_tuning()
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Masahiro Yamada <[email protected]>
commit 85a882c2e91d3655927ecdc1db823d1420a65b8f upstream.
Some SDHCI-compat controllers support not only SD, but also eMMC, but they use different commands for tuning: CMD19 for SD, CMD21 for eMMC.
Due to the difference of the underlying mechanism, some controllers (at least, the Cadence IP is the case) provide their own registers for the eMMC tuning.
This commit will be useful when we want to override .execute_tuning callback (for eMMC HS200 tuning), but still let it fall back to sdhci_execute_tuning() for SD timing.
---
drivers/mmc/host/sdhci.c +2 -2
@@ -52,7 +52,6 @@ static unsigned int debug_quirks2;static void sdhci_finish_data (struct sdhci_host *);static void sdhci_finish_command (struct sdhci_host *); -static int sdhci_execute_tuning (struct mmc_host *mmc,u32 opcode);static void sdhci_tuning_timer (unsigned long data);static void sdhci_enable_preset_value (struct sdhci_host *host,bool enable);
@@ -1840,7 +1839,7 @@ static int sdhci_card_busy(struct mmc_horeturn !(present_state &SDHCI_DATA_LVL_MASK ); } -static int sdhci_execute_tuning (struct mmc_host *mmc,u32 opcode) +int sdhci_execute_tuning (struct mmc_host *mmc,u32 opcode) {struct sdhci_host *host =mmc_priv (mmc);u16 ctrl;
@@ -2054,6 +2053,7 @@ out:return err; } +EXPORT_SYMBOL_GPL (sdhci_execute_tuning);static void sdhci_enable_preset_value (struct sdhci_host *host,bool enable)
drivers/mmc/host/sdhci.h +1 -0
@@ -402,6 +402,7 @@ void sdhci_set_clock(struct sdhci_host *void sdhci_set_bus_width (struct sdhci_host *host,int width);void sdhci_reset (struct sdhci_host *host,u8 mask);void sdhci_set_uhs_signaling (struct sdhci_host *host,unsigned timing); +int sdhci_execute_tuning (struct mmc_host *mmc,u32 opcode);#ifdef CONFIG_PM extern int sdhci_suspend_host (struct sdhci_host *host);
PATCH 301/410 mmc: sdhci-pci: Fix S0i3 for Intel BYT-based controllers
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
commit f8870ae6e2d6be75b1accc2db981169fdfbea7ab upstream.
Tuning can leave the IP in an active state (Buffer Read Enable bit set) which prevents the entry to low power states (i.e. S0i3). Data reset will clear it.
Generally tuning is followed by a data transfer which will anyway sort out the state, so it is rare that S0i3 is actually prevented.
[bwh: Backported to 3.16:
- Drop chnages in ni_byt_sdio_probe_slot(), byt_sd_probe_slot()
- Adjust filename, context]
--- drivers/mmc/host/sdhci-pci.c | 35 +++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-)
drivers/mmc/host/sdhci-pci.c +27 -0
@@ -265,8 +265,34 @@ static void sdhci_pci_int_hw_reset(strucusleep_range (300 ,1000 ); } +static int intel_execute_tuning (struct mmc_host *mmc,u32 opcode) +{ +int err =sdhci_execute_tuning (mmc, opcode); +struct sdhci_host *host =mmc_priv (mmc); + +if (err) +return err; + +/* +* Tuning can leave the IP in an active state (Buffer Read Enable bit +* set) which prevents the entry to low power states (i.e. S0i3). Data +* reset will clear it. +*/ +sdhci_reset (host,SDHCI_RESET_DATA ); + +return 0 ; +} + +static void byt_probe_slot (struct sdhci_pci_slot *slot) +{ +struct mmc_host_ops *ops = &slot->host->mmc_host_ops; + + ops->execute_tuning = intel_execute_tuning; +} +static int byt_emmc_probe_slot (struct sdhci_pci_slot *slot) { +byt_probe_slot (slot); slot->host->mmc->caps |=MMC_CAP_8_BIT_DATA |MMC_CAP_NONREMOVABLE |MMC_CAP_HW_RESET ; slot->host->mmc->caps2 |=MMC_CAP2_HC_ERASE_SZ ;
@@ -278,6 +304,7 @@ static int byt_emmc_probe_slot(struct sdstatic int byt_sdio_probe_slot (struct sdhci_pci_slot *slot) { +byt_probe_slot (slot); slot->host->mmc->caps |=MMC_CAP_POWER_OFF_CARD |MMC_CAP_NONREMOVABLE ;return 0 ; }
PATCH 302/410 mmc: dw_mmc: Factor out dw_mci_init_slot_caps
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Shawn Lin <[email protected]>
commit a4faa4929ed3be15e2d500d2405f992f6dedc8eb upstream.
Factor out dw_mci_init_slot_caps to consolidate parsing all differents types of capabilities from host contrllers. No functional change intended.
[bwh: Backported to 3.16:
- We don't set MMC_CAP_ERASE or MMC_CAP2_SDIO_IRQ_NOTHREAD capabilities
- Fold in required changes to the exit path from commits 51da2240906c "mmc: dw_mmc: use mmc_regulator_get_supply to handle regulators" and 3cf890fc42b2 "mmc: dw_mmc: Pass back errors from mmc_of_parse()"
- Adjust context]
---
drivers/mmc/host/dw_mmc.c +37 -24
@@ -2044,12 +2044,40 @@ static struct device_node *dw_mci_of_fin }#endif /* CONFIG_OF */ +static int dw_mci_init_slot_caps (struct dw_mci_slot *slot) +{ +struct dw_mci *host = slot->host; +const struct dw_mci_drv_data *drv_data = host->drv_data; +struct mmc_host *mmc = slot->mmc; +int ctrl_id; + +if (host->pdata->caps) + mmc->caps = host->pdata->caps; + +if (host->pdata->pm_caps) + mmc->pm_caps = host->pdata->pm_caps; + +if (host->dev->of_node) { + ctrl_id =of_alias_get_id (host->dev->of_node,"mshc" ); +if (ctrl_id <0 ) + ctrl_id =0 ; + }else { + ctrl_id =to_platform_device (host->dev)->id; + } +if (drv_data && drv_data->caps) + mmc->caps |= drv_data->caps[ctrl_id]; + +if (host->pdata->caps2) + mmc->caps2 = host->pdata->caps2; + +return 0 ; +} +static int dw_mci_init_slot (struct dw_mci *host,unsigned int id) {struct mmc_host *mmc;struct dw_mci_slot *slot; -const struct dw_mci_drv_data *drv_data = host->drv_data; -int ctrl_id, ret; +int ret;u32 freq[2 ]; mmc =mmc_alloc_host (sizeof (struct dw_mci_slot ), host->dev);
@@ -2076,27 +2104,12 @@ static int dw_mci_init_slot(struct dw_mc mmc->ocr_avail =MMC_VDD_32_33 |MMC_VDD_33_34 ; -if (host->pdata->caps) - mmc->caps = host->pdata->caps; - -if (host->pdata->pm_caps) - mmc->pm_caps = host->pdata->pm_caps; - -if (host->dev->of_node) { - ctrl_id =of_alias_get_id (host->dev->of_node,"mshc" ); -if (ctrl_id <0 ) - ctrl_id =0 ; - }else { - ctrl_id =to_platform_device (host->dev)->id; - } -if (drv_data && drv_data->caps) - mmc->caps |= drv_data->caps[ctrl_id]; - -if (host->pdata->caps2) - mmc->caps2 = host->pdata->caps2; -mmc_of_parse (mmc); + ret =dw_mci_init_slot_caps (slot); +if (ret) + goto err_host_allocated; +if (host->pdata->blk_settings) { mmc->max_segs = host->pdata->blk_settings->max_segs; mmc->max_blk_size = host->pdata->blk_settings->max_blk_size;
@@ -2127,7 +2140,7 @@ static int dw_mci_init_slot(struct dw_mc ret =mmc_add_host (mmc);if (ret) - goto err_setup_bus; + goto err_host_allocated;#if defined(CONFIG_DEBUG_FS )dw_mci_init_debugfs (slot);
@@ -2138,9 +2151,9 @@ static int dw_mci_init_slot(struct dw_mcreturn 0 ; -err_setup_bus: +err_host_allocated:mmc_free_host (mmc); -return -EINVAL ; +return ret; }static void dw_mci_cleanup_slot (struct dw_mci_slot *slot,unsigned int id)
PATCH 303/410 mmc: dw_mmc: Fix out-of-bounds access for slot's caps
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Shawn Lin <[email protected]>
commit 0d84b9e5631d923744767dc6608672df906dd092 upstream.
Add num_caps field for dw_mci_drv_data to validate the controller id from DT alias and non-DT ways.
[bwh: Backported to 3.16:
- Drop changes to dw_mmc-{k3,rockchip,zx}.c
- Adjust context]
---
drivers/mmc/host/dw_mmc-exynos.c +1 -0
@@ -394,6 +394,7 @@ static unsigned long exynos_dwmmc_caps[4static const struct dw_mci_drv_data exynos_drv_data = { .caps = exynos_dwmmc_caps, + .num_caps =ARRAY_SIZE (exynos_dwmmc_caps), .init = dw_mci_exynos_priv_init, .setup_clock = dw_mci_exynos_setup_clock, .prepare_command = dw_mci_exynos_prepare_command,
drivers/mmc/host/dw_mmc.c +8 -1
@@ -2064,8 +2064,15 @@ static int dw_mci_init_slot_caps(struct }else { ctrl_id =to_platform_device (host->dev)->id; } -if (drv_data && drv_data->caps) + +if (drv_data && drv_data->caps) { +if (ctrl_id >= drv_data->num_caps) { +dev_err (host->dev,"invalid controller id %d\n" , + ctrl_id); +return -EINVAL ; + } mmc->caps |= drv_data->caps[ctrl_id]; + }if (host->pdata->caps2) mmc->caps2 = host->pdata->caps2;
drivers/mmc/host/dw_mmc.h +2 -0
@@ -237,6 +237,7 @@ struct dw_mci_tuning_data {/** * dw_mci driver data - dw-mshc implementation specific driver data. * @caps: mmc subsystem specified capabilities of the controller(s). +* @num_caps: number of capabilities specified by @caps. * @init: early implementation specific initialization. * @setup_clock: implementation specific clock configuration. * @prepare_command: handle CMD register extensions.
@@ -250,6 +251,7 @@ struct dw_mci_tuning_data {*/ struct dw_mci_drv_data {unsigned long *caps; +u32 num_caps;int (*init)(struct dw_mci *host);int (*setup_clock)(struct dw_mci *host);void (*prepare_command)(struct dw_mci *host,u32 *cmdr);
PATCH 304/410 cpufreq: s3c24xx: Fix broken s3c_cpufreq_init()
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Viresh Kumar <[email protected]>
commit 0373ca74831b0f93cd4cdbf7ad3aec3c33a479a5 upstream.
commit a307a1e6bc0d "cpufreq: s3c: use cpufreq_generic_init()" accidentally broke cpufreq on s3c2410 and s3c2412.
These two platforms don't have a CPU frequency table and used to skip calling cpufreq_table_validate_and_show() for them. But with the above commit, we started calling it unconditionally and that will eventually fail as the frequency table pointer is NULL.
Fix this by calling cpufreq_table_validate_and_show() conditionally again.
--- drivers/cpufreq/s3c24xx-cpufreq.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/cpufreq/s3c24xx-cpufreq.c +7 -1
@@ -370,7 +370,13 @@ struct clk *s3c_cpufreq_clk_get(struct dstatic int s3c_cpufreq_init (struct cpufreq_policy *policy) { policy->clk = clk_arm; -return cpufreq_generic_init (policy, ftab, cpu_cur.info->latency); + + policy->cpuinfo.transition_latency = cpu_cur.info->latency; + +if (ftab) +return cpufreq_table_validate_and_show (policy, ftab); + +return 0 ; }static int __init s3c_cpufreq_initclks (void )
PATCH 305/410 tty: make n_tty_read() always abort if hangup is in progress
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <[email protected]>
commit 28b0f8a6962a24ed21737578f3b1b07424635c9e upstream.
A tty is hung up by __tty_hangup() setting file->f_op to hung_up_tty_fops, which is skipped on ttys whose write operation isn't tty_write(). This means that, for example, /dev/console whose write op is redirected_tty_write() is never actually marked hung up.
Because n_tty_read() uses the hung up status to decide whether to abort the waiting readers, the lack of hung-up marking can lead to the following scenario.
1. A session contains two processes. The leader and its child. The child ignores SIGHUP.
2. The leader exits and starts disassociating from the controlling terminal (/dev/console).
3. __tty_hangup() skips setting f_op to hung_up_tty_fops.
4. SIGHUP is delivered and ignored.
5. tty_ldisc_hangup() is invoked. It wakes up the waits which should
clear the read lockers of tty->ldisc_sem.
6. The reader wakes up but because tty_hung_up_p() is false, it doesn't abort and goes back to sleep while read-holding tty->ldisc_sem.
7. The leader progresses to tty_ldisc_lock() in tty_ldisc_hangup() and is now stuck in D sleep indefinitely waiting for tty->ldisc_sem.
The following is Alan's explanation on why some ttys aren't hung up.
http://lkml.kernel.org/r/20171101170908.6ad08580@alans-desktop
1. It broke the serial consoles because they would hang up and close down the hardware. With tty_port that *should* be fixable properly for any cases remaining.
2. The console layer was (and still is) completely broken and doens't refcount properly. So if you turn on console hangups it breaks (as indeed does freeing consoles and half a dozen other things).
As neither can be fixed quickly, this patch works around the problem by introducing a new flag, TTY_HUPPING, which is used solely to tell n_tty_read() that hang-up is in progress for the console and the readers should be aborted regardless of the hung-up status of the device.
The following is a sample hung task warning caused by this issue.
INFO: task agetty:2662 blocked for more than 120 seconds.
Not tainted 4.11.3-dbg-tty-lockup-02478-gfd6c7ee-dirty #28
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
0 2662 1 0x00000086
Call Trace:
__schedule+0x267/0x890
schedule+0x36/0x80
schedule_timeout+0x23c/0x2e0
ldsem_down_write+0xce/0x1f6
tty_ldisc_lock+0x16/0x30
tty_ldisc_hangup+0xb3/0x1b0
__tty_hangup+0x300/0x410
disassociate_ctty+0x6c/0x290
do_exit+0x7ef/0xb00
do_group_exit+0x3f/0xa0
get_signal+0x1b3/0x5d0
do_signal+0x28/0x660
exit_to_usermode_loop+0x46/0x86
do_syscall_64+0x9c/0xb0
entry_SYSCALL64_slow_path+0x25/0x25The following is the repro. Run "$PROG /dev/console". The parent process hangs in D state.
#include <sys/types.h> #include <sys/stat.h> #include <sys/wait.h> #include <sys/ioctl.h> #include <fcntl.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <signal.h> #include <time.h> #include <termios.h>
int main(int argc, char **argv)
{
struct sigaction sact = { .sa_handler = SIG_IGN };
struct timespec ts1s = { .tv_sec = 1 };
pid_t pid;
int fd;
if (argc < 2) {
fprintf(stderr, "test-hung-tty /dev/$TTY\n");
return 1;
}
/* fork a child to ensure that it isn't already the session leader */
pid = fork();
if (pid < 0) {
perror("fork");
return 1;
}
if (pid > 0) {
/* top parent, wait for everyone */
while (waitpid(-1, NULL, 0) >= 0)
;
if (errno != ECHILD)
perror("waitpid");
return 0;
}
/* new session, start a new session and set the controlling tty */
if (setsid() < 0) {
perror("setsid");
return 1;
}
fd = open(argv[1], O_RDWR);
if (fd < 0) {
perror("open");
return 1;
}
if (ioctl(fd, TIOCSCTTY, 1) < 0) {
perror("ioctl");
return 1;
}
/* fork a child, sleep a bit and exit */
pid = fork();
if (pid < 0) {
perror("fork");
return 1;
}
if (pid > 0) {
nanosleep(&ts1s, NULL);
printf("Session leader exiting\n");
exit(0);
}
/*
* The child ignores SIGHUP and keeps reading from the controlling
* tty. Because SIGHUP is ignored, the child doesn't get killed on
* parent exit and the bug in n_tty makes the read(2) block the
* parent's control terminal hangup attempt. The parent ends up in
* D sleep until the child is explicitly killed.
*/
sigaction(SIGHUP, &sact, NULL);
printf("Child reading tty\n");
while (1) {
char buf[1024];
if (read(fd, buf, sizeof(buf)) < 0) {
perror("read");
return 1;
}
}
return 0;}
[bwh: Backported to 3.16: TTY_HUPPING is not really a new flag; it's an old flag
that was wrongly removed in 3.19. Just add the test for it in n_tty_read().]
---
drivers/tty/n_tty.c +6 -0
@@ -2261,6 +2261,12 @@ static ssize_t n_tty_read(struct tty_str }if (tty_hung_up_p (file))break ; +/* +* Abort readers for ttys which never actually +* get hung up. See __tty_hangup(). +*/ +if (test_bit (TTY_HUPPING , &tty->flags)) +break ;if (!timeout)break ;if (file->f_flags &O_NONBLOCK ) {
PATCH 306/410 tty/serial: atmel: add new version check for usart
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jonas Danielsson <[email protected]>
commit fd63a8903a2c40425a9811c3371dd4d0f42c0ad3 upstream.
On our at91sam9260 based board the usart0 and usart1 ports report their versions (ATMEL_US_VERSION) as 0x10302. This version is not included in the current checks in the driver.
--- drivers/tty/serial/atmel_serial.c | 1 + 1 file changed, 1 insertion(+)
drivers/tty/serial/atmel_serial.c +1 -0
@@ -1644,6 +1644,7 @@ static void atmel_get_ip_name(struct uarswitch (version) {case 0x302 :case 0x10213 : +case 0x10302 :dev_dbg (port->dev,"This version is usart\n" ); atmel_port->is_usart = true;break ;
PATCH 307/410 serial: 8250_pci: Add Brainboxes UC-260 4 port serial device
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Nikola Ciprich <[email protected]>
commit 9f2068f35729948bde84d87a40d135015911345d upstream.
Add PCI ids for two variants of Brainboxes UC-260 quad port PCI serial cards.
--- drivers/tty/serial/8250/8250_pci.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/tty/serial/8250/8250_pci.c +11 -0
@@ -5067,6 +5067,17 @@ static struct pci_device_id serial_pci_tPCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,/* 135a.0dc0 */ pbn_b2_4_115200 },/* +* BrainBoxes UC-260 +*/ + { PCI_VENDOR_ID_INTASHIELD, 0x0D21, +PCI_ANY_ID ,PCI_ANY_ID , +PCI_CLASS_COMMUNICATION_MULTISERIAL <<8 ,0xffff00 , + pbn_b2_4_115200 }, + { PCI_VENDOR_ID_INTASHIELD, 0x0E34, +PCI_ANY_ID ,PCI_ANY_ID , +PCI_CLASS_COMMUNICATION_MULTISERIAL <<8 ,0xffff00 , + pbn_b2_4_115200 }, +/* * Perle PCI-RAS cards */ { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9030,
PATCH 308/410 serial: sh-sci: prevent lockup on full TTY buffers
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ulrich Hecht <[email protected]>
commit 7842055bfce4bf0170d0f61df8b2add8399697be upstream.
When the TTY buffers fill up to the configured maximum, a system lockup occurs:
[ 598.820128] INFO: rcu_preempt detected stalls on CPUs/tasks: [ 598.825796] 0-...!: (1 GPs behind) idle=5a6/2/0 softirq=1974/1974 fqs=1 [ 598.832577] (detected by 3, t=62517 jiffies, g=296, c=295, q=126) [ 598.838755] Task dump for CPU 0: [ 598.841977] swapper/0 R running task 0 0 0 0x00000022 [ 598.849023] Call trace: [ 598.851476] __switch_to+0x98/0xb0 [ 598.854870] (null)
This can be prevented by doing a dummy read of the RX data register.
This issue affects both HSCIF and SCIF ports. Reported for R-Car H3 ES2.0; reproduced and fixed on H3 ES1.1. Probably affects other R-Car platforms as well.
--- drivers/tty/serial/sh-sci.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/serial/sh-sci.c +2 -0
@@ -734,6 +734,8 @@ static void sci_receive_chars(struct uar/* Tell the rest of the system the news. New characters! */ tty_flip_buffer_push (tport); }else { +/* TTY buffers full; read from RX reg to prevent lockup */ +serial_port_in (port, SCxRDR);serial_port_in (port, SCxSR);/* dummy read */ serial_port_out (port, SCxSR,SCxSR_RDxF_CLEAR (port)); }
PATCH 309/410 xen: Add xen_arch_suspend()
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ben Hutchings <[email protected]>
This is based on commit 2b953a5e994ce279904ec70220f7d4f31d380a0a upstream, "xen: Suspend ticks on all CPUs during suspend", but excluding the bug fix in that commit which is not needed in 3.16. We only need the xen_arch_suspend() hook for the following fix.
---
arch/x86/xen/suspend.c +9 -0
@@ -91,8 +91,17 @@ static void xen_vcpu_notify_restore(voidclockevents_notify (reason,NULL ); } +static void xen_vcpu_notify_suspend (void *data) +{ +} +void xen_arch_resume (void ) {on_each_cpu (xen_vcpu_notify_restore, (void *)CLOCK_EVT_NOTIFY_RESUME ,1 ); } + +void xen_arch_suspend (void ) +{ +on_each_cpu (xen_vcpu_notify_suspend,NULL ,1 ); +}
drivers/xen/manage.c +6 -3
@@ -131,6 +131,8 @@ static void do_suspend(void) goto out_resume; } +xen_arch_suspend (); + si.cancelled =1 ; err =stop_machine (xen_suspend, &si,cpumask_of (0 ));
@@ -148,11 +150,12 @@ static void do_suspend(void) si.cancelled =1 ; } +xen_arch_resume (); + out_resume: -if (!si.cancelled) { -xen_arch_resume (); +if (!si.cancelled)xs_resume (); - }else +else xs_suspend_cancel ();dpm_resume_end (si.cancelled ?PMSG_THAW :PMSG_RESTORE );
include/xen/xen-ops.h +1 -0
@@ -12,6 +12,7 @@ void xen_arch_post_suspend(int suspend_cvoid xen_timer_resume (void );void xen_arch_resume (void ); +void xen_arch_suspend (void );void xen_resume_notifier_register (struct notifier_block *nb);void xen_resume_notifier_unregister (struct notifier_block *nb);
PATCH 310/410 xen/arm: Define xen_arch_suspend()
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Boris Ostrovsky <[email protected]>
commit ffb7dbed47da6ac4460b606a3feee295bbe4d9e2 upstream.
Commit 2b953a5e994c ("xen: Suspend ticks on all CPUs during suspend") introduced xen_arch_suspend() routine but did so only for x86, breaking ARM builds.
We need to add it to ARM as well.
--- arch/arm/xen/enlighten.c | 1 + 1 file changed, 1 insertion(+)
arch/arm/xen/enlighten.c +1 -0
@@ -344,6 +344,7 @@ void xen_arch_pre_suspend(void) { }void xen_arch_post_suspend (int suspend_cancelled) { }void xen_timer_resume (void ) { }void xen_arch_resume (void ) { } +void xen_arch_suspend (void ) { }/* In the hypervisor.S file. */
PATCH 311/410 x86/xen: Zero MSR_IA32_SPEC_CTRL before suspend
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
commit 71c208dd54ab971036d83ff6d9837bae4976e623 upstream.
Older Xen versions (4.5 and before) might have problems migrating pv guests with MSR_IA32_SPEC_CTRL having a non-zero value. So before suspending zero that MSR and restore it after being resumed.
[bwh: Backported to 3.16:
- Include <asm/cpufeature.h> instead of <asm/cpufeatures.h>
- Adjust context]
---
arch/x86/xen/suspend.c +15 -0
@@ -1,10 +1,13 @@#include <linux/types.h> #include <linux/clockchips.h> +#include <linux/percpu-defs.h> #include <xen/interface/xen.h> #include <xen/grant_table.h> #include <xen/events.h> +#include <asm/cpufeature.h> +#include <asm/msr-index.h> #include <asm/xen/hypercall.h> #include <asm/xen/page.h> #include <asm/fixmap.h>
@@ -12,6 +15,8 @@#include "xen-ops.h" #include "mmu.h" +static DEFINE_PER_CPU(u64, spec_ctrl); +static void xen_pv_pre_suspend (void ) {xen_mm_pin_all ();
@@ -84,6 +89,9 @@ static void xen_vcpu_notify_restore(void {unsigned long reason = (unsigned long )data; +if (xen_pv_domain () &&boot_cpu_has (X86_FEATURE_SPEC_CTRL )) +wrmsrl (MSR_IA32_SPEC_CTRL ,this_cpu_read (spec_ctrl)); +/* Boot processor notified via generic timekeeping_resume() */ if (smp_processor_id () ==0 )return ;
@@ -93,6 +101,13 @@ static void xen_vcpu_notify_restore(voidstatic void xen_vcpu_notify_suspend (void *data) { +u64 tmp; + +if (xen_pv_domain () &&boot_cpu_has (X86_FEATURE_SPEC_CTRL )) { +rdmsrl (MSR_IA32_SPEC_CTRL , tmp); +this_cpu_write (spec_ctrl, tmp); +wrmsrl (MSR_IA32_SPEC_CTRL ,0 ); + } }void xen_arch_resume (void )
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 312/410 xen/pirq: fix error path cleanup when binding MSIs
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Roger Pau Monne <[email protected]>
commit 910f8befdf5bccf25287d9f1743e3e546bcb7ce0 upstream.
Current cleanup in the error path of xen_bind_pirq_msi_to_irq is wrong. First of all there's an off-by-one in the cleanup loop, which can lead to unbinding wrong IRQs.
Secondly IRQs not bound won't be freed, thus leaking IRQ numbers.
Note that there's no need to differentiate between bound and unbound IRQs when freeing them, __unbind_from_irq will deal with both of them correctly.
--- drivers/xen/events/events_base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/xen/events/events_base.c +2 -2
@@ -763,8 +763,8 @@ out:mutex_unlock (&irq_mapping_update_lock);return irq; error_irq: -for (; i >=0 ; i--) -__unbind_from_irq (irq + i); +while (nvec--) +__unbind_from_irq (irq + nvec);mutex_unlock (&irq_mapping_update_lock);return ret; }
PATCH 313/410 KVM: s390: provide io interrupt kvm_stat
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Christian Borntraeger <[email protected]>
commit 09a0fb67536a49af19f2bfc632100e9de91fe526 upstream.
We already count io interrupts, but we forgot to print them.
--- arch/s390/kvm/kvm-s390.c | 1 + 1 file changed, 1 insertion(+)
arch/s390/kvm/kvm-s390.c +1 -0
@@ -62,6 +62,7 @@ struct kvm_stats_debugfs_item debugfs_en { "deliver_prefix_signal", VCPU_STAT(deliver_prefix_signal) }, { "deliver_restart_signal", VCPU_STAT(deliver_restart_signal) }, { "deliver_program_interruption", VCPU_STAT(deliver_program_int) }, + { "deliver_io_interrupt", VCPU_STAT(deliver_io_int) }, { "exit_wait_state", VCPU_STAT(exit_wait_state) }, { "instruction_pfmf", VCPU_STAT(instruction_pfmf) }, { "instruction_stidp", VCPU_STAT(instruction_stidp) },
PATCH 314/410 btrfs: alloc_chunk: fix DUP stripe size handling
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hans van Kranenburg <[email protected]>
commit 92e222df7b8f05c565009c7383321b593eca488b upstream.
In case of using DUP, we search for enough unallocated disk space on a device to hold two stripes.
The devices_info[ndevs-1].max_avail that holds the amount of unallocated space found is directly assigned to stripe_size, while it's actually twice the stripe size.
Later on in the code, an unconditional division of stripe_size by dev_stripes corrects the value, but in the meantime there's a check to see if the stripe_size does not exceed max_chunk_size. Since during this check stripe_size is twice the amount as intended, the check will reduce the stripe_size to max_chunk_size if the actual correct to be used stripe_size is more than half the amount of max_chunk_size.
The unconditional division later tries to correct stripe_size, but will actually make sure we can't allocate more than half the max_chunk_size.
Fix this by moving the division by dev_stripes before the max chunk size check, so it always contains the right value, instead of putting a duct tape division in further on to get it fixed again.
Since in all other cases than DUP, dev_stripes is 1, this change only affects DUP.
Other attempts in the past were made to fix this:
* 37db63a400 "Btrfs: fix max chunk size check in chunk allocator" tried to fix the same problem, but still resulted in part of the code acting on a wrongly doubled stripe_size value.
* 86db25785a "Btrfs: fix max chunk size on raid5/6" unintentionally broke this fix again.
The real problem was already introduced with the rest of the code in 73c5de0051.
The user visible result however will be that the max chunk size for DUP will suddenly double, while it's actually acting according to the limits in the code again like it was 5 years ago.
--- fs/btrfs/volumes.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
fs/btrfs/volumes.c +6 -5
@@ -4241,10 +4241,13 @@ static int __btrfs_alloc_chunk(struct btif (devs_max && ndevs > devs_max) ndevs = devs_max;/* -* the primary goal is to maximize the number of stripes, so use as many -* devices as possible, even if the stripes are not maximum sized. +* The primary goal is to maximize the number of stripes, so use as +* many devices as possible, even if the stripes are not maximum sized. +* +* The DUP profile stores more than one stripe per device, the +* max_avail is the total size so we have to adjust. */ - stripe_size = devices_info[ndevs-1 ].max_avail; + stripe_size =div_u64 (devices_info[ndevs -1 ].max_avail, dev_stripes); num_stripes = ndevs * dev_stripes;/*
@@ -4284,8 +4287,6 @@ static int __btrfs_alloc_chunk(struct bt stripe_size = devices_info[ndevs-1 ].max_avail; } -do_div (stripe_size, dev_stripes); -/* align to BTRFS_STRIPE_LEN */ do_div (stripe_size, raid_stripe_len); stripe_size *= raid_stripe_len;
PATCH 315/410 btrfs: use proper endianness accessors for super_copy
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Anand Jain <[email protected]>
commit 3c181c12c431fe33b669410d663beb9cceefcd1b upstream.
The fs_info::super_copy is a byte copy of the on-disk structure and all members must use the accessor macros/functions to obtain the right value. This was missing in update_super_roots and in sysfs readers.
Moving between opposite endianness hosts will report bogus numbers in sysfs, and mount may fail as the root will not be restored correctly. If the filesystem is always used on a same endian host, this will not be a problem.
Fix this by using the btrfs_set_super...() functions to set fs_info::super_copy values, and for the sysfs, use the cached fs_info::nodesize/sectorsize values.
[bwh: Backported to 3.16:
- btrfs_fs_info doesn't have cached nodesize or sectorsize fields, so use the accessor functions
- Adjust context]
---
fs/btrfs/sysfs.c +3 -3
@@ -406,7 +406,7 @@ static ssize_t btrfs_nodesize_show(struc {struct btrfs_fs_info *fs_info =to_fs_info (kobj); -return snprintf (buf,PAGE_SIZE ,"%u\n" , fs_info->super_copy->nodesize); +return snprintf (buf,PAGE_SIZE ,"%u\n" ,btrfs_super_nodesize (fs_info->super_copy)); }BTRFS_ATTR_RW (nodesize,0444 , btrfs_nodesize_show, btrfs_no_store);
@@ -416,7 +416,7 @@ static ssize_t btrfs_sectorsize_show(str {struct btrfs_fs_info *fs_info =to_fs_info (kobj); -return snprintf (buf,PAGE_SIZE ,"%u\n" , fs_info->super_copy->sectorsize); +return snprintf (buf,PAGE_SIZE ,"%u\n" ,btrfs_super_sectorsize (fs_info->super_copy)); }BTRFS_ATTR_RW (sectorsize,0444 , btrfs_sectorsize_show, btrfs_no_store);
@@ -426,7 +426,7 @@ static ssize_t btrfs_clone_alignment_sho {struct btrfs_fs_info *fs_info =to_fs_info (kobj); -return snprintf (buf,PAGE_SIZE ,"%u\n" , fs_info->super_copy->sectorsize); +return snprintf (buf,PAGE_SIZE ,"%u\n" ,btrfs_super_sectorsize (fs_info->super_copy)); }BTRFS_ATTR_RW (clone_alignment,0444 , btrfs_clone_alignment_show, btrfs_no_store);
fs/btrfs/transaction.c +12 -8
@@ -1428,19 +1428,23 @@ static void update_super_roots(struct bt super = root->fs_info->super_copy; +/* update latest btrfs_super_block::chunk_root refs */ root_item = &root->fs_info->chunk_root->root_item; - super->chunk_root = root_item->bytenr; - super->chunk_root_generation = root_item->generation; - super->chunk_root_level = root_item->level; +btrfs_set_super_chunk_root (super, root_item->bytenr); +btrfs_set_super_chunk_root_generation (super, root_item->generation); +btrfs_set_super_chunk_root_level (super, root_item->level); +/* update latest btrfs_super_block::root refs */ root_item = &root->fs_info->tree_root->root_item; - super->root = root_item->bytenr; - super->generation = root_item->generation; - super->root_level = root_item->level; +btrfs_set_super_root (super, root_item->bytenr); +btrfs_set_super_generation (super, root_item->generation); +btrfs_set_super_root_level (super, root_item->level); +if (btrfs_test_opt (root,SPACE_CACHE )) - super->cache_generation = root_item->generation; +btrfs_set_super_cache_generation (super, root_item->generation);if (root->fs_info->update_uuid_tree_gen) - super->uuid_tree_generation = root_item->generation; +btrfs_set_super_uuid_tree_generation (super, + root_item->generation); }int btrfs_transaction_in_commit (struct btrfs_fs_info *info)
Re: [PATCH 3.16 315/410] btrfs: use proper endianness accessors for super_copy
Hi Ben,
This patch was reverted from the mainline and 4.14 stable as it only added half of the endianness conversion and caused regression. This patch should not be included.
Thanks, Anand
Quoted 97 lines · Ben Hutchings
3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Anand Jain <[email protected]>
commit
3c181c12c431fe33b669410d663beb9cceefcd1bupstream.The
fs_info::super_copyis a byte copy of the on-disk structure and all members must use the accessor macros/functions to obtain the right value. This was missing inupdate_super_rootsand in sysfs readers.Moving between opposite endianness hosts will report bogus numbers in sysfs, and mount may fail as the root will not be restored correctly. If the filesystem is always used on a same endian host, this will not be a problem.
Fix this by using the btrfs_set_super...() functions to set
fs_info::super_copyvalues, and for the sysfs, use the cached fs_info::nodesize/sectorsize values.Fixes df93589a17378 ("btrfs: export more from FS_INFO to sysfs")Signed-off-by Anand Jain <[email protected]>Reviewed-by Liu Bo <[email protected]>Reviewed-by David Sterba <[email protected]>[ update changelog ]Signed-off-by David Sterba <[email protected]>[bwh: Backported to 3.16:
-btrfs_fs_infodoesn't have cached nodesize or sectorsize fields, so use the accessor functions
- Adjust context]Signed-off-by Ben Hutchings <[email protected]>---
fs/btrfs/sysfs.c +3
-3@@ -406,7 +406,7 @@ static ssize_t btrfs_nodesize_show(struc {struct btrfs_fs_info *fs_info =to_fs_info (kobj); -return snprintf (buf,PAGE_SIZE ,"%u\n" , fs_info->super_copy->nodesize); +return snprintf (buf,PAGE_SIZE ,"%u\n" ,btrfs_super_nodesize (fs_info->super_copy)); }BTRFS_ATTR_RW (nodesize,0444 , btrfs_nodesize_show, btrfs_no_store);@@ -416,7 +416,7 @@ static ssize_t btrfs_sectorsize_show(str {struct btrfs_fs_info *fs_info =to_fs_info (kobj); -return snprintf (buf,PAGE_SIZE ,"%u\n" , fs_info->super_copy->sectorsize); +return snprintf (buf,PAGE_SIZE ,"%u\n" ,btrfs_super_sectorsize (fs_info->super_copy)); }BTRFS_ATTR_RW (sectorsize,0444 , btrfs_sectorsize_show, btrfs_no_store);@@ -426,7 +426,7 @@ static ssize_t btrfs_clone_alignment_sho {struct btrfs_fs_info *fs_info =to_fs_info (kobj); -return snprintf (buf,PAGE_SIZE ,"%u\n" , fs_info->super_copy->sectorsize); +return snprintf (buf,PAGE_SIZE ,"%u\n" ,btrfs_super_sectorsize (fs_info->super_copy)); }BTRFS_ATTR_RW (clone_alignment,0444 , btrfs_clone_alignment_show, btrfs_no_store);fs/btrfs/transaction.c +12
-8@@ -1428,19 +1428,23 @@ static void update_super_roots(struct bt super = root->fs_info->super_copy; +/* update latest btrfs_super_block::chunk_root refs */ root_item = &root->fs_info->chunk_root->root_item; - super->chunk_root = root_item->bytenr; - super->chunk_root_generation = root_item->generation; - super->chunk_root_level = root_item->level; +btrfs_set_super_chunk_root (super, root_item->bytenr); +btrfs_set_super_chunk_root_generation (super, root_item->generation); +btrfs_set_super_chunk_root_level (super, root_item->level); +/* update latest btrfs_super_block::root refs */ root_item = &root->fs_info->tree_root->root_item; - super->root = root_item->bytenr; - super->generation = root_item->generation; - super->root_level = root_item->level; +btrfs_set_super_root (super, root_item->bytenr); +btrfs_set_super_generation (super, root_item->generation); +btrfs_set_super_root_level (super, root_item->level); +if (btrfs_test_opt (root,SPACE_CACHE )) - super->cache_generation = root_item->generation; +btrfs_set_super_cache_generation (super, root_item->generation);if (root->fs_info->update_uuid_tree_gen) - super->uuid_tree_generation = root_item->generation; +btrfs_set_super_uuid_tree_generation (super, + root_item->generation); }int btrfs_transaction_in_commit (struct btrfs_fs_info *info)
Re: [PATCH 3.16 315/410] btrfs: use proper endianness accessors for super_copy
Quoted 5 lines · Anand Jain
Hi Ben,
This patch was reverted from the mainline and 4.14 stable as it only added half of the endianness conversion and caused regression. This patch should not be included.
Oh yes, sorry I didn't spot that. I'll drop it.
Ben.
Quoted 98 lines · Ben Hutchings
Quoted 97 lines
3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Anand Jain <[email protected]>
commit
3c181c12c431fe33b669410d663beb9cceefcd1bupstream.The
fs_info::super_copyis a byte copy of the on-disk structure and all members must use the accessor macros/functions to obtain the right value. This was missing inupdate_super_rootsand in sysfs readers.Moving between opposite endianness hosts will report bogus numbers in sysfs, and mount may fail as the root will not be restored correctly. If the filesystem is always used on a same endian host, this will not be a problem.
Fix this by using the btrfs_set_super...() functions to set
fs_info::super_copyvalues, and for the sysfs, use the cached fs_info::nodesize/sectorsize values.Fixes df93589a17378 ("btrfs: export more from FS_INFO to sysfs")Signed-off-by Anand Jain <[email protected]>Reviewed-by Liu Bo <[email protected]>Reviewed-by David Sterba <[email protected]>[ update changelog ]Signed-off-by David Sterba <[email protected]>[bwh: Backported to 3.16:
-btrfs_fs_infodoesn't have cached nodesize or sectorsize fields, so use the accessor functions
- Adjust context]Signed-off-by Ben Hutchings <[email protected]>---
fs/btrfs/sysfs.c +3
-3@@ -406,7 +406,7 @@ static ssize_t btrfs_nodesize_show(struc {struct btrfs_fs_info *fs_info =to_fs_info (kobj); -return snprintf (buf,PAGE_SIZE ,"%u\n" , fs_info->super_copy->nodesize); +return snprintf (buf,PAGE_SIZE ,"%u\n" ,btrfs_super_nodesize (fs_info->super_copy)); }BTRFS_ATTR_RW (nodesize,0444 , btrfs_nodesize_show, btrfs_no_store);@@ -416,7 +416,7 @@ static ssize_t btrfs_sectorsize_show(str {struct btrfs_fs_info *fs_info =to_fs_info (kobj); -return snprintf (buf,PAGE_SIZE ,"%u\n" , fs_info->super_copy->sectorsize); +return snprintf (buf,PAGE_SIZE ,"%u\n" ,btrfs_super_sectorsize (fs_info->super_copy)); }BTRFS_ATTR_RW (sectorsize,0444 , btrfs_sectorsize_show, btrfs_no_store);@@ -426,7 +426,7 @@ static ssize_t btrfs_clone_alignment_sho {struct btrfs_fs_info *fs_info =to_fs_info (kobj); -return snprintf (buf,PAGE_SIZE ,"%u\n" , fs_info->super_copy->sectorsize); +return snprintf (buf,PAGE_SIZE ,"%u\n" ,btrfs_super_sectorsize (fs_info->super_copy)); }BTRFS_ATTR_RW (clone_alignment,0444 , btrfs_clone_alignment_show, btrfs_no_store);fs/btrfs/transaction.c +12
-8@@ -1428,19 +1428,23 @@ static void update_super_roots(struct bt super = root->fs_info->super_copy; +/* update latest btrfs_super_block::chunk_root refs */ root_item = &root->fs_info->chunk_root->root_item; - super->chunk_root = root_item->bytenr; - super->chunk_root_generation = root_item->generation; - super->chunk_root_level = root_item->level; +btrfs_set_super_chunk_root (super, root_item->bytenr); +btrfs_set_super_chunk_root_generation (super, root_item->generation); +btrfs_set_super_chunk_root_level (super, root_item->level); +/* update latest btrfs_super_block::root refs */ root_item = &root->fs_info->tree_root->root_item; - super->root = root_item->bytenr; - super->generation = root_item->generation; - super->root_level = root_item->level; +btrfs_set_super_root (super, root_item->bytenr); +btrfs_set_super_generation (super, root_item->generation); +btrfs_set_super_root_level (super, root_item->level); +if (btrfs_test_opt (root,SPACE_CACHE )) - super->cache_generation = root_item->generation; +btrfs_set_super_cache_generation (super, root_item->generation);if (root->fs_info->update_uuid_tree_gen) - super->uuid_tree_generation = root_item->generation; +btrfs_set_super_uuid_tree_generation (super, + root_item->generation); }int btrfs_transaction_in_commit (struct btrfs_fs_info *info)
Signature · 2 lines
Ben Hutchings When in doubt, use brute force. - Ken Thompson
PATCH 316/410 staging: android: ashmem: Fix lockdep issue during llseek
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Joel Fernandes <[email protected]>
commit cb57469c9573f6018cd1302953dd45d6e05aba7b upstream.
ashmem_mutex create a chain of dependencies like so:
(1)
mmap syscall ->
mmap_sem -> (acquired)
ashmem_mmap
ashmem_mutex (try to acquire)
(block)
(2)
llseek syscall ->
ashmem_llseek ->
ashmem_mutex -> (acquired)
inode_lock ->
inode->i_rwsem (try to acquire)
(block)
(3)
getdents ->
iterate_dir ->
inode_lock ->
inode->i_rwsem (acquired)
copy_to_user ->
mmap_sem (try to acquire)
There is a lock ordering created between mmap_sem and inode->i_rwsem causing a lockdep splat [2] during a syzcaller test, this patch fixes the issue by unlocking the mutex earlier. Functionally that's Ok since we don't need to protect vfs_llseek.
[1] https://patchwork.kernel.org/patch/10185031/
[2] https://lkml.org/lkml/2018/1/10/48
--- drivers/staging/android/ashmem.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/staging/android/ashmem.c +7 -8
@@ -330,24 +330,23 @@ static loff_t ashmem_llseek(struct filemutex_lock (&ashmem_mutex);if (asma->size ==0 ) { - ret = -EINVAL ; - goto out; +mutex_unlock (&ashmem_mutex); +return -EINVAL ; }if (!asma->file) { - ret = -EBADF ; - goto out; +mutex_unlock (&ashmem_mutex); +return -EBADF ; } +mutex_unlock (&ashmem_mutex); + ret = asma->file->f_op->llseek (asma->file, offset, origin);if (ret <0 ) - goto out; +return ret;/** Copy f_pos from backing file, since f_ops->llseek() sets it */ file->f_pos = asma->file->f_pos; - -out: -mutex_unlock (&ashmem_mutex);return ret; }
PATCH 317/410 ata: Add a new flag to destinguish sas controller
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Shaohua Li <[email protected]>
commit 5067c0469c643512f24786990e315f9c15cc7d24 upstream.
SAS controller has its own tag allocation, which doesn't directly match to ATA tag, so SAS and SATA have different code path for ata tags. Originally we use port->scsi_host (98bd4be1) to destinguish SAS controller, but libsas set ->scsi_host too, so we can't use it for the destinguish, we add a new flag for this purpose.
Without this patch, the following oops can happen because scsi-mq uses a host-wide tag map shared among all devices with some integer tag values >= ATA_MAX_QUEUE. These unexpectedly high tag values cause __ata_qc_from_tag() to return NULL, which is then dereferenced in ata_qc_new_init().
BUG: unable to handle kernel NULL pointer dereference at 0000000000000058 IP: [<ffffffff804fd46e>] ata_qc_new_init+0x3e/0x120 PGD 32adf0067 PUD 32adf1067 PMD 0 Oops: 0002 [#1] SMP DEBUG_PAGEALLOC Modules linked in: iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi igb i2c_algo_bit ptp pps_core pm80xx libsas scsi_transport_sas sg coretemp eeprom w83795 i2c_i801 CPU: 4 PID: 1450 Comm: cydiskbench Not tainted 4.0.0-rc3 #1 Hardware name: Supermicro X8DTH-i/6/iF/6F/X8DTH, BIOS 2.1b 05/04/12 task: ffff8800ba86d500 ti: ffff88032a064000 task.ti: ffff88032a064000 RIP: 0010:[<ffffffff804fd46e>] [<ffffffff804fd46e>] ata_qc_new_init+0x3e/0x120 RSP: 0018:ffff88032a067858 EFLAGS: 00010046 RAX: 0000000000000000 RBX: ffff8800ba0d2230 RCX: 000000000000002a RDX: ffffffff80505ae0 RSI: 0000000000000020 RDI: ffff8800ba0d2230 RBP: ffff88032a067868 R08: 0000000000000201 R09: 0000000000000001 R10: 0000000000000000 R11: 0000000000000000 R12: ffff8800ba0d0000 R13: ffff8800ba0d2230 R14: ffffffff80505ae0 R15: ffff8800ba0d0000 FS: 0000000041223950(0063) GS:ffff88033e480000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b CR2: 0000000000000058 CR3: 000000032a0a3000 CR4: 00000000000006e0 Stack: ffff880329eee758 ffff880329eee758 ffff88032a0678a8 ffffffff80502dad ffff8800ba167978 ffff880329eee758 ffff88032bf9c520 ffff8800ba167978 ffff88032bf9c520 ffff88032bf9a290 ffff88032a0678b8 ffffffff80506909 Call Trace: [<ffffffff80502dad>] ata_scsi_translate+0x3d/0x1b0 [<ffffffff80506909>] ata_sas_queuecmd+0x149/0x2a0 [<ffffffffa0046650>] sas_queuecommand+0xa0/0x1f0 [libsas] [<ffffffff804ea544>] scsi_dispatch_cmd+0xd4/0x1a0 [<ffffffff804eb50f>] scsi_queue_rq+0x66f/0x7f0 [<ffffffff803e5098>] __blk_mq_run_hw_queue+0x208/0x3f0 [<ffffffff803e54b8>] blk_mq_run_hw_queue+0x88/0xc0 [<ffffffff803e5c74>] blk_mq_insert_request+0xc4/0x130 [<ffffffff803e0b63>] blk_execute_rq_nowait+0x73/0x160 [<ffffffffa0023fca>] sg_common_write+0x3da/0x720 [sg] [<ffffffffa0025100>] sg_new_write+0x250/0x360 [sg] [<ffffffffa0025feb>] sg_write+0x13b/0x450 [sg] [<ffffffff8032ec91>] vfs_write+0xd1/0x1b0 [<ffffffff8032ee54>] SyS_write+0x54/0xc0 [<ffffffff80689932>] system_call_fastpath+0x12/0x17
tj: updated description.
[bwh: Backported to 3.16: Drop changes to ata_qc_{new_init,free}(); we don't
actually have the tag allocation bug]
--- drivers/ata/libata-core.c | 4 ++-- drivers/scsi/ipr.c | 3 ++- drivers/scsi/libsas/sas_ata.c | 3 ++- include/linux/libata.h | 1 + 4 files changed, 7 insertions(+), 4 deletions(-)
drivers/scsi/ipr.c +2 -1
@@ -6862,7 +6862,8 @@ static struct ata_port_operations ipr_sa };static struct ata_port_info sata_port_info = { - .flags =ATA_FLAG_SATA |ATA_FLAG_PIO_DMA , + .flags =ATA_FLAG_SATA |ATA_FLAG_PIO_DMA | +ATA_FLAG_SAS_HOST , .pio_mask =ATA_PIO4_ONLY , .mwdma_mask =ATA_MWDMA2 , .udma_mask =ATA_UDMA6 ,
drivers/scsi/libsas/sas_ata.c +2 -1
@@ -566,7 +566,8 @@ static struct ata_port_operations sas_sa };static struct ata_port_info sata_port_info = { - .flags =ATA_FLAG_SATA |ATA_FLAG_PIO_DMA |ATA_FLAG_NCQ , + .flags =ATA_FLAG_SATA |ATA_FLAG_PIO_DMA |ATA_FLAG_NCQ | +ATA_FLAG_SAS_HOST , .pio_mask =ATA_PIO4 , .mwdma_mask =ATA_MWDMA2 , .udma_mask =ATA_UDMA6 ,
include/linux/libata.h +1 -0
@@ -232,6 +232,7 @@ enum {* led */ ATA_FLAG_NO_DIPM = (1 <<23 ),/* host not happy with DIPM */ ATA_FLAG_LOWTAG = (1 <<24 ),/* host wants lowest available tag */ + ATA_FLAG_SAS_HOST = (1 << 25), /* SAS host *//* bits 24:31 of ap->flags are reserved for LLD specific flags */
PATCH 318/410 ata: do not schedule hot plug if it is a sas host
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jason Yan <[email protected]>
commit 6f54120e17e311fd7ac42b9ec2a0611caa5b46ad upstream.
We've got a kernel panic when using sata disk with sas controller:
[115946.152283] Unable to handle kernel NULL pointer dereference at virtual address 000007d8 [115946.223963] CPU: 0 PID: 22175 Comm: kworker/0:1 Tainted: G W OEL 4.14.0 #1 [115946.232925] Workqueue: events ata_scsi_hotplug [115946.237938] task: ffff8021ee50b180 task.stack: ffff00000d5d0000 [115946.244717] PC is at sas_find_dev_by_rphy+0x44/0x114 [115946.250224] LR is at sas_find_dev_by_rphy+0x3c/0x114 ...... [115946.355701] Process kworker/0:1 (pid: 22175, stack limit = 0xffff00000d5d0000) [115946.363369] Call trace: [115946.456356] [<ffff000008878a9c>] sas_find_dev_by_rphy+0x44/0x114 [115946.462908] [<ffff000008878b8c>] sas_target_alloc+0x20/0x5c [115946.469408] [<ffff00000885a31c>] scsi_alloc_target+0x250/0x308 [115946.475781] [<ffff00000885ba30>] __scsi_add_device+0xb0/0x154 [115946.481991] [<ffff0000088b520c>] ata_scsi_scan_host+0x180/0x218 [115946.488367] [<ffff0000088b53d8>] ata_scsi_hotplug+0xb0/0xcc [115946.494801] [<ffff0000080ebd70>] process_one_work+0x144/0x390 [115946.501115] [<ffff0000080ec100>] worker_thread+0x144/0x418 [115946.507093] [<ffff0000080f2c98>] kthread+0x10c/0x138 [115946.512792] [<ffff0000080855dc>] ret_from_fork+0x10/0x18
We found that Ding Xiang has reported a similar bug before:
https://patchwork.kernel.org/patch/9179817/
And this bug still exists in mainline. Since libsas handles hotplug and device adding/removing itself, do not need to schedule ata hot plug task here if it is a sas host.
--- drivers/ata/libata-eh.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/ata/libata-eh.c +2 -1
@@ -815,7 +815,8 @@ void ata_scsi_port_error_handler(structif (ap->pflags &ATA_PFLAG_LOADING ) ap->pflags &= ~ATA_PFLAG_LOADING ; -else if (ap->pflags &ATA_PFLAG_SCSI_HOTPLUG ) +else if ((ap->pflags &ATA_PFLAG_SCSI_HOTPLUG ) && + !(ap->flags &ATA_FLAG_SAS_HOST ))schedule_delayed_work (&ap->hotplug_task,0 );if (ap->pflags &ATA_PFLAG_RECOVERED )
PATCH 319/410 ahci: Add PCI-id for the Highpoint Rocketraid 644L card
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit 28b2182dad43f6f8fcbd167539a26714fd12bd64 upstream.
Like the Highpoint Rocketraid 642L and cards using a Marvel 88SE9235 controller in general, this RAID card also supports AHCI mode and short of a custom driver, this is the only way to make it work under Linux.
Note that even though the card is called to 644L, it has a product-id of 0x0645.
--- drivers/ata/ahci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/ata/ahci.c +3 -1
@@ -529,7 +529,9 @@ static const struct pci_device_id ahci_p .driver_data = board_ahci_yes_fbs }, { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9230), .driver_data = board_ahci_yes_fbs }, - { PCI_DEVICE(PCI_VENDOR_ID_TTI, 0x0642), + { PCI_DEVICE(PCI_VENDOR_ID_TTI, 0x0642), /* highpoint rocketraid 642L */ + .driver_data = board_ahci_yes_fbs }, + { PCI_DEVICE(PCI_VENDOR_ID_TTI, 0x0645), /* highpoint rocketraid 644L */ .driver_data = board_ahci_yes_fbs },/* Promise */
PATCH 320/410 PCI: Add function 1 DMA alias quirk for Highpoint RocketRAID 644L
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit 1903be8222b7c278ca897c129ce477c1dd6403a8 upstream.
The Highpoint RocketRAID 644L uses a Marvel 88SE9235 controller, as with other Marvel controllers this needs a function 1 DMA alias quirk.
Note the RocketRAID 642L uses the same Marvel 88SE9235 controller and already is listed with a function 1 DMA alias quirk.
--- drivers/pci/quirks.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pci/quirks.c +2 -0
@@ -3511,6 +3511,8 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_M quirk_dma_func1_alias);DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_TTI ,0x0642 , quirk_dma_func1_alias); +DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_TTI ,0x0645 , + quirk_dma_func1_alias);/* https://bugs.gentoo.org/show_bug.cgi?id=497630 */ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB388_ESD,
PATCH 321/410 e1000e: Fix check_for_link return value with autoneg off
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Poirier <[email protected]>
commit 4e7dc08e57c95673d2edaba8983c3de4dd1f65f5 upstream.
When autoneg is off, the .check_for_link callback functions clear the get_link_status flag and systematically return a "pseudo-error". This means that the link is not detected as up until the next execution of the e1000_watchdog_task() 2 seconds later.
--- drivers/net/ethernet/intel/e1000e/ich8lan.c | 2 +- drivers/net/ethernet/intel/e1000e/mac.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/e1000e/ich8lan.c +1 -1
@@ -1442,7 +1442,7 @@ static s32 e1000_check_for_copper_link_i* we have already determined whether we have link or not. */ if (!mac->autoneg) -return -E1000_ERR_CONFIG ; +return 1 ;/* Auto-Neg is enabled. Auto Speed Detection takes care * of MAC speed/duplex configuration. So we only need to
drivers/net/ethernet/intel/e1000e/mac.c +1 -1
@@ -450,7 +450,7 @@ s32 e1000e_check_for_copper_link(struct* we have already determined whether we have link or not. */ if (!mac->autoneg) -return -E1000_ERR_CONFIG ; +return 1 ;/* Auto-Neg is enabled. Auto Speed Detection takes care * of MAC speed/duplex configuration. So we only need to
PATCH 322/410 bcache: fix crashes in duplicate cache device register
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Tang Junhui <[email protected]>
commit cc40daf91bdddbba72a4a8cd0860640e06668309 upstream.
Kernel crashed when register a duplicate cache device, the call trace is bellow:
[ 417.643790] CPU: 1 PID: 16886 Comm: bcache-register Tainted: G W OE 4.15.5-amd64-preempt-sysrq-20171018 #2 [ 417.643861] Hardware name: LENOVO 20ERCTO1WW/20ERCTO1WW, BIOS N1DET41W (1.15 ) 12/31/2015 [ 417.643870] RIP: 0010:bdevname+0x13/0x1e [ 417.643876] RSP: 0018:ffffa3aa9138fd38 EFLAGS: 00010282 [ 417.643884] RAX: 0000000000000000 RBX: ffff8c8f2f2f8000 RCX: ffffd6701f8 c7edf [ 417.643890] RDX: ffffa3aa9138fd88 RSI: ffffa3aa9138fd88 RDI: 00000000000 00000 [ 417.643895] RBP: ffffa3aa9138fde0 R08: ffffa3aa9138fae8 R09: 00000000000 1850e [ 417.643901] R10: ffff8c8eed34b271 R11: ffff8c8eed34b250 R12: 00000000000 00000 [ 417.643906] R13: ffffd6701f78f940 R14: ffff8c8f38f80000 R15: ffff8c8ea7d 90000 [ 417.643913] FS: 00007fde7e66f500(0000) GS:ffff8c8f61440000(0000) knlGS: 0000000000000000 [ 417.643919] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 417.643925] CR2: 0000000000000314 CR3: 00000007e6fa0001 CR4: 00000000003 606e0 [ 417.643931] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 00000000000 00000 [ 417.643938] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 00000000000 00400 [ 417.643946] Call Trace: [ 417.643978] register_bcache+0x1117/0x1270 [bcache] [ 417.643994] ? slab_pre_alloc_hook+0x15/0x3c [ 417.644001] ? slab_post_alloc_hook.isra.44+0xa/0x1a [ 417.644013] ? kernfs_fop_write+0xf6/0x138 [ 417.644020] kernfs_fop_write+0xf6/0x138 [ 417.644031] __vfs_write+0x31/0xcc [ 417.644043] ? current_kernel_time64+0x10/0x36 [ 417.644115] ? __audit_syscall_entry+0xbf/0xe3 [ 417.644124] vfs_write+0xa5/0xe2 [ 417.644133] SyS_write+0x5c/0x9f [ 417.644144] do_syscall_64+0x72/0x81 [ 417.644161] entry_SYSCALL_64_after_hwframe+0x3d/0xa2 [ 417.644169] RIP: 0033:0x7fde7e1c1974 [ 417.644175] RSP: 002b:00007fff13009a38 EFLAGS: 00000246 ORIG_RAX: 0000000 000000001 [ 417.644183] RAX: ffffffffffffffda RBX: 0000000001658280 RCX: 00007fde7e1c 1974 [ 417.644188] RDX: 000000000000000a RSI: 0000000001658280 RDI: 000000000000 0001 [ 417.644193] RBP: 000000000000000a R08: 0000000000000003 R09: 000000000000 0077 [ 417.644198] R10: 000000000000089e R11: 0000000000000246 R12: 000000000000 0001 [ 417.644203] R13: 000000000000000a R14: 7fffffffffffffff R15: 000000000000 0000 [ 417.644213] Code: c7 c2 83 6f ee 98 be 20 00 00 00 48 89 df e8 6c 27 3b 0 0 48 89 d8 5b c3 0f 1f 44 00 00 48 8b 47 70 48 89 f2 48 8b bf 80 00 00 00 <8 b> b0 14 03 00 00 e9 73 ff ff ff 0f 1f 44 00 00 48 8b 47 40 39 [ 417.644302] RIP: bdevname+0x13/0x1e RSP: ffffa3aa9138fd38 [ 417.644306] CR2: 0000000000000314
When registering duplicate cache device in register_cache(), after failure on calling register_cache_set(), bch_cache_release() will be called, then bdev will be freed, so bdevname(bdev, name) caused kernel crash.
Since bch_cache_release() will free bdev, so in this patch we make sure bdev being freed if register_cache() fail, and do not free bdev again in register_bcache() when register_cache() fail.
--- drivers/md/bcache/super.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/md/bcache/super.c +10 -6
@@ -1203,7 +1203,7 @@ static void register_bdev(struct cache_sreturn ; err: -pr_notice ("error opening %s: %s" ,bdevname (bdev, name), err); +pr_notice ("error %s: %s" ,bdevname (bdev, name), err);bcache_device_stop (&dc->disk); }
@@ -1861,6 +1861,8 @@ static int register_cache(struct cache_sconst char *err =NULL ;/* must be set for any error case */ int ret =0 ; +bdevname (bdev, name); +memcpy (&ca->sb, sb,sizeof (struct cache_sb )); ca->bdev = bdev; ca->bdev->bd_holder = ca;
@@ -1871,11 +1873,12 @@ static int register_cache(struct cache_s ca->sb_bio.bi_io_vec[0 ].bv_page = sb_page;get_page (sb_page); -if (blk_queue_discard (bdev_get_queue (ca->bdev))) +if (blk_queue_discard (bdev_get_queue (bdev))) ca->discard =CACHE_DISCARD (&ca->sb); ret =cache_alloc (sb, ca);if (ret !=0 ) { +blkdev_put (bdev,FMODE_READ |FMODE_WRITE |FMODE_EXCL );if (ret == -ENOMEM ) err ="cache_alloc(): -ENOMEM" ;else
@@ -1898,14 +1901,14 @@ static int register_cache(struct cache_s goto out; } -pr_info ("registered cache device %s" ,bdevname (bdev, name)); +pr_info ("registered cache device %s" , name); out:kobject_put (&ca->kobj); err:if (err) -pr_notice ("error opening %s: %s" ,bdevname (bdev, name), err); +pr_notice ("error %s: %s" , name, err);return ret; }
@@ -1994,6 +1997,7 @@ static ssize_t register_bcache(struct koif (err) goto err_close; + err ="failed to register device" ;if (SB_IS_BDEV (sb)) {struct cached_dev *dc =kzalloc (sizeof (*dc),GFP_KERNEL );if (!dc)
@@ -2008,7 +2012,7 @@ static ssize_t register_bcache(struct ko goto err_close;if (register_cache (sb, sb_page, bdev, ca) !=0 ) - goto err_close; + goto err; } out:if (sb_page)
@@ -2021,7 +2025,7 @@ out: err_close:blkdev_put (bdev,FMODE_READ |FMODE_WRITE |FMODE_EXCL ); err: -pr_info ("error opening %s: %s" , path, err); +pr_info ("error %s: %s" , path, err); ret = -EINVAL ; goto out; }
PATCH 323/410 bcache: don't attach backing with duplicate UUID
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Michael Lyle <[email protected]>
commit 86755b7a96faed57f910f9e6b8061e019ac1ec08 upstream.
This can happen e.g. during disk cloning.
This is an incomplete fix: it does not catch duplicate UUIDs earlier when things are still unattached. It does not unregister the device. Further changes to cope better with this are planned but conflict with Coly's ongoing improvements to handling device errors. In the meantime, one can manually stop the device after this has happened.
Attempts to attach a duplicate device result in:
[ 136.372404] loop: module loaded [ 136.424461] bcache: register_bdev() registered backing device loop0 [ 136.424464] bcache: bch_cached_dev_attach() Tried to attach loop0 but duplicate UUID already attached
My test procedure is:
dd if=/dev/sdb1 of=imgfile bs=1024 count=262144
losetup -f imgfile
--- drivers/md/bcache/super.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/md/bcache/super.c +11 -0
@@ -964,6 +964,7 @@ int bch_cached_dev_attach(struct cached_uint32_t rtime =cpu_to_le32 (get_seconds ());struct uuid_entry *u;char buf[BDEVNAME_SIZE ]; +struct cached_dev *exist_dc, *t;bdevname (dc->bdev, buf);
@@ -987,6 +988,16 @@ int bch_cached_dev_attach(struct cached_return -EINVAL ; } +/* Check whether already attached */ +list_for_each_entry_safe (exist_dc, t, &c->cached_devs, list) { +if (!memcmp (dc->sb.uuid, exist_dc->sb.uuid,16 )) { +pr_err ("Tried to attach %s but duplicate UUID already attached" , + buf); + +return -EINVAL ; + } + } + u =uuid_find (c, dc->sb.uuid); if (u &&
PATCH 324/410 ia64: convert unwcheck.py to python3
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Corentin Labbe <[email protected]>
commit bd5edbe677948d0883f59d9625c444818d5284b1 upstream.
Since my system use python3 as default, arch/ia64/scripts/unwcheck.py no longer run.
This patch convert it to the python3 syntax.
I have ran it with python2/python3 while printing values of start/end/rlen_sum which could be impacted by this change and I see no difference.
--- arch/ia64/scripts/unwcheck.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
arch/ia64/scripts/unwcheck.py +8 -8
@@ -15,7 +15,7 @@ import re import sys if len(sys.argv) != 2: - print "Usage: %s FILE" % sys.argv[0] + print("Usage: %s FILE" % sys.argv[0]) sys.exit(2) readelf = os.getenv("READELF", "readelf")
@@ -28,7 +28,7 @@ def check_func (func, slots, rlen_sum): global num_errors num_errors += 1 if not func: func = "[%#x-%#x]" % (start, end) - print "ERROR: %s: %lu slots, total region length = %lu" % (func, slots, rlen_sum) + print("ERROR: %s: %lu slots, total region length = %lu" % (func, slots, rlen_sum)) return num_funcs = 0
@@ -42,23 +42,23 @@ for line in os.popen("%s -u %s" % (reade check_func(func, slots, rlen_sum) func = m.group(1) - start = long(m.group(2), 16) - end = long(m.group(3), 16) + start = int(m.group(2), 16) + end = int(m.group(3), 16) slots = 3 * (end - start) / 16 - rlen_sum = 0L + rlen_sum = 0 num_funcs += 1 else: m = rlen_pattern.match(line) if m: - rlen_sum += long(m.group(1)) + rlen_sum += int(m.group(1)) check_func(func, slots, rlen_sum) if num_errors == 0: - print "No errors detected in %u functions." % num_funcs + print("No errors detected in %u functions." % num_funcs) else: if num_errors > 1: err="errors" else: err="error" - print "%u %s detected in %u functions." % (num_errors, err, num_funcs) + print("%u %s detected in %u functions." % (num_errors, err, num_funcs)) sys.exit(1)
PATCH 325/410 MIPS: BMIPS: Do not mask IPIs during suspend
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Justin Chen <[email protected]>
commit 06a3f0c9f2725f5d7c63c4203839373c9bd00c28 upstream.
Commit a3e6c1eff548 ("MIPS: IRQ: Fix disable_irq on CPU IRQs") fixes an issue where disable_irq did not actually disable the irq. The bug caused our IPIs to not be disabled, which actually is the correct behavior.
With the addition of commit a3e6c1eff548 ("MIPS: IRQ: Fix disable_irq on CPU IRQs"), the IPIs were getting disabled going into suspend, thus schedule_ipi() was not being called. This caused deadlocks where schedulable task were not being scheduled and other cpus were waiting for them to do something.
Add the IRQF_NO_SUSPEND flag so an irq_disable will not be called on the IPIs during suspend.
Patchwork: https://patchwork.linux-mips.org/patch/17385/
--- arch/mips/kernel/smp-bmips.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/mips/kernel/smp-bmips.c +4 -4
@@ -159,11 +159,11 @@ static void bmips_prepare_cpus(unsignedreturn ; } -if (request_irq (IPI0_IRQ , bmips_ipi_interrupt,IRQF_PERCPU , -"smp_ipi0" ,NULL )) +if (request_irq (IPI0_IRQ , bmips_ipi_interrupt, +IRQF_PERCPU |IRQF_NO_SUSPEND ,"smp_ipi0" ,NULL ))panic ("Can't request IPI0 interrupt" ); -if (request_irq (IPI1_IRQ , bmips_ipi_interrupt,IRQF_PERCPU , -"smp_ipi1" ,NULL )) +if (request_irq (IPI1_IRQ , bmips_ipi_interrupt, +IRQF_PERCPU |IRQF_NO_SUSPEND ,"smp_ipi1" ,NULL ))panic ("Can't request IPI1 interrupt" ); }
PATCH 326/410 uas: fix comparison for error code
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit 9a513c905bb95bef79d96feb08621c1ec8d8c4bb upstream.
A typo broke the comparison.
--- drivers/usb/storage/uas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/storage/uas.c +1 -1
@@ -1195,7 +1195,7 @@ static int uas_post_reset(struct usb_intreturn 0 ; err =uas_configure_endpoints (devinfo); -if (err && err !=ENODEV ) +if (err && err != -ENODEV )shost_printk (KERN_ERR , shost,"%s: alloc streams error %d after reset" , __func__, err);
PATCH 327/410 usb: quirks: add control message delay for 1b1c:1b20
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Danilo Krummrich <[email protected]>
commit cb88a0588717ba6c756cb5972d75766b273a6817 upstream.
Corsair Strafe RGB keyboard does not respond to usb control messages sometimes and hence generates timeouts.
Commit de3af5bf259d ("usb: quirks: add delay init quirk for Corsair Strafe RGB keyboard") tried to fix those timeouts by adding USB_QUIRK_DELAY_INIT.
Unfortunately, even with this quirk timeouts of usb_control_msg() can still be seen, but with a lower frequency (approx. 1 out of 15):
[ 29.103520] usb 1-8: string descriptor 0 read error: -110 [ 34.363097] usb 1-8: can't set config #1, error -110
Adding further delays to different locations where usb control messages are issued just moves the timeouts to other locations, e.g.:
[ 35.400533] usbhid 1-8:1.0: can't add hid device: -110 [ 35.401014] usbhid: probe of 1-8:1.0 failed with error -110
The only way to reliably avoid those issues is having a pause after each usb control message. In approx. 200 boot cycles no more timeouts were seen.
Addionaly, keep USB_QUIRK_DELAY_INIT as it turned out to be necessary to have the delay in hub_port_connect() after hub_port_init().
The overall boot time seems not to be influenced by these additional delays, even on fast machines and lightweight distributions.
--- drivers/usb/core/message.c | 4 ++++ drivers/usb/core/quirks.c | 3 ++- include/linux/usb/quirks.h | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-)
drivers/usb/core/message.c +4 -0
@@ -147,6 +147,10 @@ int usb_control_msg(struct usb_device *d ret =usb_internal_control_msg (dev, pipe, dr, data, size, timeout); +/* Linger a bit, prior to the next control message. */ +if (dev->quirks &USB_QUIRK_DELAY_CTRL_MSG ) +msleep (200 ); +kfree (dr);return ret;
drivers/usb/core/quirks.c +2 -1
@@ -226,7 +226,8 @@ static const struct usb_device_id usb_qu { USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT }, /* Corsair Strafe RGB */ - { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT }, + { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT | + USB_QUIRK_DELAY_CTRL_MSG }, /* Corsair K70 LUX */ { USB_DEVICE(0x1b1c, 0x1b36), .driver_info = USB_QUIRK_DELAY_INIT },
include/linux/usb/quirks.h +3 -0
@@ -56,4 +56,7 @@*/ #define USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL BIT(11) +/* Device needs a pause after every control message. */ +#define USB_QUIRK_DELAY_CTRL_MSG BIT(13) +#endif /* __LINUX_USB_QUIRKS_H */
PATCH 328/410 brcmfmac: fix P2P_DEVICE ethernet address generation
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Arend Van Spriel <[email protected]>
commit 455f3e76cfc0d893585a5f358b9ddbe9c1e1e53b upstream.
The firmware has a requirement that the P2P_DEVICE address should be different from the address of the primary interface. When not specified by user-space, the driver generates the MAC address for the P2P_DEVICE interface using the MAC address of the primary interface and setting the locally administered bit. However, the MAC address of the primary interface may already have that bit set causing the creation of the P2P_DEVICE interface to fail with -EBUSY. Fix this by using a random address instead to determine the P2P_DEVICE address.
--- drivers/net/wireless/brcm80211/brcmfmac/p2p.c | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/p2p.c +11 -13
@@ -457,25 +457,23 @@ static int brcmf_p2p_set_firmware(struct* @dev_addr: optional device address. * * P2P needs mac addresses for P2P device and interface. If no device -* address it specified, these are derived from the primary net device, ie. -* the permanent ethernet address of the device. +* address it specified, these are derived from a random ethernet +* address. */ static void brcmf_p2p_generate_bss_mac (struct brcmf_p2p_info *p2p,u8 *dev_addr) { -struct brcmf_if *pri_ifp = p2p->bss_idx[P2PAPI_BSSCFG_PRIMARY ].vif->ifp; -bool local_admin = false; +bool random_addr = false; -if (!dev_addr ||is_zero_ether_addr (dev_addr)) { - dev_addr = pri_ifp->mac_addr; - local_admin = true; - } +if (!dev_addr ||is_zero_ether_addr (dev_addr)) + random_addr = true; -/* Generate the P2P Device Address. This consists of the device's -* primary MAC address with the locally administered bit set. +/* Generate the P2P Device Address obtaining a random ethernet +* address with the locally administered bit set. */ -memcpy (p2p->dev_addr, dev_addr,ETH_ALEN ); -if (local_admin) - p2p->dev_addr[0 ] |=0x02 ; +if (random_addr) +eth_random_addr (p2p->dev_addr); +else +memcpy (p2p->dev_addr, dev_addr,ETH_ALEN );/* Generate the P2P Interface Address. If the discovery and connection * BSSCFGs need to simultaneously co-exist, then this address must be
PATCH 329/410 sch_netem: fix skb leak in netem_enqueue()
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Kodanev <[email protected]>
commit 35d889d10b649fda66121891ec05eca88150059d upstream.
When we exceed current packets limit and we have more than one segment in the list returned by skb_gso_segment(), netem drops only the first one, skipping the rest, hence kmemleak reports:
unreferenced object 0xffff880b5d23b600 (size 1024):
comm "softirq", pid 0, jiffies 4384527763 (age 2770.629s) hex dump (first 32 bytes):
00 80 23 5d 0b 88 ff ff 00 00 00 00 00 00 00 00 ..#]............
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<00000000d8a19b9d>] __alloc_skb+0xc9/0x520
[<000000001709b32f>] skb_segment+0x8c8/0x3710
[<00000000c7b9bb88>] tcp_gso_segment+0x331/0x1830
[<00000000c921cba1>] inet_gso_segment+0x476/0x1370
[<000000008b762dd4>] skb_mac_gso_segment+0x1f9/0x510
[<000000002182660a>] __skb_gso_segment+0x1dd/0x620
[<00000000412651b9>] netem_enqueue+0x1536/0x2590 [sch_netem]
[<0000000005d3b2a9>] __dev_queue_xmit+0x1167/0x2120
[<00000000fc5f7327>] ip_finish_output2+0x998/0xf00
[<00000000d309e9d3>] ip_output+0x1aa/0x2c0
[<000000007ecbd3a4>] tcp_transmit_skb+0x18db/0x3670
[<0000000042d2a45f>] tcp_write_xmit+0x4d4/0x58c0
[<0000000056a44199>] tcp_tasklet_func+0x3d9/0x540
[<0000000013d06d02>] tasklet_action+0x1ca/0x250
[<00000000fcde0b8b>] __do_softirq+0x1b4/0x5a3
[<00000000e7ed027c>] irq_exit+0x1e2/0x210Fix it by adding the rest of the segments, if any, to skb 'to_free' list. Add new __qdisc_drop_all() and qdisc_drop_all() functions because they can be useful in the future if we need to drop segmented GSO packets in other places.
[bwh: Backported to 3.16:
- The reshape_fail operation still exists, so keep calling it here if the skb did not require segmentation
- We don't have a to_free list, so free directly in qdisc_drop_all()
- Open-code qdisc_qstats_drop()]
---
include/net/sch_generic.h +8 -0
@@ -656,6 +656,14 @@ static inline int qdisc_drop(struct sk_breturn NET_XMIT_DROP ; } +static inline int qdisc_drop_all (struct sk_buff *skb,struct Qdisc *sch) +{ +kfree_skb_list (skb); + sch->qstats.drops++; + +return NET_XMIT_DROP ; +} +static inline int qdisc_reshape_fail (struct sk_buff *skb,struct Qdisc *sch) { sch->qstats.drops++;
net/sched/sch_netem.c +5 -1
@@ -511,8 +511,12 @@ static int netem_enqueue(struct sk_buff1 <<(prandom_u32 () %8 ); } -if (unlikely (skb_queue_len (&sch->q) >= sch->limit)) +if (unlikely (skb_queue_len (&sch->q) >= sch->limit)) { +/* qdisc_reshape_fail() can't handle segmented skb */ +if (segs) +return qdisc_drop_all (skb, sch);return qdisc_reshape_fail (skb, sch); + } sch->qstats.backlog +=qdisc_pkt_len (skb);
PATCH 330/410 l2tp: do not accept arbitrary sockets
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit 17cfe79a65f98abe535261856c5aef14f306dff7 upstream.
syzkaller found an issue caused by lack of sufficient checks in l2tp_tunnel_create()
RAW sockets can not be considered as UDP ones for instance.
In another patch, we shall replace all pr_err() by less intrusive pr_debug() so that syzkaller can find other bugs faster.
==================================================================
BUG: KASAN: slab-out-of-bounds in setup_udp_tunnel_sock+0x3ee/0x5f0 net/ipv4/udp_tunnel.c:69 dst_release: dst:00000000d53d0d0f refcnt:-1 Write of size 1 at addr ffff8801d013b798 by task syz-executor3/6242 CPU: 1 PID: 6242 Comm: syz-executor3 Not tainted 4.16.0-rc2+ #253 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:17 [inline] dump_stack+0x194/0x24d lib/dump_stack.c:53 print_address_description+0x73/0x250 mm/kasan/report.c:256 kasan_report_error mm/kasan/report.c:354 [inline] kasan_report+0x23b/0x360 mm/kasan/report.c:412 __asan_report_store1_noabort+0x17/0x20 mm/kasan/report.c:435 setup_udp_tunnel_sock+0x3ee/0x5f0 net/ipv4/udp_tunnel.c:69 l2tp_tunnel_create+0x1354/0x17f0 net/l2tp/l2tp_core.c:1596 pppol2tp_connect+0x14b1/0x1dd0 net/l2tp/l2tp_ppp.c:707 SYSC_connect+0x213/0x4a0 net/socket.c:1640 SyS_connect+0x24/0x30 net/socket.c:1621 do_syscall_64+0x280/0x940 arch/x86/entry/common.c:287 entry_SYSCALL_64_after_hwframe+0x42/0xb7
--- net/l2tp/l2tp_core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
net/l2tp/l2tp_core.c +6 -2
@@ -1581,9 +1581,14 @@ int l2tp_tunnel_create(struct net *net, encap = cfg->encap;/* Quick sanity checks */ + err = -EPROTONOSUPPORT ; +if (sk->sk_type !=SOCK_DGRAM ) { +pr_debug ("tunl %hu: fd %d wrong socket type\n" , + tunnel_id, fd); + goto err; + }switch (encap) {case L2TP_ENCAPTYPE_UDP : - err = -EPROTONOSUPPORT ;if (sk->sk_protocol !=IPPROTO_UDP ) {pr_err ("tunl %hu: fd %d wrong protocol, got %d, expected %d\n" , tunnel_id, fd, sk->sk_protocol,IPPROTO_UDP );
@@ -1591,7 +1596,6 @@ int l2tp_tunnel_create(struct net *net, }break ;case L2TP_ENCAPTYPE_IP : - err = -EPROTONOSUPPORT ;if (sk->sk_protocol !=IPPROTO_L2TP ) {pr_err ("tunl %hu: fd %d wrong protocol, got %d, expected %d\n" , tunnel_id, fd, sk->sk_protocol,IPPROTO_L2TP );
PATCH 331/410 RDMA/ucma: Limit possible option size
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
commit 6a21dfc0d0db7b7e0acedce67ca533a6eb19283c upstream.
Users of ucma are supposed to provide size of option level, in most paths it is supposed to be equal to u8 or u16, but it is not the case for the IB path record, where it can be multiple of struct ib_path_rec_data.
This patch takes simplest possible approach and prevents providing values more than possible to allocate.
--- drivers/infiniband/core/ucma.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/infiniband/core/ucma.c +3 -0
@@ -1187,6 +1187,9 @@ static ssize_t ucma_set_option(struct ucif (IS_ERR (ctx))return PTR_ERR (ctx); +if (unlikely (cmd.optval >KMALLOC_MAX_SIZE )) +return -EINVAL ; + optval =memdup_user ((void __user *) (unsigned long ) cmd.optval, cmd.optlen);if (IS_ERR (optval)) {
PATCH 332/410 RDMA/ucma: Check that user doesn't overflow QP state
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
commit a5880b84430316e3e1c1f5d23aa32ec6000cc717 upstream.
The QP state is limited and declared in enum ib_qp_state, but ucma user was able to supply any possible (u32) value.
--- drivers/infiniband/core/ucma.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/infiniband/core/ucma.c +3 -0
@@ -1050,6 +1050,9 @@ static ssize_t ucma_init_qp_attr(structif (copy_from_user (&cmd, inbuf,sizeof (cmd)))return -EFAULT ; +if (cmd.qp_state >IB_QPS_ERR ) +return -EINVAL ; + ctx =ucma_get_ctx (file, cmd.id);if (IS_ERR (ctx))return PTR_ERR (ctx);
PATCH 333/410 drm/radeon: fix KV harvesting
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit 0b58d90f89545e021d188c289fa142e5ff9e708b upstream.
Always set the graphics values to the max for the asic type. E.g., some 1 RB chips are actually 1 RB chips, others are actually harvested 2 RB chips.
--- drivers/gpu/drm/radeon/cik.c | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-)
drivers/gpu/drm/radeon/cik.c +2 -29
@@ -3299,35 +3299,8 @@ static void cik_gpu_init(struct radeon_dcase CHIP_KAVERI : rdev->config.cik.max_shader_engines =1 ; rdev->config.cik.max_tile_pipes =4 ; -if ((rdev->pdev->device ==0x1304 ) || - (rdev->pdev->device ==0x1305 ) || - (rdev->pdev->device ==0x130C ) || - (rdev->pdev->device ==0x130F ) || - (rdev->pdev->device ==0x1310 ) || - (rdev->pdev->device ==0x1311 ) || - (rdev->pdev->device ==0x131C )) { - rdev->config.cik.max_cu_per_sh =8 ; - rdev->config.cik.max_backends_per_se =2 ; - }else if ((rdev->pdev->device ==0x1309 ) || - (rdev->pdev->device ==0x130A ) || - (rdev->pdev->device ==0x130D ) || - (rdev->pdev->device ==0x1313 ) || - (rdev->pdev->device ==0x131D )) { - rdev->config.cik.max_cu_per_sh =6 ; - rdev->config.cik.max_backends_per_se =2 ; - }else if ((rdev->pdev->device ==0x1306 ) || - (rdev->pdev->device ==0x1307 ) || - (rdev->pdev->device ==0x130B ) || - (rdev->pdev->device ==0x130E ) || - (rdev->pdev->device ==0x1315 ) || - (rdev->pdev->device ==0x1318 ) || - (rdev->pdev->device ==0x131B )) { - rdev->config.cik.max_cu_per_sh =4 ; - rdev->config.cik.max_backends_per_se =1 ; - }else { - rdev->config.cik.max_cu_per_sh =3 ; - rdev->config.cik.max_backends_per_se =1 ; - } + rdev->config.cik.max_cu_per_sh =8 ; + rdev->config.cik.max_backends_per_se =2 ; rdev->config.cik.max_sh_per_se =1 ; rdev->config.cik.max_texture_channel_caches =4 ; rdev->config.cik.max_gprs =256 ;
PATCH 334/410 x86/spectre_v2: Don't check microcode versions when running under hypervisors
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Rzeszutek Wilk <[email protected]>
commit 36268223c1e9981d6cfc33aff8520b3bde4b8114 upstream.
As:
1) It's known that hypervisors lie about the environment anyhow (host mismatch)
2) Even if the hypervisor (Xen, KVM, VMWare, etc) provided a valid "correct" value, it all gets to be very murky when migration happens (do you provide the "new" microcode of the machine?).
And in reality the cloud vendors are the ones that should make sure that the microcode that is running is correct and we should just sing lalalala and trust them.
--- arch/x86/kernel/cpu/intel.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/x86/kernel/cpu/intel.c +7 -0
@@ -68,6 +68,13 @@ static bool bad_spectre_microcode(struct {int i; +/* +* We know that the hypervisor lie to us on the microcode version so +* we may as well hope that it is running the correct version. +*/ +if (cpu_has (c,X86_FEATURE_HYPERVISOR )) +return false; +for (i =0 ; i <ARRAY_SIZE (spectre_bad_microcodes); i++) {if (c->x86_model == spectre_bad_microcodes[i].model && c->x86_mask == spectre_bad_microcodes[i].stepping)
PATCH 335/410 x86/MCE: Save microcode revision in machine check records
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Tony Luck <[email protected]>
commit fa94d0c6e0f3431523f5701084d799c77c7d4a4f upstream.
Updating microcode used to be relatively rare. Now that it has become more common we should save the microcode version in a machine check record to make sure that those people looking at the error have this important information bundled with the rest of the logged information.
[ Borislav: Simplify a bit. ]
[bwh: Backported to 3.2:
- Add other new fields to struct mce, to match upstream UAPI
- Adjust context]
---
--
To unsubscribe from this list: send the line "unsubscribe linux-edac" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
arch/x86/include/uapi/asm/mce.h +4 -0
@@ -25,6 +25,10 @@ struct mce {__u32 socketid;/* CPU socket ID */ __u32 apicid;/* CPU initial apic ID */ __u64 mcgcap;/* MCGCAP MSR: machine check capabilities of CPU */ +__u64 synd;/* MCA_SYND MSR: only valid on SMCA systems */ +__u64 ipid;/* MCA_IPID MSR: only valid on SMCA systems */ +__u64 ppin;/* Protected Processor Inventory Number */ +__u32 microcode;/* Microcode revision */ };#define MCE_GET_RECORD_LEN _IOR('M', 1, int)
arch/x86/kernel/cpu/mcheck/mce.c +3 -1
@@ -135,6 +135,8 @@ void mce_setup(struct mce *m) m->socketid =cpu_data (m->extcpu).phys_proc_id; m->apicid =cpu_data (m->extcpu).initial_apicid;rdmsrl (MSR_IA32_MCG_CAP , m->mcgcap); + + m->microcode = boot_cpu_data.microcode; } DEFINE_PER_CPU(struct mce, injectm);
@@ -282,7 +284,7 @@ static void print_mce(struct mce *m)*/ pr_emerg (HW_ERR "PROCESSOR %u:%x TIME %llu SOCKET %u APIC %x microcode %x\n" , m->cpuvendor, m->cpuid, m->time, m->socketid, m->apicid, -cpu_data (m->extcpu).microcode); + m->microcode);/* * Print out human-readable details about the MCE error,
PATCH 336/410 team: Fix double free in error path
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Arkadi Sharshevsky <[email protected]>
commit cbcc607e18422555db569b593608aec26111cb0b upstream.
The __send_and_alloc_skb() receives a skb ptr as a parameter but in case it fails the skb is not valid:
- Send failed and released the skb internally.
- Allocation failed.
The current code tries to release the skb in case of failure which causes redundant freeing.
--- drivers/net/team/team.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/team/team.c +2 -2
@@ -2356,7 +2356,7 @@ send_done:if (!nlh) { err =__send_and_alloc_skb (&skb, team, portid, send_func);if (err) - goto errout; +return err; goto send_done; }
@@ -2636,7 +2636,7 @@ send_done:if (!nlh) { err =__send_and_alloc_skb (&skb, team, portid, send_func);if (err) - goto errout; +return err; goto send_done; }
PATCH 337/410 USB: storage: Add JMicron bridge 152d:2567 to unusual_devs.h
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Teijo Kinnunen <[email protected]>
commit 5126a504b63d82785eaece3a9c30c660b313785a upstream.
This USB-SATA controller seems to be similar with JMicron bridge 152d:2566 already on the list. Adding it here fixes "Invalid field in cdb" errors.
--- drivers/usb/storage/unusual_devs.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/storage/unusual_devs.h +7 -0
@@ -2004,6 +2004,13 @@ UNUSUAL_DEV( 0x152d, 0x2566, 0x0114, 0x USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_BROKEN_FUA ), +/* Reported by Teijo Kinnunen <[email protected]> */ +UNUSUAL_DEV (0x152d ,0x2567 ,0x0117 ,0x0117 , +"JMicron" , +"USB to ATA/ATAPI Bridge" , +USB_SC_DEVICE ,USB_PR_DEVICE ,NULL , +US_FL_BROKEN_FUA ), +/* Reported-by George Cherian <[email protected]> */ UNUSUAL_DEV(0x152d, 0x9561, 0x0000, 0x9999, "JMicron",
PATCH 338/410 USB: usbmon: remove assignment from IS_ERR argument
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Julia Lawall <[email protected]>
commit 46c236dc7d1212d7417e6fb0317f91c44c719322 upstream.
The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression e1,e2;
statement S1,S2;
@@
+e1 = e2;
if (IS_ERR(
e1
- = e2
)) S1 else S2
// </smpl>
--- drivers/usb/mon/mon_text.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/usb/mon/mon_text.c +4 -2
@@ -386,7 +386,8 @@ static ssize_t mon_text_read_t(struct fistruct mon_event_text *ep;struct mon_text_ptr ptr; -if (IS_ERR (ep =mon_text_read_wait (rp, file))) + ep =mon_text_read_wait (rp, file); +if (IS_ERR (ep))return PTR_ERR (ep);mutex_lock (&rp->printf_lock); ptr.cnt =0 ;
@@ -413,7 +414,8 @@ static ssize_t mon_text_read_u(struct fistruct mon_event_text *ep;struct mon_text_ptr ptr; -if (IS_ERR (ep =mon_text_read_wait (rp, file))) + ep =mon_text_read_wait (rp, file); +if (IS_ERR (ep))return PTR_ERR (ep);mutex_lock (&rp->printf_lock); ptr.cnt =0 ;
PATCH 339/410 usb: usbmon: Read text within supplied buffer size
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Pete Zaitcev <[email protected]>
commit a5f596830e27e15f7a0ecd6be55e433d776986d8 upstream.
This change fixes buffer overflows and silent data corruption with the usbmon device driver text file read operations.
--- drivers/usb/mon/mon_text.c | 126 +++++++++++++++++++++++-------------- 1 file changed, 78 insertions(+), 48 deletions(-)
drivers/usb/mon/mon_text.c +77 -47
@@ -82,6 +82,8 @@ struct mon_reader_text {wait_queue_head_t wait;int printf_size; +size_t printf_offset; +size_t printf_togo;char *printf_buf;struct mutex printf_lock;
@@ -373,75 +375,103 @@ err_alloc:return rc; } -/* -* For simplicity, we read one record in one system call and throw out -* what does not fit. This means that the following does not work: -* dd if=/dbg/usbmon/0t bs=10 -* Also, we do not allow seeks and do not bother advancing the offset. -*/ +static ssize_t mon_text_copy_to_user (struct mon_reader_text *rp, +char __user *const buf,const size_t nbytes) +{ +const size_t togo =min (nbytes, rp->printf_togo); + +if (copy_to_user (buf, &rp->printf_buf[rp->printf_offset], togo)) +return -EFAULT ; + rp->printf_togo -= togo; + rp->printf_offset += togo; +return togo; +} + +/* ppos is not advanced since the llseek operation is not permitted. */ static ssize_t mon_text_read_t (struct file *file,char __user *buf, -size_t nbytes,loff_t *ppos) +size_t nbytes,loff_t *ppos) {struct mon_reader_text *rp = file->private_data;struct mon_event_text *ep;struct mon_text_ptr ptr; +ssize_t ret; - ep =mon_text_read_wait (rp, file); -if (IS_ERR (ep)) -return PTR_ERR (ep);mutex_lock (&rp->printf_lock); - ptr.cnt =0 ; - ptr.pbuf = rp->printf_buf; - ptr.limit = rp->printf_size; - -mon_text_read_head_t (rp, &ptr, ep); -mon_text_read_statset (rp, &ptr, ep); - ptr.cnt +=snprintf (ptr.pbuf + ptr.cnt, ptr.limit - ptr.cnt, -" %d" , ep->length); -mon_text_read_data (rp, &ptr, ep); -if (copy_to_user (buf, rp->printf_buf, ptr.cnt)) - ptr.cnt = -EFAULT ; +if (rp->printf_togo ==0 ) { + + ep =mon_text_read_wait (rp, file); +if (IS_ERR (ep)) { +mutex_unlock (&rp->printf_lock); +return PTR_ERR (ep); + } + ptr.cnt =0 ; + ptr.pbuf = rp->printf_buf; + ptr.limit = rp->printf_size; + +mon_text_read_head_t (rp, &ptr, ep); +mon_text_read_statset (rp, &ptr, ep); + ptr.cnt +=snprintf (ptr.pbuf + ptr.cnt, ptr.limit - ptr.cnt, +" %d" , ep->length); +mon_text_read_data (rp, &ptr, ep); + + rp->printf_togo = ptr.cnt; + rp->printf_offset =0 ; + +kmem_cache_free (rp->e_slab, ep); + } + + ret =mon_text_copy_to_user (rp, buf, nbytes);mutex_unlock (&rp->printf_lock); -kmem_cache_free (rp->e_slab, ep); -return ptr.cnt; +return ret; } +/* ppos is not advanced since the llseek operation is not permitted. */ static ssize_t mon_text_read_u (struct file *file,char __user *buf, -size_t nbytes,loff_t *ppos) +size_t nbytes,loff_t *ppos) {struct mon_reader_text *rp = file->private_data;struct mon_event_text *ep;struct mon_text_ptr ptr; +ssize_t ret; - ep =mon_text_read_wait (rp, file); -if (IS_ERR (ep)) -return PTR_ERR (ep);mutex_lock (&rp->printf_lock); - ptr.cnt =0 ; - ptr.pbuf = rp->printf_buf; - ptr.limit = rp->printf_size; -mon_text_read_head_u (rp, &ptr, ep); -if (ep->type =='E' ) { -mon_text_read_statset (rp, &ptr, ep); - }else if (ep->xfertype ==USB_ENDPOINT_XFER_ISOC ) { -mon_text_read_isostat (rp, &ptr, ep); -mon_text_read_isodesc (rp, &ptr, ep); - }else if (ep->xfertype ==USB_ENDPOINT_XFER_INT ) { -mon_text_read_intstat (rp, &ptr, ep); - }else { -mon_text_read_statset (rp, &ptr, ep); +if (rp->printf_togo ==0 ) { + + ep =mon_text_read_wait (rp, file); +if (IS_ERR (ep)) { +mutex_unlock (&rp->printf_lock); +return PTR_ERR (ep); + } + ptr.cnt =0 ; + ptr.pbuf = rp->printf_buf; + ptr.limit = rp->printf_size; + +mon_text_read_head_u (rp, &ptr, ep); +if (ep->type =='E' ) { +mon_text_read_statset (rp, &ptr, ep); + }else if (ep->xfertype ==USB_ENDPOINT_XFER_ISOC ) { +mon_text_read_isostat (rp, &ptr, ep); +mon_text_read_isodesc (rp, &ptr, ep); + }else if (ep->xfertype ==USB_ENDPOINT_XFER_INT ) { +mon_text_read_intstat (rp, &ptr, ep); + }else { +mon_text_read_statset (rp, &ptr, ep); + } + ptr.cnt +=snprintf (ptr.pbuf + ptr.cnt, ptr.limit - ptr.cnt, +" %d" , ep->length); +mon_text_read_data (rp, &ptr, ep); + + rp->printf_togo = ptr.cnt; + rp->printf_offset =0 ; + +kmem_cache_free (rp->e_slab, ep); } - ptr.cnt +=snprintf (ptr.pbuf + ptr.cnt, ptr.limit - ptr.cnt, -" %d" , ep->length); -mon_text_read_data (rp, &ptr, ep); -if (copy_to_user (buf, rp->printf_buf, ptr.cnt)) - ptr.cnt = -EFAULT ; + ret =mon_text_copy_to_user (rp, buf, nbytes);mutex_unlock (&rp->printf_lock); -kmem_cache_free (rp->e_slab, ep); -return ptr.cnt; +return ret; } static struct mon_event_text *mon_text_read_wait(struct mon_reader_text *rp,
PATCH 340/410 xhci: Fix front USB ports on ASUS PRIME B350M-A
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Kai-Heng Feng <[email protected]>
commit 191edc5e2e515aab1075a3f0ef23599e80be5f59 upstream.
When a USB device gets plugged on ASUS PRIME B350M-A's front ports, the xHC stops working:
[ 549.114587] xhci_hcd 0000:02:00.0: WARN: xHC CMD_RUN timeout [ 549.114608] suspend_common(): xhci_pci_suspend+0x0/0xc0 returns -110 [ 549.114638] xhci_hcd 0000:02:00.0: can't suspend (hcd_pci_runtime_suspend returned -110)
Delay before running xHC command CMD_RUN can workaround the issue.
Use a new quirk to make the delay only targets to the affected xHC.
--- drivers/usb/host/xhci-pci.c | 3 +++ drivers/usb/host/xhci.c | 3 +++ drivers/usb/host/xhci.h | 1 + 3 files changed, 7 insertions(+)
drivers/usb/host/xhci-pci.c +3 -0
@@ -124,6 +124,9 @@ static void xhci_pci_quirks(struct devicif (pdev->vendor ==PCI_VENDOR_ID_AMD &&usb_amd_find_chipset_info ()) xhci->quirks |=XHCI_AMD_PLL_FIX ; +if (pdev->vendor ==PCI_VENDOR_ID_AMD && pdev->device ==0x43bb ) + xhci->quirks |=XHCI_SUSPEND_DELAY ; +if (pdev->vendor ==PCI_VENDOR_ID_AMD ) xhci->quirks |=XHCI_TRUST_TX_LENGTH ;
drivers/usb/host/xhci.c +3 -0
@@ -922,6 +922,9 @@ int xhci_suspend(struct xhci_hcd *xhci,clear_bit (HCD_FLAG_POLL_RH , &hcd->flags);del_timer_sync (&hcd->rh_timer); +if (xhci->quirks &XHCI_SUSPEND_DELAY ) +usleep_range (1000 ,1500 ); +spin_lock_irq (&xhci->lock);clear_bit (HCD_FLAG_HW_ACCESSIBLE , &hcd->flags);clear_bit (HCD_FLAG_HW_ACCESSIBLE , &xhci->shared_hcd->flags);
drivers/usb/host/xhci.h +1 -0
@@ -1571,6 +1571,7 @@ struct xhci_hcd {#define XHCI_MISSING_CAS (1 << 24)#define XHCI_U2_DISABLE_WAKE (1 << 27)#define XHCI_ASMEDIA_MODIFY_FLOWCONTROL (1 << 28) +#define XHCI_SUSPEND_DELAY (1 << 30)unsigned int num_active_eps;unsigned int limit_active_eps;/* There are two roothubs to keep track of bus suspend info for */
PATCH 341/410 RDMA/mlx5: Fix integer overflow while resizing CQ
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
commit 28e9091e3119933c38933cb8fc48d5618eb784c8 upstream.
The user can provide very large cqe_size which will cause to integer overflow as it can be seen in the following UBSAN warning:
=======================================================================
UBSAN: Undefined behaviour in drivers/infiniband/hw/mlx5/cq.c:1192:53 signed integer overflow: 64870 * 65536 cannot be represented in type 'int' CPU: 0 PID: 267 Comm: syzkaller605279 Not tainted 4.15.0+ #90 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.7.5-0-ge51488c-20140602_164612-nilsson.home.kraxel.org 04/01/2014 Call Trace: dump_stack+0xde/0x164 ? dma_virt_map_sg+0x22c/0x22c ubsan_epilogue+0xe/0x81 handle_overflow+0x1f3/0x251 ? __ubsan_handle_negate_overflow+0x19b/0x19b ? lock_acquire+0x440/0x440 mlx5_ib_resize_cq+0x17e7/0x1e40 ? cyc2ns_read_end+0x10/0x10 ? native_read_msr_safe+0x6c/0x9b ? cyc2ns_read_end+0x10/0x10 ? mlx5_ib_modify_cq+0x220/0x220 ? sched_clock_cpu+0x18/0x200 ? lookup_get_idr_uobject+0x200/0x200 ? rdma_lookup_get_uobject+0x145/0x2f0 ib_uverbs_resize_cq+0x207/0x3e0 ? ib_uverbs_ex_create_cq+0x250/0x250 ib_uverbs_write+0x7f9/0xef0 ? cyc2ns_read_end+0x10/0x10 ? print_irqtrace_events+0x280/0x280 ? ib_uverbs_ex_create_cq+0x250/0x250 ? uverbs_devnode+0x110/0x110 ? sched_clock_cpu+0x18/0x200 ? do_raw_spin_trylock+0x100/0x100 ? __lru_cache_add+0x16e/0x290 __vfs_write+0x10d/0x700 ? uverbs_devnode+0x110/0x110 ? kernel_read+0x170/0x170 ? sched_clock_cpu+0x18/0x200 ? security_file_permission+0x93/0x260 vfs_write+0x1b0/0x550 SyS_write+0xc7/0x1a0 ? SyS_read+0x1a0/0x1a0 ? trace_hardirqs_on_thunk+0x1a/0x1c entry_SYSCALL_64_fastpath+0x1e/0x8b RIP: 0033:0x433549 RSP: 002b:00007ffe63bd1ea8 EFLAGS: 00000217 =======================================================================
--- drivers/infiniband/hw/mlx5/cq.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/cq.c +6 -1
@@ -956,7 +956,12 @@ static int resize_user(struct mlx5_ib_deif (ucmd.reserved0 || ucmd.reserved1)return -EINVAL ; - umem =ib_umem_get (context, ucmd.buf_addr, entries * ucmd.cqe_size, +/* check multiplication overflow */ +if (ucmd.cqe_size &&SIZE_MAX / ucmd.cqe_size <= entries -1 ) +return -EINVAL ; + + umem =ib_umem_get (context, ucmd.buf_addr, + (size_t )ucmd.cqe_size * entries,IB_ACCESS_LOCAL_WRITE ,1 );if (IS_ERR (umem)) { err =PTR_ERR (umem);
PATCH 342/410 ALSA: seq: Fix possible UAF in snd_seq_check_queue()
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit d0f833065221cbfcbadf19fd4102bcfa9330006a upstream.
Although we've covered the races between concurrent write() and ioctl() in the previous patch series, there is still a possible UAF in the following scenario:
A: user client closed B: timer irq
-> snd_seq_release() -> snd_seq_timer_interrupt()
-> snd_seq_free_client() -> snd_seq_check_queue()
-> cell = snd_seq_prioq_cell_peek()
-> snd_seq_prioq_leave()
.... removing all cells
-> snd_seq_pool_done()
.... vfree()
-> snd_seq_compare_tick_time(cell)
... OopsSo the problem is that a cell is peeked and accessed without any protection until it's retrieved from the queue again via snd_seq_prioq_cell_out().
This patch tries to address it, also cleans up the code by a slight refactoring. snd_seq_prioq_cell_out() now receives an extra pointer argument. When it's non-NULL, the function checks the event timestamp with the given pointer. The caller needs to pass the right reference either to snd_seq_tick or snd_seq_realtime depending on the event timestamp type.
A good news is that the above change allows us to remove the snd_seq_prioq_cell_peek(), too, thus the patch actually reduces the code size.
--- sound/core/seq/seq_prioq.c | 28 ++++++++++++++-------------- sound/core/seq/seq_prioq.h | 6 ++---- sound/core/seq/seq_queue.c | 28 +++++++++------------------- 3 files changed, 25 insertions(+), 37 deletions(-)
sound/core/seq/seq_prioq.c +14 -14
@@ -87,7 +87,7 @@ void snd_seq_prioq_delete(struct snd_seqif (f->cells >0 ) {/* drain prioQ */ while (f->cells >0 ) -snd_seq_cell_free (snd_seq_prioq_cell_out (f)); +snd_seq_cell_free (snd_seq_prioq_cell_out (f,NULL )); }kfree (f);
@@ -214,8 +214,18 @@ int snd_seq_prioq_cell_in(struct snd_seqreturn 0 ; } +/* return 1 if the current time >= event timestamp */ +static int event_is_ready (struct snd_seq_event *ev,void *current_time) +{ +if ((ev->flags &SNDRV_SEQ_TIME_STAMP_MASK ) ==SNDRV_SEQ_TIME_STAMP_TICK ) +return snd_seq_compare_tick_time (current_time, &ev->time.tick); +else +return snd_seq_compare_real_time (current_time, &ev->time.time); +} +/* dequeue cell from prioq */ -struct snd_seq_event_cell *snd_seq_prioq_cell_out (struct snd_seq_prioq *f) +struct snd_seq_event_cell *snd_seq_prioq_cell_out (struct snd_seq_prioq *f, +void *current_time) {struct snd_seq_event_cell *cell;unsigned long flags;
@@ -227,6 +237,8 @@ struct snd_seq_event_cell *snd_seq_prioqspin_lock_irqsave (&f->lock, flags); cell = f->head; +if (cell && current_time && !event_is_ready (&cell->event, current_time)) + cell =NULL ;if (cell) { f->head = cell->next;
@@ -252,18 +264,6 @@ int snd_seq_prioq_avail(struct snd_seq_preturn f->cells; } - -/* peek at cell at the head of the prioq */ -struct snd_seq_event_cell *snd_seq_prioq_cell_peek (struct snd_seq_prioq * f) -{ -if (f ==NULL ) { -pr_debug ("ALSA: seq: snd_seq_prioq_cell_in() called with NULL prioq\n" ); -return NULL ; - } -return f->head; -} - -static inline int prioq_match (struct snd_seq_event_cell *cell,int client,int timestamp) {
sound/core/seq/seq_prioq.h +2 -4
@@ -44,14 +44,12 @@ void snd_seq_prioq_delete(struct snd_seqint snd_seq_prioq_cell_in (struct snd_seq_prioq *f,struct snd_seq_event_cell *cell);/* dequeue cell from prioq */ -struct snd_seq_event_cell *snd_seq_prioq_cell_out (struct snd_seq_prioq *f); +struct snd_seq_event_cell *snd_seq_prioq_cell_out (struct snd_seq_prioq *f, +void *current_time);/* return number of events available in prioq */ int snd_seq_prioq_avail (struct snd_seq_prioq *f); -/* peek at cell at the head of the prioq */ -struct snd_seq_event_cell *snd_seq_prioq_cell_peek (struct snd_seq_prioq *f); -/* client left queue */ void snd_seq_prioq_leave (struct snd_seq_prioq *f,int client,int timestamp);
sound/core/seq/seq_queue.c +9 -19
@@ -273,30 +273,20 @@ void snd_seq_check_queue(struct snd_seq_ __again:/* Process tick queue... */ -while ((cell =snd_seq_prioq_cell_peek (q->tickq)) !=NULL ) { -if (snd_seq_compare_tick_time (&q->timer->tick.cur_tick, - &cell->event.time.tick)) { - cell =snd_seq_prioq_cell_out (q->tickq); -if (cell) -snd_seq_dispatch_event (cell, atomic, hop); - }else { -/* event remains in the queue */ +for (;;) { + cell =snd_seq_prioq_cell_out (q->tickq, + &q->timer->tick.cur_tick); +if (!cell)break ; - } +snd_seq_dispatch_event (cell, atomic, hop); } -/* Process time queue... */ -while ((cell =snd_seq_prioq_cell_peek (q->timeq)) !=NULL ) { -if (snd_seq_compare_real_time (&q->timer->cur_time, - &cell->event.time.time)) { - cell =snd_seq_prioq_cell_out (q->timeq); -if (cell) -snd_seq_dispatch_event (cell, atomic, hop); - }else { -/* event remains in the queue */ +for (;;) { + cell =snd_seq_prioq_cell_out (q->timeq, &q->timer->cur_time); +if (!cell)break ; - } +snd_seq_dispatch_event (cell, atomic, hop); }/* free lock */
PATCH 343/410 ALSA: seq: Clear client entry before deleting else at closing
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit a2ff19f7b70118ced291a28d5313469914de451b upstream.
When releasing a client, we need to clear the clienttab[] entry at first, then call snd_seq_queue_client_leave(). Otherwise, the in-flight cell in the queue might be picked up by the timer interrupt via snd_seq_check_queue() before calling snd_seq_queue_client_leave(), and it's delivered to another queue while the client is clearing queues. This may eventually result in an uncleared cell remaining in a queue, and the later snd_seq_pool_delete() may need to wait for a long time until the event gets really processed.
By moving the clienttab[] clearance at the beginning of release, any event delivery of a cell belonging to this client will fail at a later point, since snd_seq_client_ptr() returns NULL. Thus the cell that was picked up by the timer interrupt will be returned immediately without further delivery, and the long stall of snd_seq_delete_pool() can be avoided, too.
--- sound/core/seq/seq_clientmgr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/core/seq/seq_clientmgr.c +2 -2
@@ -270,12 +270,12 @@ static int seq_free_client1(struct snd_sif (!client)return 0 ; -snd_seq_delete_all_ports (client); -snd_seq_queue_client_leave (client->number);spin_lock_irqsave (&clients_lock, flags); clienttablock[client->number] =1 ; clienttab[client->number] =NULL ;spin_unlock_irqrestore (&clients_lock, flags); +snd_seq_delete_all_ports (client); +snd_seq_queue_client_leave (client->number);snd_use_lock_sync (&client->use_lock);snd_seq_queue_client_termination (client->number);if (client->pool)
PATCH 344/410 netfilter: bridge: ebt_among: add missing match size checks
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
commit c4585a2823edf4d1326da44d1524ecbfda26bb37 upstream.
ebt_among is special, it has a dynamic match size and is exempt from the central size checks.
Therefore it must check that the size of the match structure provided from userspace is sane by making sure em->match_size is at least the minimum size of the expected structure.
The module has such a check, but its only done after accessing a structure that might be out of bounds.
tested with: ebtables -A INPUT ... \
--among-dst fe:fe:fe:fe:fe:fe
--among-dst fe:fe:fe:fe:fe:fe --among-src fe:fe:fe:fe:ff:f,fe:fe:fe:fe:fe:fb,fe:fe:fe:fe:fc:fd,fe:fe:fe:fe:fe:fd,fe:fe:fe:fe:fe:fe --among-src fe:fe:fe:fe:ff:f,fe:fe:fe:fe:fe:fa,fe:fe:fe:fe:fe:fd,fe:fe:fe:fe:fe:fe,fe:fe:fe:fe:fe:fe
--- net/bridge/netfilter/ebt_among.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
net/bridge/netfilter/ebt_among.c +19 -2
@@ -172,18 +172,35 @@ ebt_among_mt(const struct sk_buff *skb,return true; } +static bool poolsize_invalid (const struct ebt_mac_wormhash *w) +{ +return w && w->poolsize >= (INT_MAX /sizeof (struct ebt_mac_wormhash_tuple )); +} +static int ebt_among_mt_check (const struct xt_mtchk_param *par) {const struct ebt_among_info *info = par->matchinfo;const struct ebt_entry_match *em = container_of(par->matchinfo, const struct ebt_entry_match, data); -int expected_length =sizeof (struct ebt_among_info ); +unsigned int expected_length =sizeof (struct ebt_among_info );const struct ebt_mac_wormhash *wh_dst, *wh_src;int err; +if (expected_length > em->match_size) +return -EINVAL ; + wh_dst =ebt_among_wh_dst (info); - wh_src =ebt_among_wh_src (info); +if (poolsize_invalid (wh_dst)) +return -EINVAL ; + expected_length +=ebt_mac_wormhash_size (wh_dst); +if (expected_length > em->match_size) +return -EINVAL ; + + wh_src =ebt_among_wh_src (info); +if (poolsize_invalid (wh_src)) +return -EINVAL ; + expected_length +=ebt_mac_wormhash_size (wh_src);if (em->match_size !=EBT_ALIGN (expected_length)) {
PATCH 345/410 netfilter: bridge: ebt_among: add more missing match size checks
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
commit c8d70a700a5b486bfa8e5a7d33d805389f6e59f9 upstream.
ebt_among is special, it has a dynamic match size and is exempt from the central size checks.
commit c4585a2823edf ("bridge: ebt_among: add missing match size checks") added validation for pool size, but missed fact that the macros ebt_among_wh_src/dst can already return out-of-bound result because they do not check value of wh_src/dst_ofs (an offset) vs. the size of the match that userspace gave to us.
v2:
check that offset has correct alignment.
Paolo Abeni points out that we should also check that src/dst wormhash arrays do not overlap, and src + length lines up with start of dst (or vice versa).
v3: compact wormhash_sizes_valid() part
NB: Fixes tag is intentionally wrong, this bug exists from day one when match was added for 2.6 kernel. Tag is there so stable maintainers will notice this one too.
Tested with same rules from the earlier patch.
--- net/bridge/netfilter/ebt_among.c | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
net/bridge/netfilter/ebt_among.c +34 -0
@@ -177,6 +177,28 @@ static bool poolsize_invalid(const strucreturn w && w->poolsize >= (INT_MAX /sizeof (struct ebt_mac_wormhash_tuple )); } +static bool wormhash_offset_invalid (int off,unsigned int len) +{ +if (off ==0 )/* not present */ +return false; + +if (off < (int )sizeof (struct ebt_among_info ) || + off % __alignof__(struct ebt_mac_wormhash )) +return true; + + off +=sizeof (struct ebt_mac_wormhash ); + +return off > len; +} + +static bool wormhash_sizes_valid (const struct ebt_mac_wormhash *wh,int a,int b) +{ +if (a ==0 ) + a =sizeof (struct ebt_among_info ); + +return ebt_mac_wormhash_size (wh) + a == b; +} +static int ebt_among_mt_check (const struct xt_mtchk_param *par) {const struct ebt_among_info *info = par->matchinfo;
@@ -189,6 +211,10 @@ static int ebt_among_mt_check(const struif (expected_length > em->match_size)return -EINVAL ; +if (wormhash_offset_invalid (info->wh_dst_ofs, em->match_size) || +wormhash_offset_invalid (info->wh_src_ofs, em->match_size)) +return -EINVAL ; + wh_dst =ebt_among_wh_dst (info);if (poolsize_invalid (wh_dst))return -EINVAL ;
@@ -201,6 +227,14 @@ static int ebt_among_mt_check(const struif (poolsize_invalid (wh_src))return -EINVAL ; +if (info->wh_src_ofs < info->wh_dst_ofs) { +if (!wormhash_sizes_valid (wh_src, info->wh_src_ofs, info->wh_dst_ofs)) +return -EINVAL ; + }else { +if (!wormhash_sizes_valid (wh_dst, info->wh_dst_ofs, info->wh_src_ofs)) +return -EINVAL ; + } + expected_length +=ebt_mac_wormhash_size (wh_src);if (em->match_size !=EBT_ALIGN (expected_length)) {
PATCH 346/410 l2tp: fix races with ipv4-mapped ipv6 addresses
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
commit b954f94023dcc61388c8384f0f14eb8e42c863c5 upstream.
The l2tp_tunnel_create() function checks for v4mapped ipv6 sockets and cache that flag, so that l2tp core code can reusing it at xmit time.
If the socket is provided by the userspace, the connection status of the tunnel sockets can change between the tunnel creation and the xmit call, so that syzbot is able to trigger the following splat:
BUG: KASAN: use-after-free in ip6_dst_idev include/net/ip6_fib.h:192 [inline] BUG: KASAN: use-after-free in ip6_xmit+0x1f76/0x2260 net/ipv6/ip6_output.c:264 Read of size 8 at addr ffff8801bd949318 by task syz-executor4/23448 CPU: 0 PID: 23448 Comm: syz-executor4 Not tainted 4.16.0-rc4+ #65 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:17 [inline] dump_stack+0x194/0x24d lib/dump_stack.c:53 print_address_description+0x73/0x250 mm/kasan/report.c:256 kasan_report_error mm/kasan/report.c:354 [inline] kasan_report+0x23c/0x360 mm/kasan/report.c:412 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433 ip6_dst_idev include/net/ip6_fib.h:192 [inline] ip6_xmit+0x1f76/0x2260 net/ipv6/ip6_output.c:264 inet6_csk_xmit+0x2fc/0x580 net/ipv6/inet6_connection_sock.c:139 l2tp_xmit_core net/l2tp/l2tp_core.c:1053 [inline] l2tp_xmit_skb+0x105f/0x1410 net/l2tp/l2tp_core.c:1148 pppol2tp_sendmsg+0x470/0x670 net/l2tp/l2tp_ppp.c:341 sock_sendmsg_nosec net/socket.c:630 [inline] sock_sendmsg+0xca/0x110 net/socket.c:640 ___sys_sendmsg+0x767/0x8b0 net/socket.c:2046 __sys_sendmsg+0xe5/0x210 net/socket.c:2080 SYSC_sendmsg net/socket.c:2091 [inline] SyS_sendmsg+0x2d/0x50 net/socket.c:2087 do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287 entry_SYSCALL_64_after_hwframe+0x42/0xb7 RIP: 0033:0x453e69 RSP: 002b:00007f819593cc68 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00007f819593d6d4 RCX: 0000000000453e69 RDX: 0000000000000081 RSI: 000000002037ffc8 RDI: 0000000000000004 RBP: 000000000072bea0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff R13: 00000000000004c3 R14: 00000000006f72e8 R15: 0000000000000000
This change addresses the issues:
* explicitly checking for TCP_ESTABLISHED for user space provided sockets
* dropping the v4mapped flag usage - it can become outdated - and explicitly invoking ipv6_addr_v4mapped() instead
The issue is apparently there since ancient times.
v1 -> v2: (many thanks to Guillaume)
- with csum issue introduced in v1
- replace pr_err with pr_debug
- fix build issue with IPV6 disabled
- move l2tp_sk_is_v4mapped in l2tp_core.c
v2 -> v3:
- don't update inet_daddr for v4mapped address, unneeded
- drop rendundant check at creation time
[bwh: Backported to 3.16: Change an additional test of tunnel->v4mapped to use
l2tp_sk_is_v6()]
---
net/l2tp/l2tp_core.c +19 -21
@@ -110,6 +110,13 @@ struct l2tp_net {spinlock_t l2tp_session_hlist_lock; }; +#if IS_ENABLED (CONFIG_IPV6 ) +static bool l2tp_sk_is_v6 (struct sock *sk) +{ +return sk->sk_family ==PF_INET6 && + !ipv6_addr_v4mapped (&sk->sk_v6_daddr); +} +#endif static inline struct l2tp_tunnel *l2tp_tunnel (struct sock *sk) {
@@ -1134,7 +1141,7 @@ static int l2tp_xmit_core(struct l2tp_se/* Queue the packet to IP for output */ skb->ignore_df =1 ;#if IS_ENABLED (CONFIG_IPV6 ) -if (tunnel->sock->sk_family ==PF_INET6 && !tunnel->v4mapped) +if (l2tp_sk_is_v6 (tunnel->sock)) error =inet6_csk_xmit (tunnel->sock, skb,NULL ); else#endif
@@ -1197,6 +1204,15 @@ int l2tp_xmit_skb(struct l2tp_session *s goto out_unlock; } +/* The user-space may change the connection status for the user-space +* provided socket at run time: we must check it under the socket lock +*/ +if (tunnel->fd >=0 && sk->sk_state !=TCP_ESTABLISHED ) { +kfree_skb (skb); + ret =NET_XMIT_DROP ; + goto out_unlock; + } +/* Get routing info from the tunnel socket */ skb_dst_drop (skb);skb_dst_set (skb,dst_clone (__sk_dst_check (sk,0 )));
@@ -1216,7 +1232,7 @@ int l2tp_xmit_skb(struct l2tp_session *s/* Calculate UDP checksum if configured to do so */ #if IS_ENABLED (CONFIG_IPV6 ) -if (sk->sk_family ==PF_INET6 && !tunnel->v4mapped) +if (l2tp_sk_is_v6 (sk))udp6_set_csum (udp_get_no_check6_tx (sk), skb, &inet6_sk (sk)->saddr, &sk->sk_v6_daddr, udp_len);
@@ -1635,24 +1651,6 @@ int l2tp_tunnel_create(struct net *net,if (cfg !=NULL ) tunnel->debug = cfg->debug; -#if IS_ENABLED (CONFIG_IPV6 ) -if (sk->sk_family ==PF_INET6 ) { -struct ipv6_pinfo *np =inet6_sk (sk); - -if (ipv6_addr_v4mapped (&np->saddr) && -ipv6_addr_v4mapped (&sk->sk_v6_daddr)) { -struct inet_sock *inet =inet_sk (sk); - - tunnel->v4mapped = true; - inet->inet_saddr = np->saddr.s6_addr32[3 ]; - inet->inet_rcv_saddr = sk->sk_v6_rcv_saddr.s6_addr32[3 ]; - inet->inet_daddr = sk->sk_v6_daddr.s6_addr32[3 ]; - }else { - tunnel->v4mapped = false; - } - } -#endif -/* Mark socket as an encapsulation socket. See net/ipv4/udp.c */ tunnel->encap = encap;if (encap ==L2TP_ENCAPTYPE_UDP ) {
@@ -1661,7 +1659,7 @@ int l2tp_tunnel_create(struct net *net,udp_sk (sk)->encap_rcv = l2tp_udp_encap_recv;udp_sk (sk)->encap_destroy = l2tp_udp_encap_destroy;#if IS_ENABLED (CONFIG_IPV6 ) -if (sk->sk_family ==PF_INET6 && !tunnel->v4mapped) +if (l2tp_sk_is_v6 (sk))udpv6_encap_enable (); else#endif
net/l2tp/l2tp_core.h +0 -3
@@ -203,9 +203,6 @@ struct l2tp_tunnel {struct sock *sock;/* Parent socket */ int fd;/* Parent fd, if tunnel socket * was created by userspace */ -#if IS_ENABLED (CONFIG_IPV6 ) -bool v4mapped; -#endif struct work_struct del_work;
PATCH 347/410 IB/mlx5: Fix integer overflows in mlx5_ib_create_srq
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Boris Pismenny <[email protected]>
commit c2b37f76485f073f020e60b5954b6dc4e55f693c upstream.
This patch validates user provided input to prevent integer overflow due to integer manipulation in the mlx5_ib_create_srq function.
--- drivers/infiniband/hw/mlx5/srq.c | 15 +++++++++------ include/linux/mlx5/driver.h | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-)
drivers/infiniband/hw/mlx5/srq.c +9 -6
@@ -234,8 +234,8 @@ struct ib_srq *mlx5_ib_create_srq(struct {struct mlx5_ib_dev *dev =to_mdev (pd->device);struct mlx5_ib_srq *srq; -int desc_size; -int buf_size; +size_t desc_size; +size_t buf_size;int err;struct mlx5_create_srq_mbox_in *uninitialized_var (in );int uninitialized_var (inlen );
@@ -261,15 +261,18 @@ struct ib_srq *mlx5_ib_create_srq(struct desc_size =sizeof (struct mlx5_wqe_srq_next_seg ) + srq->msrq.max_gs *sizeof (struct mlx5_wqe_data_seg ); +if (desc_size ==0 || srq->msrq.max_gs > desc_size) +return ERR_PTR (-EINVAL ); desc_size =roundup_pow_of_two (desc_size); - desc_size =max_t (int,32 , desc_size); + desc_size =max_t (size_t,32 , desc_size); +if (desc_size <sizeof (struct mlx5_wqe_srq_next_seg )) +return ERR_PTR (-EINVAL ); srq->msrq.max_avail_gather = (desc_size -sizeof (struct mlx5_wqe_srq_next_seg )) /sizeof (struct mlx5_wqe_data_seg ); srq->msrq.wqe_shift =ilog2 (desc_size); buf_size = srq->msrq.max * desc_size; -mlx5_ib_dbg (dev,"desc_size 0x%x, req wr 0x%x, srq size 0x%x, max_gs 0x%x, max_avail_gather 0x%x\n" , - desc_size, init_attr->attr.max_wr, srq->msrq.max, srq->msrq.max_gs, - srq->msrq.max_avail_gather); +if (buf_size < desc_size) +return ERR_PTR (-EINVAL );if (pd->uobject) err =create_srq_user (pd, srq, &in, udata, buf_size, &inlen);
include/linux/mlx5/driver.h +2 -2
@@ -432,8 +432,8 @@ struct mlx5_core_mr {struct mlx5_core_srq {u32 srqn;int max; -int max_gs; -int max_avail_gather; +size_t max_gs; +size_t max_avail_gather;int wqe_shift;void (*event) (struct mlx5_core_srq *,enum mlx5_event );
PATCH 348/410 can: cc770: Fix stalls on rt-linux, remove redundant IRQ ack
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Andri Yngvason <[email protected]>
commit f4353daf4905c0099fd25fa742e2ffd4a4bab26a upstream.
This has been reported to cause stalls on rt-linux.
--- drivers/net/can/cc770/cc770.c | 15 --------------- 1 file changed, 15 deletions(-)
drivers/net/can/cc770/cc770.c +0 -15
@@ -447,15 +447,6 @@ static netdev_tx_t cc770_start_xmit(stru stats->tx_bytes += dlc; - -/* -* HM: We had some cases of repeated IRQs so make sure the -* INT is acknowledged I know it's already further up, but -* doing again fixed the issue -*/ -cc770_write_reg (priv, msgobj[mo].ctrl0, -MSGVAL_UNC |TXIE_UNC |RXIE_UNC |INTPND_RES ); -return NETDEV_TX_OK ; }
@@ -683,12 +674,6 @@ static void cc770_tx_interrupt(struct ne/* Nothing more to send, switch off interrupts */ cc770_write_reg (priv, msgobj[mo].ctrl0,MSGVAL_RES |TXIE_RES |RXIE_RES |INTPND_RES ); -/* -* We had some cases of repeated IRQ so make sure the -* INT is acknowledged -*/ -cc770_write_reg (priv, msgobj[mo].ctrl0, -MSGVAL_UNC |TXIE_UNC |RXIE_UNC |INTPND_RES ); stats->tx_packets++;can_get_echo_skb (dev,0 );
PATCH 349/410 can: cc770: Fix queue stall & dropped RTR reply
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Andri Yngvason <[email protected]>
commit 746201235b3f876792099079f4c6fea941d76183 upstream.
While waiting for the TX object to send an RTR, an external message with a matching id can overwrite the TX data. In this case we must call the rx routine and then try transmitting the message that was overwritten again.
The queue was being stalled because the RX event did not generate an interrupt to wake up the queue again and the TX event did not happen because the TXRQST flag is reset by the chip when new data is received.
According to the CC770 datasheet the id of a message object should not be changed while the MSGVAL bit is set. This has been fixed by resetting the MSGVAL bit before modifying the object in the transmit function and setting it after. It is not enough to set & reset CPUUPD.
It is important to keep the MSGVAL bit reset while the message object is being modified. Otherwise, during RTR transmission, a frame with matching id could trigger an rx-interrupt, which would cause a race condition between the interrupt routine and the transmit function.
--- drivers/net/can/cc770/cc770.c | 94 ++++++++++++++++++++++++----------- drivers/net/can/cc770/cc770.h | 2 + 2 files changed, 68 insertions(+), 28 deletions(-)
drivers/net/can/cc770/cc770.c +66 -28
@@ -390,37 +390,23 @@ static int cc770_get_berr_counter(constreturn 0 ; } -static netdev_tx_t cc770_start_xmit (struct sk_buff *skb,struct net_device *dev) +static void cc770_tx (struct net_device *dev,int mo) {struct cc770_priv *priv =netdev_priv (dev); -struct net_device_stats *stats = &dev->stats; -struct can_frame *cf = (struct can_frame *)skb->data; -unsigned int mo =obj2msgobj (CC770_OBJ_TX ); +struct can_frame *cf = (struct can_frame *)priv->tx_skb->data;u8 dlc, rtr;u32 id;int i; -if (can_dropped_invalid_skb (dev, skb)) -return NETDEV_TX_OK ; - -if ((cc770_read_reg (priv, - msgobj[mo].ctrl1) &TXRQST_UNC ) ==TXRQST_SET ) { -netdev_err (dev,"TX register is still occupied!\n" ); -return NETDEV_TX_BUSY ; - } - -netif_stop_queue (dev); - dlc = cf->can_dlc; id = cf->can_id; -if (cf->can_id &CAN_RTR_FLAG ) - rtr =0 ; -else - rtr =MSGCFG_DIR ; + rtr = cf->can_id &CAN_RTR_FLAG ?0 :MSGCFG_DIR ; + +cc770_write_reg (priv, msgobj[mo].ctrl0, +MSGVAL_RES |TXIE_RES |RXIE_RES |INTPND_RES );cc770_write_reg (priv, msgobj[mo].ctrl1,RMTPND_RES |TXRQST_RES |CPUUPD_SET |NEWDAT_RES ); -cc770_write_reg (priv, msgobj[mo].ctrl0, -MSGVAL_SET |TXIE_SET |RXIE_RES |INTPND_RES ); +if (id &CAN_EFF_FLAG ) { id &=CAN_EFF_MASK ; cc770_write_reg(priv, msgobj[mo].config,
@@ -439,13 +425,30 @@ static netdev_tx_t cc770_start_xmit(strufor (i =0 ; i < dlc; i++)cc770_write_reg (priv, msgobj[mo].data[i], cf->data[i]); -/* Store echo skb before starting the transfer */ -can_put_echo_skb (skb, dev,0 ); -cc770_write_reg (priv, msgobj[mo].ctrl1, -RMTPND_RES |TXRQST_SET |CPUUPD_RES |NEWDAT_UNC ); +RMTPND_UNC |TXRQST_SET |CPUUPD_RES |NEWDAT_UNC ); +cc770_write_reg (priv, msgobj[mo].ctrl0, +MSGVAL_SET |TXIE_SET |RXIE_SET |INTPND_UNC ); +} + +static netdev_tx_t cc770_start_xmit (struct sk_buff *skb,struct net_device *dev) +{ +struct cc770_priv *priv =netdev_priv (dev); +unsigned int mo =obj2msgobj (CC770_OBJ_TX ); + +if (can_dropped_invalid_skb (dev, skb)) +return NETDEV_TX_OK ; + +netif_stop_queue (dev); + +if ((cc770_read_reg (priv, + msgobj[mo].ctrl1) &TXRQST_UNC ) ==TXRQST_SET ) { +netdev_err (dev,"TX register is still occupied!\n" ); +return NETDEV_TX_BUSY ; + } - stats->tx_bytes += dlc; + priv->tx_skb = skb; +cc770_tx (dev, mo);return NETDEV_TX_OK ; }
@@ -670,13 +673,47 @@ static void cc770_tx_interrupt(struct nestruct cc770_priv *priv =netdev_priv (dev);struct net_device_stats *stats = &dev->stats;unsigned int mo =obj2msgobj (o); +struct can_frame *cf; +u8 ctrl1; + + ctrl1 =cc770_read_reg (priv, msgobj[mo].ctrl1); -/* Nothing more to send, switch off interrupts */ cc770_write_reg (priv, msgobj[mo].ctrl0,MSGVAL_RES |TXIE_RES |RXIE_RES |INTPND_RES ); +cc770_write_reg (priv, msgobj[mo].ctrl1, +RMTPND_RES |TXRQST_RES |MSGLST_RES |NEWDAT_RES ); - stats->tx_packets++; +if (unlikely (!priv->tx_skb)) { +netdev_err (dev,"missing tx skb in tx interrupt\n" ); +return ; + } + +if (unlikely (ctrl1 &MSGLST_SET )) { + stats->rx_over_errors++; + stats->rx_errors++; + } + +/* When the CC770 is sending an RTR message and it receives a regular +* message that matches the id of the RTR message, it will overwrite the +* outgoing message in the TX register. When this happens we must +* process the received message and try to transmit the outgoing skb +* again. +*/ +if (unlikely (ctrl1 &NEWDAT_SET )) { +cc770_rx (dev, mo, ctrl1); +cc770_tx (dev, mo); +return ; + } + +can_put_echo_skb (priv->tx_skb, dev,0 );can_get_echo_skb (dev,0 ); + + cf = (struct can_frame *)priv->tx_skb->data; + stats->tx_bytes += cf->can_dlc; + stats->tx_packets++; + + priv->tx_skb =NULL ; +netif_wake_queue (dev); }
@@ -788,6 +825,7 @@ struct net_device *alloc_cc770dev(int si priv->can.do_set_bittiming = cc770_set_bittiming; priv->can.do_set_mode = cc770_set_mode; priv->can.ctrlmode_supported =CAN_CTRLMODE_3_SAMPLES ; + priv->tx_skb =NULL ;memcpy (priv->obj_flags, cc770_obj_flags,sizeof (cc770_obj_flags));
drivers/net/can/cc770/cc770.h +2 -0
@@ -193,6 +193,8 @@ struct cc770_priv {u8 cpu_interface;/* CPU interface register */ u8 clkout;/* Clock out register */ u8 bus_config;/* Bus conffiguration register */ + +struct sk_buff *tx_skb; };struct net_device *alloc_cc770dev (int sizeof_priv);
PATCH 350/410 libata: Enable queued TRIM for Samsung SSD 860
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ju Hyung Park <[email protected]>
commit ca6bfcb2f6d9deab3924bf901e73622a94900473 upstream.
Samsung explicitly states that queued TRIM is supported for Linux with 860 PRO and 860 EVO.
Make the previous blacklist to cover only 840 and 850 series.
--- drivers/ata/libata-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/ata/libata-core.c +2 -1
@@ -4237,7 +4237,8 @@ static const struct ata_blacklist_entry { "Micron_M5[15]0_*", "MU01", ATA_HORKAGE_NO_NCQ_TRIM, }, { "Crucial_CT*M550*", "MU01", ATA_HORKAGE_NO_NCQ_TRIM, }, { "Crucial_CT*MX100*", "MU01", ATA_HORKAGE_NO_NCQ_TRIM, }, - { "Samsung SSD 8*", NULL, ATA_HORKAGE_NO_NCQ_TRIM, }, + { "Samsung SSD 840*", NULL, ATA_HORKAGE_NO_NCQ_TRIM, }, + { "Samsung SSD 850*", NULL, ATA_HORKAGE_NO_NCQ_TRIM, }, { "FCCT*M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM, },/* devices that don't properly handle TRIM commands */
PATCH 351/410 route: remove unsed variable in __mkroute_input
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Masatake YAMATO <[email protected]>
commit cb1c61680d29a054b91a23c7a504cea8a72bdcff upstream.
flags local variable in __mkroute_input is not used as a variable.
--- net/ipv4/route.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/ipv4/route.c +1 -2
@@ -1587,7 +1587,6 @@ static int __mkroute_input(struct sk_bufstruct rtable *rth;int err;struct in_device *out_dev; -unsigned int flags =0 ;bool do_cache;u32 itag =0 ;
@@ -1660,7 +1659,7 @@ rt_cache: } rth->rt_genid =rt_genid_ipv4 (dev_net (rth->dst.dev)); - rth->rt_flags = flags; + rth->rt_flags =0 ; rth->rt_type = res->type; rth->rt_is_input =1 ; rth->rt_iif =0 ;
PATCH 352/410 net: Refactor rtable initialization
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: David Ahern <[email protected]>
commit d08c4f355403840fad98d9918db51a7113f38ee8 upstream.
All callers to rt_dst_alloc have nearly the same initialization following a successful allocation. Consolidate it into rt_dst_alloc.
---
net/ipv4/route.c +34 -53
@@ -1435,12 +1435,33 @@ static void rt_set_nexthop(struct rtable }static struct rtable *rt_dst_alloc (struct net_device *dev, +unsigned int flags,u16 type,bool nopolicy,bool noxfrm,bool will_cache) { -return dst_alloc (&ipv4_dst_ops, dev,1 ,DST_OBSOLETE_FORCE_CHK , - (will_cache ?0 : (DST_HOST |DST_NOCACHE )) | - (nopolicy ?DST_NOPOLICY :0 ) | - (noxfrm ?DST_NOXFRM :0 )); +struct rtable *rt; + + rt =dst_alloc (&ipv4_dst_ops, dev,1 ,DST_OBSOLETE_FORCE_CHK , + (will_cache ?0 : (DST_HOST |DST_NOCACHE )) | + (nopolicy ?DST_NOPOLICY :0 ) | + (noxfrm ?DST_NOXFRM :0 )); + +if (rt) { + rt->rt_genid =rt_genid_ipv4 (dev_net (dev)); + rt->rt_flags = flags; + rt->rt_type = type; + rt->rt_is_input =0 ; + rt->rt_iif =0 ; + rt->rt_pmtu =0 ; + rt->rt_gateway =0 ; + rt->rt_uses_gateway =0 ; +INIT_LIST_HEAD (&rt->rt_uncached); + + rt->dst.output = ip_output; +if (flags &RTCF_LOCAL ) + rt->dst.input = ip_local_deliver; + } + +return rt; }/* called in rcu_read_lock() section */
@@ -1480,6 +1501,7 @@ static int ip_route_input_mc(struct sk_b {struct in_device *in_dev =__in_dev_get_rcu (dev);struct rtable *rth; +unsigned int flags =RTCF_MULTICAST ;u32 itag =0 ;int err;
@@ -1487,7 +1509,10 @@ static int ip_route_input_mc(struct sk_bif (err)return err; - rth =rt_dst_alloc (dev_net (dev)->loopback_dev, +if (our) + flags |=RTCF_LOCAL ; + + rth =rt_dst_alloc (dev_net (dev)->loopback_dev, flags,RTN_MULTICAST ,IN_DEV_CONF_GET (in_dev,NOPOLICY ), false, false);if (!rth)return -ENOBUFS ;
@@ -1496,20 +1521,7 @@ static int ip_route_input_mc(struct sk_b rth->dst.tclassid = itag;#endif rth->dst.output = ip_rt_bug; - - rth->rt_genid =rt_genid_ipv4 (dev_net (dev)); - rth->rt_flags =RTCF_MULTICAST ; - rth->rt_type =RTN_MULTICAST ; rth->rt_is_input=1 ; - rth->rt_iif =0 ; - rth->rt_pmtu =0 ; - rth->rt_gateway =0 ; - rth->rt_uses_gateway =0 ; -INIT_LIST_HEAD (&rth->rt_uncached); -if (our) { - rth->dst.input= ip_local_deliver; - rth->rt_flags |=RTCF_LOCAL ; - }#ifdef CONFIG_IP_MROUTE if (!ipv4_is_local_multicast (daddr) &&IN_DEV_MFORWARD (in_dev))
@@ -1650,7 +1662,7 @@ rt_cache: } } - rth =rt_dst_alloc (out_dev->dev, + rth =rt_dst_alloc (out_dev->dev,0 , res->type,IN_DEV_CONF_GET (in_dev,NOPOLICY ),IN_DEV_CONF_GET (out_dev,NOXFRM ), do_cache);if (!rth) {
@@ -1658,19 +1670,10 @@ rt_cache: goto cleanup; } - rth->rt_genid =rt_genid_ipv4 (dev_net (rth->dst.dev)); - rth->rt_flags =0 ; - rth->rt_type = res->type; rth->rt_is_input =1 ; - rth->rt_iif =0 ; - rth->rt_pmtu =0 ; - rth->rt_gateway =0 ; - rth->rt_uses_gateway =0 ; -INIT_LIST_HEAD (&rth->rt_uncached);RT_CACHE_STAT_INC (in_slow_tot); rth->dst.input = ip_forward; - rth->dst.output = ip_output;rt_set_nexthop (rth, daddr, res, fnhe, res->fi, res->type, itag);skb_dst_set (skb, &rth->dst);
@@ -1821,26 +1824,17 @@ local_input: } } - rth =rt_dst_alloc (net->loopback_dev, + rth =rt_dst_alloc (net->loopback_dev, flags |RTCF_LOCAL , res.type,IN_DEV_CONF_GET (in_dev,NOPOLICY ), false, do_cache);if (!rth) goto e_nobufs; - rth->dst.input= ip_local_deliver; rth->dst.output= ip_rt_bug;#ifdef CONFIG_IP_ROUTE_CLASSID rth->dst.tclassid = itag;#endif - - rth->rt_genid =rt_genid_ipv4 (net); - rth->rt_flags = flags|RTCF_LOCAL ; - rth->rt_type = res.type; rth->rt_is_input =1 ; - rth->rt_iif =0 ; - rth->rt_pmtu =0 ; - rth->rt_gateway =0 ; - rth->rt_uses_gateway =0 ; -INIT_LIST_HEAD (&rth->rt_uncached); +RT_CACHE_STAT_INC (in_slow_tot);if (res.type ==RTN_UNREACHABLE ) { rth->dst.input= ip_error;
@@ -2037,29 +2031,16 @@ rt_cache: } add: - rth =rt_dst_alloc (dev_out, + rth =rt_dst_alloc (dev_out, flags, type,IN_DEV_CONF_GET (in_dev,NOPOLICY ),IN_DEV_CONF_GET (in_dev,NOXFRM ), do_cache);if (!rth)return ERR_PTR (-ENOBUFS ); - rth->dst.output = ip_output; - - rth->rt_genid =rt_genid_ipv4 (dev_net (dev_out)); - rth->rt_flags = flags; - rth->rt_type = type; - rth->rt_is_input =0 ; rth->rt_iif = orig_oif ? :0 ; - rth->rt_pmtu =0 ; - rth->rt_gateway =0 ; - rth->rt_uses_gateway =0 ; -INIT_LIST_HEAD (&rth->rt_uncached); -RT_CACHE_STAT_INC (out_slow_tot); -if (flags &RTCF_LOCAL ) - rth->dst.input = ip_local_deliver;if (flags & (RTCF_BROADCAST |RTCF_MULTICAST )) {if (flags &RTCF_LOCAL && !(dev_out->flags &IFF_LOOPBACK )) {
PATCH 353/410 ipv4: lock mtu in fnhe when received PMTU < net.ipv4.route.min_pmtu
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
commit d52e5a7e7ca49457dd31fc8b42fb7c0d58a31221 upstream.
Prior to the rework of PMTU information storage in commit 2c8cec5c10bc ("ipv4: Cache learned PMTU information in inetpeer."), when a PMTU event advertising a PMTU smaller than net.ipv4.route.min_pmtu was received, we would disable setting the DF flag on packets by locking the MTU metric, and set the PMTU to net.ipv4.route.min_pmtu.
Since then, we don't disable DF, and set PMTU to net.ipv4.route.min_pmtu, so the intermediate router that has this link with a small MTU will have to drop the packets.
This patch reestablishes pre-2.6.39 behavior by splitting rtable->rt_pmtu into a bitfield with rt_mtu_locked and rt_pmtu. rt_mtu_locked indicates that we shouldn't set the DF bit on that path, and is checked in ip_dont_fragment().
One possible workaround is to set net.ipv4.route.min_pmtu to a value low enough to accommodate the lowest MTU encountered.
--- include/net/ip.h | 11 +++++++++-- include/net/ip_fib.h | 1 + include/net/route.h | 3 ++- net/ipv4/route.c | 26 +++++++++++++++++++------- net/ipv4/xfrm4_policy.c | 1 + 5 files changed, 32 insertions(+), 10 deletions(-)
include/net/ip.h +9 -2
@@ -263,12 +263,19 @@ int ip_decrease_ttl(struct iphdr *iph)return --iph->ttl; } +static inline int ip_mtu_locked (const struct dst_entry *dst) +{ +const struct rtable *rt = (const struct rtable *)dst; + +return rt->rt_mtu_locked ||dst_metric_locked (dst,RTAX_MTU ); +} +static inline int ip_dont_fragment (struct sock *sk,struct dst_entry *dst) {return inet_sk (sk)->pmtudisc ==IP_PMTUDISC_DO || (inet_sk (sk)->pmtudisc ==IP_PMTUDISC_WANT && - !(dst_metric_locked (dst,RTAX_MTU ))); + !ip_mtu_locked (dst)); }static inline bool ip_sk_accept_pmtu (const struct sock *sk)
@@ -294,7 +301,7 @@ static inline unsigned int ip_dst_mtu_mastruct net *net =dev_net (dst->dev);if (net->ipv4.sysctl_ip_fwd_use_pmtu || -dst_metric_locked (dst,RTAX_MTU ) || +ip_mtu_locked (dst) || !forwarding)return dst_mtu (dst);
include/net/ip_fib.h +1 -0
@@ -54,6 +54,7 @@ struct fib_nh_exception {int fnhe_genid;__be32 fnhe_daddr;u32 fnhe_pmtu; +bool fnhe_mtu_locked;__be32 fnhe_gw;unsigned long fnhe_expires;struct rtable __rcu *fnhe_rth_input;
include/net/route.h +2 -1
@@ -61,7 +61,8 @@ struct rtable {__be32 rt_gateway;/* Miscellaneous cached information */ -u32 rt_pmtu; + u32 rt_mtu_locked:1, + rt_pmtu:31;struct list_head rt_uncached; };
net/ipv4/route.c +19 -7
@@ -608,6 +608,7 @@ static inline u32 fnhe_hashfun(__be32 dastatic void fill_route_from_fnhe (struct rtable *rt,struct fib_nh_exception *fnhe) { rt->rt_pmtu = fnhe->fnhe_pmtu; + rt->rt_mtu_locked = fnhe->fnhe_mtu_locked; rt->dst.expires = fnhe->fnhe_expires;if (fnhe->fnhe_gw) {
@@ -618,7 +619,7 @@ static void fill_route_from_fnhe(struct }static void update_or_create_fnhe (struct fib_nh *nh,__be32 daddr,__be32 gw, -u32 pmtu,unsigned long expires) +u32 pmtu,bool lock,unsigned long expires) {struct fnhe_hash_bucket *hash;struct fib_nh_exception *fnhe;
@@ -655,8 +656,10 @@ static void update_or_create_fnhe(struct fnhe->fnhe_genid = genid;if (gw) fnhe->fnhe_gw = gw; -if (pmtu) +if (pmtu) { fnhe->fnhe_pmtu = pmtu; + fnhe->fnhe_mtu_locked = lock; + } fnhe->fnhe_expires =max (1UL , expires);/* Update all cached dsts too */ rt =rcu_dereference (fnhe->fnhe_rth_input);
@@ -680,6 +683,7 @@ static void update_or_create_fnhe(struct fnhe->fnhe_daddr = daddr; fnhe->fnhe_gw = gw; fnhe->fnhe_pmtu = pmtu; + fnhe->fnhe_mtu_locked = lock; fnhe->fnhe_expires = expires;/* Exception created; mark the cached routes for the nexthop
@@ -761,7 +765,8 @@ static void __ip_do_redirect(struct rtabstruct fib_nh *nh = &FIB_RES_NH (res);update_or_create_fnhe (nh, fl4->daddr, new_gw, -0 , jiffies + ip_rt_gc_timeout); +0 , false, + jiffies + ip_rt_gc_timeout); }if (kill_route) rt->dst.obsolete =DST_OBSOLETE_KILL ;
@@ -970,15 +975,18 @@ static void __ip_rt_update_pmtu(struct r {struct dst_entry *dst = &rt->dst;struct fib_result res; +bool lock = false; -if (dst_metric_locked (dst,RTAX_MTU )) +if (ip_mtu_locked (dst))return ;if (dst->dev->mtu < mtu)return ; -if (mtu < ip_rt_min_pmtu) +if (mtu < ip_rt_min_pmtu) { + lock = true; mtu = ip_rt_min_pmtu; + }if (rt->rt_pmtu == mtu &&time_before (jiffies, dst->expires - ip_rt_mtu_expires /2 ))
@@ -988,7 +996,7 @@ static void __ip_rt_update_pmtu(struct rif (fib_lookup (dev_net (dst->dev), fl4, &res) ==0 ) {struct fib_nh *nh = &FIB_RES_NH (res); -update_or_create_fnhe (nh, fl4->daddr,0 , mtu, +update_or_create_fnhe (nh, fl4->daddr,0 , mtu, lock, jiffies + ip_rt_mtu_expires); }rcu_read_unlock ();
@@ -1243,7 +1251,7 @@ static unsigned int ipv4_mtu(const struc mtu = dst->dev->mtu; -if (unlikely (dst_metric_locked (dst,RTAX_MTU ))) { +if (unlikely (ip_mtu_locked (dst))) {if (rt->rt_uses_gateway && mtu >576 ) mtu =576 ; }
@@ -1452,6 +1460,7 @@ static struct rtable *rt_dst_alloc(struc rt->rt_is_input =0 ; rt->rt_iif =0 ; rt->rt_pmtu =0 ; + rt->rt_mtu_locked =0 ; rt->rt_gateway =0 ; rt->rt_uses_gateway =0 ;INIT_LIST_HEAD (&rt->rt_uncached);
@@ -2308,6 +2317,7 @@ struct dst_entry *ipv4_blackhole_route(s rt->rt_is_input = ort->rt_is_input; rt->rt_iif = ort->rt_iif; rt->rt_pmtu = ort->rt_pmtu; + rt->rt_mtu_locked = ort->rt_mtu_locked; rt->rt_genid =rt_genid_ipv4 (net); rt->rt_flags = ort->rt_flags;
@@ -2411,6 +2421,8 @@ static int rt_fill_info(struct net *net,memcpy (metrics,dst_metrics_ptr (&rt->dst),sizeof (metrics));if (rt->rt_pmtu && expires) metrics[RTAX_MTU -1 ] = rt->rt_pmtu; +if (rt->rt_mtu_locked && expires) + metrics[RTAX_LOCK -1 ] |=BIT (RTAX_MTU );if (rtnetlink_put_metrics (skb, metrics) <0 ) goto nla_put_failure;
net/ipv4/xfrm4_policy.c +1 -0
@@ -93,6 +93,7 @@ static int xfrm4_fill_dst(struct xfrm_ds xdst->u.rt.rt_gateway = rt->rt_gateway; xdst->u.rt.rt_uses_gateway = rt->rt_uses_gateway; xdst->u.rt.rt_pmtu = rt->rt_pmtu; + xdst->u.rt.rt_mtu_locked = rt->rt_mtu_locked;INIT_LIST_HEAD (&xdst->u.rt.rt_uncached);return 0 ;
PATCH 354/410 aio: change exit_aio() to load mm->ioctx_table once and avoid rcu_read_lock()
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Oleg Nesterov <[email protected]>
commit 4b70ac5fd9b58bfaa5f25b4ea48f528aefbf3308 upstream.
Quoted 12 lines · Benjamin LaHaise
Review
Quoted 8 lines
(quoted diff) +4
-3- ctx->mmap_size = 0; - - kill_ioctx(mm, ctx, NULL); + if (ctx) { + ctx->mmap_size = 0; + kill_ioctx(mm, ctx, NULL); + }Rather than indenting and moving the two lines changing
mmap_sizeand thekill_ioctx()call, why not just do "if (!ctx) ... continue;"? That reduces the number of lines changed and avoid excessive indentation.
OK. To me the code looks better/simpler with "if (ctx)", but this is subjective of course, I won't argue.
The patch still removes the empty line between mmap_size = 0 and kill_ioctx(), we reset mmap_size only for kill_ioctx(). But feel free to remove this change.
-------------------------------------------------------------------------------
Subject: [PATCH v3 1/2] aio: change exit_aio() to load mm->ioctx_table once and avoid rcu_read_lock()
1. We can read ->ioctx_table only once and we do not read rcu_read_lock() or even rcu_dereference().
This mm has no users, nobody else can play with ->ioctx_table. Otherwise the code is buggy anyway, if we need rcu_read_lock() in a loop because ->ioctx_table can be updated then kfree(table) is obviously wrong.
2. Update the comment. "exit_mmap(mm) is coming" is the good reason to avoid munmap(), but another reason is that we simply can't do vm_munmap() unless current->mm == mm and this is not true in general, the caller is mmput().
3. We do not really need to nullify mm->ioctx_table before return, probably the current code does this to catch the potential problems. But in this case RCU_INIT_POINTER(NULL) looks better.
[bwh: Backported to 3.16: Adjust context to apply after backport of commit
6098b45b32e6 "aio: block exit_aio() until all context requests are completed"]
---
fs/aio.c +17 -28
@@ -803,46 +803,35 @@ EXPORT_SYMBOL(wait_on_sync_kiocb);*/ void exit_aio (struct mm_struct *mm) { -struct kioctx_table *table; -struct kioctx *ctx; -unsigned i =0 ; +struct kioctx_table *table =rcu_dereference_raw (mm->ioctx_table); +int i; -while (1 ) { +if (!table) +return ; + +for (i =0 ; i < table->nr; ++i) { +struct kioctx *ctx = table->table[i];struct completion requests_done =COMPLETION_INITIALIZER_ONSTACK (requests_done); -rcu_read_lock (); - table =rcu_dereference (mm->ioctx_table); - -do { -if (!table || i >= table->nr) { -rcu_read_unlock (); -rcu_assign_pointer (mm->ioctx_table,NULL ); -if (table) -kfree (table); -return ; - } - - ctx = table->table[i++]; - }while (!ctx); - -rcu_read_unlock (); - +if (!ctx) +continue ;/* -* We don't need to bother with munmap() here - -* exit_mmap(mm) is coming and it'll unmap everything. -* Since aio_free_ring() uses non-zero ->mmap_size -* as indicator that it needs to unmap the area, -* just set it to 0; aio_free_ring() is the only -* place that uses ->mmap_size, so it's safe. +* We don't need to bother with munmap() here - exit_mmap(mm) +* is coming and it'll unmap everything. And we simply can't, +* this is not necessarily our ->mm. +* Since kill_ioctx() uses non-zero ->mmap_size as indicator +* that it needs to unmap the area, just set it to 0. */ ctx->mmap_size =0 ; -kill_ioctx (mm, ctx, &requests_done);/* Wait until all IO for the context are done. */ wait_for_completion (&requests_done); } + +RCU_INIT_POINTER (mm->ioctx_table,NULL ); +kfree (table); }static void put_reqs_available (struct kioctx *ctx,unsigned nr)
PATCH 355/410 aio: kill the misleading rcu read locks in ioctx_add_table() and kill_ioctx()
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Oleg Nesterov <[email protected]>
commit 855ef0dec7271ff7be7381feaaf3f4aed80bd503 upstream.
ioctx_add_table() is the writer, it does not need rcu_read_lock() to protect ->ioctx_table. It relies on mm->ioctx_lock and rcu locks just add the confusion.
And it doesn't need rcu_dereference() by the same reason, it must see any updates previously done under the same ->ioctx_lock. We could use rcu_dereference_protected() but the patch uses rcu_dereference_raw(), the function is simple enough.
The same for kill_ioctx(), although it does not update the pointer.
--- fs/aio.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
fs/aio.c +3 -11
@@ -563,8 +563,7 @@ static int ioctx_add_table(struct kioctxstruct aio_ring *ring;spin_lock (&mm->ioctx_lock); -rcu_read_lock (); - table =rcu_dereference (mm->ioctx_table); + table =rcu_dereference_raw (mm->ioctx_table);while (1 ) {if (table)
@@ -572,7 +571,6 @@ static int ioctx_add_table(struct kioctxif (!table->table[i]) { ctx->id = i; table->table[i] = ctx; -rcu_read_unlock ();spin_unlock (&mm->ioctx_lock);/* While kioctx setup is in progress,
@@ -586,8 +584,6 @@ static int ioctx_add_table(struct kioctx } new_nr = (table ? table->nr :1 ) *4 ; - -rcu_read_unlock ();spin_unlock (&mm->ioctx_lock); table = kzalloc(sizeof(*table) + sizeof(struct kioctx *) *
@@ -598,8 +594,7 @@ static int ioctx_add_table(struct kioctx table->nr = new_nr;spin_lock (&mm->ioctx_lock); -rcu_read_lock (); - old =rcu_dereference (mm->ioctx_table); + old =rcu_dereference_raw (mm->ioctx_table);if (!old) {rcu_assign_pointer (mm->ioctx_table, table);
@@ -749,12 +744,9 @@ static int kill_ioctx(struct mm_struct *spin_lock (&mm->ioctx_lock); -rcu_read_lock (); - table =rcu_dereference (mm->ioctx_table); - + table =rcu_dereference_raw (mm->ioctx_table);WARN_ON (ctx != table->table[ctx->id]); table->table[ctx->id] =NULL ; -rcu_read_unlock ();spin_unlock (&mm->ioctx_lock);/* percpu_ref_kill() will do the necessary call_rcu() */
PATCH 356/410 aio: fix serial draining in exit_aio()
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
commit dc48e56d761610da4ea1088d1bea0a030b8e3e43 upstream.
exit_aio() currently serializes killing io contexts. Each context killing ends up having to do percpu_ref_kill(), which in turns has to wait for an RCU grace period. This can take a long time, depending on the number of contexts. And there's no point in doing them serially, when we could be waiting for all of them in one fell swoop.
This patches makes my fio thread offload test case exit 0.2s instead of almost 6s.
--- fs/aio.c | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-)
fs/aio.c +30 -15
@@ -77,6 +77,11 @@ struct kioctx_cpu {unsigned reqs_available; }; +struct ctx_rq_wait { +struct completion comp; +atomic_t count; +}; +struct kioctx {struct percpu_ref users;atomic_t dead;
@@ -115,7 +120,7 @@ struct kioctx {/* * signals when all in-flight requests are done */ -struct completion *requests_done; +struct ctx_rq_wait *rq_wait;struct {/*
@@ -523,8 +528,8 @@ static void free_ioctx_reqs(struct percp struct kioctx *ctx = container_of(ref, struct kioctx, reqs);/* At this point we know that there are no any in-flight requests */ -if (ctx->requests_done) -complete (ctx->requests_done); +if (ctx->rq_wait &&atomic_dec_and_test (&ctx->rq_wait->count)) +complete (&ctx->rq_wait->comp);INIT_WORK (&ctx->free_work, free_ioctx);schedule_work (&ctx->free_work);
@@ -735,7 +740,7 @@ err:* the rapid destruction of the kioctx. */ static int kill_ioctx (struct mm_struct *mm,struct kioctx *ctx, -struct completion *requests_done) +struct ctx_rq_wait *wait) {struct kioctx_table *table;
@@ -764,7 +769,7 @@ static int kill_ioctx(struct mm_struct *if (ctx->mmap_size)vm_munmap (ctx->mmap_base, ctx->mmap_size); - ctx->requests_done = requests_done; + ctx->rq_wait = wait;percpu_ref_kill (&ctx->users);return 0 ; }
@@ -796,18 +801,24 @@ EXPORT_SYMBOL(wait_on_sync_kiocb);void exit_aio (struct mm_struct *mm) {struct kioctx_table *table =rcu_dereference_raw (mm->ioctx_table); -int i; +struct ctx_rq_wait wait; +int i, skipped;if (!table)return ; +atomic_set (&wait.count, table->nr); +init_completion (&wait.comp); + + skipped =0 ;for (i =0 ; i < table->nr; ++i) {struct kioctx *ctx = table->table[i]; -struct completion requests_done = -COMPLETION_INITIALIZER_ONSTACK (requests_done); -if (!ctx) +if (!ctx) { + skipped++;continue ; + } +/* * We don't need to bother with munmap() here - exit_mmap(mm) * is coming and it'll unmap everything. And we simply can't,
@@ -816,10 +827,12 @@ void exit_aio(struct mm_struct *mm)* that it needs to unmap the area, just set it to 0. */ ctx->mmap_size =0 ; -kill_ioctx (mm, ctx, &requests_done); +kill_ioctx (mm, ctx, &wait); + } +if (!atomic_sub_and_test (skipped, &wait.count)) {/* Wait until all IO for the context are done. */ -wait_for_completion (&requests_done); +wait_for_completion (&wait.comp); }RCU_INIT_POINTER (mm->ioctx_table,NULL );
@@ -1299,15 +1312,17 @@ SYSCALL_DEFINE1(io_destroy, aio_context_ {struct kioctx *ioctx =lookup_ioctx (ctx);if (likely (NULL != ioctx)) { -struct completion requests_done = -COMPLETION_INITIALIZER_ONSTACK (requests_done); +struct ctx_rq_wait wait;int ret; +init_completion (&wait.comp); +atomic_set (&wait.count,1 ); +/* Pass requests_done to kill_ioctx() where it can be set * in a thread-safe way. If we try to set it here then we have * a race condition if two io_destroy() called simultaneously. */ - ret =kill_ioctx (current->mm, ioctx, &requests_done); + ret =kill_ioctx (current->mm, ioctx, &wait);percpu_ref_put (&ioctx->users);/* Wait until all IO for the context are done. Otherwise kernel
@@ -1315,7 +1330,7 @@ SYSCALL_DEFINE1(io_destroy, aio_context_* is destroyed. */ if (!ret) -wait_for_completion (&requests_done); +wait_for_completion (&wait.comp);return ret; }
PATCH 357/410 fs/aio: Add explicit RCU grace period when freeing kioctx
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <[email protected]>
commit a6d7cff472eea87d96899a20fa718d2bab7109f3 upstream.
While fixing refcounting, e34ecee2ae79 ("aio: Fix a trinity splat") incorrectly removed explicit RCU grace period before freeing kioctx. The intention seems to be depending on the internal RCU grace periods of percpu_ref; however, percpu_ref uses a different flavor of RCU, sched-RCU. This can lead to kioctx being freed while RCU read protected dereferences are still in progress.
Fix it by updating free_ioctx() to go through call_rcu() explicitly.
v2: Comment added to explain double bouncing.
--- fs/aio.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
fs/aio.c +19 -4
@@ -115,7 +115,8 @@ struct kioctx {struct page **ring_pages;long nr_pages; -struct work_struct free_work; +struct rcu_head free_rcu; +struct work_struct free_work;/* see free_ioctx() */ /* * signals when all in-flight requests are done
@@ -512,6 +513,12 @@ static int kiocb_cancel(struct kiocb *kireturn cancel (kiocb); } +/* +* free_ioctx() should be RCU delayed to synchronize against the RCU +* protected lookup_ioctx() and also needs process context to call +* aio_free_ring(), so the double bouncing through kioctx->free_rcu and +* ->free_work. +*/ static void free_ioctx (struct work_struct *work) { struct kioctx *ctx = container_of(work, struct kioctx, free_work);
@@ -523,6 +530,14 @@ static void free_ioctx(struct work_struckmem_cache_free (kioctx_cachep, ctx); } +static void free_ioctx_rcufn (struct rcu_head *head) +{ + struct kioctx *ctx = container_of(head, struct kioctx, free_rcu); + +INIT_WORK (&ctx->free_work, free_ioctx); +schedule_work (&ctx->free_work); +} +static void free_ioctx_reqs (struct percpu_ref *ref) { struct kioctx *ctx = container_of(ref, struct kioctx, reqs);
@@ -531,8 +546,8 @@ static void free_ioctx_reqs(struct percpif (ctx->rq_wait &&atomic_dec_and_test (&ctx->rq_wait->count))complete (&ctx->rq_wait->comp); -INIT_WORK (&ctx->free_work, free_ioctx); -schedule_work (&ctx->free_work); +/* Synchronize against RCU protected table->table[] dereferences */ +call_rcu (&ctx->free_rcu, free_ioctx_rcufn); }/*
@@ -754,7 +769,7 @@ static int kill_ioctx(struct mm_struct * table->table[ctx->id] =NULL ;spin_unlock (&mm->ioctx_lock); -/* percpu_ref_kill() will do the necessary call_rcu() */ +/* free_ioctx_reqs() will do the necessary RCU synchronization */ wake_up_all (&ctx->wait);/*
PATCH 358/410 fs/aio: Use RCU accessors for kioctx_table->table[]
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <[email protected]>
commit d0264c01e7587001a8c4608a5d1818dba9a4c11a upstream.
While converting ioctx index from a list to a table, db446a08c23d ("aio: convert the ioctx list to table lookup v3") missed tagging kioctx_table->table[] as an array of RCU pointers and using the appropriate RCU accessors. This introduces a small window in the lookup path where init and access may race.
Mark kioctx_table->table[] with __rcu and use the approriate RCU accessors when using the field.
[bwh: Backported to 3.16:
- Drop changes to aio_ring_mremap()
-
--- fs/aio.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
fs/aio.c +10 -9
@@ -68,9 +68,9 @@ struct aio_ring {#define AIO_RING_PAGES 8struct kioctx_table { -struct rcu_head rcu; -unsigned nr; -struct kioctx *table[]; +struct rcu_head rcu; +unsigned nr; +struct kioctx __rcu *table[]; };struct kioctx_cpu {
@@ -588,9 +588,9 @@ static int ioctx_add_table(struct kioctxwhile (1 ) {if (table)for (i =0 ; i < table->nr; i++) -if (!table->table[i]) { +if (!rcu_access_pointer (table->table[i])) { ctx->id = i; - table->table[i] = ctx; +rcu_assign_pointer (table->table[i], ctx);spin_unlock (&mm->ioctx_lock);/* While kioctx setup is in progress,
@@ -765,8 +765,8 @@ static int kill_ioctx(struct mm_struct *spin_lock (&mm->ioctx_lock); table =rcu_dereference_raw (mm->ioctx_table); -WARN_ON (ctx != table->table[ctx->id]); - table->table[ctx->id] =NULL ; +WARN_ON (ctx !=rcu_access_pointer (table->table[ctx->id])); +RCU_INIT_POINTER (table->table[ctx->id],NULL );spin_unlock (&mm->ioctx_lock);/* free_ioctx_reqs() will do the necessary RCU synchronization */
@@ -827,7 +827,8 @@ void exit_aio(struct mm_struct *mm) skipped =0 ;for (i =0 ; i < table->nr; ++i) { -struct kioctx *ctx = table->table[i]; +struct kioctx *ctx = +rcu_dereference_protected (table->table[i], true);if (!ctx) { skipped++;
@@ -1022,7 +1023,7 @@ static struct kioctx *lookup_ioctx(unsigif (!table || id >= table->nr) goto out; - ctx = table->table[id]; + ctx =rcu_dereference (table->table[id]);if (ctx && ctx->user_id == ctx_id) {percpu_ref_get (&ctx->users); ret = ctx;
PATCH 359/410 RDMA/ucma: Fix access to non-initialized CM_ID object
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
commit 7688f2c3bbf55e52388e37ac5d63ca471a7712e1 upstream.
The attempt to join multicast group without ensuring that CMA device exists will lead to the following crash reported by syzkaller.
[ 64.076794] BUG: KASAN: null-ptr-deref in rdma_join_multicast+0x26e/0x12c0 [ 64.076797] Read of size 8 at addr 00000000000000b0 by task join/691 [ 64.076797] [ 64.076800] CPU: 1 PID: 691 Comm: join Not tainted 4.16.0-rc1-00219-gb97853b65b93 #23 [ 64.076802] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.11.0-0-g63451fca13-prebuilt.qemu-proj4 [ 64.076803] Call Trace: [ 64.076809] dump_stack+0x5c/0x77 [ 64.076817] kasan_report+0x163/0x380 [ 64.085859] ? rdma_join_multicast+0x26e/0x12c0 [ 64.086634] rdma_join_multicast+0x26e/0x12c0 [ 64.087370] ? rdma_disconnect+0xf0/0xf0 [ 64.088579] ? __radix_tree_replace+0xc3/0x110 [ 64.089132] ? node_tag_clear+0x81/0xb0 [ 64.089606] ? idr_alloc_u32+0x12e/0x1a0 [ 64.090517] ? __fprop_inc_percpu_max+0x150/0x150 [ 64.091768] ? tracing_record_taskinfo+0x10/0xc0 [ 64.092340] ? idr_alloc+0x76/0xc0 [ 64.092951] ? idr_alloc_u32+0x1a0/0x1a0 [ 64.093632] ? ucma_process_join+0x23d/0x460 [ 64.094510] ucma_process_join+0x23d/0x460 [ 64.095199] ? ucma_migrate_id+0x440/0x440 [ 64.095696] ? futex_wake+0x10b/0x2a0 [ 64.096159] ucma_join_multicast+0x88/0xe0 [ 64.096660] ? ucma_process_join+0x460/0x460 [ 64.097540] ? _copy_from_user+0x5e/0x90 [ 64.098017] ucma_write+0x174/0x1f0 [ 64.098640] ? ucma_resolve_route+0xf0/0xf0 [ 64.099343] ? rb_erase_cached+0x6c7/0x7f0 [ 64.099839] __vfs_write+0xc4/0x350 [ 64.100622] ? perf_syscall_enter+0xe4/0x5f0 [ 64.101335] ? kernel_read+0xa0/0xa0 [ 64.103525] ? perf_sched_cb_inc+0xc0/0xc0 [ 64.105510] ? syscall_exit_register+0x2a0/0x2a0 [ 64.107359] ? __switch_to+0x351/0x640 [ 64.109285] ? fsnotify+0x899/0x8f0 [ 64.111610] ? fsnotify_unmount_inodes+0x170/0x170 [ 64.113876] ? __fsnotify_update_child_dentry_flags+0x30/0x30 [ 64.115813] ? ring_buffer_record_is_on+0xd/0x20 [ 64.117824] ? __fget+0xa8/0xf0 [ 64.119869] vfs_write+0xf7/0x280 [ 64.122001] SyS_write+0xa1/0x120 [ 64.124213] ? SyS_read+0x120/0x120 [ 64.126644] ? SyS_read+0x120/0x120 [ 64.128563] do_syscall_64+0xeb/0x250 [ 64.130732] entry_SYSCALL_64_after_hwframe+0x21/0x86 [ 64.132984] RIP: 0033:0x7f5c994ade99 [ 64.135699] RSP: 002b:00007f5c99b97d98 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 [ 64.138740] RAX: ffffffffffffffda RBX: 00000000200001e4 RCX: 00007f5c994ade99 [ 64.141056] RDX: 00000000000000a0 RSI: 00000000200001c0 RDI: 0000000000000015 [ 64.143536] RBP: 00007f5c99b97ec0 R08: 0000000000000000 R09: 0000000000000000 [ 64.146017] R10: 0000000000000000 R11: 0000000000000246 R12: 00007f5c99b97fc0 [ 64.148608] R13: 0000000000000000 R14: 00007fff660e1c40 R15: 00007f5c99b989c0 [ 64.151060] [ 64.153703] Disabling lock debugging due to kernel taint [ 64.156032] BUG: unable to handle kernel NULL pointer dereference at 00000000000000b0 [ 64.159066] IP: rdma_join_multicast+0x26e/0x12c0 [ 64.161451] PGD 80000001d0298067 P4D 80000001d0298067 PUD 1dea39067 PMD 0 [ 64.164442] Oops: 0000 [#1] SMP KASAN PTI [ 64.166817] CPU: 1 PID: 691 Comm: join Tainted: G B 4.16.0-rc1-00219-gb97853b65b93 #23 [ 64.170004] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.11.0-0-g63451fca13-prebuilt.qemu-proj4 [ 64.174985] RIP: 0010:rdma_join_multicast+0x26e/0x12c0 [ 64.177246] RSP: 0018:ffff8801c8207860 EFLAGS: 00010282 [ 64.179901] RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffff94789522 [ 64.183344] RDX: 1ffffffff2d50fa5 RSI: 0000000000000297 RDI: 0000000000000297 [ 64.186237] RBP: ffff8801c8207a50 R08: 0000000000000000 R09: ffffed0039040ea7 [ 64.189328] R10: 0000000000000001 R11: ffffed0039040ea6 R12: 0000000000000000 [ 64.192634] R13: 0000000000000000 R14: ffff8801e2022800 R15: ffff8801d4ac2400 [ 64.196105] FS: 00007f5c99b98700(0000) GS:ffff8801e5d00000(0000) knlGS:0000000000000000 [ 64.199211] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 64.202046] CR2: 00000000000000b0 CR3: 00000001d1c48004 CR4: 00000000003606a0 [ 64.205032] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 64.208221] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 64.211554] Call Trace: [ 64.213464] ? rdma_disconnect+0xf0/0xf0 [ 64.216124] ? __radix_tree_replace+0xc3/0x110 [ 64.219337] ? node_tag_clear+0x81/0xb0 [ 64.222140] ? idr_alloc_u32+0x12e/0x1a0 [ 64.224422] ? __fprop_inc_percpu_max+0x150/0x150 [ 64.226588] ? tracing_record_taskinfo+0x10/0xc0 [ 64.229763] ? idr_alloc+0x76/0xc0 [ 64.232186] ? idr_alloc_u32+0x1a0/0x1a0 [ 64.234505] ? ucma_process_join+0x23d/0x460 [ 64.237024] ucma_process_join+0x23d/0x460 [ 64.240076] ? ucma_migrate_id+0x440/0x440 [ 64.243284] ? futex_wake+0x10b/0x2a0 [ 64.245302] ucma_join_multicast+0x88/0xe0 [ 64.247783] ? ucma_process_join+0x460/0x460 [ 64.250841] ? _copy_from_user+0x5e/0x90 [ 64.253878] ucma_write+0x174/0x1f0 [ 64.257008] ? ucma_resolve_route+0xf0/0xf0 [ 64.259877] ? rb_erase_cached+0x6c7/0x7f0 [ 64.262746] __vfs_write+0xc4/0x350 [ 64.265537] ? perf_syscall_enter+0xe4/0x5f0 [ 64.267792] ? kernel_read+0xa0/0xa0 [ 64.270358] ? perf_sched_cb_inc+0xc0/0xc0 [ 64.272575] ? syscall_exit_register+0x2a0/0x2a0 [ 64.275367] ? __switch_to+0x351/0x640 [ 64.277700] ? fsnotify+0x899/0x8f0 [ 64.280530] ? fsnotify_unmount_inodes+0x170/0x170 [ 64.283156] ? __fsnotify_update_child_dentry_flags+0x30/0x30 [ 64.286182] ? ring_buffer_record_is_on+0xd/0x20 [ 64.288749] ? __fget+0xa8/0xf0 [ 64.291136] vfs_write+0xf7/0x280 [ 64.292972] SyS_write+0xa1/0x120 [ 64.294965] ? SyS_read+0x120/0x120 [ 64.297474] ? SyS_read+0x120/0x120 [ 64.299751] do_syscall_64+0xeb/0x250 [ 64.301826] entry_SYSCALL_64_after_hwframe+0x21/0x86 [ 64.304352] RIP: 0033:0x7f5c994ade99 [ 64.306711] RSP: 002b:00007f5c99b97d98 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 [ 64.309577] RAX: ffffffffffffffda RBX: 00000000200001e4 RCX: 00007f5c994ade99 [ 64.312334] RDX: 00000000000000a0 RSI: 00000000200001c0 RDI: 0000000000000015 [ 64.315783] RBP: 00007f5c99b97ec0 R08: 0000000000000000 R09: 0000000000000000 [ 64.318365] R10: 0000000000000000 R11: 0000000000000246 R12: 00007f5c99b97fc0 [ 64.320980] R13: 0000000000000000 R14: 00007fff660e1c40 R15: 00007f5c99b989c0 [ 64.323515] Code: e8 e8 79 08 ff 4c 89 ff 45 0f b6 a7 b8 01 00 00 e8 68 7c 08 ff 49 8b 1f 4d 89 e5 49 c1 e4 04 48 8 [ 64.330753] RIP: rdma_join_multicast+0x26e/0x12c0 RSP: ffff8801c8207860 [ 64.332979] CR2: 00000000000000b0 [ 64.335550] ---[ end trace 0c00c17a408849c1 ]---
--- drivers/infiniband/core/cma.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/infiniband/core/cma.c +3 -0
@@ -3355,6 +3355,9 @@ int rdma_join_multicast(struct rdma_cm_istruct cma_multicast *mc;int ret; +if (!id->device) +return -EINVAL ; + id_priv = container_of(id, struct rdma_id_private, id);if (!cma_comp (id_priv,RDMA_CM_ADDR_BOUND ) && !cma_comp (id_priv,RDMA_CM_ADDR_RESOLVED ))
PATCH 360/410 RDMA/ucma: Don't allow join attempts for unsupported AF family
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
commit 0c81ffc60d5280991773d17e84bda605387148b1 upstream.
Users can provide garbage while calling to ucma_join_ip_multicast(), it will indirectly cause to rdma_addr_size() return 0, making the call to ucma_process_join(), which had the right checks, but it is better to check the input as early as possible.
The following crash from syzkaller revealed it.
kernel BUG at lib/string.c:1052!
invalid opcode: 0000 [#1] SMP KASAN Dumping ftrace buffer:
(ftrace buffer empty)
Modules linked in: CPU: 0 PID: 4113 Comm: syz-executor0 Not tainted 4.16.0-rc5+ #261 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 RIP: 0010:fortify_panic+0x13/0x20 lib/string.c:1051 RSP: 0018:ffff8801ca81f8f0 EFLAGS: 00010286 RAX: 0000000000000022 RBX: 1ffff10039503f23 RCX: 0000000000000000 RDX: 0000000000000022 RSI: 1ffff10039503ed3 RDI: ffffed0039503f12 RBP: ffff8801ca81f8f0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000006 R11: 0000000000000000 R12: ffff8801ca81f998 R13: ffff8801ca81f938 R14: ffff8801ca81fa58 R15: 000000000000fa00 FS: 0000000000000000(0000) GS:ffff8801db200000(0063) knlGS:000000000a12a900 CS: 0010 DS: 002b ES: 002b CR0: 0000000080050033 CR2: 0000000008138024 CR3: 00000001cbb58004 CR4: 00000000001606f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: memcpy include/linux/string.h:344 [inline] ucma_join_ip_multicast+0x36b/0x3b0 drivers/infiniband/core/ucma.c:1421 ucma_write+0x2d6/0x3d0 drivers/infiniband/core/ucma.c:1633 __vfs_write+0xef/0x970 fs/read_write.c:480 vfs_write+0x189/0x510 fs/read_write.c:544 SYSC_write fs/read_write.c:589 [inline] SyS_write+0xef/0x220 fs/read_write.c:581 do_syscall_32_irqs_on arch/x86/entry/common.c:330 [inline] do_fast_syscall_32+0x3ec/0xf9f arch/x86/entry/common.c:392 entry_SYSENTER_compat+0x70/0x7f arch/x86/entry/entry_64_compat.S:139 RIP: 0023:0xf7f9ec99 RSP: 002b:00000000ff8172cc EFLAGS: 00000282 ORIG_RAX: 0000000000000004 RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000020000100 RDX: 0000000000000063 RSI: 0000000000000000 RDI: 0000000000000000 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 Code: 08 5b 41 5c 41 5d 41 5e 41 5f 5d c3 0f 0b 48 89 df e8 42 2c e3 fb eb de 55 48 89 fe 48 c7 c7 80 75 98 86 48 89 e5 e8 85 95 94 fb <0f> 0b 90 90 90 90 90 90 90 90 90 90 90 55 48 89 e5 41 57 41 56 RIP: fortify_panic+0x13/0x20 lib/string.c:1051 RSP: ffff8801ca81f8f0
--- drivers/infiniband/core/ucma.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/infiniband/core/ucma.c +7 -1
@@ -1241,7 +1241,7 @@ static ssize_t ucma_process_join(structreturn -ENOSPC ; addr = (struct sockaddr *) &cmd->addr; -if (cmd->reserved || !cmd->addr_size || (cmd->addr_size !=rdma_addr_size (addr))) +if (cmd->reserved || cmd->addr_size !=rdma_addr_size (addr))return -EINVAL ; ctx =ucma_get_ctx (file, cmd->id);
@@ -1301,6 +1301,9 @@ static ssize_t ucma_join_ip_multicast(st join_cmd.uid = cmd.uid; join_cmd.id = cmd.id; join_cmd.addr_size =rdma_addr_size ((struct sockaddr *) &cmd.addr); +if (!join_cmd.addr_size) +return -EINVAL ; + join_cmd.reserved =0 ;memcpy (&join_cmd.addr, &cmd.addr, join_cmd.addr_size);
@@ -1316,6 +1319,9 @@ static ssize_t ucma_join_multicast(strucif (copy_from_user (&cmd, inbuf,sizeof (cmd)))return -EFAULT ; +if (!rdma_addr_size ((struct sockaddr *)&cmd.addr)) +return -EINVAL ; +return ucma_process_join (file, &cmd, out_len); }
PATCH 361/410 drm/radeon: fix prime teardown order
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Christian König <[email protected]>
commit 0f4f715bc6bed3bf14c5cd7d5fe88d443e756b14 upstream.
We unmapped imported DMA-bufs when the GEM handle was dropped, not when the hardware was done with the buffere.
--- drivers/gpu/drm/radeon/radeon_gem.c | 2 -- drivers/gpu/drm/radeon/radeon_object.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_gem.c +0 -2
@@ -34,8 +34,6 @@ void radeon_gem_object_free(struct drm_gstruct radeon_bo *robj =gem_to_radeon_bo (gobj);if (robj) { -if (robj->gem_base.import_attach) -drm_prime_gem_destroy (&robj->gem_base, robj->tbo.sg);radeon_bo_unref (&robj); } }
drivers/gpu/drm/radeon/radeon_object.c +2 -0
@@ -91,6 +91,8 @@ static void radeon_ttm_bo_destroy(structmutex_unlock (&bo->rdev->gem.mutex);radeon_bo_clear_surface_reg (bo);radeon_bo_clear_va (bo); +if (bo->gem_base.import_attach) +drm_prime_gem_destroy (&bo->gem_base, bo->tbo.sg);drm_gem_object_release (&bo->gem_base);kfree (bo); }
PATCH 362/410 mmc: block: fix updating ext_csd caches on ioctl call
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Bastian Stender <[email protected]>
commit e74ef2194b41ba5e511fab29fe5ff00e72d2f42a upstream.
PARTITION_CONFIG is cached in mmc_card->ext_csd.part_config and the currently active partition in mmc_blk_data->part_curr. These caches do not always reflect changes if the ioctl call modifies the PARTITION_CONFIG registers, e.g. by changing BOOT_PARTITION_ENABLE.
Write the PARTITION_CONFIG value extracted from the ioctl call to the cache and update the currently active partition accordingly. This ensures that the user space cannot change the values behind the kernel's back. The next call to mmc_blk_part_switch() will operate on the data set by the ioctl and reflect the changes appropriately.
[bwh: Backported to 3.16:
- Also add the definition of MMC_EXTRACT_INDEX_FROM_ARG()
- Adjust filename, context]
---
drivers/mmc/card/block.c +21 -0
@@ -67,6 +67,9 @@ MODULE_ALIAS("mmc:block");#define PACKED_CMD_VER 0x01#define PACKED_CMD_WR 0x02 +#define MMC_EXTRACT_INDEX_FROM_ARG (x) ((x & 0x00FF0000) >> 16) +#define MMC_EXTRACT_VALUE_FROM_ARG (x) ((x & 0x0000FF00) >> 8) +static DEFINE_MUTEX (block_mutex);/*
@@ -569,6 +572,24 @@ static int mmc_blk_ioctl_cmd(struct bloc }/* +* Make sure the cache of the PARTITION_CONFIG register and +* PARTITION_ACCESS bits is updated in case the ioctl ext_csd write +* changed it successfully. +*/ +if ((MMC_EXTRACT_INDEX_FROM_ARG (cmd.arg) ==EXT_CSD_PART_CONFIG ) && + (cmd.opcode ==MMC_SWITCH )) { +struct mmc_blk_data *main_md =dev_get_drvdata (&card->dev); +u8 value =MMC_EXTRACT_VALUE_FROM_ARG (cmd.arg); + +/* +* Update cache so the next mmc_blk_part_switch call operates +* on up-to-date data. +*/ + card->ext_csd.part_config = value; + main_md->part_curr = value &EXT_CSD_PART_CONFIG_ACC_MASK ; + } + +/* * According to the SD specs, some commands require a delay after * issuing the command. */
PATCH 363/410 drm/radeon: Don't turn off DP sink when disconnected
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Michel Dänzer <[email protected]>
commit 2681bc79eeb640562c932007bfebbbdc55bf6a7d upstream.
Turning off the sink in this case causes various issues, because userspace expects it to stay on until it turns it off explicitly.
Instead, turn the sink off and back on when a display is connected again. This dance seems necessary for link training to work correctly.
Bugzilla: https://bugs.freedesktop.org/105308
--- drivers/gpu/drm/radeon/radeon_connectors.c | 31 +++++++++------------- 1 file changed, 12 insertions(+), 19 deletions(-)
drivers/gpu/drm/radeon/radeon_connectors.c +11 -18
@@ -66,25 +66,18 @@ void radeon_connector_hotplug(struct drm/* don't do anything if sink is not display port, i.e., * passive dp->(dvi|hdmi) adaptor */ -if (dig_connector->dp_sink_type ==CONNECTOR_OBJECT_ID_DISPLAYPORT ) { -int saved_dpms = connector->dpms; -/* Only turn off the display if it's physically disconnected */ -if (!radeon_hpd_sense (rdev, radeon_connector->hpd.hpd)) { -drm_helper_connector_dpms (connector,DRM_MODE_DPMS_OFF ); - }else if (radeon_dp_needs_link_train (radeon_connector)) { -/* Don't try to start link training before we -* have the dpcd */ -if (!radeon_dp_getdpcd (radeon_connector)) -return ; +if (dig_connector->dp_sink_type ==CONNECTOR_OBJECT_ID_DISPLAYPORT && +radeon_hpd_sense (rdev, radeon_connector->hpd.hpd) && +radeon_dp_needs_link_train (radeon_connector)) { +/* Don't start link training before we have the DPCD */ +if (!radeon_dp_getdpcd (radeon_connector)) +return ; -/* set it to OFF so that drm_helper_connector_dpms() -* won't return immediately since the current state -* is ON at this point. -*/ - connector->dpms =DRM_MODE_DPMS_OFF ; -drm_helper_connector_dpms (connector,DRM_MODE_DPMS_ON ); - } - connector->dpms = saved_dpms; +/* Turn the connector off and back on immediately, which +* will trigger link training +*/ +drm_helper_connector_dpms (connector,DRM_MODE_DPMS_OFF ); +drm_helper_connector_dpms (connector,DRM_MODE_DPMS_ON ); } } }
PATCH 364/410 fs: Teach path_connected to handle nfs filesystems with multiple roots.
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Eric W. Biederman" <[email protected]>
commit 95dd77580ccd66a0da96e6d4696945b8cea39431 upstream.
On nfsv2 and nfsv3 the nfs server can export subsets of the same filesystem and report the same filesystem identifier, so that the nfs client can know they are the same filesystem. The subsets can be from disjoint directory trees. The nfsv2 and nfsv3 filesystems provides no way to find the common root of all directory trees exported form the server with the same filesystem identifier.
The practical result is that in struct super s_root for nfs s_root is not necessarily the root of the filesystem. The nfs mount code sets s_root to the root of the first subset of the nfs filesystem that the kernel mounts.
This effects the dcache invalidation code in generic_shutdown_super currently called shrunk_dcache_for_umount and that code for years has gone through an additional list of dentries that might be dentry trees that need to be freed to accomodate nfs.
When I wrote path_connected I did not realize nfs was so special, and it's hueristic for avoiding calling is_subdir can fail.
The practical case where this fails is when there is a move of a directory from the subtree exposed by one nfs mount to the subtree exposed by another nfs mount. This move can happen either locally or remotely. With the remote case requiring that the move directory be cached before the move and that after the move someone walks the path to where the move directory now exists and in so doing causes the already cached directory to be moved in the dcache through the magic of d_splice_alias.
If someone whose working directory is in the move directory or a subdirectory and now starts calling .. from the initial mount of nfs (where s_root == mnt_root), then path_connected as a heuristic will not bother with the is_subdir check. As s_root really is not the root of the nfs filesystem this heuristic is wrong, and the path may actually not be connected and path_connected can fail.
The is_subdir function might be cheap enough that we can call it unconditionally. Verifying that will take some benchmarking and the result may not be the same on all kernels this fix needs to be backported to. So I am avoiding that for now.
Filesystems with snapshots such as nilfs and btrfs do something similar. But as the directory tree of the snapshots are disjoint from one another and from the main directory tree rename won't move things between them and this problem will not occur.
[bwh: Backported to 3.16:
- Add the super_block::s_iflags field
- Adjust context]
---
fs/namei.c +3 -2
@@ -496,9 +496,10 @@ EXPORT_SYMBOL(path_put);static bool path_connected (const struct path *path) {struct vfsmount *mnt = path->mnt; +struct super_block *sb = mnt->mnt_sb; -/* Only bind mounts can have disconnected paths */ -if (mnt->mnt_root == mnt->mnt_sb->s_root) +/* Bind mounts and multi-root filesystems can have disconnected paths */ +if (!(sb->s_iflags &SB_I_MULTIROOT ) && (mnt->mnt_root == sb->s_root))return true;return is_subdir (path->dentry, mnt->mnt_root);
fs/nfs/super.c +2 -0
@@ -2590,6 +2590,8 @@ struct dentry *nfs_fs_mount_common(struc/* initial superblock/root creation */ mount_info->fill_super (s, mount_info);nfs_get_cache_cookie (s, mount_info->parsed, mount_info->cloned); +if (!(server->flags &NFS_MOUNT_UNSHARED )) + s->s_iflags |=SB_I_MULTIROOT ; } mntroot =nfs_get_root (s, mount_info->mntfh, dev_name);
include/linux/fs.h +4 -0
@@ -1150,6 +1150,9 @@ struct mm_struct;#define UMOUNT_NOFOLLOW 0x00000008/* Don't follow symlink on umount */ #define UMOUNT_UNUSED 0x80000000/* Flag guaranteed to be unused */ +/* sb->s_iflags */ +#define SB_I_MULTIROOT 0x00000008/* Multiple roots to the dentry tree */ +extern struct list_head super_blocks;extern spinlock_t sb_lock;
@@ -1190,6 +1193,7 @@ struct super_block {const struct quotactl_ops *s_qcop;const struct export_operations *s_export_op;unsigned long s_flags; +unsigned long s_iflags;/* internal SB_I_* flags */ unsigned long s_magic;struct dentry *s_root;struct rw_semaphore s_umount;
PATCH 365/410 RDMA/ucma: Check AF family prior resolving address
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
commit 2975d5de6428ff6d9317e9948f0968f7d42e5d74 upstream.
Garbage supplied by user will cause to UCMA module provide zero memory size for memcpy(), because it wasn't checked, it will produce unpredictable results in rdma_resolve_addr().
[ 42.873814] BUG: KASAN: null-ptr-deref in rdma_resolve_addr+0xc8/0xfb0 [ 42.874816] Write of size 28 at addr 00000000000000a0 by task resaddr/1044 [ 42.876765] [ 42.876960] CPU: 1 PID: 1044 Comm: resaddr Not tainted 4.16.0-rc1-00057-gaa56a5293d7e #34 [ 42.877840] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.11.0-0-g63451fca13-prebuilt.qemu-project.org 04/01/2014 [ 42.879691] Call Trace: [ 42.880236] dump_stack+0x5c/0x77 [ 42.880664] kasan_report+0x163/0x380 [ 42.881354] ? rdma_resolve_addr+0xc8/0xfb0 [ 42.881864] memcpy+0x34/0x50 [ 42.882692] rdma_resolve_addr+0xc8/0xfb0 [ 42.883366] ? deref_stack_reg+0x88/0xd0 [ 42.883856] ? vsnprintf+0x31a/0x770 [ 42.884686] ? rdma_bind_addr+0xc40/0xc40 [ 42.885327] ? num_to_str+0x130/0x130 [ 42.885773] ? deref_stack_reg+0x88/0xd0 [ 42.886217] ? __read_once_size_nocheck.constprop.6+0x10/0x10 [ 42.887698] ? unwind_get_return_address_ptr+0x50/0x50 [ 42.888302] ? replace_slot+0x147/0x170 [ 42.889176] ? delete_node+0x12c/0x340 [ 42.890223] ? __radix_tree_lookup+0xa9/0x160 [ 42.891196] ? ucma_resolve_ip+0xb7/0x110 [ 42.891917] ucma_resolve_ip+0xb7/0x110 [ 42.893003] ? ucma_resolve_addr+0x190/0x190 [ 42.893531] ? _copy_from_user+0x5e/0x90 [ 42.894204] ucma_write+0x174/0x1f0 [ 42.895162] ? ucma_resolve_route+0xf0/0xf0 [ 42.896309] ? dequeue_task_fair+0x67e/0xd90 [ 42.897192] ? put_prev_entity+0x7d/0x170 [ 42.897870] ? ring_buffer_record_is_on+0xd/0x20 [ 42.898439] ? tracing_record_taskinfo_skip+0x20/0x50 [ 42.899686] __vfs_write+0xc4/0x350 [ 42.900142] ? kernel_read+0xa0/0xa0 [ 42.900602] ? firmware_map_remove+0xdf/0xdf [ 42.901135] ? do_task_dead+0x5d/0x60 [ 42.901598] ? do_exit+0xcc6/0x1220 [ 42.902789] ? __fget+0xa8/0xf0 [ 42.903190] vfs_write+0xf7/0x280 [ 42.903600] SyS_write+0xa1/0x120 [ 42.904206] ? SyS_read+0x120/0x120 [ 42.905710] ? compat_start_thread+0x60/0x60 [ 42.906423] ? SyS_read+0x120/0x120 [ 42.908716] do_syscall_64+0xeb/0x250 [ 42.910760] entry_SYSCALL_64_after_hwframe+0x21/0x86 [ 42.912735] RIP: 0033:0x7f138b0afe99 [ 42.914734] RSP: 002b:00007f138b799e98 EFLAGS: 00000287 ORIG_RAX: 0000000000000001 [ 42.917134] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f138b0afe99 [ 42.919487] RDX: 000000000000002e RSI: 0000000020000c40 RDI: 0000000000000004 [ 42.922393] RBP: 00007f138b799ec0 R08: 00007f138b79a700 R09: 0000000000000000 [ 42.925266] R10: 00007f138b79a700 R11: 0000000000000287 R12: 00007f138b799fc0 [ 42.927570] R13: 0000000000000000 R14: 00007ffdbae757c0 R15: 00007f138b79a9c0 [ 42.930047] [ 42.932681] Disabling lock debugging due to kernel taint [ 42.934795] BUG: unable to handle kernel NULL pointer dereference at 00000000000000a0 [ 42.936939] IP: memcpy_erms+0x6/0x10 [ 42.938864] PGD 80000001bea92067 P4D 80000001bea92067 PUD 1bea96067 PMD 0 [ 42.941576] Oops: 0002 [#1] SMP KASAN PTI [ 42.943952] CPU: 1 PID: 1044 Comm: resaddr Tainted: G B 4.16.0-rc1-00057-gaa56a5293d7e #34 [ 42.946964] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.11.0-0-g63451fca13-prebuilt.qemu-project.org 04/01/2014 [ 42.952336] RIP: 0010:memcpy_erms+0x6/0x10 [ 42.954707] RSP: 0018:ffff8801c8b479c8 EFLAGS: 00010286 [ 42.957227] RAX: 00000000000000a0 RBX: ffff8801c8b47ba0 RCX: 000000000000001c [ 42.960543] RDX: 000000000000001c RSI: ffff8801c8b47bbc RDI: 00000000000000a0 [ 42.963867] RBP: ffff8801c8b47b60 R08: 0000000000000000 R09: ffffed0039168ed1 [ 42.967303] R10: 0000000000000001 R11: ffffed0039168ed0 R12: ffff8801c8b47bbc [ 42.970685] R13: 00000000000000a0 R14: 1ffff10039168f4a R15: 0000000000000000 [ 42.973631] FS: 00007f138b79a700(0000) GS:ffff8801e5d00000(0000) knlGS:0000000000000000 [ 42.976831] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 42.979239] CR2: 00000000000000a0 CR3: 00000001be908002 CR4: 00000000003606a0 [ 42.982060] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 42.984877] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 42.988033] Call Trace: [ 42.990487] rdma_resolve_addr+0xc8/0xfb0 [ 42.993202] ? deref_stack_reg+0x88/0xd0 [ 42.996055] ? vsnprintf+0x31a/0x770 [ 42.998707] ? rdma_bind_addr+0xc40/0xc40 [ 43.000985] ? num_to_str+0x130/0x130 [ 43.003410] ? deref_stack_reg+0x88/0xd0 [ 43.006302] ? __read_once_size_nocheck.constprop.6+0x10/0x10 [ 43.008780] ? unwind_get_return_address_ptr+0x50/0x50 [ 43.011178] ? replace_slot+0x147/0x170 [ 43.013517] ? delete_node+0x12c/0x340 [ 43.016019] ? __radix_tree_lookup+0xa9/0x160 [ 43.018755] ? ucma_resolve_ip+0xb7/0x110 [ 43.021270] ucma_resolve_ip+0xb7/0x110 [ 43.023968] ? ucma_resolve_addr+0x190/0x190 [ 43.026312] ? _copy_from_user+0x5e/0x90 [ 43.029384] ucma_write+0x174/0x1f0 [ 43.031861] ? ucma_resolve_route+0xf0/0xf0 [ 43.034782] ? dequeue_task_fair+0x67e/0xd90 [ 43.037483] ? put_prev_entity+0x7d/0x170 [ 43.040215] ? ring_buffer_record_is_on+0xd/0x20 [ 43.042990] ? tracing_record_taskinfo_skip+0x20/0x50 [ 43.045595] __vfs_write+0xc4/0x350 [ 43.048624] ? kernel_read+0xa0/0xa0 [ 43.051604] ? firmware_map_remove+0xdf/0xdf [ 43.055379] ? do_task_dead+0x5d/0x60 [ 43.058000] ? do_exit+0xcc6/0x1220 [ 43.060783] ? __fget+0xa8/0xf0 [ 43.063133] vfs_write+0xf7/0x280 [ 43.065677] SyS_write+0xa1/0x120 [ 43.068647] ? SyS_read+0x120/0x120 [ 43.071179] ? compat_start_thread+0x60/0x60 [ 43.074025] ? SyS_read+0x120/0x120 [ 43.076705] do_syscall_64+0xeb/0x250 [ 43.079006] entry_SYSCALL_64_after_hwframe+0x21/0x86 [ 43.081606] RIP: 0033:0x7f138b0afe99 [ 43.083679] RSP: 002b:00007f138b799e98 EFLAGS: 00000287 ORIG_RAX: 0000000000000001 [ 43.086802] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f138b0afe99 [ 43.089989] RDX: 000000000000002e RSI: 0000000020000c40 RDI: 0000000000000004 [ 43.092866] RBP: 00007f138b799ec0 R08: 00007f138b79a700 R09: 0000000000000000 [ 43.096233] R10: 00007f138b79a700 R11: 0000000000000287 R12: 00007f138b799fc0 [ 43.098913] R13: 0000000000000000 R14: 00007ffdbae757c0 R15: 00007f138b79a9c0 [ 43.101809] Code: 90 90 90 90 90 eb 1e 0f 1f 00 48 89 f8 48 89 d1 48 c1 e9 03 83 e2 07 f3 48 a5 89 d1 f3 a4 c3 66 0f 1f 44 00 00 48 89 f8 48 89 d1 <f3> a4 c3 0f 1f 80 00 00 00 00 48 89 f8 48 83 fa 20 72 7e 40 38 [ 43.107950] RIP: memcpy_erms+0x6/0x10 RSP: ffff8801c8b479c8
--- drivers/infiniband/core/ucma.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/infiniband/core/ucma.c +7 -3
@@ -560,19 +560,23 @@ static ssize_t ucma_resolve_ip(struct uc int in_len, int out_len) {struct rdma_ucm_resolve_ip cmd; +struct sockaddr *src, *dst;struct ucma_context *ctx;int ret;if (copy_from_user (&cmd, inbuf,sizeof (cmd)))return -EFAULT ; + src = (struct sockaddr *) &cmd.src_addr; + dst = (struct sockaddr *) &cmd.dst_addr; +if (!rdma_addr_size (src) || !rdma_addr_size (dst)) +return -EINVAL ; + ctx =ucma_get_ctx (file, cmd.id);if (IS_ERR (ctx))return PTR_ERR (ctx); - ret =rdma_resolve_addr (ctx->cm_id, (struct sockaddr *) &cmd.src_addr, - (struct sockaddr *) &cmd.dst_addr, - cmd.timeout_ms); + ret =rdma_resolve_addr (ctx->cm_id, src, dst, cmd.timeout_ms);ucma_put_ctx (ctx);return ret; }
PATCH 366/410 net: Fix vlan untag for bridge and vlan_dev with reorder_hdr off
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Toshiaki Makita <[email protected]>
commit 4bbb3e0e8239f9079bf1fe20b3c0cb598714ae61 upstream.
When we have a bridge with vlan_filtering on and a vlan device on top of it, packets would be corrupted in skb_vlan_untag() called from br_dev_xmit().
The problem sits in skb_reorder_vlan_header() used in skb_vlan_untag(), which makes use of skb->mac_len. In this function mac_len is meant for handling rx path with vlan devices with reorder_header disabled, but in tx path mac_len is typically 0 and cannot be used, which is the problem in this case.
The current code even does not properly handle rx path (skb_vlan_untag() called from __netif_receive_skb_core()) with reorder_header off actually.
In rx path single tag case, it works as follows:
- Before skb_reorder_vlan_header()
mac_header data
v v
+-------------------+-------------+------+---- | ETH | VLAN | ETH | | ADDRS | TPID | TCI | TYPE | +-------------------+-------------+------+----
<-------- mac_len --------->
<------------->
to be removed
- After skb_reorder_vlan_header()
mac_header data
v v
+-------------------+------+----
| ETH | ETH |
| ADDRS | TYPE |
+-------------------+------+----
<-------- mac_len --------->This is ok, but in rx double tag case, it corrupts packets:
- Before skb_reorder_vlan_header()
mac_header data
v v
+-------------------+-------------+-------------+------+---- | ETH | VLAN | VLAN | ETH | | ADDRS | TPID | TCI | TPID | TCI | TYPE | +-------------------+-------------+-------------+------+----
<--------------- mac_len ---------------->
<------------->
should be removed
<--------------------------->
actually will be removed
- After skb_reorder_vlan_header()
mac_header data
v v
+-------------------+------+----
| ETH | ETH |
| ADDRS | TYPE |
+-------------------+------+----
<--------------- mac_len ---------------->So, two of vlan tags are both removed while only inner one should be removed and mac_header (and mac_len) is broken.
skb_vlan_untag() is meant for removing the vlan header at (skb->data - 2), so use skb->data and skb->mac_header to calculate the right offset.
--- include/uapi/linux/if_ether.h | 1 + net/core/skbuff.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-)
include/uapi/linux/if_ether.h +1 -0
@@ -29,6 +29,7 @@*/ #define ETH_ALEN 6/* Octets in one ethernet addr */ +#define ETH_TLEN 2/* Octets in ethernet type field */ #define ETH_HLEN 14/* Total octets in header. */ #define ETH_ZLEN 60/* Min. octets in frame sans FCS */ #define ETH_DATA_LEN 1500/* Max. octets in payload */
net/core/skbuff.c +5 -2
@@ -3994,13 +3994,16 @@ EXPORT_SYMBOL_GPL(skb_gso_transport_seglstatic struct sk_buff *skb_reorder_vlan_header (struct sk_buff *skb) { +int mac_len; +if (skb_cow (skb,skb_headroom (skb)) <0 ) {kfree_skb (skb);return NULL ; } -memmove (skb->data -ETH_HLEN , skb->data - skb->mac_len -VLAN_HLEN , -2 *ETH_ALEN ); + mac_len = skb->data -skb_mac_header (skb); +memmove (skb_mac_header (skb) +VLAN_HLEN ,skb_mac_header (skb), + mac_len -VLAN_HLEN -ETH_TLEN ); skb->mac_header +=VLAN_HLEN ;return skb; }
PATCH 367/410 net: systemport: Rewrite __bcm_sysport_tx_reclaim()
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
commit 484d802d0f2f29c335563fcac2a8facf174a1bbc upstream.
There is no need for complex checking between the last consumed index and current consumed index, a simple subtraction will do.
This also eliminates the possibility of a permanent transmit queue stall under the following conditions:
- one CPU bursts ring->size worth of traffic (up to 256 buffers), to the point where we run out of free descriptors, so we stop the transmit queue at the end of bcm_sysport_xmit()
- because of our locking, we have the transmit process disable interrupts which means we can be blocking the TX reclamation process
- when TX reclamation finally runs, we will be computing the difference between ring->c_index (last consumed index by SW) and what the HW reports through its register
- this register is masked with (ring->size - 1) = 0xff, which will lead to stripping the upper bits of the index (register is 16-bits wide)
- we will be computing last_tx_cn as 0, which means there is no work to be done, and we never wake-up the transmit queue, leaving it permanently disabled
A practical example is e.g: ring->c_index aka last_c_index = 12, we pushed 256 entries, HW consumer index = 268, we mask it with 0xff = 12, so last_tx_cn == 0, nothing happens.
--- drivers/net/ethernet/broadcom/bcmsysport.c | 33 ++++++++++------------ drivers/net/ethernet/broadcom/bcmsysport.h | 2 +- 2 files changed, 16 insertions(+), 19 deletions(-)
drivers/net/ethernet/broadcom/bcmsysport.c +15 -18
@@ -584,37 +584,33 @@ static unsigned int __bcm_sysport_tx_rec struct bcm_sysport_tx_ring *ring) {struct net_device *ndev = priv->netdev; -unsigned int c_index, last_c_index, last_tx_cn, num_tx_cbs;unsigned int pkts_compl =0 , bytes_compl =0 ; +unsigned int txbds_processed =0 ;struct bcm_sysport_cb *cb; +unsigned int txbds_ready; +unsigned int c_index;u32 hw_ind;/* Compute how many descriptors have been processed since last call */ hw_ind =tdma_readl (priv,TDMA_DESC_RING_PROD_CONS_INDEX (ring->index)); c_index = (hw_ind >>RING_CONS_INDEX_SHIFT ) &RING_CONS_INDEX_MASK ; - ring->p_index = (hw_ind &RING_PROD_INDEX_MASK ); - - last_c_index = ring->c_index; - num_tx_cbs = ring->size; - - c_index &= (num_tx_cbs -1 ); - -if (c_index >= last_c_index) - last_tx_cn = c_index - last_c_index; -else - last_tx_cn = num_tx_cbs - last_c_index + c_index; + txbds_ready = (c_index - ring->c_index) &RING_CONS_INDEX_MASK ;netif_dbg (priv, tx_done, ndev, -"ring=%d c_index=%d last_tx_cn=%d last_c_index=%d\n" , - ring->index, c_index, last_tx_cn, last_c_index); +"ring=%d old_c_index=%u c_index=%u txbds_ready=%u\n" , + ring->index, ring->c_index, c_index, txbds_ready); -while (last_tx_cn-- >0 ) { - cb = ring->cbs + last_c_index; +while (txbds_processed < txbds_ready) { + cb = &ring->cbs[ring->clean_index];bcm_sysport_tx_reclaim_one (priv, cb, &bytes_compl, &pkts_compl); ring->desc_count++; - last_c_index++; - last_c_index &= (num_tx_cbs -1 ); + txbds_processed++; + +if (likely (ring->clean_index < ring->size -1 )) + ring->clean_index++; +else + ring->clean_index =0 ; } ring->c_index = c_index;
@@ -1036,6 +1032,7 @@ static int bcm_sysport_init_tx_ring(strunetif_napi_add (priv->netdev, &ring->napi, bcm_sysport_tx_poll,64 ); ring->index = index; ring->size = size; + ring->clean_index =0 ; ring->alloc_size = ring->size; ring->desc_cpu = p; ring->desc_count = ring->size;
drivers/net/ethernet/broadcom/bcmsysport.h +1 -1
@@ -624,7 +624,7 @@ struct bcm_sysport_tx_ring {unsigned int desc_count;/* Number of descriptors */ unsigned int curr_desc;/* Current descriptor */ unsigned int c_index;/* Last consumer index */ -unsigned int p_index;/* Current producer index */ +unsigned int clean_index;/* Current clean index */ struct bcm_sysport_cb *cbs;/* Transmit control blocks */ struct dma_desc *desc_cpu;/* CPU view of the descriptor */ struct bcm_sysport_priv *priv;/* private context backpointer */
PATCH 368/410 skbuff: Fix not waking applications when errors are enqueued
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Vinicius Costa Gomes <[email protected]>
commit 6e5d58fdc9bedd0255a8781b258f10bbdc63e975 upstream.
When errors are enqueued to the error queue via sock_queue_err_skb() function, it is possible that the waiting application is not notified.
Calling 'sk->sk_data_ready()' would not notify applications that selected only POLLERR events in poll() (for example).
--- net/core/skbuff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/skbuff.c +1 -1
@@ -3512,7 +3512,7 @@ int sock_queue_err_skb(struct sock *sk,skb_queue_tail (&sk->sk_error_queue, skb);if (!sock_flag (sk,SOCK_DEAD )) - sk->sk_data_ready (sk); + sk->sk_error_report (sk);return 0 ; }EXPORT_SYMBOL (sock_queue_err_skb);
PATCH 369/410 batman-adv: update data pointers after skb_cow()
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Matthias Schiffer <[email protected]>
commit bc44b78157f621ff2a2618fe287a827bcb094ac4 upstream.
batadv_check_unicast_ttvn() calls skb_cow(), so pointers into the SKB data must be (re)set after calling it. The ethhdr variable is dropped altogether.
[bwh: Backported to 3.16:
- There's no ethhdr variable here
- Adjust context]
---
net/batman-adv/routing.c +4 -2
@@ -886,8 +886,6 @@ int batadv_recv_unicast_packet(struct skbool is4addr; unicast_packet = (struct batadv_unicast_packet *)skb->data; - unicast_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data; - is4addr = unicast_packet->packet_type ==BATADV_UNICAST_4ADDR ;/* the caller function should have already pulled 2 bytes */ if (is4addr)
@@ -907,9 +905,13 @@ int batadv_recv_unicast_packet(struct skif (!batadv_check_unicast_ttvn (bat_priv, skb, hdr_size))return NET_RX_DROP ; + unicast_packet = (struct batadv_unicast_packet *)skb->data; +/* packet for me */ if (batadv_is_my_mac (bat_priv, unicast_packet->dest)) {if (is4addr) { + unicast_4addr_packet = + (struct batadv_unicast_4addr_packet *)skb->data;batadv_dat_inc_counter (bat_priv, unicast_4addr_packet->subtype); orig_addr = unicast_4addr_packet->src;
PATCH 370/410 batman-adv: fix header size check in batadv_dbg_arp()
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Matthias Schiffer <[email protected]>
commit 6f27d2c2a8c236d296201c19abb8533ec20d212b upstream.
Checking for 0 is insufficient: when an SKB without a batadv header, but with a VLAN header is received, hdr_size will be 4, making the following code interpret the Ethernet header as a batadv header.
--- net/batman-adv/distributed-arp-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/batman-adv/distributed-arp-table.c +1 -1
@@ -343,7 +343,7 @@ static void batadv_dbg_arp(struct batadvbatadv_arp_hw_src (skb, hdr_size), &ip_src, batadv_arp_hw_dst(skb, hdr_size), &ip_dst); -if (hdr_size ==0 ) +if (hdr_size <sizeof (struct batadv_unicast_packet ))return ; unicast_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data;
PATCH 371/410 ALSA: hda/realtek - Always immediately update mute LED with pin VREF
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit e40bdb03d3cd7da66bd0bc1e40cbcfb49351265c upstream.
Some HP laptops have a mute mute LED controlled by a pin VREF. The Realtek codec driver updates the VREF via vmaster hook by calling snd_hda_set_pin_ctl_cache().
This works fine as long as the driver is running in a normal mode. However, when the VREF change happens during the codec being in runtime PM suspend, the regmap access will skip and postpone the actual register change. This ends up with the unchanged LED status until the next runtime PM resume even if you change the Master mute switch. (Interestingly, the machine keeps the LED status even after the codec goes into D3 -- but it's another story.)
For improving this usability, let the driver temporarily powering up / down only during the pin VREF change. This can be achieved easily by wrapping the call with snd_hda_power_up_pm() / *_down_pm().
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=199073
[bwh: Backported to 3.16: Use snd_hda_power{down,up}() (without the _pm
suffix]
--- sound/pci/hda/patch_realtek.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
sound/pci/hda/patch_realtek.c +5 -1
@@ -3435,8 +3435,12 @@ static void alc269_fixup_mic_mute_hook(v pinval =snd_hda_codec_get_pin_target (codec, spec->mute_led_nid); pinval &= ~AC_PINCTL_VREFEN ; pinval |= enabled ?AC_PINCTL_VREF_HIZ :AC_PINCTL_VREF_80 ; -if (spec->mute_led_nid) +if (spec->mute_led_nid) { +/* temporarily power up/down for setting VREF */ +snd_hda_power_up (codec);snd_hda_set_pin_ctl_cache (codec, spec->mute_led_nid, pinval); +snd_hda_power_down (codec); + } }/* Make sure the led works even in runtime suspend */
PATCH 372/410 skb: Add skb_postpush_rcsum()
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ben Hutchings <[email protected]>
This is based on commit f8ffad69c9f8b8dfb0b633425d4ef4d2493ba61a upstream, "bpf: add skb_postpush_rcsum and fix dev_forward_skb occasions". We don't need the bpf fixes here, just the new function.
---
include/linux/skbuff.h +17 -0
@@ -2477,6 +2477,23 @@ static inline void skb_postpull_rcsum(stunsigned char *skb_pull_rcsum (struct sk_buff *skb,unsigned int len); +static inline void skb_postpush_rcsum (struct sk_buff *skb, +const void *start,unsigned int len) +{ +/* For performing the reverse operation to skb_postpull_rcsum(), +* we can instead of ... +* +* skb->csum = csum_add(skb->csum, csum_partial(start, len, 0)); +* +* ... just use this equivalent version here to save a few +* instructions. Feeding csum of 0 in csum_partial() and later +* on adding skb->csum is equivalent to feed skb->csum in the +* first place. +*/ +if (skb->ip_summed ==CHECKSUM_COMPLETE ) + skb->csum =csum_partial (start, len, skb->csum); +} +/** * pskb_trim_rcsum - trim received skb and update checksum * @skb: buffer to trim
PATCH 373/410 batman-adv: Fix skbuff rcsum on packet reroute
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit fc04fdb2c8a894283259f5621d31d75610701091 upstream.
batadv_check_unicast_ttvn may redirect a packet to itself or another originator. This involves rewriting the ttvn and the destination address in the batadv unicast header. These field were not yet pulled (with skb rcsum update) and thus any change to them also requires a change in the receive checksum.
--- net/batman-adv/routing.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
net/batman-adv/routing.c +10 -5
@@ -687,6 +687,7 @@ out:/** * batadv_reroute_unicast_packet - update the unicast header for re-routing * @bat_priv: the bat priv with all the soft interface information +* @skb: unicast packet to process * @unicast_packet: the unicast header to be updated * @dst_addr: the payload destination * @vid: VLAN identifier
@@ -698,7 +699,7 @@ out:* Returns true if the packet header has been updated, false otherwise */ static bool -batadv_reroute_unicast_packet (struct batadv_priv *bat_priv, +batadv_reroute_unicast_packet (struct batadv_priv *bat_priv,struct sk_buff *skb,struct batadv_unicast_packet *unicast_packet,uint8_t *dst_addr,unsigned short vid) {
@@ -727,8 +728,10 @@ batadv_reroute_unicast_packet(struct bat }/* update the packet header */ +skb_postpull_rcsum (skb, unicast_packet,sizeof (*unicast_packet));ether_addr_copy (unicast_packet->dest, orig_addr); unicast_packet->ttvn = orig_ttvn; +skb_postpush_rcsum (skb, unicast_packet,sizeof (*unicast_packet)); ret = true; out:
@@ -768,7 +771,7 @@ static int batadv_check_unicast_ttvn(str* the packet to */ if (batadv_tt_local_client_is_roaming (bat_priv, ethhdr->h_dest, vid)) { -if (batadv_reroute_unicast_packet (bat_priv, unicast_packet, +if (batadv_reroute_unicast_packet (bat_priv, skb, unicast_packet, ethhdr->h_dest, vid)) net_ratelimited_function(batadv_dbg, BATADV_DBG_TT, bat_priv,
@@ -814,7 +817,7 @@ static int batadv_check_unicast_ttvn(str* destination can possibly be updated and forwarded towards the new * target host */ -if (batadv_reroute_unicast_packet (bat_priv, unicast_packet, +if (batadv_reroute_unicast_packet (bat_priv, skb, unicast_packet, ethhdr->h_dest, vid)) { net_ratelimited_function(batadv_dbg, BATADV_DBG_TT, bat_priv, "Rerouting unicast packet to %pM (dst=%pM): TTVN mismatch old_ttvn=%u new_ttvn=%u\n",
@@ -837,12 +840,14 @@ static int batadv_check_unicast_ttvn(strif (!primary_if)return 0 ; +/* update the packet header */ +skb_postpull_rcsum (skb, unicast_packet,sizeof (*unicast_packet));ether_addr_copy (unicast_packet->dest, primary_if->net_dev->dev_addr); + unicast_packet->ttvn = curr_ttvn; +skb_postpush_rcsum (skb, unicast_packet,sizeof (*unicast_packet));batadv_hardif_free_ref (primary_if); - unicast_packet->ttvn = curr_ttvn; -return 1 ; }
PATCH 374/410 vti4: Don't count header length twice on tunnel setup
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Stefano Brivio <[email protected]>
commit dd1df24737727e119c263acf1be2a92763938297 upstream.
This re-introduces the effect of commit a32452366b72 ("vti4:
Don't count header length twice.") which was accidentally reverted by merge commit f895f0cfbb77 ("Merge branch 'master' ofgit://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec").
The commit message from Steffen Klassert said:
We currently count the size of LL_MAX_HEADER and struct iphdr twice for vti4 devices, this leads to a wrong device mtu. The size of LL_MAX_HEADER and struct iphdr is already counted in ip_tunnel_bind_dev(), so don't do it again in vti_tunnel_init().
And this is still the case now: ip_tunnel_bind_dev() already accounts for the header length of the link layer (not necessarily LL_MAX_HEADER, if the output device is found), plus one IP header.
For example, with a vti device on top of veth, with MTU of 1500, the existing implementation would set the initial vti MTU to 1332, accounting once for LL_MAX_HEADER (128, included in hard_header_len by vti) and twice for the same IP header (once from hard_header_len, once from ip_tunnel_bind_dev()).
It should instead be 1480, because ip_tunnel_bind_dev() is able to figure out that the output device is veth, so no additional link layer header is attached, and will properly count one single IP header.
The existing issue had the side effect of avoiding PMTUD for most xfrm policies, by arbitrarily lowering the initial MTU. However, the only way to get a consistent PMTU value is to let the xfrm PMTU discovery do its course, and commit d6af1a31cc72 ("vti: Add pmtu handling to vti_xmit.") now takes care of local delivery cases where the application ignores local socket notifications.
--- net/ipv4/ip_vti.c | 1 - 1 file changed, 1 deletion(-)
net/ipv4/ip_vti.c +0 -1
@@ -359,7 +359,6 @@ static int vti_tunnel_init(struct net_dememcpy (dev->dev_addr, &iph->saddr,4 );memcpy (dev->broadcast, &iph->daddr,4 ); - dev->hard_header_len =LL_MAX_HEADER +sizeof (struct iphdr ); dev->mtu =ETH_DATA_LEN ; dev->flags =IFF_NOARP ; dev->iflink =0 ;
PATCH 375/410 ip_tunnel: Clamp MTU to bounds on new link
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Stefano Brivio <[email protected]>
commit 24fc79798b8ddfd46f2dd363a8d29072c083b977 upstream.
Otherwise, it's possible to specify invalid MTU values directly on creation of a link (via 'ip link add'). This is already prevented on subsequent MTU changes by commit b96f9afee4eb ("ipv4/6: use core net MTU range checking").
--- net/ipv4/ip_tunnel.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
net/ipv4/ip_tunnel.c +7 -1
@@ -968,8 +968,14 @@ int ip_tunnel_newlink(struct net_deviceeth_hw_addr_random (dev); mtu =ip_tunnel_bind_dev (dev); -if (!tb[IFLA_MTU ]) +if (tb[IFLA_MTU ]) { +unsigned int max =0xfff8 - dev->hard_header_len - nt->hlen; + + dev->mtu =clamp (dev->mtu, (unsigned int )ETH_MIN_MTU , + (unsigned int )(max -sizeof (struct iphdr ))); + }else { dev->mtu = mtu; + }ip_tunnel_add (itn, nt);
include/uapi/linux/if_ether.h +2 -0
@@ -36,6 +36,8 @@#define ETH_FRAME_LEN 1514/* Max. octets in frame sans FCS */ #define ETH_FCS_LEN 4/* Octets in the FCS */ +#define ETH_MIN_MTU 68/* Min IPv4 MTU per RFC791 */ +/* * These are the defined Ethernet Protocol ID's. */
PATCH 376/410 vti4: Don't override MTU passed on link creation via IFLA_MTU
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Stefano Brivio <[email protected]>
commit 03080e5ec72740c1a62e6730f2a5f3f114f11b19 upstream.
Don't hardcode a MTU value on vti tunnel initialization, ip_tunnel_newlink() is able to deal with this already. See also commit ffc2b6ee4174 ("ip_gre: fix IFLA_MTU ignored on NEWLINK").
--- net/ipv4/ip_vti.c | 1 - 1 file changed, 1 deletion(-)
net/ipv4/ip_vti.c +0 -1
@@ -359,7 +359,6 @@ static int vti_tunnel_init(struct net_dememcpy (dev->dev_addr, &iph->saddr,4 );memcpy (dev->broadcast, &iph->daddr,4 ); - dev->mtu =ETH_DATA_LEN ; dev->flags =IFF_NOARP ; dev->iflink =0 ; dev->addr_len =4 ;
PATCH 377/410 can: cc770: Fix use after free in cc770_tx_interrupt()
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Andri Yngvason <[email protected]>
commit 9ffd7503944ec7c0ef41c3245d1306c221aef2be upstream.
This fixes use after free introduced by the last cc770 patch.
--- drivers/net/can/cc770/cc770.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/can/cc770/cc770.c +2 -3
@@ -705,13 +705,12 @@ static void cc770_tx_interrupt(struct nereturn ; } -can_put_echo_skb (priv->tx_skb, dev,0 ); -can_get_echo_skb (dev,0 ); - cf = (struct can_frame *)priv->tx_skb->data; stats->tx_bytes += cf->can_dlc; stats->tx_packets++; +can_put_echo_skb (priv->tx_skb, dev,0 ); +can_get_echo_skb (dev,0 ); priv->tx_skb =NULL ;netif_wake_queue (dev);
PATCH 378/410 libata: Apply NOLPM quirk to Crucial M500 480 and 960GB SSDs
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit 62ac3f7305470e3f52f159de448bc1a771717e88 upstream.
There have been reports of the Crucial M500 480GB model not working with LPM set to min_power / med_power_with_dipm level.
It has not been tested with medium_power, but that typically has no measurable power-savings.
Note the reporters Crucial_CT480M500SSD3 has a firmware version of MU03 and there is a MU05 update available, but that update does not mention any LPM fixes in its changelog, so the quirk matches all firmware versions.
In my experience the LPM problems with (older) Crucial SSDs seem to be limited to higher capacity versions of the SSDs (different firmware?), so this commit adds a NOLPM quirk for the 480 and 960GB versions of the M500, to avoid LPM causing issues with these SSDs.
--- drivers/ata/libata-core.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/ata/libata-core.c +6 -0
@@ -4231,6 +4231,12 @@ static const struct ata_blacklist_entry {"Crucial_CT512MX100*" ,NULL ,ATA_HORKAGE_NO_NCQ_TRIM | ATA_HORKAGE_NOLPM, }, + /* 480GB+ M500 SSDs have both queued TRIM and LPM issues */ + { "Crucial_CT480M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | + ATA_HORKAGE_NOLPM, }, + { "Crucial_CT960M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | + ATA_HORKAGE_NOLPM, }, + /* devices that don't properly handle queued TRIM commands */ { "Micron_M500_*", NULL, ATA_HORKAGE_NO_NCQ_TRIM, }, { "Crucial_CT*M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM, },
PATCH 379/410 libata: Make Crucial BX100 500GB LPM quirk apply to all firmware versions
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit 3bf7b5d6d017c27e0d3b160aafb35a8e7cfeda1f upstream.
Commit b17e5729a630 ("libata: disable LPM for Crucial BX100 SSD 500GB drive"), introduced a ATA_HORKAGE_NOLPM quirk for Crucial BX100 500GB SSDs but limited this to the MU02 firmware version, according to:
http://www.crucial.com/usa/en/support-ssd-firmware
MU02 is the last version, so there are no newer possibly fixed versions and if the MU02 version has broken LPM then the MU01 almost certainly also has broken LPM, so this commit changes the quirk to apply to all firmware versions.
--- drivers/ata/libata-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/libata-core.c +1 -1
@@ -4225,7 +4225,7 @@ static const struct ata_blacklist_entry { "PIONEER DVD-RW DVR-216D", NULL, ATA_HORKAGE_NOSETXFER },/* Crucial BX100 SSD 500GB has broken LPM support */ - { "CT500BX100SSD1", "MU02", ATA_HORKAGE_NOLPM }, + { "CT500BX100SSD1", NULL, ATA_HORKAGE_NOLPM },/* The 512GB version of the MX100 has both queued TRIM and LPM issues */ { "Crucial_CT512MX100*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
PATCH 380/410 libata: Modify quirks for MX100 to limit NCQ_TRIM quirk to MU01 version
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit d418ff56b8f2d2b296daafa8da151fe27689b757 upstream.
When commit 9c7be59fc519af ("libata: Apply NOLPM quirk to Crucial MX100 512GB SSDs") was added it inherited the ATA_HORKAGE_NO_NCQ_TRIM quirk from the existing "Crucial_CT*MX100*" entry, but that entry sets model_rev to "MU01", where as the entry adding the NOLPM quirk sets it to NULL.
This means that after this commit we no apply the NO_NCQ_TRIM quirk to all "Crucial_CT512MX100*" SSDs even if they have the fixed "MU02" firmware. This commit splits the "Crucial_CT512MX100*" quirk into 2 quirks, one for the "MU01" firmware and one for all other firmware versions, so that we once again only apply the NO_NCQ_TRIM quirk to the "MU01" firmware version.
--- drivers/ata/libata-core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/ata/libata-core.c +4 -2
@@ -4227,9 +4227,11 @@ static const struct ata_blacklist_entry/* Crucial BX100 SSD 500GB has broken LPM support */ { "CT500BX100SSD1", NULL, ATA_HORKAGE_NOLPM }, -/* The 512GB version of the MX100 has both queued TRIM and LPM issues */ - { "Crucial_CT512MX100*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | +/* 512GB MX100 with MU01 firmware has both queued TRIM and LPM issues */ + { "Crucial_CT512MX100*", "MU01", ATA_HORKAGE_NO_NCQ_TRIM | ATA_HORKAGE_NOLPM, }, + /* 512GB MX100 with newer firmware has only LPM issues */ + { "Crucial_CT512MX100*", NULL, ATA_HORKAGE_NOLPM, }, /* 480GB+ M500 SSDs have both queued TRIM and LPM issues */ { "Crucial_CT480M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
PATCH 381/410 ALSA: usb-audio: Fix parsing descriptor of UAC2 processing unit
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Kirill Marinushkin <[email protected]>
commit a6618f4aedb2b60932d766bd82ae7ce866e842aa upstream.
Currently, the offsets in the UAC2 processing unit descriptor are calculated incorrectly. It causes an issue when connecting the device which provides such a feature:
~~~~
[84126.724420] usb 1-1.3.1: invalid Processing Unit descriptor (id 18)
~~~~
After this patch is applied, the UAC2 processing unit inits w/o this error.
--- include/uapi/linux/usb/audio.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/uapi/linux/usb/audio.h +2 -2
@@ -369,7 +369,7 @@ static inline __u8 uac_processing_unit_b {return (protocol ==UAC_VERSION_1 ) ? desc->baSourceID[desc->bNrInPins +4 ] : - desc->baSourceID[desc->bNrInPins +6 ]; +2 ;/* in UAC2, this value is constant */ } static inline __u8 *uac_processing_unit_bmControls(struct uac_processing_unit_descriptor *desc,
@@ -377,7 +377,7 @@ static inline __u8 *uac_processing_unit_ {return (protocol ==UAC_VERSION_1 ) ? &desc->baSourceID[desc->bNrInPins +5 ] : - &desc->baSourceID[desc->bNrInPins +7 ]; + &desc->baSourceID[desc->bNrInPins +6 ]; } static inline __u8 uac_processing_unit_iProcessing(struct uac_processing_unit_descriptor *desc,
PATCH 382/410 RDMA/ucma: Fix use-after-free access in ucma_close
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
commit ed65a4dc22083e73bac599ded6a262318cad7baf upstream.
The error in ucma_create_id() left ctx in the list of contexts belong to ucma file descriptor. The attempt to close this file descriptor causes to use-after-free accesses while iterating over such list.
--- drivers/infiniband/core/ucma.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/infiniband/core/ucma.c +3 -0
@@ -411,6 +411,9 @@ err1:mutex_lock (&mut);idr_remove (&ctx_idr, ctx->id);mutex_unlock (&mut); +mutex_lock (&file->mut); +list_del (&ctx->list); +mutex_unlock (&file->mut);kfree (ctx);return ret; }
PATCH 383/410 RDMA/ucma: Ensure that CM_ID exists prior to access it
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
commit e8980d67d6017c8eee8f9c35f782c4bd68e004c9 upstream.
Prior to access UCMA commands, the context should be initialized and connected to CM_ID with ucma_create_id(). In case user skips this step, he can provide non-valid ctx without CM_ID and cause to multiple NULL dereferences.
Also there are situations where the create_id can be raced with other user access, ensure that the context is only shared to other threads once it is fully initialized to avoid the races.
[ 109.088108] BUG: unable to handle kernel NULL pointer dereference at 0000000000000020 [ 109.090315] IP: ucma_connect+0x138/0x1d0 [ 109.092595] PGD 80000001dc02d067 P4D 80000001dc02d067 PUD 1da9ef067 PMD 0 [ 109.095384] Oops: 0000 [#1] SMP KASAN PTI [ 109.097834] CPU: 0 PID: 663 Comm: uclose Tainted: G B 4.16.0-rc1-00062-g2975d5de6428 #45 [ 109.100816] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.11.0-0-g63451fca13-prebuilt.qemu-project.org 04/01/2014 [ 109.105943] RIP: 0010:ucma_connect+0x138/0x1d0 [ 109.108850] RSP: 0018:ffff8801c8567a80 EFLAGS: 00010246 [ 109.111484] RAX: 0000000000000000 RBX: 1ffff100390acf50 RCX: ffffffff9d7812e2 [ 109.114496] RDX: 1ffffffff3f507a5 RSI: 0000000000000297 RDI: 0000000000000297 [ 109.117490] RBP: ffff8801daa15600 R08: 0000000000000000 R09: ffffed00390aceeb [ 109.120429] R10: 0000000000000001 R11: ffffed00390aceea R12: 0000000000000000 [ 109.123318] R13: 0000000000000120 R14: ffff8801de6459c0 R15: 0000000000000118 [ 109.126221] FS: 00007fabb68d6700(0000) GS:ffff8801e5c00000(0000) knlGS:0000000000000000 [ 109.129468] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 109.132523] CR2: 0000000000000020 CR3: 00000001d45d8003 CR4: 00000000003606b0 [ 109.135573] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 109.138716] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 109.142057] Call Trace: [ 109.144160] ? ucma_listen+0x110/0x110 [ 109.146386] ? wake_up_q+0x59/0x90 [ 109.148853] ? futex_wake+0x10b/0x2a0 [ 109.151297] ? save_stack+0x89/0xb0 [ 109.153489] ? _copy_from_user+0x5e/0x90 [ 109.155500] ucma_write+0x174/0x1f0 [ 109.157933] ? ucma_resolve_route+0xf0/0xf0 [ 109.160389] ? __mod_node_page_state+0x1d/0x80 [ 109.162706] __vfs_write+0xc4/0x350 [ 109.164911] ? kernel_read+0xa0/0xa0 [ 109.167121] ? path_openat+0x1b10/0x1b10 [ 109.169355] ? fsnotify+0x899/0x8f0 [ 109.171567] ? fsnotify_unmount_inodes+0x170/0x170 [ 109.174145] ? __fget+0xa8/0xf0 [ 109.177110] vfs_write+0xf7/0x280 [ 109.179532] SyS_write+0xa1/0x120 [ 109.181885] ? SyS_read+0x120/0x120 [ 109.184482] ? compat_start_thread+0x60/0x60 [ 109.187124] ? SyS_read+0x120/0x120 [ 109.189548] do_syscall_64+0xeb/0x250 [ 109.192178] entry_SYSCALL_64_after_hwframe+0x21/0x86 [ 109.194725] RIP: 0033:0x7fabb61ebe99 [ 109.197040] RSP: 002b:00007fabb68d5e98 EFLAGS: 00000202 ORIG_RAX: 0000000000000001 [ 109.200294] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fabb61ebe99 [ 109.203399] RDX: 0000000000000120 RSI: 00000000200001c0 RDI: 0000000000000004 [ 109.206548] RBP: 00007fabb68d5ec0 R08: 0000000000000000 R09: 0000000000000000 [ 109.209902] R10: 0000000000000000 R11: 0000000000000202 R12: 00007fabb68d5fc0 [ 109.213327] R13: 0000000000000000 R14: 00007fff40ab2430 R15: 00007fabb68d69c0 [ 109.216613] Code: 88 44 24 2c 0f b6 84 24 6e 01 00 00 88 44 24 2d 0f b6 84 24 69 01 00 00 88 44 24 2e 8b 44 24 60 89 44 24 30 e8 da f6 06 ff 31 c0 <66> 41 83 7c 24 20 1b 75 04 8b 44 24 64 48 8d 74 24 20 4c 89 e7 [ 109.223602] RIP: ucma_connect+0x138/0x1d0 RSP: ffff8801c8567a80 [ 109.226256] CR2: 0000000000000020
--- drivers/infiniband/core/ucma.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/infiniband/core/ucma.c +8 -5
@@ -121,7 +121,7 @@ static inline struct ucma_context *_ucma ctx =idr_find (&ctx_idr, id);if (!ctx) ctx =ERR_PTR (-ENOENT ); -else if (ctx->file != file) +else if (ctx->file != file || !ctx->cm_id) ctx =ERR_PTR (-EINVAL );return ctx; }
@@ -371,6 +371,7 @@ static ssize_t ucma_create_id(struct ucmstruct rdma_ucm_create_id cmd;struct rdma_ucm_create_id_resp resp;struct ucma_context *ctx; +struct rdma_cm_id *cm_id;enum ib_qp_type qp_type;int ret;
@@ -391,9 +392,9 @@ static ssize_t ucma_create_id(struct ucmreturn -ENOMEM ; ctx->uid = cmd.uid; - ctx->cm_id =rdma_create_id (ucma_event_handler, ctx, cmd.ps, qp_type); -if (IS_ERR (ctx->cm_id)) { - ret =PTR_ERR (ctx->cm_id); + cm_id =rdma_create_id (ucma_event_handler, ctx, cmd.ps, qp_type); +if (IS_ERR (cm_id)) { + ret =PTR_ERR (cm_id); goto err1; }
@@ -403,10 +404,12 @@ static ssize_t ucma_create_id(struct ucm ret = -EFAULT ; goto err2; } + + ctx->cm_id = cm_id;return 0 ; err2: -rdma_destroy_id (ctx->cm_id); +rdma_destroy_id (cm_id); err1:mutex_lock (&mut);idr_remove (&ctx_idr, ctx->id);
PATCH 384/410 RDMA/ucma: Correct option size check using optlen
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Chien Tin Tung <[email protected]>
commit 5f3e3b85cc0a5eae1c46d72e47d3de7bf208d9e2 upstream.
The option size check is using optval instead of optlen causing the set option call to fail. Use the correct field, optlen, for size check.
--- drivers/infiniband/core/ucma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/ucma.c +1 -1
@@ -1200,7 +1200,7 @@ static ssize_t ucma_set_option(struct ucif (IS_ERR (ctx))return PTR_ERR (ctx); -if (unlikely (cmd.optval >KMALLOC_MAX_SIZE )) +if (unlikely (cmd.optlen >KMALLOC_MAX_SIZE ))return -EINVAL ; optval = memdup_user((void __user *) (unsigned long) cmd.optval,
PATCH 385/410 MIPS: ralink: Don't set pm_power_off
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: John Crispin <[email protected]>
commit 81ab9f6c5ff8565e4cba330e340a8979a10521d7 upstream.
Setting pm_power_off is apprently wrong and makes drivers such as gpio-poweroff not work.
Patchwork: https://patchwork.linux-mips.org/patch/11445/
--- arch/mips/ralink/reset.c | 1 - 1 file changed, 1 deletion(-)
arch/mips/ralink/reset.c +0 -1
@@ -98,7 +98,6 @@ static int __init mips_reboot_setup(void { _machine_restart = ralink_restart; _machine_halt = ralink_halt; - pm_power_off = ralink_halt;return 0 ; }
PATCH 386/410 MIPS: ralink: Remove ralink_halt()
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: NeilBrown <[email protected]>
commit 891731f6a5dbe508d12443175a7e166a2fba616a upstream.
ralink_halt() does nothing that machine_halt() doesn't already do, so it adds no value.
It actually causes incorrect behaviour due to the "unreachable()" at the end. This tells the compiler that the end of the function will never be reached, which isn't true. The compiler responds by not adding a 'return' instruction, so control simply moves on to whatever bytes come afterwards in memory. In my tested, that was the ralink_restart() function. This means that an attempt to 'halt' the machine would actually cause a reboot.
So remove ralink_halt() so that a 'halt' really does halt.
Patchwork: https://patchwork.linux-mips.org/patch/18851/
--- arch/mips/ralink/reset.c | 7 ------- 1 file changed, 7 deletions(-)
arch/mips/ralink/reset.c +0 -7
@@ -88,16 +88,9 @@ static void ralink_restart(char *commandunreachable (); } -static void ralink_halt (void ) -{ -local_irq_disable (); -unreachable (); -} -static int __init mips_reboot_setup (void ) { _machine_restart = ralink_restart; - _machine_halt = ralink_halt;return 0 ; }
PATCH 387/410 ALSA: aloop: Sync stale timer before release
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 67a01afaf3d34893cf7d2ea19b34555d6abb7cb0 upstream.
The aloop driver tries to stop the pending timer via timer_del() in the trigger callback and in the close callback. The former is correct, as it's an atomic operation, while the latter expects that the timer gets really removed and proceeds the resource releases after that. But timer_del() doesn't synchronize, hence the running timer may still access the released resources.
A similar situation can be also seen in the prepare callback after trigger(STOP) where the prepare tries to re-initialize the things while a timer is still running.
The problems like the above are seen indirectly in some syzkaller reports (although it's not 100% clear whether this is the only cause, as the race condition is quite narrow and not always easy to trigger).
For addressing these issues, this patch adds the explicit alls of timer_del_sync() in some places, so that the pending timer is properly killed / synced.
--- sound/drivers/aloop.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
sound/drivers/aloop.c +8 -1
@@ -193,6 +193,11 @@ static inline void loopback_timer_stop(s dpcm->timer.expires =0 ; } +static inline void loopback_timer_stop_sync (struct loopback_pcm *dpcm) +{ +del_timer_sync (&dpcm->timer); +} +#define CABLE_VALID_PLAYBACK (1 << SNDRV_PCM_STREAM_PLAYBACK)#define CABLE_VALID_CAPTURE (1 << SNDRV_PCM_STREAM_CAPTURE)#define CABLE_VALID_BOTH (CABLE_VALID_PLAYBACK|CABLE_VALID_CAPTURE)
@@ -327,6 +332,8 @@ static int loopback_prepare(struct snd_pstruct loopback_cable *cable = dpcm->cable;int bps, salign; +loopback_timer_stop_sync (dpcm); + salign = (snd_pcm_format_width (runtime->format) * runtime->channels) /8 ; bps = salign * runtime->rate;
@@ -746,7 +753,7 @@ static int loopback_close(struct snd_pcmstruct loopback *loopback = substream->private_data;struct loopback_pcm *dpcm = substream->runtime->private_data; -loopback_timer_stop (dpcm); +loopback_timer_stop_sync (dpcm);mutex_lock (&loopback->cable_lock);free_cable (substream);mutex_unlock (&loopback->cable_lock);
PATCH 388/410 ALSA: aloop: Fix access to not-yet-ready substream via cable
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 8e6b1a72a75bb5067ccb6b56d8ca4aa3a300a64e upstream.
In loopback_open() and loopback_close(), we assign and release the substream object to the corresponding cable in a racy way. It's neither locked nor done in the right position. The open callback assigns the substream before its preparation finishes, hence the other side of the cable may pick it up, which may lead to the invalid memory access.
This patch addresses these: move the assignment to the end of the open callback, and wrap with cable->lock for avoiding concurrent accesses.
--- sound/drivers/aloop.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
sound/drivers/aloop.c +7 -1
@@ -667,7 +667,9 @@ static void free_cable(struct snd_pcm_sureturn ;if (cable->streams[!substream->stream]) {/* other stream is still alive */ +spin_lock_irq (&cable->lock); cable->streams[substream->stream] =NULL ; +spin_unlock_irq (&cable->lock); }else {/* free the cable */ loopback->cables[substream->number][dev] =NULL ;
@@ -707,7 +709,6 @@ static int loopback_open(struct snd_pcm_ loopback->cables[substream->number][dev] = cable; } dpcm->cable = cable; - cable->streams[substream->stream] = dpcm;snd_pcm_hw_constraint_integer (runtime,SNDRV_PCM_HW_PARAM_PERIODS );
@@ -739,6 +740,11 @@ static int loopback_open(struct snd_pcm_ runtime->hw = loopback_pcm_hardware; else runtime->hw = cable->hw; + +spin_lock_irq (&cable->lock); + cable->streams[substream->stream] = dpcm; +spin_unlock_irq (&cable->lock); + unlock:if (err <0 ) {free_cable (substream);
PATCH 389/410 posix-timers: Protect posix clock array access against speculation
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit 19b558db12f9f4e45a22012bae7b4783e62224da upstream.
The clockid argument of clockid_to_kclock() comes straight from user space via various syscalls and is used as index into the posix_clocks array.
Protect it against spectre v1 array out of bounds speculation. Remove the redundant check for !posix_clock[id] as this is another source for speculation and does not provide any advantage over the return posix_clock[id] path which returns NULL in that case anyway.
[bwh: Backported to 3.16:
- Move the test of the clock_getres field below the lookup using array_index_nospec()
- Adjust filename, context]
---
kernel/posix-timers.c +12 -3
@@ -48,6 +48,7 @@#include <linux/workqueue.h> #include <linux/export.h> #include <linux/hashtable.h> +#include <linux/nospec.h> /* * Management arrays for POSIX timers. Timers are now kept in static hash table
@@ -578,13 +579,21 @@ static void release_posix_timer(struct kstatic struct k_clock *clockid_to_kclock (const clockid_t id) { -if (id <0 ) +clockid_t idx = id; +struct k_clock *kc; + +if (id <0 ) {return (id &CLOCKFD_MASK ) ==CLOCKFD ? &clock_posix_dynamic : &clock_posix_cpu; + } + +if (id >=ARRAY_SIZE (posix_clocks)) +return NULL ; -if (id >=MAX_CLOCKS || !posix_clocks[id].clock_getres) + kc = &posix_clocks[array_index_nospec (idx,ARRAY_SIZE (posix_clocks))]; +if (!kc->clock_getres)return NULL ; -return &posix_clocks[id]; +return kc; }static int common_timer_create (struct k_itimer *new_timer)
PATCH 390/410 s390/qeth: free netdevice when removing a card
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Julian Wiedmann <[email protected]>
commit 6be687395b3124f002a653c1a50b3260222b3cd7 upstream.
On removal, a qeth card's netdevice is currently not properly freed because the call chain looks as follows:
qeth_core_remove_device(card)
lx_remove_device(card) unregister_netdev(card->dev) card->dev = NULL !!! qeth_core_free_card(card) if (card->dev) !!! free_netdev(card->dev)
Fix it by free'ing the netdev straight after unregistering. This also fixes the sysfs-driven layer switch case (qeth_dev_layer2_store()), where the need to free the current netdevice was not considered at all.
Note that free_netdev() takes care of the netif_napi_del() for us too.
--- drivers/s390/net/qeth_core_main.c | 2 -- drivers/s390/net/qeth_l2_main.c | 2 +- drivers/s390/net/qeth_l3_main.c | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-)
drivers/s390/net/qeth_core_main.c +0 -2
@@ -4857,8 +4857,6 @@ static void qeth_core_free_card(struct qQETH_DBF_HEX (SETUP ,2 , &card,sizeof (void *));qeth_clean_channel (&card->read);qeth_clean_channel (&card->write); -if (card->dev) -free_netdev (card->dev);kfree (card->ip_tbd_list);qeth_free_qdio_buffers (card);unregister_service_level (&card->qeth_service_level);
drivers/s390/net/qeth_l2_main.c +1 -1
@@ -922,8 +922,8 @@ static void qeth_l2_remove_device(structqeth_l2_set_offline (cgdev);if (card->dev) { -netif_napi_del (&card->napi);unregister_netdev (card->dev); +free_netdev (card->dev); card->dev =NULL ; }return ;
drivers/s390/net/qeth_l3_main.c +1 -1
@@ -3340,8 +3340,8 @@ static void qeth_l3_remove_device(structqeth_l3_set_offline (cgdev);if (card->dev) { -netif_napi_del (&card->napi);unregister_netdev (card->dev); +free_netdev (card->dev); card->dev =NULL ; }
PATCH 391/410 mm/mempolicy.c: avoid use uninitialized preferred_node
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Yisheng Xie <[email protected]>
commit 8970a63e965b43288c4f5f40efbc2bbf80de7f16 upstream.
Alexander reported a use of uninitialized memory in __mpol_equal(), which is caused by incorrect use of preferred_node.
When mempolicy in mode MPOL_PREFERRED with flags MPOL_F_LOCAL, it uses numa_node_id() instead of preferred_node, however, __mpol_equal() uses preferred_node without checking whether it is MPOL_F_LOCAL or not.
--- mm/mempolicy.c | 3 +++ 1 file changed, 3 insertions(+)
mm/mempolicy.c +3 -0
@@ -2160,6 +2160,9 @@ bool __mpol_equal(struct mempolicy *a, scase MPOL_INTERLEAVE :return !!nodes_equal (a->v.nodes, b->v.nodes);case MPOL_PREFERRED : +/* a's ->flags is the same as b's */ +if (a->flags &MPOL_F_LOCAL ) +return true;return a->v.preferred_node == b->v.preferred_node;default :BUG ();
PATCH 392/410 tracing: probeevent: Fix to support minus offset from symbol
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu <[email protected]>
commit c5d343b6b7badd1f5fe0873eff2e8d63a193e732 upstream.
In Documentation/trace/kprobetrace.txt, it says
@SYM[+|-offs] : Fetch memory at SYM +|- offs (SYM should be a data symbol)
However, the parser doesn't parse minus offset correctly, since commit 2fba0c8867af ("tracing/kprobes: Fix probe offset to be unsigned") drops minus ("-") offset support for kprobe probe address usage.
This fixes the traceprobe_split_symbol_offset() to parse minus offset again with checking the offset range, and add a minus offset check in kprobe probe address usage.
--- kernel/trace/trace_kprobe.c | 4 ++-- kernel/trace/trace_probe.c | 8 +++----- kernel/trace/trace_probe.h | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-)
kernel/trace/trace_kprobe.c +2 -2
@@ -611,7 +611,7 @@ static int create_trace_kprobe(int argc,bool is_return = false, is_delete = false;char *symbol =NULL , *event =NULL , *group =NULL ;char *arg; -unsigned long offset =0 ; +long offset =0 ;void *addr =NULL ;char buf[MAX_EVENT_NAME_LEN ];
@@ -684,7 +684,7 @@ static int create_trace_kprobe(int argc, symbol = argv[1 ];/* TODO: support .init module functions */ ret =traceprobe_split_symbol_offset (symbol, &offset); -if (ret) { +if (ret || offset <0 || offset >UINT_MAX ) {pr_info ("Failed to parse either an address or a symbol.\n" );return ret; }
kernel/trace/trace_probe.c +3 -5
@@ -291,7 +291,7 @@ static fetch_func_t get_fetch_size_funct }/* Split symbol and offset. */ -int traceprobe_split_symbol_offset (char *symbol,unsigned long *offset) +int traceprobe_split_symbol_offset (char *symbol,long *offset) {char *tmp;int ret;
@@ -299,13 +299,11 @@ int traceprobe_split_symbol_offset(charif (!offset)return -EINVAL ; - tmp =strchr (symbol,'+' ); + tmp =strpbrk (symbol,"+-" );if (tmp) { -/* skip sign because kstrtoul doesn't accept '+' */ - ret =kstrtoul (tmp +1 ,0 , offset); + ret =kstrtol (tmp,0 , offset);if (ret)return ret; - *tmp ='\0' ; }else *offset =0 ;
kernel/trace/trace_probe.h +1 -1
@@ -341,7 +341,7 @@ extern int traceprobe_conflict_field_namextern void traceprobe_update_arg (struct probe_arg *arg);extern void traceprobe_free_probe_arg (struct probe_arg *arg); -extern int traceprobe_split_symbol_offset (char *symbol,unsigned long *offset); +extern int traceprobe_split_symbol_offset (char *symbol,long *offset); extern ssize_t traceprobe_probes_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos,
PATCH 393/410 ip_tunnel: Emit events for post-register MTU changes
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Petr Machata <[email protected]>
commit f6cc9c054e77b9a28d4594bcc201697edb21dfd2 upstream.
For tunnels created with IFLA_MTU, MTU of the netdevice is set by rtnl_create_link() (called from rtnl_newlink()) before the device is registered. However without IFLA_MTU that's not done.
rtnl_newlink() proceeds by calling struct rtnl_link_ops.newlink, which via ip_tunnel_newlink() calls register_netdevice(), and that emits NETDEV_REGISTER. Thus any listeners that inspect the netdevice get the MTU of 0.
After ip_tunnel_newlink() corrects the MTU after registering the netdevice, but since there's no event, the listeners don't get to know about the MTU until something else happens--such as a NETDEV_UP event. That's not ideal.
So instead of setting the MTU directly, go through dev_set_mtu(), which takes care of distributing the necessary NETDEV_PRECHANGEMTU and NETDEV_CHANGEMTU events.
[bwh: Backported to 3.16: Resolve conflict with commit 24fc79798b8d
"ip_tunnel: Clamp MTU to bounds on new link", referring to commit 5568cdc368c3 "ip_tunnel: Resolve ipsec merge conflict properly."]
---
net/ipv4/ip_tunnel.c +21 -7
@@ -405,17 +405,26 @@ static struct ip_tunnel *ip_tunnel_creat {struct ip_tunnel *nt;struct net_device *dev; +int mtu; +int err;BUG_ON (!itn->fb_tunnel_dev); dev =__ip_tunnel_create (net, itn->fb_tunnel_dev->rtnl_link_ops, parms);if (IS_ERR (dev))return ERR_CAST (dev); - dev->mtu =ip_tunnel_bind_dev (dev); + mtu =ip_tunnel_bind_dev (dev); + err =dev_set_mtu (dev, mtu); +if (err) + goto err_dev_set_mtu; nt =netdev_priv (dev);ip_tunnel_add (itn, nt);return nt; + +err_dev_set_mtu: +unregister_netdevice (dev); +return ERR_PTR (err); } int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
@@ -962,7 +971,7 @@ int ip_tunnel_newlink(struct net_device nt->parms = *p; err =register_netdevice (dev);if (err) - goto out; + goto err_register_netdevice;if (dev->type ==ARPHRD_ETHER && !tb[IFLA_ADDRESS ])eth_hw_addr_random (dev);
@@ -971,15 +980,20 @@ int ip_tunnel_newlink(struct net_deviceif (tb[IFLA_MTU ]) {unsigned int max =0xfff8 - dev->hard_header_len - nt->hlen; - dev->mtu =clamp (dev->mtu, (unsigned int )ETH_MIN_MTU , - (unsigned int )(max -sizeof (struct iphdr ))); - }else { - dev->mtu = mtu; + mtu =clamp (dev->mtu, (unsigned int )ETH_MIN_MTU , + (unsigned int )(max -sizeof (struct iphdr ))); } + err =dev_set_mtu (dev, mtu); +if (err) + goto err_dev_set_mtu; +ip_tunnel_add (itn, nt); +return 0 ; -out: +err_dev_set_mtu: +unregister_netdevice (dev); +err_register_netdevice:return err; }EXPORT_SYMBOL_GPL (ip_tunnel_newlink);
PATCH 394/410 batman-adv: fix multicast-via-unicast transmission with AP isolation
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Linus Lüssing <[email protected]>
commit f8fb3419ead44f9a3136995acd24e35da4525177 upstream.
For multicast frames AP isolation is only supposed to be checked on the receiving nodes and never on the originating one.
Furthermore, the isolation or wifi flag bits should only be intepreted as such for unicast and never multicast TT entries.
By injecting flags to the multicast TT entry claimed by a single target node it was verified in tests that this multicast address becomes unreachable, leading to packet loss.
Omitting the "src" parameter to the batadv_transtable_search() call successfully skipped the AP isolation check and made the target reachable again.
--- net/batman-adv/multicast.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/batman-adv/multicast.c +2 -2
@@ -398,8 +398,8 @@ static struct batadv_orig_node * batadv_mcast_forw_tt_node_get(struct batadv_priv *bat_priv, struct ethhdr *ethhdr) { - return batadv_transtable_search(bat_priv, ethhdr->h_source, - ethhdr->h_dest, BATADV_NO_FLAGS); + return batadv_transtable_search(bat_priv, NULL, ethhdr->h_dest, + BATADV_NO_FLAGS); }/**
PATCH 395/410 batman-adv: fix packet loss for broadcasted DHCP packets to a server
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Linus Lüssing <[email protected]>
commit a752c0a4524889cdc0765925258fd1fd72344100 upstream.
DHCP connectivity issues can currently occur if the following conditions are met:
1) A DHCP packet from a client to a server
2) This packet has a multicast destination
3) This destination has a matching entry in the translation table (FF:FF:FF:FF:FF:FF for IPv4, 33:33:00:01:00:02/33:33:00:01:00:03 for IPv6)
4) The orig-node determined by TT for the multicast destination does not match the orig-node determined by best-gateway-selection
In this case the DHCP packet will be dropped.
The "gateway-out-of-range" check is supposed to only be applied to unicasted DHCP packets to a specific DHCP server.
In that case dropping the the unicasted frame forces the client to retry via a broadcasted one, but now directed to the new best gateway.
A DHCP packet with broadcast/multicast destination is already ensured to always be delivered to the best gateway. Dropping a multicasted DHCP packet here will only prevent completing DHCP as there is no other fallback.
So far, it seems the unicast check was implicitly performed by expecting the batadv_transtable_search() to return NULL for multicast destinations. However, a multicast address could have always ended up in the translation table and in fact is now common.
To fix this potential loss of a DHCP client-to-server packet to a multicast address this patch adds an explicit multicast destination check to reliably bail out of the gateway-out-of-range check for such destinations.
The issue and fix were tested in the following three node setup:
- Line topology, A-B-C
- A: gateway client, DHCP client
- B: gateway server, hop-penalty increased: 30->60, DHCP server
- C: gateway server, code modifications to announce FF:FF:FF:FF:FF:FF
Without this patch, A would never transmit its DHCP Discover packet due to an always "out-of-range" condition. With this patch, a full DHCP handshake between A and B was possible again.
---
net/batman-adv/gateway_client.c +3 -0
@@ -804,6 +804,9 @@ bool batadv_gw_out_of_range(struct batad vid =batadv_get_vid (skb,0 ); +if (is_multicast_ether_addr (ethhdr->h_dest)) + goto out; + orig_dst_node =batadv_transtable_search (bat_priv, ethhdr->h_source, ethhdr->h_dest, vid);if (!orig_dst_node)
PATCH 396/410 tty: vt: fix up tabstops properly
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Linus Torvalds <[email protected]>
commit f1869a890cdedb92a3fab969db5d0fd982850273 upstream.
Tabs on a console with long lines do not wrap properly, so correctly account for the line length when computing the tab placement location.
--- drivers/tty/vt/vt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/tty/vt/vt.c +4 -4
@@ -1705,7 +1705,7 @@ static void reset_terminal(struct vc_datdefault_attr (vc);update_attr (vc); - vc->vc_tab_stop[0 ] =0x01010100 ; + vc->vc_tab_stop[0 ] = vc->vc_tab_stop[1 ] = vc->vc_tab_stop[2 ] = vc->vc_tab_stop[3] =
@@ -1748,7 +1748,7 @@ static void do_con_trol(struct tty_struc vc->vc_pos -= (vc->vc_x <<1 );while (vc->vc_x < vc->vc_cols -1 ) { vc->vc_x++; -if (vc->vc_tab_stop[vc->vc_x >>5 ] & (1 << (vc->vc_x &31 ))) +if (vc->vc_tab_stop[7 & (vc->vc_x >>5 )] & (1 << (vc->vc_x &31 )))break ; } vc->vc_pos += (vc->vc_x <<1 );
@@ -1808,7 +1808,7 @@ static void do_con_trol(struct tty_struclf (vc);return ;case 'H' : - vc->vc_tab_stop[vc->vc_x >>5 ] |= (1 << (vc->vc_x &31 )); + vc->vc_tab_stop[7 & (vc->vc_x >>5 )] |= (1 << (vc->vc_x &31 ));return ;case 'Z' :respond_ID (tty);
@@ -2001,7 +2001,7 @@ static void do_con_trol(struct tty_strucreturn ;case 'g' :if (!vc->vc_par[0 ]) - vc->vc_tab_stop[vc->vc_x >>5 ] &= ~(1 << (vc->vc_x &31 )); + vc->vc_tab_stop[7 & (vc->vc_x >>5 )] &= ~(1 << (vc->vc_x &31 ));else if (vc->vc_par[0 ] ==3 ) { vc->vc_tab_stop[0 ] = vc->vc_tab_stop[1] =
PATCH 397/410 netlink: make sure nladdr has correct size in netlink_connect()
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Potapenko <[email protected]>
commit 7880287981b60a6808f39f297bb66936e8bdf57a upstream.
KMSAN reports use of uninitialized memory in the case when |alen| is smaller than sizeof(struct sockaddr_nl), and therefore |nladdr| isn't fully copied from the userspace.
--- net/netlink/af_netlink.c | 3 +++ 1 file changed, 3 insertions(+)
net/netlink/af_netlink.c +3 -0
@@ -990,6 +990,9 @@ static int netlink_connect(struct socketif (addr->sa_family !=AF_NETLINK )return -EINVAL ; +if (alen <sizeof (struct sockaddr_nl )) +return -EINVAL ; +if ((nladdr->nl_groups || nladdr->nl_pid) && !netlink_allowed (sock,NL_CFG_F_NONROOT_SEND ))return -EPERM ;
PATCH 398/410 ipv6: the entire IPv6 header chain must fit the first fragment
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
commit 10b8a3de603df7b96004179b1b33b1708c76d144 upstream.
While building ipv6 datagram we currently allow arbitrary large extheaders, even beyond pmtu size. The syzbot has found a way to exploit the above to trigger the following splat:
kernel BUG at ./include/linux/skbuff.h:2073!
invalid opcode: 0000 [#1] SMP KASAN
Dumping ftrace buffer:
(ftrace buffer empty)
Modules linked in: CPU: 1 PID: 4230 Comm: syzkaller672661 Not tainted 4.16.0-rc2+ #326 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 RIP: 0010:__skb_pull include/linux/skbuff.h:2073 [inline] RIP: 0010:__ip6_make_skb+0x1ac8/0x2190 net/ipv6/ip6_output.c:1636 RSP: 0018:ffff8801bc18f0f0 EFLAGS: 00010293 RAX: ffff8801b17400c0 RBX: 0000000000000738 RCX: ffffffff84f01828 RDX: 0000000000000000 RSI: 0000000000000001 RDI: ffff8801b415ac18 RBP: ffff8801bc18f360 R08: ffff8801b4576844 R09: 0000000000000000 R10: ffff8801bc18f380 R11: ffffed00367aee4e R12: 00000000000000d6 R13: ffff8801b415a740 R14: dffffc0000000000 R15: ffff8801b45767c0 FS: 0000000001535880(0000) GS:ffff8801db300000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000002000b000 CR3: 00000001b4123001 CR4: 00000000001606e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: ip6_finish_skb include/net/ipv6.h:969 [inline] udp_v6_push_pending_frames+0x269/0x3b0 net/ipv6/udp.c:1073 udpv6_sendmsg+0x2a96/0x3400 net/ipv6/udp.c:1343 inet_sendmsg+0x11f/0x5e0 net/ipv4/af_inet.c:764 sock_sendmsg_nosec net/socket.c:630 [inline] sock_sendmsg+0xca/0x110 net/socket.c:640 ___sys_sendmsg+0x320/0x8b0 net/socket.c:2046 __sys_sendmmsg+0x1ee/0x620 net/socket.c:2136 SYSC_sendmmsg net/socket.c:2167 [inline] SyS_sendmmsg+0x35/0x60 net/socket.c:2162 do_syscall_64+0x280/0x940 arch/x86/entry/common.c:287 entry_SYSCALL_64_after_hwframe+0x42/0xb7 RIP: 0033:0x4404c9 RSP: 002b:00007ffdce35f948 EFLAGS: 00000217 ORIG_RAX: 0000000000000133 RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 00000000004404c9 RDX: 0000000000000003 RSI: 0000000020001f00 RDI: 0000000000000003 RBP: 00000000006cb018 R08: 00000000004002c8 R09: 00000000004002c8 R10: 0000000020000080 R11: 0000000000000217 R12: 0000000000401df0 R13: 0000000000401e80 R14: 0000000000000000 R15: 0000000000000000 Code: ff e8 1d 5e b9 fc e9 15 e9 ff ff e8 13 5e b9 fc e9 44 e8 ff ff e8 29 5e b9 fc e9 c0 e6 ff ff e8 3f f3 80 fc 0f 0b e8 38 f3 80 fc <0f> 0b 49 8d 87 80 00 00 00 4d 8d 87 84 00 00 00 48 89 85 20 fe RIP: __skb_pull include/linux/skbuff.h:2073 [inline] RSP: ffff8801bc18f0f0 RIP: __ip6_make_skb+0x1ac8/0x2190 net/ipv6/ip6_output.c:1636 RSP:
ffff8801bc18f0f0
As stated by RFC 7112 section 5:
When a host fragments an IPv6 datagram, it MUST include the entire IPv6 Header Chain in the First Fragment.
So this patch addresses the issue dropping datagrams with excessive extheader length. It also updates the error path to report to the calling socket nonnegative pmtu values.
The issue apparently predates git history.
v1 -> v2: cleanup error path, as per Eric's suggestion
--- net/ipv6/ip6_output.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
net/ipv6/ip6_output.c +9 -4
@@ -1146,7 +1146,7 @@ int ip6_append_data(struct sock *sk, intstruct ipv6_pinfo *np =inet6_sk (sk);struct inet_cork *cork;struct sk_buff *skb, *skb_prev =NULL ; -unsigned int maxfraglen, fragheaderlen, mtu, orig_mtu, headersize; +unsigned int maxfraglen, fragheaderlen, mtu, orig_mtu, headersize, pmtu;int exthdrlen;int dst_exthdrlen;int hh_len;
@@ -1242,6 +1242,12 @@ int ip6_append_data(struct sock *sk, int sizeof(struct frag_hdr) : 0) + rt->rt6i_nfheader_len; +/* as per RFC 7112 section 5, the entire IPv6 Header Chain must fit +* the first fragment +*/ +if (headersize + transhdrlen > mtu) + goto emsgsize; +if (mtu <=sizeof (struct ipv6hdr ) +IPV6_MAXPLEN ) {unsigned int maxnonfragsize;
@@ -1261,9 +1267,8 @@ int ip6_append_data(struct sock *sk, intif (cork->length + length > maxnonfragsize - headersize) { emsgsize: -ipv6_local_error (sk,EMSGSIZE , fl6, - mtu - headersize + -sizeof (struct ipv6hdr )); + pmtu =max_t (int, mtu - headersize +sizeof (struct ipv6hdr ),0 ); +ipv6_local_error (sk,EMSGSIZE , fl6, pmtu);return -EMSGSIZE ; } }
PATCH 399/410 ALSA: pcm: Use dma_bytes as size parameter in dma_mmap_coherent()
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Roese <[email protected]>
commit 9066ae7ff5d89c0b5daa271e2d573540097a94fa upstream.
When trying to use the driver (e.g. aplay *.wav), the 4MiB DMA buffer will get mmapp'ed in 16KiB chunks. But this fails with the 2nd 16KiB area, as the page offset is outside of the VMA range (size), which is currently used as size parameter in snd_pcm_lib_default_mmap(). By using the DMA buffer size (dma_bytes) instead, the complete DMA buffer can be mmapp'ed and the issue is fixed.
This issue was detected on an ARM platform (TI AM57xx) using the RME HDSP MADI PCIe soundcard.
--- sound/core/pcm_native.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/pcm_native.c +1 -1
@@ -3219,7 +3219,7 @@ int snd_pcm_lib_default_mmap(struct snd_ area, substream->runtime->dma_area, substream->runtime->dma_addr, - area->vm_end - area->vm_start); + substream->runtime->dma_bytes);#elif defined(CONFIG_MIPS ) && defined(CONFIG_DMA_NONCOHERENT )if (substream->dma_buffer.dev.type ==SNDRV_DMA_TYPE_DEV && !plat_device_is_coherent (substream->dma_buffer.dev.dev))
PATCH 400/410 bonding: fix the err path for dev hwaddr sync in bond_enslave
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
commit 5c78f6bfae2b10ff70e21d343e64584ea6280c26 upstream.
vlan_vids_add_by_dev is called right after dev hwaddr sync, so on the err path it should unsync dev hwaddr. Otherwise, the slave dev's hwaddr will never be unsync when this err happens.
--- drivers/net/bonding/bond_main.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/net/bonding/bond_main.c +5 -4
@@ -1451,7 +1451,7 @@ int bond_enslave(struct net_device *bondif (res) {pr_err ("%s: Error: Couldn't add bond vlan ids to %s\n" , bond_dev->name, slave_dev->name); - goto err_close; + goto err_hwaddr_unsync; } prev_slave =bond_last_slave (bond);
@@ -1626,9 +1626,6 @@ err_unregister:netdev_rx_handler_unregister (slave_dev); err_detach: -if (!bond_uses_primary (bond)) -bond_hw_addr_flush (bond_dev, slave_dev); -vlan_vids_del_by_dev (slave_dev, bond_dev);if (bond->primary_slave == new_slave) bond->primary_slave =NULL ;
@@ -1642,6 +1639,10 @@ err_detach: }slave_disable_netpoll (new_slave); +err_hwaddr_unsync: +if (!bond_uses_primary (bond)) +bond_hw_addr_flush (bond_dev, slave_dev); + err_close: slave_dev->priv_flags &= ~IFF_BONDING ;dev_close (slave_dev);
PATCH 401/410 bonding: move dev_mc_sync after master_upper_dev_link in bond_enslave
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
commit ae42cc62a9f07f1f6979054ed92606b9c30f4a2e upstream.
Beniamino found a crash when adding vlan as slave of bond which is also the parent link:
ip link add bond1 type bond
ip link set bond1 up
ip link add link bond1 vlan1 type vlan id 80
ip link set vlan1 master bond1
The call trace is as below:
[<ffffffffa850842a>] queued_spin_lock_slowpath+0xb/0xf [<ffffffffa8515680>] _raw_spin_lock+0x20/0x30 [<ffffffffa83f6f07>] dev_mc_sync+0x37/0x80 [<ffffffffc08687dc>] vlan_dev_set_rx_mode+0x1c/0x30 [8021q] [<ffffffffa83efd2a>] __dev_set_rx_mode+0x5a/0xa0 [<ffffffffa83f7138>] dev_mc_sync_multiple+0x78/0x80 [<ffffffffc084127c>] bond_enslave+0x67c/0x1190 [bonding] [<ffffffffa8401909>] do_setlink+0x9c9/0xe50 [<ffffffffa8403bf2>] rtnl_newlink+0x522/0x880 [<ffffffffa8403ff7>] rtnetlink_rcv_msg+0xa7/0x260 [<ffffffffa8424ecb>] netlink_rcv_skb+0xab/0xc0 [<ffffffffa83fe498>] rtnetlink_rcv+0x28/0x30 [<ffffffffa8424850>] netlink_unicast+0x170/0x210 [<ffffffffa8424bf8>] netlink_sendmsg+0x308/0x420 [<ffffffffa83cc396>] sock_sendmsg+0xb6/0xf0
This is actually a dead lock caused by sync slave hwaddr from master when the master is the slave's 'slave'. This dead loop check is actually done by netdev_master_upper_dev_link. However, Commit 1f718f0f4f97 ("bonding:
populate neighbour's private on enslave") moved it after dev_mc_sync.
This patch is to fix it by moving dev_mc_sync after master_upper_dev_link, so that this loop check would be earlier than dev_mc_sync. It also moves if (mode == BOND_MODE_8023AD) into if (!bond_uses_primary) clause as an improvement.
Note team driver also has this issue, I will fix it in another patch.
--- drivers/net/bonding/bond_main.c | 73 ++++++++++++++++----------------- 1 file changed, 35 insertions(+), 38 deletions(-)
drivers/net/bonding/bond_main.c +35 -38
@@ -1414,44 +1414,11 @@ int bond_enslave(struct net_device *bond goto err_close; } -/* If the mode uses primary, then the following is handled by -* bond_change_active_slave(). -*/ -if (!bond_uses_primary (bond)) { -/* set promiscuity level to new slave */ -if (bond_dev->flags &IFF_PROMISC ) { - res =dev_set_promiscuity (slave_dev,1 ); -if (res) - goto err_close; - } - -/* set allmulti level to new slave */ -if (bond_dev->flags &IFF_ALLMULTI ) { - res =dev_set_allmulti (slave_dev,1 ); -if (res) - goto err_close; - } - -netif_addr_lock_bh (bond_dev); - -dev_mc_sync_multiple (slave_dev, bond_dev); -dev_uc_sync_multiple (slave_dev, bond_dev); - -netif_addr_unlock_bh (bond_dev); - } - -if (BOND_MODE (bond) ==BOND_MODE_8023AD ) { -/* add lacpdu mc addr to mc list */ -u8 lacpdu_multicast[ETH_ALEN ] =MULTICAST_LACPDU_ADDR ; - -dev_mc_add (slave_dev, lacpdu_multicast); - } - res =vlan_vids_add_by_dev (slave_dev, bond_dev);if (res) {pr_err ("%s: Error: Couldn't add bond vlan ids to %s\n" , bond_dev->name, slave_dev->name); - goto err_hwaddr_unsync; + goto err_close; } prev_slave =bond_last_slave (bond);
@@ -1598,6 +1565,37 @@ int bond_enslave(struct net_device *bond goto err_upper_unlink; } +/* If the mode uses primary, then the following is handled by +* bond_change_active_slave(). +*/ +if (!bond_uses_primary (bond)) { +/* set promiscuity level to new slave */ +if (bond_dev->flags &IFF_PROMISC ) { + res =dev_set_promiscuity (slave_dev,1 ); +if (res) + goto err_sysfs_del; + } + +/* set allmulti level to new slave */ +if (bond_dev->flags &IFF_ALLMULTI ) { + res =dev_set_allmulti (slave_dev,1 ); +if (res) + goto err_sysfs_del; + } + +netif_addr_lock_bh (bond_dev); +dev_mc_sync_multiple (slave_dev, bond_dev); +dev_uc_sync_multiple (slave_dev, bond_dev); +netif_addr_unlock_bh (bond_dev); + +if (BOND_MODE (bond) ==BOND_MODE_8023AD ) { +/* add lacpdu mc addr to mc list */ +u8 lacpdu_multicast[ETH_ALEN ] =MULTICAST_LACPDU_ADDR ; + +dev_mc_add (slave_dev, lacpdu_multicast); + } + } + bond->slave_cnt++;bond_compute_features (bond);bond_set_carrier (bond);
@@ -1619,6 +1617,9 @@ int bond_enslave(struct net_device *bondreturn 0 ;/* Undo stages on error */ +err_sysfs_del: +bond_sysfs_slave_del (new_slave); + err_upper_unlink:bond_upper_dev_unlink (bond_dev, slave_dev);
@@ -1639,10 +1640,6 @@ err_detach: }slave_disable_netpoll (new_slave); -err_hwaddr_unsync: -if (!bond_uses_primary (bond)) -bond_hw_addr_flush (bond_dev, slave_dev); - err_close: slave_dev->priv_flags &= ~IFF_BONDING ;dev_close (slave_dev);
PATCH 402/410 bonding: process the err returned by dev_set_allmulti properly in bond_enslave
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
commit 9f5a90c107741b864398f4ac0014711a8c1d8474 upstream.
When dev_set_promiscuity(1) succeeds but dev_set_allmulti(1) fails, dev_set_promiscuity(-1) should be done before going to the err path. Otherwise, dev->promiscuity will leak.
--- drivers/net/bonding/bond_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/bonding/bond_main.c +4 -1
@@ -1579,8 +1579,11 @@ int bond_enslave(struct net_device *bond/* set allmulti level to new slave */ if (bond_dev->flags &IFF_ALLMULTI ) { res =dev_set_allmulti (slave_dev,1 ); -if (res) +if (res) { +if (bond_dev->flags &IFF_PROMISC ) +dev_set_promiscuity (slave_dev,-1 ); goto err_sysfs_del; + } }netif_addr_lock_bh (bond_dev);
PATCH 403/410 ALSA: pcm: potential uninitialized return values
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 5607dddbfca774fb38bffadcb077fe03aa4ac5c6 upstream.
Smatch complains that "tmp" can be uninitialized if we do a zero size write.
--- sound/core/oss/pcm_oss.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/core/oss/pcm_oss.c +2 -2
@@ -1362,7 +1362,7 @@ static ssize_t snd_pcm_oss_write2(structstatic ssize_t snd_pcm_oss_write1 (struct snd_pcm_substream *substream,const char __user *buf,size_t bytes) {size_t xfer =0 ; -ssize_t tmp; +ssize_t tmp =0 ;struct snd_pcm_runtime *runtime = substream->runtime;if (atomic_read (&substream->mmap_count))
@@ -1469,7 +1469,7 @@ static ssize_t snd_pcm_oss_read2(structstatic ssize_t snd_pcm_oss_read1 (struct snd_pcm_substream *substream,char __user *buf,size_t bytes) {size_t xfer =0 ; -ssize_t tmp; +ssize_t tmp =0 ;struct snd_pcm_runtime *runtime = substream->runtime;if (atomic_read (&substream->mmap_count))
PATCH 404/410 net: fix possible out-of-bound read in skb_network_protocol()
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit 1dfe82ebd7d8fd43dba9948fdfb31f145014baa0 upstream.
skb mac header is not necessarily set at the time skb_network_protocol() is called. Use skb->data instead.
BUG: KASAN: slab-out-of-bounds in skb_network_protocol+0x46b/0x4b0 net/core/dev.c:2739 Read of size 2 at addr ffff8801b3097a0b by task syz-executor5/14242 CPU: 1 PID: 14242 Comm: syz-executor5 Not tainted 4.16.0-rc6+ #280 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:17 [inline] dump_stack+0x194/0x24d lib/dump_stack.c:53 print_address_description+0x73/0x250 mm/kasan/report.c:256 kasan_report_error mm/kasan/report.c:354 [inline] kasan_report+0x23c/0x360 mm/kasan/report.c:412 __asan_report_load_n_noabort+0xf/0x20 mm/kasan/report.c:443 skb_network_protocol+0x46b/0x4b0 net/core/dev.c:2739 harmonize_features net/core/dev.c:2924 [inline] netif_skb_features+0x509/0x9b0 net/core/dev.c:3011 validate_xmit_skb+0x81/0xb00 net/core/dev.c:3084 validate_xmit_skb_list+0xbf/0x120 net/core/dev.c:3142 packet_direct_xmit+0x117/0x790 net/packet/af_packet.c:256 packet_snd net/packet/af_packet.c:2944 [inline] packet_sendmsg+0x3aed/0x60b0 net/packet/af_packet.c:2969 sock_sendmsg_nosec net/socket.c:629 [inline] sock_sendmsg+0xca/0x110 net/socket.c:639 ___sys_sendmsg+0x767/0x8b0 net/socket.c:2047 __sys_sendmsg+0xe5/0x210 net/socket.c:2081
--- net/core/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/dev.c +1 -1
@@ -2336,7 +2336,7 @@ __be16 skb_network_protocol(struct sk_buif (unlikely (!pskb_may_pull (skb,sizeof (struct ethhdr ))))return 0 ; - eth = (struct ethhdr *)skb_mac_header (skb); + eth = (struct ethhdr *)skb->data; type = eth->h_proto; }
PATCH 405/410 net/mlx4_en: do not ignore autoneg in mlx4_en_set_pauseparam()
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ivan Vecera <[email protected]>
commit 278d436a476f69fc95d5c82bf61b6c2d02f4d44e upstream.
The driver does not support pause autonegotiation so it should return -EINVAL when the function is called with non-zero autoneg.
--- drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c +3 -0
@@ -476,6 +476,9 @@ static int mlx4_en_set_pauseparam(structstruct mlx4_en_dev *mdev = priv->mdev;int err; +if (pause->autoneg) +return -EINVAL ; + priv->prof->tx_pause = pause->tx_pause !=0 ; priv->prof->rx_pause = pause->rx_pause !=0 ; err = mlx4_SET_PORT_general(mdev->dev, priv->port,
PATCH 406/410 net/mlx4_en: Fix mixed PFC and Global pause user control requests
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eran Ben Elisha <[email protected]>
commit 6e8814ceb7e8f468659ef9253bd212c07ae19584 upstream.
Global pause and PFC configuration should be mutually exclusive (i.e. only one of them at most can be set). However, once PFC was turned off, driver automatically turned Global pause on. This is a bug.
Fix the driver behaviour to turn off PFC/Global once the user turned the other on.
This also fixed a weird behaviour that at a current time, the profile had both PFC and global pause configuration turned on, which is Hardware-wise impossible and caused returning false positive indication to query tools.
In addition, fix error code when setting global pause or PFC to change metadata only upon successful change.
Also, removed useless debug print.
[bwh: Backported to 3.16:
- Drop changes to mlx4_en_dcbnl_set_all()
- Don't call mlx4_en_update_pfc_stats_bitmap()]
---
drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c +14 -9
@@ -162,6 +162,7 @@ static int mlx4_en_dcbnl_ieee_setpfc(strstruct mlx4_en_priv *priv =netdev_priv (dev);struct mlx4_en_port_profile *prof = priv->prof;struct mlx4_en_dev *mdev = priv->mdev; +u32 tx_pause, tx_ppp, rx_pause, rx_ppp;int err; en_dbg(DRV, priv, "cap: 0x%x en: 0x%x mbc: 0x%x delay: %d\n",
@@ -170,19 +171,23 @@ static int mlx4_en_dcbnl_ieee_setpfc(str pfc->mbc, pfc->delay); - prof->rx_pause = !pfc->pfc_en; - prof->tx_pause = !pfc->pfc_en; - prof->rx_ppp = pfc->pfc_en; - prof->tx_ppp = pfc->pfc_en; + rx_pause = prof->rx_pause && !pfc->pfc_en; + tx_pause = prof->tx_pause && !pfc->pfc_en; + rx_ppp = pfc->pfc_en; + tx_ppp = pfc->pfc_en; err =mlx4_SET_PORT_general (mdev->dev, priv->port, priv->rx_skb_size +ETH_FCS_LEN , - prof->tx_pause, - prof->tx_ppp, - prof->rx_pause, - prof->rx_ppp); -if (err) + tx_pause, tx_ppp, rx_pause, rx_ppp); +if (err) {en_err (priv,"Failed setting pause params\n" ); +return err; + } + + prof->tx_ppp = tx_ppp; + prof->rx_ppp = rx_ppp; + prof->rx_pause = rx_pause; + prof->tx_pause = tx_pause;return err; }
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c +16 -8
@@ -474,21 +474,29 @@ static int mlx4_en_set_pauseparam(struct {struct mlx4_en_priv *priv =netdev_priv (dev);struct mlx4_en_dev *mdev = priv->mdev; +u8 tx_pause, tx_ppp, rx_pause, rx_ppp;int err;if (pause->autoneg)return -EINVAL ; - priv->prof->tx_pause = pause->tx_pause !=0 ; - priv->prof->rx_pause = pause->rx_pause !=0 ; + tx_pause = !!(pause->tx_pause); + rx_pause = !!(pause->rx_pause); + rx_ppp = priv->prof->rx_ppp && !(tx_pause || rx_pause); + tx_ppp = priv->prof->tx_ppp && !(tx_pause || rx_pause); + err =mlx4_SET_PORT_general (mdev->dev, priv->port, priv->rx_skb_size +ETH_FCS_LEN , - priv->prof->tx_pause, - priv->prof->tx_ppp, - priv->prof->rx_pause, - priv->prof->rx_ppp); -if (err) -en_err (priv,"Failed setting pause params\n" ); + tx_pause, tx_ppp, rx_pause, rx_ppp); +if (err) { +en_err (priv,"Failed setting pause params, err = %d\n" , err); +return err; + } + + priv->prof->tx_pause = tx_pause; + priv->prof->rx_pause = rx_pause; + priv->prof->tx_ppp = tx_ppp; + priv->prof->rx_ppp = rx_ppp;return err; }
drivers/net/ethernet/mellanox/mlx4/en_main.c +2 -2
@@ -137,9 +137,9 @@ static int mlx4_en_get_profile(struct ml params->udp_rss =0 ; }for (i =1 ; i <=MLX4_MAX_PORTS ; i++) { - params->prof[i].rx_pause =1 ; + params->prof[i].rx_pause = !(pfcrx || pfctx); params->prof[i].rx_ppp = pfcrx; - params->prof[i].tx_pause =1 ; + params->prof[i].tx_pause = !(pfcrx || pfctx); params->prof[i].tx_ppp = pfctx; params->prof[i].tx_ring_size =MLX4_EN_DEF_TX_RING_SIZE ; params->prof[i].rx_ring_size =MLX4_EN_DEF_RX_RING_SIZE ;
PATCH 407/410 RDMA/ucma: Check that device is connected prior to access it
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
commit 4b658d1bbc16605330694bb3ef2570c465ef383d upstream.
Add missing check that device is connected prior to access it.
[ 55.358652] BUG: KASAN: null-ptr-deref in rdma_init_qp_attr+0x4a/0x2c0 [ 55.359389] Read of size 8 at addr 00000000000000b0 by task qp/618 [ 55.360255] [ 55.360432] CPU: 1 PID: 618 Comm: qp Not tainted 4.16.0-rc1-00071-gcaf61b1b8b88 #91 [ 55.361693] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.11.0-0-g63451fca13-prebuilt.qemu-project.org 04/01/2014 [ 55.363264] Call Trace: [ 55.363833] dump_stack+0x5c/0x77 [ 55.364215] kasan_report+0x163/0x380 [ 55.364610] ? rdma_init_qp_attr+0x4a/0x2c0 [ 55.365238] rdma_init_qp_attr+0x4a/0x2c0 [ 55.366410] ucma_init_qp_attr+0x111/0x200 [ 55.366846] ? ucma_notify+0xf0/0xf0 [ 55.367405] ? _get_random_bytes+0xea/0x1b0 [ 55.367846] ? urandom_read+0x2f0/0x2f0 [ 55.368436] ? kmem_cache_alloc_trace+0xd2/0x1e0 [ 55.369104] ? refcount_inc_not_zero+0x9/0x60 [ 55.369583] ? refcount_inc+0x5/0x30 [ 55.370155] ? rdma_create_id+0x215/0x240 [ 55.370937] ? _copy_to_user+0x4f/0x60 [ 55.371620] ? mem_cgroup_commit_charge+0x1f5/0x290 [ 55.372127] ? _copy_from_user+0x5e/0x90 [ 55.372720] ucma_write+0x174/0x1f0 [ 55.373090] ? ucma_close_id+0x40/0x40 [ 55.373805] ? __lru_cache_add+0xa8/0xd0 [ 55.374403] __vfs_write+0xc4/0x350 [ 55.374774] ? kernel_read+0xa0/0xa0 [ 55.375173] ? fsnotify+0x899/0x8f0 [ 55.375544] ? fsnotify_unmount_inodes+0x170/0x170 [ 55.376689] ? __fsnotify_update_child_dentry_flags+0x30/0x30 [ 55.377522] ? handle_mm_fault+0x174/0x320 [ 55.378169] vfs_write+0xf7/0x280 [ 55.378864] SyS_write+0xa1/0x120 [ 55.379270] ? SyS_read+0x120/0x120 [ 55.379643] ? mm_fault_error+0x180/0x180 [ 55.380071] ? task_work_run+0x7d/0xd0 [ 55.380910] ? __task_pid_nr_ns+0x120/0x140 [ 55.381366] ? SyS_read+0x120/0x120 [ 55.381739] do_syscall_64+0xeb/0x250 [ 55.382143] entry_SYSCALL_64_after_hwframe+0x21/0x86 [ 55.382841] RIP: 0033:0x7fc2ef803e99 [ 55.383227] RSP: 002b:00007fffcc5f3be8 EFLAGS: 00000217 ORIG_RAX: 0000000000000001 [ 55.384173] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fc2ef803e99 [ 55.386145] RDX: 0000000000000057 RSI: 0000000020000080 RDI: 0000000000000003 [ 55.388418] RBP: 00007fffcc5f3c00 R08: 0000000000000000 R09: 0000000000000000 [ 55.390542] R10: 0000000000000000 R11: 0000000000000217 R12: 0000000000400480 [ 55.392916] R13: 00007fffcc5f3cf0 R14: 0000000000000000 R15: 0000000000000000 [ 55.521088] Code: e5 4d 1e ff 48 89 df 44 0f b6 b3 b8 01 00 00 e8 65 50 1e ff 4c 8b 2b 49 8d bd b0 00 00 00 e8 56 50 1e ff 41 0f b6 c6 48 c1 e0 04 <49> 03 85 b0 00 00 00 48 8d 78 08 48 89 04 24 e8 3a 4f 1e ff 48 [ 55.525980] RIP: rdma_init_qp_attr+0x52/0x2c0 RSP: ffff8801e2c2f9d8 [ 55.532648] CR2: 00000000000000b0 [ 55.534396] ---[ end trace 70cee64090251c0b ]---
--- drivers/infiniband/core/ucma.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/infiniband/core/ucma.c +5 -0
@@ -1067,6 +1067,11 @@ static ssize_t ucma_init_qp_attr(structif (IS_ERR (ctx))return PTR_ERR (ctx); +if (!ctx->cm_id->device) { + ret = -EINVAL ; + goto out; + } + resp.qp_attr_mask =0 ;memset (&qp_attr,0 ,sizeof qp_attr); qp_attr.qp_state = cmd.qp_state;
PATCH 408/410 RDMA/ucma: Check that device exists prior to accessing it
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
commit c8d3bcbfc5eab3f01cf373d039af725f3b488813 upstream.
Ensure that device exists prior to accessing its properties.
--- drivers/infiniband/core/ucma.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/infiniband/core/ucma.c +4 -2
@@ -1229,7 +1229,7 @@ static ssize_t ucma_notify(struct ucma_f {struct rdma_ucm_notify cmd;struct ucma_context *ctx; -int ret; +int ret = -EINVAL ;if (copy_from_user (&cmd, inbuf,sizeof (cmd)))return -EFAULT ;
@@ -1238,7 +1238,9 @@ static ssize_t ucma_notify(struct ucma_fif (IS_ERR (ctx))return PTR_ERR (ctx); - ret =rdma_notify (ctx->cm_id, (enum ib_event_type ) cmd.event); +if (ctx->cm_id->device) + ret =rdma_notify (ctx->cm_id, (enum ib_event_type )cmd.event); +ucma_put_ctx (ctx);return ret; }
PATCH 409/410 mtd: jedec_probe: Fix crash in jedec_read_mfr()
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
commit 87a73eb5b56fd6e07c8e499fe8608ef2d8912b82 upstream.
It turns out that the loop where we read manufacturer jedec_read_mfd() can under some circumstances get a CFI_MFR_CONTINUATION repeatedly, making the loop go over all banks and eventually hit the end of the map and crash because of an access violation:
Unable to handle kernel paging request at virtual address c4980000 pgd = (ptrval) [c4980000] *pgd=03808811, *pte=00000000, *ppte=00000000 Internal error: Oops: 7 [#1] PREEMPT ARM CPU: 0 PID: 1 Comm: swapper Not tainted 4.16.0-rc1+ #150 Hardware name: Gemini (Device Tree) PC is at jedec_probe_chip+0x6ec/0xcd0 LR is at 0x4 pc : [<c03a2bf4>] lr : [<00000004>] psr: 60000013
sp : c382dd18 ip : 0000ffff fp : 00000000
r10: c0626388 r9 : 00020000 r8 : c0626340
r7 : 00000000 r6 : 00000001 r5 : c3a71afc r4 : c382dd70 r3 : 00000001 r2 : c4900000 r1 : 00000002 r0 : 00080000
Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none
Control: 0000397f Table: 00004000 DAC: 00000053 Process swapper (pid: 1, stack limit = 0x(ptrval))
Fix this by breaking the loop with a return 0 if
the offset exceeds the map size.
--- drivers/mtd/chips/jedec_probe.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mtd/chips/jedec_probe.c +2 -0
@@ -1889,6 +1889,8 @@ static inline u32 jedec_read_mfr(structdo {uint32_t ofs =cfi_build_cmd_addr (0 + (bank <<8 ), map, cfi); mask = (1 << (cfi->device_type *8 )) -1 ; +if (ofs >= map->size) +return 0 ; result =map_read (map, base + ofs); bank++; }while ((result.x[0 ] & mask) ==CFI_MFR_CONTINUATION );
PATCH 410/410 net: Fix untag for vlan packets without ethernet header
In reply to Ben Hutchings3.16.57-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Toshiaki Makita <[email protected]>
commit ae4745730cf8e693d354ccd4dbaf59ea440c09a9 upstream.
In some situation vlan packets do not have ethernet headers. One example is packets from tun devices. Users can specify vlan protocol in tun_pi field instead of IP protocol, and skb_vlan_untag() attempts to untag such packets.
skb_vlan_untag() (more precisely, skb_reorder_vlan_header() called by it) however did not expect packets without ethernet headers, so in such a case size argument for memmove() underflowed and triggered crash.
====
BUG: unable to handle kernel paging request at ffff8801cccb8000 IP: __memmove+0x24/0x1a0 arch/x86/lib/memmove_64.S:43 PGD 9cee067 P4D 9cee067 PUD 1d9401063 PMD 1cccb7063 PTE 2810100028101 Oops: 000b [#1] SMP KASAN Dumping ftrace buffer: (ftrace buffer empty) Modules linked in: CPU: 1 PID: 17663 Comm: syz-executor2 Not tainted 4.16.0-rc7+ #368 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 RIP: 0010:__memmove+0x24/0x1a0 arch/x86/lib/memmove_64.S:43 RSP: 0018:ffff8801cc046e28 EFLAGS: 00010287 RAX: ffff8801ccc244c4 RBX: fffffffffffffffe RCX: fffffffffff6c4c2 RDX: fffffffffffffffe RSI: ffff8801cccb7ffc RDI: ffff8801cccb8000 RBP: ffff8801cc046e48 R08: ffff8801ccc244be R09: ffffed0039984899 R10: 0000000000000001 R11: ffffed0039984898 R12: ffff8801ccc244c4 R13: ffff8801ccc244c0 R14: ffff8801d96b7c06 R15: ffff8801d96b7b40 FS: 00007febd562d700(0000) GS:ffff8801db300000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffff8801cccb8000 CR3: 00000001ccb2f006 CR4: 00000000001606e0 DR0: 0000000020000000 DR1: 0000000020000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000600 Call Trace: memmove include/linux/string.h:360 [inline] skb_reorder_vlan_header net/core/skbuff.c:5031 [inline] skb_vlan_untag+0x470/0xc40 net/core/skbuff.c:5061 __netif_receive_skb_core+0x119c/0x3460 net/core/dev.c:4460 __netif_receive_skb+0x2c/0x1b0 net/core/dev.c:4627 netif_receive_skb_internal+0x10b/0x670 net/core/dev.c:4701 netif_receive_skb+0xae/0x390 net/core/dev.c:4725 tun_rx_batched.isra.50+0x5ee/0x870 drivers/net/tun.c:1555 tun_get_user+0x299e/0x3c20 drivers/net/tun.c:1962 tun_chr_write_iter+0xb9/0x160 drivers/net/tun.c:1990 call_write_iter include/linux/fs.h:1782 [inline] new_sync_write fs/read_write.c:469 [inline] __vfs_write+0x684/0x970 fs/read_write.c:482 vfs_write+0x189/0x510 fs/read_write.c:544 SYSC_write fs/read_write.c:589 [inline] SyS_write+0xef/0x220 fs/read_write.c:581 do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287 entry_SYSCALL_64_after_hwframe+0x42/0xb7 RIP: 0033:0x454879 RSP: 002b:00007febd562cc68 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007febd562d6d4 RCX: 0000000000454879 RDX: 0000000000000157 RSI: 0000000020000180 RDI: 0000000000000014 RBP: 000000000072bea0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff R13: 00000000000006b0 R14: 00000000006fc120 R15: 0000000000000000 Code: 90 90 90 90 90 90 90 48 89 f8 48 83 fa 20 0f 82 03 01 00 00 48 39 fe 7d 0f 49 89 f0 49 01 d0 49 39 f8 0f 8f 9f 00 00 00 48 89 d1 <f3> a4 c3 48 81 fa a8 02 00 00 72 05 40 38 fe 74 3b 48 83 ea 20 RIP: __memmove+0x24/0x1a0 arch/x86/lib/memmove_64.S:43 RSP: ffff8801cc046e28
CR2: ffff8801cccb8000
====
We don't need to copy headers for packets which do not have preceding headers of vlan headers, so skip memmove() in that case.
--- net/core/skbuff.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/core/skbuff.c +4 -2
@@ -4002,8 +4002,10 @@ static struct sk_buff *skb_reorder_vlan_ } mac_len = skb->data -skb_mac_header (skb); -memmove (skb_mac_header (skb) +VLAN_HLEN ,skb_mac_header (skb), - mac_len -VLAN_HLEN -ETH_TLEN ); +if (likely (mac_len >VLAN_HLEN +ETH_TLEN )) { +memmove (skb_mac_header (skb) +VLAN_HLEN ,skb_mac_header (skb), + mac_len -VLAN_HLEN -ETH_TLEN ); + } skb->mac_header +=VLAN_HLEN ;return skb; }
Quoted 8 lines · Ben Hutchings
This is the start of the stable review cycle for the 3.16.57 release. There are 410 patches in this series, which will be posted as responses to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu Jun 14 18:00:00 UTC 2018. Anything received after that time might be too late.
Build results:
total: 138 pass: 136 fail: 2 Failed builds: i386:tools/perf x86_64:tools/perf Qemu test results: total: 116 pass: 116 fail: 0
tools/perf builds are new, so it is probably not entirely surprising that they fail.
Deetails are available at http://kerneltests.org/builders/.
Guenter
Quoted 18 lines · Guenter Roeck
Quoted 8 lines · Ben Hutchings
This is the start of the stable review cycle for the 3.16.57 release. There are 410 patches in this series, which will be posted as responses to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu Jun 14 18:00:00 UTC 2018. Anything received after that time might be too late.
Build results:
total: 138 pass: 136 fail: 2 Failed builds: i386:tools/perf x86_64:tools/perf Qemu test results: total: 116 pass: 116 fail: 0
Quoted 4 lines
tools/perfbuilds are new, so it is probably not entirely surprising that they fail.Deetails are available at http://kerneltests.org/builders/.
Thanks for testing. I see you've now made the tools/perf builds work for 3.16, so thanks for that as well.
Ben.
Signature · 3 lines
Ben Hutchings
The generation of random numbers is too important to be left to chance.
- Robert CoveyouQuoted 19 lines · Ben Hutchings
Quoted 18 lines · Guenter Roeck
Quoted 8 lines · Ben Hutchings
This is the start of the stable review cycle for the 3.16.57 release. There are 410 patches in this series, which will be posted as responses to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu Jun 14 18:00:00 UTC 2018. Anything received after that time might be too late.
Build results:
total: 138 pass: 136 fail: 2 Failed builds: i386:tools/perf x86_64:tools/perf Qemu test results: total: 116 pass: 116 fail: 0
Quoted 7 lines
Quoted 4 lines
tools/perfbuilds are new, so it is probably not entirely surprising that they fail.Deetails are available at http://kerneltests.org/builders/.
Thanks for testing. I see you've now made the
tools/perfbuilds work for 3.16, so thanks for that as well.
I looked again and for the current patch queue I see:
Building i386:tools/perf ... failed (script) - skipping
Building x86_64:tools/perf ... failed (script) - skipping
I can still build it here in a Debian jessie environment though.
Ben.
Signature · 3 lines
Ben Hutchings Kids! Bringing about Armageddon can be dangerous. Do not attempt it in your own home. - Terry Pratchett and Neil Gaiman, `Good Omens'
Quoted 25 lines · Ben Hutchings
Quoted 24 lines · Ben Hutchings
Quoted 22 lines · Guenter Roeck
Quoted 8 lines · Ben Hutchings
This is the start of the stable review cycle for the 3.16.57 release. There are 410 patches in this series, which will be posted as responses to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu Jun 14 18:00:00 UTC 2018. Anything received after that time might be too late.
Build results:
total: 138 pass: 136 fail: 2 Failed builds: i386:tools/perf x86_64:tools/perf Qemu test results: total: 116 pass: 116 fail: 0
tools/perfbuilds are new, so it is probably not entirely surprising that they fail.Deetails are available at http://kerneltests.org/builders/.
Quoted 9 lines
Quoted 2 lines
Thanks for testing. I see you've now made the
tools/perfbuilds work for 3.16, so thanks for that as well.I looked again and for the current patch queue I see:
Building i386:tools/perf ... failed (script) - skipping
Building x86_64:tools/perf ... failed (script) - skipping
perf builds are currently skipped in 3.16. Let me check if I can drop that.
Guenter
Quoted 28 lines · Ben Hutchings
Quoted 19 lines · Ben Hutchings
Quoted 18 lines · Guenter Roeck
Quoted 8 lines · Ben Hutchings
This is the start of the stable review cycle for the 3.16.57 release. There are 410 patches in this series, which will be posted as responses to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu Jun 14 18:00:00 UTC 2018. Anything received after that time might be too late.
Build results:
total: 138 pass: 136 fail: 2 Failed builds: i386:tools/perf x86_64:tools/perf Qemu test results: total: 116 pass: 116 fail: 0Quoted 7 lines
Quoted 4 lines
tools/perfbuilds are new, so it is probably not entirely surprising that they fail.Deetails are available at http://kerneltests.org/builders/.
Thanks for testing. I see you've now made the
tools/perfbuilds work for 3.16, so thanks for that as well.
Quoted 8 lines
I looked again and for the current patch queue I see:
Building i386:tools/perf ... failed (script) - skipping
Building x86_64:tools/perf ... failed (script) - skipping
I can still build it here in a Debian jessie environment though.
I re-enabled it, but now it fails. Let me know if you want to try to fix it. Probably something with out-of-tree build - I didn't try to find the reason.
Please ignore the arm qemu failures - I restructured the tests, and need to make some fixes.
Guenter
Quoted 33 lines · Guenter Roeck
Quoted 32 lines · Ben Hutchings
Quoted 19 lines · Ben Hutchings
Quoted 18 lines · Guenter Roeck
Quoted 8 lines · Ben Hutchings
This is the start of the stable review cycle for the 3.16.57 release. There are 410 patches in this series, which will be posted as responses to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu Jun 14 18:00:00 UTC 2018. Anything received after that time might be too late.
Build results:
total: 138 pass: 136 fail: 2 Failed builds: i386:tools/perf x86_64:tools/perf Qemu test results: total: 116 pass: 116 fail: 0Quoted 7 lines
Quoted 4 lines
tools/perfbuilds are new, so it is probably not entirely surprising that they fail.Deetails are available at http://kerneltests.org/builders/.
Thanks for testing. I see you've now made the
tools/perfbuilds work for 3.16, so thanks for that as well.I looked again and for the current patch queue I see:
Building i386:tools/perf ... failed (script) - skipping
Quoted 7 lines
Quoted 4 lines
Building x86_64:tools/perf ... failed (script) - skipping
I can still build it here in a Debian jessie environment though.
I re-enabled it, but now it fails. Let me know if you want to try to fix it. Probably something with out-of-tree build - I didn't try to find the reason.
Thanks. I can reproduce the failure when building in Debian unstable, and am working through fixing the problems.
Ben.
Quoted 4 lines
Please ignore the arm qemu failures - I restructured the tests, and need to make some fixes.
Guenter
Signature · 2 lines
Ben Hutchings Humans are not rational beings; they are rationalising beings.
Quoted 1 line · Ben Hutchings
On Sun, Nov 11, 2018 at 08:23:43AM -0800, Guenter Roeck wrote:
[...]
Quoted 6 lines
Quoted 3 lines
I re-enabled it, but now it fails. Let me know if you want to try to fix it. Probably something with out-of-tree build - I didn't try to find the reason.
Thanks. I can reproduce the failure when building in Debian unstable, and am working through fixing the problems.
I fixed most of them. Two of the problems still (potentially) exist in mainline so I'll send patches for those and wait for those to come back to stable.
In the mean time, please can you build perf with WERROR=0?
Ben.
Signature · 2 lines
Ben Hutchings Reality is just a crutch for people who can't handle science fiction.
Quoted 7 lines · Ben Hutchings
Quoted 1 line · Ben Hutchings
On Sun, Nov 11, 2018 at 08:23:43AM -0800, Guenter Roeck wrote:
[...]
Quoted 4 lines
Quoted 3 lines
I re-enabled it, but now it fails. Let me know if you want to try to fix it. Probably something with out-of-tree build - I didn't try to find the reason.
Quoted 9 lines
Quoted 2 lines
Thanks. I can reproduce the failure when building in Debian unstable, and am working through fixing the problems.
I fixed most of them. Two of the problems still (potentially) exist in mainline so I'll send patches for those and wait for those to come back to stable.
In the mean time, please can you build perf with WERROR=0?
Done. It still fails to build, though (SYS_futex undeclared).
Thanks,
Guenter