5.4.19-stable review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 20/309 netdevsim: fix stack-out-of-bounds in nsim_dev_debugfs_init()
In reply to Greg Kroah-HartmanFrom: Taehee Yoo <[email protected]>
[ Upstream commit 6fb8852b1298200da39bd85788bc5755d1d56f32 ]
When netdevsim dev is being created, a debugfs directory is created. The variable "dev_ddir_name" is 16bytes device name pointer and device name is "netdevsim<dev id>".
The maximum dev id length is 10.
So, 16bytes for device name isn't enough.
Test commands:
modprobe netdevsim
echo "1000000000 0" > /sys/bus/netdevsim/new_deviceSplat looks like:
[ 249.622710][ T900] BUG: KASAN: stack-out-of-bounds in number+0x824/0x880 [ 249.623658][ T900] Write of size 1 at addr ffff88804c527988 by task bash/900 [ 249.624521][ T900] [ 249.624830][ T900] CPU: 1 PID: 900 Comm: bash Not tainted 5.5.0+ #322 [ 249.625691][ T900] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 [ 249.626712][ T900] Call Trace: [ 249.627103][ T900] dump_stack+0x96/0xdb [ 249.627639][ T900] ? number+0x824/0x880 [ 249.628173][ T900] print_address_description.constprop.5+0x1be/0x360 [ 249.629022][ T900] ? number+0x824/0x880 [ 249.629569][ T900] ? number+0x824/0x880 [ 249.630105][ T900] __kasan_report+0x12a/0x170 [ 249.630717][ T900] ? number+0x824/0x880 [ 249.631201][ T900] kasan_report+0xe/0x20 [ 249.631723][ T900] number+0x824/0x880 [ 249.632235][ T900] ? put_dec+0xa0/0xa0 [ 249.632716][ T900] ? rcu_read_lock_sched_held+0x90/0xc0 [ 249.633392][ T900] vsnprintf+0x63c/0x10b0 [ 249.633983][ T900] ? pointer+0x5b0/0x5b0 [ 249.634543][ T900] ? mark_lock+0x11d/0xc40 [ 249.635200][ T900] sprintf+0x9b/0xd0 [ 249.635750][ T900] ? scnprintf+0xe0/0xe0 [ 249.636370][ T900] nsim_dev_probe+0x63c/0xbf0 [netdevsim]
[ ... ]
--- drivers/net/netdevsim/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/netdevsim/dev.c +1 -1
@@ -73,7 +73,7 @@ static const struct file_operations nsimstatic int nsim_dev_debugfs_init (struct nsim_dev *nsim_dev) { -char dev_ddir_name[16 ]; +char dev_ddir_name[sizeof (DRV_NAME ) +10 ];sprintf (dev_ddir_name,DRV_NAME "%u" , nsim_dev->nsim_bus_dev->dev.id); nsim_dev->ddir =debugfs_create_dir (dev_ddir_name, nsim_dev_ddir);
Greg Kroah-Hartman
maintainerPATCH 22/309 media: uvcvideo: Avoid cyclic entity chains due to malformed USB descriptors
In reply to Greg Kroah-HartmanFrom: Will Deacon <[email protected]>
commit 68035c80e129c4cfec659aac4180354530b26527 upstream.
Way back in 2017, fuzzing the 4.14-rc2 USB stack with syzkaller kicked up the following WARNING from the UVC chain scanning code:
| list_add double add: new=ffff880069084010, prev=ffff880069084010, | next=ffff880067d22298. | ------------[ cut here ]------------ | WARNING: CPU: 1 PID: 1846 at lib/list_debug.c:31 __list_add_valid+0xbd/0xf0 | Modules linked in: | CPU: 1 PID: 1846 Comm: kworker/1:2 Not tainted | 4.14.0-rc2-42613-g1488251d1a98 #238 | Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 | Workqueue: usb_hub_wq hub_event | task: ffff88006b01ca40 task.stack: ffff880064358000 | RIP: 0010:__list_add_valid+0xbd/0xf0 lib/list_debug.c:29 | RSP: 0018:ffff88006435ddd0 EFLAGS: 00010286 | RAX: 0000000000000058 RBX: ffff880067d22298 RCX: 0000000000000000 | RDX: 0000000000000058 RSI: ffffffff85a58800 RDI: ffffed000c86bbac | RBP: ffff88006435dde8 R08: 1ffff1000c86ba52 R09: 0000000000000000 | R10: 0000000000000002 R11: 0000000000000000 R12: ffff880069084010 | R13: ffff880067d22298 R14: ffff880069084010 R15: ffff880067d222a0 | FS: 0000000000000000(0000) GS:ffff88006c900000(0000) knlGS:0000000000000000 | CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 | CR2: 0000000020004ff2 CR3: 000000006b447000 CR4: 00000000000006e0 | Call Trace: | __list_add ./include/linux/list.h:59 | list_add_tail+0x8c/0x1b0 ./include/linux/list.h:92 | uvc_scan_chain_forward.isra.8+0x373/0x416 | drivers/media/usb/uvc/uvc_driver.c:1471 | uvc_scan_chain drivers/media/usb/uvc/uvc_driver.c:1585 | uvc_scan_device drivers/media/usb/uvc/uvc_driver.c:1769 | uvc_probe+0x77f2/0x8f00 drivers/media/usb/uvc/uvc_driver.c:2104
Looking into the output from usbmon, the interesting part is the following data packet:
ffff880069c63e00 30710169 C Ci:1:002:0 0 143 = 09028f00 01030080 00090403 00000e01 00000924 03000103 7c003328 010204db
If we drop the lead configuration and interface descriptors, we're left with an output terminal descriptor describing a generic display:
/* Output terminal descriptor */
buf[0] 09
buf[1] 24
buf[2] 03 /* UVC_VC_OUTPUT_TERMINAL */
buf[3] 00 /* ID */
buf[4] 01 /* type == 0x0301 (UVC_OTT_DISPLAY) */
buf[5] 03
buf[6] 7c
buf[7] 00 /* source ID refers to self! */
buf[8] 33
The problem with this descriptor is that it is self-referential: the source ID of 0 matches itself! This causes the 'struct uvc_entity' representing the display to be added to its chain list twice during 'uvc_scan_chain()': once via 'uvc_scan_chain_entity()' when it is processed directly from the 'dev->entities' list and then again immediately afterwards when trying to follow the source ID in 'uvc_scan_chain_forward()'
Add a check before adding an entity to a chain list to ensure that the entity is not already part of a chain.
--- drivers/media/usb/uvc/uvc_driver.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/media/usb/uvc/uvc_driver.c +12 -0
@@ -1493,6 +1493,11 @@ static int uvc_scan_chain_forward(structbreak ;if (forward == prev)continue ; +if (forward->chain.next || forward->chain.prev) { +uvc_trace (UVC_TRACE_DESCR ,"Found reference to " +"entity %d already in chain.\n" , forward->id); +return -EINVAL ; + }switch (UVC_ENTITY_TYPE (forward)) {case UVC_VC_EXTENSION_UNIT :
@@ -1574,6 +1579,13 @@ static int uvc_scan_chain_backward(strucreturn -1 ; } +if (term->chain.next || term->chain.prev) { +uvc_trace (UVC_TRACE_DESCR ,"Found reference to " +"entity %d already in chain.\n" , + term->id); +return -EINVAL ; + } +if (uvc_trace_param &UVC_TRACE_PROBE )printk (KERN_CONT " %d" , term->id);
Greg Kroah-Hartman
maintainerPATCH 25/309 ipc/msg.c: consolidate all xxxctl_down() functions
In reply to Greg Kroah-HartmanFrom: Lu Shuaibing <[email protected]>
commit 889b331724c82c11e15ba0a60979cf7bded0a26c upstream.
A use of uninitialized memory in msgctl_down() because msqid64 in ksys_msgctl hasn't been initialized. The local | msqid64 | is created in ksys_msgctl() and then passed into msgctl_down(). Along the way msqid64 is never initialized before msgctl_down() checks msqid64->msg_qbytes.
KUMSAN(KernelUninitializedMemorySantizer, a new error detection tool) reports:
==================================================================
BUG: KUMSAN: use of uninitialized memory in msgctl_down+0x94/0x300 Read of size 8 at addr ffff88806bb97eb8 by task syz-executor707/2022 CPU: 0 PID: 2022 Comm: syz-executor707 Not tainted 5.2.0-rc4+ #63 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014 Call Trace: dump_stack+0x75/0xae __kumsan_report+0x17c/0x3e6 kumsan_report+0xe/0x20 msgctl_down+0x94/0x300 ksys_msgctl.constprop.14+0xef/0x260 do_syscall_64+0x7e/0x1f0 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x4400e9 Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 fb 13 fc ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007ffd869e0598 EFLAGS: 00000246 ORIG_RAX: 0000000000000047 RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 00000000004400e9 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: 00000000006ca018 R08: 0000000000000000 R09: 0000000000000000 R10: 00000000ffffffff R11: 0000000000000246 R12: 0000000000401970 R13: 0000000000401a00 R14: 0000000000000000 R15: 0000000000000000 The buggy address belongs to the page: page:ffffea0001aee5c0 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 flags: 0x100000000000000() raw: 0100000000000000 0000000000000000 ffffffff01ae0101 0000000000000000 raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000 page dumped because: kumsan: bad access detected ==================================================================
Syzkaller reproducer:
msgctl$IPC_RMID(0x0, 0x0)
C reproducer:
// autogenerated by syzkaller (https://github.com/google/syzkaller)
int main(void)
{
syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); syscall(__NR_msgctl, 0, 0, 0);
return 0;
}
From: Andrew Morton <[email protected]>
Subject: [PATCH 5.4 025/309] ipc/msg.c: consolidate all xxxctl_down() functions
Each line here overflows 80 cols by exactly one character. Delete one tab per line to fix.
--- ipc/msg.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
ipc/msg.c +10 -9
@@ -377,7 +377,7 @@ copy_msqid_from_user(struct msqid64_ds ** NOTE: no locks must be held, the rwsem is taken inside this function. */ static int msgctl_down (struct ipc_namespace *ns,int msqid,int cmd, -struct msqid64_ds *msqid64) +struct ipc64_perm *perm,int msg_qbytes) {struct kern_ipc_perm *ipcp;struct msg_queue *msq;
@@ -387,7 +387,7 @@ static int msgctl_down(struct ipc_namesprcu_read_lock (); ipcp =ipcctl_obtain_check (ns, &msg_ids (ns), msqid, cmd, - &msqid64->msg_perm, msqid64->msg_qbytes); + perm, msg_qbytes);if (IS_ERR (ipcp)) { err =PTR_ERR (ipcp); goto out_unlock1;
@@ -409,18 +409,18 @@ static int msgctl_down(struct ipc_namesp {DEFINE_WAKE_Q (wake_q); -if (msqid64->msg_qbytes > ns->msg_ctlmnb && +if (msg_qbytes > ns->msg_ctlmnb && !capable (CAP_SYS_RESOURCE )) { err = -EPERM ; goto out_unlock1; }ipc_lock_object (&msq->q_perm); - err =ipc_update_perm (&msqid64->msg_perm, ipcp); + err =ipc_update_perm (perm, ipcp);if (err) goto out_unlock0; - msq->q_qbytes = msqid64->msg_qbytes; + msq->q_qbytes = msg_qbytes; msq->q_ctime =ktime_get_real_seconds ();/*
@@ -601,9 +601,10 @@ static long ksys_msgctl(int msqid, int ccase IPC_SET :if (copy_msqid_from_user (&msqid64, buf, version))return -EFAULT ; -/* fallthru */ +return msgctl_down (ns, msqid, cmd, &msqid64.msg_perm, + msqid64.msg_qbytes);case IPC_RMID : -return msgctl_down (ns, msqid, cmd, &msqid64); +return msgctl_down (ns, msqid, cmd,NULL ,0 );default :return -EINVAL ; }
@@ -735,9 +736,9 @@ static long compat_ksys_msgctl(int msqidcase IPC_SET :if (copy_compat_msqid_from_user (&msqid64, uptr, version))return -EFAULT ; -/* fallthru */ +return msgctl_down (ns, msqid, cmd, &msqid64.msg_perm, msqid64.msg_qbytes);case IPC_RMID : -return msgctl_down (ns, msqid, cmd, &msqid64); +return msgctl_down (ns, msqid, cmd,NULL ,0 );default :return -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 28/309 rcu: Use *_ONCE() to protect lockless ->expmask accesses
In reply to Greg Kroah-HartmanFrom: Paul E. McKenney <[email protected]>
commit 15c7c972cd26d89a26788e609c53b5a465324a6c upstream.
The rcu_node structure's ->expmask field is accessed locklessly when starting a new expedited grace period and when reporting an expedited RCU CPU stall warning. This commit therefore handles the former by taking a snapshot of ->expmask while the lock is held and the latter by applying READ_ONCE() to lockless reads and WRITE_ONCE() to the corresponding updates.
--- kernel/rcu/tree_exp.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
kernel/rcu/tree_exp.h +9 -10
@@ -134,7 +134,7 @@ static void __maybe_unused sync_exp_resercu_for_each_node_breadth_first (rnp) {raw_spin_lock_irqsave_rcu_node (rnp, flags);WARN_ON_ONCE (rnp->expmask); - rnp->expmask = rnp->expmaskinit; +WRITE_ONCE (rnp->expmask, rnp->expmaskinit);raw_spin_unlock_irqrestore_rcu_node (rnp, flags); } }
@@ -211,7 +211,7 @@ static void __rcu_report_exp_rnp(struct rnp = rnp->parent;raw_spin_lock_rcu_node (rnp);/* irqs already disabled */ WARN_ON_ONCE (!(rnp->expmask & mask)); - rnp->expmask &= ~mask; +WRITE_ONCE (rnp->expmask, rnp->expmask & ~mask); } }
@@ -241,7 +241,7 @@ static void rcu_report_exp_cpu_mult(struraw_spin_unlock_irqrestore_rcu_node (rnp, flags);return ; } - rnp->expmask &= ~mask; +WRITE_ONCE (rnp->expmask, rnp->expmask & ~mask);__rcu_report_exp_rnp (rnp, wake, flags);/* Releases rnp->lock. */ }
@@ -372,12 +372,10 @@ static void sync_rcu_exp_select_node_cpuraw_spin_unlock_irqrestore_rcu_node (rnp, flags);/* IPI the remaining CPUs for expedited quiescent state. */ -for_each_leaf_node_cpu_mask (rnp, cpu, rnp->expmask) { +for_each_leaf_node_cpu_mask (rnp, cpu, mask_ofl_ipi) {unsigned long mask =leaf_node_cpu_bit (rnp, cpu);struct rcu_data *rdp =per_cpu_ptr (&rcu_data, cpu); -if (!(mask_ofl_ipi & mask)) -continue ; retry_ipi:if (rcu_dynticks_in_eqs_since (rdp, rdp->exp_dynticks_snap)) { mask_ofl_test |= mask;
@@ -491,7 +489,7 @@ static void synchronize_sched_expedited_struct rcu_data *rdp; mask =leaf_node_cpu_bit (rnp, cpu); -if (!(rnp->expmask & mask)) +if (!(READ_ONCE (rnp->expmask) & mask))continue ; ndetected++; rdp =per_cpu_ptr (&rcu_data, cpu);
@@ -503,7 +501,8 @@ static void synchronize_sched_expedited_ }pr_cont (" } %lu jiffies s: %lu root: %#lx/%c\n" , jiffies - jiffies_start, rcu_state.expedited_sequence, - rnp_root->expmask,".T" [!!rnp_root->exp_tasks]); +READ_ONCE (rnp_root->expmask), +".T" [!!rnp_root->exp_tasks]);if (ndetected) {pr_err ("blocking rcu_node structures:" );rcu_for_each_node_breadth_first (rnp) {
@@ -513,7 +512,7 @@ static void synchronize_sched_expedited_continue ;pr_cont (" l=%u:%d-%d:%#lx/%c" , rnp->level, rnp->grplo, rnp->grphi, - rnp->expmask, +READ_ONCE (rnp->expmask),".T" [!!rnp->exp_tasks]); }pr_cont ("\n" );
@@ -521,7 +520,7 @@ static void synchronize_sched_expedited_rcu_for_each_leaf_node (rnp) {for_each_leaf_node_possible_cpu (rnp, cpu) { mask =leaf_node_cpu_bit (rnp, cpu); -if (!(rnp->expmask & mask)) +if (!(READ_ONCE (rnp->expmask) & mask))continue ;dump_cpu_task (cpu); }
Greg Kroah-Hartman
maintainerPATCH 29/309 rcu: Avoid data-race in rcu_gp_fqs_check_wake()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
commit 6935c3983b246d5fbfebd3b891c825e65c118f2d upstream.
The rcu_gp_fqs_check_wake() function uses rcu_preempt_blocked_readers_cgp() to read ->gp_tasks while other cpus might overwrite this field.
We need READ_ONCE()/WRITE_ONCE() pairs to avoid compiler tricks and KCSAN splats like the following :
BUG: KCSAN: data-race in rcu_gp_fqs_check_wake / rcu_preempt_deferred_qs_irqrestore
write to 0xffffffff85a7f190 of 8 bytes by task 7317 on cpu 0:
rcu_preempt_deferred_qs_irqrestore+0x43d/0x580 kernel/rcu/tree_plugin.h:507 rcu_read_unlock_special+0xec/0x370 kernel/rcu/tree_plugin.h:659 __rcu_read_unlock+0xcf/0xe0 kernel/rcu/tree_plugin.h:394 rcu_read_unlock include/linux/rcupdate.h:645 [inline] __ip_queue_xmit+0x3b0/0xa40 net/ipv4/ip_output.c:533 ip_queue_xmit+0x45/0x60 include/net/ip.h:236 __tcp_transmit_skb+0xdeb/0x1cd0 net/ipv4/tcp_output.c:1158 __tcp_send_ack+0x246/0x300 net/ipv4/tcp_output.c:3685 tcp_send_ack+0x34/0x40 net/ipv4/tcp_output.c:3691 tcp_cleanup_rbuf+0x130/0x360 net/ipv4/tcp.c:1575 tcp_recvmsg+0x633/0x1a30 net/ipv4/tcp.c:2179 inet_recvmsg+0xbb/0x250 net/ipv4/af_inet.c:838 sock_recvmsg_nosec net/socket.c:871 [inline] sock_recvmsg net/socket.c:889 [inline] sock_recvmsg+0x92/0xb0 net/socket.c:885 sock_read_iter+0x15f/0x1e0 net/socket.c:967 call_read_iter include/linux/fs.h:1864 [inline] new_sync_read+0x389/0x4f0 fs/read_write.c:414
read to 0xffffffff85a7f190 of 8 bytes by task 10 on cpu 1:
rcu_gp_fqs_check_wake kernel/rcu/tree.c:1556 [inline] rcu_gp_fqs_check_wake+0x93/0xd0 kernel/rcu/tree.c:1546 rcu_gp_fqs_loop+0x36c/0x580 kernel/rcu/tree.c:1611 rcu_gp_kthread+0x143/0x220 kernel/rcu/tree.c:1768 kthread+0x1d4/0x200 drivers/block/aoe/aoecmd.c:1253 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:352
Reported by Kernel Concurrency Sanitizer on:
CPU: 1 PID: 10 Comm: rcu_preempt Not tainted 5.3.0+ #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
--- kernel/rcu/tree_plugin.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
kernel/rcu/tree_plugin.h +6 -5
@@ -220,7 +220,7 @@ static void rcu_preempt_ctxt_queue(struc* blocked tasks. */ if (!rnp->gp_tasks && (blkd_state &RCU_GP_BLKD )) { - rnp->gp_tasks = &t->rcu_node_entry; +WRITE_ONCE (rnp->gp_tasks, &t->rcu_node_entry);WARN_ON_ONCE (rnp->completedqs == rnp->gp_seq); }if (!rnp->exp_tasks && (blkd_state &RCU_EXP_BLKD ))
@@ -340,7 +340,7 @@ EXPORT_SYMBOL_GPL(rcu_note_context_switc*/ static int rcu_preempt_blocked_readers_cgp (struct rcu_node *rnp) { -return rnp->gp_tasks !=NULL ; +return READ_ONCE (rnp->gp_tasks) !=NULL ; }/* Bias and limit values for ->rcu_read_lock_nesting. */
@@ -493,7 +493,7 @@ rcu_preempt_deferred_qs_irqrestore(structrace_rcu_unlock_preempted_task (TPS ("rcu_preempt" ), rnp->gp_seq, t->pid);if (&t->rcu_node_entry == rnp->gp_tasks) - rnp->gp_tasks = np; +WRITE_ONCE (rnp->gp_tasks, np);if (&t->rcu_node_entry == rnp->exp_tasks) rnp->exp_tasks = np;if (IS_ENABLED (CONFIG_RCU_BOOST )) {
@@ -663,7 +663,7 @@ static void rcu_preempt_check_blocked_tadump_blkd_tasks (rnp,10 );if (rcu_preempt_has_tasks (rnp) && (rnp->qsmaskinit || rnp->wait_blkd_tasks)) { - rnp->gp_tasks = rnp->blkd_tasks.next; +WRITE_ONCE (rnp->gp_tasks, rnp->blkd_tasks.next); t = container_of(rnp->gp_tasks, struct task_struct, rcu_node_entry); trace_rcu_unlock_preempted_task(TPS("rcu_preempt-GPS"),
@@ -757,7 +757,8 @@ dump_blkd_tasks(struct rcu_node *rnp, inpr_info ("%s: %d:%d ->qsmask %#lx ->qsmaskinit %#lx ->qsmaskinitnext %#lx\n" , __func__, rnp1->grplo, rnp1->grphi, rnp1->qsmask, rnp1->qsmaskinit, rnp1->qsmaskinitnext);pr_info ("%s: ->gp_tasks %p ->boost_tasks %p ->exp_tasks %p\n" , - __func__, rnp->gp_tasks, rnp->boost_tasks, rnp->exp_tasks); + __func__,READ_ONCE (rnp->gp_tasks), rnp->boost_tasks, + rnp->exp_tasks);pr_info ("%s: ->blkd_tasks" , __func__); i =0 ;list_for_each (lhp, &rnp->blkd_tasks) {
Greg Kroah-Hartman
maintainerPATCH 5/309 l2tp: Allow duplicate session creation with UDP
In reply to Greg Kroah-HartmanFrom: Ridge Kennedy <[email protected]>
[ Upstream commit 0d0d9a388a858e271bb70e71e99e7fe2a6fd6f64 ]
In the past it was possible to create multiple L2TPv3 sessions with the same session id as long as the sessions belonged to different tunnels. The resulting sessions had issues when used with IP encapsulated tunnels, but worked fine with UDP encapsulated ones. Some applications began to rely on this behaviour to avoid having to negotiate unique session ids.
Some time ago a change was made to require session ids to be unique across all tunnels, breaking the applications making use of this "feature".
This change relaxes the duplicate session id check to allow duplicates if both of the colliding sessions belong to UDP encapsulated tunnels.
--- net/l2tp/l2tp_core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/l2tp/l2tp_core.c +6 -1
@@ -322,8 +322,13 @@ int l2tp_session_register(struct l2tp_sespin_lock_bh (&pn->l2tp_session_hlist_lock); +/* IP encap expects session IDs to be globally unique, while +* UDP encap doesn't. +*/ hlist_for_each_entry (session_walk, g_head, global_hlist) -if (session_walk->session_id == session->session_id) { +if (session_walk->session_id == session->session_id && + (session_walk->tunnel->encap ==L2TP_ENCAPTYPE_IP || + tunnel->encap ==L2TP_ENCAPTYPE_IP )) { err = -EEXIST ; goto err_tlock_pnlock; }
Greg Kroah-Hartman
maintainerPATCH 53/309 mm: thp: dont need care deferred split queue in memcg charge move path
In reply to Greg Kroah-HartmanFrom: Wei Yang <[email protected]>
commit fac0516b5534897bf4c4a88daa06a8cfa5611b23 upstream.
If compound is true, this means it is a PMD mapped THP. Which implies the page is not linked to any defer list. So the first code chunk will not be executed.
Also with this reason, it would not be proper to add this page to a defer list. So the second code chunk is not correct.
Based on this, we should remove the defer list related code.
--- mm/memcontrol.c | 18 ------------------ 1 file changed, 18 deletions(-)
mm/memcontrol.c +0 -18
@@ -5465,14 +5465,6 @@ static int mem_cgroup_move_account(struc__mod_lruvec_state (to_vec,NR_WRITEBACK , nr_pages); } -#ifdef CONFIG_TRANSPARENT_HUGEPAGE -if (compound && !list_empty (page_deferred_list (page))) { -spin_lock (&from->deferred_split_queue.split_queue_lock); -list_del_init (page_deferred_list (page)); - from->deferred_split_queue.split_queue_len--; -spin_unlock (&from->deferred_split_queue.split_queue_lock); - } -#endif /* * It is safe to change page->mem_cgroup here because the page * is referenced, charged, and isolated - we can't race with
@@ -5482,16 +5474,6 @@ static int mem_cgroup_move_account(struc/* caller should have done css_get */ page->mem_cgroup = to; -#ifdef CONFIG_TRANSPARENT_HUGEPAGE -if (compound &&list_empty (page_deferred_list (page))) { -spin_lock (&to->deferred_split_queue.split_queue_lock); -list_add_tail (page_deferred_list (page), - &to->deferred_split_queue.split_queue); - to->deferred_split_queue.split_queue_len++; -spin_unlock (&to->deferred_split_queue.split_queue_lock); - } -#endif -spin_unlock_irqrestore (&from->move_lock, flags); ret =0 ;
Greg Kroah-Hartman
maintainerPATCH 60/309 x86/cpu: Update cached HLE state on write to TSX_CTRL_CPUID_CLEAR
In reply to Greg Kroah-HartmanFrom: Pawan Gupta <[email protected]>
commit 5efc6fa9044c3356d6046c6e1da6d02572dbed6b upstream.
/proc/cpuinfo currently reports Hardware Lock Elision (HLE) feature to be present on boot cpu even if it was disabled during the bootup. This is because cpuinfo_x86->x86_capability HLE bit is not updated after TSX state is changed via the new MSR IA32_TSX_CTRL.
Update the cached HLE bit also since it is expected to change after an update to CPUID_CLEAR bit in MSR IA32_TSX_CTRL.
--- arch/x86/kernel/cpu/tsx.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
arch/x86/kernel/cpu/tsx.c +7 -6
@@ -115,11 +115,12 @@ void __init tsx_init(void)tsx_disable ();/* -* tsx_disable() will change the state of the -* RTM CPUID bit. Clear it here since it is now -* expected to be not set. +* tsx_disable() will change the state of the RTM and HLE CPUID +* bits. Clear them here since they are now expected to be not +* set. */ setup_clear_cpu_cap (X86_FEATURE_RTM ); +setup_clear_cpu_cap (X86_FEATURE_HLE ); }else if (tsx_ctrl_state ==TSX_CTRL_ENABLE ) {/*
@@ -131,10 +132,10 @@ void __init tsx_init(void)tsx_enable ();/* -* tsx_enable() will change the state of the -* RTM CPUID bit. Force it here since it is now -* expected to be set. +* tsx_enable() will change the state of the RTM and HLE CPUID +* bits. Force them here since they are now expected to be set. */ setup_force_cpu_cap (X86_FEATURE_RTM ); +setup_force_cpu_cap (X86_FEATURE_HLE ); } }
Greg Kroah-Hartman
maintainerPATCH 62/309 ALSA: hda: Apply aligned MMIO access only conditionally
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 4d024fe8f806e20e577cc934204c5784c7063293 upstream.
It turned out that the recent simplification of HD-audio bus access helpers caused a regression on the virtual HD-audio device on QEMU with ARM platforms. The driver got a CORB/RIRB timeout and couldn't probe any codecs.
The essential difference that caused a problem was the enforced aligned MMIO accesses by simplification. Since snd-hda-tegra driver is enabled on ARM, it enables CONFIG_SND_HDA_ALIGNED_MMIO, which makes the all HD-audio drivers using the aligned MMIO accesses. While this is mandatory for snd-hda-tegra, it seems that snd-hda-intel on ARM gets broken by this access pattern.
For addressing the regression, this patch introduces a new flag, aligned_mmio, to hdac_bus object, and applies the aligned MMIO only when this flag is set. This change affects only platforms with CONFIG_SND_HDA_ALIGNED_MMIO set, i.e. mostly only for ARM platforms.
Unfortunately the patch became a big bigger than it should be, just because the former calls didn't take hdac_bus object in the argument, hence we had to extend the call patterns.
--- include/sound/hdaudio.h | 77 +++++++++++++++++++++++++++++++--------------- sound/pci/hda/hda_tegra.c | 1 2 files changed, 54 insertions(+), 24 deletions(-)
include/sound/hdaudio.h +53 -24
@@ -8,6 +8,7 @@#include <linux/device.h> #include <linux/interrupt.h> +#include <linux/io.h> #include <linux/pm_runtime.h> #include <linux/timecounter.h> #include <sound/core.h>
@@ -330,6 +331,7 @@ struct hdac_bus { bool chip_init:1; /* h/w initialized *//* behavior flags */ + bool aligned_mmio:1; /* aligned MMIO access */ bool sync_write:1; /* sync after verb write */ bool use_posbuf:1; /* use position buffer */ bool snoop:1; /* enable snooping */
@@ -405,34 +407,61 @@ void snd_hdac_bus_free_stream_pages(struunsigned int snd_hdac_aligned_read (void __iomem *addr,unsigned int mask);void snd_hdac_aligned_write (unsigned int val,void __iomem *addr,unsigned int mask); -#define snd_hdac_reg_writeb (v, addr) snd_hdac_aligned_write(v, addr, 0xff) -#define snd_hdac_reg_writew (v, addr) snd_hdac_aligned_write(v, addr, 0xffff) -#define snd_hdac_reg_readb (addr) snd_hdac_aligned_read(addr, 0xff) -#define snd_hdac_reg_readw (addr) snd_hdac_aligned_read(addr, 0xffff) -#else /* CONFIG_SND_HDA_ALIGNED_MMIO */ -#define snd_hdac_reg_writeb (val, addr) writeb(val, addr) -#define snd_hdac_reg_writew (val, addr) writew(val, addr) -#define snd_hdac_reg_readb (addr) readb(addr) -#define snd_hdac_reg_readw (addr) readw(addr) -#endif /* CONFIG_SND_HDA_ALIGNED_MMIO */ -#define snd_hdac_reg_writel (val, addr) writel(val, addr) -#define snd_hdac_reg_readl (addr) readl(addr) +#define snd_hdac_aligned_mmio (bus) (bus)->aligned_mmio +#else +#define snd_hdac_aligned_mmio (bus) false +#define snd_hdac_aligned_read (addr, mask) 0 +#define snd_hdac_aligned_write (val, addr, mask) do {} while (0) +#endif + +static inline void snd_hdac_reg_writeb (struct hdac_bus *bus,void __iomem *addr, +u8 val) +{ +if (snd_hdac_aligned_mmio (bus)) +snd_hdac_aligned_write (val, addr,0xff ); +else +writeb (val, addr); +} + +static inline void snd_hdac_reg_writew (struct hdac_bus *bus,void __iomem *addr, +u16 val) +{ +if (snd_hdac_aligned_mmio (bus)) +snd_hdac_aligned_write (val, addr,0xffff ); +else +writew (val, addr); +} + +static inline u8 snd_hdac_reg_readb (struct hdac_bus *bus,void __iomem *addr) +{ +return snd_hdac_aligned_mmio (bus) ? +snd_hdac_aligned_read (addr,0xff ) :readb (addr); +} + +static inline u16 snd_hdac_reg_readw (struct hdac_bus *bus,void __iomem *addr) +{ +return snd_hdac_aligned_mmio (bus) ? +snd_hdac_aligned_read (addr,0xffff ) :readw (addr); +} + +#define snd_hdac_reg_writel (bus, addr, val) writel(val, addr) +#define snd_hdac_reg_readl (bus, addr) readl(addr)/* * macros for easy use */ #define _snd_hdac_chip_writeb (chip, reg, value) \ - snd_hdac_reg_writeb(value, (chip)->remap_addr + (reg)) + snd_hdac_reg_writeb(chip, (chip)->remap_addr + (reg), value)#define _snd_hdac_chip_readb (chip, reg) \ - snd_hdac_reg_readb((chip)->remap_addr + (reg)) + snd_hdac_reg_readb(chip, (chip)->remap_addr + (reg))#define _snd_hdac_chip_writew (chip, reg, value) \ - snd_hdac_reg_writew(value, (chip)->remap_addr + (reg)) + snd_hdac_reg_writew(chip, (chip)->remap_addr + (reg), value)#define _snd_hdac_chip_readw (chip, reg) \ - snd_hdac_reg_readw((chip)->remap_addr + (reg)) + snd_hdac_reg_readw(chip, (chip)->remap_addr + (reg))#define _snd_hdac_chip_writel (chip, reg, value) \ - snd_hdac_reg_writel(value, (chip)->remap_addr + (reg)) + snd_hdac_reg_writel(chip, (chip)->remap_addr + (reg), value)#define _snd_hdac_chip_readl (chip, reg) \ - snd_hdac_reg_readl((chip)->remap_addr + (reg)) + snd_hdac_reg_readl(chip, (chip)->remap_addr + (reg))/* read/write a register, pass without AZX_REG_ prefix */ #define snd_hdac_chip_writel (chip, reg, value) \
@@ -540,17 +569,17 @@ int snd_hdac_get_stream_stripe_ctl(struc*/ /* read/write a register, pass without AZX_REG_ prefix */ #define snd_hdac_stream_writel (dev, reg, value) \ - snd_hdac_reg_writel(value, (dev)->sd_addr + AZX_REG_ ## reg) + snd_hdac_reg_writel((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg, value)#define snd_hdac_stream_writew (dev, reg, value) \ - snd_hdac_reg_writew(value, (dev)->sd_addr + AZX_REG_ ## reg) + snd_hdac_reg_writew((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg, value)#define snd_hdac_stream_writeb (dev, reg, value) \ - snd_hdac_reg_writeb(value, (dev)->sd_addr + AZX_REG_ ## reg) + snd_hdac_reg_writeb((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg, value)#define snd_hdac_stream_readl (dev, reg) \ - snd_hdac_reg_readl((dev)->sd_addr + AZX_REG_ ## reg) + snd_hdac_reg_readl((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg)#define snd_hdac_stream_readw (dev, reg) \ - snd_hdac_reg_readw((dev)->sd_addr + AZX_REG_ ## reg) + snd_hdac_reg_readw((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg)#define snd_hdac_stream_readb (dev, reg) \ - snd_hdac_reg_readb((dev)->sd_addr + AZX_REG_ ## reg) + snd_hdac_reg_readb((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg)/* update a register, pass without AZX_REG_ prefix */ #define snd_hdac_stream_updatel (dev, reg, mask, val) \
sound/pci/hda/hda_tegra.c +1 -0
@@ -398,6 +398,7 @@ static int hda_tegra_create(struct snd_creturn err; chip->bus.needs_damn_long_delay =1 ; + chip->bus.core.aligned_mmio =1 ; err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops);if (err <0 ) {
Greg Kroah-Hartman
maintainerPATCH 63/309 ALSA: hda: Add Clevo W65_67SB the power_save blacklist
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
commit d8feb6080bb0c9f4d799a423d9453048fdd06990 upstream.
Using HDA power-saving on the Clevo W65_67SB causes the first 0.5 seconds of audio to be missing every time audio starts playing.
This commit adds the Clevo W65_67SB the power_save blacklist to avoid this issue.
--- sound/pci/hda/hda_intel.c | 2 ++ 1 file changed, 2 insertions(+)
sound/pci/hda/hda_intel.c +2 -0
@@ -2156,6 +2156,8 @@ static struct snd_pci_quirk power_save_b/* https://bugzilla.redhat.com/show_bug.cgi?id=1581607 */ SND_PCI_QUIRK (0x1558 ,0x3501 ,"Clevo W35xSS_370SS" ,0 ),/* https://bugzilla.redhat.com/show_bug.cgi?id=1525104 */ +SND_PCI_QUIRK (0x1558 ,0x6504 ,"Clevo W65_67SB" ,0 ), +/* https://bugzilla.redhat.com/show_bug.cgi?id=1525104 */ SND_PCI_QUIRK(0x1028, 0x0497, "Dell Precision T3600", 0),/* https://bugzilla.redhat.com/show_bug.cgi?id=1525104 */ /* Note the P55A-UD3 and Z87-D3HP share the subsys id for the HDA dev */
Greg Kroah-Hartman
maintainerPATCH 66/309 KVM: arm64: Correct PSTATE on exception entry
In reply to Greg Kroah-HartmanFrom: Mark Rutland <[email protected]>
commit a425372e733177eb0779748956bc16c85167af48 upstream.
When KVM injects an exception into a guest, it generates the PSTATE value from scratch, configuring PSTATE.{M[4:0],DAIF}, and setting all other bits to zero.
This isn't correct, as the architecture specifies that some PSTATE bits are (conditionally) cleared or set upon an exception, and others are unchanged from the original context.
This patch adds logic to match the architectural behaviour. To make this simple to follow/audit/extend, documentation references are provided, and bits are configured in order of their layout in SPSR_EL2. This layout can be seen in the diagram on ARM DDI 0487E.a page C5-429.
--- arch/arm64/include/uapi/asm/ptrace.h | 1 arch/arm64/kvm/inject_fault.c | 70 ++++++++++++++++++++++++++++++++--- 2 files changed, 66 insertions(+), 5 deletions(-)
arch/arm64/include/uapi/asm/ptrace.h +1 -0
@@ -49,6 +49,7 @@#define PSR_SSBS_BIT 0x00001000#define PSR_PAN_BIT 0x00400000#define PSR_UAO_BIT 0x00800000 +#define PSR_DIT_BIT 0x01000000#define PSR_V_BIT 0x10000000#define PSR_C_BIT 0x20000000#define PSR_Z_BIT 0x40000000
arch/arm64/kvm/inject_fault.c +65 -5
94 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 79/309 powerpc/32s: Fix CPU wake-up from sleep mode
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit 9933819099c4600b41a042f27a074470a43cf6b9 upstream.
Commit f7354ccac844 ("powerpc/32: Remove CURRENT_THREAD_INFO and rename TI_CPU") broke the CPU wake-up from sleep mode (i.e. when _TLF_SLEEPING is set) by delaying the tovirt(r2, r2).
This is because r2 is not restored by fast_exception_return. It used to work (by chance ?) because CPU wake-up interrupt never comes from user, so r2 is expected to point to 'current' on return.
Commit e2fb9f544431 ("powerpc/32: Prepare for Kernel Userspace Access Protection") broke it even more by clobbering r0 which is not restored by fast_exception_return either.
Use r6 instead of r0. This is possible because r3-r6 are restored by fast_exception_return and only r3-r5 are used for exception arguments.
For r2 it could be converted back to virtual address, but stay on the safe side and restore it from the stack instead. It should be live in the cache at that moment, so loading from the stack should make no difference compared to converting it from phys to virt.
--- arch/powerpc/kernel/entry_32.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/kernel/entry_32.S +2 -1
@@ -179,7 +179,7 @@ transfer_to_handler: 2: /* if from kernel, check interrupted DOZE/NAP mode and * check for stack overflow */ - kuap_save_and_lock r11, r12, r9, r2, r0 + kuap_save_and_lock r11, r12, r9, r2, r6 addi r2, r12, -THREAD lwz r9,KSP_LIMIT(r12) cmplw r1,r9 /* if r1 <= ksp_limit */
@@ -284,6 +284,7 @@ reenable_mmu: rlwinm r9,r9,0,~MSR_EE lwz r12,_LINK(r11) /* and return to address in LR */ kuap_restore r11, r2, r3, r4, r5 + lwz r2, GPR2(r11) b fast_exception_return #endif
Greg Kroah-Hartman
maintainerPATCH 44/309 usb: gadget: f_ecm: Use atomic_t to track in-flight request
In reply to Greg Kroah-HartmanFrom: Bryan O'Donoghue <[email protected]>
commit d710562e01c48d59be3f60d58b7a85958b39aeda upstream.
Currently ecm->notify_req is used to flag when a request is in-flight. ecm->notify_req is set to NULL and when a request completes it is subsequently reset.
This is fundamentally buggy in that the unbind logic of the ECM driver will unconditionally free ecm->notify_req leading to a NULL pointer dereference.
--- drivers/usb/gadget/function/f_ecm.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/usb/gadget/function/f_ecm.c +12 -4
@@ -52,6 +52,7 @@ struct f_ecm {struct usb_ep *notify;struct usb_request *notify_req;u8 notify_state; +atomic_t notify_count;bool is_open;/* FIXME is_open needs some irq-ish locking
@@ -380,7 +381,7 @@ static void ecm_do_notify(struct f_ecm *int status;/* notification already in flight? */ -if (!req) +if (atomic_read (&ecm->notify_count))return ; event = req->buf;
@@ -420,10 +421,10 @@ static void ecm_do_notify(struct f_ecm * event->bmRequestType =0xA1 ; event->wIndex =cpu_to_le16 (ecm->ctrl_id); - ecm->notify_req =NULL ; +atomic_inc (&ecm->notify_count); status =usb_ep_queue (ecm->notify, req,GFP_ATOMIC );if (status <0 ) { - ecm->notify_req = req; +atomic_dec (&ecm->notify_count);DBG (cdev,"notify --> %d\n" , status); } }
@@ -448,17 +449,19 @@ static void ecm_notify_complete(struct uswitch (req->status) {case 0 :/* no fault */ +atomic_dec (&ecm->notify_count);break ;case -ECONNRESET :case -ESHUTDOWN : +atomic_set (&ecm->notify_count,0 ); ecm->notify_state =ECM_NOTIFY_NONE ;break ;default :DBG (cdev,"event %02x --> %d\n" , event->bNotificationType, req->status); +atomic_dec (&ecm->notify_count);break ; } - ecm->notify_req = req;ecm_do_notify (ecm); }
@@ -907,6 +910,11 @@ static void ecm_unbind(struct usb_configusb_free_all_descriptors (f); +if (atomic_read (&ecm->notify_count)) { +usb_ep_dequeue (ecm->notify, ecm->notify_req); +atomic_set (&ecm->notify_count,0 ); + } +kfree (ecm->notify_req->buf);usb_ep_free_request (ecm->notify, ecm->notify_req); }
Greg Kroah-Hartman
maintainerPATCH 39/309 usb: typec: tcpci: mask event interrupts when remove driver
In reply to Greg Kroah-HartmanFrom: Jun Li <[email protected]>
commit 3ba76256fc4e2a0d7fb26cc95459041ea0e88972 upstream.
This is to prevent any possible events generated while unregister tpcm port.
--- drivers/usb/typec/tcpm/tcpci.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/usb/typec/tcpm/tcpci.c +6 -0
@@ -591,6 +591,12 @@ static int tcpci_probe(struct i2c_clientstatic int tcpci_remove (struct i2c_client *client) {struct tcpci_chip *chip =i2c_get_clientdata (client); +int err; + +/* Disable chip interrupts before unregistering port */ + err =tcpci_write16 (chip->tcpci,TCPC_ALERT_MASK ,0 ); +if (err <0 ) +return err;tcpci_unregister_port (chip->tcpci);
Greg Kroah-Hartman
maintainerPATCH 94/309 ubifs: Fix FS_IOC_SETFLAGS unexpectedly clearing encrypt flag
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit 2b57067a7778484c10892fa191997bfda29fea13 upstream.
UBIFS's implementation of FS_IOC_SETFLAGS fails to preserve existing inode flags that aren't settable by FS_IOC_SETFLAGS, namely the encrypt flag. This causes the encrypt flag to be unexpectedly cleared.
Fix it by preserving existing unsettable flags, like ext4 and f2fs do.
Test case with kvm-xfstests shell:
FSTYP=ubifs KEYCTL_PROG=keyctl
. fs/ubifs/config
. ~/xfstests/common/encrypt
dev=$(__blkdev_to_ubi_volume /dev/vdc)
ubiupdatevol -t $dev
mount $dev /mnt -t ubifs
k=$(_generate_session_encryption_key)
mkdir /mnt/edir
xfs_io -c "set_encpolicy $k" /mnt/edir
echo contents > /mnt/edir/file
chattr +i /mnt/edir/file
chattr -i /mnt/edir/file
With the bug, the following errors occur on the last command:
[ 18.081559] fscrypt (ubifs, inode 67): Inconsistent encryption context (parent directory: 65)
chattr: Operation not permitted while reading flags on /mnt/edir/file--- fs/ubifs/ioctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ubifs/ioctl.c +2 -1
@@ -113,7 +113,8 @@ static int setflags(struct inode *inode,if (err) goto out_unlock; - ui->flags =ioctl2ubifs (flags); + ui->flags &= ~ioctl2ubifs (UBIFS_SUPPORTED_IOCTL_FLAGS ); + ui->flags |=ioctl2ubifs (flags);ubifs_set_inode_flags (inode); inode->i_ctime =current_time (inode); release = ui->dirty;
Greg Kroah-Hartman
maintainerPATCH 111/309 scsi: megaraid_sas: Do not initiate OCR if controller is not in ready state
In reply to Greg Kroah-HartmanFrom: Anand Lodnoor <[email protected]>
commit 6d7537270e3283b92f9b327da9d58a4de40fe8d0 upstream.
Driver initiates OCR if a DCMD command times out. But there is a deadlock if the driver attempts to invoke another OCR before the mutex lock (reset_mutex) is released from the previous session of OCR.
This patch takes care of the above scenario using new flag MEGASAS_FUSION_OCR_NOT_POSSIBLE to indicate if OCR is possible.
--- drivers/scsi/megaraid/megaraid_sas_base.c | 3 ++- drivers/scsi/megaraid/megaraid_sas_fusion.c | 3 ++- drivers/scsi/megaraid/megaraid_sas_fusion.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-)
drivers/scsi/megaraid/megaraid_sas_base.c +2 -1
@@ -4392,7 +4392,8 @@ dcmd_timeout_ocr_possible(struct megasasif (instance->adapter_type ==MFI_SERIES )return KILL_ADAPTER ;else if (instance->unload || -test_bit (MEGASAS_FUSION_IN_RESET , &instance->reset_flags)) +test_bit (MEGASAS_FUSION_OCR_NOT_POSSIBLE , + &instance->reset_flags))return IGNORE_TIMEOUT ;else return INITIATE_OCR ;
drivers/scsi/megaraid/megaraid_sas_fusion.c +2 -1
@@ -4847,6 +4847,7 @@ int megasas_reset_fusion(struct Scsi_Hosif (instance->requestorId && !instance->skip_heartbeat_timer_del)del_timer_sync (&instance->sriov_heartbeat_timer);set_bit (MEGASAS_FUSION_IN_RESET , &instance->reset_flags); +set_bit (MEGASAS_FUSION_OCR_NOT_POSSIBLE , &instance->reset_flags);atomic_set (&instance->adprecovery,MEGASAS_ADPRESET_SM_POLLING ); instance->instancet->disable_intr (instance);megasas_sync_irqs ((unsigned long )instance);
@@ -5046,7 +5047,7 @@ kill_hba: instance->skip_heartbeat_timer_del =1 ; retval =FAILED ; out: -clear_bit (MEGASAS_FUSION_IN_RESET , &instance->reset_flags); +clear_bit (MEGASAS_FUSION_OCR_NOT_POSSIBLE , &instance->reset_flags);mutex_unlock (&instance->reset_mutex);return retval; }
drivers/scsi/megaraid/megaraid_sas_fusion.h +1 -0
@@ -89,6 +89,7 @@ enum MR_RAID_FLAGS_IO_SUB_TYPE {#define MEGASAS_FP_CMD_LEN 16#define MEGASAS_FUSION_IN_RESET 0 +#define MEGASAS_FUSION_OCR_NOT_POSSIBLE 1#define RAID_1_PEER_CMDS 2#define JBOD_MAPS_COUNT 2#define MEGASAS_REDUCE_QD_COUNT 64
Greg Kroah-Hartman
maintainerPATCH 113/309 cpupower: Revert library ABI changes from commit ae2917093fb60bdc1ed3e
In reply to Greg Kroah-HartmanFrom: Thomas Renninger <[email protected]>
commit 41ddb7e1f79693d904502ae9bea609837973eff8 upstream.
Commit ae2917093fb6 ("tools/power/cpupower: Display boost frequency separately") modified the library function:
struct cpufreq_available_frequencies *cpufreq_get_available_frequencies(unsigned int cpu)
to
struct cpufreq_frequencies *cpufreq_get_frequencies(const char *type, unsigned int cpu)
This patch recovers the old API and implements the new functionality in a newly introduce method:
struct cpufreq_boost_frequencies *cpufreq_get_available_frequencies(unsigned int cpu)
This one should get merged into stable kernels back to 5.0 when the above had been introduced.
--- tools/power/cpupower/lib/cpufreq.c | 78 ++++++++++++++++++++++++++---- tools/power/cpupower/lib/cpufreq.h | 20 +++++-- tools/power/cpupower/utils/cpufreq-info.c | 12 ++-- 3 files changed, 87 insertions(+), 23 deletions(-)
tools/power/cpupower/lib/cpufreq.c +68 -10
@@ -332,21 +332,74 @@ void cpufreq_put_available_governors(str } -struct cpufreq_frequencies -*cpufreq_get_frequencies (const char *type,unsigned int cpu) +struct cpufreq_available_frequencies +*cpufreq_get_available_frequencies (unsigned int cpu) { -struct cpufreq_frequencies *first =NULL ; -struct cpufreq_frequencies *current =NULL ; +struct cpufreq_available_frequencies *first =NULL ; +struct cpufreq_available_frequencies *current =NULL ;char one_value[SYSFS_PATH_MAX ];char linebuf[MAX_LINE_LEN ]; -char fname[MAX_LINE_LEN ];unsigned int pos, i;unsigned int len; -snprintf (fname,MAX_LINE_LEN ,"scaling_%s_frequencies" , type); + len =sysfs_cpufreq_read_file (cpu,"scaling_available_frequencies" , + linebuf,sizeof (linebuf)); +if (len ==0 ) +return NULL ; + + pos =0 ; +for (i =0 ; i < len; i++) { +if (linebuf[i] ==' ' || linebuf[i] =='\n' ) { +if (i - pos <2 ) +continue ; +if (i - pos >=SYSFS_PATH_MAX ) + goto error_out; +if (current) { + current->next =malloc (sizeof (*current)); +if (!current->next) + goto error_out; + current = current->next; + }else { + first =malloc (sizeof (*first)); +if (!first) + goto error_out; + current = first; + } + current->first = first; + current->next =NULL ; + +memcpy (one_value, linebuf + pos, i - pos); + one_value[i - pos] ='\0' ; +if (sscanf (one_value,"%lu" , ¤t->frequency) !=1 ) + goto error_out; + + pos = i +1 ; + } + } + +return first; + + error_out: +while (first) { + current = first->next; +free (first); + first = current; + } +return NULL ; +} - len =sysfs_cpufreq_read_file (cpu, fname, - linebuf,sizeof (linebuf)); +struct cpufreq_available_frequencies +*cpufreq_get_boost_frequencies (unsigned int cpu) +{ +struct cpufreq_available_frequencies *first =NULL ; +struct cpufreq_available_frequencies *current =NULL ; +char one_value[SYSFS_PATH_MAX ]; +char linebuf[MAX_LINE_LEN ]; +unsigned int pos, i; +unsigned int len; + + len =sysfs_cpufreq_read_file (cpu,"scaling_boost_frequencies" , + linebuf,sizeof (linebuf));if (len ==0 )return NULL ;
@@ -391,9 +444,9 @@ struct cpufreq_frequenciesreturn NULL ; } -void cpufreq_put_frequencies (struct cpufreq_frequencies *any) +void cpufreq_put_available_frequencies (struct cpufreq_available_frequencies *any) { -struct cpufreq_frequencies *tmp, *next; +struct cpufreq_available_frequencies *tmp, *next;if (!any)return ;
@@ -406,6 +459,11 @@ void cpufreq_put_frequencies(struct cpuf } } +void cpufreq_put_boost_frequencies (struct cpufreq_available_frequencies *any) +{ +cpufreq_put_available_frequencies (any); +} +static struct cpufreq_affected_cpus *sysfs_get_cpu_list (unsigned int cpu,const char *file) {
tools/power/cpupower/lib/cpufreq.h +13 -7
@@ -20,10 +20,10 @@ struct cpufreq_available_governors {struct cpufreq_available_governors *first; }; -struct cpufreq_frequencies { +struct cpufreq_available_frequencies {unsigned long frequency; -struct cpufreq_frequencies *next; -struct cpufreq_frequencies *first; +struct cpufreq_available_frequencies *next; +struct cpufreq_available_frequencies *first; };
@@ -124,11 +124,17 @@ void cpufreq_put_available_governors(* cpufreq_put_frequencies after use. */ -struct cpufreq_frequencies -*cpufreq_get_frequencies (const char *type,unsigned int cpu); +struct cpufreq_available_frequencies +*cpufreq_get_available_frequencies (unsigned int cpu); -void cpufreq_put_frequencies ( -struct cpufreq_frequencies *first); +void cpufreq_put_available_frequencies ( +struct cpufreq_available_frequencies *first); + +struct cpufreq_available_frequencies +*cpufreq_get_boost_frequencies (unsigned int cpu); + +void cpufreq_put_boost_frequencies ( +struct cpufreq_available_frequencies *first);/* determine affected CPUs
tools/power/cpupower/utils/cpufreq-info.c +6 -6
@@ -244,14 +244,14 @@ static int get_boost_mode_x86(unsigned istatic int get_boost_mode (unsigned int cpu) { -struct cpufreq_frequencies *freqs; +struct cpufreq_available_frequencies *freqs;if (cpupower_cpu_info.vendor ==X86_VENDOR_AMD || cpupower_cpu_info.vendor ==X86_VENDOR_HYGON || cpupower_cpu_info.vendor ==X86_VENDOR_INTEL )return get_boost_mode_x86 (cpu); - freqs =cpufreq_get_frequencies ("boost" , cpu); + freqs =cpufreq_get_boost_frequencies (cpu);if (freqs) {printf (_ (" boost frequency steps: " ));while (freqs->next) {
@@ -261,7 +261,7 @@ static int get_boost_mode(unsigned int c }print_speed (freqs->frequency);printf ("\n" ); -cpufreq_put_frequencies (freqs); +cpufreq_put_available_frequencies (freqs); }return 0 ;
@@ -475,7 +475,7 @@ static int get_latency(unsigned int cpu,static void debug_output_one (unsigned int cpu) { -struct cpufreq_frequencies *freqs; +struct cpufreq_available_frequencies *freqs;get_driver (cpu);get_related_cpus (cpu);
@@ -483,7 +483,7 @@ static void debug_output_one(unsigned inget_latency (cpu,1 );get_hardware_limits (cpu,1 ); - freqs =cpufreq_get_frequencies ("available" , cpu); + freqs =cpufreq_get_available_frequencies (cpu);if (freqs) {printf (_ (" available frequency steps: " ));while (freqs->next) {
@@ -493,7 +493,7 @@ static void debug_output_one(unsigned in }print_speed (freqs->frequency);printf ("\n" ); -cpufreq_put_frequencies (freqs); +cpufreq_put_available_frequencies (freqs); }get_available_governors (cpu);
Greg Kroah-Hartman
maintainerPATCH 121/309 f2fs: fix dcache lookup of !casefolded directories
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit 5515eae647426169e4b7969271fb207881eba7f6 upstream.
Do the name comparison for non-casefolded directories correctly.
This is analogous to ext4's commit 66883da1eee8 ("ext4: fix dcache lookup of !casefolded directories").
--- fs/f2fs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/dir.c +1 -1
@@ -1072,7 +1072,7 @@ static int f2fs_d_compare(const struct dif (!IS_CASEFOLDED (dentry->d_parent->d_inode)) {if (len != name->len)return -1 ; -return memcmp (str, name, len); +return memcmp (str, name->name, len); }return f2fs_ci_compare (dentry->d_parent->d_inode, name, &qstr, false);
Greg Kroah-Hartman
maintainerPATCH 122/309 f2fs: fix race conditions in ->d_compare() and ->d_hash()
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit 80f2388afa6ef985f9c5c228e36705c4d4db4756 upstream.
Since ->d_compare() and ->d_hash() can be called in RCU-walk mode, ->d_parent and ->d_inode can be concurrently modified, and in particular, ->d_inode may be changed to NULL. For f2fs_d_hash() this resulted in a reproducible NULL dereference if a lookup is done in a directory being deleted, e.g. with:
int main()
{
if (fork()) {
for (;;) {
mkdir("subdir", 0700);
rmdir("subdir");
}
} else {
for (;;)
access("subdir/file", 0);
}
}... or by running the 't_encrypted_d_revalidate' program from xfstests. Both repros work in any directory on a filesystem with the encoding feature, even if the directory doesn't actually have the casefold flag.
I couldn't reproduce a crash in f2fs_d_compare(), but it appears that a similar crash is possible there.
Fix these bugs by reading ->d_parent and ->d_inode using READ_ONCE() and falling back to the case sensitive behavior if the inode is NULL.
--- fs/f2fs/dir.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
fs/f2fs/dir.c +6 -3
@@ -1068,24 +1068,27 @@ static int f2fs_d_compare(const struct d const char *str, const struct qstr *name) { struct qstr qstr = {.name = str, .len = len }; +const struct dentry *parent =READ_ONCE (dentry->d_parent); +const struct inode *inode =READ_ONCE (parent->d_inode); -if (!IS_CASEFOLDED (dentry->d_parent->d_inode)) { +if (!inode || !IS_CASEFOLDED (inode)) {if (len != name->len)return -1 ;return memcmp (str, name->name, len); } -return f2fs_ci_compare (dentry->d_parent->d_inode, name, &qstr, false); +return f2fs_ci_compare (inode, name, &qstr, false); }static int f2fs_d_hash (const struct dentry *dentry,struct qstr *str) {struct f2fs_sb_info *sbi =F2FS_SB (dentry->d_sb);const struct unicode_map *um = sbi->s_encoding; +const struct inode *inode =READ_ONCE (dentry->d_inode);unsigned char *norm;int len, ret =0 ; -if (!IS_CASEFOLDED (dentry->d_inode)) +if (!inode || !IS_CASEFOLDED (inode))return 0 ; norm =f2fs_kmalloc (sbi,PATH_MAX ,GFP_ATOMIC );
Greg Kroah-Hartman
maintainerPATCH 84/309 PCI: keystone: Fix error handling when "num-viewport" DT property is not populated
In reply to Greg Kroah-HartmanFrom: Kishon Vijay Abraham I <[email protected]>
commit b0de922af53eede340986a2d05b6cd4b6d6efa43 upstream.
Fix error handling when "num-viewport" DT property is not populated.
--- drivers/pci/controller/dwc/pci-keystone.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/dwc/pci-keystone.c +1 -1
@@ -1354,7 +1354,7 @@ static int __init ks_pcie_probe(struct p ret =of_property_read_u32 (np,"num-viewport" , &num_viewport);if (ret <0 ) {dev_err (dev,"unable to read *num-viewport* property\n" ); -return ret; + goto err_get_sync; }/*
Greg Kroah-Hartman
maintainerPATCH 160/309 crypto: atmel-aes - Fix counter overflow in CTR mode
In reply to Greg Kroah-HartmanFrom: Tudor Ambarus <[email protected]>
commit 781a08d9740afa73357f1a60d45d7c93d7cca2dd upstream.
32 bit counter is not supported by neither of our AES IPs, all implement a 16 bit block counter. Drop the 32 bit block counter logic.
--- drivers/crypto/atmel-aes.c | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-)
drivers/crypto/atmel-aes.c +12 -25
@@ -88,7 +88,6 @@struct atmel_aes_caps {bool has_dualbuff;bool has_cfb64; -bool has_ctr32;bool has_gcm;bool has_xts;bool has_authenc;
@@ -1013,8 +1012,9 @@ static int atmel_aes_ctr_transfer(structstruct atmel_aes_ctr_ctx *ctx =atmel_aes_ctr_ctx_cast (dd->ctx);struct ablkcipher_request *req =ablkcipher_request_cast (dd->areq);struct scatterlist *src, *dst; -u32 ctr, blocks;size_t datalen; +u32 ctr; +u16 blocks, start, end;bool use_dma, fragmented = false;/* Check for transfer completion. */
@@ -1026,27 +1026,17 @@ static int atmel_aes_ctr_transfer(struct datalen = req->nbytes - ctx->offset; blocks =DIV_ROUND_UP (datalen,AES_BLOCK_SIZE ); ctr =be32_to_cpu (ctx->iv[3 ]); -if (dd->caps.has_ctr32) { -/* Check 32bit counter overflow. */ -u32 start = ctr; -u32 end = start + blocks -1 ; - -if (end < start) { - ctr |=0xffffffff ; - datalen =AES_BLOCK_SIZE * -start; - fragmented = true; - } - }else { -/* Check 16bit counter overflow. */ -u16 start = ctr &0xffff ; -u16 end = start + (u16 )blocks -1 ; - -if (blocks >>16 || end < start) { - ctr |=0xffff ; - datalen =AES_BLOCK_SIZE * (0x10000 -start); - fragmented = true; - } + +/* Check 16bit counter overflow. */ + start = ctr &0xffff ; + end = start + blocks -1 ; + +if (blocks >>16 || end < start) { + ctr |=0xffff ; + datalen =AES_BLOCK_SIZE * (0x10000 - start); + fragmented = true; } + use_dma = (datalen >=ATMEL_AES_DMA_THRESHOLD );/* Jump to offset. */
@@ -2550,7 +2540,6 @@ static void atmel_aes_get_cap(struct atm { dd->caps.has_dualbuff =0 ; dd->caps.has_cfb64 =0 ; - dd->caps.has_ctr32 =0 ; dd->caps.has_gcm =0 ; dd->caps.has_xts =0 ; dd->caps.has_authenc =0 ;
@@ -2561,7 +2550,6 @@ static void atmel_aes_get_cap(struct atmcase 0x500 : dd->caps.has_dualbuff =1 ; dd->caps.has_cfb64 =1 ; - dd->caps.has_ctr32 =1 ; dd->caps.has_gcm =1 ; dd->caps.has_xts =1 ; dd->caps.has_authenc =1 ;
@@ -2570,7 +2558,6 @@ static void atmel_aes_get_cap(struct atmcase 0x200 : dd->caps.has_dualbuff =1 ; dd->caps.has_cfb64 =1 ; - dd->caps.has_ctr32 =1 ; dd->caps.has_gcm =1 ; dd->caps.max_burst_size =4 ;break ;
Greg Kroah-Hartman
maintainerPATCH 1/309 sparc32: fix struct ipc64_perm type definition
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 34ca70ef7d3a9fa7e89151597db5e37ae1d429b4 ]
As discussed in the strace issue tracker, it appears that the sparc32 sysvipc support has been broken for the past 11 years. It was however working in compat mode, which is how it must have escaped most of the regular testing.
The problem is that a cleanup patch inadvertently changed the uid/gid fields in struct ipc64_perm from 32-bit types to 16-bit types in uapi headers.
Both glibc and uclibc-ng still use the original types, so they should work fine with compat mode, but not natively. Change the definitions to use __kernel_uid32_t and __kernel_gid32_t again.
--- arch/sparc/include/uapi/asm/ipcbuf.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
arch/sparc/include/uapi/asm/ipcbuf.h +11 -11
@@ -15,19 +15,19 @@struct ipc64_perm { -__kernel_key_t key; -__kernel_uid_t uid; -__kernel_gid_t gid; -__kernel_uid_t cuid; -__kernel_gid_t cgid; +__kernel_key_t key; +__kernel_uid32_t uid; +__kernel_gid32_t gid; +__kernel_uid32_t cuid; +__kernel_gid32_t cgid;#ifndef __arch64__ -unsigned short __pad0; +unsigned short __pad0;#endif -__kernel_mode_t mode; -unsigned short __pad1; -unsigned short seq; -unsigned long long __unused1; -unsigned long long __unused2; +__kernel_mode_t mode; +unsigned short __pad1; +unsigned short seq; +unsigned long long __unused1; +unsigned long long __unused2; };#endif /* __SPARC_IPCBUF_H */
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 169/309 ext4: fix deadlock allocating crypto bounce page from mempool
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit 547c556f4db7c09447ecf5f833ab6aaae0c5ab58 upstream.
ext4_writepages() on an encrypted file has to encrypt the data, but it can't modify the pagecache pages in-place, so it encrypts the data into bounce pages and writes those instead. All bounce pages are allocated from a mempool using GFP_NOFS.
This is not correct use of a mempool, and it can deadlock. This is because GFP_NOFS includes __GFP_DIRECT_RECLAIM, which enables the "never fail" mode for mempool_alloc() where a failed allocation will fall back to waiting for one of the preallocated elements in the pool.
But since this mode is used for all a bio's pages and not just the first, it can deadlock waiting for pages already in the bio to be freed.
This deadlock can be reproduced by patching mempool_alloc() to pretend that pool->alloc() always fails (so that it always falls back to the preallocations), and then creating an encrypted file of size > 128 KiB.
Fix it by only using GFP_NOFS for the first page in the bio. For subsequent pages just use GFP_NOWAIT, and if any of those fail, just submit the bio and start a new one.
This will need to be fixed in f2fs too, but that's less straightforward.
--- fs/ext4/page-io.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
fs/ext4/page-io.c +14 -5
@@ -478,17 +478,26 @@ int ext4_bio_write_page(struct ext4_io_sgfp_t gfp_flags =GFP_NOFS ;unsigned int enc_bytes =round_up (len,i_blocksize (inode)); +/* +* Since bounce page allocation uses a mempool, we can only use +* a waiting mask (i.e. request guaranteed allocation) on the +* first page of the bio. Otherwise it can deadlock. +*/ +if (io->io_bio) + gfp_flags =GFP_NOWAIT | __GFP_NOWARN; retry_encrypt: bounce_page =fscrypt_encrypt_pagecache_blocks (page, enc_bytes,0 , gfp_flags);if (IS_ERR (bounce_page)) { ret =PTR_ERR (bounce_page); -if (ret == -ENOMEM && wbc->sync_mode ==WB_SYNC_ALL ) { -if (io->io_bio) { +if (ret == -ENOMEM && + (io->io_bio || wbc->sync_mode ==WB_SYNC_ALL )) { + gfp_flags =GFP_NOFS ; +if (io->io_bio)ext4_io_submit (io); -congestion_wait (BLK_RW_ASYNC ,HZ /50 ); - } - gfp_flags |= __GFP_NOFAIL; +else + gfp_flags |= __GFP_NOFAIL; +congestion_wait (BLK_RW_ASYNC ,HZ /50 ); goto retry_encrypt; } bounce_page =NULL ;
Greg Kroah-Hartman
maintainerPATCH 2/309 bnxt_en: Move devlink_register before registering netdev
In reply to Greg Kroah-HartmanFrom: Vasundhara Volam <[email protected]>
[ Upstream commit cda2cab0771183932d6ba73c5ac63bb63decdadf ]
Latest kernels get the phys_port_name via devlink, if ndo_get_phys_port_name is not defined. To provide the phys_port_name correctly, register devlink before registering netdev.
Also call devlink_port_type_eth_set() after registering netdev as devlink port updates the netdev structure and notifies user.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 12 ++++++++---- drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 1 - 2 files changed, 8 insertions(+), 5 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +8 -4
@@ -11359,9 +11359,9 @@ static void bnxt_remove_one(struct pci_dbnxt_sriov_disable (bp);bnxt_dl_fw_reporters_destroy (bp, true); -bnxt_dl_unregister (bp);pci_disable_pcie_error_reporting (pdev);unregister_netdev (dev); +bnxt_dl_unregister (bp);bnxt_shutdown_tc (bp);bnxt_cancel_sp_work (bp); bp->sp_event =0 ;
@@ -11850,11 +11850,14 @@ static int bnxt_init_one(struct pci_devbnxt_init_tc (bp); } +bnxt_dl_register (bp); + rc =register_netdev (dev);if (rc) - goto init_err_cleanup_tc; + goto init_err_cleanup; -bnxt_dl_register (bp); +if (BNXT_PF (bp)) +devlink_port_type_eth_set (&bp->dl_port, bp->dev);bnxt_dl_fw_reporters_create (bp); netdev_info(dev, "%s found at mem %lx, node addr %pM\n",
@@ -11864,7 +11867,8 @@ static int bnxt_init_one(struct pci_devreturn 0 ; -init_err_cleanup_tc: +init_err_cleanup: +bnxt_dl_unregister (bp);bnxt_shutdown_tc (bp);bnxt_clear_int_mode (bp);
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +0 -1
@@ -482,7 +482,6 @@ int bnxt_dl_register(struct bnxt *bp)netdev_err (bp->dev,"devlink_port_register failed" ); goto err_dl_param_unreg; } -devlink_port_type_eth_set (&bp->dl_port, bp->dev); rc =devlink_port_params_register (&bp->dl_port, bnxt_dl_port_params,ARRAY_SIZE (bnxt_dl_port_params));
Greg Kroah-Hartman
maintainerPATCH 138/309 tracing: Annotate ftrace_graph_notrace_hash pointer with __rcu
In reply to Greg Kroah-HartmanFrom: Amol Grover <[email protected]>
[ Upstream commit fd0e6852c407dd9aefc594f54ddcc21d84803d3b ]
Fix following instances of sparse error kernel/trace/ftrace.c:5667:29: error: incompatible types in comparison kernel/trace/ftrace.c:5813:21: error: incompatible types in comparison kernel/trace/ftrace.c:5868:36: error: incompatible types in comparison kernel/trace/ftrace.c:5870:25: error: incompatible types in comparison
Use rcu_dereference_protected to dereference the newly annotated pointer.
--- kernel/trace/ftrace.c | 2 +- kernel/trace/trace.h | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-)
kernel/trace/ftrace.c +1 -1
@@ -5103,7 +5103,7 @@ static const struct file_operations ftrace_notrace_fops = {static DEFINE_MUTEX (graph_lock);struct ftrace_hash __rcu *ftrace_graph_hash =EMPTY_HASH ; -struct ftrace_hash *ftrace_graph_notrace_hash =EMPTY_HASH ; +struct ftrace_hash __rcu *ftrace_graph_notrace_hash =EMPTY_HASH ;enum graph_filter_type {GRAPH_FILTER_NOTRACE =0 ,
kernel/trace/trace.h +6 -2
@@ -933,7 +933,7 @@ extern void __trace_graph_return(struct trace_array *tr,#ifdef CONFIG_DYNAMIC_FTRACE extern struct ftrace_hash __rcu *ftrace_graph_hash; -extern struct ftrace_hash *ftrace_graph_notrace_hash; +extern struct ftrace_hash __rcu *ftrace_graph_notrace_hash;static inline int ftrace_graph_addr (struct ftrace_graph_ent *trace) {
@@ -986,10 +986,14 @@ static inline void ftrace_graph_addr_finish(struct ftrace_graph_ret *trace)static inline int ftrace_graph_notrace_addr (unsigned long addr) {int ret =0 ; +struct ftrace_hash *notrace_hash;preempt_disable_notrace (); -if (ftrace_lookup_ip (ftrace_graph_notrace_hash, addr)) + notrace_hash =rcu_dereference_protected (ftrace_graph_notrace_hash, + !preemptible ()); + +if (ftrace_lookup_ip (notrace_hash, addr)) ret =1 ;preempt_enable_notrace ();
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 198/309 KVM: x86: Refactor picdev_write() to prevent Spectre-v1/L1TF attacks
In reply to Greg Kroah-HartmanFrom: Marios Pomonis <[email protected]>
commit 14e32321f3606e4b0970200b6e5e47ee6f1e6410 upstream.
This fixes a Spectre-v1/L1TF vulnerability in picdev_write(). It replaces index computations based on the (attacked-controlled) port number with constants through a minor refactoring.
--- arch/x86/kvm/i8259.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/x86/kvm/i8259.c +5 -1
@@ -460,10 +460,14 @@ static int picdev_write(struct kvm_pic *switch (addr) {case 0x20 :case 0x21 : +pic_lock (s); +pic_ioport_write (&s->pics[0 ], addr, data); +pic_unlock (s); +break ;case 0xa0 :case 0xa1 :pic_lock (s); -pic_ioport_write (&s->pics[addr >>7 ], addr, data); +pic_ioport_write (&s->pics[1 ], addr, data);pic_unlock (s);break ;case 0x4d0 :
Greg Kroah-Hartman
maintainerPATCH 201/309 KVM: x86: Protect DR-based index computations from Spectre-v1/L1TF attacks
In reply to Greg Kroah-HartmanFrom: Marios Pomonis <[email protected]>
commit ea740059ecb37807ba47b84b33d1447435a8d868 upstream.
This fixes a Spectre-v1/L1TF vulnerability in __kvm_set_dr() and kvm_get_dr().
Both kvm_get_dr() and kvm_set_dr() (a wrapper of __kvm_set_dr()) are exported symbols so KVM should tream them conservatively from a security perspective.
--- arch/x86/kvm/x86.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/x86/kvm/x86.c +6 -2
@@ -1054,9 +1054,11 @@ static u64 kvm_dr6_fixed(struct kvm_vcpustatic int __kvm_set_dr (struct kvm_vcpu *vcpu,int dr,unsigned long val) { +size_t size =ARRAY_SIZE (vcpu->arch.db); +switch (dr) { case 0 ... 3: - vcpu->arch.db[dr] = val; + vcpu->arch.db[array_index_nospec (dr, size)] = val;if (!(vcpu->guest_debug &KVM_GUESTDBG_USE_HW_BP )) vcpu->arch.eff_db[dr] = val;break ;
@@ -1093,9 +1095,11 @@ EXPORT_SYMBOL_GPL(kvm_set_dr);int kvm_get_dr (struct kvm_vcpu *vcpu,int dr,unsigned long *val) { +size_t size =ARRAY_SIZE (vcpu->arch.db); +switch (dr) { case 0 ... 3: - *val = vcpu->arch.db[dr]; + *val = vcpu->arch.db[array_index_nospec (dr, size)];break ;case 4 :/* fall through */
Greg Kroah-Hartman
maintainerPATCH 30/309 srcu: Apply *_ONCE() to ->srcu_last_gp_end
In reply to Greg Kroah-HartmanFrom: Paul E. McKenney <[email protected]>
commit 844a378de3372c923909681706d62336d702531e upstream.
The ->srcu_last_gp_end field is accessed from any CPU at any time by synchronize_srcu(), so non-initialization references need to use READ_ONCE() and WRITE_ONCE(). This commit therefore makes that change.
--- kernel/rcu/srcutree.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/rcu/srcutree.c +4 -3
@@ -530,7 +530,7 @@ static void srcu_gp_end(struct srcu_stru idx =rcu_seq_state (ssp->srcu_gp_seq);WARN_ON_ONCE (idx !=SRCU_STATE_SCAN2 ); cbdelay =srcu_get_delay (ssp); - ssp->srcu_last_gp_end =ktime_get_mono_fast_ns (); +WRITE_ONCE (ssp->srcu_last_gp_end,ktime_get_mono_fast_ns ());rcu_seq_end (&ssp->srcu_gp_seq); gpseq =rcu_seq_current (&ssp->srcu_gp_seq);if (ULONG_CMP_LT (ssp->srcu_gp_seq_needed_exp, gpseq))
@@ -762,6 +762,7 @@ static bool srcu_might_be_idle(struct srunsigned long flags;struct srcu_data *sdp;unsigned long t; +unsigned long tlast;/* If the local srcu_data structure has callbacks, not idle. */ local_irq_save (flags);
@@ -780,9 +781,9 @@ static bool srcu_might_be_idle(struct sr/* First, see if enough time has passed since the last GP. */ t =ktime_get_mono_fast_ns (); + tlast =READ_ONCE (ssp->srcu_last_gp_end);if (exp_holdoff ==0 || -time_in_range_open (t, ssp->srcu_last_gp_end, - ssp->srcu_last_gp_end + exp_holdoff)) +time_in_range_open (t, tlast, tlast + exp_holdoff))return false;/* Too soon after last GP. */ /* Next, check for probable idleness. */
Greg Kroah-Hartman
maintainerPATCH 207/309 KVM: x86: Protect MSR-based index computations from Spectre-v1/L1TF attacks in x86.c
In reply to Greg Kroah-HartmanFrom: Marios Pomonis <[email protected]>
commit 6ec4c5eee1750d5d17951c4e1960d953376a0dda upstream.
This fixes a Spectre-v1/L1TF vulnerability in set_msr_mce() and get_msr_mce().
Both functions contain index computations based on the (attacker-controlled) MSR number.
--- arch/x86/kvm/x86.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
arch/x86/kvm/x86.c +8 -2
@@ -2494,7 +2494,10 @@ static int set_msr_mce(struct kvm_vcpu *default :if (msr >=MSR_IA32_MC0_CTL && msr <MSR_IA32_MCx_CTL (bank_num)) { -u32 offset = msr -MSR_IA32_MC0_CTL ; +u32 offset =array_index_nospec ( + msr -MSR_IA32_MC0_CTL , +MSR_IA32_MCx_CTL (bank_num) -MSR_IA32_MC0_CTL ); +/* only 0 or all 1s can be written to IA32_MCi_CTL * some Linux kernels though clear bit 10 in bank 4 to * workaround a BIOS/GART TBL issue on AMD K8s, ignore
@@ -2921,7 +2924,10 @@ static int get_msr_mce(struct kvm_vcpu *default :if (msr >=MSR_IA32_MC0_CTL && msr <MSR_IA32_MCx_CTL (bank_num)) { -u32 offset = msr -MSR_IA32_MC0_CTL ; +u32 offset =array_index_nospec ( + msr -MSR_IA32_MC0_CTL , +MSR_IA32_MCx_CTL (bank_num) -MSR_IA32_MC0_CTL ); + data = vcpu->arch.mce_banks[offset];break ; }
Greg Kroah-Hartman
maintainerPATCH 208/309 KVM: x86: Protect x86_decode_insn from Spectre-v1/L1TF attacks
In reply to Greg Kroah-HartmanFrom: Marios Pomonis <[email protected]>
commit 3c9053a2cae7ba2ba73766a34cea41baa70f57f7 upstream.
This fixes a Spectre-v1/L1TF vulnerability in x86_decode_insn(). kvm_emulate_instruction() (an ancestor of x86_decode_insn()) is an exported symbol, so KVM should treat it conservatively from a security perspective.
--- arch/x86/kvm/emulate.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
arch/x86/kvm/emulate.c +8 -3
@@ -5317,10 +5317,15 @@ done_prefixes: }break ;case Escape: -if (ctxt->modrm >0xbf ) - opcode = opcode.u.esc->high[ctxt->modrm -0xc0 ]; -else +if (ctxt->modrm >0xbf ) { +size_t size =ARRAY_SIZE (opcode.u.esc->high); +u32 index =array_index_nospec ( + ctxt->modrm -0xc0 , size); + + opcode = opcode.u.esc->high[index]; + }else { opcode = opcode.u.esc->op[(ctxt->modrm >>3 ) &7 ]; + }break ;case InstrDual:if ((ctxt->modrm >>6 ) ==3 )
Greg Kroah-Hartman
maintainerPATCH 210/309 KVM: x86: Fix potential put_fpu() w/o load_fpu() on MPX platform
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit f958bd2314d117f8c29f4821401bc1925bc2e5ef upstream.
Unlike most state managed by XSAVE, MPX is initialized to zero on INIT. Because INITs are usually recognized in the context of a VCPU_RUN call, kvm_vcpu_reset() puts the guest's FPU so that the FPU state is resident in memory, zeros the MPX state, and reloads FPU state to hardware. But, in the unlikely event that an INIT is recognized during kvm_arch_vcpu_ioctl_get_mpstate() via kvm_apic_accept_events(), kvm_vcpu_reset() will call kvm_put_guest_fpu() without a preceding kvm_load_guest_fpu() and corrupt the guest's FPU state (and possibly userspace's FPU state as well).
Given that MPX is being removed from the kernel[*], fix the bug with the simple-but-ugly approach of loading the guest's FPU during KVM_GET_MP_STATE.
[*] See commit f240652b6032b ("x86/mpx: Remove MPX APIs").
--- arch/x86/kvm/x86.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/kvm/x86.c +4 -0
@@ -8698,6 +8698,8 @@ int kvm_arch_vcpu_ioctl_get_mpstate(stru struct kvm_mp_state *mp_state) {vcpu_load (vcpu); +if (kvm_mpx_supported ()) +kvm_load_guest_fpu (vcpu);kvm_apic_accept_events (vcpu); if (vcpu->arch.mp_state == KVM_MP_STATE_HALTED &&
@@ -8706,6 +8708,8 @@ int kvm_arch_vcpu_ioctl_get_mpstate(struelse mp_state->mp_state = vcpu->arch.mp_state; +if (kvm_mpx_supported ()) +kvm_put_guest_fpu (vcpu);vcpu_put (vcpu);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 215/309 x86/kvm: Introduce kvm_(un)map_gfn()
In reply to Greg Kroah-HartmanFrom: Boris Ostrovsky <[email protected]>
commit 1eff70a9abd46f175defafd29bc17ad456f398a7 upstream.
kvm_vcpu_(un)map operates on gfns from any current address space. In certain cases we want to make sure we are not mapping SMRAM and for that we can use kvm_(un)map_gfn() that we are introducing in this patch.
This is part of CVE-2019-3016.
--- include/linux/kvm_host.h | 2 ++ virt/kvm/kvm_main.c | 29 ++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-)
include/linux/kvm_host.h +2 -0
@@ -758,8 +758,10 @@ struct kvm_memory_slot *kvm_vcpu_gfn_to_kvm_pfn_t kvm_vcpu_gfn_to_pfn_atomic (struct kvm_vcpu *vcpu,gfn_t gfn);kvm_pfn_t kvm_vcpu_gfn_to_pfn (struct kvm_vcpu *vcpu,gfn_t gfn);int kvm_vcpu_map (struct kvm_vcpu *vcpu,gpa_t gpa,struct kvm_host_map *map); +int kvm_map_gfn (struct kvm_vcpu *vcpu,gfn_t gfn,struct kvm_host_map *map);struct page *kvm_vcpu_gfn_to_page (struct kvm_vcpu *vcpu,gfn_t gfn);void kvm_vcpu_unmap (struct kvm_vcpu *vcpu,struct kvm_host_map *map,bool dirty); +int kvm_unmap_gfn (struct kvm_vcpu *vcpu,struct kvm_host_map *map,bool dirty);unsigned long kvm_vcpu_gfn_to_hva (struct kvm_vcpu *vcpu,gfn_t gfn);unsigned long kvm_vcpu_gfn_to_hva_prot (struct kvm_vcpu *vcpu,gfn_t gfn,bool *writable); int kvm_vcpu_read_guest_page(struct kvm_vcpu *vcpu, gfn_t gfn, void *data, int offset,
virt/kvm/kvm_main.c +24 -5
@@ -1809,12 +1809,13 @@ struct page *gfn_to_page(struct kvm *kvm }EXPORT_SYMBOL_GPL (gfn_to_page); -static int __kvm_map_gfn (struct kvm_memory_slot *slot,gfn_t gfn, +static int __kvm_map_gfn (struct kvm_memslots *slots,gfn_t gfn,struct kvm_host_map *map) {kvm_pfn_t pfn;void *hva =NULL ;struct page *page =KVM_UNMAPPED_PAGE ; +struct kvm_memory_slot *slot =__gfn_to_memslot (slots, gfn);if (!map)return -EINVAL ;
@@ -1843,14 +1844,20 @@ static int __kvm_map_gfn(struct kvm_memoreturn 0 ; } +int kvm_map_gfn (struct kvm_vcpu *vcpu,gfn_t gfn,struct kvm_host_map *map) +{ +return __kvm_map_gfn (kvm_memslots (vcpu->kvm), gfn, map); +} +EXPORT_SYMBOL_GPL (kvm_map_gfn); +int kvm_vcpu_map (struct kvm_vcpu *vcpu,gfn_t gfn,struct kvm_host_map *map) { -return __kvm_map_gfn (kvm_vcpu_gfn_to_memslot (vcpu, gfn), gfn, map); +return __kvm_map_gfn (kvm_vcpu_memslots (vcpu), gfn, map); }EXPORT_SYMBOL_GPL (kvm_vcpu_map); -void kvm_vcpu_unmap (struct kvm_vcpu *vcpu,struct kvm_host_map *map, -bool dirty) +static void __kvm_unmap_gfn (struct kvm_memory_slot *memslot, +struct kvm_host_map *map,bool dirty) {if (!map)return ;
@@ -1866,7 +1873,7 @@ void kvm_vcpu_unmap(struct kvm_vcpu *vcp#endif if (dirty) { -kvm_vcpu_mark_page_dirty (vcpu, map->gfn); +mark_page_dirty_in_slot (memslot, map->gfn);kvm_release_pfn_dirty (map->pfn); }else {kvm_release_pfn_clean (map->pfn);
@@ -1875,6 +1882,18 @@ void kvm_vcpu_unmap(struct kvm_vcpu *vcp map->hva =NULL ; map->page =NULL ; } + +int kvm_unmap_gfn (struct kvm_vcpu *vcpu,struct kvm_host_map *map,bool dirty) +{ +__kvm_unmap_gfn (gfn_to_memslot (vcpu->kvm, map->gfn), map, dirty); +return 0 ; +} +EXPORT_SYMBOL_GPL (kvm_unmap_gfn); + +void kvm_vcpu_unmap (struct kvm_vcpu *vcpu,struct kvm_host_map *map,bool dirty) +{ +__kvm_unmap_gfn (kvm_vcpu_gfn_to_memslot (vcpu, map->gfn), map, dirty); +}EXPORT_SYMBOL_GPL (kvm_vcpu_unmap);struct page *kvm_vcpu_gfn_to_page (struct kvm_vcpu *vcpu,gfn_t gfn)
Greg Kroah-Hartman
maintainerPATCH 36/309 brcmfmac: Fix memory leak in brcmf_usbdev_qinit
In reply to Greg Kroah-HartmanFrom: Navid Emamdoost <[email protected]>
commit 4282dc057d750c6a7dd92953564b15c26b54c22c upstream.
In the implementation of brcmf_usbdev_qinit() the allocated memory for reqs is leaking if usb_alloc_urb() fails. Release reqs in the error handling path.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c +1 -0
@@ -430,6 +430,7 @@ fail:usb_free_urb (req->urb);list_del (q->next); } +kfree (reqs);return NULL ; }
Greg Kroah-Hartman
maintainerPATCH 214/309 x86/kvm: Be careful not to clear KVM_VCPU_FLUSH_TLB bit
In reply to Greg Kroah-HartmanFrom: Boris Ostrovsky <[email protected]>
commit 8c6de56a42e0c657955e12b882a81ef07d1d073e upstream.
kvm_steal_time_set_preempted() may accidentally clear KVM_VCPU_FLUSH_TLB bit if it is called more than once while VCPU is preempted.
This is part of CVE-2019-3016.
(This bug was also independently discovered by Jim Mattson <[email protected]>)
--- arch/x86/kvm/x86.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kvm/x86.c +3 -0
@@ -3499,6 +3499,9 @@ static void kvm_steal_time_set_preemptedif (!(vcpu->arch.st.msr_val &KVM_MSR_ENABLED ))return ; +if (vcpu->arch.st.steal.preempted) +return ; + vcpu->arch.st.steal.preempted =KVM_VCPU_PREEMPTED ; kvm_write_guest_offset_cached(vcpu->kvm, &vcpu->arch.st.stime,
Greg Kroah-Hartman
maintainerPATCH 216/309 x86/KVM: Make sure KVM_VCPU_FLUSH_TLB flag is not missed
In reply to Greg Kroah-HartmanFrom: Boris Ostrovsky <[email protected]>
commit b043138246a41064527cf019a3d51d9f015e9796 upstream.
There is a potential race in record_steal_time() between setting host-local vcpu->arch.st.steal.preempted to zero (i.e. clearing KVM_VCPU_PREEMPTED) and propagating this value to the guest with kvm_write_guest_cached(). Between those two events the guest may still see KVM_VCPU_PREEMPTED in its copy of kvm_steal_time, set KVM_VCPU_FLUSH_TLB and assume that hypervisor will do the right thing. Which it won't.
Instad of copying, we should map kvm_steal_time and that will guarantee atomicity of accesses to @preempted.
This is part of CVE-2019-3016.
--- arch/x86/kvm/x86.c | 51 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-)
arch/x86/kvm/x86.c +30 -21
@@ -2593,45 +2593,47 @@ static void kvm_vcpu_flush_tlb(struct kvstatic void record_steal_time (struct kvm_vcpu *vcpu) { +struct kvm_host_map map; +struct kvm_steal_time *st; +if (!(vcpu->arch.st.msr_val &KVM_MSR_ENABLED ))return ; -if (unlikely (kvm_read_guest_cached (vcpu->kvm, &vcpu->arch.st.stime, - &vcpu->arch.st.steal,sizeof (struct kvm_steal_time )))) +/* -EAGAIN is returned in atomic context so we can just return. */ +if (kvm_map_gfn (vcpu, vcpu->arch.st.msr_val >>PAGE_SHIFT , + &map, &vcpu->arch.st.cache, false))return ; + st = map.hva + +offset_in_page (vcpu->arch.st.msr_val &KVM_STEAL_VALID_BITS ); +/* * Doing a TLB flush here, on the guest's behalf, can avoid * expensive IPIs. */ trace_kvm_pv_tlb_flush (vcpu->vcpu_id, - vcpu->arch.st.steal.preempted &KVM_VCPU_FLUSH_TLB ); -if (xchg (&vcpu->arch.st.steal.preempted,0 ) &KVM_VCPU_FLUSH_TLB ) + st->preempted &KVM_VCPU_FLUSH_TLB ); +if (xchg (&st->preempted,0 ) &KVM_VCPU_FLUSH_TLB )kvm_vcpu_flush_tlb (vcpu, false); -if (vcpu->arch.st.steal.version &1 ) - vcpu->arch.st.steal.version +=1 ;/* first time write, random junk */ + vcpu->arch.st.steal.preempted =0 ; - vcpu->arch.st.steal.version +=1 ; +if (st->version &1 ) + st->version +=1 ;/* first time write, random junk */ -kvm_write_guest_cached (vcpu->kvm, &vcpu->arch.st.stime, - &vcpu->arch.st.steal,sizeof (struct kvm_steal_time )); + st->version +=1 ;smp_wmb (); - vcpu->arch.st.steal.steal += current->sched_info.run_delay - + st->steal += current->sched_info.run_delay - vcpu->arch.st.last_steal; vcpu->arch.st.last_steal = current->sched_info.run_delay; -kvm_write_guest_cached (vcpu->kvm, &vcpu->arch.st.stime, - &vcpu->arch.st.steal,sizeof (struct kvm_steal_time )); -smp_wmb (); - vcpu->arch.st.steal.version +=1 ; + st->version +=1 ; -kvm_write_guest_cached (vcpu->kvm, &vcpu->arch.st.stime, - &vcpu->arch.st.steal,sizeof (struct kvm_steal_time )); +kvm_unmap_gfn (vcpu, &map, &vcpu->arch.st.cache, true, false); }int kvm_set_msr_common (struct kvm_vcpu *vcpu,struct msr_data *msr_info)
@@ -3496,18 +3498,25 @@ void kvm_arch_vcpu_load(struct kvm_vcpustatic void kvm_steal_time_set_preempted (struct kvm_vcpu *vcpu) { +struct kvm_host_map map; +struct kvm_steal_time *st; +if (!(vcpu->arch.st.msr_val &KVM_MSR_ENABLED ))return ;if (vcpu->arch.st.steal.preempted)return ; - vcpu->arch.st.steal.preempted =KVM_VCPU_PREEMPTED ; +if (kvm_map_gfn (vcpu, vcpu->arch.st.msr_val >>PAGE_SHIFT , &map, + &vcpu->arch.st.cache, true)) +return ; + + st = map.hva + +offset_in_page (vcpu->arch.st.msr_val &KVM_STEAL_VALID_BITS ); + + st->preempted = vcpu->arch.st.steal.preempted =KVM_VCPU_PREEMPTED ; -kvm_write_guest_offset_cached (vcpu->kvm, &vcpu->arch.st.stime, - &vcpu->arch.st.steal.preempted, - offsetof(struct kvm_steal_time , preempted), -sizeof (vcpu->arch.st.steal.preempted)); +kvm_unmap_gfn (vcpu, &map, &vcpu->arch.st.cache, true, true); }void kvm_arch_vcpu_put (struct kvm_vcpu *vcpu)
Greg Kroah-Hartman
maintainerPATCH 218/309 x86/KVM: Clean up hosts steal time structure
In reply to Greg Kroah-HartmanFrom: Boris Ostrovsky <[email protected]>
commit a6bd811f1209fe1c64c9f6fd578101d6436c6b6e upstream.
Now that we are mapping kvm_steal_time from the guest directly we don't need keep a copy of it in kvm_vcpu_arch.st. The same is true for the stime field.
This is part of CVE-2019-3016.
--- arch/x86/include/asm/kvm_host.h | 3 +-- arch/x86/kvm/x86.c | 11 +++-------- 2 files changed, 4 insertions(+), 10 deletions(-)
arch/x86/include/asm/kvm_host.h +1 -2
@@ -667,10 +667,9 @@ struct kvm_vcpu_arch {bool pvclock_set_guest_stopped_request;struct { +u8 preempted;u64 msr_val;u64 last_steal; -struct gfn_to_hva_cache stime; -struct kvm_steal_time steal;struct gfn_to_pfn_cache cache; } st;
arch/x86/kvm/x86.c +3 -8
@@ -2616,7 +2616,7 @@ static void record_steal_time(struct kvmif (xchg (&st->preempted,0 ) &KVM_VCPU_FLUSH_TLB )kvm_vcpu_flush_tlb (vcpu, false); - vcpu->arch.st.steal.preempted =0 ; + vcpu->arch.st.preempted =0 ;if (st->version &1 ) st->version +=1 ;/* first time write, random junk */
@@ -2786,11 +2786,6 @@ int kvm_set_msr_common(struct kvm_vcpu *if (data &KVM_STEAL_RESERVED_MASK )return 1 ; -if (kvm_gfn_to_hva_cache_init (vcpu->kvm, &vcpu->arch.st.stime, - data &KVM_STEAL_VALID_BITS , -sizeof (struct kvm_steal_time ))) -return 1 ; - vcpu->arch.st.msr_val = data;if (!(data &KVM_MSR_ENABLED ))
@@ -3504,7 +3499,7 @@ static void kvm_steal_time_set_preemptedif (!(vcpu->arch.st.msr_val &KVM_MSR_ENABLED ))return ; -if (vcpu->arch.st.steal.preempted) +if (vcpu->arch.st.preempted)return ; if (kvm_map_gfn(vcpu, vcpu->arch.st.msr_val >> PAGE_SHIFT, &map,
@@ -3514,7 +3509,7 @@ static void kvm_steal_time_set_preempted st = map.hva +offset_in_page (vcpu->arch.st.msr_val &KVM_STEAL_VALID_BITS ); - st->preempted = vcpu->arch.st.steal.preempted =KVM_VCPU_PREEMPTED ; + st->preempted = vcpu->arch.st.preempted =KVM_VCPU_PREEMPTED ;kvm_unmap_gfn (vcpu, &map, &vcpu->arch.st.cache, true, true); }
Greg Kroah-Hartman
maintainerPATCH 182/309 sunrpc: expiry_time should be seconds not timeval
In reply to Greg Kroah-HartmanFrom: Roberto Bergantinos Corpas <[email protected]>
commit 3d96208c30f84d6edf9ab4fac813306ac0d20c10 upstream.
When upcalling gssproxy, cache_head.expiry_time is set as a timeval, not seconds since boot. As such, RPC cache expiry logic will not clean expired objects created under auth.rpcsec.context cache.
This has proven to cause kernel memory leaks on field. Using 64 bit variants of getboottime/timespec
Expiration times have worked this way since 2010's c5b29f885afe "sunrpc:
use seconds since boot in expiry cache". The gssproxy code introduced in 2012 added gss_proxy_save_rsc and introduced the bug. That's a while for this to lurk, but it required a bit of an extreme case to make it obvious.
--- net/sunrpc/auth_gss/svcauth_gss.c | 4 ++++ 1 file changed, 4 insertions(+)
net/sunrpc/auth_gss/svcauth_gss.c +4 -0
@@ -1245,6 +1245,7 @@ static int gss_proxy_save_rsc(struct cacdprintk ("RPC: No creds found!\n" ); goto out; }else { +struct timespec64 boot;/* steal creds */ rsci.cred = ud->creds;
@@ -1265,6 +1266,9 @@ static int gss_proxy_save_rsc(struct cac &expiry, GFP_KERNEL);if (status) goto out; + +getboottime64 (&boot); + expiry -= boot.tv_sec; } rsci.h.expiry_time = expiry;
Greg Kroah-Hartman
maintainerPATCH 35/309 Bluetooth: btusb: Disable runtime suspend on Realtek devices
In reply to Greg Kroah-HartmanFrom: Kai-Heng Feng <[email protected]>
commit 7ecacafc240638148567742cca41aa7144b4fe1e upstream.
After commit 9e45524a0111 ("Bluetooth: btusb: Fix suspend issue for Realtek devices") both WiFi and Bluetooth stop working after reboot:
[ 34.322617] usb 1-8: reset full-speed USB device number 3 using xhci_hcd [ 34.450401] usb 1-8: device descriptor read/64, error -71 [ 34.694375] usb 1-8: device descriptor read/64, error -71 ... [ 44.599111] rtw_pci 0000:02:00.0: failed to poll offset=0x5 mask=0x3 value=0x0 [ 44.599113] rtw_pci 0000:02:00.0: mac power on failed [ 44.599114] rtw_pci 0000:02:00.0: failed to power on mac [ 44.599114] rtw_pci 0000:02:00.0: leave idle state failed [ 44.599492] rtw_pci 0000:02:00.0: failed to leave ips state [ 44.599493] rtw_pci 0000:02:00.0: failed to leave idle state
That commit removed USB_QUIRK_RESET_RESUME, which not only resets the USB device after resume, it also prevents the device from being runtime suspended by USB core. My experiment shows if the Realtek btusb device ever runtime suspends once, the entire wireless module becomes useless after reboot.
So let's explicitly disable runtime suspend on Realtek btusb device for now.
--- drivers/bluetooth/btusb.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/bluetooth/btusb.c +4 -0
@@ -3819,6 +3819,10 @@ static int btusb_probe(struct usb_interf* (DEVICE_REMOTE_WAKEUP) */ set_bit (BTUSB_WAKEUP_DISABLE , &data->flags); + + err =usb_autopm_get_interface (intf); +if (err <0 ) + goto out_free_dev; }if (id->driver_info &BTUSB_AMP ) {
Greg Kroah-Hartman
maintainerPATCH 230/309 clk: tegra: Mark fuse clock as critical
In reply to Greg Kroah-HartmanFrom: Stephen Warren <[email protected]>
commit bf83b96f87ae2abb1e535306ea53608e8de5dfbb upstream.
For a little over a year, U-Boot on Tegra124 has configured the flow controller to perform automatic RAM re-repair on off->on power transitions of the CPU rail[1]. This is mandatory for correct operation of Tegra124. However, RAM re-repair relies on certain clocks, which the kernel must enable and leave running. The fuse clock is one of those clocks. Mark this clock as critical so that LP1 power mode (system suspend) operates correctly.
[1] 3cc7942a4ae5 ARM: tegra: implement RAM repair
--- drivers/clk/tegra/clk-tegra-periph.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/clk/tegra/clk-tegra-periph.c +5 -1
@@ -785,7 +785,11 @@ static struct tegra_periph_init_data gatGATE ("ahbdma" ,"hclk" ,33 ,0 , tegra_clk_ahbdma,0 ),GATE ("apbdma" ,"pclk" ,34 ,0 , tegra_clk_apbdma,0 ),GATE ("kbc" ,"clk_32k" ,36 ,TEGRA_PERIPH_ON_APB |TEGRA_PERIPH_NO_RESET , tegra_clk_kbc,0 ), -GATE ("fuse" ,"clk_m" ,39 ,TEGRA_PERIPH_ON_APB , tegra_clk_fuse,0 ), +/* +* Critical for RAM re-repair operation, which must occur on resume +* from LP1 system suspend and as part of CCPLEX cluster switching. +*/ +GATE ("fuse" ,"clk_m" ,39 ,TEGRA_PERIPH_ON_APB , tegra_clk_fuse,CLK_IS_CRITICAL ),GATE ("fuse_burn" ,"clk_m" ,39 ,TEGRA_PERIPH_ON_APB , tegra_clk_fuse_burn,0 ),GATE ("kfuse" ,"clk_m" ,40 ,TEGRA_PERIPH_ON_APB , tegra_clk_kfuse,0 ), GATE("apbif", "clk_m", 107, TEGRA_PERIPH_ON_APB, tegra_clk_apbif, 0),
Greg Kroah-Hartman
maintainerPATCH 221/309 KVM: x86: Free wbinvd_dirty_mask if vCPU creation fails
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit 16be9ddea268ad841457a59109963fff8c9de38d upstream.
Free the vCPU's wbinvd_dirty_mask if vCPU creation fails after kvm_arch_vcpu_init(), e.g. when installing the vCPU's file descriptor. Do the freeing by calling kvm_arch_vcpu_free() instead of open coding the freeing. This adds a likely superfluous, but ultimately harmless, call to kvmclock_reset(), which only clears vcpu->arch.pv_time_enabled. Using kvm_arch_vcpu_free() allows for additional cleanup in the future.
--- arch/x86/kvm/x86.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/x86.c +1 -1
@@ -9180,7 +9180,7 @@ void kvm_arch_vcpu_destroy(struct kvm_vckvm_mmu_unload (vcpu);vcpu_put (vcpu); - kvm_x86_ops->vcpu_free (vcpu); +kvm_arch_vcpu_free (vcpu); }void kvm_vcpu_reset (struct kvm_vcpu *vcpu,bool init_event)
Greg Kroah-Hartman
maintainerPATCH 242/309 mtd: spi-nor: Split mt25qu512a (n25q512a) entry into two
In reply to Greg Kroah-HartmanFrom: Vignesh Raghavendra <[email protected]>
commit bd8a6e31b87b39a03ab11820776363640440dbe0 upstream.
mt25q family is different from n25q family of devices, even though manf ID and device IDs are same. mt25q flash has bit 6 set in 5th byte of READ ID response which can be used to distinguish it from n25q variant. mt25q flashes support stateless 4 Byte addressing opcodes where as n25q flashes don't. Therefore, have two separate entries for mt25qu512a and n25q512a.
--- drivers/mtd/spi-nor/spi-nor.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/mtd/spi-nor/spi-nor.c +5 -4
@@ -2310,15 +2310,16 @@ static const struct flash_info spi_nor_i { "n25q256a", INFO(0x20ba19, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { "n25q256ax1", INFO(0x20bb19, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_QUAD_READ) }, { "n25q512ax3", INFO(0x20ba20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) }, + { "mt25qu512a", INFO6(0x20bb20, 0x104400, 64 * 1024, 1024, +SECT_4K |USE_FSR |SPI_NOR_DUAL_READ | + SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) }, + { "n25q512a", INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K | + SPI_NOR_QUAD_READ) }, { "n25q00", INFO(0x20ba21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | NO_CHIP_ERASE) }, { "n25q00a", INFO(0x20bb21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | NO_CHIP_ERASE) }, { "mt25ql02g", INFO(0x20ba22, 0, 64 * 1024, 4096,SECT_4K |USE_FSR |SPI_NOR_QUAD_READ | NO_CHIP_ERASE) }, - { "mt25qu512a (n25q512a)", INFO(0x20bb20, 0, 64 * 1024, 1024, -SECT_4K |USE_FSR |SPI_NOR_DUAL_READ | -SPI_NOR_QUAD_READ | - SPI_NOR_4B_OPCODES) }, { "mt25qu02g", INFO(0x20bb22, 0, 64 * 1024, 4096, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | NO_CHIP_ERASE) }, /* Micron */
Greg Kroah-Hartman
maintainerPATCH 52/309 mm/memory_hotplug: fix remove_memory() lockdep splat
In reply to Greg Kroah-HartmanFrom: Dan Williams <[email protected]>
commit f1037ec0cc8ac1a450974ad9754e991f72884f48 upstream.
The daxctl unit test for the dax_kmem driver currently triggers the (false positive) lockdep splat below. It results from the fact that remove_memory_block_devices() is invoked under the mem_hotplug_lock() causing lockdep entanglements with cpu_hotplug_lock() and sysfs (kernfs active state tracking). It is a false positive because the sysfs attribute path triggering the memory remove is not the same attribute path associated with memory-block device.
sysfs_break_active_protection() is not applicable since there is no real deadlock conflict, instead move memory-block device removal outside the lock. The mem_hotplug_lock() is not needed to synchronize the memory-block device removal vs the page online state, that is already handled by lock_device_hotplug(). Specifically, lock_device_hotplug() is sufficient to allow try_remove_memory() to check the offline state of the memblocks and be assured that any in progress online attempts are flushed / blocked by kernfs_drain() / attribute removal.
The add_memory() path safely creates memblock devices under the mem_hotplug_lock(). There is no kernfs active state synchronization in the memblock device_register() path, so nothing to fix there.
This change is only possible thanks to the recent change that refactored memory block device removal out of arch_remove_memory() (commit 4c4b7f9ba948 "mm/memory_hotplug: remove memory block devices before arch_remove_memory()"), and David's due diligence tracking down the guarantees afforded by kernfs_drain(). Not flagged for -stable since this only impacts ongoing development and lockdep validation, not a runtime issue.
======================================================
WARNING: possible circular locking dependency detected
5.5.0-rc3+ #230 Tainted: G OE
------------------------------------------------------
lt-daxctl/6459 is trying to acquire lock:
ffff99c7f0003510 (kn->count#241){++++}, at: kernfs_remove_by_name_ns+0x41/0x80
but task is already holding lock:
ffffffffa76a5450 (mem_hotplug_lock.rw_sem){++++}, at: percpu_down_write+0x20/0xe0
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #2 (mem_hotplug_lock.rw_sem){++++}:
__lock_acquire+0x39c/0x790
lock_acquire+0xa2/0x1b0
get_online_mems+0x3e/0xb0
kmem_cache_create_usercopy+0x2e/0x260
kmem_cache_create+0x12/0x20
ptlock_cache_init+0x20/0x28
start_kernel+0x243/0x547
secondary_startup_64+0xb6/0xc0
-> #1 (cpu_hotplug_lock.rw_sem){++++}:
__lock_acquire+0x39c/0x790
lock_acquire+0xa2/0x1b0
cpus_read_lock+0x3e/0xb0
online_pages+0x37/0x300
memory_subsys_online+0x17d/0x1c0
device_online+0x60/0x80
state_store+0x65/0xd0
kernfs_fop_write+0xcf/0x1c0
vfs_write+0xdb/0x1d0
ksys_write+0x65/0xe0
do_syscall_64+0x5c/0xa0
entry_SYSCALL_64_after_hwframe+0x49/0xbe
-> #0 (kn->count#241){++++}:
check_prev_add+0x98/0xa40
validate_chain+0x576/0x860
__lock_acquire+0x39c/0x790
lock_acquire+0xa2/0x1b0
__kernfs_remove+0x25f/0x2e0
kernfs_remove_by_name_ns+0x41/0x80
remove_files.isra.0+0x30/0x70
sysfs_remove_group+0x3d/0x80
sysfs_remove_groups+0x29/0x40
device_remove_attrs+0x39/0x70
device_del+0x16a/0x3f0
device_unregister+0x16/0x60
remove_memory_block_devices+0x82/0xb0
try_remove_memory+0xb5/0x130
remove_memory+0x26/0x40
dev_dax_kmem_remove+0x44/0x6a [kmem]
device_release_driver_internal+0xe4/0x1c0
unbind_store+0xef/0x120
kernfs_fop_write+0xcf/0x1c0
vfs_write+0xdb/0x1d0
ksys_write+0x65/0xe0
do_syscall_64+0x5c/0xa0
entry_SYSCALL_64_after_hwframe+0x49/0xbe
other info that might help us debug this:
Chain exists of:
kn->count#241 --> cpu_hotplug_lock.rw_sem --> mem_hotplug_lock.rw_sem
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(mem_hotplug_lock.rw_sem);
lock(cpu_hotplug_lock.rw_sem);
lock(mem_hotplug_lock.rw_sem);
lock(kn->count#241);
*** DEADLOCK ***No fixes tag as this has been a long standing issue that predated the addition of kernfs lockdep annotations.
--- mm/memory_hotplug.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
mm/memory_hotplug.c +6 -3
@@ -1738,8 +1738,6 @@ static int __ref try_remove_memory(int nBUG_ON (check_hotplug_memory_range (start, size)); -mem_hotplug_begin (); -/* * All memory blocks must be offlined before removing memory. Check * whether all memory blocks in question are offline and return error
@@ -1754,9 +1752,14 @@ static int __ref try_remove_memory(int nmemblock_free (start, size);memblock_remove (start, size); -/* remove memory block devices before removing memory */ +/* +* Memory block device removal under the device_hotplug_lock is +* a barrier against racing online attempts. +*/ remove_memory_block_devices (start, size); +mem_hotplug_begin (); +arch_remove_memory (nid, start, size,NULL );__release_memory_resource (start, size);
Greg Kroah-Hartman
maintainerPATCH 55/309 media/v4l2-core: set pages dirty upon releasing DMA buffers
In reply to Greg Kroah-HartmanFrom: John Hubbard <[email protected]>
commit 3c7470b6f68434acae459482ab920d1e3fabd1c7 upstream.
After DMA is complete, and the device and CPU caches are synchronized, it's still required to mark the CPU pages as dirty, if the data was coming from the device. However, this driver was just issuing a bare put_page() call, without any set_page_dirty*() call.
Fix the problem, by calling set_page_dirty_lock() if the CPU pages were potentially receiving data from the device.
--- drivers/media/v4l2-core/videobuf-dma-sg.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/v4l2-core/videobuf-dma-sg.c +4 -1
@@ -349,8 +349,11 @@ int videobuf_dma_free(struct videobuf_dmBUG_ON (dma->sglen);if (dma->pages) { -for (i =0 ; i < dma->nr_pages; i++) +for (i =0 ; i < dma->nr_pages; i++) { +if (dma->direction ==DMA_FROM_DEVICE ) +set_page_dirty_lock (dma->pages[i]);put_page (dma->pages[i]); + }kfree (dma->pages); dma->pages =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 41/309 usb: gadget: f_fs: set req->num_sgs as 0 for non-sg transfer
In reply to Greg Kroah-HartmanFrom: Peter Chen <[email protected]>
commit d2450c6937018d40d4111fe830fa48d4ddceb8d0 upstream.
The UDC core uses req->num_sgs to judge if scatter buffer list is used.
Eg: usb_gadget_map_request_by_dev. For f_fs sync io mode, the request is re-used for each request, so if the 1st request->length > PAGE_SIZE, and the 2nd request->length is <= PAGE_SIZE, the f_fs uses the 1st req->num_sgs for the 2nd request, it causes the UDC core get the wrong req->num_sgs value (The 2nd request doesn't use sg). For f_fs async io mode, it is not harm to initialize req->num_sgs as 0 either, in case, the UDC driver doesn't zeroed request structure.
--- drivers/usb/gadget/function/f_fs.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/gadget/function/f_fs.c +2 -0
@@ -1062,6 +1062,7 @@ static ssize_t ffs_epfile_io(struct file req->num_sgs = io_data->sgt.nents; }else { req->buf = data; + req->num_sgs =0 ; } req->length = data_len;
@@ -1105,6 +1106,7 @@ static ssize_t ffs_epfile_io(struct file req->num_sgs = io_data->sgt.nents; }else { req->buf = data; + req->num_sgs =0 ; } req->length = data_len;
Greg Kroah-Hartman
maintainerPATCH 257/309 virtio_balloon: Fix memory leaks on errors in virtballoon_probe()
In reply to Greg Kroah-HartmanFrom: David Hildenbrand <[email protected]>
commit 1ad6f58ea9364b0a5d8ae06249653ac9304a8578 upstream.
We forget to put the inode and unmount the kernfs used for compaction.
--- drivers/virtio/virtio_balloon.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/virtio/virtio_balloon.c +9 -4
@@ -900,8 +900,7 @@ static int virtballoon_probe(struct virt vb->vb_dev_info.inode =alloc_anon_inode (balloon_mnt->mnt_sb);if (IS_ERR (vb->vb_dev_info.inode)) { err =PTR_ERR (vb->vb_dev_info.inode); -kern_unmount (balloon_mnt); - goto out_del_vqs; + goto out_kern_unmount; } vb->vb_dev_info.inode->i_mapping->a_ops = &balloon_aops;#endif
@@ -912,13 +911,13 @@ static int virtballoon_probe(struct virt*/ if (virtqueue_get_vring_size (vb->free_page_vq) <2 ) { err = -ENOSPC ; - goto out_del_vqs; + goto out_iput; } vb->balloon_wq =alloc_workqueue ("balloon-wq" ,WQ_FREEZABLE |WQ_CPU_INTENSIVE ,0 );if (!vb->balloon_wq) { err = -ENOMEM ; - goto out_del_vqs; + goto out_iput; }INIT_WORK (&vb->report_free_page_work, report_free_page_func); vb->cmd_id_received_cache =VIRTIO_BALLOON_CMD_ID_STOP ;
@@ -952,6 +951,12 @@ static int virtballoon_probe(struct virt out_del_balloon_wq:if (virtio_has_feature (vdev,VIRTIO_BALLOON_F_FREE_PAGE_HINT ))destroy_workqueue (vb->balloon_wq); +out_iput: +#ifdef CONFIG_BALLOON_COMPACTION +iput (vb->vb_dev_info.inode); +out_kern_unmount: +kern_unmount (balloon_mnt); +#endif out_del_vqs: vdev->config->del_vqs (vdev); out_free_vb:
Greg Kroah-Hartman
maintainerPATCH 260/309 ubifs: Fix memory leak from c->sup_node
In reply to Greg Kroah-HartmanFrom: Quanyang Wang <[email protected]>
commit ff90bdfb206e49c8b418811efbdd0c77380fa8c2 upstream.
The c->sup_node is allocated in function ubifs_read_sb_node but is not freed. This will cause memory leak as below:
unreferenced object 0xbc9ce000 (size 4096):
comm "mount", pid 500, jiffies 4294952946 (age 315.820s) hex dump (first 32 bytes):
31 18 10 06 06 7b f1 11 02 00 00 00 00 00 00 00 1....{..........
00 10 00 00 06 00 00 00 00 00 00 00 08 00 00 00 ................
backtrace:
[<d1c503cd>] ubifs_read_superblock+0x48/0xebc
[<a20e14bd>] ubifs_mount+0x974/0x1420
[<8589ecc3>] legacy_get_tree+0x2c/0x50
[<5f1fb889>] vfs_get_tree+0x28/0xfc
[<bbfc7939>] do_mount+0x4f8/0x748
[<4151f538>] ksys_mount+0x78/0xa0
[<d59910a9>] ret_fast_syscall+0x0/0x54
[<1cc40005>] 0x7ea02790Free it in ubifs_umount and in the error path of mount_ubifs.
--- fs/ubifs/super.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ubifs/super.c +2 -0
@@ -1599,6 +1599,7 @@ out_free:vfree (c->ileb_buf);vfree (c->sbuf);kfree (c->bottom_up_buf); +kfree (c->sup_node);ubifs_debugging_exit (c);return err; }
@@ -1641,6 +1642,7 @@ static void ubifs_umount(struct ubifs_invfree (c->ileb_buf);vfree (c->sbuf);kfree (c->bottom_up_buf); +kfree (c->sup_node);ubifs_debugging_exit (c); }
Greg Kroah-Hartman
maintainerPATCH 262/309 ASoC: sgtl5000: Fix VDDA and VDDIO comparison
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
commit e19ecbf105b236a6334fab64d8fd5437b12ee019 upstream.
Comparing the voltage of VDDA and VDDIO to determine whether or not to enable VDDC manual override is insufficient. This is a problem in case the VDDA is supplied from different regulator than VDDIO, while both report the same voltage to the regulator framework. In that case where VDDA and VDDIO is supplied by different regulators, the VDDC manual override must not be applied.
--- sound/soc/codecs/sgtl5000.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/codecs/sgtl5000.c +2 -1
@@ -1344,7 +1344,8 @@ static int sgtl5000_set_power_regs(struc* if vddio == vdda the source of charge pump should be * assigned manually to VDDIO */ -if (vddio == vdda) { +if (regulator_is_equal (sgtl5000->supplies[VDDA ].consumer, + sgtl5000->supplies[VDDIO ].consumer)) { lreg_ctrl |=SGTL5000_VDDC_ASSN_OVRD ; lreg_ctrl |=SGTL5000_VDDC_MAN_ASSN_VDDIO <<SGTL5000_VDDC_MAN_ASSN_SHIFT ;
Greg Kroah-Hartman
maintainerPATCH 72/309 MIPS: boot: fix typo in vmlinux.lzma.its target
In reply to Greg Kroah-HartmanFrom: Alexander Lobakin <[email protected]>
commit 16202c09577f3d0c533274c0410b7de05fb0d458 upstream.
Commit 92b34a976348 ("MIPS: boot: add missing targets for vmlinux.*.its") fixed constant rebuild of *.its files on every make invocation, but due to typo ("lzmo") it made no sense for vmlinux.lzma.its.
--- arch/mips/boot/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/boot/Makefile +1 -1
@@ -123,7 +123,7 @@ $(obj)/vmlinux.its.S: $(addprefix $(srct targets += vmlinux.its targets += vmlinux.gz.its targets += vmlinux.bz2.its -targets += vmlinux.lzmo.its +targets += vmlinux.lzma.its targets += vmlinux.lzo.its quiet_cmd_cpp_its_S = ITS $@
Greg Kroah-Hartman
maintainerPATCH 75/309 powerpc/ptdump: Fix W+X verification
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit d80ae83f1f932ab7af47b54d0d3bef4f4dba489f upstream.
Verification cannot rely on simple bit checking because on some platforms PAGE_RW is 0, checking that a page is not W means checking that PAGE_RO is set instead of checking that PAGE_RW is not set.
Use pte helpers instead of checking bits.
--- arch/powerpc/mm/ptdump/ptdump.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/powerpc/mm/ptdump/ptdump.c +3 -1
@@ -173,10 +173,12 @@ static void dump_addr(struct pg_state *sstatic void note_prot_wx (struct pg_state *st,unsigned long addr) { +pte_t pte =__pte (st->current_flags); +if (!IS_ENABLED (CONFIG_PPC_DEBUG_WX ) || !st->check_wx)return ; -if (!((st->current_flags &pgprot_val (PAGE_KERNEL_X )) ==pgprot_val (PAGE_KERNEL_X ))) +if (!pte_write (pte) || !pte_exec (pte))return ; WARN_ONCE(1, "powerpc/mm: Found insecure W+X mapping at address %p/%pS\n",
Greg Kroah-Hartman
maintainerPATCH 289/309 mfd: rn5t618: Mark ADC control register volatile
In reply to Greg Kroah-HartmanFrom: Andreas Kemnade <[email protected]>
commit 2f3dc25c0118de03a00ddc88b61f7216854f534d upstream.
There is a bit which gets cleared after conversion.
--- drivers/mfd/rn5t618.c | 1 + 1 file changed, 1 insertion(+)
drivers/mfd/rn5t618.c +1 -0
@@ -26,6 +26,7 @@ static bool rn5t618_volatile_reg(structcase RN5T618_WATCHDOGCNT :case RN5T618_DCIRQ : case RN5T618_ILIMDATAH ... RN5T618_AIN0DATAL: +case RN5T618_ADCCNT3 : case RN5T618_IR_ADC1 ... RN5T618_IR_ADC3:case RN5T618_IR_GPR :case RN5T618_IR_GPF :
Greg Kroah-Hartman
maintainerPATCH 288/309 mfd: da9062: Fix watchdog compatible string
In reply to Greg Kroah-HartmanFrom: Marco Felsch <[email protected]>
commit 1112ba02ff1190ca9c15a912f9269e54b46d2d82 upstream.
The watchdog driver compatible is "dlg,da9062-watchdog" and not "dlg,da9062-wdt". Therefore the mfd-core can't populate the of_node and fwnode. As result the watchdog driver can't parse the devicetree.
--- drivers/mfd/da9062-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/da9062-core.c +1 -1
@@ -248,7 +248,7 @@ static const struct mfd_cell da9062_devs .name = "da9062-watchdog", .num_resources = ARRAY_SIZE(da9062_wdt_resources), .resources = da9062_wdt_resources, - .of_compatible = "dlg,da9062-wdt", + .of_compatible = "dlg,da9062-watchdog", }, { .name = "da9062-thermal",
Greg Kroah-Hartman
maintainerPATCH 293/309 btrfs: free block groups after freeing fs trees
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
[ Upstream commit 4e19443da1941050b346f8fc4c368aa68413bc88 ]
Sometimes when running generic/475 we would trip the WARN_ON(cache->reserved) check when free'ing the block groups on umount. This is because sometimes we don't commit the transaction because of IO errors and thus do not cleanup the tree logs until at umount time.
These blocks are still reserved until they are cleaned up, but they aren't cleaned up until _after_ we do the free block groups work. Fix this by moving the free after free'ing the fs roots, that way all of the tree logs are cleaned up and we have a properly cleaned fs. A bunch of loops of generic/475 confirmed this fixes the problem.
--- fs/btrfs/disk-io.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
fs/btrfs/disk-io.c +9 -2
@@ -4046,11 +4046,18 @@ void close_ctree(struct btrfs_fs_info *fs_info)invalidate_inode_pages2 (fs_info->btree_inode->i_mapping);btrfs_stop_all_workers (fs_info); -btrfs_free_block_groups (fs_info); -clear_bit (BTRFS_FS_OPEN , &fs_info->flags);free_root_pointers (fs_info, true); +/* +* We must free the block groups after dropping the fs_roots as we could +* have had an IO error and have left over tree log blocks that aren't +* cleaned up until the fs roots are freed. This makes the block group +* accounting appear to be wrong because there's pending reserved bytes, +* so make sure we do the block group cleanup afterwards. +*/ +btrfs_free_block_groups (fs_info); +iput (fs_info->btree_inode);#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 303/309 cifs: fix mode bits from dir listing when mounted with modefromsid
In reply to Greg Kroah-HartmanFrom: Aurelien Aptel <[email protected]>
commit e3e056c35108661e418c803adfc054bf683426e7 upstream.
When mounting with -o modefromsid, the mode bits are stored in an ACE. Directory enumeration (e.g. ls -l /mnt) triggers an SMB Query Dir which does not include ACEs in its response. The mode bits in this case are silently set to a default value of 755 instead.
This patch marks the dentry created during the directory enumeration as needing re-evaluation (i.e. additional Query Info with ACEs) so that the mode bits can be properly extracted.
Quick repro:
$ mount.cifs //win19.test/data /mnt -o ...,modefromsid $ touch /mnt/foo && chmod 751 /mnt/foo $ stat /mnt/foo # reports 751 (OK) $ sleep 2 # dentry older than 1s by default get invalidated $ ls -l /mnt # since dentry invalid, ls does a Query Dir # and reports foo as 755 (WRONG)
--- fs/cifs/readdir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/cifs/readdir.c +2 -1
@@ -174,7 +174,8 @@ cifs_fill_common_info(struct cifs_fattr* may look wrong since the inodes may not have timed out by the time * "ls" does a stat() call on them. */ -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_CIFS_ACL ) +if ((cifs_sb->mnt_cifs_flags &CIFS_MOUNT_CIFS_ACL ) || + (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MODE_FROM_SID )) fattr->cf_flags |=CIFS_FATTR_NEED_REVAL ; if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL &&
Greg Kroah-Hartman
maintainerPATCH 85/309 mmc: spi: Toggle SPI polarity, do not hardcode it
In reply to Greg Kroah-HartmanFrom: Linus Walleij <[email protected]>
commit af3ed119329cf9690598c5a562d95dfd128e91d6 upstream.
The code in mmc_spi_initsequence() tries to send a burst with high chipselect and for this reason hardcodes the device into SPI_CS_HIGH.
This is not good because the SPI_CS_HIGH flag indicates logical "asserted" CS not always the physical level. In some cases the signal is inverted in the GPIO library and in that case SPI_CS_HIGH is already set, and enforcing SPI_CS_HIGH again will actually drive it low.
Instead of hard-coding this, toggle the polarity so if the default is LOW it goes high to assert chipselect but if it is already high then toggle it low instead.
--- drivers/mmc/host/mmc_spi.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/mmc/host/mmc_spi.c +8 -3
@@ -1134,17 +1134,22 @@ static void mmc_spi_initsequence(struct* SPI protocol. Another is that when chipselect is released while * the card returns BUSY status, the clock must issue several cycles * with chipselect high before the card will stop driving its output. +* +* SPI_CS_HIGH means "asserted" here. In some cases like when using +* GPIOs for chip select, SPI_CS_HIGH is set but this will be logically +* inverted by gpiolib, so if we want to ascertain to drive it high +* we should toggle the default with an XOR as we do here. */ - host->spi->mode |=SPI_CS_HIGH ; + host->spi->mode ^=SPI_CS_HIGH ;if (spi_setup (host->spi) !=0 ) {/* Just warn; most cards work without it. */ dev_warn (&host->spi->dev,"can't change chip-select polarity\n" ); - host->spi->mode &= ~SPI_CS_HIGH ; + host->spi->mode ^=SPI_CS_HIGH ; }else {mmc_spi_readbytes (host,18 ); - host->spi->mode &= ~SPI_CS_HIGH ; + host->spi->mode ^=SPI_CS_HIGH ;if (spi_setup (host->spi) !=0 ) {/* Wot, we can't get the same setup we had before? */ dev_err(&host->spi->dev,
Greg Kroah-Hartman
maintainerPATCH 48/309 memcg: fix a crash in wb_workfn when a device disappears
In reply to Greg Kroah-HartmanFrom: Theodore Ts'o <[email protected]>
commit 68f23b89067fdf187763e75a56087550624fdbee upstream.
Without memcg, there is a one-to-one mapping between the bdi and bdi_writeback structures. In this world, things are fairly straightforward; the first thing bdi_unregister() does is to shutdown the bdi_writeback structure (or wb), and part of that writeback ensures that no other work queued against the wb, and that the wb is fully drained.
With memcg, however, there is a one-to-many relationship between the bdi and bdi_writeback structures; that is, there are multiple wb objects which can all point to a single bdi. There is a refcount which prevents the bdi object from being released (and hence, unregistered). So in theory, the bdi_unregister() *should* only get called once its refcount goes to zero (bdi_put will drop the refcount, and when it is zero, release_bdi gets called, which calls bdi_unregister).
Unfortunately, del_gendisk() in block/gen_hd.c never got the memo about the Brave New memcg World, and calls bdi_unregister directly. It does this without informing the file system, or the memcg code, or anything else. This causes the root wb associated with the bdi to be unregistered, but none of the memcg-specific wb's are shutdown. So when one of these wb's are woken up to do delayed work, they try to dereference their wb->bdi->dev to fetch the device name, but unfortunately bdi->dev is now NULL, thanks to the bdi_unregister() called by del_gendisk(). As a result, *boom*.
Fortunately, it looks like the rest of the writeback path is perfectly happy with bdi->dev and bdi->owner being NULL, so the simplest fix is to create a bdi_dev_name() function which can handle bdi->dev being NULL. This also allows us to bulletproof the writeback tracepoints to prevent them from dereferencing a NULL pointer and crashing the kernel if one is tracing with memcg's enabled, and an iSCSI device dies or a USB storage stick is pulled.
The most common way of triggering this will be hotremoval of a device while writeback with memcg enabled is going on. It was triggering several times a day in a heavily loaded production environment.
Google Bug Id: 145475544
--- fs/fs-writeback.c | 2 +- include/linux/backing-dev.h | 10 ++++++++++ include/trace/events/writeback.h | 37 +++++++++++++++++-------------------- mm/backing-dev.c | 1 + 4 files changed, 29 insertions(+), 21 deletions(-)
fs/fs-writeback.c +1 -1
@@ -2063,7 +2063,7 @@ void wb_workfn(struct work_struct *work) struct bdi_writeback, dwork);long pages_written; -set_worker_desc ("flush-%s" ,dev_name (wb->bdi->dev)); +set_worker_desc ("flush-%s" ,bdi_dev_name (wb->bdi)); current->flags |=PF_SWAPWRITE ; if (likely(!current_is_workqueue_rescuer() ||
include/linux/backing-dev.h +10 -0
@@ -13,6 +13,7 @@#include <linux/fs.h> #include <linux/sched.h> #include <linux/blkdev.h> +#include <linux/device.h> #include <linux/writeback.h> #include <linux/blk-cgroup.h> #include <linux/backing-dev-defs.h>
@@ -504,4 +505,13 @@ static inline int bdi_rw_congested(struc (1 << WB_async_congested)); } +extern const char *bdi_unknown_name; + +static inline const char *bdi_dev_name (struct backing_dev_info *bdi) +{ +if (!bdi || !bdi->dev) +return bdi_unknown_name; +return dev_name (bdi->dev); +} +#endif /* _LINUX_BACKING_DEV_H */
include/trace/events/writeback.h +17 -20
@@ -67,8 +67,8 @@ DECLARE_EVENT_CLASS(writeback_page_templTP_fast_assign (strscpy_pad (__entry->name, - mapping ?dev_name (inode_to_bdi (mapping->host)->dev) :"(unknown)" , - 32); +bdi_dev_name (mapping ?inode_to_bdi (mapping->host) : + NULL), 32); __entry->ino = mapping ? mapping->host->i_ino :0 ; __entry->index = page->index; ),
@@ -111,8 +111,7 @@ DECLARE_EVENT_CLASS(writeback_dirty_inodstruct backing_dev_info *bdi =inode_to_bdi (inode);/* may be called for files on pseudo FSes w/ unregistered bdi */ -strscpy_pad (__entry->name, - bdi->dev ?dev_name (bdi->dev) :"(unknown)" ,32 ); +strscpy_pad (__entry->name,bdi_dev_name (bdi),32 ); __entry->ino = inode->i_ino; __entry->state = inode->i_state; __entry->flags = flags;
@@ -193,7 +192,7 @@ TRACE_EVENT(inode_foreign_history, ),TP_fast_assign ( - strncpy(__entry->name, dev_name(inode_to_bdi(inode)->dev), 32); + strncpy(__entry->name, bdi_dev_name(inode_to_bdi(inode)), 32); __entry->ino = inode->i_ino; __entry->cgroup_ino =__trace_wbc_assign_cgroup (wbc); __entry->history = history;
@@ -222,7 +221,7 @@ TRACE_EVENT(inode_switch_wbs, ),TP_fast_assign ( - strncpy(__entry->name, dev_name(old_wb->bdi->dev), 32); + strncpy(__entry->name, bdi_dev_name(old_wb->bdi), 32); __entry->ino = inode->i_ino; __entry->old_cgroup_ino =__trace_wb_assign_cgroup (old_wb); __entry->new_cgroup_ino =__trace_wb_assign_cgroup (new_wb);
@@ -255,7 +254,7 @@ TRACE_EVENT(track_foreign_dirty,struct address_space *mapping =page_mapping (page);struct inode *inode = mapping ? mapping->host :NULL ; -strncpy (__entry->name,dev_name (wb->bdi->dev),32 ); +strncpy (__entry->name,bdi_dev_name (wb->bdi),32 ); __entry->bdi_id = wb->bdi->id; __entry->ino = inode ? inode->i_ino :0 ; __entry->memcg_id = wb->memcg_css->id;
@@ -288,7 +287,7 @@ TRACE_EVENT(flush_foreign, ), TP_fast_assign( - strncpy(__entry->name, dev_name(wb->bdi->dev), 32); + strncpy(__entry->name, bdi_dev_name(wb->bdi), 32); __entry->cgroup_ino =__trace_wb_assign_cgroup (wb); __entry->frn_bdi_id = frn_bdi_id; __entry->frn_memcg_id = frn_memcg_id;
@@ -318,7 +317,7 @@ DECLARE_EVENT_CLASS(writeback_write_inodTP_fast_assign (strscpy_pad (__entry->name, - dev_name(inode_to_bdi(inode)->dev), 32); + bdi_dev_name(inode_to_bdi(inode)), 32); __entry->ino = inode->i_ino; __entry->sync_mode = wbc->sync_mode; __entry->cgroup_ino =__trace_wbc_assign_cgroup (wbc);
@@ -361,9 +360,7 @@ DECLARE_EVENT_CLASS(writeback_work_class __field(unsigned int, cgroup_ino) ),TP_fast_assign ( - strscpy_pad(__entry->name, - wb->bdi->dev ? dev_name(wb->bdi->dev) : - "(unknown)", 32); + strscpy_pad(__entry->name, bdi_dev_name(wb->bdi), 32); __entry->nr_pages = work->nr_pages; __entry->sb_dev = work->sb ? work->sb->s_dev :0 ; __entry->sync_mode = work->sync_mode;
@@ -416,7 +413,7 @@ DECLARE_EVENT_CLASS(writeback_class, __field(unsigned int, cgroup_ino) ),TP_fast_assign ( - strscpy_pad(__entry->name, dev_name(wb->bdi->dev), 32); + strscpy_pad(__entry->name, bdi_dev_name(wb->bdi), 32); __entry->cgroup_ino =__trace_wb_assign_cgroup (wb); ), TP_printk("bdi %s: cgroup_ino=%u",
@@ -438,7 +435,7 @@ TRACE_EVENT(writeback_bdi_register,__array (char, name,32 ) ),TP_fast_assign ( - strscpy_pad(__entry->name, dev_name(bdi->dev), 32); + strscpy_pad(__entry->name, bdi_dev_name(bdi), 32); ),TP_printk ("bdi %s" , __entry->name
@@ -463,7 +460,7 @@ DECLARE_EVENT_CLASS(wbc_class, ), TP_fast_assign( - strscpy_pad(__entry->name, dev_name(bdi->dev), 32); + strscpy_pad(__entry->name, bdi_dev_name(bdi), 32); __entry->nr_to_write = wbc->nr_to_write; __entry->pages_skipped = wbc->pages_skipped; __entry->sync_mode = wbc->sync_mode;
@@ -514,7 +511,7 @@ TRACE_EVENT(writeback_queue_io, ),TP_fast_assign ( unsigned long *older_than_this = work->older_than_this; -strscpy_pad (__entry->name,dev_name (wb->bdi->dev),32 ); +strscpy_pad (__entry->name,bdi_dev_name (wb->bdi),32 ); __entry->older = older_than_this ? *older_than_this :0 ; __entry->age = older_than_this ? (jiffies - *older_than_this) *1000 /HZ :-1 ;
@@ -600,7 +597,7 @@ TRACE_EVENT(bdi_dirty_ratelimit, ),TP_fast_assign ( - strscpy_pad(__entry->bdi, dev_name(wb->bdi->dev), 32); + strscpy_pad(__entry->bdi, bdi_dev_name(wb->bdi), 32); __entry->write_bw =KBps (wb->write_bandwidth); __entry->avg_write_bw =KBps (wb->avg_write_bandwidth); __entry->dirty_rate =KBps (dirty_rate);
@@ -665,7 +662,7 @@ TRACE_EVENT(balance_dirty_pages, TP_fast_assign( unsigned long freerun = (thresh + bg_thresh) / 2; -strscpy_pad (__entry->bdi,dev_name (wb->bdi->dev),32 ); +strscpy_pad (__entry->bdi,bdi_dev_name (wb->bdi),32 ); __entry->limit = global_wb_domain.dirty_limit; __entry->setpoint = (global_wb_domain.dirty_limit +
@@ -726,7 +723,7 @@ TRACE_EVENT(writeback_sb_inodes_requeue,TP_fast_assign (strscpy_pad (__entry->name, - dev_name(inode_to_bdi(inode)->dev), 32); + bdi_dev_name(inode_to_bdi(inode)), 32); __entry->ino = inode->i_ino; __entry->state = inode->i_state; __entry->dirtied_when = inode->dirtied_when;
@@ -800,7 +797,7 @@ DECLARE_EVENT_CLASS(writeback_single_inoTP_fast_assign (strscpy_pad (__entry->name, - dev_name(inode_to_bdi(inode)->dev), 32); + bdi_dev_name(inode_to_bdi(inode)), 32); __entry->ino = inode->i_ino; __entry->state = inode->i_state; __entry->dirtied_when = inode->dirtied_when;
mm/backing-dev.c +1 -0
@@ -21,6 +21,7 @@ struct backing_dev_info noop_backing_devEXPORT_SYMBOL_GPL (noop_backing_dev_info);static struct class *bdi_class; +const char *bdi_unknown_name ="(unknown)" ;/* * bdi_lock protects bdi_tree and updates to bdi_list. bdi_list has RCU
Greg Kroah-Hartman
maintainerPATCH 86/309 ACPI: video: Do not export a non working backlight interface on MSI MS-7721 boards
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
commit d21a91629f4b8e794fc4c0e0c17c85cedf1d806c upstream.
Despite our heuristics to not wrongly export a non working ACPI backlight interface on desktop machines, we still end up exporting one on desktops using a motherboard from the MSI MS-7721 series.
I've looked at improving the heuristics, but in this case a quirk seems to be the only way to solve this.
While at it also add a comment to separate the video_detect_force_none entries in the video_detect_dmi_table from other type of entries, as we already do for the other entry types.
--- drivers/acpi/video_detect.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/acpi/video_detect.c +13 -0
@@ -336,6 +336,11 @@ static const struct dmi_system_id video_ DMI_MATCH(DMI_PRODUCT_NAME, "Precision 7510"), }, }, + +/* +* Desktops which falsely report a backlight and which our heuristics +* for this do not catch. +*/ { .callback = video_detect_force_none, .ident = "Dell OptiPlex 9020M",
@@ -344,6 +349,14 @@ static const struct dmi_system_id video_ DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 9020M"), }, }, + { + .callback = video_detect_force_none, + .ident = "MSI MS-7721", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "MSI"), + DMI_MATCH(DMI_PRODUCT_NAME, "MS-7721"), + }, + }, { }, };
Greg Kroah-Hartman
maintainerPATCH 108/309 fs: allow deduplication of eof block into the end of the destination file
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit a5e6ea18e3d132be4716eb5fdd520c2c234e3003 upstream.
We always round down, to a multiple of the filesystem's block size, the length to deduplicate at generic_remap_check_len(). However this is only needed if an attempt to deduplicate the last block into the middle of the destination file is requested, since that leads into a corruption if the length of the source file is not block size aligned. When an attempt to deduplicate the last block into the end of the destination file is requested, we should allow it because it is safe to do it - there's no stale data exposure and we are prepared to compare the data ranges for a length not aligned to the block (or page) size - in fact we even do the data compare before adjusting the deduplication length.
After btrfs was updated to use the generic helpers from VFS (by commit 34a28e3d77535e ("Btrfs: use generic_remap_file_range_prep() for cloning and deduplication")) we started to have user reports of deduplication not reflinking the last block anymore, and whence users getting lower deduplication scores. The main use case is deduplication of entire files that have a size not aligned to the block size of the filesystem.
We already allow cloning the last block to the end (and beyond) of the destination file, so allow for deduplication as well.
--- fs/read_write.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
fs/read_write.c +4 -6
@@ -1777,10 +1777,9 @@ static int remap_verify_area(struct file* else. Assume that the offsets have already been checked for block * alignment. * -* For deduplication we always scale down to the previous block because we -* can't meaningfully compare post-EOF contents. -* -* For clone we only link a partial EOF block above the destination file's EOF. +* For clone we only link a partial EOF block above or at the destination file's +* EOF. For deduplication we accept a partial EOF block only if it ends at the +* destination file's EOF (can not link it into the middle of a file). * * Shorten the request if possible. */
@@ -1796,8 +1795,7 @@ static int generic_remap_check_len(strucif ((*len & blkmask) ==0 )return 0 ; -if ((remap_flags &REMAP_FILE_DEDUP ) || - pos_out + *len <i_size_read (inode_out)) +if (pos_out + *len <i_size_read (inode_out)) new_len &= ~blkmask;if (new_len == *len)
Greg Kroah-Hartman
maintainerPATCH 91/309 fscrypt: dont print name of busy file when removing key
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit 13a10da94615d81087e718517794f2868a8b3fab upstream.
When an encryption key can't be fully removed due to file(s) protected by it still being in-use, we shouldn't really print the path to one of these files to the kernel log, since parts of this path are likely to be encrypted on-disk, and (depending on how the system is set up) the confidentiality of this path might be lost by printing it to the log.
This is a trade-off: a single file path often doesn't matter at all, especially if it's a directory; the kernel log might still be protected in some way; and I had originally hoped that any "inode(s) still busy" bugs (which are security weaknesses in their own right) would be quickly fixed and that to do so it would be super helpful to always know the file path and not have to run 'find dir -inum $inum' after the fact.
But in practice, these bugs can be hard to fix (e.g. due to asynchronous process killing that is difficult to eliminate, for performance reasons), and also not tied to specific files, so knowing a file path doesn't necessarily help.
So to be safe, for now let's just show the inode number, not the path. If someone really wants to know a path they can use 'find -inum'.
--- fs/crypto/keyring.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-)
fs/crypto/keyring.c +2 -13
@@ -664,9 +664,6 @@ static int check_for_busy_inodes(structstruct list_head *pos;size_t busy_count =0 ;unsigned long ino; -struct dentry *dentry; -char _path[256 ]; -char *path =NULL ;spin_lock (&mk->mk_decrypted_inodes_lock);
@@ -685,22 +682,14 @@ static int check_for_busy_inodes(struct struct fscrypt_info, ci_master_key_link)->ci_inode; ino = inode->i_ino; - dentry =d_find_alias (inode); }spin_unlock (&mk->mk_decrypted_inodes_lock); -if (dentry) { - path =dentry_path (dentry, _path,sizeof (_path)); -dput (dentry); - } -if (IS_ERR_OR_NULL (path)) - path ="(unknown)" ; -fscrypt_warn (NULL , -"%s: %zu inode(s) still busy after removing key with %s %*phN, including ino %lu (%s)" , +"%s: %zu inode(s) still busy after removing key with %s %*phN, including ino %lu" , sb->s_id, busy_count,master_key_spec_type (&mk->mk_spec),master_key_spec_len (&mk->mk_spec), (u8 *)&mk->mk_spec.u, - ino, path); + ino);return -EBUSY ; }
Greg Kroah-Hartman
maintainerPATCH 156/309 crypto: hisilicon - Use the offset fields in sqe to avoid need to split scatterlists
In reply to Greg Kroah-HartmanFrom: Jonathan Cameron <[email protected]>
commit 484a897ffa3005f16cd9a31efd747bcf8155826f upstream.
We can configure sgl offset fields in ZIP sqe to let ZIP engine read/write sgl data with skipped data. Hence no need to splite the sgl.
--- drivers/crypto/hisilicon/Kconfig | 1 drivers/crypto/hisilicon/zip/zip.h | 4 + drivers/crypto/hisilicon/zip/zip_crypto.c | 92 +++++++----------------------- 3 files changed, 27 insertions(+), 70 deletions(-)
drivers/crypto/hisilicon/Kconfig +0 -1
@@ -35,6 +35,5 @@ config CRYPTO_DEV_HISI_ZIP depends on ARM64 && PCI && PCI_MSI select CRYPTO_DEV_HISI_QM select CRYPTO_HISI_SGL - select SG_SPLIT help Support for HiSilicon ZIP Driver
drivers/crypto/hisilicon/zip/zip.h +4 -0
@@ -12,6 +12,10 @@/* hisi_zip_sqe dw3 */ #define HZIP_BD_STATUS_M GENMASK(7, 0) +/* hisi_zip_sqe dw7 */ +#define HZIP_IN_SGE_DATA_OFFSET_M GENMASK(23, 0) +/* hisi_zip_sqe dw8 */ +#define HZIP_OUT_SGE_DATA_OFFSET_M GENMASK(23, 0)/* hisi_zip_sqe dw9 */ #define HZIP_REQ_TYPE_M GENMASK(7, 0)#define HZIP_ALG_TYPE_ZLIB 0x02
drivers/crypto/hisilicon/zip/zip_crypto.c +23 -69
178 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 164/309 scsi: qla2xxx: Fix unbound NVME response length
In reply to Greg Kroah-HartmanFrom: Arun Easi <[email protected]>
commit 00fe717ee1ea3c2979db4f94b1533c57aed8dea9 upstream.
On certain cases when response length is less than 32, NVME response data is supplied inline in IOCB. This is indicated by some combination of state flags. There was an instance when a high, and incorrect, response length was indicated causing driver to overrun buffers. Fix this by checking and limiting the response payload length.
--- drivers/scsi/qla2xxx/qla_dbg.c | 6 ------ drivers/scsi/qla2xxx/qla_dbg.h | 6 ++++++ drivers/scsi/qla2xxx/qla_isr.c | 12 ++++++++++++ 3 files changed, 18 insertions(+), 6 deletions(-)
drivers/scsi/qla2xxx/qla_dbg.c +0 -6
@@ -2519,12 +2519,6 @@ qla83xx_fw_dump_failed:/* Driver Debug Functions. */ /****************************************************************************/ -static inline int -ql_mask_match (uint level) -{ -return (level & ql2xextended_error_logging) == level; -} -/* * This function is for formatting and logging debug information. * It is to be used when vha is available. It formats the message
drivers/scsi/qla2xxx/qla_dbg.h +6 -0
@@ -374,3 +374,9 @@ extern int qla24xx_dump_ram(struct qla_hextern void qla24xx_pause_risc (struct device_reg_24xx __iomem *,struct qla_hw_data *);extern int qla24xx_soft_reset (struct qla_hw_data *); + +static inline int +ql_mask_match (uint level) +{ +return (level & ql2xextended_error_logging) == level; +}
drivers/scsi/qla2xxx/qla_isr.c +12 -0
@@ -1897,6 +1897,18 @@ static void qla24xx_nvme_iocb_entry(scsi inbuf = (uint32_t *)&sts->nvme_ersp_data; outbuf = (uint32_t *)fd->rspaddr; iocb->u.nvme.rsp_pyld_len =le16_to_cpu (sts->nvme_rsp_pyld_len); +if (unlikely (iocb->u.nvme.rsp_pyld_len > +sizeof (struct nvme_fc_ersp_iu ))) { +if (ql_mask_match (ql_dbg_io)) { +WARN_ONCE (1 ,"Unexpected response payload length %u.\n" , + iocb->u.nvme.rsp_pyld_len); +ql_log (ql_log_warn, fcport->vha,0x5100 , +"Unexpected response payload length %u.\n" , + iocb->u.nvme.rsp_pyld_len); + } + iocb->u.nvme.rsp_pyld_len = +sizeof (struct nvme_fc_ersp_iu ); + } iter = iocb->u.nvme.rsp_pyld_len >>2 ;for (; iter; iter--) *outbuf++ =swab32 (*inbuf++);
Greg Kroah-Hartman
maintainerPATCH 194/309 watchdog: fix UAF in reboot notifier handling in watchdog core code
In reply to Greg Kroah-HartmanFrom: Vladis Dronov <[email protected]>
commit 69503e585192fdd84b240f18a0873d20e18a2e0a upstream.
After the commit 44ea39420fc9 ("drivers/watchdog: make use of devm_register_reboot_notifier()") the struct notifier_block reboot_nb in the struct watchdog_device is removed from the reboot notifiers chain at the time watchdog's chardev is closed. But at least in i6300esb.c case reboot_nb is embedded in the struct esb_dev which can be freed on its device removal and before the chardev is closed, thus UAF at reboot:
[ 7.728581] esb_probe: esb_dev.watchdog_device ffff91316f91ab28
ts# uname -r note the address ^^^
5.5.0-rc5-ae6088-wdog
ts# ./openwdog0 &
[1] 696
ts# opened /dev/watchdog0, sleeping 10s...
ts# echo 1 > /sys/devices/pci0000\:00/0000\:00\:09.0/remove
[ 178.086079] devres:rel_nodes: dev ffff91317668a0b0 data ffff91316f91ab28
esb_dev.watchdog_device.reboot_nb memory is freed here ^^^
ts# ...woken up
[ 181.459010] devres:rel_nodes: dev ffff913171781000 data ffff913174a1dae8
[ 181.460195] devm_unreg_reboot_notifier: res ffff913174a1dae8 nb ffff91316f91ab78
attempt to use memory already freed ^^^
[ 181.461063] devm_unreg_reboot_notifier: nb->call 6b6b6b6b6b6b6b6b
[ 181.461243] devm_unreg_reboot_notifier: nb->next 6b6b6b6b6b6b6b6b
freed memory is filled with a slub poison ^^^
[1]+ Done ./openwdog0
ts# reboot
[ 229.921862] systemd-shutdown[1]: Rebooting.
[ 229.939265] notifier_call_chain: nb ffffffff9c6c2f20 nb->next ffffffff9c6d50c0
[ 229.943080] notifier_call_chain: nb ffffffff9c6d50c0 nb->next 6b6b6b6b6b6b6b6b
[ 229.946054] notifier_call_chain: nb 6b6b6b6b6b6b6b6b INVAL
[ 229.957584] general protection fault: 0000 [#1] SMP
[ 229.958770] CPU: 0 PID: 1 Comm: systemd-shutdow Not tainted 5.5.0-rc5-ae6088-wdog
[ 229.960224] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), ...
[ 229.963288] RIP: 0010:notifier_call_chain+0x66/0xd0
[ 229.969082] RSP: 0018:ffffb20dc0013d88 EFLAGS: 00010246
[ 229.970812] RAX: 000000000000002e RBX: 6b6b6b6b6b6b6b6b RCX: 00000000000008b3
[ 229.972929] RDX: 0000000000000000 RSI: 0000000000000096 RDI: ffffffff9ccc46ac
[ 229.975028] RBP: 0000000000000001 R08: 0000000000000000 R09: 00000000000008b3
[ 229.977039] R10: 0000000000000001 R11: ffffffff9c26c740 R12: 0000000000000000
[ 229.979155] R13: 6b6b6b6b6b6b6b6b R14: 0000000000000000 R15: 00000000fffffffa
... slub_debug=FZP poison ^^^
[ 229.989089] Call Trace:
[ 229.990157] blocking_notifier_call_chain+0x43/0x59
[ 229.991401] kernel_restart_prepare+0x14/0x30
[ 229.992607] kernel_restart+0x9/0x30
[ 229.993800] __do_sys_reboot+0x1d2/0x210
[ 230.000149] do_syscall_64+0x3d/0x130
[ 230.001277] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[ 230.002639] RIP: 0033:0x7f5461bdd177
[ 230.016402] Modules linked in: i6300esb
[ 230.050261] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000bFix the crash by reverting 44ea39420fc9 so unregister_reboot_notifier() is called when watchdog device is removed. This also makes handling of the reboot notifier unified with the handling of the restart handler, which is freed with unregister_restart_handler() in the same place.
--- drivers/watchdog/watchdog_core.c | 35 +++++++++++++++++++++++++++++++++++ drivers/watchdog/watchdog_dev.c | 36 +----------------------------------- 2 files changed, 36 insertions(+), 35 deletions(-)
drivers/watchdog/watchdog_core.c +35 -0
@@ -147,6 +147,25 @@ int watchdog_init_timeout(struct watchdo }EXPORT_SYMBOL_GPL (watchdog_init_timeout); +static int watchdog_reboot_notifier (struct notifier_block *nb, +unsigned long code,void *data) +{ +struct watchdog_device *wdd; + + wdd = container_of(nb, struct watchdog_device, reboot_nb); +if (code ==SYS_DOWN || code ==SYS_HALT ) { +if (watchdog_active (wdd)) { +int ret; + + ret = wdd->ops->stop (wdd); +if (ret) +return NOTIFY_BAD ; + } + } + +return NOTIFY_DONE ; +} +static int watchdog_restart_notifier (struct notifier_block *nb,unsigned long action,void *data) {
@@ -235,6 +254,19 @@ static int __watchdog_register_device(st } } +if (test_bit (WDOG_STOP_ON_REBOOT , &wdd->status)) { + wdd->reboot_nb.notifier_call = watchdog_reboot_notifier; + + ret =register_reboot_notifier (&wdd->reboot_nb); +if (ret) { +pr_err ("watchdog%d: Cannot register reboot notifier (%d)\n" , + wdd->id, ret); +watchdog_dev_unregister (wdd); +ida_simple_remove (&watchdog_ida, id); +return ret; + } + } +if (wdd->ops->restart) { wdd->restart_nb.notifier_call = watchdog_restart_notifier;
@@ -289,6 +321,9 @@ static void __watchdog_unregister_deviceif (wdd->ops->restart)unregister_restart_handler (&wdd->restart_nb); +if (test_bit (WDOG_STOP_ON_REBOOT , &wdd->status)) +unregister_reboot_notifier (&wdd->reboot_nb); +watchdog_dev_unregister (wdd);ida_simple_remove (&watchdog_ida, wdd->id); }
drivers/watchdog/watchdog_dev.c +1 -35
@@ -38,7 +38,6 @@#include <linux/miscdevice.h> /* For handling misc devices */ #include <linux/module.h> /* For module stuff/... */ #include <linux/mutex.h> /* For mutexes */ -#include <linux/reboot.h> /* For reboot notifier */ #include <linux/slab.h> /* For memory functions */ #include <linux/types.h> /* For standard types (like size_t) */ #include <linux/watchdog.h> /* For watchdog specific items */
@@ -1077,25 +1076,6 @@ static void watchdog_cdev_unregister(strput_device (&wd_data->dev); } -static int watchdog_reboot_notifier (struct notifier_block *nb, -unsigned long code,void *data) -{ -struct watchdog_device *wdd; - - wdd = container_of(nb, struct watchdog_device, reboot_nb); -if (code ==SYS_DOWN || code ==SYS_HALT ) { -if (watchdog_active (wdd)) { -int ret; - - ret = wdd->ops->stop (wdd); -if (ret) -return NOTIFY_BAD ; - } - } - -return NOTIFY_DONE ; -} -/* * watchdog_dev_register: register a watchdog device * @wdd: watchdog device
@@ -1114,22 +1094,8 @@ int watchdog_dev_register(struct watchdoreturn ret; ret =watchdog_register_pretimeout (wdd); -if (ret) { +if (ret)watchdog_cdev_unregister (wdd); -return ret; - } - -if (test_bit (WDOG_STOP_ON_REBOOT , &wdd->status)) { - wdd->reboot_nb.notifier_call = watchdog_reboot_notifier; - - ret =devm_register_reboot_notifier (&wdd->wd_data->dev, - &wdd->reboot_nb); -if (ret) { -pr_err ("watchdog%d: Cannot register reboot notifier (%d)\n" , - wdd->id, ret); -watchdog_dev_unregister (wdd); - } - }return ret; }
Greg Kroah-Hartman
maintainerPATCH 204/309 KVM: x86: Protect ioapic_write_indirect() from Spectre-v1/L1TF attacks
In reply to Greg Kroah-HartmanFrom: Marios Pomonis <[email protected]>
commit 670564559ca35b439c8d8861fc399451ddf95137 upstream.
This fixes a Spectre-v1/L1TF vulnerability in ioapic_write_indirect(). This function contains index computations based on the (attacker-controlled) IOREGSEL register.
This patch depends on patch
"KVM: x86: Protect ioapic_read_indirect() from Spectre-v1/L1TF attacks".
--- arch/x86/kvm/ioapic.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/kvm/ioapic.c +1 -0
@@ -291,6 +291,7 @@ static void ioapic_write_indirect(structif (index >=IOAPIC_NUM_PINS )return ; + index =array_index_nospec (index,IOAPIC_NUM_PINS ); e = &ioapic->redirtbl[index]; mask_before = e->fields.mask;/* Preserve read-only fields */
Greg Kroah-Hartman
maintainerPATCH 205/309 KVM: x86: Protect MSR-based index computations in pmu.h from Spectre-v1/L1TF attacks
In reply to Greg Kroah-HartmanFrom: Marios Pomonis <[email protected]>
commit 13c5183a4e643cc2b03a22d0e582c8e17bb7457d upstream.
This fixes a Spectre-v1/L1TF vulnerability in the get_gp_pmc() and get_fixed_pmc() functions.
They both contain index computations based on the (attacker-controlled) MSR number.
--- arch/x86/kvm/pmu.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
arch/x86/kvm/pmu.h +14 -4
@@ -2,6 +2,8 @@#ifndef __KVM_X86_PMU_H#define __KVM_X86_PMU_H +#include <linux/nospec.h> +#define vcpu_to_pmu (vcpu) (&(vcpu)->arch.pmu)#define pmu_to_vcpu (pmu) (container_of((pmu), struct kvm_vcpu, arch.pmu))#define pmc_to_pmu (pmc) (&(pmc)->vcpu->arch.pmu)
@@ -86,8 +88,12 @@ static inline bool pmc_is_enabled(structstatic inline struct kvm_pmc *get_gp_pmc (struct kvm_pmu *pmu,u32 msr,u32 base) { -if (msr >= base && msr < base + pmu->nr_arch_gp_counters) -return &pmu->gp_counters[msr - base]; +if (msr >= base && msr < base + pmu->nr_arch_gp_counters) { +u32 index =array_index_nospec (msr - base, + pmu->nr_arch_gp_counters); + +return &pmu->gp_counters[index]; + }return NULL ; }
@@ -97,8 +103,12 @@ static inline struct kvm_pmc *get_fixed_ {int base =MSR_CORE_PERF_FIXED_CTR0 ; -if (msr >= base && msr < base + pmu->nr_arch_fixed_counters) -return &pmu->fixed_counters[msr - base]; +if (msr >= base && msr < base + pmu->nr_arch_fixed_counters) { +u32 index =array_index_nospec (msr - base, + pmu->nr_arch_fixed_counters); + +return &pmu->fixed_counters[index]; + }return NULL ; }
Greg Kroah-Hartman
maintainerPATCH 206/309 KVM: x86: Protect ioapic_read_indirect() from Spectre-v1/L1TF attacks
In reply to Greg Kroah-HartmanFrom: Marios Pomonis <[email protected]>
commit 8c86405f606ca8508b8d9280680166ca26723695 upstream.
This fixes a Spectre-v1/L1TF vulnerability in ioapic_read_indirect(). This function contains index computations based on the (attacker-controlled) IOREGSEL register.
--- arch/x86/kvm/ioapic.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
arch/x86/kvm/ioapic.c +8 -6
@@ -36,6 +36,7 @@#include <linux/io.h> #include <linux/slab.h> #include <linux/export.h> +#include <linux/nospec.h> #include <asm/processor.h> #include <asm/page.h> #include <asm/current.h>
@@ -68,13 +69,14 @@ static unsigned long ioapic_read_indirecdefault : {u32 redir_index = (ioapic->ioregsel -0x10 ) >>1 ; -u64 redir_content; +u64 redir_content = ~0ULL ; -if (redir_index <IOAPIC_NUM_PINS ) - redir_content = - ioapic->redirtbl[redir_index].bits; -else - redir_content = ~0ULL ; +if (redir_index <IOAPIC_NUM_PINS ) { +u32 index =array_index_nospec ( + redir_index,IOAPIC_NUM_PINS ); + + redir_content = ioapic->redirtbl[index].bits; + } result = (ioapic->ioregsel &0x1 ) ? (redir_content >> 32) & 0xffffffff :
Greg Kroah-Hartman
maintainerPATCH 174/309 btrfs: set trans->drity in btrfs_commit_transaction
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit d62b23c94952e78211a383b7d90ef0afbd9a3717 upstream.
If we abort a transaction we have the following sequence
if (!trans->dirty && list_empty(&trans->new_bgs))
return;
WRITE_ONCE(trans->transaction->aborted, err);
The idea being if we didn't modify anything with our trans handle then we don't really need to abort the whole transaction, maybe the other trans handles are fine and we can carry on.
However in the case of create_snapshot we add a pending_snapshot object to our transaction and then commit the transaction. We don't actually modify anything. sync() behaves the same way, attach to an existing transaction and commit it. This means that if we have an IO error in the right places we could abort the committing transaction with our trans->dirty being not set and thus not set transaction->aborted.
This is a problem because in the create_snapshot() case we depend on pending->error being set to something, or btrfs_commit_transaction returning an error.
If we are not the trans handle that gets to commit the transaction, and we're waiting on the commit to happen we get our return value from cur_trans->aborted. If this was not set to anything because sync() hit an error in the transaction commit before it could modify anything then cur_trans->aborted would be 0. Thus we'd return 0 from btrfs_commit_transaction() in create_snapshot.
This is a problem because we then try to do things with pending_snapshot->snap, which will be NULL because we didn't create the snapshot, and then we'll get a NULL pointer dereference like the following
"BUG: kernel NULL pointer dereference, address: 00000000000001f0"
RIP: 0010:btrfs_orphan_cleanup+0x2d/0x330 Call Trace: ? btrfs_mksubvol.isra.31+0x3f2/0x510 btrfs_mksubvol.isra.31+0x4bc/0x510 ? __sb_start_write+0xfa/0x200 ? mnt_want_write_file+0x24/0x50 btrfs_ioctl_snap_create_transid+0x16c/0x1a0 btrfs_ioctl_snap_create_v2+0x11e/0x1a0 btrfs_ioctl+0x1534/0x2c10 ? free_debug_processing+0x262/0x2a3 do_vfs_ioctl+0xa6/0x6b0 ? do_sys_open+0x188/0x220 ? syscall_trace_enter+0x1f8/0x330 ksys_ioctl+0x60/0x90 __x64_sys_ioctl+0x16/0x20 do_syscall_64+0x4a/0x1b0
In order to fix this we need to make sure anybody who calls commit_transaction has trans->dirty set so that they properly set the trans->transaction->aborted value properly so any waiters know bad things happened.
This was found while I was running generic/475 with my modified fsstress, it reproduced within a few runs. I ran with this patch all night and didn't see the problem again.
--- fs/btrfs/transaction.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/btrfs/transaction.c +8 -0
@@ -1949,6 +1949,14 @@ int btrfs_commit_transaction(struct btrfstruct btrfs_transaction *prev_trans =NULL ;int ret; +/* +* Some places just start a transaction to commit it. We need to make +* sure that if this commit fails that the abort code actually marks the +* transaction as failed, so set trans->dirty to make the abort code do +* the right thing. +*/ + trans->dirty = true; +/* Stop the commit early if ->aborted is set */ if (unlikely (READ_ONCE (cur_trans->aborted))) { ret = cur_trans->aborted;
Greg Kroah-Hartman
maintainerPATCH 243/309 phy: qualcomm: Adjust indentation in read_poll_timeout
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit a89806c998ee123bb9c0f18526e55afd12c0c0ab upstream.
Clang warns:
../drivers/phy/qualcomm/phy-qcom-apq8064-sata.c:83:4: warning:
misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
usleep_range(DELAY_INTERVAL_US, DELAY_INTERVAL_US + 50);
^../drivers/phy/qualcomm/phy-qcom-apq8064-sata.c:80:3: note: previous statement is here
if (readl_relaxed(addr) & mask)
^
1 warning generated.
This warning occurs because there is a space after the tab on this line. Remove it so that the indentation is consistent with the Linux kernel coding style and clang no longer warns.
--- drivers/phy/qualcomm/phy-qcom-apq8064-sata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/qualcomm/phy-qcom-apq8064-sata.c +1 -1
@@ -80,7 +80,7 @@ static int read_poll_timeout(void __iomeif (readl_relaxed (addr) & mask)return 0 ; -usleep_range (DELAY_INTERVAL_US ,DELAY_INTERVAL_US +50 ); +usleep_range (DELAY_INTERVAL_US ,DELAY_INTERVAL_US +50 ); }while (!time_after (jiffies, timeout));return (readl_relaxed (addr) & mask) ?0 : -ETIMEDOUT ;
Greg Kroah-Hartman
maintainerPATCH 245/309 powerpc/44x: Adjust indentation in ibm4xx_denali_fixup_memsize
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit c3aae14e5d468d18dbb5d7c0c8c7e2968cc14aad upstream.
Clang warns:
../arch/powerpc/boot/4xx.c:231:3: warning: misleading indentation; statement is not part of the previous 'else' [-Wmisleading-indentation]
val = SDRAM0_READ(DDR0_42);
^
../arch/powerpc/boot/4xx.c:227:2: note: previous statement is here
else
^This is because there is a space at the beginning of this line; remove it so that the indentation is consistent according to the Linux kernel coding style and clang no longer warns.
--- arch/powerpc/boot/4xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/boot/4xx.c +1 -1
@@ -228,7 +228,7 @@ void ibm4xx_denali_fixup_memsize(void) dpath =8 ;/* 64 bits */ /* get address pins (rows) */ - val =SDRAM0_READ (DDR0_42 ); + val =SDRAM0_READ (DDR0_42 ); row =DDR_GET_VAL (val,DDR_APIN ,DDR_APIN_SHIFT );if (row > max_row)
Greg Kroah-Hartman
maintainerPATCH 254/309 nfsd: fix jiffies/time_t mixup in LRU list
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
commit 9594497f2c78993cb66b696122f7c65528ace985 upstream.
The nfsd4_blocked_lock->nbl_time timestamp is recorded in jiffies, but then compared to a CLOCK_REALTIME timestamp later on, which makes no sense.
For consistency with the other timestamps, change this to use a time_t.
This is a change in behavior, which may cause regressions, but the current code is not sensible. On a system with CONFIG_HZ=1000, the 'time_after((unsigned long)nbl->nbl_time, (unsigned long)cutoff))' check is false for roughly the first 18 days of uptime and then true for the next 49 days.
--- fs/nfsd/nfs4state.c | 2 +- fs/nfsd/state.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/nfsd/nfs4state.c +1 -1
@@ -6550,7 +6550,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struc }if (fl_flags &FL_SLEEP ) { - nbl->nbl_time = jiffies; + nbl->nbl_time =get_seconds ();spin_lock (&nn->blocked_locks_lock);list_add_tail (&nbl->nbl_list, &lock_sop->lo_blocked);list_add_tail (&nbl->nbl_lru, &nn->blocked_locks_lru);
fs/nfsd/state.h +1 -1
@@ -605,7 +605,7 @@ static inline bool nfsd4_stateid_generatstruct nfsd4_blocked_lock {struct list_head nbl_list;struct list_head nbl_lru; -unsigned long nbl_time; +time_t nbl_time;struct file_lock nbl_lock;struct knfsd_fh nbl_fh;struct nfsd4_callback nbl_cb;
Greg Kroah-Hartman
maintainerPATCH 223/309 KVM: x86: Ensure guests FPU state is loaded when accessing for emulation
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit a7baead7e312f5a05381d68585fb6dc68e19e90f upstream.
Lock the FPU regs and reload the current thread's FPU state, which holds the guest's FPU state, to the CPU registers if necessary prior to accessing guest FPU state as part of emulation. kernel_fpu_begin() can be called from softirq context, therefore KVM must ensure softirqs are disabled (locking the FPU regs disables softirqs) when touching CPU FPU state.
Note, for all intents and purposes this reverts commit 6ab0b9feb82a7 ("x86,kvm: remove KVM emulator get_fpu / put_fpu"), but at the time it was applied, removing get/put_fpu() was correct. The re-introduction of {get,put}_fpu() is necessitated by the deferring of FPU state load.
--- arch/x86/kvm/emulate.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
arch/x86/kvm/emulate.c +39 -0
@@ -22,6 +22,7 @@#include "kvm_cache_regs.h" #include <asm/kvm_emulate.h> #include <linux/stringify.h> +#include <asm/fpu/api.h> #include <asm/debugreg.h> #include <asm/nospec-branch.h>
@@ -1075,8 +1076,23 @@ static void fetch_register_operand(struc } } +static void emulator_get_fpu (void ) +{ +fpregs_lock (); + +fpregs_assert_state_consistent (); +if (test_thread_flag (TIF_NEED_FPU_LOAD )) +switch_fpu_return (); +} + +static void emulator_put_fpu (void ) +{ +fpregs_unlock (); +} +static void read_sse_reg (struct x86_emulate_ctxt *ctxt,sse128_t *data,int reg) { +emulator_get_fpu ();switch (reg) {case 0 : asm("movdqa %%xmm0, %0" :"=m" (*data));break ;case 1 : asm("movdqa %%xmm1, %0" :"=m" (*data));break ;
@@ -1098,11 +1114,13 @@ static void read_sse_reg(struct x86_emul#endif default :BUG (); } +emulator_put_fpu (); }static void write_sse_reg (struct x86_emulate_ctxt *ctxt,sse128_t *data,int reg) { +emulator_get_fpu ();switch (reg) {case 0 : asm("movdqa %0, %%xmm0" : :"m" (*data));break ;case 1 : asm("movdqa %0, %%xmm1" : :"m" (*data));break ;
@@ -1124,10 +1142,12 @@ static void write_sse_reg(struct x86_emu#endif default :BUG (); } +emulator_put_fpu (); }static void read_mmx_reg (struct x86_emulate_ctxt *ctxt,u64 *data,int reg) { +emulator_get_fpu ();switch (reg) {case 0 : asm("movq %%mm0, %0" :"=m" (*data));break ;case 1 : asm("movq %%mm1, %0" :"=m" (*data));break ;
@@ -1139,10 +1159,12 @@ static void read_mmx_reg(struct x86_emulcase 7 : asm("movq %%mm7, %0" :"=m" (*data));break ;default :BUG (); } +emulator_put_fpu (); }static void write_mmx_reg (struct x86_emulate_ctxt *ctxt,u64 *data,int reg) { +emulator_get_fpu ();switch (reg) {case 0 : asm("movq %0, %%mm0" : :"m" (*data));break ;case 1 : asm("movq %0, %%mm1" : :"m" (*data));break ;
@@ -1154,6 +1176,7 @@ static void write_mmx_reg(struct x86_emucase 7 : asm("movq %0, %%mm7" : :"m" (*data));break ;default :BUG (); } +emulator_put_fpu (); }static int em_fninit (struct x86_emulate_ctxt *ctxt)
@@ -1161,7 +1184,9 @@ static int em_fninit(struct x86_emulate_if (ctxt->ops->get_cr (ctxt,0 ) & (X86_CR0_TS |X86_CR0_EM ))return emulate_nm (ctxt); +emulator_get_fpu (); asmvolatile ("fninit" ); +emulator_put_fpu ();return X86EMUL_CONTINUE ; }
@@ -1172,7 +1197,9 @@ static int em_fnstcw(struct x86_emulate_if (ctxt->ops->get_cr (ctxt,0 ) & (X86_CR0_TS |X86_CR0_EM ))return emulate_nm (ctxt); +emulator_get_fpu (); asmvolatile ("fnstcw %0" :"+m" (fcw)); +emulator_put_fpu (); ctxt->dst.val = fcw;
@@ -1186,7 +1213,9 @@ static int em_fnstsw(struct x86_emulate_if (ctxt->ops->get_cr (ctxt,0 ) & (X86_CR0_TS |X86_CR0_EM ))return emulate_nm (ctxt); +emulator_get_fpu (); asmvolatile ("fnstsw %0" :"+m" (fsw)); +emulator_put_fpu (); ctxt->dst.val = fsw;
@@ -4094,8 +4123,12 @@ static int em_fxsave(struct x86_emulate_if (rc !=X86EMUL_CONTINUE )return rc; +emulator_get_fpu (); + rc = asm_safe("fxsave %[fx]", , [fx] "+m"(fx_state)); +emulator_put_fpu (); +if (rc !=X86EMUL_CONTINUE )return rc;
@@ -4138,6 +4171,8 @@ static int em_fxrstor(struct x86_emulateif (rc !=X86EMUL_CONTINUE )return rc; +emulator_get_fpu (); +if (size <__fxstate_size (16 )) { rc =fxregs_fixup (&fx_state, size);if (rc !=X86EMUL_CONTINUE )
@@ -4153,6 +4188,8 @@ static int em_fxrstor(struct x86_emulate rc = asm_safe("fxrstor %[fx]", : [fx] "m"(fx_state)); out: +emulator_put_fpu (); +return rc; }
@@ -5467,7 +5504,9 @@ static int flush_pending_x87_faults(stru {int rc; +emulator_get_fpu (); rc =asm_safe ("fwait" ); +emulator_put_fpu ();if (unlikely (rc !=X86EMUL_CONTINUE ))return emulate_exception (ctxt,MF_VECTOR ,0 , false);
Greg Kroah-Hartman
maintainerPATCH 224/309 KVM: x86: Revert "KVM: X86: Fix fpu state crash in kvm guest"
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit 2620fe268e80d667a94553cd37a94ccaa2cb8c83 upstream.
Reload the current thread's FPU state, which contains the guest's FPU state, to the CPU registers if necessary during vcpu_enter_guest(). TIF_NEED_FPU_LOAD can be set any time control is transferred out of KVM, e.g. if I/O is triggered during a KVM call to get_user_pages() or if a softirq occurs while KVM is scheduled in.
Moving the handling of TIF_NEED_FPU_LOAD from vcpu_enter_guest() to kvm_arch_vcpu_load(), effectively kvm_sched_in(), papered over a bug where kvm_put_guest_fpu() failed to account for TIF_NEED_FPU_LOAD. The easiest way to the kvm_put_guest_fpu() bug was to run with involuntary preemption enable, thus handling TIF_NEED_FPU_LOAD during kvm_sched_in() made the bug go away. But, removing the handling in vcpu_enter_guest() exposed KVM to the rare case of a softirq triggering kernel_fpu_begin() between vcpu_load() and vcpu_enter_guest().
Now that kvm_{load,put}_guest_fpu() correctly handle TIF_NEED_FPU_LOAD, revert the commit to both restore the vcpu_enter_guest() behavior and eliminate the superfluous switch_fpu_return() in kvm_arch_vcpu_load().
Note, leaving the handling in kvm_arch_vcpu_load() isn't wrong per se, but it is unnecessary, and most critically, makes it extremely difficult to find bugs such as the kvm_put_guest_fpu() issue due to shrinking the window where a softirq can corrupt state.
A sample trace triggered by warning if TIF_NEED_FPU_LOAD is set while vcpu state is loaded:
<IRQ> gcmaes_crypt_by_sg.constprop.12+0x26e/0x660 ? 0xffffffffc024547d ? __qdisc_run+0x83/0x510 ? __dev_queue_xmit+0x45e/0x990 ? ip_finish_output2+0x1a8/0x570 ? fib4_rule_action+0x61/0x70 ? fib4_rule_action+0x70/0x70 ? fib_rules_lookup+0x13f/0x1c0 ? helper_rfc4106_decrypt+0x82/0xa0 ? crypto_aead_decrypt+0x40/0x70 ? crypto_aead_decrypt+0x40/0x70 ? crypto_aead_decrypt+0x40/0x70 ? esp_output_tail+0x8f4/0xa5a [esp4] ? skb_ext_add+0xd3/0x170 ? xfrm_input+0x7a6/0x12c0 ? xfrm4_rcv_encap+0xae/0xd0 ? xfrm4_transport_finish+0x200/0x200 ? udp_queue_rcv_one_skb+0x1ba/0x460 ? udp_unicast_rcv_skb.isra.63+0x72/0x90 ? __udp4_lib_rcv+0x51b/0xb00 ? ip_protocol_deliver_rcu+0xd2/0x1c0 ? ip_local_deliver_finish+0x44/0x50 ? ip_local_deliver+0xe0/0xf0 ? ip_protocol_deliver_rcu+0x1c0/0x1c0 ? ip_rcv+0xbc/0xd0 ? ip_rcv_finish_core.isra.19+0x380/0x380 ? __netif_receive_skb_one_core+0x7e/0x90 ? netif_receive_skb_internal+0x3d/0xb0 ? napi_gro_receive+0xed/0x150 ? 0xffffffffc0243c77 ? net_rx_action+0x149/0x3b0 ? __do_softirq+0xe4/0x2f8 ? handle_irq_event_percpu+0x6a/0x80 ? irq_exit+0xe6/0xf0 ? do_IRQ+0x7f/0xd0 ? common_interrupt+0xf/0xf </IRQ> ? irq_entries_start+0x20/0x660 ? vmx_get_interrupt_shadow+0x2f0/0x710 [kvm_intel] ? kvm_set_msr_common+0xfc7/0x2380 [kvm] ? recalibrate_cpu_khz+0x10/0x10 ? ktime_get+0x3a/0xa0 ? kvm_arch_vcpu_ioctl_run+0x107/0x560 [kvm] ? kvm_init+0x6bf/0xd00 [kvm] ? __seccomp_filter+0x7a/0x680 ? do_vfs_ioctl+0xa4/0x630 ? security_file_ioctl+0x32/0x50 ? ksys_ioctl+0x60/0x90 ? __x64_sys_ioctl+0x16/0x20 ? do_syscall_64+0x5f/0x1a0 ? entry_SYSCALL_64_after_hwframe+0x44/0xa9 ---[ end trace 9564a1ccad733a90 ]---
This reverts commit e751732486eb3f159089a64d1901992b1357e7cc.
--- arch/x86/kvm/x86.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
arch/x86/kvm/x86.c +3 -6
@@ -3481,10 +3481,6 @@ void kvm_arch_vcpu_load(struct kvm_vcpu kvm_x86_ops->vcpu_load (vcpu, cpu); -fpregs_assert_state_consistent (); -if (test_thread_flag (TIF_NEED_FPU_LOAD )) -switch_fpu_return (); -/* Apply any externally detected TSC adjustments (due to suspend) */ if (unlikely (vcpu->arch.tsc_offset_adjustment)) {adjust_tsc_offset_host (vcpu, vcpu->arch.tsc_offset_adjustment);
@@ -8220,8 +8216,9 @@ static int vcpu_enter_guest(struct kvm_vtrace_kvm_entry (vcpu->vcpu_id);guest_enter_irqoff (); -/* The preempt notifier should have taken care of the FPU already. */ -WARN_ON_ONCE (test_thread_flag (TIF_NEED_FPU_LOAD )); +fpregs_assert_state_consistent (); +if (test_thread_flag (TIF_NEED_FPU_LOAD )) +switch_fpu_return ();if (unlikely (vcpu->arch.switch_db_regs)) {set_debugreg (0 ,7 );
Greg Kroah-Hartman
maintainerPATCH 275/309 net: macb: Remove unnecessary alignment check for TSO
In reply to Greg Kroah-HartmanFrom: Harini Katakam <[email protected]>
[ Upstream commit 41c1ef978c8d0259c6636e6d2d854777e92650eb ]
The IP TSO implementation does NOT require the length to be a multiple of 8. That is only a requirement for UFO as per IP documentation. Hence, exit macb_features_check function in the beginning if the protocol is not UDP. Only when it is UDP, proceed further to the alignment checks. Update comments to reflect the same. Also remove dead code checking for protocol TCP when calculating header length.
--- drivers/net/ethernet/cadence/macb_main.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +3 -5
@@ -1664,16 +1664,14 @@ static netdev_features_t macb_features_c/* Validate LSO compatibility */ -/* there is only one buffer */ -if (!skb_is_nonlinear (skb)) +/* there is only one buffer or protocol is not UDP */ +if (!skb_is_nonlinear (skb) || (ip_hdr (skb)->protocol !=IPPROTO_UDP ))return features;/* length of header */ hdrlen =skb_transport_offset (skb); -if (ip_hdr (skb)->protocol ==IPPROTO_TCP ) - hdrlen +=tcp_hdrlen (skb); -/* For LSO: +/* For UFO only: * When software supplies two or more payload buffers all payload buffers * apart from the last must be a multiple of 8 bytes in size. */
Greg Kroah-Hartman
maintainerPATCH 277/309 taprio: Fix enabling offload with wrong number of traffic classes
In reply to Greg Kroah-HartmanFrom: Vinicius Costa Gomes <[email protected]>
[ Upstream commit 5652e63df3303c2a702bac25fbf710b9cb64dfba ]
If the driver implementing taprio offloading depends on the value of the network device number of traffic classes (dev->num_tc) for whatever reason, it was going to receive the value zero. The value was only set after the offloading function is called.
So, moving setting the number of traffic classes to before the offloading function is called fixes this issue. This is safe because this only happens when taprio is instantiated (we don't allow this configuration to be changed without first removing taprio).
--- net/sched/sch_taprio.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
net/sched/sch_taprio.c +13 -13
@@ -1444,6 +1444,19 @@ static int taprio_change(struct Qdisc *staprio_set_picos_per_byte (dev, q); +if (mqprio) { +netdev_set_num_tc (dev, mqprio->num_tc); +for (i =0 ; i < mqprio->num_tc; i++) +netdev_set_tc_queue (dev, i, + mqprio->count[i], + mqprio->offset[i]); + +/* Always use supplied priority mappings */ +for (i =0 ; i <=TC_BITMASK ; i++) +netdev_set_prio_tc_map (dev, i, + mqprio->prio_tc_map[i]); + } +if (FULL_OFFLOAD_IS_ENABLED (taprio_flags)) err =taprio_enable_offload (dev, mqprio, q, new_admin, extack);else
@@ -1471,19 +1484,6 @@ static int taprio_change(struct Qdisc *s q->advance_timer.function = advance_sched; } -if (mqprio) { -netdev_set_num_tc (dev, mqprio->num_tc); -for (i =0 ; i < mqprio->num_tc; i++) -netdev_set_tc_queue (dev, i, - mqprio->count[i], - mqprio->offset[i]); - -/* Always use supplied priority mappings */ -for (i =0 ; i <=TC_BITMASK ; i++) -netdev_set_prio_tc_map (dev, i, - mqprio->prio_tc_map[i]); - } -if (FULL_OFFLOAD_IS_ENABLED (taprio_flags)) { q->dequeue = taprio_dequeue_offload; q->peek = taprio_peek_offload;
Greg Kroah-Hartman
maintainerPATCH 279/309 taprio: Add missing policy validation for flags
In reply to Greg Kroah-HartmanFrom: Vinicius Costa Gomes <[email protected]>
[ Upstream commit 49c684d79cfdc3032344bf6f3deeea81c4efedbf ]
netlink policy validation for the 'flags' argument was missing.
--- net/sched/sch_taprio.c | 1 + 1 file changed, 1 insertion(+)
net/sched/sch_taprio.c +1 -0
@@ -767,6 +767,7 @@ static const struct nla_policy taprio_po [TCA_TAPRIO_ATTR_SCHED_CLOCKID] = { .type = NLA_S32 }, [TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME] = { .type = NLA_S64 }, [TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME_EXTENSION] = { .type = NLA_S64 }, + [TCA_TAPRIO_ATTR_FLAGS] = { .type = NLA_U32 }, }; static int fill_sched_entry(struct nlattr **tb, struct sched_entry *entry,
Greg Kroah-Hartman
maintainerPATCH 278/309 taprio: Fix still allowing changing the flags during runtime
In reply to Greg Kroah-HartmanFrom: Vinicius Costa Gomes <[email protected]>
[ Upstream commit a9d6227436f32142209f4428f2dc616761485112 ]
Because 'q->flags' starts as zero, and zero is a valid value, we aren't able to detect the transition from zero to something else during "runtime".
The solution is to initialize 'q->flags' with an invalid value, so we can detect if 'q->flags' was set by the user or not.
To better solidify the behavior, 'flags' handling is moved to a separate function. The behavior is:
- 'flags' if unspecified by the user, is assumed to be zero;
- 'flags' cannot change during "runtime" (i.e. a change() request cannot modify it);
With this new function we can remove taprio_flags, which should reduce the risk of future accidents.
Allowing flags to be changed was causing the following RCU stall:
[ 1730.558249] rcu: INFO: rcu_preempt detected stalls on CPUs/tasks: [ 1730.558258] rcu: 6-...0: (190 ticks this GP) idle=922/0/0x1 softirq=25580/25582 fqs=16250 [ 1730.558264] (detected by 2, t=65002 jiffies, g=33017, q=81) [ 1730.558269] Sending NMI from CPU 2 to CPUs 6: [ 1730.559277] NMI backtrace for cpu 6 [ 1730.559277] CPU: 6 PID: 0 Comm: swapper/6 Tainted: G E 5.5.0-rc6+ #35 [ 1730.559278] Hardware name: Gigabyte Technology Co., Ltd. Z390 AORUS ULTRA/Z390 AORUS ULTRA-CF, BIOS F7 03/14/2019 [ 1730.559278] RIP: 0010:__hrtimer_run_queues+0xe2/0x440 [ 1730.559278] Code: 48 8b 43 28 4c 89 ff 48 8b 75 c0 48 89 45 c8 e8 f4 bb 7c 00 0f 1f 44 00 00 65 8b 05 40 31 f0 68 89 c0 48 0f a3 05 3e 5c 25 01 <0f> 82 fc 01 00 00 48 8b 45 c8 48 89 df ff d0 89 45 c8 0f 1f 44 00 [ 1730.559279] RSP: 0018:ffff9970802d8f10 EFLAGS: 00000083 [ 1730.559279] RAX: 0000000000000006 RBX: ffff8b31645bff38 RCX: 0000000000000000 [ 1730.559280] RDX: 0000000000000000 RSI: ffffffff9710f2ec RDI: ffffffff978daf0e [ 1730.559280] RBP: ffff9970802d8f68 R08: 0000000000000000 R09: 0000000000000000 [ 1730.559280] R10: 0000018336d7944e R11: 0000000000000001 R12: ffff8b316e39f9c0 [ 1730.559281] R13: ffff8b316e39f940 R14: ffff8b316e39f998 R15: ffff8b316e39f7c0 [ 1730.559281] FS: 0000000000000000(0000) GS:ffff8b316e380000(0000) knlGS:0000000000000000 [ 1730.559281] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 1730.559281] CR2: 00007f1105303760 CR3: 0000000227210005 CR4: 00000000003606e0 [ 1730.559282] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 1730.559282] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 1730.559282] Call Trace: [ 1730.559282] <IRQ> [ 1730.559283] ? taprio_dequeue_soft+0x2d0/0x2d0 [sch_taprio] [ 1730.559283] hrtimer_interrupt+0x104/0x220 [ 1730.559283] ? irqtime_account_irq+0x34/0xa0 [ 1730.559283] smp_apic_timer_interrupt+0x6d/0x230 [ 1730.559284] apic_timer_interrupt+0xf/0x20 [ 1730.559284] </IRQ> [ 1730.559284] RIP: 0010:cpu_idle_poll+0x35/0x1a0 [ 1730.559285] Code: 88 82 ff 65 44 8b 25 12 7d 73 68 0f 1f 44 00 00 e8 90 c3 89 ff fb 65 48 8b 1c 25 c0 7e 01 00 48 8b 03 a8 08 74 0b eb 1c f3 90 <48> 8b 03 a8 08 75 13 8b 05 be a8 a8 00 85 c0 75 ed e8 75 48 84 ff [ 1730.559285] RSP: 0018:ffff997080137ea8 EFLAGS: 00000202 ORIG_RAX: ffffffffffffff13 [ 1730.559285] RAX: 0000000000000001 RBX: ffff8b316bc3c580 RCX: 0000000000000000 [ 1730.559286] RDX: 0000000000000001 RSI: 000000002819aad9 RDI: ffffffff978da730 [ 1730.559286] RBP: ffff997080137ec0 R08: 0000018324a6d387 R09: 0000000000000000 [ 1730.559286] R10: 0000000000000400 R11: 0000000000000001 R12: 0000000000000006 [ 1730.559286] R13: ffff8b316bc3c580 R14: 0000000000000000 R15: 0000000000000000 [ 1730.559287] ? cpu_idle_poll+0x20/0x1a0 [ 1730.559287] ? cpu_idle_poll+0x20/0x1a0 [ 1730.559287] do_idle+0x4d/0x1f0 [ 1730.559287] ? complete+0x44/0x50 [ 1730.559288] cpu_startup_entry+0x1b/0x20 [ 1730.559288] start_secondary+0x142/0x180 [ 1730.559288] secondary_startup_64+0xb6/0xc0 [ 1776.686313] nvme nvme0: I/O 96 QID 1 timeout, completion polled
--- net/sched/sch_taprio.c | 61 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 20 deletions(-)
net/sched/sch_taprio.c +41 -20
@@ -31,6 +31,7 @@ static DEFINE_SPINLOCK(taprio_list_lock)#define TXTIME_ASSIST_IS_ENABLED (flags) ((flags) & TCA_TAPRIO_ATTR_FLAG_TXTIME_ASSIST)#define FULL_OFFLOAD_IS_ENABLED (flags) ((flags) & TCA_TAPRIO_ATTR_FLAG_FULL_OFFLOAD) +#define TAPRIO_FLAGS_INVALID U32_MAXstruct sched_entry {struct list_head list;
@@ -1367,6 +1368,33 @@ static int taprio_mqprio_cmp(const strucreturn 0 ; } +/* The semantics of the 'flags' argument in relation to 'change()' +* requests, are interpreted following two rules (which are applied in +* this order): (1) an omitted 'flags' argument is interpreted as +* zero; (2) the 'flags' of a "running" taprio instance cannot be +* changed. +*/ +static int taprio_new_flags (const struct nlattr *attr,u32 old, +struct netlink_ext_ack *extack) +{ +u32 new =0 ; + +if (attr) + new =nla_get_u32 (attr); + +if (old !=TAPRIO_FLAGS_INVALID && old != new) { +NL_SET_ERR_MSG_MOD (extack,"Changing 'flags' of a running schedule is not supported" ); +return -EOPNOTSUPP ; + } + +if (!taprio_flags_valid (new)) { +NL_SET_ERR_MSG_MOD (extack,"Specified 'flags' are not valid" ); +return -EINVAL ; + } + +return new; +} +static int taprio_change (struct Qdisc *sch,struct nlattr *opt,struct netlink_ext_ack *extack) {
@@ -1375,7 +1403,6 @@ static int taprio_change(struct Qdisc *sstruct taprio_sched *q =qdisc_priv (sch);struct net_device *dev =qdisc_dev (sch);struct tc_mqprio_qopt *mqprio =NULL ; -u32 taprio_flags =0 ;unsigned long flags;ktime_t start;int i, err;
@@ -1388,21 +1415,14 @@ static int taprio_change(struct Qdisc *sif (tb[TCA_TAPRIO_ATTR_PRIOMAP ]) mqprio =nla_data (tb[TCA_TAPRIO_ATTR_PRIOMAP ]); -if (tb[TCA_TAPRIO_ATTR_FLAGS ]) { - taprio_flags =nla_get_u32 (tb[TCA_TAPRIO_ATTR_FLAGS ]); - -if (q->flags !=0 && q->flags != taprio_flags) { -NL_SET_ERR_MSG_MOD (extack,"Changing 'flags' of a running schedule is not supported" ); -return -EOPNOTSUPP ; - }else if (!taprio_flags_valid (taprio_flags)) { -NL_SET_ERR_MSG_MOD (extack,"Specified 'flags' are not valid" ); -return -EINVAL ; - } + err =taprio_new_flags (tb[TCA_TAPRIO_ATTR_FLAGS ], + q->flags, extack); +if (err <0 ) +return err; - q->flags = taprio_flags; - } + q->flags = err; - err =taprio_parse_mqprio_opt (dev, mqprio, extack, taprio_flags); + err =taprio_parse_mqprio_opt (dev, mqprio, extack, q->flags);if (err <0 )return err;
@@ -1457,7 +1477,7 @@ static int taprio_change(struct Qdisc *s mqprio->prio_tc_map[i]); } -if (FULL_OFFLOAD_IS_ENABLED (taprio_flags)) +if (FULL_OFFLOAD_IS_ENABLED (q->flags)) err =taprio_enable_offload (dev, mqprio, q, new_admin, extack);else err =taprio_disable_offload (dev, q, extack);
@@ -1477,14 +1497,14 @@ static int taprio_change(struct Qdisc *s q->txtime_delay =nla_get_u32 (tb[TCA_TAPRIO_ATTR_TXTIME_DELAY ]); } -if (!TXTIME_ASSIST_IS_ENABLED (taprio_flags) && - !FULL_OFFLOAD_IS_ENABLED (taprio_flags) && +if (!TXTIME_ASSIST_IS_ENABLED (q->flags) && + !FULL_OFFLOAD_IS_ENABLED (q->flags) && !hrtimer_active (&q->advance_timer)) {hrtimer_init (&q->advance_timer, q->clockid,HRTIMER_MODE_ABS ); q->advance_timer.function = advance_sched; } -if (FULL_OFFLOAD_IS_ENABLED (taprio_flags)) { +if (FULL_OFFLOAD_IS_ENABLED (q->flags)) { q->dequeue = taprio_dequeue_offload; q->peek = taprio_peek_offload; }else {
@@ -1501,7 +1521,7 @@ static int taprio_change(struct Qdisc *s goto unlock; } -if (TXTIME_ASSIST_IS_ENABLED (taprio_flags)) { +if (TXTIME_ASSIST_IS_ENABLED (q->flags)) {setup_txtime (q, new_admin, start);if (!oper) {
@@ -1528,7 +1548,7 @@ static int taprio_change(struct Qdisc *sspin_unlock_irqrestore (&q->current_entry_lock, flags); -if (FULL_OFFLOAD_IS_ENABLED (taprio_flags)) +if (FULL_OFFLOAD_IS_ENABLED (q->flags))taprio_offload_config_changed (q); }
@@ -1597,6 +1617,7 @@ static int taprio_init(struct Qdisc *sch* and get the valid one on taprio_change(). */ q->clockid =-1 ; + q->flags =TAPRIO_FLAGS_INVALID ;spin_lock (&taprio_list_lock);list_add (&q->taprio_list, &taprio_list);
Greg Kroah-Hartman
maintainerPATCH 281/309 taprio: Fix dropping packets when using taprio + ETF offloading
In reply to Greg Kroah-HartmanFrom: Vinicius Costa Gomes <[email protected]>
[ Upstream commit bfabd41da34180d05382312533a3adc2e012dee0 ]
When using taprio offloading together with ETF offloading, configured like this, for example:
$ tc qdisc replace dev $IFACE parent root handle 100 taprio \
num_tc 4 \
map 2 2 1 0 3 2 2 2 2 2 2 2 2 2 2 2 \
queues 1@0 1@1 1@2 1@3 \
base-time $BASE_TIME \
sched-entry S 01 1000000 \
sched-entry S 0e 1000000 \
flags 0x2$ tc qdisc replace dev $IFACE parent 100:1 etf \
offload delta 300000 clockid CLOCK_TAIDuring enqueue, it works out that the verification added for the "txtime" assisted mode is run when using taprio + ETF offloading, the only thing missing is initializing the 'next_txtime' of all the cycle entries. (if we don't set 'next_txtime' all packets from SO_TXTIME sockets are dropped)
--- net/sched/sch_taprio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/sched/sch_taprio.c +2 -2
@@ -1522,9 +1522,9 @@ static int taprio_change(struct Qdisc *s goto unlock; } -if (TXTIME_ASSIST_IS_ENABLED (q->flags)) { -setup_txtime (q, new_admin, start); +setup_txtime (q, new_admin, start); +if (TXTIME_ASSIST_IS_ENABLED (q->flags)) {if (!oper) {rcu_assign_pointer (q->oper_sched, new_admin); err =0 ;
Greg Kroah-Hartman
maintainerPATCH 287/309 ASoC: Intel: skl_hda_dsp_common: Fix global-out-of-bounds bug
In reply to Greg Kroah-HartmanFrom: Cezary Rojewski <[email protected]>
commit 15adb20f64c302b31e10ad50f22bb224052ce1df upstream.
Definitions for idisp snd_soc_dai_links within skl_hda_dsp_common are missing platform component. Add it to address following bug reported by KASAN:
[ 10.538502] BUG: KASAN: global-out-of-bounds in skl_hda_audio_probe+0x13a/0x2b0 [snd_soc_skl_hda_dsp] [ 10.538509] Write of size 8 at addr ffffffffc0606840 by task systemd-udevd/299 (...) [ 10.538519] Call Trace: [ 10.538524] dump_stack+0x62/0x95 [ 10.538528] print_address_description+0x2f5/0x3b0 [ 10.538532] ? skl_hda_audio_probe+0x13a/0x2b0 [snd_soc_skl_hda_dsp] [ 10.538535] __kasan_report+0x134/0x191 [ 10.538538] ? skl_hda_audio_probe+0x13a/0x2b0 [snd_soc_skl_hda_dsp] [ 10.538542] ? skl_hda_audio_probe+0x13a/0x2b0 [snd_soc_skl_hda_dsp] [ 10.538544] kasan_report+0x12/0x20 [ 10.538546] __asan_store8+0x57/0x90 [ 10.538550] skl_hda_audio_probe+0x13a/0x2b0 [snd_soc_skl_hda_dsp] [ 10.538553] platform_drv_probe+0x51/0xb0 [ 10.538556] really_probe+0x311/0x600 [ 10.538559] driver_probe_device+0x87/0x1b0 [ 10.538562] device_driver_attach+0x8f/0xa0 [ 10.538565] ? device_driver_attach+0xa0/0xa0 [ 10.538567] __driver_attach+0x102/0x1a0 [ 10.538569] ? device_driver_attach+0xa0/0xa0 [ 10.538572] bus_for_each_dev+0xe8/0x160 [ 10.538574] ? subsys_dev_iter_exit+0x10/0x10 [ 10.538577] ? preempt_count_sub+0x18/0xc0 [ 10.538580] ? _raw_write_unlock+0x1f/0x40 [ 10.538582] driver_attach+0x2b/0x30 [ 10.538585] bus_add_driver+0x251/0x340 [ 10.538588] driver_register+0xd3/0x1c0 [ 10.538590] __platform_driver_register+0x6c/0x80 [ 10.538592] ? 0xffffffffc03e8000 [ 10.538595] skl_hda_audio_init+0x1c/0x1000 [snd_soc_skl_hda_dsp] [ 10.538598] do_one_initcall+0xd0/0x36a [ 10.538600] ? trace_event_raw_event_initcall_finish+0x160/0x160 [ 10.538602] ? kasan_unpoison_shadow+0x36/0x50 [ 10.538605] ? __kasan_kmalloc+0xcc/0xe0 [ 10.538607] ? kasan_unpoison_shadow+0x36/0x50 [ 10.538609] ? kasan_poison_shadow+0x2f/0x40 [ 10.538612] ? __asan_register_globals+0x65/0x80 [ 10.538615] do_init_module+0xf9/0x36f [ 10.538619] load_module+0x398e/0x4590 [ 10.538625] ? module_frob_arch_sections+0x20/0x20 [ 10.538628] ? __kasan_check_write+0x14/0x20 [ 10.538630] ? kernel_read+0x9a/0xc0 [ 10.538632] ? __kasan_check_write+0x14/0x20 [ 10.538634] ? kernel_read_file+0x1d3/0x3c0 [ 10.538638] ? cap_capable+0xca/0x110 [ 10.538642] __do_sys_finit_module+0x190/0x1d0 [ 10.538644] ? __do_sys_finit_module+0x190/0x1d0 [ 10.538646] ? __x64_sys_init_module+0x50/0x50 [ 10.538649] ? expand_files+0x380/0x380 [ 10.538652] ? __kasan_check_write+0x14/0x20 [ 10.538654] ? fput_many+0x20/0xc0 [ 10.538658] __x64_sys_finit_module+0x43/0x50 [ 10.538660] do_syscall_64+0xce/0x700 [ 10.538662] ? syscall_return_slowpath+0x230/0x230 [ 10.538665] ? __do_page_fault+0x51e/0x640 [ 10.538668] ? __kasan_check_read+0x11/0x20 [ 10.538670] ? prepare_exit_to_usermode+0xc7/0x200 [ 10.538673] entry_SYSCALL_64_after_hwframe+0x44/0xa9
--- sound/soc/intel/boards/skl_hda_dsp_common.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
sound/soc/intel/boards/skl_hda_dsp_common.c +12 -9
@@ -38,16 +38,19 @@ int skl_hda_hdmi_add_pcm(struct snd_soc_return 0 ; } -SND_SOC_DAILINK_DEFS (idisp1, -DAILINK_COMP_ARRAY (COMP_CPU ("iDisp1 Pin" )), +SND_SOC_DAILINK_DEF (idisp1_cpu, +DAILINK_COMP_ARRAY (COMP_CPU ("iDisp1 Pin" ))); +SND_SOC_DAILINK_DEF (idisp1_codec,DAILINK_COMP_ARRAY (COMP_CODEC ("ehdaudio0D2" ,"intel-hdmi-hifi1" ))); -SND_SOC_DAILINK_DEFS (idisp2, -DAILINK_COMP_ARRAY (COMP_CPU ("iDisp2 Pin" )), +SND_SOC_DAILINK_DEF (idisp2_cpu, +DAILINK_COMP_ARRAY (COMP_CPU ("iDisp2 Pin" ))); +SND_SOC_DAILINK_DEF (idisp2_codec,DAILINK_COMP_ARRAY (COMP_CODEC ("ehdaudio0D2" ,"intel-hdmi-hifi2" ))); -SND_SOC_DAILINK_DEFS (idisp3, -DAILINK_COMP_ARRAY (COMP_CPU ("iDisp3 Pin" )), +SND_SOC_DAILINK_DEF (idisp3_cpu, +DAILINK_COMP_ARRAY (COMP_CPU ("iDisp3 Pin" ))); +SND_SOC_DAILINK_DEF (idisp3_codec,DAILINK_COMP_ARRAY (COMP_CODEC ("ehdaudio0D2" ,"intel-hdmi-hifi3" ))); SND_SOC_DAILINK_DEF(analog_cpu,
@@ -80,21 +83,21 @@ struct snd_soc_dai_link skl_hda_be_dai_l .id = 1, .dpcm_playback = 1, .no_pcm = 1, - SND_SOC_DAILINK_REG(idisp1), + SND_SOC_DAILINK_REG(idisp1_cpu, idisp1_codec, platform), }, { .name = "iDisp2", .id = 2, .dpcm_playback = 1, .no_pcm =1 , - SND_SOC_DAILINK_REG(idisp2), + SND_SOC_DAILINK_REG(idisp2_cpu, idisp2_codec, platform), }, { .name ="iDisp3" , .id = 3, .dpcm_playback = 1, .no_pcm = 1, - SND_SOC_DAILINK_REG(idisp3), + SND_SOC_DAILINK_REG(idisp3_cpu, idisp3_codec, platform), }, { .name = "Analog Playback and Capture",
Greg Kroah-Hartman
maintainerPATCH 285/309 net/mlx5: Fix deadlock in fs_core
In reply to Greg Kroah-HartmanFrom: Maor Gottlieb <[email protected]>
[ Upstream commit c1948390d78b5183ee9b7dd831efd7f6ac496ab0 ]
free_match_list could be called when the flow table is already locked. We need to pass this notation to tree_put_node.
It fixes the following lockdep warnning:
[ 1797.268537] ============================================
[ 1797.276837] WARNING: possible recursive locking detected
[ 1797.285101] 5.5.0-rc5+ #10 Not tainted
[ 1797.291641] --------------------------------------------
[ 1797.299917] handler10/9296 is trying to acquire lock:
[ 1797.307885] ffff889ad399a0a0 (&node->lock){++++}, at:
tree_put_node+0x1d5/0x210 [mlx5_core]
[ 1797.319694]
[ 1797.319694] but task is already holding lock:
[ 1797.330904] ffff889ad399a0a0 (&node->lock){++++}, at:
nested_down_write_ref_node.part.33+0x1a/0x60 [mlx5_core]
[ 1797.344707]
[ 1797.344707] other info that might help us debug this:
[ 1797.356952] Possible unsafe locking scenario:
[ 1797.356952]
[ 1797.368333] CPU0
[ 1797.373357] ----
[ 1797.378364] lock(&node->lock);
[ 1797.384222] lock(&node->lock);
[ 1797.390031]
[ 1797.390031] *** DEADLOCK ***
[ 1797.390031]
[ 1797.403003] May be due to missing lock nesting notation
[ 1797.403003]
[ 1797.414691] 3 locks held by handler10/9296:
[ 1797.421465] #0: ffff889cf2c5a110 (&block->cb_lock){++++}, at:
tc_setup_cb_add+0x70/0x250
[ 1797.432810] #1: ffff88a030081490 (&comp->sem){++++}, at:
mlx5_devcom_get_peer_data+0x4c/0xb0 [mlx5_core]
[ 1797.445829] #2: ffff889ad399a0a0 (&node->lock){++++}, at:
nested_down_write_ref_node.part.33+0x1a/0x60 [mlx5_core]
[ 1797.459913]
[ 1797.459913] stack backtrace:
[ 1797.469436] CPU: 1 PID: 9296 Comm: handler10 Kdump: loaded Not
tainted 5.5.0-rc5+ #10
[ 1797.480643] Hardware name: Dell Inc. PowerEdge R730/072T6D, BIOS
2.4.3 01/17/2017
[ 1797.491480] Call Trace:
[ 1797.496701] dump_stack+0x96/0xe0
[ 1797.502864] __lock_acquire.cold.63+0xf8/0x212
[ 1797.510301] ? lockdep_hardirqs_on+0x250/0x250
[ 1797.517701] ? mark_held_locks+0x55/0xa0
[ 1797.524547] ? quarantine_put+0xb7/0x160
[ 1797.531422] ? lockdep_hardirqs_on+0x17d/0x250
[ 1797.538913] lock_acquire+0xd6/0x1f0
[ 1797.545529] ? tree_put_node+0x1d5/0x210 [mlx5_core]
[ 1797.553701] down_write+0x94/0x140
[ 1797.560206] ? tree_put_node+0x1d5/0x210 [mlx5_core]
[ 1797.568464] ? down_write_killable_nested+0x170/0x170
[ 1797.576925] ? del_hw_flow_group+0xde/0x1f0 [mlx5_core]
[ 1797.585629] tree_put_node+0x1d5/0x210 [mlx5_core]
[ 1797.593891] ? free_match_list.part.25+0x147/0x170 [mlx5_core]
[ 1797.603389] free_match_list.part.25+0xe0/0x170 [mlx5_core]
[ 1797.612654] _mlx5_add_flow_rules+0x17e2/0x20b0 [mlx5_core]
[ 1797.621838] ? lock_acquire+0xd6/0x1f0
[ 1797.629028] ? esw_get_prio_table+0xb0/0x3e0 [mlx5_core]
[ 1797.637981] ? alloc_insert_flow_group+0x420/0x420 [mlx5_core]
[ 1797.647459] ? try_to_wake_up+0x4c7/0xc70
[ 1797.654881] ? lock_downgrade+0x350/0x350
[ 1797.662271] ? __mutex_unlock_slowpath+0xb1/0x3f0
[ 1797.670396] ? find_held_lock+0xac/0xd0
[ 1797.677540] ? mlx5_add_flow_rules+0xdc/0x360 [mlx5_core]
[ 1797.686467] mlx5_add_flow_rules+0xdc/0x360 [mlx5_core]
[ 1797.695134] ? _mlx5_add_flow_rules+0x20b0/0x20b0 [mlx5_core]
[ 1797.704270] ? irq_exit+0xa5/0x170
[ 1797.710764] ? retint_kernel+0x10/0x10
[ 1797.717698] ? mlx5_eswitch_set_rule_source_port.isra.9+0x122/0x230
[mlx5_core]
[ 1797.728708] mlx5_eswitch_add_offloaded_rule+0x465/0x6d0 [mlx5_core]
[ 1797.738713] ? mlx5_eswitch_get_prio_range+0x30/0x30 [mlx5_core]
[ 1797.748384] ? mlx5_fc_stats_work+0x670/0x670 [mlx5_core]
[ 1797.757400] mlx5e_tc_offload_fdb_rules.isra.27+0x24/0x90 [mlx5_core]
[ 1797.767665] mlx5e_tc_add_fdb_flow+0xaf8/0xd40 [mlx5_core]
[ 1797.776886] ? mlx5e_encap_put+0xd0/0xd0 [mlx5_core]
[ 1797.785562] ? mlx5e_alloc_flow.isra.43+0x18c/0x1c0 [mlx5_core]
[ 1797.795353] __mlx5e_add_fdb_flow+0x2e2/0x440 [mlx5_core]
[ 1797.804558] ? mlx5e_tc_update_neigh_used_value+0x8c0/0x8c0
[mlx5_core]
[ 1797.815093] ? wait_for_completion+0x260/0x260
[ 1797.823272] mlx5e_configure_flower+0xe94/0x1620 [mlx5_core]
[ 1797.832792] ? __mlx5e_add_fdb_flow+0x440/0x440 [mlx5_core]
[ 1797.842096] ? down_read+0x11a/0x2e0
[ 1797.849090] ? down_write+0x140/0x140
[ 1797.856142] ? mlx5e_rep_indr_setup_block_cb+0xc0/0xc0 [mlx5_core]
[ 1797.866027] tc_setup_cb_add+0x11a/0x250
[ 1797.873339] fl_hw_replace_filter+0x25e/0x320 [cls_flower]
[ 1797.882385] ? fl_hw_destroy_filter+0x1c0/0x1c0 [cls_flower]
[ 1797.891607] fl_change+0x1d54/0x1fb6 [cls_flower]
[ 1797.899772] ? __rhashtable_insert_fast.constprop.50+0x9f0/0x9f0
[cls_flower]
[ 1797.910728] ? lock_downgrade+0x350/0x350
[ 1797.918187] ? __radix_tree_lookup+0xa5/0x130
[ 1797.926046] ? fl_set_key+0x1590/0x1590 [cls_flower]
[ 1797.934611] ? __rhashtable_insert_fast.constprop.50+0x9f0/0x9f0
[cls_flower]
[ 1797.945673] tc_new_tfilter+0xcd1/0x1240
[ 1797.953138] ? tc_del_tfilter+0xb10/0xb10
[ 1797.960688] ? avc_has_perm_noaudit+0x92/0x320
[ 1797.968721] ? avc_has_perm_noaudit+0x1df/0x320
[ 1797.976816] ? avc_has_extended_perms+0x990/0x990
[ 1797.985090] ? mark_lock+0xaa/0x9e0
[ 1797.991988] ? match_held_lock+0x1b/0x240
[ 1797.999457] ? match_held_lock+0x1b/0x240
[ 1798.006859] ? find_held_lock+0xac/0xd0
[ 1798.014045] ? symbol_put_addr+0x40/0x40
[ 1798.021317] ? rcu_read_lock_sched_held+0xd0/0xd0
[ 1798.029460] ? tc_del_tfilter+0xb10/0xb10
[ 1798.036810] rtnetlink_rcv_msg+0x4d5/0x620
[ 1798.044236] ? rtnl_bridge_getlink+0x460/0x460
[ 1798.052034] ? lockdep_hardirqs_on+0x250/0x250
[ 1798.059837] ? match_held_lock+0x1b/0x240
[ 1798.067146] ? find_held_lock+0xac/0xd0
[ 1798.074246] netlink_rcv_skb+0xc6/0x1f0
[ 1798.081339] ? rtnl_bridge_getlink+0x460/0x460
[ 1798.089104] ? netlink_ack+0x440/0x440
[ 1798.096061] netlink_unicast+0x2d4/0x3b0
[ 1798.103189] ? netlink_attachskb+0x3f0/0x3f0
[ 1798.110724] ? _copy_from_iter_full+0xda/0x370
[ 1798.118415] netlink_sendmsg+0x3ba/0x6a0
[ 1798.125478] ? netlink_unicast+0x3b0/0x3b0
[ 1798.132705] ? netlink_unicast+0x3b0/0x3b0
[ 1798.139880] sock_sendmsg+0x94/0xa0
[ 1798.146332] ____sys_sendmsg+0x36c/0x3f0
[ 1798.153251] ? copy_msghdr_from_user+0x165/0x230
[ 1798.160941] ? kernel_sendmsg+0x30/0x30
[ 1798.167738] ___sys_sendmsg+0xeb/0x150
[ 1798.174411] ? sendmsg_copy_msghdr+0x30/0x30
[ 1798.181649] ? lock_downgrade+0x350/0x350
[ 1798.188559] ? rcu_read_lock_sched_held+0xd0/0xd0
[ 1798.196239] ? __fget+0x21d/0x320
[ 1798.202335] ? do_dup2+0x2a0/0x2a0
[ 1798.208499] ? lock_downgrade+0x350/0x350
[ 1798.215366] ? __fget_light+0xd6/0xf0
[ 1798.221808] ? syscall_trace_enter+0x369/0x5d0
[ 1798.229112] __sys_sendmsg+0xd3/0x160
[ 1798.235511] ? __sys_sendmsg_sock+0x60/0x60
[ 1798.242478] ? syscall_trace_enter+0x233/0x5d0
[ 1798.249721] ? syscall_slow_exit_work+0x280/0x280
[ 1798.257211] ? do_syscall_64+0x1e/0x2e0
[ 1798.263680] do_syscall_64+0x72/0x2e0
[ 1798.269950] entry_SYSCALL_64_after_hwframe+0x49/0xbe--- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +8 -7
@@ -1555,16 +1555,16 @@ struct match_list_head {struct match_list first; }; -static void free_match_list (struct match_list_head *head) +static void free_match_list (struct match_list_head *head,bool ft_locked) {if (!list_empty (&head->list)) {struct match_list *iter, *match_tmp;list_del (&head->first.list); -tree_put_node (&head->first.g->node, false); +tree_put_node (&head->first.g->node, ft_locked);list_for_each_entry_safe (iter, match_tmp, &head->list, list) { -tree_put_node (&iter->g->node, false); +tree_put_node (&iter->g->node, ft_locked);list_del (&iter->list);kfree (iter); }
@@ -1573,7 +1573,8 @@ static void free_match_list(struct matchstatic int build_match_list (struct match_list_head *match_head,struct mlx5_flow_table *ft, -const struct mlx5_flow_spec *spec) +const struct mlx5_flow_spec *spec, +bool ft_locked) {struct rhlist_head *tmp, *list;struct mlx5_flow_group *g;
@@ -1598,7 +1599,7 @@ static int build_match_list(struct match curr_match =kmalloc (sizeof (*curr_match),GFP_ATOMIC );if (!curr_match) { -free_match_list (match_head); +free_match_list (match_head, ft_locked); err = -ENOMEM ; goto out; }
@@ -1778,7 +1779,7 @@ search_again_locked: version =atomic_read (&ft->node.version);/* Collect all fgs which has a matching match_criteria */ - err =build_match_list (&match_head, ft, spec); + err =build_match_list (&match_head, ft, spec, take_write);if (err) {if (take_write)up_write_ref_node (&ft->node, false);
@@ -1792,7 +1793,7 @@ search_again_locked: rule =try_add_to_existing_fg (ft, &match_head.list, spec, flow_act, dest, dest_num, version); -free_match_list (&match_head); +free_match_list (&match_head, take_write);if (!IS_ERR (rule) || (PTR_ERR (rule) != -ENOENT &&PTR_ERR (rule) != -EAGAIN )) {if (take_write)
Greg Kroah-Hartman
maintainerPATCH 299/309 KVM: nVMX: vmread should not set rflags to specify success in case of #PF
In reply to Greg Kroah-HartmanFrom: Miaohe Lin <[email protected]>
[ Upstream commit a4d956b9390418623ae5d07933e2679c68b6f83c ]
In case writing to vmread destination operand result in a #PF, vmread should not call nested_vmx_succeed() to set rflags to specify success. Similar to as done in VMPTRST (See handle_vmptrst()).
--- arch/x86/kvm/vmx/nested.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kvm/vmx/nested.c +3 -1
@@ -4663,8 +4663,10 @@ static int handle_vmread(struct kvm_vcpu *vcpu) vmx_instruction_info, true, len, &gva))return 1 ;/* _system ok, nested_vmx_check_permission has verified cpl=0 */ -if (kvm_write_guest_virt_system (vcpu, gva, &field_value, len, &e)) +if (kvm_write_guest_virt_system (vcpu, gva, &field_value, len, &e)) {kvm_inject_page_fault (vcpu, &e); +return 1 ; + } }return nested_vmx_succeed (vcpu);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 309/309 powerpc/kuap: Fix set direction in allow/prevent_user_access()
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
[ Upstream commit 1d8f739b07bd538f272f60bf53f10e7e6248d295 ]
__builtin_constant_p() always return 0 for pointers, so on RADIX we always end up opening both direction (by writing 0 in SPR29):
0000000000000170 <._copy_to_user>:
...
1b0: 4c 00 01 2c isync
1b4: 39 20 00 00 li r9,0
1b8: 7d 3d 03 a6 mtspr 29,r9
1bc: 4c 00 01 2c isync
1c0: 48 00 00 01 bl 1c0 <._copy_to_user+0x50>
1c0: R_PPC64_REL24 .__copy_tofrom_user
...
0000000000000220 <._copy_from_user>:
...
2ac: 4c 00 01 2c isync
2b0: 39 20 00 00 li r9,0
2b4: 7d 3d 03 a6 mtspr 29,r9
2b8: 4c 00 01 2c isync
2bc: 7f c5 f3 78 mr r5,r30 2c0: 7f 83 e3 78 mr r3,r28 2c4: 48 00 00 01 bl 2c4 <._copy_from_user+0xa4>
2c4: R_PPC64_REL24 .__copy_tofrom_user
...
Use an explicit parameter for direction selection, so that GCC is able to see it is a constant:
00000000000001b0 <._copy_to_user>:
...
1f0: 4c 00 01 2c isync
1f4: 3d 20 40 00 lis r9,16384 1f8: 79 29 07 c6 rldicr r9,r9,32,31 1fc: 7d 3d 03 a6 mtspr 29,r9 200: 4c 00 01 2c isync 204: 48 00 00 01 bl 204 <._copy_to_user+0x54> 204: R_PPC64_REL24 .__copy_tofrom_user ... 0000000000000260 <._copy_from_user>: ... 2ec: 4c 00 01 2c isync 2f0: 39 20 ff ff li r9,-1 2f4: 79 29 00 04 rldicr r9,r9,0,0 2f8: 7d 3d 03 a6 mtspr 29,r9 2fc: 4c 00 01 2c isync 300: 7f c5 f3 78 mr r5,r30 304: 7f 83 e3 78 mr r3,r28 308: 48 00 00 01 bl 308 <._copy_from_user+0xa8>
308: R_PPC64_REL24 .__copy_tofrom_user
...
--- arch/powerpc/include/asm/book3s/32/kup.h | 13 ++++++-- .../powerpc/include/asm/book3s/64/kup-radix.h | 11 +++---- arch/powerpc/include/asm/kup.h | 30 ++++++++++++++----- arch/powerpc/include/asm/nohash/32/kup-8xx.h | 4 +-- arch/powerpc/include/asm/uaccess.h | 4 +-- 5 files changed, 43 insertions(+), 19 deletions(-)
arch/powerpc/include/asm/book3s/32/kup.h +10 -3
@@ -102,11 +102,13 @@ static inline void kuap_update_sr(u32 sr, u32 addr, u32 end)isync ();/* Context sync required after mtsrin() */ } -static inline void allow_user_access (void __user *to,const void __user *from,u32 size) +static __always_inline void allow_user_access(void __user *to, const void __user *from, +u32 size,unsigned long dir) {u32 addr, end; -if (__builtin_constant_p (to) && to ==NULL ) +BUILD_BUG_ON (!__builtin_constant_p (dir)); +if (!(dir &KUAP_WRITE ))return ; addr = (__force u32 )to;
@@ -119,11 +121,16 @@ static inline void allow_user_access(void __user *to, const void __user *from, ukuap_update_sr (mfsrin (addr) & ~SR_KS , addr, end);/* Clear Ks */ } -static inline void prevent_user_access (void __user *to,const void __user *from,u32 size) +static __always_inline void prevent_user_access(void __user *to, const void __user *from, +u32 size,unsigned long dir) {u32 addr = (__force u32 )to;u32 end =min (addr + size,TASK_SIZE ); +BUILD_BUG_ON (!__builtin_constant_p (dir)); +if (!(dir &KUAP_WRITE )) +return ; +if (!addr || addr >=TASK_SIZE || !size)return ;
arch/powerpc/include/asm/book3s/64/kup-radix.h +6 -5
@@ -77,20 +77,21 @@ static inline void set_kuap(unsigned long value)isync (); } -static inline void allow_user_access (void __user *to,const void __user *from, -unsigned long size) +static __always_inline void allow_user_access(void __user *to, const void __user *from, +unsigned long size,unsigned long dir) {// This is written so we can resolve to a single case at build time -if (__builtin_constant_p (to) && to ==NULL ) +BUILD_BUG_ON (!__builtin_constant_p (dir)); +if (dir ==KUAP_READ )set_kuap (AMR_KUAP_BLOCK_WRITE ); -else if (__builtin_constant_p (from) && from ==NULL ) +else if (dir ==KUAP_WRITE )set_kuap (AMR_KUAP_BLOCK_READ );else set_kuap (0 ); }static inline void prevent_user_access (void __user *to,const void __user *from, -unsigned long size) +unsigned long size,unsigned long dir) {set_kuap (AMR_KUAP_BLOCKED ); }
arch/powerpc/include/asm/kup.h +23 -7
@@ -2,6 +2,10 @@#ifndef _ASM_POWERPC_KUP_H_#define _ASM_POWERPC_KUP_H_ +#define KUAP_READ 1 +#define KUAP_WRITE 2 +#define KUAP_READ_WRITE (KUAP_READ | KUAP_WRITE) +#ifdef CONFIG_PPC64 #include <asm/book3s/64/kup-radix.h> #endif
@@ -42,9 +46,9 @@ void setup_kuap(bool disabled);#else static inline void setup_kuap (bool disabled) { }static inline void allow_user_access (void __user *to,const void __user *from, -unsigned long size) { } +unsigned long size,unsigned long dir) { }static inline void prevent_user_access (void __user *to,const void __user *from, -unsigned long size) { } +unsigned long size,unsigned long dir) { }static inline bool bad_kuap_fault (struct pt_regs *regs,unsigned long address,bool is_write) {
@@ -54,24 +58,36 @@ bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write)static inline void allow_read_from_user (const void __user *from,unsigned long size) { -allow_user_access (NULL , from, size); +allow_user_access (NULL , from, size,KUAP_READ ); }static inline void allow_write_to_user (void __user *to,unsigned long size) { -allow_user_access (to,NULL , size); +allow_user_access (to,NULL , size,KUAP_WRITE ); +} + +static inline void allow_read_write_user (void __user *to,const void __user *from, +unsigned long size) +{ +allow_user_access (to, from, size,KUAP_READ_WRITE ); }static inline void prevent_read_from_user (const void __user *from,unsigned long size) { -prevent_user_access (NULL , from, size); +prevent_user_access (NULL , from, size,KUAP_READ ); }static inline void prevent_write_to_user (void __user *to,unsigned long size) { -prevent_user_access (to,NULL , size); +prevent_user_access (to,NULL , size,KUAP_WRITE ); +} + +static inline void prevent_read_write_user (void __user *to,const void __user *from, +unsigned long size) +{ +prevent_user_access (to, from, size,KUAP_READ_WRITE ); }#endif /* !__ASSEMBLY__ */ -#endif /* _ASM_POWERPC_KUP_H_ */ +#endif /* _ASM_POWERPC_KUAP_H_ */
arch/powerpc/include/asm/nohash/32/kup-8xx.h +2 -2
@@ -34,13 +34,13 @@#include <asm/reg.h> static inline void allow_user_access (void __user *to,const void __user *from, -unsigned long size) +unsigned long size,unsigned long dir) {mtspr (SPRN_MD_AP ,MD_APG_INIT ); }static inline void prevent_user_access (void __user *to,const void __user *from, -unsigned long size) +unsigned long size,unsigned long dir) {mtspr (SPRN_MD_AP ,MD_APG_KUAP ); }
arch/powerpc/include/asm/uaccess.h +2 -2
@@ -313,9 +313,9 @@ raw_copy_in_user(void __user *to, const void __user *from, unsigned long n)unsigned long ret;barrier_nospec (); -allow_user_access (to, from, n); +allow_read_write_user (to, from, n); ret =__copy_tofrom_user (to, from, n); -prevent_user_access (to, from, n); +prevent_read_write_user (to, from, n); return ret; }#endif /* __powerpc64__ */
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 233/309 virtio-pci: check name when counting MSI-X vectors
In reply to Greg Kroah-HartmanFrom: Daniel Verkamp <[email protected]>
commit 303090b513fd1ee45aa1536b71a3838dc054bc05 upstream.
VQs without a name specified are not valid; they are skipped in the later loop that assigns MSI-X vectors to queues, but the per_vq_vectors loop above that counts the required number of vectors previously still counted any queue with a non-NULL callback as needing a vector.
Add a check to the per_vq_vectors loop so that vectors with no name are not counted to make the two loops consistent. This prevents over-counting unnecessary vectors (e.g. for features which were not negotiated with the device).
--- drivers/virtio/virtio_pci_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/virtio/virtio_pci_common.c +1 -1
@@ -294,7 +294,7 @@ static int vp_find_vqs_msix(struct virti/* Best option: one for change interrupt, one per vq. */ nvectors =1 ;for (i =0 ; i < nvqs; ++i) -if (callbacks[i]) +if (names[i] && callbacks[i]) ++nvectors; }else {/* Second best: one for change, shared for all vqs. */
Greg Kroah-Hartman
maintainerPATCH 268/309 net: dsa: microchip: enable module autoprobe
In reply to Greg Kroah-HartmanFrom: Razvan Stefanescu <[email protected]>
[ Upstream commit f8c2afa66d5397b0b9293c4347dac6dabb327685 ]
This matches /sys/devices/.../spi1.0/modalias content.
--- drivers/net/dsa/microchip/ksz9477_spi.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/dsa/microchip/ksz9477_spi.c +6 -0
@@ -101,6 +101,12 @@ static struct spi_driver ksz9477_spi_drimodule_spi_driver (ksz9477_spi_driver); +MODULE_ALIAS ("spi:ksz9477" ); +MODULE_ALIAS ("spi:ksz9897" ); +MODULE_ALIAS ("spi:ksz9893" ); +MODULE_ALIAS ("spi:ksz9563" ); +MODULE_ALIAS ("spi:ksz8563" ); +MODULE_ALIAS ("spi:ksz9567" );MODULE_AUTHOR ("Woojung Huh <[email protected]>" );MODULE_DESCRIPTION ("Microchip KSZ9477 Series Switch SPI access Driver" );MODULE_LICENSE ("GPL" );
Greg Kroah-Hartman
maintainerPATCH 305/309 clocksource: Prevent double add_timer_on() for watchdog_timer
In reply to Greg Kroah-HartmanFrom: Konstantin Khlebnikov <[email protected]>
commit febac332a819f0e764aa4da62757ba21d18c182b upstream.
Kernel crashes inside QEMU/KVM are observed:
kernel BUG at kernel/time/timer.c:1154! BUG_ON(timer_pending(timer) || !timer->function) in add_timer_on().
At the same time another cpu got:
general protection fault: 0000 [#1] SMP PTI of poinson pointer 0xdead000000000200 in:
__hlist_del at include/linux/list.h:681
(inlined by) detach_timer at kernel/time/timer.c:818 (inlined by) expire_timers at kernel/time/timer.c:1355 (inlined by) __run_timers at kernel/time/timer.c:1686 (inlined by) run_timer_softirq at kernel/time/timer.c:1699
Unfortunately kernel logs are badly scrambled, stacktraces are lost.
Printing the timer->function before the BUG_ON() pointed to clocksource_watchdog().
The execution of clocksource_watchdog() can race with a sequence of clocksource_stop_watchdog() .. clocksource_start_watchdog():
expire_timers()
detach_timer(timer, true);
timer->entry.pprev = NULL;
raw_spin_unlock_irq(&base->lock);
call_timer_fn
clocksource_watchdog()
clocksource_watchdog_kthread() or clocksource_unbind() spin_lock_irqsave(&watchdog_lock, flags); clocksource_stop_watchdog(); del_timer(&watchdog_timer); watchdog_running = 0; spin_unlock_irqrestore(&watchdog_lock, flags); spin_lock_irqsave(&watchdog_lock, flags); clocksource_start_watchdog(); add_timer_on(&watchdog_timer, ...); watchdog_running = 1; spin_unlock_irqrestore(&watchdog_lock, flags);
spin_lock(&watchdog_lock);
add_timer_on(&watchdog_timer, ...);
BUG_ON(timer_pending(timer) || !timer->function);
timer_pending() -> true
BUG()I.e. inside clocksource_watchdog() watchdog_timer could be already armed.
Check timer_pending() before calling add_timer_on(). This is sufficient as all operations are synchronized by watchdog_lock.
--- kernel/time/clocksource.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
kernel/time/clocksource.c +9 -2
@@ -293,8 +293,15 @@ static void clocksource_watchdog(struct next_cpu =cpumask_next (raw_smp_processor_id (), cpu_online_mask);if (next_cpu >= nr_cpu_ids) next_cpu =cpumask_first (cpu_online_mask); - watchdog_timer.expires +=WATCHDOG_INTERVAL ; -add_timer_on (&watchdog_timer, next_cpu); + +/* +* Arm timer if not already pending: could race with concurrent +* pair clocksource_stop_watchdog() clocksource_start_watchdog(). +*/ +if (!timer_pending (&watchdog_timer)) { + watchdog_timer.expires +=WATCHDOG_INTERVAL ; +add_timer_on (&watchdog_timer, next_cpu); + } out:spin_unlock (&watchdog_lock); }
Greg Kroah-Hartman
maintainerPATCH 267/309 net: dsa: bcm_sf2: Only 7278 supports 2Gb/sec IMP port
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
[ Upstream commit de34d7084edd069dac5aa010cfe32bd8c4619fa6 ]
The 7445 switch clocking profiles do not allow us to run the IMP port at 2Gb/sec in a way that it is reliable and consistent. Make sure that the setting is only applied to the 7278 family.
--- drivers/net/dsa/bcm_sf2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/dsa/bcm_sf2.c +3 -1
@@ -68,7 +68,9 @@ static void bcm_sf2_imp_setup(struct dsa/* Force link status for IMP port */ reg =core_readl (priv, offset); - reg |= (MII_SW_OR |LINK_STS |GMII_SPEED_UP_2G ); + reg |= (MII_SW_OR |LINK_STS ); +if (priv->type ==BCM7278_DEVICE_ID ) + reg |=GMII_SPEED_UP_2G ;core_writel (priv, reg, offset);/* Enable Broadcast, Multicast, Unicast forwarding to IMP port */
Greg Kroah-Hartman
maintainerPATCH 302/309 cifs: fail i/o on soft mounts if sessionsetup errors out
In reply to Greg Kroah-HartmanFrom: Ronnie Sahlberg <[email protected]>
commit b0dd940e582b6a60296b9847a54012a4b080dc72 upstream.
RHBZ: 1579050
If we have a soft mount we should fail commands for session-setup failures (such as the password having changed/ account being deleted/ ...) and return an error back to the application.
--- fs/cifs/smb2pdu.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
fs/cifs/smb2pdu.c +8 -2
@@ -350,9 +350,14 @@ smb2_reconnect(__le16 smb2_command, stru } rc =cifs_negotiate_protocol (0 , tcon->ses); -if (!rc && tcon->ses->need_reconnect) +if (!rc && tcon->ses->need_reconnect) { rc =cifs_setup_session (0 , tcon->ses, nls_codepage); - +if ((rc == -EACCES ) && !tcon->retry) { + rc = -EHOSTDOWN ; +mutex_unlock (&tcon->ses->session_mutex); + goto failed; + } + }if (rc || !tcon->need_reconnect) {mutex_unlock (&tcon->ses->session_mutex); goto out;
@@ -397,6 +402,7 @@ out:case SMB2_SET_INFO : rc = -EAGAIN ; } +failed:unload_nls (nls_codepage);return rc; }
Greg Kroah-Hartman
maintainerPATCH 301/309 KVM: Play nice with read-only memslots when querying host page size
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
[ Upstream commit 42cde48b2d39772dba47e680781a32a6c4b7dc33 ]
Avoid the "writable" check in __gfn_to_hva_many(), which will always fail on read-only memslots due to gfn_to_hva() assuming writes. Functionally, this allows x86 to create large mappings for read-only memslots that are backed by HugeTLB mappings.
Note, the changelog for commit 05da45583de9 ("KVM: MMU: large page support") states "If the largepage contains write-protected pages, a large pte is not used.", but "write-protected" refers to pages that are temporarily read-only, e.g. read-only memslots didn't even exist at the time.
--- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
virt/kvm/kvm_main.c +1 -1
@@ -1401,7 +1401,7 @@ unsigned long kvm_host_page_size(struct kvm_vcpu *vcpu, gfn_t gfn) size =PAGE_SIZE ; - addr =kvm_vcpu_gfn_to_hva (vcpu, gfn); + addr =kvm_vcpu_gfn_to_hva_prot (vcpu, gfn,NULL );if (kvm_is_error_hva (addr))return PAGE_SIZE ;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 228/309 arm64: dts: qcom: qcs404-evb: Set vdd_apc regulator in high power mode
In reply to Greg Kroah-HartmanFrom: Niklas Cassel <[email protected]>
commit eac8ce86cb90ba96cb4bcbf2549d7a8b6938aa30 upstream.
vdd_apc is the regulator that supplies the main CPU cluster.
At sudden CPU load changes, we have noticed invalid page faults on addresses with all bits shifted, as well as on addresses with individual bits flipped.
By putting the vdd_apc regulator in high power mode, the voltage drops during sudden load changes will be less severe, and we have not been able to reproduce the invalid page faults with the regulator in this mode.
--- arch/arm64/boot/dts/qcom/qcs404-evb.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/qcom/qcs404-evb.dtsi +1 -0
@@ -73,6 +73,7 @@ regulator-always-on; regulator-boot-on; regulator-name = "vdd_apc"; + regulator-initial-mode = <1>; regulator-min-microvolt = <1048000>; regulator-max-microvolt = <1384000>; };
Greg Kroah-Hartman
maintainerPATCH 247/309 NFC: pn544: Adjust indentation in pn544_hci_check_presence
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit 5080832627b65e3772a35d1dced68c64e2b24442 upstream.
Clang warns
../drivers/nfc/pn544/pn544.c:696:4: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
return nfc_hci_send_cmd(hdev, NFC_HCI_RF_READER_A_GATE, ^../drivers/nfc/pn544/pn544.c:692:3: note: previous statement is here
if (target->nfcid1_len != 4 && target->nfcid1_len != 7 &&
^1 warning generated.
This warning occurs because there is a space after the tab on this line. Remove it so that the indentation is consistent with the Linux kernel coding style and clang no longer warns.
--- drivers/nfc/pn544/pn544.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nfc/pn544/pn544.c +1 -1
@@ -693,7 +693,7 @@ static int pn544_hci_check_presence(stru target->nfcid1_len != 10)return -EOPNOTSUPP ; -return nfc_hci_send_cmd (hdev,NFC_HCI_RF_READER_A_GATE , +return nfc_hci_send_cmd (hdev,NFC_HCI_RF_READER_A_GATE ,PN544_RF_READER_CMD_ACTIVATE_NEXT , target->nfcid1, target->nfcid1_len,NULL ); } else if (target->supported_protocols & (NFC_PROTO_JEWEL_MASK |
Greg Kroah-Hartman
maintainerPATCH 239/309 scsi: csiostor: Adjust indentation in csio_device_reset
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit a808a04c861782e31fc30e342a619c144aaee14a upstream.
Clang warns:
../drivers/scsi/csiostor/csio_scsi.c:1386:3: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
csio_lnodes_exit(hw, 1);
^
../drivers/scsi/csiostor/csio_scsi.c:1382:2: note: previous statement is
here
if (*buf != '1')
^1 warning generated.
This warning occurs because there is a space after the tab on this line. Remove it so that the indentation is consistent with the Linux kernel coding style and clang no longer warns.
--- drivers/scsi/csiostor/csio_scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/csiostor/csio_scsi.c +1 -1
@@ -1383,7 +1383,7 @@ csio_device_reset(struct device *dev,return -EINVAL ;/* Delete NPIV lnodes */ -csio_lnodes_exit (hw,1 ); +csio_lnodes_exit (hw,1 );/* Block upper IOs */ csio_lnodes_block_request (hw);
Greg Kroah-Hartman
maintainerPATCH 231/309 drm/amd/dm/mst: Ignore payload update failures
In reply to Greg Kroah-HartmanFrom: Lyude Paul <[email protected]>
commit 58fe03d6dec908a1bec07eea7e94907af5c07eec upstream.
Disabling a display on MST can potentially happen after the entire MST topology has been removed, which means that we can't communicate with the topology at all in this scenario. Likewise, this also means that we can't properly update payloads on the topology and as such, it's a good idea to ignore payload update failures when disabling displays. Currently, amdgpu makes the mistake of halting the payload update process when any payload update failures occur, resulting in leaving DC's local copies of the payload tables out of date.
This ends up causing problems with hotplugging MST topologies, and causes modesets on the second hotplug to fail like so:
[drm] Failed to updateMST allocation table forpipe idx:1
------------[ cut here ]------------ WARNING: CPU: 5 PID: 1511 at drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_link.c:2677 update_mst_stream_alloc_table+0x11e/0x130 [amdgpu] Modules linked in: cdc_ether usbnet fuse xt_conntrack nf_conntrack
nf_defrag_ipv6 libcrc32c nf_defrag_ipv4 ipt_REJECT nf_reject_ipv4 nft_counter nft_compat nf_tables nfnetlink tun bridge stp llc sunrpc vfat fat wmi_bmof uvcvideo snd_hda_codec_realtek snd_hda_codec_generic snd_hda_codec_hdmi videobuf2_vmalloc snd_hda_intel videobuf2_memops videobuf2_v4l2 snd_intel_dspcfg videobuf2_common crct10dif_pclmul snd_hda_codec videodev crc32_pclmul snd_hwdep snd_hda_core ghash_clmulni_intel snd_seq mc joydev pcspkr snd_seq_device snd_pcm sp5100_tco k10temp i2c_piix4 snd_timer thinkpad_acpi ledtrig_audio snd wmi soundcore video i2c_scmi acpi_cpufreq ip_tables amdgpu(O) rtsx_pci_sdmmc amd_iommu_v2 gpu_sched mmc_core i2c_algo_bit ttm drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops cec drm crc32c_intel serio_raw hid_multitouch r8152 mii nvme r8169 nvme_core rtsx_pci pinctrl_amd
CPU: 5 PID: 1511 Comm: gnome-shell Tainted: G O 5.5.0-rc7Lyude-Test+ #4 Hardware name: LENOVO FA495SIT26/FA495SIT26, BIOS R12ET22W(0.22 ) 01/31/2019 RIP: 0010:update_mst_stream_alloc_table+0x11e/0x130 [amdgpu] Code: 28 00 00 00 75 2b 48 8d 65 e0 5b 41 5c 41 5d 41 5e 5d c3 0f b6 06 49 89 1c 24 41 88 44 24 08 0f b6 46 01 41 88 44 24 09 eb 93 <0f> 0b e9 2f ff ff ff e8 a6 82 a3 c2 66 0f 1f 44 00 00 0f 1f 44 00 RSP: 0018:ffffac428127f5b0 EFLAGS: 00010202 RAX: 0000000000000002 RBX: ffff8d1e166eee80 RCX: 0000000000000000 RDX: ffffac428127f668 RSI: ffff8d1e166eee80 RDI: ffffac428127f610 RBP: ffffac428127f640 R08: ffffffffc03d94a8 R09: 0000000000000000 R10: ffff8d1e24b02000 R11: ffffac428127f5b0 R12: ffff8d1e1b83d000 R13: ffff8d1e1bea0b08 R14: 0000000000000002 R15: 0000000000000002 FS: 00007fab23ffcd80(0000) GS:ffff8d1e28b40000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f151f1711e8 CR3: 00000005997c0000 CR4: 00000000003406e0 Call Trace: ? mutex_lock+0xe/0x30 dc_link_allocate_mst_payload+0x9a/0x210 [amdgpu] ? dm_read_reg_func+0x39/0xb0 [amdgpu] ? core_link_enable_stream+0x656/0x730 [amdgpu] core_link_enable_stream+0x656/0x730 [amdgpu] dce110_apply_ctx_to_hw+0x58e/0x5d0 [amdgpu] ? dcn10_verify_allow_pstate_change_high+0x1d/0x280 [amdgpu] ? dcn10_wait_for_mpcc_disconnect+0x3c/0x130 [amdgpu] dc_commit_state+0x292/0x770 [amdgpu] ? add_timer+0x101/0x1f0 ? ttm_bo_put+0x1a1/0x2f0 [ttm] amdgpu_dm_atomic_commit_tail+0xb59/0x1ff0 [amdgpu] ? amdgpu_move_blit.constprop.0+0xb8/0x1f0 [amdgpu] ? amdgpu_bo_move+0x16d/0x2b0 [amdgpu] ? ttm_bo_handle_move_mem+0x118/0x570 [ttm] ? ttm_bo_validate+0x134/0x150 [ttm] ? dm_plane_helper_prepare_fb+0x1b9/0x2a0 [amdgpu] ? _cond_resched+0x15/0x30 ? wait_for_completion_timeout+0x38/0x160 ? _cond_resched+0x15/0x30 ? wait_for_completion_interruptible+0x33/0x190 commit_tail+0x94/0x130 [drm_kms_helper] drm_atomic_helper_commit+0x113/0x140 [drm_kms_helper] drm_atomic_helper_set_config+0x70/0xb0 [drm_kms_helper] drm_mode_setcrtc+0x194/0x6a0 [drm] ? _cond_resched+0x15/0x30 ? mutex_lock+0xe/0x30 ? drm_mode_getcrtc+0x180/0x180 [drm] drm_ioctl_kernel+0xaa/0xf0 [drm] drm_ioctl+0x208/0x390 [drm] ? drm_mode_getcrtc+0x180/0x180 [drm] amdgpu_drm_ioctl+0x49/0x80 [amdgpu] do_vfs_ioctl+0x458/0x6d0 ksys_ioctl+0x5e/0x90 __x64_sys_ioctl+0x16/0x20 do_syscall_64+0x55/0x1b0 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7fab2121f87b Code: 0f 1e fa 48 8b 05 0d 96 2c 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff
ff ff c3 66 0f 1f 44 00 00 f3 0f 1e fa b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d dd 95 2c 00 f7 d8 64 89 01 48
RSP: 002b:00007ffd045f9068 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007ffd045f90a0 RCX: 00007fab2121f87b
RDX: 00007ffd045f90a0 RSI: 00000000c06864a2 RDI: 000000000000000b
RBP: 00007ffd045f90a0 R08: 0000000000000000 R09: 000055dbd2985d10
R10: 000055dbd2196280 R11: 0000000000000246 R12: 00000000c06864a2
R13: 000000000000000b R14: 0000000000000000 R15: 000055dbd2196280
---[ end trace 6ea888c24d2059cd ]---
Note as well, I have only been able to reproduce this on setups with 2 MST displays.
Changes since v1:
* Don't return false when part 1 or part 2 of updating the payloads fails, we don't want to abort at any step of the process even if things fail
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +4 -9
@@ -247,7 +247,8 @@ bool dm_helpers_dp_mst_write_payload_alldrm_dp_mst_reset_vcpi_slots (mst_mgr, mst_port); } - ret =drm_dp_update_payload_part1 (mst_mgr); +/* It's OK for this to fail */ +drm_dp_update_payload_part1 (mst_mgr);/* mst_mgr->->payloads are VC payload notify MST branch using DPCD or * AUX message. The sequence is slot 1-63 allocated sequence for each
@@ -256,9 +257,6 @@ bool dm_helpers_dp_mst_write_payload_allget_payload_table (aconnector, proposed_table); -if (ret) -return false; -return true; }
@@ -316,7 +314,6 @@ bool dm_helpers_dp_mst_send_payload_allostruct amdgpu_dm_connector *aconnector;struct drm_dp_mst_topology_mgr *mst_mgr;struct drm_dp_mst_port *mst_port; -int ret; aconnector = (struct amdgpu_dm_connector *)stream->dm_stream_context;
@@ -330,10 +327,8 @@ bool dm_helpers_dp_mst_send_payload_alloif (!mst_mgr->mst_state)return false; - ret =drm_dp_update_payload_part2 (mst_mgr); - -if (ret) -return false; +/* It's OK for this to fail */ +drm_dp_update_payload_part2 (mst_mgr);if (!enable)drm_dp_mst_deallocate_vcpi (mst_mgr, mst_port);
Greg Kroah-Hartman
maintainerPATCH 229/309 mm/mmu_gather: invalidate TLB correctly on batch allocation failure and flush
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
commit 0ed1325967ab5f7a4549a2641c6ebe115f76e228 upstream.
Architectures for which we have hardware walkers of Linux page table should flush TLB on mmu gather batch allocation failures and batch flush. Some architectures like POWER supports multiple translation modes (hash and radix) and in the case of POWER only radix translation mode needs the above TLBI. This is because for hash translation mode kernel wants to avoid this extra flush since there are no hardware walkers of linux page table. With radix translation, the hardware also walks linux page table and with that, kernel needs to make sure to TLB invalidate page walk cache before page table pages are freed.
More details in commit d86564a2f085 ("mm/tlb, x86/mm: Support invalidating TLB caches for RCU_TABLE_FREE")
The changes to sparc are to make sure we keep the old behavior since we are now removing HAVE_RCU_TABLE_NO_INVALIDATE. The default value for tlb_needs_table_invalidate is to always force an invalidate and sparc can avoid the table invalidate. Hence we define tlb_needs_table_invalidate to false for sparc architecture.
--- arch/Kconfig | 3 --- arch/powerpc/Kconfig | 1 - arch/powerpc/include/asm/tlb.h | 11 +++++++++++ arch/sparc/Kconfig | 1 - arch/sparc/include/asm/tlb_64.h | 9 +++++++++ include/asm-generic/tlb.h | 22 +++++++++++++++------- mm/mmu_gather.c | 16 ++++++++-------- 7 files changed, 43 insertions(+), 20 deletions(-)
arch/Kconfig +0 -3
@@ -396,9 +396,6 @@ config HAVE_ARCH_JUMP_LABEL_RELATIVE config HAVE_RCU_TABLE_FREE bool -config HAVE_RCU_TABLE_NO_INVALIDATE - bool - config HAVE_MMU_GATHER_PAGE_SIZE bool
arch/powerpc/Kconfig +0 -1
@@ -222,7 +222,6 @@ config PPC select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP select HAVE_RCU_TABLE_FREE - select HAVE_RCU_TABLE_NO_INVALIDATE if HAVE_RCU_TABLE_FREE select HAVE_MMU_GATHER_PAGE_SIZE select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RELIABLE_STACKTRACE if PPC_BOOK3S_64 && CPU_LITTLE_ENDIAN
arch/powerpc/include/asm/tlb.h +11 -0
@@ -26,6 +26,17 @@#define tlb_flush tlb_flushextern void tlb_flush (struct mmu_gather *tlb); +/* +* book3s: +* Hash does not use the linux page-tables, so we can avoid +* the TLB invalidate for page-table freeing, Radix otoh does use the +* page-tables and needs the TLBI. +* +* nohash: +* We still do TLB invalidate in the __pte_free_tlb routine before we +* add the page table pages to mmu gather table batch. +*/ +#define tlb_needs_table_invalidate () radix_enabled()/* Get the generic bits... */ #include <asm-generic/tlb.h>
arch/sparc/Kconfig +0 -1
@@ -65,7 +65,6 @@ config SPARC64 select HAVE_KRETPROBES select HAVE_KPROBES select HAVE_RCU_TABLE_FREE if SMP - select HAVE_RCU_TABLE_NO_INVALIDATE if HAVE_RCU_TABLE_FREE select HAVE_MEMBLOCK_NODE_MAP select HAVE_ARCH_TRANSPARENT_HUGEPAGE select HAVE_DYNAMIC_FTRACE
arch/sparc/include/asm/tlb_64.h +9 -0
@@ -28,6 +28,15 @@ void flush_tlb_pending(void);#define __tlb_remove_tlb_entry (tlb, ptep, address) do { } while (0)#define tlb_flush (tlb) flush_tlb_pending() +/* +* SPARC64's hardware TLB fill does not use the Linux page-tables +* and therefore we don't need a TLBI when freeing page-table pages. +*/ + +#ifdef CONFIG_HAVE_RCU_TABLE_FREE +#define tlb_needs_table_invalidate () (false) +#endif +#include <asm-generic/tlb.h> #endif /* _SPARC64_TLB_H */
include/asm-generic/tlb.h +15 -7
@@ -137,13 +137,6 @@* When used, an architecture is expected to provide __tlb_remove_table() * which does the actual freeing of these pages. * -* HAVE_RCU_TABLE_NO_INVALIDATE -* -* This makes HAVE_RCU_TABLE_FREE avoid calling tlb_flush_mmu_tlbonly() before -* freeing the page-table pages. This can be avoided if you use -* HAVE_RCU_TABLE_FREE and your architecture does _NOT_ use the Linux -* page-tables natively. -* * MMU_GATHER_NO_RANGE * * Use this if your architecture lacks an efficient flush_tlb_range().
@@ -189,8 +182,23 @@ struct mmu_table_batch {extern void tlb_remove_table (struct mmu_gather *tlb,void *table); +/* +* This allows an architecture that does not use the linux page-tables for +* hardware to skip the TLBI when freeing page tables. +*/ +#ifndef tlb_needs_table_invalidate +#define tlb_needs_table_invalidate () (true)#endif +#else + +#ifdef tlb_needs_table_invalidate +#error tlb_needs_table_invalidate() requires HAVE_RCU_TABLE_FREE +#endif + +#endif /* CONFIG_HAVE_RCU_TABLE_FREE */ + +#ifndef CONFIG_HAVE_MMU_GATHER_NO_GATHER /* * If we can't allocate a page to make a big batch of page pointers
mm/mmu_gather.c +8 -8
@@ -102,14 +102,14 @@ bool __tlb_remove_page_size(struct mmu_g*/ static inline void tlb_table_invalidate (struct mmu_gather *tlb) { -#ifndef CONFIG_HAVE_RCU_TABLE_NO_INVALIDATE -/* -* Invalidate page-table caches used by hardware walkers. Then we still -* need to RCU-sched wait while freeing the pages because software -* walkers can still be in-flight. -*/ -tlb_flush_mmu_tlbonly (tlb); -#endif +if (tlb_needs_table_invalidate ()) { +/* +* Invalidate page-table caches used by hardware walkers. Then +* we still need to RCU-sched wait while freeing the pages +* because software walkers can still be in-flight. +*/ +tlb_flush_mmu_tlbonly (tlb); + } }static void tlb_remove_table_smp_sync (void *arg)
Greg Kroah-Hartman
maintainerPATCH 212/309 KVM: PPC: Book3S PR: Free shared page if mmu initialization fails
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit cb10bf9194f4d2c5d830eddca861f7ca0fecdbb4 upstream.
Explicitly free the shared page if kvmppc_mmu_init() fails during kvmppc_core_vcpu_create(), as the page is freed only in kvmppc_core_vcpu_free(), which is not reached via kvm_vcpu_uninit().
--- arch/powerpc/kvm/book3s_pr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/powerpc/kvm/book3s_pr.c +3 -1
@@ -1769,10 +1769,12 @@ static struct kvm_vcpu *kvmppc_core_vcpu err =kvmppc_mmu_init (vcpu);if (err <0 ) - goto uninit_vcpu; + goto free_shared_page;return vcpu; +free_shared_page: +free_page ((unsigned long )vcpu->arch.shared); uninit_vcpu:kvm_vcpu_uninit (vcpu); free_shadow_vcpu:
Re: [PATCH 5.4 261/309] regulator: core: Add regulator_is_equal() helper
In reply to Greg Kroah-Hartmaninclude/linux/regulator/consumer.h regulator_bulk_set_supply_names(struct r · line 599
Quoted 2 lines · Greg Kroah-Hartman
include/linux/regulator/consumer.h +2
-0+static inline bool +regulator_is_equal (struct regulator *reg1,struct regulator *reg2);
This causes build error. There is a fix for this in:
commit 0468e667a5bead9c1b7ded92861b5a98d8d78745
Author: Stephen Rothwell <[email protected]> Date: Wed Jan 15 12:02:58 2020 +1100
regulator fix for "regulator: core: Add regulator_is_equal() helper"
Greg Kroah-Hartman
maintainerPATCH 199/309 KVM: x86: Refactor prefix decoding to prevent Spectre-v1/L1TF attacks
In reply to Greg Kroah-HartmanFrom: Marios Pomonis <[email protected]>
commit 125ffc5e0a56a3eded608dc51e09d5ebf72cf652 upstream.
This fixes Spectre-v1/L1TF vulnerabilities in vmx_read_guest_seg_selector(), vmx_read_guest_seg_base(), vmx_read_guest_seg_limit() and vmx_read_guest_seg_ar(). When invoked from emulation, these functions contain index computations based on the (attacker-influenced) segment value. Using constants prevents the attack.
--- arch/x86/kvm/emulate.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
arch/x86/kvm/emulate.c +14 -2
@@ -5212,16 +5212,28 @@ int x86_decode_insn(struct x86_emulate_c ctxt->ad_bytes = def_ad_bytes ^6 ;break ;case 0x26 :/* ES override */ + has_seg_override = true; + ctxt->seg_override =VCPU_SREG_ES ; +break ;case 0x2e :/* CS override */ + has_seg_override = true; + ctxt->seg_override =VCPU_SREG_CS ; +break ;case 0x36 :/* SS override */ + has_seg_override = true; + ctxt->seg_override =VCPU_SREG_SS ; +break ;case 0x3e :/* DS override */ has_seg_override = true; - ctxt->seg_override = (ctxt->b >>3 ) &3 ; + ctxt->seg_override =VCPU_SREG_DS ;break ;case 0x64 :/* FS override */ + has_seg_override = true; + ctxt->seg_override =VCPU_SREG_FS ; +break ;case 0x65 :/* GS override */ has_seg_override = true; - ctxt->seg_override = ctxt->b &7 ; + ctxt->seg_override =VCPU_SREG_GS ;break ; case 0x40 ... 0x4f: /* REX */if (mode !=X86EMUL_MODE_PROT64 )
Greg Kroah-Hartman
maintainerPATCH 193/309 xen/balloon: Support xend-based toolstack take two
In reply to Greg Kroah-HartmanFrom: Juergen Gross <[email protected]>
commit eda4eabf86fd6806eaabc23fb90dd056fdac037b upstream.
Commit 3aa6c19d2f38be ("xen/balloon: Support xend-based toolstack") tried to fix a regression with running on rather ancient Xen versions. Unfortunately the fix was based on the assumption that xend would just use another Xenstore node, but in reality only some downstream versions of xend are doing that. The upstream xend does not write that Xenstore node at all, so the problem must be fixed in another way.
The easiest way to achieve that is to fall back to the behavior before commit 96edd61dcf4436 ("xen/balloon: don't online new memory initially") in case the static memory maximum can't be read.
This is achieved by setting static_max to the current number of memory pages known by the system resulting in target_diff becoming zero.
--- drivers/xen/xen-balloon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/xen/xen-balloon.c +1 -1
@@ -94,7 +94,7 @@ static void watch_target(struct xenbus_w "%llu", &static_max) == 1)) static_max >>=PAGE_SHIFT -10 ; else - static_max = new_target; + static_max = balloon_stats.current_pages; target_diff = (xen_pv_domain () ||xen_initial_domain ()) ?0 : static_max - balloon_stats.target_pages;
Greg Kroah-Hartman
maintainerPATCH 184/309 gfs2: move setting current->backing_dev_info
In reply to Greg Kroah-HartmanFrom: Christoph Hellwig <[email protected]>
commit 4c0e8dda608a51855225c611b5c6b442f95fbc56 upstream.
Set current->backing_dev_info just around the buffered write calls to prepare for the next fix.
--- fs/gfs2/file.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)
fs/gfs2/file.c +10 -11
@@ -853,18 +853,15 @@ static ssize_t gfs2_file_write_iter(struinode_lock (inode); ret =generic_write_checks (iocb, from);if (ret <=0 ) - goto out; - -/* We can write back this queue in page reclaim */ - current->backing_dev_info =inode_to_bdi (inode); + goto out_unlock; ret =file_remove_privs (file);if (ret) - goto out2; + goto out_unlock; ret =file_update_time (file);if (ret) - goto out2; + goto out_unlock;if (iocb->ki_flags &IOCB_DIRECT ) {struct address_space *mapping = file->f_mapping;
@@ -873,11 +870,13 @@ static ssize_t gfs2_file_write_iter(stru written =gfs2_file_direct_write (iocb, from);if (written <0 || !iov_iter_count (from)) - goto out2; + goto out_unlock; + current->backing_dev_info =inode_to_bdi (inode); ret =iomap_file_buffered_write (iocb, from, &gfs2_iomap_ops); + current->backing_dev_info =NULL ;if (unlikely (ret <0 )) - goto out2; + goto out_unlock; buffered = ret;/*
@@ -901,14 +900,14 @@ static ssize_t gfs2_file_write_iter(stru*/ } }else { + current->backing_dev_info =inode_to_bdi (inode); ret =iomap_file_buffered_write (iocb, from, &gfs2_iomap_ops); + current->backing_dev_info =NULL ;if (likely (ret >0 )) iocb->ki_pos += ret; } -out2: - current->backing_dev_info =NULL ; -out: +out_unlock:inode_unlock (inode);if (likely (ret >0 )) {/* Handle various SYNC-type writes */
Greg Kroah-Hartman
maintainerPATCH 166/309 NFS: Directory page cache pages need to be locked when read
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
commit 114de38225d9b300f027e2aec9afbb6e0def154b upstream.
When a NFS directory page cache page is removed from the page cache, its contents are freed through a call to nfs_readdir_clear_array(). To prevent the removal of the page cache entry until after we've finished reading it, we must take the page lock.
--- fs/nfs/dir.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-)
fs/nfs/dir.c +19 -11
@@ -702,8 +702,6 @@ int nfs_readdir_filler(void *data, strucstatic void cache_page_release (nfs_readdir_descriptor_t *desc) { -if (!desc->page->mapping) -nfs_readdir_clear_array (desc->page);put_page (desc->page); desc->page =NULL ; }
@@ -717,19 +715,28 @@ struct page *get_cache_page(nfs_readdir_/* * Returns 0 if desc->dir_cookie was found on page desc->page_index +* and locks the page to prevent removal from the page cache. */ static -int find_cache_page (nfs_readdir_descriptor_t *desc) +int find_and_lock_cache_page (nfs_readdir_descriptor_t *desc) {int res; desc->page =get_cache_page (desc);if (IS_ERR (desc->page))return PTR_ERR (desc->page); - - res =nfs_readdir_search_array (desc); + res =lock_page_killable (desc->page);if (res !=0 ) -cache_page_release (desc); + goto error; + res = -EAGAIN ; +if (desc->page->mapping !=NULL ) { + res =nfs_readdir_search_array (desc); +if (res ==0 ) +return 0 ; + } +unlock_page (desc->page); +error: +cache_page_release (desc);return res; }
@@ -744,7 +751,7 @@ int readdir_search_pagecache(nfs_readdir desc->last_cookie =0 ; }do { - res =find_cache_page (desc); + res =find_and_lock_cache_page (desc); }while (res == -EAGAIN );return res; }
@@ -783,7 +790,6 @@ int nfs_do_filldir(nfs_readdir_descripto desc->eof = true;kunmap (desc->page); -cache_page_release (desc);dfprintk (DIRCACHE ,"NFS: nfs_do_filldir() filling ended @ cookie %Lu; returning = %d\n" , (unsigned long long )*desc->dir_cookie, res);return res;
@@ -829,13 +835,13 @@ int uncached_readdir(nfs_readdir_descrip status =nfs_do_filldir (desc); + out_release: +nfs_readdir_clear_array (desc->page); +cache_page_release (desc); out:dfprintk (DIRCACHE ,"NFS: %s: returns %d\n" , __func__, status);return status; - out_release: -cache_page_release (desc); - goto out; }/* The file offset position represents the dirent entry number. A
@@ -900,6 +906,8 @@ static int nfs_readdir(struct file *filebreak ; res =nfs_do_filldir (desc); +unlock_page (desc->page); +cache_page_release (desc);if (res <0 )break ; }while (!desc->eof);
Greg Kroah-Hartman
maintainerPATCH 162/309 crypto: picoxcell - adjust the position of tasklet_init and fix missed tasklet_kill
In reply to Greg Kroah-HartmanFrom: Chuhong Yuan <[email protected]>
commit 7f8c36fe9be46862c4f3c5302f769378028a34fa upstream.
Since tasklet is needed to be initialized before registering IRQ handler, adjust the position of tasklet_init to fix the wrong order.
Besides, to fix the missed tasklet_kill, this patch adds a helper function and uses devm_add_action to kill the tasklet automatically.
--- drivers/crypto/picoxcell_crypto.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/crypto/picoxcell_crypto.c +13 -2
@@ -1613,6 +1613,11 @@ static const struct of_device_id spacc_oMODULE_DEVICE_TABLE (of, spacc_of_id_table);#endif /* CONFIG_OF */ +static void spacc_tasklet_kill (void *data) +{ +tasklet_kill (data); +} +static int spacc_probe (struct platform_device *pdev) {int i, err, ret;
@@ -1655,6 +1660,14 @@ static int spacc_probe(struct platform_dreturn -ENXIO ; } +tasklet_init (&engine->complete, spacc_spacc_complete, + (unsigned long )engine); + + ret =devm_add_action (&pdev->dev, spacc_tasklet_kill, + &engine->complete); +if (ret) +return ret; +if (devm_request_irq (&pdev->dev, irq->start, spacc_spacc_irq,0 , engine->name, engine)) {dev_err (engine->dev,"failed to request IRQ\n" );
@@ -1712,8 +1725,6 @@ static int spacc_probe(struct platform_dINIT_LIST_HEAD (&engine->completed);INIT_LIST_HEAD (&engine->in_progress); engine->in_flight =0 ; -tasklet_init (&engine->complete, spacc_spacc_complete, - (unsigned long )engine);platform_set_drvdata (pdev, engine);
Greg Kroah-Hartman
maintainerPATCH 161/309 crypto: api - Fix race condition in crypto_spawn_alg
In reply to Greg Kroah-HartmanFrom: Herbert Xu <[email protected]>
commit 73669cc556462f4e50376538d77ee312142e8a8a upstream.
The function crypto_spawn_alg is racy because it drops the lock before shooting the dying algorithm. The algorithm could disappear altogether before we shoot it.
This patch fixes it by moving the shooting into the locked section.
--- crypto/algapi.c | 16 +++++----------- crypto/api.c | 3 +-- crypto/internal.h | 1 - 3 files changed, 6 insertions(+), 14 deletions(-)
crypto/algapi.c +5 -11
@@ -697,22 +697,16 @@ EXPORT_SYMBOL_GPL(crypto_drop_spawn);static struct crypto_alg *crypto_spawn_alg (struct crypto_spawn *spawn) {struct crypto_alg *alg; -struct crypto_alg *alg2;down_read (&crypto_alg_sem); alg = spawn->alg; - alg2 = alg; -if (alg2) - alg2 =crypto_mod_get (alg2); -up_read (&crypto_alg_sem); - -if (!alg2) { -if (alg) -crypto_shoot_alg (alg); -return ERR_PTR (-EAGAIN ); +if (alg && !crypto_mod_get (alg)) { + alg->cra_flags |=CRYPTO_ALG_DYING ; + alg =NULL ; } +up_read (&crypto_alg_sem); -return alg; +return alg ?:ERR_PTR (-EAGAIN ); } struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type,
crypto/api.c +1 -2
@@ -346,13 +346,12 @@ static unsigned int crypto_ctxsize(strucreturn len; } -void crypto_shoot_alg (struct crypto_alg *alg) +static void crypto_shoot_alg (struct crypto_alg *alg) {down_write (&crypto_alg_sem); alg->cra_flags |=CRYPTO_ALG_DYING ;up_write (&crypto_alg_sem); } -EXPORT_SYMBOL_GPL (crypto_shoot_alg);struct crypto_tfm *__crypto_alloc_tfm (struct crypto_alg *alg,u32 type,u32 mask)
crypto/internal.h +0 -1
@@ -68,7 +68,6 @@ void crypto_alg_tested(const char *name,void crypto_remove_spawns (struct crypto_alg *alg,struct list_head *list,struct crypto_alg *nalg);void crypto_remove_final (struct list_head *list); -void crypto_shoot_alg (struct crypto_alg *alg);struct crypto_tfm *__crypto_alloc_tfm (struct crypto_alg *alg,u32 type,u32 mask); void *crypto_create_tfm(struct crypto_alg *alg,
Greg Kroah-Hartman
maintainerPATCH 144/309 riscv, bpf: Fix broken BPF tail calls
In reply to Greg Kroah-HartmanFrom: Björn Töpel <[email protected]>
commit f1003b787c00fbaa4b11619c6b23a885bfce8f07 upstream.
The BPF JIT incorrectly clobbered the a0 register, and did not flag usage of s5 register when BPF stack was being used.
--- arch/riscv/net/bpf_jit_comp.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
arch/riscv/net/bpf_jit_comp.c +11 -2
@@ -120,6 +120,11 @@ static bool seen_reg(int reg, struct rv_return false; } +static void mark_fp (struct rv_jit_context *ctx) +{ +__set_bit (RV_CTX_F_SEEN_S5 , &ctx->flags); +} +static void mark_call (struct rv_jit_context *ctx) {__set_bit (RV_CTX_F_SEEN_CALL , &ctx->flags);
@@ -596,7 +601,8 @@ static void __build_epilogue(u8 reg, stremit (rv_addi (RV_REG_SP ,RV_REG_SP , stack_adjust), ctx);/* Set return value. */ -emit (rv_addi (RV_REG_A0 ,RV_REG_A5 ,0 ), ctx); +if (reg ==RV_REG_RA ) +emit (rv_addi (RV_REG_A0 ,RV_REG_A5 ,0 ), ctx);emit (rv_jalr (RV_REG_ZERO , reg,0 ), ctx); }
@@ -1426,6 +1432,10 @@ static void build_prologue(struct rv_jit {int stack_adjust =0 , store_offset, bpf_stack_adjust; + bpf_stack_adjust =round_up (ctx->prog->aux->stack_depth,16 ); +if (bpf_stack_adjust) +mark_fp (ctx); +if (seen_reg (RV_REG_RA , ctx)) stack_adjust +=8 ; stack_adjust +=8 ;/* RV_REG_FP */
@@ -1443,7 +1453,6 @@ static void build_prologue(struct rv_jit stack_adjust +=8 ; stack_adjust =round_up (stack_adjust,16 ); - bpf_stack_adjust =round_up (ctx->prog->aux->stack_depth,16 ); stack_adjust += bpf_stack_adjust; store_offset = stack_adjust -8 ;
Greg Kroah-Hartman
maintainerPATCH 143/309 btrfs: Handle another split brain scenario with metadata uuid feature
In reply to Greg Kroah-HartmanFrom: Nikolay Borisov <[email protected]>
commit 05840710149c7d1a78ea85a2db5723f706e97d8f upstream.
There is one more cases which isn't handled by the original metadata uuid work. Namely, when a filesystem has METADATA_UUID incompat bit and the user decides to change the FSID to the original one e.g. have metadata_uuid and fsid match. In case of power failure while this operation is in progress we could end up in a situation where some of the disks have the incompat bit removed and the other half have both METADATA_UUID_INCOMPAT and FSID_CHANGING_IN_PROGRESS flags.
This patch handles the case where a disk that has successfully changed its FSID such that it equals METADATA_UUID is scanned first. Subsequently when a disk with both METADATA_UUID_INCOMPAT/FSID_CHANGING_IN_PROGRESS flags is scanned find_fsid_changed won't be able to find an appropriate btrfs_fs_devices. This is done by extending find_fsid_changed to correctly find btrfs_fs_devices whose metadata_uuid/fsid are the same and they match the metadata_uuid of the currently scanned device.
--- fs/btrfs/volumes.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
fs/btrfs/volumes.c +14 -3
@@ -881,17 +881,28 @@ static struct btrfs_fs_devices *find_fsi/* * Handles the case where scanned device is part of an fs that had * multiple successful changes of FSID but curently device didn't -* observe it. Meaning our fsid will be different than theirs. +* observe it. Meaning our fsid will be different than theirs. We need +* to handle two subcases : +* 1 - The fs still continues to have different METADATA/FSID uuids. +* 2 - The fs is switched back to its original FSID (METADATA/FSID +* are equal). */ list_for_each_entry (fs_devices, &fs_uuids, fs_list) { +/* Changed UUIDs */ if (memcmp (fs_devices->metadata_uuid, fs_devices->fsid,BTRFS_FSID_SIZE ) !=0 &&memcmp (fs_devices->metadata_uuid, disk_super->metadata_uuid,BTRFS_FSID_SIZE ) ==0 &&memcmp (fs_devices->fsid, disk_super->fsid, -BTRFS_FSID_SIZE ) !=0 ) { +BTRFS_FSID_SIZE ) !=0 ) +return fs_devices; + +/* Unchanged UUIDs */ +if (memcmp (fs_devices->metadata_uuid, fs_devices->fsid, +BTRFS_FSID_SIZE ) ==0 && +memcmp (fs_devices->fsid, disk_super->metadata_uuid, +BTRFS_FSID_SIZE ) ==0 )return fs_devices; - } }return NULL ;
Greg Kroah-Hartman
maintainerPATCH 92/309 ubifs: dont trigger assertion on invalid no-key filename
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit f0d07a98a070bb5e443df19c3aa55693cbca9341 upstream.
If userspace provides an invalid fscrypt no-key filename which encodes a hash value with any of the UBIFS node type bits set (i.e. the high 3 bits), gracefully report ENOENT rather than triggering ubifs_assert().
Test case with kvm-xfstests shell:
. fs/ubifs/config
. ~/xfstests/common/encrypt dev=$(__blkdev_to_ubi_volume /dev/vdc) ubiupdatevol $dev -t
mount $dev /mnt -t ubifs
mkdir /mnt/edir
xfs_io -c set_encpolicy /mnt/edir
rm /mnt/edir/_,,,,,DAAAAAAAAAAAAAAAAAAAAAAAAAA
With the bug, the following assertion fails on the 'rm' command:
[ 19.066048] UBIFS error (ubi0:0 pid 379): ubifs_assert_failed: UBIFS assert failed: !(hash & ~UBIFS_S_KEY_HASH_MASK), in fs/ubifs/key.h:170
--- fs/ubifs/dir.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ubifs/dir.c +2 -0
@@ -228,6 +228,8 @@ static struct dentry *ubifs_lookup(strucif (nm.hash) {ubifs_assert (c,fname_len (&nm) ==0 );ubifs_assert (c,fname_name (&nm) ==NULL ); +if (nm.hash & ~UBIFS_S_KEY_HASH_MASK ) + goto done;/* ENOENT */ dent_key_init_hash (c, &key, dir->i_ino, nm.hash); err =ubifs_tnc_lookup_dh (c, &key, dent, nm.minor_hash); }else {
Greg Kroah-Hartman
maintainerPATCH 127/309 dm zoned: support zone sizes smaller than 128MiB
In reply to Greg Kroah-HartmanFrom: Dmitry Fomichev <[email protected]>
commit b39962950339912978484cdac50069258545d753 upstream.
dm-zoned is observed to log failed kernel assertions and not work correctly when operating against a device with a zone size smaller than 128MiB (e.g. 32768 bits per 4K block). The reason is that the bitmap size per zone is calculated as zero with such a small zone size. Fix this problem and also make the code related to zone bitmap management be able to handle per zone bitmaps smaller than a single block.
A dm-zoned-tools patch is required to properly format dm-zoned devices with zone sizes smaller than 128MiB.
--- drivers/md/dm-zoned-metadata.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
drivers/md/dm-zoned-metadata.c +14 -9
@@ -134,6 +134,7 @@ struct dmz_metadata {sector_t zone_bitmap_size;unsigned int zone_nr_bitmap_blocks; +unsigned int zone_bits_per_mblk;unsigned int nr_bitmap_blocks;unsigned int nr_map_blocks;
@@ -1167,7 +1168,10 @@ static int dmz_init_zones(struct dmz_met/* Init */ zmd->zone_bitmap_size = dev->zone_nr_blocks >>3 ; - zmd->zone_nr_bitmap_blocks = zmd->zone_bitmap_size >>DMZ_BLOCK_SHIFT ; + zmd->zone_nr_bitmap_blocks = +max_t (sector_t,1 , zmd->zone_bitmap_size >>DMZ_BLOCK_SHIFT ); + zmd->zone_bits_per_mblk =min_t (sector_t, dev->zone_nr_blocks, +DMZ_BLOCK_SIZE_BITS );/* Allocate zone array */ zmd->zones =kcalloc (dev->nr_zones,sizeof (struct dm_zone ),GFP_KERNEL );
@@ -1991,7 +1995,7 @@ int dmz_copy_valid_blocks(struct dmz_metdmz_release_mblock (zmd, to_mblk);dmz_release_mblock (zmd, from_mblk); - chunk_block +=DMZ_BLOCK_SIZE_BITS ; + chunk_block += zmd->zone_bits_per_mblk; } to_zone->weight = from_zone->weight;
@@ -2052,7 +2056,7 @@ int dmz_validate_blocks(struct dmz_metad/* Set bits */ bit = chunk_block &DMZ_BLOCK_MASK_BITS ; - nr_bits =min (nr_blocks,DMZ_BLOCK_SIZE_BITS - bit); + nr_bits =min (nr_blocks, zmd->zone_bits_per_mblk - bit); count =dmz_set_bits ((unsigned long *)mblk->data, bit, nr_bits);if (count) {
@@ -2131,7 +2135,7 @@ int dmz_invalidate_blocks(struct dmz_met/* Clear bits */ bit = chunk_block &DMZ_BLOCK_MASK_BITS ; - nr_bits =min (nr_blocks,DMZ_BLOCK_SIZE_BITS - bit); + nr_bits =min (nr_blocks, zmd->zone_bits_per_mblk - bit); count =dmz_clear_bits ((unsigned long *)mblk->data, bit, nr_bits);
@@ -2191,6 +2195,7 @@ static int dmz_to_next_set_block(struct {struct dmz_mblock *mblk;unsigned int bit, set_bit, nr_bits; +unsigned int zone_bits = zmd->zone_bits_per_mblk;unsigned long *bitmap;int n =0 ;
@@ -2205,15 +2210,15 @@ static int dmz_to_next_set_block(struct/* Get offset */ bitmap = (unsigned long *) mblk->data; bit = chunk_block &DMZ_BLOCK_MASK_BITS ; - nr_bits =min (nr_blocks,DMZ_BLOCK_SIZE_BITS - bit); + nr_bits =min (nr_blocks, zone_bits - bit);if (set) - set_bit =find_next_bit (bitmap,DMZ_BLOCK_SIZE_BITS , bit); + set_bit =find_next_bit (bitmap, zone_bits, bit);else - set_bit =find_next_zero_bit (bitmap,DMZ_BLOCK_SIZE_BITS , bit); + set_bit =find_next_zero_bit (bitmap, zone_bits, bit);dmz_release_mblock (zmd, mblk); n += set_bit - bit; -if (set_bit <DMZ_BLOCK_SIZE_BITS ) +if (set_bit < zone_bits)break ; nr_blocks -= nr_bits;
@@ -2316,7 +2321,7 @@ static void dmz_get_zone_weight(struct d/* Count bits in this block */ bitmap = mblk->data; bit = chunk_block &DMZ_BLOCK_MASK_BITS ; - nr_bits =min (nr_blocks,DMZ_BLOCK_SIZE_BITS - bit); + nr_bits =min (nr_blocks, zmd->zone_bits_per_mblk - bit); n +=dmz_count_bits (bitmap, bit, nr_bits);dmz_release_mblock (zmd, mblk);
Greg Kroah-Hartman
maintainerPATCH 308/309 regulator fix for "regulator: core: Add regulator_is_equal() helper"
In reply to Greg Kroah-HartmanFrom: Stephen Rothwell <[email protected]>
[ Upstream commit 0468e667a5bead9c1b7ded92861b5a98d8d78745 ]
--- include/linux/regulator/consumer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/regulator/consumer.h +1 -1
@@ -596,7 +596,7 @@ regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers, }static inline bool -regulator_is_equal (struct regulator *reg1,struct regulator *reg2); +regulator_is_equal (struct regulator *reg1,struct regulator *reg2) {return false; }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 263/309 bonding/alb: properly access headers in bond_alb_xmit()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 38f88c45404293bbc027b956def6c10cbd45c616 ]
syzbot managed to send an IPX packet through bond_alb_xmit() and af_packet and triggered a use-after-free.
First, bond_alb_xmit() was using ipx_hdr() helper to reach the IPX header, but ipx_hdr() was using the transport offset instead of the network offset. In the particular syzbot report transport offset was 0xFFFF
This patch removes ipx_hdr() since it was only (mis)used from bonding.
Then we need to make sure IPv4/IPv6/IPX headers are pulled in skb->head before dereferencing anything.
BUG: KASAN: use-after-free in bond_alb_xmit+0x153a/0x1590 drivers/net/bonding/bond_alb.c:1452 Read of size 2 at addr ffff8801ce56dfff by task syz-executor.2/18108 (if (ipx_hdr(skb)->ipx_checksum != IPX_NO_CHECKSUM) ...) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: [<ffffffff8441fc42>] __dump_stack lib/dump_stack.c:17 [inline] [<ffffffff8441fc42>] dump_stack+0x14d/0x20b lib/dump_stack.c:53 [<ffffffff81a7dec4>] print_address_description+0x6f/0x20b mm/kasan/report.c:282 [<ffffffff81a7e0ec>] kasan_report_error mm/kasan/report.c:380 [inline] [<ffffffff81a7e0ec>] kasan_report mm/kasan/report.c:438 [inline] [<ffffffff81a7e0ec>] kasan_report.cold+0x8c/0x2a0 mm/kasan/report.c:422 [<ffffffff81a7dc4f>] __asan_report_load_n_noabort+0xf/0x20 mm/kasan/report.c:469 [<ffffffff82c8c00a>] bond_alb_xmit+0x153a/0x1590 drivers/net/bonding/bond_alb.c:1452 [<ffffffff82c60c74>] __bond_start_xmit drivers/net/bonding/bond_main.c:4199 [inline] [<ffffffff82c60c74>] bond_start_xmit+0x4f4/0x1570 drivers/net/bonding/bond_main.c:4224 [<ffffffff83baa558>] __netdev_start_xmit include/linux/netdevice.h:4525 [inline] [<ffffffff83baa558>] netdev_start_xmit include/linux/netdevice.h:4539 [inline] [<ffffffff83baa558>] xmit_one net/core/dev.c:3611 [inline] [<ffffffff83baa558>] dev_hard_start_xmit+0x168/0x910 net/core/dev.c:3627 [<ffffffff83bacf35>] __dev_queue_xmit+0x1f55/0x33b0 net/core/dev.c:4238 [<ffffffff83bae3a8>] dev_queue_xmit+0x18/0x20 net/core/dev.c:4278 [<ffffffff84339189>] packet_snd net/packet/af_packet.c:3226 [inline] [<ffffffff84339189>] packet_sendmsg+0x4919/0x70b0 net/packet/af_packet.c:3252 [<ffffffff83b1ac0c>] sock_sendmsg_nosec net/socket.c:673 [inline] [<ffffffff83b1ac0c>] sock_sendmsg+0x12c/0x160 net/socket.c:684 [<ffffffff83b1f5a2>] __sys_sendto+0x262/0x380 net/socket.c:1996 [<ffffffff83b1f700>] SYSC_sendto net/socket.c:2008 [inline] [<ffffffff83b1f700>] SyS_sendto+0x40/0x60 net/socket.c:2004
--- drivers/net/bonding/bond_alb.c | 44 +++++++++++++++++++++++++++++------------ include/net/ipx.h | 5 ---- 2 files changed, 32 insertions(+), 17 deletions(-)
drivers/net/bonding/bond_alb.c +32 -12
@@ -1383,26 +1383,31 @@ netdev_tx_t bond_alb_xmit(struct sk_buffbool do_tx_balance = true;u32 hash_index =0 ;const u8 *hash_start =NULL ; -struct ipv6hdr *ip6hdr;skb_reset_mac_header (skb); eth_data =eth_hdr (skb);switch (ntohs (skb->protocol)) {case ETH_P_IP : { -const struct iphdr *iph =ip_hdr (skb); +const struct iphdr *iph;if (is_broadcast_ether_addr (eth_data->h_dest) || - iph->daddr == ip_bcast || - iph->protocol ==IPPROTO_IGMP ) { + !pskb_network_may_pull (skb,sizeof (*iph))) { + do_tx_balance = false; +break ; + } + iph =ip_hdr (skb); +if (iph->daddr == ip_bcast || iph->protocol ==IPPROTO_IGMP ) { do_tx_balance = false;break ; } hash_start = (char *)&(iph->daddr); hash_size =sizeof (iph->daddr); - }break ; -case ETH_P_IPV6 : + } +case ETH_P_IPV6 : { +const struct ipv6hdr *ip6hdr; +/* IPv6 doesn't really use broadcast mac address, but leave * that here just in case. */
@@ -1419,7 +1424,11 @@ netdev_tx_t bond_alb_xmit(struct sk_buffbreak ; } -/* Additianally, DAD probes should not be tx-balanced as that +if (!pskb_network_may_pull (skb,sizeof (*ip6hdr))) { + do_tx_balance = false; +break ; + } +/* Additionally, DAD probes should not be tx-balanced as that * will lead to false positives for duplicate addresses and * prevent address configuration from working. */
@@ -1429,17 +1438,26 @@ netdev_tx_t bond_alb_xmit(struct sk_buffbreak ; } - hash_start = (char *)&(ipv6_hdr (skb)->daddr); - hash_size =sizeof (ipv6_hdr (skb)->daddr); + hash_start = (char *)&ip6hdr->daddr; + hash_size =sizeof (ip6hdr->daddr);break ; -case ETH_P_IPX : -if (ipx_hdr (skb)->ipx_checksum !=IPX_NO_CHECKSUM ) { + } +case ETH_P_IPX : { +const struct ipxhdr *ipxhdr; + +if (pskb_network_may_pull (skb,sizeof (*ipxhdr))) { + do_tx_balance = false; +break ; + } + ipxhdr = (struct ipxhdr *)skb_network_header (skb); + +if (ipxhdr->ipx_checksum !=IPX_NO_CHECKSUM ) {/* something is wrong with this packet */ do_tx_balance = false;break ; } -if (ipx_hdr (skb)->ipx_type !=IPX_TYPE_NCP ) { +if (ipxhdr->ipx_type !=IPX_TYPE_NCP ) {/* The only protocol worth balancing in * this family since it has an "ARP" like * mechanism
@@ -1448,9 +1466,11 @@ netdev_tx_t bond_alb_xmit(struct sk_buffbreak ; } + eth_data =eth_hdr (skb); hash_start = (char *)eth_data->h_dest; hash_size =ETH_ALEN ;break ; + }case ETH_P_ARP : do_tx_balance = false;if (bond_info->rlb_enabled)
include/net/ipx.h +0 -5
@@ -47,11 +47,6 @@ struct ipxhdr {/* From af_ipx.c */ extern int sysctl_ipx_pprop_broadcasting; -static __inline__struct ipxhdr *ipx_hdr (struct sk_buff *skb) -{ -return (struct ipxhdr *)skb_transport_header (skb); -} -struct ipx_interface {/* IPX address */ __be32 if_netnum;
Greg Kroah-Hartman
maintainerPATCH 271/309 net: stmmac: fix a possible endless loop
In reply to Greg Kroah-HartmanFrom: Dejin Zheng <[email protected]>
[ Upstream commit 7d10f0774f9e32aa2f2e012f7fcb312a2ce422b9 ]
It forgot to reduce the value of the variable retry in a while loop in the ethqos_configure() function. It may cause an endless loop and without timeout.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +1 -0
@@ -413,6 +413,7 @@ static int ethqos_configure(struct qcom_ dll_lock =rgmii_readl (ethqos,SDC4_STATUS );if (dll_lock &SDC4_STATUS_DLL_LOCK )break ; + retry--; }while (retry >0 );if (!retry) dev_err(ðqos->pdev->dev,
Greg Kroah-Hartman
maintainerPATCH 270/309 net_sched: fix a resource leak in tcindex_set_parms()
In reply to Greg Kroah-HartmanFrom: Cong Wang <[email protected]>
[ Upstream commit 52b5ae501c045010aeeb1d5ac0373ff161a88291 ]
Jakub noticed there is a potential resource leak in tcindex_set_parms(): when tcindex_filter_result_init() fails and it jumps to 'errout1' which doesn't release the memory and resources allocated by tcindex_alloc_perfect_hash().
We should just jump to 'errout_alloc' which callstcindex_free_perfect_hash().
--- net/sched/cls_tcindex.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/sched/cls_tcindex.c +1 -2
@@ -365,7 +365,7 @@ tcindex_set_parms(struct net *net, struc err =tcindex_filter_result_init (&new_filter_result, net);if (err <0 ) - goto errout1; + goto errout_alloc;if (old_r) cr = r->res;
@@ -484,7 +484,6 @@ errout_alloc:tcindex_free_perfect_hash (cp); else if (balloc == 2) kfree(cp->h); -errout1:tcf_exts_destroy (&new_filter_result.exts); errout:kfree (cp);
Greg Kroah-Hartman
maintainerPATCH 272/309 net: systemport: Avoid RBUF stuck in Wake-on-LAN mode
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
[ Upstream commit 263a425a482fc495d6d3f9a29b9103a664c38b69 ]
After a number of suspend and resume cycles, it is possible for the RBUF to be stuck in Wake-on-LAN mode, despite the MPD enable bit being cleared which instructed the RBUF to exit that mode.
Avoid creating that problematic condition by clearing the RX_EN and TX_EN bits in the UniMAC prior to disable the Magic Packet Detector logic which is guaranteed to make the RBUF exit Wake-on-LAN mode.
--- drivers/net/ethernet/broadcom/bcmsysport.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/broadcom/bcmsysport.c +3 -0
@@ -2728,6 +2728,9 @@ static int __maybe_unused bcm_sysport_reumac_reset (priv); +/* Disable the UniMAC RX/TX */ +umac_enable_set (priv,CMD_RX_EN |CMD_TX_EN ,0 ); +/* We may have been suspended and never received a WOL event that * would turn off MPD detection, take care of that now */
Greg Kroah-Hartman
maintainerPATCH 269/309 net: mvneta: move rx_dropped and rx_errors in per-cpu stats
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit c35947b8ff8acca33134ee39c31708233765c31a ]
Move rx_dropped and rx_errors counters in mvneta_pcpu_stats in order to avoid possible races updating statistics
--- drivers/net/ethernet/marvell/mvneta.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-)
drivers/net/ethernet/marvell/mvneta.c +21 -6
@@ -388,6 +388,8 @@ struct mvneta_pcpu_stats {struct u64_stats_sync syncp;u64 rx_packets;u64 rx_bytes; +u64 rx_dropped; +u64 rx_errors;u64 tx_packets;u64 tx_bytes; };
@@ -706,6 +708,8 @@ mvneta_get_stats64(struct net_device *destruct mvneta_pcpu_stats *cpu_stats;u64 rx_packets;u64 rx_bytes; +u64 rx_dropped; +u64 rx_errors;u64 tx_packets;u64 tx_bytes;
@@ -714,19 +718,20 @@ mvneta_get_stats64(struct net_device *de start =u64_stats_fetch_begin_irq (&cpu_stats->syncp); rx_packets = cpu_stats->rx_packets; rx_bytes = cpu_stats->rx_bytes; + rx_dropped = cpu_stats->rx_dropped; + rx_errors = cpu_stats->rx_errors; tx_packets = cpu_stats->tx_packets; tx_bytes = cpu_stats->tx_bytes; }while (u64_stats_fetch_retry_irq (&cpu_stats->syncp, start)); stats->rx_packets += rx_packets; stats->rx_bytes += rx_bytes; + stats->rx_dropped += rx_dropped; + stats->rx_errors += rx_errors; stats->tx_packets += tx_packets; stats->tx_bytes += tx_bytes; } - stats->rx_errors = dev->stats.rx_errors; - stats->rx_dropped = dev->stats.rx_dropped; - stats->tx_dropped = dev->stats.tx_dropped; }
@@ -1703,8 +1708,14 @@ static u32 mvneta_txq_desc_csum(int l3_ostatic void mvneta_rx_error (struct mvneta_port *pp,struct mvneta_rx_desc *rx_desc) { +struct mvneta_pcpu_stats *stats =this_cpu_ptr (pp->stats);u32 status = rx_desc->status; +/* update per-cpu counter */ +u64_stats_update_begin (&stats->syncp); + stats->rx_errors++; +u64_stats_update_end (&stats->syncp); +switch (status &MVNETA_RXD_ERR_CODE_MASK ) {case MVNETA_RXD_ERR_CRC : netdev_err(pp->dev, "bad rx status %08x (crc error), size=%d\n",
@@ -1965,7 +1976,6 @@ static int mvneta_rx_swbm(struct napi_st/* Check errors only for FIRST descriptor */ if (rx_status &MVNETA_RXD_ERR_SUMMARY ) {mvneta_rx_error (pp, rx_desc); - dev->stats.rx_errors++;/* leave the descriptor untouched */ continue ; }
@@ -1976,11 +1986,17 @@ static int mvneta_rx_swbm(struct napi_st skb_size =max (rx_copybreak, rx_header_size); rxq->skb =netdev_alloc_skb_ip_align (dev, skb_size);if (unlikely (!rxq->skb)) { +struct mvneta_pcpu_stats *stats =this_cpu_ptr (pp->stats); +netdev_err (dev,"Can't allocate skb on queue %d\n" , rxq->id); - dev->stats.rx_dropped++; + rxq->skb_alloc_err++; + +u64_stats_update_begin (&stats->syncp); + stats->rx_dropped++; +u64_stats_update_end (&stats->syncp);continue ; } copy_size =min (skb_size, rx_bytes);
@@ -2137,7 +2153,6 @@ err_drop_frame_ret_pool:mvneta_bm_pool_put_bp (pp->bm_priv, bm_pool, rx_desc->buf_phys_addr); err_drop_frame: - dev->stats.rx_errors++;mvneta_rx_error (pp, rx_desc);/* leave the descriptor untouched */ continue ;
Greg Kroah-Hartman
maintainerPATCH 307/309 rxrpc: Fix service call disconnection
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
[ Upstream commit b39a934ec72fa2b5a74123891f25273a38378b90 ]
The recent patch that substituted a flag on an rxrpc_call for the connection pointer being NULL as an indication that a call was disconnected puts the set_bit in the wrong place for service calls. This is only a problem if a call is implicitly terminated by a new call coming in on the same connection channel instead of a terminating ACK packet.
In such a case, rxrpc_input_implicit_end_call() calls __rxrpc_disconnect_call(), which is now (incorrectly) setting the disconnection bit, meaning that when rxrpc_release_call() is later called, it doesn't call rxrpc_disconnect_call() and so the call isn't removed from the peer's error distribution list and the list gets corrupted.
KASAN finds the issue as an access after release on a call, but the position at which it occurs is confusing as it appears to be related to a different call (the call site is where the latter call is being removed from the error distribution list and either the next or pprev pointer points to a previously released call).
Fix this by moving the setting of the flag from __rxrpc_disconnect_call() to rxrpc_disconnect_call() in the same place that the connection pointer was being cleared.
--- net/rxrpc/conn_object.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/rxrpc/conn_object.c +1 -2
@@ -171,8 +171,6 @@ void __rxrpc_disconnect_call(struct rxrpc_connection *conn,_enter ("%d,%x" , conn->debug_id, call->cid); -set_bit (RXRPC_CALL_DISCONNECTED , &call->flags); -if (rcu_access_pointer (chan->call) == call) {/* Save the result of the call so that we can repeat it if necessary * through the channel, whilst disposing of the actual call record.
@@ -225,6 +223,7 @@ void rxrpc_disconnect_call(struct rxrpc_call *call)__rxrpc_disconnect_call (conn, call);spin_unlock (&conn->channel_lock); +set_bit (RXRPC_CALL_DISCONNECTED , &call->flags); conn->idle_timestamp = jiffies; }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 306/309 perf/core: Fix mlock accounting in perf_mmap()
In reply to Greg Kroah-HartmanFrom: Song Liu <[email protected]>
commit 003461559ef7a9bd0239bae35a22ad8924d6e9ad upstream.
Decreasing sysctl_perf_event_mlock between two consecutive perf_mmap()s of a perf ring buffer may lead to an integer underflow in locked memory accounting. This may lead to the undesired behaviors, such as failures in BPF map creation.
Address this by adjusting the accounting logic to take into account the possibility that the amount of already locked memory may exceed the current limit.
--- kernel/events/core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
kernel/events/core.c +9 -1
@@ -5823,7 +5823,15 @@ accounting:*/ user_lock_limit *=num_online_cpus (); - user_locked =atomic_long_read (&user->locked_vm) + user_extra; + user_locked =atomic_long_read (&user->locked_vm); + +/* +* sysctl_perf_event_mlock may have changed, so that +* user->locked_vm > user_lock_limit +*/ +if (user_locked > user_lock_limit) + user_locked = user_lock_limit; + user_locked += user_extra;if (user_locked <= user_lock_limit) {/* charge all to locked_vm */
Greg Kroah-Hartman
maintainerPATCH 304/309 x86/apic/msi: Plug non-maskable MSI affinity race
In reply to Greg Kroah-HartmanFrom: Thomas Gleixner <[email protected]>
commit 6f1a4891a5928a5969c87fa5a584844c983ec823 upstream.
Evan tracked down a subtle race between the update of the MSI message and the device raising an interrupt internally on PCI devices which do not support MSI masking. The update of the MSI message is non-atomic and consists of either 2 or 3 sequential 32bit wide writes to the PCI config space.
- Write address low 32bits
- Write address high 32bits (If supported by device)
- Write data
When an interrupt is migrated then both address and data might change, so the kernel attempts to mask the MSI interrupt first. But for MSI masking is optional, so there exist devices which do not provide it. That means that if the device raises an interrupt internally between the writes then a MSI message is sent built from half updated state.
On x86 this can lead to spurious interrupts on the wrong interrupt vector when the affinity setting changes both address and data. As a consequence the device interrupt can be lost causing the device to become stuck or malfunctioning.
Evan tried to handle that by disabling MSI accross an MSI message update. That's not feasible because disabling MSI has issues on its own:
If MSI is disabled the PCI device is routing an interrupt to the legacy INTx mechanism. The INTx delivery can be disabled, but the disablement is not working on all devices.
Some devices lose interrupts when both MSI and INTx delivery are disabled.
Another way to solve this would be to enforce the allocation of the same vector on all CPUs in the system for this kind of screwed devices. That could be done, but it would bring back the vector space exhaustion problems which got solved a few years ago.
Fortunately the high address (if supported by the device) is only relevant when X2APIC is enabled which implies interrupt remapping. In the interrupt remapping case the affinity setting is happening at the interrupt remapping unit and the PCI MSI message is programmed only once when the PCI device is initialized.
That makes it possible to solve it with a two step update:
1) Target the MSI msg to the new vector on the current target CPU
2) Target the MSI msg to the new vector on the new target CPU
In both cases writing the MSI message is only changing a single 32bit word which prevents the issue of inconsistency.
After writing the final destination it is necessary to check whether the device issued an interrupt while the intermediate state #1 (new vector, current CPU) was in effect.
This is possible because the affinity change is always happening on the current target CPU. The code runs with interrupts disabled, so the interrupt can be detected by checking the IRR of the local APIC. If the vector is pending in the IRR then the interrupt is retriggered on the new target CPU by sending an IPI for the associated vector on the target CPU.
This can cause spurious interrupts on both the local and the new target CPU.
1) If the new vector is not in use on the local CPU and the device affected by the affinity change raised an interrupt during the transitional state (step #1 above) then interrupt entry code will ignore that spurious interrupt. The vector is marked so that the 'No irq handler for vector' warning is supressed once.
2) If the new vector is in use already on the local CPU then the IRR check might see an pending interrupt from the device which is using this vector. The IPI to the new target CPU will then invoke the handler of the device, which got the affinity change, even if that device did not issue an interrupt
3) If the new vector is in use already on the local CPU and the device affected by the affinity change raised an interrupt during the transitional state (step #1 above) then the handler of the device which uses that vector on the local CPU will be invoked.
expose issues in device driver interrupt handlers which are not prepared to handle a spurious interrupt correctly. This not a regression, it's just exposing something which was already broken as spurious interrupts can happen for a lot of reasons and all driver handlers need to be able to deal with them.
--- arch/x86/include/asm/apic.h | 8 ++ arch/x86/kernel/apic/msi.c | 128 ++++++++++++++++++++++++++++++++++++++++++-- include/linux/irq.h | 18 ++++++ include/linux/irqdomain.h | 7 ++ kernel/irq/debugfs.c | 1 kernel/irq/msi.c | 5 + 6 files changed, 163 insertions(+), 4 deletions(-)
arch/x86/include/asm/apic.h +8 -0
@@ -454,6 +454,14 @@ static inline void ack_APIC_irq(void)apic_eoi (); } + +static inline bool lapic_vector_set_in_irr (unsigned int vector) +{ +u32 irr =apic_read (APIC_IRR + (vector /32 *0x10 )); + +return !!(irr & (1U << (vector %32 ))); +} +static inline unsigned default_get_apic_id (unsigned long x) {unsigned int ver =GET_APIC_VERSION (apic_read (APIC_LVR ));
arch/x86/kernel/apic/msi.c +125 -3
153 lines not on this page · raw message
include/linux/irq.h +18 -0
@@ -209,6 +209,8 @@ struct irq_data {* IRQD_SINGLE_TARGET - IRQ allows only a single affinity target * IRQD_DEFAULT_TRIGGER_SET - Expected trigger already been set * IRQD_CAN_RESERVE - Can use reservation mode +* IRQD_MSI_NOMASK_QUIRK - Non-maskable MSI quirk for affinity change +* required */ enum {IRQD_TRIGGER_MASK =0xf ,
@@ -231,6 +233,7 @@ enum {IRQD_SINGLE_TARGET = (1 <<24 ),IRQD_DEFAULT_TRIGGER_SET = (1 <<25 ),IRQD_CAN_RESERVE = (1 <<26 ), + IRQD_MSI_NOMASK_QUIRK = (1 << 27), };#define __irqd_to_state (d) ACCESS_PRIVATE((d)->common, state_use_accessors)
@@ -390,6 +393,21 @@ static inline bool irqd_can_reserve(strureturn __irqd_to_state (d) &IRQD_CAN_RESERVE ; } +static inline void irqd_set_msi_nomask_quirk (struct irq_data *d) +{ +__irqd_to_state (d) |=IRQD_MSI_NOMASK_QUIRK ; +} + +static inline void irqd_clr_msi_nomask_quirk (struct irq_data *d) +{ +__irqd_to_state (d) &= ~IRQD_MSI_NOMASK_QUIRK ; +} + +static inline bool irqd_msi_nomask_quirk (struct irq_data *d) +{ +return __irqd_to_state (d) &IRQD_MSI_NOMASK_QUIRK ; +} +#undef __irqd_to_statestatic inline irq_hw_number_t irqd_to_hwirq (struct irq_data *d)
include/linux/irqdomain.h +7 -0
@@ -206,6 +206,13 @@ enum {IRQ_DOMAIN_FLAG_MSI_REMAP = (1 <<5 ),/* +* Quirk to handle MSI implementations which do not provide +* masking. Currently known to affect x86, but partially +* handled in core code. +*/ + IRQ_DOMAIN_MSI_NOMASK_QUIRK = (1 << 6), + +/* * Flags starting from IRQ_DOMAIN_FLAG_NONCORE are reserved * for implementation specific purposes and ignored by the * core code.
kernel/irq/debugfs.c +1 -0
@@ -114,6 +114,7 @@ static const struct irq_bit_descr irqdatBIT_MASK_DESCR (IRQD_AFFINITY_MANAGED ),BIT_MASK_DESCR (IRQD_MANAGED_SHUTDOWN ),BIT_MASK_DESCR (IRQD_CAN_RESERVE ), +BIT_MASK_DESCR (IRQD_MSI_NOMASK_QUIRK ), BIT_MASK_DESCR(IRQD_FORWARDED_TO_VCPU),
kernel/irq/msi.c +4 -1
@@ -453,8 +453,11 @@ int msi_domain_alloc_irqs(struct irq_domcontinue ; irq_data =irq_domain_get_irq_data (domain, desc->irq); -if (!can_reserve) +if (!can_reserve) {irqd_clr_can_reserve (irq_data); +if (domain->flags &IRQ_DOMAIN_MSI_NOMASK_QUIRK ) +irqd_set_msi_nomask_quirk (irq_data); + } ret =irq_domain_activate_irq (irq_data, can_reserve);if (ret) goto cleanup;
Greg Kroah-Hartman
maintainerPATCH 45/309 ALSA: usb-audio: Fix endianess in descriptor validation
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit f8e5f90b3a53bb75f05124ed19156388379a337d upstream.
I overlooked that some fields are words and need the converts from LE in the recently added USB descriptor validation code. This patch fixes those with the proper macro usages.
--- sound/usb/validate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/usb/validate.c +3 -3
@@ -110,7 +110,7 @@ static bool validate_processing_unit(condefault :if (v->type ==UAC1_EXTENSION_UNIT )return true;/* OK */ -switch (d->wProcessType) { +switch (le16_to_cpu (d->wProcessType)) {case UAC_PROCESS_UP_DOWNMIX :case UAC_PROCESS_DOLBY_PROLOGIC :if (d->bLength < len +1 )/* bNrModes */
@@ -125,7 +125,7 @@ static bool validate_processing_unit(concase UAC_VERSION_2 :if (v->type ==UAC2_EXTENSION_UNIT_V2 )return true;/* OK */ -switch (d->wProcessType) { +switch (le16_to_cpu (d->wProcessType)) {case UAC2_PROCESS_UP_DOWNMIX :case UAC2_PROCESS_DOLBY_PROLOCIC :/* SiC! */ if (d->bLength < len +1 )/* bNrModes */
@@ -142,7 +142,7 @@ static bool validate_processing_unit(con len +=2 ;/* wClusterDescrID */ break ; } -switch (d->wProcessType) { +switch (le16_to_cpu (d->wProcessType)) {case UAC3_PROCESS_UP_DOWNMIX :if (d->bLength < len +1 )/* bNrModes */ return false;
Greg Kroah-Hartman
maintainerPATCH 297/309 KVM: x86: Use gpa_t for cr2/gpa to fix TDP support on 32-bit KVM
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
[ Upstream commit 736c291c9f36b07f8889c61764c28edce20e715d ]
Convert a plethora of parameters and variables in the MMU and page fault flows from type gva_t to gpa_t to properly handle TDP on 32-bit KVM.
Thanks to PSE and PAE paging, 32-bit kernels can access 64-bit physical addresses. When TDP is enabled, the fault address is a guest physical address and thus can be a 64-bit value, even when both KVM and its guest are using 32-bit virtual addressing, e.g. VMX's VMCS.GUEST_PHYSICAL is a 64-bit field, not a natural width field.
Using a gva_t for the fault address means KVM will incorrectly drop the upper 32-bits of the GPA. Ditto for gva_to_gpa() when it is used to translate L2 GPAs to L1 GPAs.
Opportunistically rename variables and parameters to better reflect the dual address modes, e.g. use "cr2_or_gpa" for fault addresses and plain "addr" instead of "vaddr" when the address may be either a GVA or an L2 GPA. Similarly, use "gpa" in the nonpaging_page_fault() flows to avoid a confusing "gpa_t gva" declaration; this also sets the stage for a future patch to combing nonpaging_page_fault() and tdp_page_fault() with minimal churn.
Sprinkle in a few comments to document flows where an address is known to be a GVA and thus can be safely truncated to a 32-bit value. Add WARNs in kvm_handle_page_fault() and FNAME(gva_to_gpa_nested)() to help document such cases and detect bugs.
--- arch/x86/include/asm/kvm_host.h | 8 ++-- arch/x86/kvm/mmu.c | 69 +++++++++++++++++++-------------- arch/x86/kvm/mmutrace.h | 12 +++--- arch/x86/kvm/paging_tmpl.h | 25 +++++++----- arch/x86/kvm/x86.c | 40 +++++++++---------- arch/x86/kvm/x86.h | 2 +- include/linux/kvm_host.h | 6 +-- virt/kvm/async_pf.c | 10 ++--- 8 files changed, 94 insertions(+), 78 deletions(-)
arch/x86/include/asm/kvm_host.h +4 -4
@@ -380,12 +380,12 @@ struct kvm_mmu {void (*set_cr3)(struct kvm_vcpu *vcpu,unsigned long root);unsigned long (*get_cr3)(struct kvm_vcpu *vcpu);u64 (*get_pdptr)(struct kvm_vcpu *vcpu,int index); -int (*page_fault)(struct kvm_vcpu *vcpu,gva_t gva,u32 err, +int (*page_fault)(struct kvm_vcpu *vcpu,gpa_t cr2_or_gpa,u32 err,bool prefault);void (*inject_page_fault)(struct kvm_vcpu *vcpu,struct x86_exception *fault); -gpa_t (*gva_to_gpa)(struct kvm_vcpu *vcpu,gva_t gva,u32 access, -struct x86_exception *exception); +gpa_t (*gva_to_gpa)(struct kvm_vcpu *vcpu,gpa_t gva_or_gpa, +u32 access,struct x86_exception *exception);gpa_t (*translate_gpa)(struct kvm_vcpu *vcpu,gpa_t gpa,u32 access,struct x86_exception *exception); int (*sync_page)(struct kvm_vcpu *vcpu,
@@ -1451,7 +1451,7 @@ void kvm_vcpu_deactivate_apicv(struct kvm_vcpu *vcpu);int kvm_emulate_hypercall (struct kvm_vcpu *vcpu); -int kvm_mmu_page_fault (struct kvm_vcpu *vcpu,gva_t gva,u64 error_code, +int kvm_mmu_page_fault (struct kvm_vcpu *vcpu,gpa_t cr2_or_gpa,u64 error_code,void *insn,int insn_len);void kvm_mmu_invlpg (struct kvm_vcpu *vcpu,gva_t gva);void kvm_mmu_invpcid_gva (struct kvm_vcpu *vcpu,gva_t gva,unsigned long pcid);
arch/x86/kvm/mmu.c +40 -29
214 lines not on this page · raw message
arch/x86/kvm/mmutrace.h +6 -6
@@ -249,13 +249,13 @@ TRACE_EVENT( TRACE_EVENT( fast_page_fault, - TP_PROTO(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code, + TP_PROTO(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, u32 error_code, u64 *sptep, u64 old_spte, bool retry), - TP_ARGS(vcpu, gva, error_code, sptep, old_spte, retry), + TP_ARGS(vcpu, cr2_or_gpa, error_code, sptep, old_spte, retry), TP_STRUCT__entry( __field(int, vcpu_id) - __field(gva_t, gva) + __field(gpa_t, cr2_or_gpa) __field(u32, error_code) __field(u64 *, sptep) __field(u64, old_spte)
@@ -265,7 +265,7 @@ TRACE_EVENT(TP_fast_assign ( __entry->vcpu_id = vcpu->vcpu_id; - __entry->gva = gva; + __entry->cr2_or_gpa = cr2_or_gpa; __entry->error_code = error_code; __entry->sptep = sptep; __entry->old_spte = old_spte;
@@ -273,9 +273,9 @@ TRACE_EVENT( __entry->retry = retry; ), -TP_printk ("vcpu %d gva %lx error_code %s sptep %p old %#llx" +TP_printk ("vcpu %d gva %llx error_code %s sptep %p old %#llx" " new %llx spurious %d fixed %d" , __entry->vcpu_id, - __entry->gva,__print_flags (__entry->error_code,"|" , + __entry->cr2_or_gpa,__print_flags (__entry->error_code,"|" , kvm_mmu_trace_pferr_flags), __entry->sptep, __entry->old_spte, __entry->new_spte, __spte_satisfied(old_spte), __spte_satisfied(new_spte)
arch/x86/kvm/paging_tmpl.h +16 -9
@@ -291,11 +291,11 @@ static inline unsigned FNAME(gpte_pkeys)(struct kvm_vcpu *vcpu, u64 gpte) }/* -* Fetch a guest pte for a guest virtual address +* Fetch a guest pte for a guest virtual address, or for an L2's GPA. */ static int FNAME (walk_addr_generic )(struct guest_walker *walker,struct kvm_vcpu *vcpu,struct kvm_mmu *mmu, -gva_t addr,u32 access) +gpa_t addr,u32 access) {int ret;pt_element_t pte;
@@ -496,7 +496,7 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker, }static int FNAME (walk_addr )(struct guest_walker *walker, -struct kvm_vcpu *vcpu,gva_t addr,u32 access) +struct kvm_vcpu *vcpu,gpa_t addr,u32 access) {return FNAME (walk_addr_generic)(walker, vcpu, vcpu->arch.mmu, addr, access);
@@ -611,7 +611,7 @@ static void FNAME(pte_prefetch)(struct kvm_vcpu *vcpu, struct guest_walker *gw,* If the guest tries to write a write-protected page, we need to * emulate this operation, return 1 to indicate this case. */ -static int FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, +static int FNAME(fetch)(struct kvm_vcpu *vcpu, gpa_t addr, struct guest_walker *gw, int write_fault, int hlevel, kvm_pfn_t pfn, bool map_writable, bool prefault,
@@ -765,7 +765,7 @@ FNAME(is_self_change_mapping)(struct kvm_vcpu *vcpu,* Returns: 1 if we need to emulate the instruction, 0 otherwise, or * a negative value on error. */ -static int FNAME (page_fault )(struct kvm_vcpu *vcpu,gva_t addr,u32 error_code, +static int FNAME (page_fault )(struct kvm_vcpu *vcpu,gpa_t addr,u32 error_code,bool prefault) {int write_fault = error_code &PFERR_WRITE_MASK ;
@@ -945,18 +945,19 @@ static void FNAME(invlpg)(struct kvm_vcpu *vcpu, gva_t gva, hpa_t root_hpa)spin_unlock (&vcpu->kvm->mmu_lock); } -static gpa_t FNAME (gva_to_gpa )(struct kvm_vcpu *vcpu,gva_t vaddr,u32 access, +/* Note, @addr is a GPA when gva_to_gpa() translates an L2 GPA to an L1 GPA. */ +static gpa_t FNAME (gva_to_gpa )(struct kvm_vcpu *vcpu,gpa_t addr,u32 access,struct x86_exception *exception) {struct guest_walker walker;gpa_t gpa =UNMAPPED_GVA ;int r; - r =FNAME (walk_addr)(&walker, vcpu, vaddr, access); + r =FNAME (walk_addr)(&walker, vcpu, addr, access);if (r) { gpa =gfn_to_gpa (walker.gfn); - gpa |= vaddr & ~PAGE_MASK ; + gpa |= addr & ~PAGE_MASK ; }else if (exception) *exception = walker.fault;
@@ -964,7 +965,8 @@ static gpa_t FNAME(gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t vaddr, u32 access, }#if PTTYPE !=PTTYPE_EPT -static gpa_t FNAME (gva_to_gpa_nested )(struct kvm_vcpu *vcpu,gva_t vaddr, +/* Note, gva_to_gpa_nested() is only used to translate L2 GVAs. */ +static gpa_t FNAME (gva_to_gpa_nested )(struct kvm_vcpu *vcpu,gpa_t vaddr,u32 access,struct x86_exception *exception) {
@@ -972,6 +974,11 @@ static gpa_t FNAME(gva_to_gpa_nested)(struct kvm_vcpu *vcpu, gva_t vaddr,gpa_t gpa =UNMAPPED_GVA ;int r; +#ifndef CONFIG_X86_64 +/* A 64-bit GVA should be impossible on 32-bit KVM. */ +WARN_ON_ONCE (vaddr >>32 ); +#endif + r =FNAME (walk_addr_nested)(&walker, vcpu, vaddr, access);if (r) {
arch/x86/kvm/x86.c +19 -21
@@ -6409,11 +6409,11 @@ static int handle_emulation_failure(struct kvm_vcpu *vcpu, int emulation_type)return 1 ; } -static bool reexecute_instruction (struct kvm_vcpu *vcpu,gva_t cr2, +static bool reexecute_instruction (struct kvm_vcpu *vcpu,gpa_t cr2_or_gpa,bool write_fault_to_shadow_pgtable,int emulation_type) { -gpa_t gpa = cr2; +gpa_t gpa = cr2_or_gpa;kvm_pfn_t pfn;if (!(emulation_type &EMULTYPE_ALLOW_RETRY ))
@@ -6427,7 +6427,7 @@ static bool reexecute_instruction(struct kvm_vcpu *vcpu, gva_t cr2,* Write permission should be allowed since only * write access need to be emulated. */ - gpa =kvm_mmu_gva_to_gpa_write (vcpu, cr2,NULL ); + gpa =kvm_mmu_gva_to_gpa_write (vcpu, cr2_or_gpa,NULL );/* * If the mapping is invalid in guest, let cpu retry
@@ -6484,10 +6484,10 @@ static bool reexecute_instruction(struct kvm_vcpu *vcpu, gva_t cr2, }static bool retry_instruction (struct x86_emulate_ctxt *ctxt, -unsigned long cr2,int emulation_type) +gpa_t cr2_or_gpa,int emulation_type) {struct kvm_vcpu *vcpu =emul_to_vcpu (ctxt); -unsigned long last_retry_eip, last_retry_addr, gpa = cr2; +unsigned long last_retry_eip, last_retry_addr, gpa = cr2_or_gpa; last_retry_eip = vcpu->arch.last_retry_eip; last_retry_addr = vcpu->arch.last_retry_addr;
@@ -6516,14 +6516,14 @@ static bool retry_instruction(struct x86_emulate_ctxt *ctxt,if (x86_page_table_writing_insn (ctxt))return false; -if (ctxt->eip == last_retry_eip && last_retry_addr == cr2) +if (ctxt->eip == last_retry_eip && last_retry_addr == cr2_or_gpa)return false; vcpu->arch.last_retry_eip = ctxt->eip; - vcpu->arch.last_retry_addr = cr2; + vcpu->arch.last_retry_addr = cr2_or_gpa;if (!vcpu->arch.mmu->direct_map) - gpa =kvm_mmu_gva_to_gpa_write (vcpu, cr2,NULL ); + gpa =kvm_mmu_gva_to_gpa_write (vcpu, cr2_or_gpa,NULL );kvm_mmu_unprotect_page (vcpu->kvm,gpa_to_gfn (gpa));
@@ -6669,11 +6669,8 @@ static bool is_vmware_backdoor_opcode(struct x86_emulate_ctxt *ctxt)return false; } -int x86_emulate_instruction (struct kvm_vcpu *vcpu, -unsigned long cr2, -int emulation_type, -void *insn, -int insn_len) +int x86_emulate_instruction (struct kvm_vcpu *vcpu,gpa_t cr2_or_gpa, +int emulation_type,void *insn,int insn_len) {int r;struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt;
@@ -6719,8 +6716,9 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu,kvm_queue_exception (vcpu,UD_VECTOR );return 1 ; } -if (reexecute_instruction (vcpu, cr2, write_fault_to_spt, - emulation_type)) +if (reexecute_instruction (vcpu, cr2_or_gpa, + write_fault_to_spt, + emulation_type))return 1 ;if (ctxt->have_exception) {/*
@@ -6754,7 +6752,7 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu,return 1 ; } -if (retry_instruction (ctxt, cr2, emulation_type)) +if (retry_instruction (ctxt, cr2_or_gpa, emulation_type))return 1 ;/* this is needed for vmware backdoor interface to work since it
@@ -6766,7 +6764,7 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, restart:/* Save the faulting GPA (cr2) in the address field */ - ctxt->exception.address = cr2; + ctxt->exception.address = cr2_or_gpa; r =x86_emulate_insn (ctxt);
@@ -6774,7 +6772,7 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu,return 1 ;if (r ==EMULATION_FAILED ) { -if (reexecute_instruction (vcpu, cr2, write_fault_to_spt, +if (reexecute_instruction (vcpu, cr2_or_gpa, write_fault_to_spt, emulation_type))return 1 ;
@@ -10051,7 +10049,7 @@ void kvm_arch_async_page_ready(struct kvm_vcpu *vcpu, struct kvm_async_pf *work) work->arch.cr3 != vcpu->arch.mmu->get_cr3(vcpu)) return; - vcpu->arch.mmu->page_fault (vcpu, work->gva,0 , true); + vcpu->arch.mmu->page_fault (vcpu, work->cr2_or_gpa,0 , true); }static inline u32 kvm_async_pf_hash_fn (gfn_t gfn)
@@ -10164,7 +10162,7 @@ void kvm_arch_async_page_not_present(struct kvm_vcpu *vcpu, {struct x86_exception fault; -trace_kvm_async_pf_not_present (work->arch.token, work->gva); +trace_kvm_async_pf_not_present (work->arch.token, work->cr2_or_gpa);kvm_add_async_pf_gfn (vcpu, work->arch.gfn); if (kvm_can_deliver_async_pf(vcpu) &&
@@ -10199,7 +10197,7 @@ void kvm_arch_async_page_present(struct kvm_vcpu *vcpu, work->arch.token = ~0 ;/* broadcast wakeup */ else kvm_del_async_pf_gfn(vcpu, work->arch.gfn); -trace_kvm_async_pf_ready (work->arch.token, work->gva); +trace_kvm_async_pf_ready (work->arch.token, work->cr2_or_gpa);if (vcpu->arch.apf.msr_val &KVM_ASYNC_PF_ENABLED && !apf_get_user (vcpu, &val)) {
arch/x86/kvm/x86.h +1 -1
@@ -286,7 +286,7 @@ int kvm_mtrr_get_msr(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata);bool kvm_mtrr_check_gfn_range_consistency (struct kvm_vcpu *vcpu,gfn_t gfn,int page_num);bool kvm_vector_hashing_enabled (void ); -int x86_emulate_instruction (struct kvm_vcpu *vcpu,unsigned long cr2, +int x86_emulate_instruction (struct kvm_vcpu *vcpu,gpa_t cr2_or_gpa,int emulation_type,void *insn,int insn_len);#define KVM_SUPPORTED_XCR0 (XFEATURE_MASK_FP | XFEATURE_MASK_SSE \
include/linux/kvm_host.h +3 -3
@@ -204,7 +204,7 @@ struct kvm_async_pf {struct list_head queue;struct kvm_vcpu *vcpu;struct mm_struct *mm; -gva_t gva; +gpa_t cr2_or_gpa;unsigned long addr;struct kvm_arch_async_pf arch;bool wakeup_all;
@@ -212,8 +212,8 @@ struct kvm_async_pf {void kvm_clear_async_pf_completion_queue (struct kvm_vcpu *vcpu);void kvm_check_async_pf_completion (struct kvm_vcpu *vcpu); -int kvm_setup_async_pf (struct kvm_vcpu *vcpu,gva_t gva,unsigned long hva, -struct kvm_arch_async_pf *arch); +int kvm_setup_async_pf (struct kvm_vcpu *vcpu,gpa_t cr2_or_gpa, +unsigned long hva,struct kvm_arch_async_pf *arch);int kvm_async_pf_wakeup_all (struct kvm_vcpu *vcpu);#endif
virt/kvm/async_pf.c +5 -5
@@ -64,7 +64,7 @@ static void async_pf_execute(struct work_struct *work)struct mm_struct *mm = apf->mm;struct kvm_vcpu *vcpu = apf->vcpu;unsigned long addr = apf->addr; -gva_t gva = apf->gva; +gpa_t cr2_or_gpa = apf->cr2_or_gpa;int locked =1 ;might_sleep ();
@@ -92,7 +92,7 @@ static void async_pf_execute(struct work_struct *work)* this point */ -trace_kvm_async_pf_completed (addr, gva); +trace_kvm_async_pf_completed (addr, cr2_or_gpa);if (swq_has_sleeper (&vcpu->wq))swake_up_one (&vcpu->wq);
@@ -165,8 +165,8 @@ void kvm_check_async_pf_completion(struct kvm_vcpu *vcpu) } } -int kvm_setup_async_pf (struct kvm_vcpu *vcpu,gva_t gva,unsigned long hva, -struct kvm_arch_async_pf *arch) +int kvm_setup_async_pf (struct kvm_vcpu *vcpu,gpa_t cr2_or_gpa, +unsigned long hva,struct kvm_arch_async_pf *arch) {struct kvm_async_pf *work;
@@ -185,7 +185,7 @@ int kvm_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, unsigned long hva, work->wakeup_all = false; work->vcpu = vcpu; - work->gva = gva; + work->cr2_or_gpa = cr2_or_gpa; work->addr = hva; work->arch = *arch; work->mm = current->mm;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 300/309 KVM: Use vcpu-specific gva->hva translation when querying host page size
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
[ Upstream commit f9b84e19221efc5f493156ee0329df3142085f28 ]
Use kvm_vcpu_gfn_to_hva() when retrieving the host page size so that the correct set of memslots is used when handling x86 page faults in SMM.
--- arch/powerpc/kvm/book3s_xive_native.c | 2 +- arch/x86/kvm/mmu.c | 6 +++--- include/linux/kvm_host.h | 2 +- virt/kvm/kvm_main.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-)
arch/powerpc/kvm/book3s_xive_native.c +1 -1
@@ -638,7 +638,7 @@ static int kvmppc_xive_native_set_queue_config(struct kvmppc_xive *xive, srcu_idx =srcu_read_lock (&kvm->srcu); gfn =gpa_to_gfn (kvm_eq.qaddr); - page_size =kvm_host_page_size (kvm, gfn); + page_size =kvm_host_page_size (vcpu, gfn);if (1ull << kvm_eq.qshift > page_size) {srcu_read_unlock (&kvm->srcu, srcu_idx);pr_warn ("Incompatible host page size %lx!\n" , page_size);
arch/x86/kvm/mmu.c +3 -3
@@ -1286,12 +1286,12 @@ static bool mmu_gfn_lpage_is_disallowed(struct kvm_vcpu *vcpu, gfn_t gfn,return __mmu_gfn_lpage_is_disallowed (gfn, level, slot); } -static int host_mapping_level (struct kvm *kvm,gfn_t gfn) +static int host_mapping_level (struct kvm_vcpu *vcpu,gfn_t gfn) {unsigned long page_size;int i, ret =0 ; - page_size =kvm_host_page_size (kvm, gfn); + page_size =kvm_host_page_size (vcpu, gfn);for (i =PT_PAGE_TABLE_LEVEL ; i <=PT_MAX_HUGEPAGE_LEVEL ; ++i) {if (page_size >=KVM_HPAGE_SIZE (i))
@@ -1341,7 +1341,7 @@ static int mapping_level(struct kvm_vcpu *vcpu, gfn_t large_gfn,if (unlikely (*force_pt_level))return PT_PAGE_TABLE_LEVEL ; - host_level =host_mapping_level (vcpu->kvm, large_gfn); + host_level =host_mapping_level (vcpu, large_gfn);if (host_level ==PT_PAGE_TABLE_LEVEL )return host_level;
include/linux/kvm_host.h +1 -1
@@ -751,7 +751,7 @@ int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len);int kvm_clear_guest (struct kvm *kvm,gpa_t gpa,unsigned long len);struct kvm_memory_slot *gfn_to_memslot (struct kvm *kvm,gfn_t gfn);bool kvm_is_visible_gfn (struct kvm *kvm,gfn_t gfn); -unsigned long kvm_host_page_size (struct kvm *kvm,gfn_t gfn); +unsigned long kvm_host_page_size (struct kvm_vcpu *vcpu,gfn_t gfn);void mark_page_dirty (struct kvm *kvm,gfn_t gfn);struct kvm_memslots *kvm_vcpu_memslots (struct kvm_vcpu *vcpu);
virt/kvm/kvm_main.c +2 -2
@@ -1394,14 +1394,14 @@ bool kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn) }EXPORT_SYMBOL_GPL (kvm_is_visible_gfn); -unsigned long kvm_host_page_size (struct kvm *kvm,gfn_t gfn) +unsigned long kvm_host_page_size (struct kvm_vcpu *vcpu,gfn_t gfn) {struct vm_area_struct *vma;unsigned long addr, size; size =PAGE_SIZE ; - addr =gfn_to_hva (kvm, gfn); + addr =kvm_vcpu_gfn_to_hva (vcpu, gfn);if (kvm_is_error_hva (addr))return PAGE_SIZE ;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 296/309 KVM: x86: use CPUID to locate host page table reserved bits
In reply to Greg Kroah-HartmanFrom: Paolo Bonzini <[email protected]>
[ Upstream commit 7adacf5eb2d2048045d9fd8fdab861fd9e7e2e96 ]
The comment in kvm_get_shadow_phys_bits refers to MKTME, but the same is actually true of SME and SEV. Just use CPUID[0x8000_0008].EAX[7:0] unconditionally if available, it is simplest and works even if memory is not encrypted.
--- arch/x86/kvm/mmu.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
arch/x86/kvm/mmu.c +12 -8
@@ -538,16 +538,20 @@ EXPORT_SYMBOL_GPL(kvm_mmu_set_mask_ptes);static u8 kvm_get_shadow_phys_bits (void ) {/* -* boot_cpu_data.x86_phys_bits is reduced when MKTME is detected -* in CPU detection code, but MKTME treats those reduced bits as -* 'keyID' thus they are not reserved bits. Therefore for MKTME -* we should still return physical address bits reported by CPUID. +* boot_cpu_data.x86_phys_bits is reduced when MKTME or SME are detected +* in CPU detection code, but the processor treats those reduced bits as +* 'keyID' thus they are not reserved bits. Therefore KVM needs to look at +* the physical address bits reported by CPUID. */ -if (!boot_cpu_has (X86_FEATURE_TME ) || -WARN_ON_ONCE (boot_cpu_data.extended_cpuid_level <0x80000008 )) -return boot_cpu_data.x86_phys_bits; +if (likely (boot_cpu_data.extended_cpuid_level >=0x80000008 )) +return cpuid_eax (0x80000008 ) &0xff ; -return cpuid_eax (0x80000008 ) &0xff ; +/* +* Quite weird to have VMX or SVM but not MAXPHYADDR; probably a VM with +* custom CPUID. Proceed with whatever the kernel found since these features +* aren't virtualizable (SME/SEV also require CPUIDs higher than 0x80000008). +*/ +return boot_cpu_data.x86_phys_bits; }static void kvm_mmu_reset_all_pte_masks (void )
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 298/309 KVM: x86: fix overlap between SPTE_MMIO_MASK and generation
In reply to Greg Kroah-HartmanFrom: Paolo Bonzini <[email protected]>
[ Upstream commit 56871d444bc4d7ea66708775e62e2e0926384dbc ]
The SPTE_MMIO_MASK overlaps with the bits used to track MMIO generation number. A high enough generation number would overwrite the SPTE_SPECIAL_MASK region and cause the MMIO SPTE to be misinterpreted.
Likewise, setting bits 52 and 53 would also cause an incorrect generation number to be read from the PTE, though this was partially mitigated by the (useless if it weren't for the bug) removal of SPTE_SPECIAL_MASK from the spte in get_mmio_spte_generation. Drop that removal, and replace it with a compile-time assertion.
--- arch/x86/kvm/mmu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/x86/kvm/mmu.c +5 -5
@@ -418,22 +418,24 @@ static inline bool is_access_track_spte(u64 spte)* requires a full MMU zap). The flag is instead explicitly queried when * checking for MMIO spte cache hits. */ -#define MMIO_SPTE_GEN_MASK GENMASK_ULL(18, 0) +#define MMIO_SPTE_GEN_MASK GENMASK_ULL(17, 0)#define MMIO_SPTE_GEN_LOW_START 3#define MMIO_SPTE_GEN_LOW_END 11#define MMIO_SPTE_GEN_LOW_MASK GENMASK_ULL(MMIO_SPTE_GEN_LOW_END, \ MMIO_SPTE_GEN_LOW_START) -#define MMIO_SPTE_GEN_HIGH_START 52 -#define MMIO_SPTE_GEN_HIGH_END 61 +#define MMIO_SPTE_GEN_HIGH_START PT64_SECOND_AVAIL_BITS_SHIFT +#define MMIO_SPTE_GEN_HIGH_END 62#define MMIO_SPTE_GEN_HIGH_MASK GENMASK_ULL(MMIO_SPTE_GEN_HIGH_END, \ MMIO_SPTE_GEN_HIGH_START) +static u64 generation_mmio_spte_mask (u64 gen) {u64 mask;WARN_ON (gen & ~MMIO_SPTE_GEN_MASK ); +BUILD_BUG_ON ((MMIO_SPTE_GEN_HIGH_MASK |MMIO_SPTE_GEN_LOW_MASK ) &SPTE_SPECIAL_MASK ); mask = (gen <<MMIO_SPTE_GEN_LOW_START ) &MMIO_SPTE_GEN_LOW_MASK ; mask |= (gen <<MMIO_SPTE_GEN_HIGH_START ) &MMIO_SPTE_GEN_HIGH_MASK ;
@@ -444,8 +446,6 @@ static u64 get_mmio_spte_generation(u64 spte) {u64 gen; - spte &= ~shadow_mmio_mask; - gen = (spte &MMIO_SPTE_GEN_LOW_MASK ) >>MMIO_SPTE_GEN_LOW_START ; gen |= (spte &MMIO_SPTE_GEN_HIGH_MASK ) >>MMIO_SPTE_GEN_HIGH_START ;return gen;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 295/309 KVM: x86/mmu: Apply max PA check for MMIO sptes to 32-bit KVM
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
[ Upstream commit e30a7d623dccdb3f880fbcad980b0cb589a1da45 ]
Remove the bogus 64-bit only condition from the check that disables MMIO spte optimization when the system supports the max PA, i.e. doesn't have any reserved PA bits. 32-bit KVM always uses PAE paging for the shadow MMU, and per Intel's SDM:
PAE paging translates 32-bit linear addresses to 52-bit physical addresses.
The kernel's restrictions on max physical addresses are limits on how much memory the kernel can reasonably use, not what physical addresses are supported by hardware.
--- arch/x86/kvm/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/mmu.c +1 -1
@@ -6249,7 +6249,7 @@ static void kvm_set_mmio_spte_mask(void)* If reserved bit is not supported, clear the present bit to disable * mmio page fault. */ -if (IS_ENABLED (CONFIG_X86_64 ) && shadow_phys_bits ==52 ) +if (shadow_phys_bits ==52 ) mask &= ~1ull ;kvm_mmu_set_mmio_spte_mask (mask, mask,ACC_WRITE_MASK |ACC_USER_MASK );
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 294/309 drm/dp_mst: Remove VCPI while disabling topology mgr
In reply to Greg Kroah-HartmanFrom: Wayne Lin <[email protected]>
[ Upstream commit 64e62bdf04ab8529f45ed0a85122c703035dec3a ]
[Why]
This patch is trying to address the issue observed when hotplug DP daisy chain monitors.
e.g.
src-mstb-mstb-sst -> src (unplug) mstb-mstb-sst -> src-mstb-mstb-sst (plug in again)
Once unplug a DP MST capable device, driver will call drm_dp_mst_topology_mgr_set_mst() to disable MST. In this function, it cleans data of topology manager while disabling mst_state. However, it doesn't clean up the proposed_vcpis of topology manager. If proposed_vcpi is not reset, once plug in MST daisy chain monitors later, code will fail at checking port validation while trying to allocate payloads.
When MST capable device is plugged in again and try to allocate payloads by calling drm_dp_update_payload_part1(), this function will iterate over all proposed virtual channels to see if any proposed VCPI's num_slots is greater than 0. If any proposed VCPI's num_slots is greater than 0 and the port which the specific virtual channel directed to is not in the topology, code then fails at the port validation. Since there are stale VCPI allocations from the previous topology enablement in proposed_vcpi[], code will fail at port validation and reurn EINVAL.
[How]
Clean up the data of stale proposed_vcpi[] and reset mgr->proposed_vcpis to NULL while disabling mst in drm_dp_mst_topology_mgr_set_mst().
Changes since v1:
*Add on more details in commit message to describe the issue which the patch is trying to fix
--- drivers/gpu/drm/drm_dp_mst_topology.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/gpu/drm/drm_dp_mst_topology.c +12 -0
@@ -2694,6 +2694,7 @@ static bool drm_dp_get_vc_payload_bw(int dp_link_bw,int drm_dp_mst_topology_mgr_set_mst (struct drm_dp_mst_topology_mgr *mgr,bool mst_state) {int ret =0 ; +int i =0 ;struct drm_dp_mst_branch *mstb =NULL ;mutex_lock (&mgr->lock);
@@ -2754,10 +2755,21 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms/* this can fail if the device is gone */ drm_dp_dpcd_writeb (mgr->aux,DP_MSTM_CTRL ,0 ); ret =0 ; +mutex_lock (&mgr->payload_lock);memset (mgr->payloads,0 , mgr->max_payloads *sizeof (struct drm_dp_payload )); mgr->payload_mask =0 ;set_bit (0 , &mgr->payload_mask); +for (i =0 ; i < mgr->max_payloads; i++) { +struct drm_dp_vcpi *vcpi = mgr->proposed_vcpis[i]; + +if (vcpi) { + vcpi->vcpi =0 ; + vcpi->num_slots =0 ; + } + mgr->proposed_vcpis[i] =NULL ; + } mgr->vcpi_mask =0 ; +mutex_unlock (&mgr->payload_lock); } out_unlock:
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 266/309 net: dsa: b53: Always use dev->vlan_enabled in b53_configure_vlan()
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
[ Upstream commit df373702bc0f8f2d83980ea441e71639fc1efcf8 ]
b53_configure_vlan() is called by the bcm_sf2 driver upon setup and indirectly through resume as well. During the initial setup, we are guaranteed that dev->vlan_enabled is false, so there is no change in behavior, however during suspend, we may have enabled VLANs before, so we do want to restore that setting.
--- drivers/net/dsa/b53/b53_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/b53/b53_common.c +1 -1
@@ -680,7 +680,7 @@ int b53_configure_vlan(struct dsa_switchb53_do_vlan_op (dev,VTA_CMD_CLEAR ); } -b53_enable_vlan (dev, false, ds->vlan_filtering); +b53_enable_vlan (dev, dev->vlan_enabled, ds->vlan_filtering);b53_for_each_port (dev, i) b53_write16(dev, B53_VLAN_PAGE,
Greg Kroah-Hartman
maintainerPATCH 292/309 btrfs: use bool argument in free_root_pointers()
In reply to Greg Kroah-HartmanFrom: Anand Jain <[email protected]>
[ Upstream commit 4273eaff9b8d5e141113a5bdf9628c02acf3afe5 ]
We don't need int argument bool shall do in free_root_pointers(). And rename the argument as it confused two people.
--- fs/btrfs/disk-io.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/btrfs/disk-io.c +5 -5
@@ -2016,7 +2016,7 @@ static void free_root_extent_buffers(struct btrfs_root *root) }/* helper to cleanup tree roots */ -static void free_root_pointers (struct btrfs_fs_info *info,int chunk_root) +static void free_root_pointers (struct btrfs_fs_info *info,bool free_chunk_root) {free_root_extent_buffers (info->tree_root);
@@ -2025,7 +2025,7 @@ static void free_root_pointers(struct btrfs_fs_info *info, int chunk_root)free_root_extent_buffers (info->csum_root);free_root_extent_buffers (info->quota_root);free_root_extent_buffers (info->uuid_root); -if (chunk_root) +if (free_chunk_root)free_root_extent_buffers (info->chunk_root);free_root_extent_buffers (info->free_space_root); }
@@ -3323,7 +3323,7 @@ int open_ctree(struct super_block *sb,btrfs_put_block_group_cache (fs_info); fail_tree_roots: -free_root_pointers (fs_info,1 ); +free_root_pointers (fs_info, true);invalidate_inode_pages2 (fs_info->btree_inode->i_mapping); fail_sb_buffer:
@@ -3355,7 +3355,7 @@ int open_ctree(struct super_block *sb,if (!btrfs_test_opt (fs_info,USEBACKUPROOT )) goto fail_tree_roots; -free_root_pointers (fs_info,0 ); +free_root_pointers (fs_info, false);/* don't use the log in recovery mode, it won't be valid */ btrfs_set_super_log_root (disk_super,0 );
@@ -4049,7 +4049,7 @@ void close_ctree(struct btrfs_fs_info *fs_info)btrfs_free_block_groups (fs_info);clear_bit (BTRFS_FS_OPEN , &fs_info->flags); -free_root_pointers (fs_info,1 ); +free_root_pointers (fs_info, true);iput (fs_info->btree_inode);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 291/309 x86/timer: Dont skip PIT setup when APIC is disabled or in legacy mode
In reply to Greg Kroah-HartmanFrom: Thomas Gleixner <[email protected]>
commit 979923871f69a4dc926658f9f9a1a4c1bde57552 upstream.
Tony reported a boot regression caused by the recent workaround for systems which have a disabled (clock gate off) PIT.
On his machine the kernel fails to initialize the PIT because apic_needs_pit() does not take into account whether the local APIC interrupt delivery mode will actually allow to setup and use the local APIC timer. This should be easy to reproduce with acpi=off on the command line which also disables HPET.
Due to the way the PIT/HPET and APIC setup ordering works (APIC setup can require working PIT/HPET) the information is not available at the point where apic_needs_pit() makes this decision.
To address this, split out the interrupt mode selection from apic_intr_mode_init(), invoke the selection before making the decision whether PIT is required or not, and add the missing checks into apic_needs_pit().
--- arch/x86/include/asm/apic.h | 2 ++ arch/x86/include/asm/x86_init.h | 2 ++ arch/x86/kernel/apic/apic.c | 23 ++++++++++++++++++----- arch/x86/kernel/time.c | 12 ++++++++++-- arch/x86/kernel/x86_init.c | 1 + arch/x86/xen/enlighten_pv.c | 1 + 6 files changed, 34 insertions(+), 7 deletions(-)
arch/x86/include/asm/apic.h +2 -0
@@ -140,6 +140,7 @@ extern void apic_soft_disable(void);extern void lapic_shutdown (void );extern void sync_Arb_IDs (void );extern void init_bsp_APIC (void ); +extern void apic_intr_mode_select (void );extern void apic_intr_mode_init (void );extern void init_apic_mappings (void );void register_lapic_address (unsigned long address);
@@ -188,6 +189,7 @@ static inline void disable_local_APIC(vo# define setup_secondary_APIC_clock x86_init_noopstatic inline void lapic_update_tsc_freq (void ) { }static inline void init_bsp_APIC (void ) { } +static inline void apic_intr_mode_select (void ) { }static inline void apic_intr_mode_init (void ) { }static inline void lapic_assign_system_vectors (void ) { }static inline void lapic_assign_legacy_vector (unsigned int i,bool r) { }
arch/x86/include/asm/x86_init.h +2 -0
@@ -51,12 +51,14 @@ struct x86_init_resources {* are set up. * @intr_init: interrupt init code * @trap_init: platform specific trap setup +* @intr_mode_select: interrupt delivery mode selection * @intr_mode_init: interrupt delivery mode setup */ struct x86_init_irqs {void (*pre_vector_init)(void );void (*intr_init)(void );void (*trap_init)(void ); +void (*intr_mode_select)(void );void (*intr_mode_init)(void ); };
arch/x86/kernel/apic/apic.c +18 -5
@@ -830,8 +830,17 @@ bool __init apic_needs_pit(void)if (!tsc_khz || !cpu_khz)return true; -/* Is there an APIC at all? */ -if (!boot_cpu_has (X86_FEATURE_APIC )) +/* Is there an APIC at all or is it disabled? */ +if (!boot_cpu_has (X86_FEATURE_APIC ) || disable_apic) +return true; + +/* +* If interrupt delivery mode is legacy PIC or virtual wire without +* configuration, the local APIC timer wont be set up. Make sure +* that the PIT is initialized. +*/ +if (apic_intr_mode ==APIC_PIC || + apic_intr_mode ==APIC_VIRTUAL_WIRE_NO_CONFIG )return true;/* Virt guests may lack ARAT, but still have DEADLINE */
@@ -1322,7 +1331,7 @@ void __init sync_Arb_IDs(void)enum apic_intr_mode_id apic_intr_mode__ro_after_init ; -static int __init apic_intr_mode_select (void ) +static int __init __apic_intr_mode_select (void ) {/* Check kernel option */ if (disable_apic) {
@@ -1384,6 +1393,12 @@ static int __init apic_intr_mode_select(return APIC_SYMMETRIC_IO ; } +/* Select the interrupt delivery mode for the BSP */ +void __init apic_intr_mode_select (void ) +{ + apic_intr_mode =__apic_intr_mode_select (); +} +/* * An initial setup of the virtual wire mode. */
@@ -1440,8 +1455,6 @@ void __init apic_intr_mode_init(void) {bool upmode =IS_ENABLED (CONFIG_UP_LATE_INIT ); - apic_intr_mode =apic_intr_mode_select (); -switch (apic_intr_mode) {case APIC_PIC :pr_info ("APIC: Keep in PIC mode(8259)\n" );
arch/x86/kernel/time.c +10 -2
@@ -91,10 +91,18 @@ void __init hpet_time_init(void)static __init void x86_late_time_init (void ) { +/* +* Before PIT/HPET init, select the interrupt mode. This is required +* to make the decision whether PIT should be initialized correct. +*/ + x86_init.irqs.intr_mode_select (); + +/* Setup the legacy timers */ x86_init.timers.timer_init (); +/* -* After PIT/HPET timers init, select and setup -* the final interrupt mode for delivering IRQs. +* After PIT/HPET timers init, set up the final interrupt mode for +* delivering IRQs. */ x86_init.irqs.intr_mode_init ();tsc_init ();
arch/x86/kernel/x86_init.c +1 -0
@@ -58,6 +58,7 @@ struct x86_init_ops x86_init __initdata .pre_vector_init = init_ISA_irqs, .intr_init = native_init_IRQ, .trap_init = x86_init_noop, + .intr_mode_select = apic_intr_mode_select, .intr_mode_init = apic_intr_mode_init },
arch/x86/xen/enlighten_pv.c +1 -0
@@ -1215,6 +1215,7 @@ asmlinkage __visible void __init xen_sta x86_platform.get_nmi_reason = xen_get_nmi_reason; x86_init.resources.memory_setup = xen_memory_setup; + x86_init.irqs.intr_mode_select = x86_init_noop; x86_init.irqs.intr_mode_init = x86_init_noop; x86_init.oem.arch_setup = xen_arch_setup; x86_init.oem.banner = xen_banner;
Greg Kroah-Hartman
maintainerPATCH 290/309 mfd: bd70528: Fix hour register mask
In reply to Greg Kroah-HartmanFrom: Matti Vaittinen <[email protected]>
commit 6c883472e1c11cb05561b6dd0c28bb037c2bf2de upstream.
When RTC is used in 24H mode (and it is by this driver) the maximum hour value is 24 in BCD. This occupies bits [5:0] - which means correct mask for HOUR register is 0x3f not 0x1f. Fix the mask
--- include/linux/mfd/rohm-bd70528.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mfd/rohm-bd70528.h +1 -1
@@ -317,7 +317,7 @@ enum {#define BD70528_MASK_RTC_MINUTE 0x7f#define BD70528_MASK_RTC_HOUR_24H 0x80#define BD70528_MASK_RTC_HOUR_PM 0x20 -#define BD70528_MASK_RTC_HOUR 0x1f +#define BD70528_MASK_RTC_HOUR 0x3f#define BD70528_MASK_RTC_DAY 0x3f#define BD70528_MASK_RTC_WEEK 0x07#define BD70528_MASK_RTC_MONTH 0x1f
Greg Kroah-Hartman
maintainerPATCH 76/309 powerpc/xmon: dont access ASDR in VMs
In reply to Greg Kroah-HartmanFrom: Sukadev Bhattiprolu <[email protected]>
commit c2a20711fc181e7f22ee5c16c28cb9578af84729 upstream.
ASDR is HV-privileged and must only be accessed in HV-mode. Fixes a Program Check (0x700) when xmon in a VM dumps SPRs.
--- arch/powerpc/xmon/xmon.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
arch/powerpc/xmon/xmon.c +4 -5
@@ -1894,15 +1894,14 @@ static void dump_300_sprs(void)printf ("pidr = %.16lx tidr = %.16lx\n" ,mfspr (SPRN_PID ),mfspr (SPRN_TIDR )); -printf ("asdr = %.16lx psscr = %.16lx\n" , -mfspr (SPRN_ASDR ), hv ?mfspr (SPRN_PSSCR ) - :mfspr (SPRN_PSSCR_PR )); +printf ("psscr = %.16lx\n" , + hv ?mfspr (SPRN_PSSCR ) :mfspr (SPRN_PSSCR_PR ));if (!hv)return ; -printf ("ptcr = %.16lx\n" , -mfspr (SPRN_PTCR )); +printf ("ptcr = %.16lx asdr = %.16lx\n" , +mfspr (SPRN_PTCR ),mfspr (SPRN_ASDR ));#endif }
Greg Kroah-Hartman
maintainerPATCH 286/309 net/mlx5: Deprecate usage of generic TLS HW capability bit
In reply to Greg Kroah-HartmanFrom: Tariq Toukan <[email protected]>
[ Upstream commit 61c00cca41aeeaa8e5263c2f81f28534bc1efafb ]
Deprecate the generic TLS cap bit, use the new TX-specific TLS cap bit instead.
--- drivers/net/ethernet/mellanox/mlx5/core/accel/tls.h | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls_rxtx.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/fw.c | 2 +- include/linux/mlx5/mlx5_ifc.h | 7 ++++--- 4 files changed, 7 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/accel/tls.h +1 -1
@@ -45,7 +45,7 @@ void mlx5_ktls_destroy_key(struct mlx5_cstatic inline bool mlx5_accel_is_ktls_device (struct mlx5_core_dev *mdev) { -if (!MLX5_CAP_GEN (mdev, tls)) +if (!MLX5_CAP_GEN (mdev, tls_tx))return false;if (!MLX5_CAP_GEN (mdev, log_max_dek))
drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls_rxtx.c +1 -1
@@ -269,7 +269,7 @@ struct sk_buff *mlx5e_tls_handle_tx_skb(int datalen;u32 skb_seq; -if (MLX5_CAP_GEN (sq->channel->mdev, tls)) { +if (MLX5_CAP_GEN (sq->channel->mdev, tls_tx)) { skb =mlx5e_ktls_handle_tx_skb (netdev, sq, skb, wqe, pi); goto out; }
drivers/net/ethernet/mellanox/mlx5/core/fw.c +1 -1
@@ -239,7 +239,7 @@ int mlx5_query_hca_caps(struct mlx5_corereturn err; } -if (MLX5_CAP_GEN (dev, tls)) { +if (MLX5_CAP_GEN (dev, tls_tx)) { err =mlx5_core_get_caps (dev,MLX5_CAP_TLS );if (err)return err;
include/linux/mlx5/mlx5_ifc.h +4 -3
@@ -1417,14 +1417,15 @@ struct mlx5_ifc_cmd_hca_cap_bits {u8 reserved_at_440[0x20 ]; -u8 tls[0x1 ]; -u8 reserved_at_461[0x2 ]; +u8 reserved_at_460[0x3 ];u8 log_max_uctx[0x5 ];u8 reserved_at_468[0x3 ];u8 log_max_umem[0x5 ];u8 max_num_eqs[0x10 ]; -u8 reserved_at_480[0x3 ]; +u8 reserved_at_480[0x1 ]; +u8 tls_tx[0x1 ]; +u8 reserved_at_482[0x1 ];u8 log_max_l2_table[0x5 ];u8 reserved_at_488[0x8 ];u8 log_uar_page_sz[0x10 ];
Greg Kroah-Hartman
maintainerPATCH 283/309 qed: Fix timestamping issue for L2 unicast ptp packets.
In reply to Greg Kroah-HartmanFrom: Sudarsana Reddy Kalluru <[email protected]>
[ Upstream commit 0202d293c2faecba791ba4afc5aec086249c393d ]
commit cedeac9df4b8 ("qed: Add support for Timestamping the unicast PTP packets.") handles the timestamping of L4 ptp packets only. This patch adds driver changes to detect/timestamp both L2/L4 unicast PTP packets.
--- drivers/net/ethernet/qlogic/qed/qed_ptp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/qlogic/qed/qed_ptp.c +2 -2
@@ -44,8 +44,8 @@/* Add/subtract the Adjustment_Value when making a Drift adjustment */ #define QED_DRIFT_CNTR_DIRECTION_SHIFT 31#define QED_TIMESTAMP_MASK BIT(16) -/* Param mask for Hardware to detect/timestamp the unicast PTP packets */ -#define QED_PTP_UCAST_PARAM_MASK 0xF +/* Param mask for Hardware to detect/timestamp the L2/L4 unicast PTP packets */ +#define QED_PTP_UCAST_PARAM_MASK 0x70Fstatic enum qed_resc_lock qed_ptcdev_to_resc (struct qed_hwfn *p_hwfn) {
Greg Kroah-Hartman
maintainerPATCH 284/309 drop_monitor: Do not cancel uninitialized work item
In reply to Greg Kroah-HartmanFrom: Ido Schimmel <[email protected]>
[ Upstream commit dfa7f709596be5ca46c070d4f8acbb344322056a ]
Drop monitor uses a work item that takes care of constructing and sending netlink notifications to user space. In case drop monitor never started to monitor, then the work item is uninitialized and not associated with a function.
Therefore, a stop command from user space results in canceling an uninitialized work item which leads to the following warning [1].
Fix this by not processing a stop command if drop monitor is not currently monitoring.
[1]
[ 31.735402] ------------[ cut here ]------------ [ 31.736470] WARNING: CPU: 0 PID: 143 at kernel/workqueue.c:3032 __flush_work+0x89f/0x9f0 ... [ 31.738120] CPU: 0 PID: 143 Comm: dwdump Not tainted 5.5.0-custom-09491-g16d4077796b8 #727 [ 31.741968] RIP: 0010:__flush_work+0x89f/0x9f0 ... [ 31.760526] Call Trace: [ 31.771689] __cancel_work_timer+0x2a6/0x3b0 [ 31.776809] net_dm_cmd_trace+0x300/0xef0 [ 31.777549] genl_rcv_msg+0x5c6/0xd50 [ 31.781005] netlink_rcv_skb+0x13b/0x3a0 [ 31.784114] genl_rcv+0x29/0x40 [ 31.784720] netlink_unicast+0x49f/0x6a0 [ 31.787148] netlink_sendmsg+0x7cf/0xc80 [ 31.790426] ____sys_sendmsg+0x620/0x770 [ 31.793458] ___sys_sendmsg+0xfd/0x170 [ 31.802216] __sys_sendmsg+0xdf/0x1a0 [ 31.806195] do_syscall_64+0xa0/0x540 [ 31.806885] entry_SYSCALL_64_after_hwframe+0x49/0xbe
--- net/core/drop_monitor.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/core/drop_monitor.c +3 -1
@@ -1004,8 +1004,10 @@ static void net_dm_hw_monitor_stop(struc {int cpu; -if (!monitor_hw) +if (!monitor_hw) {NL_SET_ERR_MSG_MOD (extack,"Hardware monitoring already disabled" ); +return ; + } monitor_hw = false;
Greg Kroah-Hartman
maintainerPATCH 265/309 dpaa_eth: support all modes with rate adapting PHYs
In reply to Greg Kroah-HartmanFrom: Madalin Bucur <[email protected]>
[ Upstream commit 73a21fa817f0cc8022dc6226250a86bca727a56d ]
Stop removing modes that are not supported on the system interface when the connected PHY is capable of rate adaptation. This addresses an issue with the LS1046ARDB board 10G interface no longer working with an 1G link partner after autonegotiation support was added for the Aquantia PHY on board in
commit 09c4c57f7bc4 ("net: phy: aquantia: add support for auto-negotiation configuration")
Before this commit the values advertised by the PHY were not influenced by the dpaa_eth driver removal of system-side unsupported modes as the aqr_config_aneg() was basically a no-op. After this commit, the modes removed by the dpaa_eth driver were no longer advertised thus autonegotiation with 1G link partners failed.
--- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +11 -3
@@ -2483,6 +2483,9 @@ static void dpaa_adjust_link(struct net_ mac_dev->adjust_link (mac_dev); } +/* The Aquantia PHYs are capable of performing rate adaptation */ +#define PHY_VEND_AQUANTIA 0x03a1b400 +static int dpaa_phy_init (struct net_device *net_dev) {__ETHTOOL_DECLARE_LINK_MODE_MASK (mask) = {0 , };
@@ -2501,9 +2504,14 @@ static int dpaa_phy_init(struct net_devireturn -ENODEV ; } -/* Remove any features not supported by the controller */ -ethtool_convert_legacy_u32_to_link_mode (mask, mac_dev->if_support); -linkmode_and (phy_dev->supported, phy_dev->supported, mask); +/* Unless the PHY is capable of rate adaptation */ +if (mac_dev->phy_if !=PHY_INTERFACE_MODE_XGMII || + ((phy_dev->drv->phy_id &GENMASK (31 ,10 )) !=PHY_VEND_AQUANTIA )) { +/* remove any features not supported by the controller */ +ethtool_convert_legacy_u32_to_link_mode (mask, + mac_dev->if_support); +linkmode_and (phy_dev->supported, phy_dev->supported, mask); + }phy_support_asym_pause (phy_dev);
Greg Kroah-Hartman
maintainerPATCH 282/309 ipv6/addrconf: fix potential NULL deref in inet6_set_link_af()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit db3fa271022dacb9f741b96ea4714461a8911bb9 ]
__in6_dev_get(dev) called from inet6_set_link_af() can return NULL.
The needed check has been recently removed, let's add it back.
While do_setlink() does call validate_linkmsg() :
...
err = validate_linkmsg(dev, tb); /* OK at this point */
...
It is possible that the following call happening before the ->set_link_af() removes IPv6 if MTU is less than 1280 :
if (tb[IFLA_MTU]) {
err = dev_set_mtu_ext(dev, nla_get_u32(tb[IFLA_MTU]), extack);
if (err < 0)
goto errout;
status |= DO_SETLINK_MODIFIED;
}...
if (tb[IFLA_AF_SPEC]) {
...
err = af_ops->set_link_af(dev, af);
->inet6_set_link_af() // CRASH because idev is NULLPlease note that IPv4 is immune to the bug since inet_set_link_af() does :
struct in_device *in_dev = __in_dev_get_rcu(dev);
if (!in_dev)
return -EAFNOSUPPORT;
This problem has been mentioned in commit cf7afbfeb8ce ("rtnl: make link af-specific updates atomic") changelog :
This method is not fail proof, while it is currently sufficient to make set_link_af() inerrable and thus 100% atomic, the validation function method will not be able to detect all error scenarios in the future, there will likely always be errors depending on states which are f.e. not protected by rtnl_mutex and thus may change between validation and setting.
IPv6: ADDRCONF(NETDEV_CHANGE): lo: link becomes ready
general protection fault, probably for non-canonical address 0xdffffc0000000056: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x00000000000002b0-0x00000000000002b7] CPU: 0 PID: 9698 Comm: syz-executor712 Not tainted 5.5.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 RIP: 0010:inet6_set_link_af+0x66e/0xae0 net/ipv6/addrconf.c:5733 Code: 38 d0 7f 08 84 c0 0f 85 20 03 00 00 48 8d bb b0 02 00 00 45 0f b6 64 24 04 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 84 c0 74 08 3c 03 0f 8e 1a 03 00 00 44 89 a3 b0 02 00 RSP: 0018:ffffc90005b06d40 EFLAGS: 00010206 RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff86df39a6 RDX: 0000000000000056 RSI: ffffffff86df3e74 RDI: 00000000000002b0 RBP: ffffc90005b06e70 R08: ffff8880a2ac0380 R09: ffffc90005b06db0 R10: fffff52000b60dbe R11: ffffc90005b06df7 R12: 0000000000000000 R13: 0000000000000000 R14: ffff8880a1fcc424 R15: dffffc0000000000 FS: 0000000000c46880(0000) GS:ffff8880ae800000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055f0494ca0d0 CR3: 000000009e4ac000 CR4: 00000000001406f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: do_setlink+0x2a9f/0x3720 net/core/rtnetlink.c:2754 rtnl_group_changelink net/core/rtnetlink.c:3103 [inline] __rtnl_newlink+0xdd1/0x1790 net/core/rtnetlink.c:3257 rtnl_newlink+0x69/0xa0 net/core/rtnetlink.c:3377 rtnetlink_rcv_msg+0x45e/0xaf0 net/core/rtnetlink.c:5438 netlink_rcv_skb+0x177/0x450 net/netlink/af_netlink.c:2477 rtnetlink_rcv+0x1d/0x30 net/core/rtnetlink.c:5456 netlink_unicast_kernel net/netlink/af_netlink.c:1302 [inline] netlink_unicast+0x59e/0x7e0 net/netlink/af_netlink.c:1328 netlink_sendmsg+0x91c/0xea0 net/netlink/af_netlink.c:1917 sock_sendmsg_nosec net/socket.c:652 [inline] sock_sendmsg+0xd7/0x130 net/socket.c:672 ____sys_sendmsg+0x753/0x880 net/socket.c:2343 ___sys_sendmsg+0x100/0x170 net/socket.c:2397 __sys_sendmsg+0x105/0x1d0 net/socket.c:2430 __do_sys_sendmsg net/socket.c:2439 [inline] __se_sys_sendmsg net/socket.c:2437 [inline] __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2437 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x4402e9 Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 fb 13 fc ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007fffd62fbcf8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 00000000004402e9 RDX: 0000000000000000 RSI: 0000000020000080 RDI: 0000000000000003 RBP: 00000000006ca018 R08: 0000000000000008 R09: 00000000004002c8 R10: 0000000000000005 R11: 0000000000000246 R12: 0000000000401b70 R13: 0000000000401c00 R14: 0000000000000000 R15: 0000000000000000 Modules linked in: ---[ end trace cfa7664b8fdcdff3 ]--- RIP: 0010:inet6_set_link_af+0x66e/0xae0 net/ipv6/addrconf.c:5733 Code: 38 d0 7f 08 84 c0 0f 85 20 03 00 00 48 8d bb b0 02 00 00 45 0f b6 64 24 04 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 84 c0 74 08 3c 03 0f 8e 1a 03 00 00 44 89 a3 b0 02 00 RSP: 0018:ffffc90005b06d40 EFLAGS: 00010206 RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff86df39a6 RDX: 0000000000000056 RSI: ffffffff86df3e74 RDI: 00000000000002b0 RBP: ffffc90005b06e70 R08: ffff8880a2ac0380 R09: ffffc90005b06db0 R10: fffff52000b60dbe R11: ffffc90005b06df7 R12: 0000000000000000 R13: 0000000000000000 R14: ffff8880a1fcc424 R15: dffffc0000000000 FS: 0000000000c46880(0000) GS:ffff8880ae900000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000020000004 CR3: 000000009e4ac000 CR4: 00000000001406e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
--- net/ipv6/addrconf.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv6/addrconf.c +3 -0
@@ -5719,6 +5719,9 @@ static int inet6_set_link_af(struct net_struct nlattr *tb[IFLA_INET6_MAX +1 ];int err; +if (!idev) +return -EAFNOSUPPORT ; +if (nla_parse_nested_deprecated (tb,IFLA_INET6_MAX , nla,NULL ,NULL ) <0 )BUG ();
Greg Kroah-Hartman
maintainerPATCH 280/309 taprio: Use taprio_reset_tc() to reset Traffic Classes configuration
In reply to Greg Kroah-HartmanFrom: Vinicius Costa Gomes <[email protected]>
[ Upstream commit 7c16680a08ee1e444a67d232c679ccf5b30fad16 ]
When destroying the current taprio instance, which can happen when the creation of one fails, we should reset the traffic class configuration back to the default state.
netdev_reset_tc() is a better way because in addition to setting the number of traffic classes to zero, it also resets the priority to traffic classes mapping to the default value.
--- net/sched/sch_taprio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_taprio.c +1 -1
@@ -1588,7 +1588,7 @@ static void taprio_destroy(struct Qdisc } q->qdiscs =NULL ; -netdev_set_num_tc (dev,0 ); +netdev_reset_tc (dev);if (q->oper_sched)call_rcu (&q->oper_sched->rcu, taprio_free_sched_cb);
Greg Kroah-Hartman
maintainerPATCH 276/309 net: macb: Limit maximum GEM TX length in TSO
In reply to Greg Kroah-HartmanFrom: Harini Katakam <[email protected]>
[ Upstream commit f822e9c4ffa511a5c681cf866287d9383a3b6f1b ]
GEM_MAX_TX_LEN currently resolves to 0x3FF8 for any IP version supporting TSO with full 14bits of length field in payload descriptor. But an IP errata causes false amba_error (bit 6 of ISR) when length in payload descriptors is specified above 16387. The error occurs because the DMA falsely concludes that there is not enough space in SRAM for incoming payload. These errors were observed continuously under stress of large packets using iperf on a version where SRAM was 16K for each queue. This errata will be documented shortly and affects all versions since TSO functionality was added. Hence limit the max length to 0x3FC0 (rounded).
--- drivers/net/ethernet/cadence/macb_main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/cadence/macb_main.c +5 -1
@@ -73,7 +73,11 @@ struct sifive_fu540_macb_mgmt {/* Max length of transmit frame must be a multiple of 8 bytes */ #define MACB_TX_LEN_ALIGN 8#define MACB_MAX_TX_LEN ((unsigned int)((1 << MACB_TX_FRMLEN_SIZE) - 1) & ~((unsigned int)(MACB_TX_LEN_ALIGN - 1))) -#define GEM_MAX_TX_LEN ((unsigned int)((1 << GEM_TX_FRMLEN_SIZE) - 1) & ~((unsigned int)(MACB_TX_LEN_ALIGN - 1))) +/* Limit maximum TX length as per Cadence TSO errata. This is to avoid a +* false amba_error in TX path from the DMA assuming there is not enough +* space in the SRAM (16KB) even when there is. +*/ +#define GEM_MAX_TX_LEN (unsigned int)(0x3FC0)#define GEM_MTU_MIN_SIZE ETH_MIN_MTU#define MACB_NETIF_LSO NETIF_F_TSO
Greg Kroah-Hartman
maintainerPATCH 274/309 net/mlx5: IPsec, fix memory leak at mlx5_fpga_ipsec_delete_sa_ctx
In reply to Greg Kroah-HartmanFrom: Raed Salem <[email protected]>
[ Upstream commit 08db2cf577487f5123aebcc2f913e0b8a2c14b43 ]
SA context is allocated at mlx5_fpga_ipsec_create_sa_ctx, however the counterpart mlx5_fpga_ipsec_delete_sa_ctx function nullifies sa_ctx pointer without freeing the memory allocated, hence the memory leak.
Fix by free SA context when the SA is released.
--- drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c +1 -0
@@ -850,6 +850,7 @@ void mlx5_fpga_ipsec_delete_sa_ctx(voidmutex_lock (&fpga_xfrm->lock);if (!--fpga_xfrm->num_rules) {mlx5_fpga_ipsec_release_sa_ctx (fpga_xfrm->sa_ctx); +kfree (fpga_xfrm->sa_ctx); fpga_xfrm->sa_ctx =NULL ; }mutex_unlock (&fpga_xfrm->lock);
Greg Kroah-Hartman
maintainerPATCH 273/309 net/mlx5: IPsec, Fix esp modify function attribute
In reply to Greg Kroah-HartmanFrom: Raed Salem <[email protected]>
[ Upstream commit 0dc2c534f17c05bed0622b37a744bc38b48ca88a ]
The function mlx5_fpga_esp_validate_xfrm_attrs is wrongly used with negative negation as zero value indicates success but it used as failure return value instead.
Fix by remove the unary not negation operator.
--- drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c +1 -1
@@ -1478,7 +1478,7 @@ int mlx5_fpga_esp_modify_xfrm(struct mlxif (!memcmp (&xfrm->attrs, attrs,sizeof (xfrm->attrs)))return 0 ; -if (!mlx5_fpga_esp_validate_xfrm_attrs (mdev, attrs)) { +if (mlx5_fpga_esp_validate_xfrm_attrs (mdev, attrs)) {mlx5_core_warn (mdev,"Tried to create an esp with unsupported attrs\n" );return -EOPNOTSUPP ; }
Greg Kroah-Hartman
maintainerPATCH 219/309 KVM: VMX: Add non-canonical check on writes to RTIT address MSRs
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit fe6ed369fca98e99df55c932b85782a5687526b5 upstream.
Reject writes to RTIT address MSRs if the data being written is a non-canonical address as the MSRs are subject to canonical checks, e.g. KVM will trigger an unchecked #GP when loading the values to hardware during pt_guest_enter().
--- arch/x86/kvm/vmx/vmx.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/kvm/vmx/vmx.c +2 -0
@@ -2140,6 +2140,8 @@ static int vmx_set_msr(struct kvm_vcpu * (index >= 2 * intel_pt_validate_cap(vmx->pt_desc.caps, PT_CAP_num_address_ranges)))return 1 ; +if (is_noncanonical_address (data, vcpu)) +return 1 ;if (index %2 ) vmx->pt_desc.guest.addr_b[index /2 ] = data;else
Greg Kroah-Hartman
maintainerPATCH 264/309 devlink: report 0 after hitting end in region read
In reply to Greg Kroah-HartmanFrom: Jacob Keller <[email protected]>
[ Upstream commit d5b90e99e1d51b7b5d2b74fbc4c2db236a510913 ]
commit fdd41ec21e15 ("devlink: Return right error code in case of errors for region read") modified the region read code to report errors properly in unexpected cases.
In the case where the start_offset and ret_offset match, it unilaterally converted this into an error. This causes an issue for the "dump" version of the command. In this case, the devlink region dump will always report an invalid argument:
000000000000ffd0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 000000000000ffe0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff devlink answers: Invalid argument000000000000fff0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
This occurs because the expected flow for the dump is to return 0 after there is no further data.
The simplest fix would be to stop converting the error code to -EINVAL if start_offset == ret_offset. However, avoid unnecessary work by checking for when start_offset is larger than the region size and returning 0 upfront.
--- net/core/devlink.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/core/devlink.c +6 -0
@@ -3863,6 +3863,12 @@ static int devlink_nl_cmd_region_read_du goto out_unlock; } +/* return 0 if there is no further data to read */ +if (start_offset >= region->size) { + err =0 ; + goto out_unlock; + } + hdr =genlmsg_put (skb,NETLINK_CB (cb->skb).portid, cb->nlh->nlmsg_seq, &devlink_nl_family,NLM_F_ACK |NLM_F_MULTI ,DEVLINK_CMD_REGION_READ );
Greg Kroah-Hartman
maintainerPATCH 225/309 KVM: s390: do not clobber registers during guest reset/store status
In reply to Greg Kroah-HartmanFrom: Christian Borntraeger <[email protected]>
commit 55680890ea78be0df5e1384989f1be835043c084 upstream.
The initial CPU reset clobbers the userspace fpc and the store status ioctl clobbers the guest acrs + fpr. As these calls are only done via ioctl (and not via vcpu_run), no CPU context is loaded, so we can (and must) act directly on the sync regs, not on the thread context.
--- arch/s390/kvm/kvm-s390.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
arch/s390/kvm/kvm-s390.c +2 -4
@@ -2863,9 +2863,7 @@ static void kvm_s390_vcpu_initial_reset( vcpu->arch.sie_block->gcr[14 ] =CR14_UNUSED_32 |CR14_UNUSED_33 |CR14_EXTERNAL_DAMAGE_SUBMASK ; -/* make sure the new fpc will be lazily loaded */ -save_fpu_regs (); - current->thread.fpu.fpc =0 ; + vcpu->run->s.regs.fpc =0 ; vcpu->arch.sie_block->gbea =1 ; vcpu->arch.sie_block->pp =0 ; vcpu->arch.sie_block->fpf &= ~FPF_BPBC ;
@@ -4354,7 +4352,7 @@ long kvm_arch_vcpu_ioctl(struct file *fiswitch (ioctl) {case KVM_S390_STORE_STATUS : idx =srcu_read_lock (&vcpu->kvm->srcu); - r =kvm_s390_vcpu_store_status (vcpu, arg); + r =kvm_s390_store_status_unloaded (vcpu, arg);srcu_read_unlock (&vcpu->kvm->srcu, idx);break ;case KVM_S390_SET_INITIAL_PSW : {
Greg Kroah-Hartman
maintainerPATCH 227/309 mm/page_alloc.c: fix uninitialized memmaps on a partially populated last section
In reply to Greg Kroah-HartmanFrom: David Hildenbrand <[email protected]>
commit e822969cab48b786b64246aad1a3ba2a774f5d23 upstream.
Patch series "mm: fix max_pfn not falling on section boundary", v2.
Playing with different memory sizes for a x86-64 guest, I discovered that some memmaps (highest section if max_mem does not fall on the section boundary) are marked as being valid and online, but contain garbage. We have to properly initialize these memmaps.
Looking at /proc/kpageflags and friends, I found some more issues, partially related to this.
This patch (of 3):
If max_pfn is not aligned to a section boundary, we can easily run into BUGs. This can e.g., be triggered on x86-64 under QEMU by specifying a memory size that is not a multiple of 128MB (e.g., 4097MB, but also 4160MB). I was told that on real HW, we can easily have this scenario (esp., one of the main reasons sub-section hotadd of devmem was added).
The issue is, that we have a valid memmap (pfn_valid()) for the whole section, and the whole section will be marked "online". pfn_to_online_page() will succeed, but the memmap contains garbage.
E.g., doing a "./page-types -r -a 0x144001" when QEMU was started with "-m 4160M" - (see tools/vm/page-types.c):
[ 200.476376] BUG: unable to handle page fault for address: fffffffffffffffe [ 200.477500] #PF: supervisor read access in kernel mode [ 200.478334] #PF: error_code(0x0000) - not-present page [ 200.479076] PGD 59614067 P4D 59614067 PUD 59616067 PMD 0 [ 200.479557] Oops: 0000 [#4] SMP NOPTI [ 200.479875] CPU: 0 PID: 603 Comm: page-types Tainted: G D W 5.5.0-rc1-next-20191209 #93 [ 200.480646] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu4 [ 200.481648] RIP: 0010:stable_page_flags+0x4d/0x410 [ 200.482061] Code: f3 ff 41 89 c0 48 b8 00 00 00 00 01 00 00 00 45 84 c0 0f 85 cd 02 00 00 48 8b 53 08 48 8b 2b 48f [ 200.483644] RSP: 0018:ffffb139401cbe60 EFLAGS: 00010202 [ 200.484091] RAX: fffffffffffffffe RBX: fffffbeec5100040 RCX: 0000000000000000 [ 200.484697] RDX: 0000000000000001 RSI: ffffffff9535c7cd RDI: 0000000000000246 [ 200.485313] RBP: ffffffffffffffff R08: 0000000000000000 R09: 0000000000000000 [ 200.485917] R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000144001 [ 200.486523] R13: 00007ffd6ba55f48 R14: 00007ffd6ba55f40 R15: ffffb139401cbf08 [ 200.487130] FS: 00007f68df717580(0000) GS:ffff9ec77fa00000(0000) knlGS:0000000000000000 [ 200.487804] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 200.488295] CR2: fffffffffffffffe CR3: 0000000135d48000 CR4: 00000000000006f0 [ 200.488897] Call Trace: [ 200.489115] kpageflags_read+0xe9/0x140 [ 200.489447] proc_reg_read+0x3c/0x60 [ 200.489755] vfs_read+0xc2/0x170 [ 200.490037] ksys_pread64+0x65/0xa0 [ 200.490352] do_syscall_64+0x5c/0xa0 [ 200.490665] entry_SYSCALL_64_after_hwframe+0x49/0xbe
But it can be triggered much easier via "cat /proc/kpageflags > /dev/null" after cold/hot plugging a DIMM to such a system:
[root@localhost ~]# cat /proc/kpageflags > /dev/null
[ 111.517275] BUG: unable to handle page fault for address: fffffffffffffffe [ 111.517907] #PF: supervisor read access in kernel mode [ 111.518333] #PF: error_code(0x0000) - not-present page [ 111.518771] PGD a240e067 P4D a240e067 PUD a2410067 PMD 0
This patch fixes that by at least zero-ing out that memmap (so e.g., page_to_pfn() will not crash). Commit 907ec5fca3dc ("mm: zero remaining unavailable struct pages") tried to fix a similar issue, but forgot to consider this special case.
After this patch, there are still problems to solve. E.g., not all of these pages falling into a memory hole will actually get initialized later and set PageReserved - they are only zeroed out - but at least the immediate crashes are gone. A follow-up patch will take care of this.
--- mm/page_alloc.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
mm/page_alloc.c +12 -2
@@ -6933,7 +6933,8 @@ static u64 zero_pfn_range(unsigned long* This function also addresses a similar issue where struct pages are left * uninitialized because the physical address range is not covered by * memblock.memory or memblock.reserved. That could happen when memblock -* layout is manually configured via memmap=. +* layout is manually configured via memmap=, or when the highest physical +* address (max_pfn) does not end on a section boundary. */ void __init zero_resv_unavail (void ) {
@@ -6951,7 +6952,16 @@ void __init zero_resv_unavail(void) pgcnt +=zero_pfn_range (PFN_DOWN (next),PFN_UP (start)); next = end; } - pgcnt +=zero_pfn_range (PFN_DOWN (next), max_pfn); + +/* +* Early sections always have a fully populated memmap for the whole +* section - see pfn_valid(). If the last section has holes at the +* end and that section is marked "online", the memmap will be +* considered initialized. Make sure that memmap has a well defined +* state. +*/ + pgcnt +=zero_pfn_range (PFN_DOWN (next), +round_up (max_pfn,PAGES_PER_SECTION ));/* * Struct pages that do not have backing memory. This could be because
Greg Kroah-Hartman
maintainerPATCH 226/309 ocfs2: fix oops when writing cloned file
In reply to Greg Kroah-HartmanFrom: Gang He <[email protected]>
commit 2d797e9ff95ecbcf0a83d657928ed20579444857 upstream.
Writing a cloned file triggers a kernel oops and the user-space command process is also killed by the system. The bug can be reproduced stably via:
1) create a file under ocfs2 file system directory.
journalctl -b > aa.txt
2) create a cloned file for this file.
reflink aa.txt bb.txt
3) write the cloned file with dd command.
dd if=/dev/zero of=bb.txt bs=512 count=1 conv=notrunc
The dd command is killed by the kernel, then you can see the oops message via dmesg command.
[ 463.875404] BUG: kernel NULL pointer dereference, address: 0000000000000028 [ 463.875413] #PF: supervisor read access in kernel mode [ 463.875416] #PF: error_code(0x0000) - not-present page [ 463.875418] PGD 0 P4D 0 [ 463.875425] Oops: 0000 [#1] SMP PTI [ 463.875431] CPU: 1 PID: 2291 Comm: dd Tainted: G OE 5.3.16-2-default [ 463.875433] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 [ 463.875500] RIP: 0010:ocfs2_refcount_cow+0xa4/0x5d0 [ocfs2] [ 463.875505] Code: 06 89 6c 24 38 89 eb f6 44 24 3c 02 74 be 49 8b 47 28 [ 463.875508] RSP: 0018:ffffa2cb409dfce8 EFLAGS: 00010202 [ 463.875512] RAX: ffff8b1ebdca8000 RBX: 0000000000000001 RCX: ffff8b1eb73a9df0 [ 463.875515] RDX: 0000000000056a01 RSI: 0000000000000000 RDI: 0000000000000000 [ 463.875517] RBP: 0000000000000001 R08: ffff8b1eb73a9de0 R09: 0000000000000000 [ 463.875520] R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000000 [ 463.875522] R13: ffff8b1eb922f048 R14: 0000000000000000 R15: ffff8b1eb922f048 [ 463.875526] FS: 00007f8f44d15540(0000) GS:ffff8b1ebeb00000(0000) knlGS:0000000000000000 [ 463.875529] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 463.875532] CR2: 0000000000000028 CR3: 000000003c17a000 CR4: 00000000000006e0 [ 463.875546] Call Trace: [ 463.875596] ? ocfs2_inode_lock_full_nested+0x18b/0x960 [ocfs2] [ 463.875648] ocfs2_file_write_iter+0xaf8/0xc70 [ocfs2] [ 463.875672] new_sync_write+0x12d/0x1d0 [ 463.875688] vfs_write+0xad/0x1a0 [ 463.875697] ksys_write+0xa1/0xe0 [ 463.875710] do_syscall_64+0x60/0x1f0 [ 463.875743] entry_SYSCALL_64_after_hwframe+0x49/0xbe [ 463.875758] RIP: 0033:0x7f8f4482ed44 [ 463.875762] Code: 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 80 00 00 00 [ 463.875765] RSP: 002b:00007fff300a79d8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 [ 463.875769] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f8f4482ed44 [ 463.875771] RDX: 0000000000000200 RSI: 000055f771b5c000 RDI: 0000000000000001 [ 463.875774] RBP: 0000000000000200 R08: 00007f8f44af9c78 R09: 0000000000000003 [ 463.875776] R10: 000000000000089f R11: 0000000000000246 R12: 000055f771b5c000 [ 463.875779] R13: 0000000000000200 R14: 0000000000000000 R15: 000055f771b5c000
This regression problem was introduced by commit e74540b28556 ("ocfs2:
protect extent tree in ocfs2_prepare_inode_for_write()").
--- fs/ocfs2/file.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
fs/ocfs2/file.c +6 -8
@@ -2101,17 +2101,15 @@ static int ocfs2_is_io_unaligned(structstatic int ocfs2_inode_lock_for_extent_tree (struct inode *inode,struct buffer_head **di_bh,int meta_level, -int overwrite_io,int write_sem,int wait) {int ret =0 ;if (wait) - ret =ocfs2_inode_lock (inode,NULL , meta_level); + ret =ocfs2_inode_lock (inode, di_bh, meta_level);else - ret =ocfs2_try_inode_lock (inode, - overwrite_io ?NULL : di_bh, meta_level); + ret =ocfs2_try_inode_lock (inode, di_bh, meta_level);if (ret <0 ) goto out;
@@ -2136,6 +2134,7 @@ static int ocfs2_inode_lock_for_extent_t out_unlock:brelse (*di_bh); + *di_bh =NULL ;ocfs2_inode_unlock (inode, meta_level); out:return ret;
@@ -2177,7 +2176,6 @@ static int ocfs2_prepare_inode_for_write ret =ocfs2_inode_lock_for_extent_tree (inode, &di_bh, meta_level, - overwrite_io, write_sem, wait);if (ret <0 ) {
@@ -2233,13 +2231,13 @@ static int ocfs2_prepare_inode_for_write &di_bh, meta_level, write_sem); + meta_level =1 ; + write_sem =1 ; ret =ocfs2_inode_lock_for_extent_tree (inode, &di_bh, meta_level, - overwrite_io, -1 , + write_sem, wait); - write_sem =1 ;if (ret <0 ) {if (ret != -EAGAIN )mlog_errno (ret);
Greg Kroah-Hartman
maintainerPATCH 261/309 regulator: core: Add regulator_is_equal() helper
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
commit b059b7e0ec3208ff1e17cff6387d75a9fbab4e02 upstream.
Add regulator_is_equal() helper to compare whether two regulators are the same. This is useful for checking whether two separate regulators in a driver are actually the same supply.
--- drivers/regulator/helpers.c | 14 ++++++++++++++ include/linux/regulator/consumer.h | 7 +++++++ 2 files changed, 21 insertions(+)
drivers/regulator/helpers.c +14 -0
@@ -13,6 +13,8 @@#include <linux/regulator/driver.h> #include <linux/module.h> +#include "internal.h" +/** * regulator_is_enabled_regmap - standard is_enabled() for regmap users *
@@ -881,3 +883,15 @@ void regulator_bulk_set_supply_names(str consumers[i].supply = supply_names[i]; }EXPORT_SYMBOL_GPL (regulator_bulk_set_supply_names); + +/** +* regulator_is_equal - test whether two regulators are the same +* +* @reg1: first regulator to operate on +* @reg2: second regulator to operate on +*/ +bool regulator_is_equal (struct regulator *reg1,struct regulator *reg2) +{ +return reg1->rdev == reg2->rdev; +} +EXPORT_SYMBOL_GPL (regulator_is_equal);
include/linux/regulator/consumer.h +7 -0
@@ -287,6 +287,8 @@ void regulator_bulk_set_supply_names(strconst char *const *supply_names, unsigned int num_supplies); +bool regulator_is_equal (struct regulator *reg1,struct regulator *reg2); +#else /*
@@ -593,6 +595,11 @@ regulator_bulk_set_supply_names(struct r { } +static inline bool +regulator_is_equal (struct regulator *reg1,struct regulator *reg2); +{ +return false; +}#endif static inline int regulator_set_voltage_triplet(struct regulator *regulator,
Greg Kroah-Hartman
maintainerPATCH 259/309 ubi: Fix an error pointer dereference in error handling code
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
commit 5d3805af279c93ef49a64701f35254676d709622 upstream.
If "seen_pebs = init_seen(ubi);" fails then "seen_pebs" is an error pointer and we try to kfree() it which results in an Oops.
This patch re-arranges the error handling so now it only frees things which have been allocated successfully.
--- drivers/mtd/ubi/fastmap.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
drivers/mtd/ubi/fastmap.c +12 -9
@@ -1137,7 +1137,7 @@ static int ubi_write_fastmap(struct ubi_struct rb_node *tmp_rb;int ret, i, j, free_peb_count, used_peb_count, vol_count;int scrub_peb_count, erase_peb_count; -unsigned long *seen_pebs =NULL ; +unsigned long *seen_pebs; fm_raw = ubi->fm_buf;memset (ubi->fm_buf,0 , ubi->fm_size);
@@ -1151,7 +1151,7 @@ static int ubi_write_fastmap(struct ubi_ dvbuf =new_fm_vbuf (ubi,UBI_FM_DATA_VOLUME_ID );if (!dvbuf) { ret = -ENOMEM ; - goto out_kfree; + goto out_free_avbuf; } avhdr =ubi_get_vid_hdr (avbuf);
@@ -1160,7 +1160,7 @@ static int ubi_write_fastmap(struct ubi_ seen_pebs =init_seen (ubi);if (IS_ERR (seen_pebs)) { ret =PTR_ERR (seen_pebs); - goto out_kfree; + goto out_free_dvbuf; }spin_lock (&ubi->volumes_lock);
@@ -1328,7 +1328,7 @@ static int ubi_write_fastmap(struct ubi_ ret =ubi_io_write_vid_hdr (ubi, new_fm->e[0 ]->pnum, avbuf);if (ret) {ubi_err (ubi,"unable to write vid_hdr to fastmap SB!" ); - goto out_kfree; + goto out_free_seen; }for (i =0 ; i < new_fm->used_blocks; i++) {
@@ -1350,7 +1350,7 @@ static int ubi_write_fastmap(struct ubi_if (ret) {ubi_err (ubi,"unable to write vid_hdr to PEB %i!" , new_fm->e[i]->pnum); - goto out_kfree; + goto out_free_seen; } }
@@ -1360,7 +1360,7 @@ static int ubi_write_fastmap(struct ubi_if (ret) {ubi_err (ubi,"unable to write fastmap to PEB %i!" , new_fm->e[i]->pnum); - goto out_kfree; + goto out_free_seen; } }
@@ -1370,10 +1370,13 @@ static int ubi_write_fastmap(struct ubi_ ret =self_check_seen (ubi, seen_pebs);dbg_bld ("fastmap written!" ); -out_kfree: -ubi_free_vid_buf (avbuf); -ubi_free_vid_buf (dvbuf); +out_free_seen:free_seen (seen_pebs); +out_free_dvbuf: +ubi_free_vid_buf (dvbuf); +out_free_avbuf: +ubi_free_vid_buf (avbuf); + out:return ret; }
Greg Kroah-Hartman
maintainerPATCH 256/309 virtio-balloon: Fix memory leak when unloading while hinting is in progress
In reply to Greg Kroah-HartmanFrom: David Hildenbrand <[email protected]>
commit 6c22dc61c76b7e7d355f1697ba0ecf26d1334ba6 upstream.
When unloading the driver while hinting is in progress, we will not release the free page blocks back to MM, resulting in a memory leak.
--- drivers/virtio/virtio_balloon.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/virtio/virtio_balloon.c +4 -0
@@ -967,6 +967,10 @@ static void remove_common(struct virtio_leak_balloon (vb, vb->num_pages);update_balloon_size (vb); +/* There might be free pages that are being reported: release them. */ +if (virtio_has_feature (vb->vdev,VIRTIO_BALLOON_F_FREE_PAGE_HINT )) +return_free_pages_to_mm (vb,ULONG_MAX ); +/* Now we reset the device so we can clean up the queues. */ vb->vdev->config->reset (vb->vdev);
Greg Kroah-Hartman
maintainerPATCH 258/309 ubi: fastmap: Fix inverted logic in seen selfcheck
In reply to Greg Kroah-HartmanFrom: Sascha Hauer <[email protected]>
commit ef5aafb6e4e9942a28cd300bdcda21ce6cbaf045 upstream.
set_seen() sets the bit corresponding to the PEB number in the bitmap, so when self_check_seen() wants to find PEBs that haven't been seen we have to print the PEBs that have their bit cleared, not the ones which have it set.
--- drivers/mtd/ubi/fastmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/ubi/fastmap.c +1 -1
@@ -64,7 +64,7 @@ static int self_check_seen(struct ubi_dereturn 0 ;for (pnum =0 ; pnum < ubi->peb_count; pnum++) { -if (test_bit (pnum, seen) && ubi->lookuptbl[pnum]) { +if (!test_bit (pnum, seen) && ubi->lookuptbl[pnum]) {ubi_err (ubi,"self-check failed for PEB %d, fastmap didn't see it" , pnum); ret = -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 255/309 nfsd: Return the correct number of bytes written to the file
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
commit 09a80f2aef06b7c86143f5c14efd3485e0d2c139 upstream.
We must allow for the fact that iov_iter_write() could have returned a short write (e.g. if there was an ENOSPC issue).
--- fs/nfsd/vfs.c | 1 + 1 file changed, 1 insertion(+)
fs/nfsd/vfs.c +1 -0
@@ -975,6 +975,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, s host_err =vfs_iter_write (file, &iter, &pos, flags);if (host_err <0 ) goto out_nfserr; + *cnt = host_err; nfsdstats.io_write += *cnt;fsnotify_modify (file);
Greg Kroah-Hartman
maintainerPATCH 253/309 nfsd: fix delay timer on 32-bit architectures
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
commit 2561c92b12f4f4e386d453556685f75775c0938b upstream.
The nfsd4_cb_layout_done() function takes a 'time_t' value, multiplied by NSEC_PER_SEC*2 to get a nanosecond value.
This works fine on 64-bit architectures, but on 32-bit, any value over 1 second results in a signed integer overflow with unexpected results.
Cast one input to a 64-bit type in order to produce the same result that we have on 64-bit architectures, regarless of the type of nfsd4_lease.
--- fs/nfsd/nfs4layouts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/nfs4layouts.c +1 -1
@@ -675,7 +675,7 @@ nfsd4_cb_layout_done(struct nfsd4_callba/* Client gets 2 lease periods to return it */ cutoff =ktime_add_ns (task->tk_start, - nn->nfsd4_lease *NSEC_PER_SEC *2 ); + (u64 )nn->nfsd4_lease *NSEC_PER_SEC *2 );if (ktime_before (now, cutoff)) {rpc_delay (task,HZ /100 );/* 10 mili-seconds */
Greg Kroah-Hartman
maintainerPATCH 252/309 IB/core: Fix ODP get user pages flow
In reply to Greg Kroah-HartmanFrom: Yishai Hadas <[email protected]>
commit d07de8bd1709a80a282963ad7b2535148678a9e4 upstream.
The nr_pages argument of get_user_pages_remote() should always be in terms of the system page size, not the MR page size. Use PAGE_SIZE instead of umem_odp->page_shift.
--- drivers/infiniband/core/umem_odp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/umem_odp.c +1 -1
@@ -632,7 +632,7 @@ int ib_umem_odp_map_dma_pages(struct ib_while (bcnt >0 ) {const size_t gup_num_pages =min_t (size_t, - (bcnt +BIT (page_shift) -1 ) >> page_shift, +ALIGN (bcnt,PAGE_SIZE ) /PAGE_SIZE ,PAGE_SIZE /sizeof (struct page *));down_read (&owning_mm->mmap_sem);
Greg Kroah-Hartman
maintainerPATCH 251/309 IB/mlx5: Fix outstanding_pi index for GSI qps
In reply to Greg Kroah-HartmanFrom: Prabhath Sajeepa <[email protected]>
commit b5671afe5e39ed71e94eae788bacdcceec69db09 upstream.
Commit b0ffeb537f3a ("IB/mlx5: Fix iteration overrun in GSI qps") changed the way outstanding WRs are tracked for the GSI QP. But the fix did not cover the case when a call to ib_post_send() fails and updates index to track outstanding.
Since the prior commmit outstanding_pi should not be bounded otherwise the loop generate_completions() will fail.
--- drivers/infiniband/hw/mlx5/gsi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/hw/mlx5/gsi.c +1 -2
@@ -507,8 +507,7 @@ int mlx5_ib_gsi_post_send(struct ib_qp * ret =ib_post_send (tx_qp, &cur_wr.wr, bad_wr);if (ret) {/* Undo the effect of adding the outstanding wr */ - gsi->outstanding_pi = (gsi->outstanding_pi -1 ) % - gsi->cap.max_send_wr; + gsi->outstanding_pi--; goto err; }spin_unlock_irqrestore (&gsi->lock, flags);
Greg Kroah-Hartman
maintainerPATCH 250/309 net: tulip: Adjust indentation in {dmfe, uli526x}_init_module
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit fe06bf3d83ef0d92f35a24e03297172e92ce9ce3 upstream.
Clang warns:
../drivers/net/ethernet/dec/tulip/uli526x.c:1812:3: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
switch (mode) {
^
../drivers/net/ethernet/dec/tulip/uli526x.c:1809:2: note: previous
statement is here
if (cr6set)
^1 warning generated.
../drivers/net/ethernet/dec/tulip/dmfe.c:2217:3: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
switch(mode) {
^
../drivers/net/ethernet/dec/tulip/dmfe.c:2214:2: note: previous
statement is here
if (cr6set)
^1 warning generated.
This warning occurs because there is a space before the tab on these lines. Remove them so that the indentation is consistent with the Linux kernel coding style and clang no longer warns.
While we are here, adjust the default block in dmfe_init_module to have a proper break between the label and assignment and add a space between the switch and opening parentheses to avoid a checkpatch warning.
--- drivers/net/ethernet/dec/tulip/dmfe.c | 7 ++++--- drivers/net/ethernet/dec/tulip/uli526x.c | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/net/ethernet/dec/tulip/dmfe.c +4 -3
@@ -2214,15 +2214,16 @@ static int __init dmfe_init_module(void)if (cr6set) dmfe_cr6_user_set = cr6set; -switch (mode) { -case DMFE_10MHF : +switch (mode) { +case DMFE_10MHF :case DMFE_100MHF :case DMFE_10MFD :case DMFE_100MFD :case DMFE_1M_HPNA : dmfe_media_mode = mode;break ; -default :dmfe_media_mode =DMFE_AUTO ; +default : + dmfe_media_mode =DMFE_AUTO ;break ; }
drivers/net/ethernet/dec/tulip/uli526x.c +2 -2
@@ -1809,8 +1809,8 @@ static int __init uli526x_init_module(voif (cr6set) uli526x_cr6_user_set = cr6set; -switch (mode) { -case ULI526X_10MHF : +switch (mode) { +case ULI526X_10MHF :case ULI526X_100MHF :case ULI526X_10MFD :case ULI526X_100MFD :
Greg Kroah-Hartman
maintainerPATCH 249/309 net: smc911x: Adjust indentation in smc911x_phy_configure
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit 5c61e223004b3b5c3f1dd25718e979bc17a3b12d upstream.
Clang warns:
../drivers/net/ethernet/smsc/smc911x.c:939:3: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
if (!lp->ctl_rfduplx)
^
../drivers/net/ethernet/smsc/smc911x.c:936:2: note: previous statement
is here
if (lp->ctl_rspeed != 100)
^1 warning generated.
This warning occurs because there is a space after the tab on this line. Remove it so that the indentation is consistent with the Linux kernel coding style and clang no longer warns.
--- drivers/net/ethernet/smsc/smc911x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/smsc/smc911x.c +1 -1
@@ -936,7 +936,7 @@ static void smc911x_phy_configure(structif (lp->ctl_rspeed !=100 ) my_ad_caps &= ~(ADVERTISE_100BASE4 |ADVERTISE_100FULL |ADVERTISE_100HALF ); -if (!lp->ctl_rfduplx) +if (!lp->ctl_rfduplx) my_ad_caps &= ~(ADVERTISE_100FULL |ADVERTISE_10FULL );/* Update our Auto-Neg Advertisement Register */
Greg Kroah-Hartman
maintainerPATCH 222/309 KVM: x86: Handle TIF_NEED_FPU_LOAD in kvm_{load,put}_guest_fpu()
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit c9aef3b85f425d1f6635382ec210ee5a7ef55d7d upstream.
Handle TIF_NEED_FPU_LOAD similar to how fpu__copy() handles the flag when duplicating FPU state to a new task struct. TIF_NEED_FPU_LOAD can be set any time control is transferred out of KVM, be it voluntarily, e.g. if I/O is triggered during a KVM call to get_user_pages, or involuntarily, e.g. if softirq runs after an IRQ occurs. Therefore, KVM must account for TIF_NEED_FPU_LOAD whenever it is (potentially) accessing CPU FPU state.
--- arch/x86/kvm/x86.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
arch/x86/kvm/x86.c +17 -2
@@ -8493,12 +8493,26 @@ static int complete_emulated_mmio(structreturn 0 ; } +static void kvm_save_current_fpu (struct fpu *fpu) +{ +/* +* If the target FPU state is not resident in the CPU registers, just +* memcpy() from current, else save CPU state directly to the target. +*/ +if (test_thread_flag (TIF_NEED_FPU_LOAD )) +memcpy (&fpu->state, ¤t->thread.fpu.state, + fpu_kernel_xstate_size); +else +copy_fpregs_to_fpstate (fpu); +} +/* Swap (qemu) user FPU context for the guest FPU context. */ static void kvm_load_guest_fpu (struct kvm_vcpu *vcpu) {fpregs_lock (); -copy_fpregs_to_fpstate (vcpu->arch.user_fpu); +kvm_save_current_fpu (vcpu->arch.user_fpu); +/* PKRU is separately restored in kvm_x86_ops->run. */ __copy_kernel_to_fpregs (&vcpu->arch.guest_fpu->state, ~XFEATURE_MASK_PKRU );
@@ -8514,7 +8528,8 @@ static void kvm_put_guest_fpu(struct kvm {fpregs_lock (); -copy_fpregs_to_fpstate (vcpu->arch.guest_fpu); +kvm_save_current_fpu (vcpu->arch.guest_fpu); +copy_kernel_to_fpregs (&vcpu->arch.user_fpu->state);fpregs_mark_activate ();
Greg Kroah-Hartman
maintainerPATCH 248/309 ppp: Adjust indentation into ppp_async_input
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit 08cbc75f96029d3092664213a844a5e25523aa35 upstream.
Clang warns:
../drivers/net/ppp/ppp_async.c:877:6: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
ap->rpkt = skb;
^
../drivers/net/ppp/ppp_async.c:875:5: note: previous statement is here
if (!skb)
^1 warning generated.
This warning occurs because there is a space before the tab on this line. Clean up this entire block's indentation so that it is consistent with the Linux kernel coding style and clang no longer warns.
--- drivers/net/ppp/ppp_async.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/net/ppp/ppp_async.c +9 -9
@@ -874,15 +874,15 @@ ppp_async_input(struct asyncppp *ap, con skb =dev_alloc_skb (ap->mru +PPP_HDRLEN +2 );if (!skb) goto nomem; - ap->rpkt = skb; - } -if (skb->len ==0 ) { -/* Try to get the payload 4-byte aligned. -* This should match the -* PPP_ALLSTATIONS/PPP_UI/compressed tests in -* process_input_packet, but we do not have -* enough chars here to test buf[1] and buf[2]. -*/ + ap->rpkt = skb; + } +if (skb->len ==0 ) { +/* Try to get the payload 4-byte aligned. +* This should match the +* PPP_ALLSTATIONS/PPP_UI/compressed tests in +* process_input_packet, but we do not have +* enough chars here to test buf[1] and buf[2]. +*/ if (buf[0 ] !=PPP_ALLSTATIONS )skb_reserve (skb,2 + (buf[0 ] &1 )); }
Greg Kroah-Hartman
maintainerPATCH 246/309 drm: msm: mdp4: Adjust indentation in mdp4_dsi_encoder_enable
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit 251e3cb1418ff3f5061ee31335e346e852b16573 upstream.
Clang warns:
../drivers/gpu/drm/msm/disp/mdp4/mdp4_dsi_encoder.c:124:3: warning:
misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
mdp4_crtc_set_config(encoder->crtc,
^
../drivers/gpu/drm/msm/disp/mdp4/mdp4_dsi_encoder.c:121:2: note:
previous statement is here
if (mdp4_dsi_encoder->enabled)
^This warning occurs because there is a space after the tab on this line. Remove it so that the indentation is consistent with the Linux kernel coding style and clang no longer warns.
--- drivers/gpu/drm/msm/disp/mdp4/mdp4_dsi_encoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/mdp4/mdp4_dsi_encoder.c +1 -1
@@ -121,7 +121,7 @@ static void mdp4_dsi_encoder_enable(struif (mdp4_dsi_encoder->enabled)return ; - mdp4_crtc_set_config(encoder->crtc, + mdp4_crtc_set_config(encoder->crtc, MDP4_DMA_CONFIG_PACK_ALIGN_MSB | MDP4_DMA_CONFIG_DEFLKR_EN | MDP4_DMA_CONFIG_DITHER_EN |
Greg Kroah-Hartman
maintainerPATCH 50/309 mmc: sdhci-pci: Make function amd_sdhci_reset static
In reply to Greg Kroah-HartmanFrom: zhengbin <[email protected]>
commit 38413ce39a4bd908c02257cd2f9e0c92b27886f4 upstream.
Fix sparse warnings:
drivers/mmc/host/sdhci-pci-core.c:1599:6: warning: symbol 'amd_sdhci_reset' was not declared. Should it be static?
--- drivers/mmc/host/sdhci-pci-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci-pci-core.c +1 -1
@@ -1604,7 +1604,7 @@ static u32 sdhci_read_present_state(strureturn sdhci_readl (host,SDHCI_PRESENT_STATE ); } -void amd_sdhci_reset (struct sdhci_host *host,u8 mask) +static void amd_sdhci_reset (struct sdhci_host *host,u8 mask) {struct sdhci_pci_slot *slot =sdhci_priv (host);struct pci_dev *pdev = slot->chip->pdev;
Greg Kroah-Hartman
maintainerPATCH 244/309 ext2: Adjust indentation in ext2_fill_super
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit d9e9866803f7b6c3fdd35d345e97fb0b2908bbbc upstream.
Clang warns:
../fs/ext2/super.c:1076:3: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) -
^
../fs/ext2/super.c:1074:2: note: previous statement is here
if (EXT2_BLOCKS_PER_GROUP(sb) == 0)
^1 warning generated.
This warning occurs because there is a space before the tab on this line. Remove it so that the indentation is consistent with the Linux kernel coding style and clang no longer warns.
--- fs/ext2/super.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/ext2/super.c +3 -3
@@ -1082,9 +1082,9 @@ static int ext2_fill_super(struct super_if (EXT2_BLOCKS_PER_GROUP (sb) ==0 ) goto cantfind_ext2; - sbi->s_groups_count = ((le32_to_cpu (es->s_blocks_count) - -le32_to_cpu (es->s_first_data_block) -1 ) - /EXT2_BLOCKS_PER_GROUP (sb)) +1 ; + sbi->s_groups_count = ((le32_to_cpu (es->s_blocks_count) - +le32_to_cpu (es->s_first_data_block) -1 ) + /EXT2_BLOCKS_PER_GROUP (sb)) +1 ; db_count = (sbi->s_groups_count +EXT2_DESC_PER_BLOCK (sb) -1 ) /EXT2_DESC_PER_BLOCK (sb); sbi->s_group_desc = kmalloc_array (db_count,