4.18.19-stable review
Subsystems (8)
Greg Kroah-Hartman
maintainerPATCH 153/350 tpm: suppress transmit cmd error logs when TPM 1.2 is disabled/deactivated
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Javier Martinez Canillas <[email protected]>
[ Upstream commit 0d6d0d62d9505a9816716aa484ebd0b04c795063 ]
For TPM 1.2 chips the system setup utility allows to set the TPM device in one of the following states:
* Active: Security chip is functional
* Inactive: Security chip is visible, but is not functional
* Disabled: Security chip is hidden and is not functional
When choosing the "Inactive" state, the TPM 1.2 device is enumerated and registered, but sending TPM commands fail with either TPM_DEACTIVATED or TPM_DISABLED depending if the firmware deactivated or disabled the TPM.
Since these TPM 1.2 error codes don't have special treatment, inactivating the TPM leads to a very noisy kernel log buffer that shows messages like the following:
tpm_tis 00:05: 1.2 TPM (device-id 0x0, rev-id 78)
tpm tpm0: A TPM error (6) occurred attempting to read a pcr value tpm tpm0: TPM is disabled/deactivated (0x6)
tpm tpm0: A TPM error (6) occurred attempting get random tpm tpm0: A TPM error (6) occurred attempting to read a pcr value
ima: No TPM chip found, activating TPM-bypass! (rc=6) tpm tpm0: A TPM error (6) occurred attempting get random tpm tpm0: A TPM error (6) occurred attempting get random tpm tpm0: A TPM error (6) occurred attempting get random tpm tpm0: A TPM error (6) occurred attempting get random
Let's just suppress error log messages for the TPM_{DEACTIVATED,DISABLED} return codes, since this is expected when the TPM 1.2 is set to Inactive.
In that case the kernel log is cleaner and less confusing for users, i.e:
tpm_tis 00:05: 1.2 TPM (device-id 0x0, rev-id 78) tpm tpm0: TPM is disabled/deactivated (0x6)
ima: No TPM chip found, activating TPM-bypass! (rc=6)
--- drivers/char/tpm/tpm-interface.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm-interface.c +2 -1
@@ -664,7 +664,8 @@ ssize_t tpm_transmit_cmd(struct tpm_chipreturn len; err =be32_to_cpu (header->return_code); -if (err !=0 && desc) +if (err !=0 && err !=TPM_ERR_DISABLED && err !=TPM_ERR_DEACTIVATED + && desc)dev_err (&chip->dev,"A TPM error (%d) occurred %s\n" , err, desc);if (err)
Greg Kroah-Hartman
maintainerPATCH 154/350 f2fs: clear PageError on the read path
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jaegeuk Kim <[email protected]>
[ Upstream commit fb7d70db305a1446864227abf711b756568f8242 ]
When running fault injection test, I hit somewhat wrong behavior in f2fs_gc -> gc_data_segment():
0. fault injection generated some PageError'ed pages
1. gc_data_segment
-> f2fs_get_read_data_page(REQ_RAHEAD)
2. move_data_page
-> f2fs_get_lock_data_page()
-> f2f_get_read_data_page()
-> f2fs_submit_page_read()
-> submit_bio(READ)
-> return EIO due to PageError
-> fail to move data
--- fs/f2fs/data.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/f2fs/data.c +4 -1
@@ -80,7 +80,8 @@ static void __read_end_io(struct bio *bi/* PG_error was set if any post_read step failed */ if (bio->bi_status ||PageError (page)) {ClearPageUptodate (page); -SetPageError (page); +/* will re-read again later */ +ClearPageError (page); }else {SetPageUptodate (page); }
@@ -584,6 +585,7 @@ static int f2fs_submit_page_read(structbio_put (bio);return -EFAULT ; } +ClearPageError (page);__submit_bio (F2FS_I_SB (inode), bio,DATA );return 0 ; }
@@ -1528,6 +1530,7 @@ submit_and_realloc:if (bio_add_page (bio, page, blocksize,0 ) < blocksize) goto submit_and_realloc; +ClearPageError (page); last_block_in_bio = block_nr; goto next_page; set_error_page:
Greg Kroah-Hartman
maintainerPATCH 155/350 Drivers: hv: vmbus: Use cpumask_var_t for on-stack cpu mask
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dexuan Cui <[email protected]>
[ Upstream commit 25355252607ca288f329ee033f387764883393f6 ]
A cpumask structure on the stack can cause a warning with CONFIG_NR_CPUS=8192 (e.g. Ubuntu 16.04 and 18.04 use this):
drivers/hv//channel_mgmt.c: In function ‘init_vp_index’:
drivers/hv//channel_mgmt.c:702:1: warning: the frame size of 1032 bytes
is larger than 1024 bytes [-Wframe-larger-than=]
Nowadays it looks most distros enable CONFIG_CPUMASK_OFFSTACK=y, and hence we can work around the warning by using cpumask_var_t.
--- drivers/hv/channel_mgmt.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/hv/channel_mgmt.c +9 -5
@@ -606,16 +606,18 @@ static void init_vp_index(struct vmbus_cbool perf_chn = vmbus_devs[dev_type].perf_device;struct vmbus_channel *primary = channel->primary_channel;int next_node; -struct cpumask available_mask; +cpumask_var_t available_mask;struct cpumask *alloced_mask;if ((vmbus_proto_version ==VERSION_WS2008 ) || - (vmbus_proto_version ==VERSION_WIN7 ) || (!perf_chn)) { + (vmbus_proto_version ==VERSION_WIN7 ) || (!perf_chn) || + !alloc_cpumask_var (&available_mask,GFP_KERNEL )) {/* * Prior to win8, all channel interrupts are * delivered on cpu 0. * Also if the channel is not a performance critical * channel, bind it to cpu 0. +* In case alloc_cpumask_var() fails, bind it to cpu 0. */ channel->numa_node =0 ; channel->target_cpu =0 ;
@@ -653,7 +655,7 @@ static void init_vp_index(struct vmbus_ccpumask_clear (alloced_mask); } -cpumask_xor (&available_mask, alloced_mask, +cpumask_xor (available_mask, alloced_mask,cpumask_of_node (primary->numa_node)); cur_cpu =-1 ;
@@ -671,10 +673,10 @@ static void init_vp_index(struct vmbus_c }while (true) { - cur_cpu =cpumask_next (cur_cpu, &available_mask); + cur_cpu =cpumask_next (cur_cpu, available_mask);if (cur_cpu >= nr_cpu_ids) { cur_cpu =-1 ; -cpumask_copy (&available_mask, +cpumask_copy (available_mask,cpumask_of_node (primary->numa_node));continue ; }
@@ -704,6 +706,8 @@ static void init_vp_index(struct vmbus_c channel->target_cpu = cur_cpu; channel->target_vp =hv_cpu_number_to_vp_number (cur_cpu); + +free_cpumask_var (available_mask); }static void vmbus_wait_for_unload (void )
Greg Kroah-Hartman
maintainerPATCH 156/350 VMCI: Resource wildcard match fixed
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jorgen Hansen <[email protected]>
[ Upstream commit 11924ba5e671d6caef1516923e2bd8c72929a3fe ]
When adding a VMCI resource, the check for an existing entry would ignore that the new entry could be a wildcard. This could result in multiple resource entries that would match a given handle. One disastrous outcome of this is that the refcounting used to ensure that delayed callbacks for VMCI datagrams have run before the datagram is destroyed can be wrong, since the refcount could be increased on the duplicate entry. This in turn leads to a use after free bug. This issue was discovered by Hangbin Liu using KASAN and syzkaller.
--- drivers/misc/vmw_vmci/vmci_driver.c | 2 +- drivers/misc/vmw_vmci/vmci_resource.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/misc/vmw_vmci/vmci_driver.c +1 -1
@@ -113,5 +113,5 @@ module_exit(vmci_drv_exit);MODULE_AUTHOR ("VMware, Inc." );MODULE_DESCRIPTION ("VMware Virtual Machine Communication Interface." ); -MODULE_VERSION ("1.1.5.0-k" ); +MODULE_VERSION ("1.1.6.0-k" );MODULE_LICENSE ("GPL v2" );
drivers/misc/vmw_vmci/vmci_resource.c +2 -1
@@ -57,7 +57,8 @@ static struct vmci_resource *vmci_resourif (r->type == type && rid == handle.resource && - (cid == handle.context || cid ==VMCI_INVALID_ID )) { + (cid == handle.context || cid ==VMCI_INVALID_ID || + handle.context ==VMCI_INVALID_ID )) { resource = r;break ; }
Greg Kroah-Hartman
maintainerPATCH 157/350 PCI / ACPI: Enable wake automatically for power managed bridges
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mika Westerberg <[email protected]>
[ Upstream commit 6299cf9ec3985cac70bede8a855b5087b81a6640 ]
We enable power management automatically for bridges where pci_bridge_d3_possible() returns true. However, these bridges may have ACPI methods such as _DSW that need to be called before D3 entry. For example in Lenovo Thinkpad X1 Carbon 6th _DSW method is used to prepare D3cold for the PCIe root port hosting Thunderbolt chain. Because wake is not enabled _DSW method is never called and the port does not enter D3cold properly consuming more power than necessary.
Users can work this around by writing "enabled" to "wakeup" sysfs file under the device in question but that is not something an ordinary user is expected to do.
Since we already automatically enable power management for PCIe ports with ->bridge_d3 set extend that to enable wake for them as well, assuming the port has any ACPI wakeup related objects implemented in the namespace (adev->wakeup.flags.valid is true). This ensures the necessary ACPI methods get called at appropriate times and allows the root port in Thinkpad X1 Carbon 6th to go into D3cold.
--- drivers/pci/pci-acpi.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
drivers/pci/pci-acpi.c +15 -1
@@ -779,19 +779,33 @@ static void pci_acpi_setup(struct devicereturn ;device_set_wakeup_capable (dev, true); +/* +* For bridges that can do D3 we enable wake automatically (as +* we do for the power management itself in that case). The +* reason is that the bridge may have additional methods such as +* _DSW that need to be called. +*/ +if (pci_dev->bridge_d3) +device_wakeup_enable (dev); +acpi_pci_wakeup (pci_dev, false); }static void pci_acpi_cleanup (struct device *dev) {struct acpi_device *adev =ACPI_COMPANION (dev); +struct pci_dev *pci_dev =to_pci_dev (dev);if (!adev)return ;pci_acpi_remove_pm_notifier (adev); -if (adev->wakeup.flags.valid) +if (adev->wakeup.flags.valid) { +if (pci_dev->bridge_d3) +device_wakeup_disable (dev); +device_set_wakeup_capable (dev, false); + } }static bool pci_acpi_bus_match (struct device *dev)
Greg Kroah-Hartman
maintainerPATCH 158/350 xprtrdma: Reset credit grant properly after a disconnect
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit ef739b2175dde9c05594f768cb78149f1ce2ac36 ]
On a fresh connection, an RPC/RDMA client is supposed to send only one RPC Call until it gets a credit grant in the first RPC Reply from the server [RFC 8166, Section 3.3.3].
There is a bug in the Linux client's credit accounting mechanism introduced by commit e7ce710a8802 ("xprtrdma: Avoid deadlock when credit window is reset"). On connect, it simply dumps all pending RPC Calls onto the new connection.
Servers have been tolerant of this bad behavior. Currently no server implementation ever changes its credit grant over reconnects, and servers always repost enough Receives before connections are fully established.
To correct this issue, ensure that the client resets both the credit grant _and_ the congestion window when handling a reconnect.
--- net/sunrpc/xprtrdma/svc_rdma_backchannel.c | 1 + net/sunrpc/xprtrdma/transport.c | 6 ++++++ 2 files changed, 7 insertions(+)
net/sunrpc/xprtrdma/svc_rdma_backchannel.c +1 -0
@@ -248,6 +248,7 @@ static void xprt_rdma_bc_close(struct rpc_xprt *xprt) {dprintk ("svcrdma: %s: xprt %p\n" , __func__, xprt); + xprt->cwnd =RPC_CWNDSHIFT ; } static void
net/sunrpc/xprtrdma/transport.c +6 -0
@@ -468,6 +468,12 @@ xprt_rdma_close(struct rpc_xprt *xprt) xprt->reestablish_timeout =0 ;xprt_disconnect_done (xprt);rpcrdma_ep_disconnect (ep, ia); + +/* Prepare @xprt for the next connection by reinitializing +* its credit grant to one (see RFC 8166, Section 3.3.3). +*/ + r_xprt->rx_buf.rb_credits =1 ; + xprt->cwnd =RPC_CWNDSHIFT ; }/**
Greg Kroah-Hartman
maintainerPATCH 159/350 irqchip/pdc: Setup all edge interrupts as rising edge at GIC
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lina Iyer <[email protected]>
[ Upstream commit 7bae48b22c8d38c5cd50f52b6e15d134e2bb3935 ]
The PDC irqchp can convert a falling edge or level low interrupt to a rising edge or level high interrupt at the GIC. We just need to setup the GIC correctly. Set up the interrupt type for the IRQ_TYPE_EDGE_BOTH as IRQ_TYPE_EDGE_RISING at the GIC.
--- drivers/irqchip/qcom-pdc.c | 1 + 1 file changed, 1 insertion(+)
drivers/irqchip/qcom-pdc.c +1 -0
@@ -124,6 +124,7 @@ static int qcom_pdc_gic_set_type(structbreak ;case IRQ_TYPE_EDGE_BOTH : pdc_type =PDC_EDGE_DUAL ; + type =IRQ_TYPE_EDGE_RISING ;break ;case IRQ_TYPE_LEVEL_HIGH : pdc_type =PDC_LEVEL_HIGH ;
Greg Kroah-Hartman
maintainerPATCH 160/350 usb: dwc2: fix a race with external vbus supply
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabrice Gasnier <[email protected]>
[ Upstream commit 41ee1ea21052583eaf5487dfa0d0c907c9667548 ]
There's a race with root hub resume, when using external vbus supply. Root hub gets resumed, but runtime pm autosuspend runs as external vbus supply isn't enabled. So, host never exit from power down properly. Initialize vbus external supply before, rater that after hub resume.
vbus supply")
--- drivers/usb/dwc2/hcd.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/usb/dwc2/hcd.c +9 -1
@@ -4394,6 +4394,7 @@ static int _dwc2_hcd_start(struct usb_hcstruct dwc2_hsotg *hsotg =dwc2_hcd_to_hsotg (hcd);struct usb_bus *bus =hcd_to_bus (hcd);unsigned long flags; +int ret;dev_dbg (hsotg->dev,"DWC OTG HCD START\n" );
@@ -4409,6 +4410,13 @@ static int _dwc2_hcd_start(struct usb_hcdwc2_hcd_reinit (hsotg); +/* enable external vbus supply before resuming root hub */ +spin_unlock_irqrestore (&hsotg->lock, flags); + ret =dwc2_vbus_supply_init (hsotg); +if (ret) +return ret; +spin_lock_irqsave (&hsotg->lock, flags); +/* Initialize and connect root hub if one is not already attached */ if (bus->root_hub) {dev_dbg (hsotg->dev,"DWC OTG HCD Has Root Hub\n" );
@@ -4418,7 +4426,7 @@ static int _dwc2_hcd_start(struct usb_hcspin_unlock_irqrestore (&hsotg->lock, flags); -return dwc2_vbus_supply_init (hsotg); +return 0 ; }/*
Greg Kroah-Hartman
maintainerPATCH 161/350 usb: gadget: udc: atmel: handle at91sam9rl PMC
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandre Belloni <[email protected]>
[ Upstream commit bb80e4fa57eb75ebd64ae9be4155da6d12c1a997 ]
The at91sam9rl PMC is not quite the same as the at91sam9g45 one and now has its own compatible string. Add support for that.
--- drivers/usb/gadget/udc/atmel_usba_udc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/gadget/udc/atmel_usba_udc.c +2 -0
@@ -2018,6 +2018,8 @@ static struct usba_ep * atmel_udc_of_ini udc->errata = match->data; udc->pmc =syscon_regmap_lookup_by_compatible ("atmel,at91sam9g45-pmc" );if (IS_ERR (udc->pmc)) + udc->pmc =syscon_regmap_lookup_by_compatible ("atmel,at91sam9rl-pmc" ); +if (IS_ERR (udc->pmc)) udc->pmc =syscon_regmap_lookup_by_compatible ("atmel,at91sam9x5-pmc" );if (udc->errata &&IS_ERR (udc->pmc))return ERR_CAST (udc->pmc);
Greg Kroah-Hartman
maintainerPATCH 162/350 ext4: fix argument checking in EXT4_IOC_MOVE_EXT
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
[ Upstream commit f18b2b83a727a3db208308057d2c7945f368e625 ]
If the starting block number of either the source or destination file exceeds the EOF, EXT4_IOC_MOVE_EXT should return EINVAL.
Also fixed the helper function mext_check_coverage() so that if the logical block is beyond EOF, make it return immediately, instead of looping until the block number wraps all the away around. This takes long enough that if there are multiple threads trying to do pound on an the same inode doing non-sensical things, it can end up triggering the kernel's soft lockup detector.
--- fs/ext4/move_extent.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/ext4/move_extent.c +6 -2
@@ -518,9 +518,13 @@ mext_check_arguments(struct inode *orig_ orig_inode->i_ino, donor_inode->i_ino);return -EINVAL ; } -if (orig_eof < orig_start + *len -1 ) +if (orig_eof <= orig_start) + *len =0 ; +else if (orig_eof < orig_start + *len -1 ) *len = orig_eof - orig_start; -if (donor_eof < donor_start + *len -1 ) +if (donor_eof <= donor_start) + *len =0 ; +else if (donor_eof < donor_start + *len -1 ) *len = donor_eof - donor_start;if (!*len) { ext4_debug("ext4 move extent: len should not be 0 "
Greg Kroah-Hartman
maintainerPATCH 163/350 MD: fix invalid stored role for a disk
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shaohua Li <[email protected]>
[ Upstream commit d595567dc4f0c1d90685ec1e2e296e2cad2643ac ]
If we change the number of array's device after device is removed from array, then add the device back to array, we can see that device is added as active role instead of spare which we expected.
Please see the below link for details:
https://marc.info/?l=linux-raid&m=153736982015076&w=2
This is caused by that we prefer to use device's previous role which is recorded by saved_raid_disk, but we should respect the new number of conf->raid_disks since it could be changed after device is removed.
--- drivers/md/md.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/md/md.c +4 -0
@@ -1779,6 +1779,10 @@ static int super_1_validate(struct mddev }else set_bit (In_sync, &rdev->flags); rdev->raid_disk = role; +if (role >= mddev->raid_disks) { + rdev->saved_raid_disk =-1 ; + rdev->raid_disk =-1 ; + }break ; }if (sb->devflags & WriteMostly1)
Greg Kroah-Hartman
maintainerPATCH 164/350 nvmem: check the return value of nvmem_add_cells()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bartosz Golaszewski <[email protected]>
[ Upstream commit fa72d847d68d7833b77a4bef944cf2c5baf56f49 ]
This function can fail so check its return value in nvmem_register() and act accordingly.
--- drivers/nvmem/core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/nvmem/core.c +8 -2
@@ -518,11 +518,17 @@ struct nvmem_device *nvmem_register(cons goto err_device_del; } -if (config->cells) -nvmem_add_cells (nvmem, config->cells, config->ncells); +if (config->cells) { + rval =nvmem_add_cells (nvmem, config->cells, config->ncells); +if (rval) + goto err_teardown_compat; + }return nvmem; +err_teardown_compat: +if (config->compat) +device_remove_bin_file (nvmem->base_dev, &nvmem->eeprom); err_device_del:device_del (&nvmem->dev); err_put_device:
Greg Kroah-Hartman
maintainerPATCH 165/350 xhci: Avoid USB autosuspend when resuming USB2 ports.
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anshuman Gupta <[email protected]>
[ Upstream commit 330e2d61cdd58363eb5e66b2e72f76fe3c5492e0 ]
When USB bus host controller root hub resumes from autosuspend, it immediately tries to enter auto-suspend, but there can be a scenario when root hub is resuming its usb2 ports, in that particular case USB host controller auto suspend fails since it is busy to resuming its usb2 ports.
This makes multiple failed cycles of auto-suspend until all usb2 ports of host controller root hub do not resume.
This patch uses USB core framework usb_hcd_start_port_resume, usb_hcd_end_port_resume API's in order to autoresume/autosuspend root hub properly.
--- drivers/usb/host/xhci-hub.c | 5 +++++ drivers/usb/host/xhci-ring.c | 1 + 2 files changed, 6 insertions(+)
drivers/usb/host/xhci-hub.c +5 -0
@@ -900,6 +900,7 @@ static u32 xhci_get_port_status(struct uset_bit (wIndex, &bus_state->resuming_ports); bus_state->resume_done[wIndex] = timeout;mod_timer (&hcd->rh_timer, timeout); +usb_hcd_start_port_resume (&hcd->self, wIndex); }/* Has resume been signalled for USB_RESUME_TIME yet? */ } else if (time_after_eq(jiffies,
@@ -940,6 +941,7 @@ static u32 xhci_get_port_status(struct uclear_bit (wIndex, &bus_state->rexit_ports); } +usb_hcd_end_port_resume (&hcd->self, wIndex); bus_state->port_c_suspend |=1 << wIndex; bus_state->suspended_ports &= ~(1 << wIndex); }else {
@@ -962,6 +964,7 @@ static u32 xhci_get_port_status(struct u (raw_port_status & PORT_PLS_MASK) != XDEV_RESUME) { bus_state->resume_done[wIndex] =0 ;clear_bit (wIndex, &bus_state->resuming_ports); +usb_hcd_end_port_resume (&hcd->self, wIndex); }
@@ -1337,6 +1340,7 @@ int xhci_hub_control(struct usb_hcd *hcd goto error;set_bit (wIndex, &bus_state->resuming_ports); +usb_hcd_start_port_resume (&hcd->self, wIndex);xhci_set_link_state (xhci, ports[wIndex],XDEV_RESUME );spin_unlock_irqrestore (&xhci->lock, flags);
@@ -1345,6 +1349,7 @@ int xhci_hub_control(struct usb_hcd *hcdxhci_set_link_state (xhci, ports[wIndex],XDEV_U0 );clear_bit (wIndex, &bus_state->resuming_ports); +usb_hcd_end_port_resume (&hcd->self, wIndex); } bus_state->port_c_suspend |=1 << wIndex;
drivers/usb/host/xhci-ring.c +1 -0
@@ -1602,6 +1602,7 @@ static void handle_port_status(struct xhset_bit (HCD_FLAG_POLL_RH , &hcd->flags);mod_timer (&hcd->rh_timer, bus_state->resume_done[hcd_portnum]); +usb_hcd_start_port_resume (&hcd->self, hcd_portnum); bogus_port_status = true; } }
Greg Kroah-Hartman
maintainerPATCH 166/350 f2fs: fix to recover inodes crtime during POR
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 5cd1f387a13b5188b4edb4c834310302a85a6ea2 ]
Testcase to reproduce this bug:
1. mkfs.f2fs -O extra_attr -O inode_crtime /dev/sdd
2. mount -t f2fs /dev/sdd /mnt/f2fs
3. touch /mnt/f2fs/file
4. xfs_io -f /mnt/f2fs/file -c "fsync"
5. godown /mnt/f2fs
6. umount /mnt/f2fs
7. mount -t f2fs /dev/sdd /mnt/f2fs
8. xfs_io -f /mnt/f2fs/file -c "statx -r"
stat.btime.tv_sec = 0
stat.btime.tv_nsec = 0
This patch fixes to recover inode creation time fields during mount.
--- fs/f2fs/node.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/f2fs/node.c +7 -0
@@ -2379,6 +2379,13 @@ retry:F2FS_FITS_IN_INODE (src,le16_to_cpu (src->i_extra_isize), i_projid)) dst->i_projid = src->i_projid; + +if (f2fs_sb_has_inode_crtime (sbi->sb) && +F2FS_FITS_IN_INODE (src,le16_to_cpu (src->i_extra_isize), + i_crtime_nsec)) { + dst->i_crtime = src->i_crtime; + dst->i_crtime_nsec = src->i_crtime_nsec; + } } new_ni = old_ni;
Greg Kroah-Hartman
maintainerPATCH 167/350 f2fs: fix to recover inodes i_flags during POR
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 19c73a691ccf6fb2f12d4e9cf9830023966cec88 ]
Testcase to reproduce this bug:
1. mkfs.f2fs /dev/sdd
2. mount -t f2fs /dev/sdd /mnt/f2fs
3. touch /mnt/f2fs/file
4. sync
5. chattr +A /mnt/f2fs/file
6. xfs_io -f /mnt/f2fs/file -c "fsync"
7. godown /mnt/f2fs
8. umount /mnt/f2fs
9. mount -t f2fs /dev/sdd /mnt/f2fs
10. lsattr /mnt/f2fs/file
-----------------N- /mnt/f2fs/file
But actually, we expect the corrct result is:
-------A---------N- /mnt/f2fs/file
The reason is we didn't recover inode.i_flags field during mount, fix it.
--- fs/f2fs/recovery.c | 1 + 1 file changed, 1 insertion(+)
fs/f2fs/recovery.c +1 -0
@@ -221,6 +221,7 @@ static void recover_inode(struct inode * inode->i_mtime.tv_nsec =le32_to_cpu (raw->i_mtime_nsec);F2FS_I (inode)->i_advise = raw->i_advise; +F2FS_I (inode)->i_flags =le32_to_cpu (raw->i_flags);recover_inline_flags (inode, raw);
Greg Kroah-Hartman
maintainerPATCH 168/350 PCI/MSI: Warn and return error if driver enables MSI/MSI-X twice
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tonghao Zhang <[email protected]>
[ Upstream commit 4c1ef72e9b71a19fb405ebfcd37c0a5e16fa44ca ]
It is a serious driver defect to enable MSI or MSI-X more than once. Doing so may panic the kernel as in the stack trace below:
Call Trace:
sysfs_add_one+0xa5/0xd0
create_dir+0x7c/0xe0
sysfs_create_subdir+0x1c/0x20
internal_create_group+0x6d/0x290
sysfs_create_groups+0x4a/0xa0
populate_msi_sysfs+0x1cd/0x210
pci_enable_msix+0x31c/0x3e0
igbuio_pci_open+0x72/0x300 [igb_uio]
uio_open+0xcc/0x120 [uio]
chrdev_open+0xa1/0x1e0
[...]
do_sys_open+0xf3/0x1f0
SyS_open+0x1e/0x20
system_call_fastpath+0x16/0x1b
---[ end trace 11042e2848880209 ]---
Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: ffffffffa056b4faWe want to keep the WARN_ON() and stack trace so the driver can be fixed, but we can avoid the kernel panic by returning an error. We may still get warnings like this:
Call Trace:
pci_enable_msix+0x3c9/0x3e0
igbuio_pci_open+0x72/0x300 [igb_uio]
uio_open+0xcc/0x120 [uio]
chrdev_open+0xa1/0x1e0
[...]
do_sys_open+0xf3/0x1f0
SyS_open+0x1e/0x20
system_call_fastpath+0x16/0x1b
------------[ cut here ]------------
WARNING: at fs/sysfs/dir.c:526 sysfs_add_one+0xa5/0xd0()
sysfs: cannot create duplicate filename '/devices/pci0000:00/0000:00:03.0/0000:01:00.1/msi_irqs'--- drivers/pci/msi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/pci/msi.c +6 -3
@@ -958,7 +958,6 @@ static int __pci_enable_msix(struct pci_ } } } -WARN_ON (!!dev->msix_enabled);/* Check whether driver already requested for MSI irq */ if (dev->msi_enabled) {
@@ -1028,8 +1027,6 @@ static int __pci_enable_msi_range(structif (!pci_msi_supported (dev, minvec))return -EINVAL ; -WARN_ON (!!dev->msi_enabled); -/* Check whether driver already requested MSI-X irqs */ if (dev->msix_enabled) {pci_info (dev,"can't enable MSI (MSI-X already enabled)\n" );
@@ -1039,6 +1036,9 @@ static int __pci_enable_msi_range(structif (maxvec < minvec)return -ERANGE ; +if (WARN_ON_ONCE (dev->msi_enabled)) +return -EINVAL ; + nvec =pci_msi_vec_count (dev);if (nvec <0 )return nvec;
@@ -1087,6 +1087,9 @@ static int __pci_enable_msix_range(strucif (maxvec < minvec)return -ERANGE ; +if (WARN_ON_ONCE (dev->msix_enabled)) +return -EINVAL ; +for (;;) {if (affd) { nvec =irq_calc_affinity_vectors (minvec, nvec, affd);
Greg Kroah-Hartman
maintainerPATCH 169/350 coresight: etb10: Fix handling of perf mode
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suzuki K Poulose <[email protected]>
[ Upstream commit 987d1e8dcd370d96029a3d76a0031b043c4a69ae ]
If the ETB is already enabled in sysfs mode, the ETB reports success even if a perf mode is requested. Fix this by checking the requested mode.
--- drivers/hwtracing/coresight/coresight-etb10.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/hwtracing/coresight/coresight-etb10.c +4 -0
@@ -147,6 +147,10 @@ static int etb_enable(struct coresight_dif (val ==CS_MODE_PERF )return -EBUSY ; +/* Don't let perf disturb sysFS sessions */ +if (val ==CS_MODE_SYSFS && mode ==CS_MODE_PERF ) +return -EBUSY ; +/* Nothing to do, the tracer is already enabled. */ if (val ==CS_MODE_SYSFS ) goto out;
Greg Kroah-Hartman
maintainerPATCH 170/350 PCI: dwc: pci-dra7xx: Enable errata i870 for both EP and RC mode
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vignesh R <[email protected]>
[ Upstream commit 726d75a6d243bf6730da3216f3592503f6f0f588 ]
Errata i870 is applicable in both EP and RC mode. Therefore rename function dra7xx_pcie_ep_unaligned_memaccess(), that implements errata workaround, to dra7xx_pcie_unaligned_memaccess() and call it for both RC and EP. Make sure driver probe does not fail in case the workaround is not applied for RC mode in order to maintain DT backward compatibility.
--- drivers/pci/controller/dwc/pci-dra7xx.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/pci/controller/dwc/pci-dra7xx.c +8 -3
@@ -542,7 +542,7 @@ static const struct of_device_id of_dra7 };/* -* dra7xx_pcie_ep_unaligned_memaccess: workaround for AM572x/AM571x Errata i870 +* dra7xx_pcie_unaligned_memaccess: workaround for AM572x/AM571x Errata i870 * @dra7xx: the dra7xx device where the workaround should be applied * * Access to the PCIe slave port that are not 32-bit aligned will result
@@ -552,7 +552,7 @@ static const struct of_device_id of_dra7* * To avoid this issue set PCIE_SS1_AXI2OCP_LEGACY_MODE_ENABLE to 1. */ -static int dra7xx_pcie_ep_unaligned_memaccess (struct device *dev) +static int dra7xx_pcie_unaligned_memaccess (struct device *dev) {int ret;struct device_node *np = dev->of_node;
@@ -704,6 +704,11 @@ static int __init dra7xx_pcie_probe(strudra7xx_pcie_writel (dra7xx,PCIECTRL_TI_CONF_DEVICE_TYPE ,DEVICE_TYPE_RC ); + + ret =dra7xx_pcie_unaligned_memaccess (dev); +if (ret) +dev_err (dev,"WA for Errata i870 not applied\n" ); + ret =dra7xx_add_pcie_port (dra7xx, pdev);if (ret <0 ) goto err_gpio;
@@ -717,7 +722,7 @@ static int __init dra7xx_pcie_probe(strudra7xx_pcie_writel (dra7xx,PCIECTRL_TI_CONF_DEVICE_TYPE ,DEVICE_TYPE_EP ); - ret =dra7xx_pcie_ep_unaligned_memaccess (dev); + ret =dra7xx_pcie_unaligned_memaccess (dev);if (ret) goto err_gpio;
Greg Kroah-Hartman
maintainerPATCH 171/350 crypto: caam - fix implicit casts in endianness helpers
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Horia Geantă" <[email protected]>
[ Upstream commit aae733a3f46f5ef338fbdde26e14cbb205a23de0 ]
Fix the following sparse endianness warnings:
drivers/crypto/caam/regs.h:95:1: sparse: incorrect type in return expression (different base types) @@ expected unsigned int @@ got restricted __le32unsigned int @@drivers/crypto/caam/regs.h:95:1: expected unsigned intdrivers/crypto/caam/regs.h:95:1: got restricted __le32 [usertype] <noident>drivers/crypto/caam/regs.h:95:1: sparse: incorrect type in return expression (different base types) @@ expected unsigned int @@ got restricted __be32unsigned int @@drivers/crypto/caam/regs.h:95:1: expected unsigned intdrivers/crypto/caam/regs.h:95:1: got restricted __be32 [usertype] <noident>
drivers/crypto/caam/regs.h:92:1: sparse: cast to restricted __le32 drivers/crypto/caam/regs.h:92:1: sparse: cast to restricted __be32
--- drivers/crypto/caam/regs.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
drivers/crypto/caam/regs.h +14 -14
@@ -70,22 +70,22 @@extern bool caam_little_end;extern bool caam_imx; -#define caam_to_cpu (len) \ -static inline u##len caam##len ## _to_cpu(u##len val) \ -{ \ - if (caam_little_end) \ - return le##len ## _to_cpu(val); \ - else \ - return be##len ## _to_cpu(val); \ +#define caam_to_cpu (len) \ +static inline u##len caam##len ## _to_cpu(u##len val) \ +{ \ + if (caam_little_end) \ + return le##len ## _to_cpu((__force __le##len)val); \ + else \ + return be##len ## _to_cpu((__force __be##len)val); \ } -#define cpu_to_caam (len) \ -static inline u##len cpu_to_caam##len(u##len val) \ -{ \ - if (caam_little_end) \ - return cpu_to_le##len(val); \ - else \ - return cpu_to_be##len(val); \ +#define cpu_to_caam (len) \ +static inline u##len cpu_to_caam##len(u##len val) \ +{ \ + if (caam_little_end) \ + return (__force u##len)cpu_to_le##len(val); \ + else \ + return (__force u##len)cpu_to_be##len(val); \ }caam_to_cpu (16 )
Greg Kroah-Hartman
maintainerPATCH 172/350 usb: chipidea: Prevent unbalanced IRQ disable
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Loic Poulain <[email protected]>
[ Upstream commit 8b97d73c4d72a2abf58f8e49062a7ee1e5f1334e ]
The ChipIdea IRQ is disabled before scheduling the otg work and re-enabled on otg work completion. However if the job is already scheduled we have to undo the effect of disable_irq int order to balance the IRQ disable-depth value.
--- drivers/usb/chipidea/otg.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/chipidea/otg.h +2 -1
@@ -17,7 +17,8 @@ void ci_handle_vbus_change(struct ci_hdrstatic inline void ci_otg_queue_work (struct ci_hdrc *ci) {disable_irq_nosync (ci->irq); -queue_work (ci->wq, &ci->work); +if (queue_work (ci->wq, &ci->work) == false) +enable_irq (ci->irq); }#endif /* __DRIVERS_USB_CHIPIDEA_OTG_H */
Greg Kroah-Hartman
maintainerPATCH 173/350 Smack: ptrace capability use fixes
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Casey Schaufler <[email protected]>
[ Upstream commit dcb569cf6ac99ca899b8109c128b6ae52477a015 ]
This fixes a pair of problems in the Smack ptrace checks related to checking capabilities. In both cases, as reported by Lukasz Pawelczyk, the raw capability calls are used rather than the Smack wrapper that check addition restrictions. In one case, as reported by Jann Horn, the wrong task is being checked for capabilities.
--- security/smack/smack_lsm.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
security/smack/smack_lsm.c +10 -3
@@ -420,6 +420,7 @@ static int smk_ptrace_rule_check(structstruct smk_audit_info ad, *saip =NULL ;struct task_smack *tsp;struct smack_known *tracer_known; +const struct cred *tracercred;if ((mode &PTRACE_MODE_NOAUDIT ) ==0 ) {smk_ad_init (&ad, func,LSM_AUDIT_DATA_TASK );
@@ -428,7 +429,8 @@ static int smk_ptrace_rule_check(struct }rcu_read_lock (); - tsp =__task_cred (tracer)->security; + tracercred =__task_cred (tracer); + tsp = tracercred->security; tracer_known =smk_of_task (tsp); if ((mode & PTRACE_MODE_ATTACH) &&
@@ -438,7 +440,7 @@ static int smk_ptrace_rule_check(struct rc =0 ; else if (smack_ptrace_rule == SMACK_PTRACE_DRACONIAN) rc = -EACCES ; - else if (capable(CAP_SYS_PTRACE)) + else if (smack_privileged_cred(CAP_SYS_PTRACE, tracercred)) rc =0 ; else rc = -EACCES ;
@@ -1840,6 +1842,7 @@ static int smack_file_send_sigiotask(str {struct smack_known *skp;struct smack_known *tkp =smk_of_task (tsk->cred->security); +const struct cred *tcred;struct file *file;int rc;struct smk_audit_info ad;
@@ -1853,8 +1856,12 @@ static int smack_file_send_sigiotask(str skp = file->f_security; rc =smk_access (skp, tkp,MAY_DELIVER ,NULL ); rc =smk_bu_note ("sigiotask" , skp, tkp,MAY_DELIVER , rc); -if (rc !=0 &&has_capability (tsk,CAP_MAC_OVERRIDE )) + +rcu_read_lock (); + tcred =__task_cred (tsk); +if (rc !=0 &&smack_privileged_cred (CAP_MAC_OVERRIDE , tcred)) rc =0 ; +rcu_read_unlock ();smk_ad_init (&ad, __func__,LSM_AUDIT_DATA_TASK );smk_ad_setfield_u_tsk (&ad, tsk);
Greg Kroah-Hartman
maintainerPATCH 174/350 driver/dma/ioat: Call del_timer_sync() without holding prep_lock
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Waiman Long <[email protected]>
[ Upstream commit cfb03be6c7e8a1591285849c361d67b09f5149f7 ]
The following lockdep splat was observed:
[ 1222.241750] ======================================================
[ 1222.271301] WARNING: possible circular locking dependency detected
[ 1222.301060] 4.16.0-10.el8+5.x86_64+debug #1 Not tainted
[ 1222.326659] ------------------------------------------------------
[ 1222.356565] systemd-shutdow/1 is trying to acquire lock:
[ 1222.382660] ((&ioat_chan->timer)){+.-.}, at: [<00000000f71e1a28>] del_timer_sync+0x5/0xf0
[ 1222.422928]
[ 1222.422928] but task is already holding lock:
[ 1222.451743] (&(&ioat_chan->prep_lock)->rlock){+.-.}, at: [<000000008ea98b12>] ioat_shutdown+0x86/0x100 [ioatdma]
:
[ 1223.524987] Chain exists of:
[ 1223.524987] (&ioat_chan->timer) --> &(&ioat_chan->cleanup_lock)->rlock --> &(&ioat_chan->prep_lock)->rlock
[ 1223.524987]
[ 1223.594082] Possible unsafe locking scenario:
[ 1223.594082]
[ 1223.622630] CPU0 CPU1
[ 1223.645080] ---- ----
[ 1223.667404] lock(&(&ioat_chan->prep_lock)->rlock);
[ 1223.691535] lock(&(&ioat_chan->cleanup_lock)->rlock);
[ 1223.728657] lock(&(&ioat_chan->prep_lock)->rlock);
[ 1223.765122] lock((&ioat_chan->timer));
[ 1223.784095]
[ 1223.784095] *** DEADLOCK ***
[ 1223.784095]
[ 1223.813492] 4 locks held by systemd-shutdow/1:
[ 1223.834677] #0: (reboot_mutex){+.+.}, at: [<0000000056d33456>] SYSC_reboot+0x10f/0x300
[ 1223.873310] #1: (&dev->mutex){....}, at: [<00000000258dfdd7>] device_shutdown+0x1c8/0x660
[ 1223.913604] #2: (&dev->mutex){....}, at: [<0000000068331147>] device_shutdown+0x1d6/0x660
[ 1223.954000] #3: (&(&ioat_chan->prep_lock)->rlock){+.-.}, at: [<000000008ea98b12>] ioat_shutdown+0x86/0x100 [ioatdma]In the ioat_shutdown() function:
spin_lock_bh(&ioat_chan->prep_lock); set_bit(IOAT_CHAN_DOWN, &ioat_chan->state); del_timer_sync(&ioat_chan->timer); spin_unlock_bh(&ioat_chan->prep_lock);
According to the synchronization rule for the del_timer_sync() function, the caller must not hold locks which would prevent completion of the timer's handler.
The timer structure has its own lock that manages its synchronization. Setting the IOAT_CHAN_DOWN bit should prevent other CPUs from trying to use that device anyway, there is probably no need to call del_timer_sync() while holding the prep_lock. So the del_timer_sync() call is now moved outside of the prep_lock critical section to prevent the circular lock dependency.
--- drivers/dma/ioat/init.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/dma/ioat/init.c +8 -1
@@ -1205,8 +1205,15 @@ static void ioat_shutdown(struct pci_devspin_lock_bh (&ioat_chan->prep_lock);set_bit (IOAT_CHAN_DOWN , &ioat_chan->state); -del_timer_sync (&ioat_chan->timer);spin_unlock_bh (&ioat_chan->prep_lock); +/* +* Synchronization rule for del_timer_sync(): +* - The caller must not hold locks which would prevent +* completion of the timer's handler. +* So prep_lock cannot be held before calling it. +*/ +del_timer_sync (&ioat_chan->timer); +/* this should quiesce then reset */ ioat_reset_hw (ioat_chan); }
Greg Kroah-Hartman
maintainerPATCH 175/350 firmware: coreboot: Unmap ioregion after device population
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephen Boyd <[email protected]>
[ Upstream commit 20edec388277b62ddfddb8b2b376a937a2cd6d1b ]
Both callers of coreboot_table_init() ioremap the pointer that comes in but they don't unmap the memory on failure. Both of them also fail probe immediately with the return value of coreboot_table_init(), leaking a mapping when it fails. The mapping isn't necessary at all after devices are populated either, so we can just drop the mapping here when we exit the function. Let's do that to simplify the code a bit and plug the leak.
--- drivers/firmware/google/coreboot_table.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/firmware/google/coreboot_table.c +4 -3
@@ -110,7 +110,8 @@ int coreboot_table_init(struct device *dif (strncmp (header.signature,"LBIO" ,sizeof (header.signature))) {pr_warn ("coreboot_table: coreboot table missing or corrupt!\n" ); -return -ENODEV ; + ret = -ENODEV ; + goto out; } ptr_entry = (void *)ptr_header + header.header_bytes;
@@ -137,7 +138,8 @@ int coreboot_table_init(struct device *d ptr_entry += entry.size; } - +out: +iounmap (ptr);return ret; }EXPORT_SYMBOL (coreboot_table_init);
@@ -146,7 +148,6 @@ int coreboot_table_exit(void) {if (ptr_header) {bus_unregister (&coreboot_bus_type); -iounmap (ptr_header); ptr_header =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 176/350 IB/mlx5: Allow transition of DCI QP to reset
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Moni Shoua <[email protected]>
[ Upstream commit 99ed748e878a99c6c7b87bbec063eefd9e47cb42 ]
The transition is allowed from any state and the atrribute mask must be IB_QP_STATE.
--- drivers/infiniband/hw/mlx5/qp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/qp.c +3 -1
@@ -3264,7 +3264,9 @@ static bool modify_dci_qp_is_ok(enum ib_int req =IB_QP_STATE ;int opt =0 ; -if (cur_state ==IB_QPS_RESET && new_state ==IB_QPS_INIT ) { +if (new_state ==IB_QPS_RESET ) { +return is_valid_mask (attr_mask, req, opt); + }else if (cur_state ==IB_QPS_RESET && new_state ==IB_QPS_INIT ) { req |=IB_QP_PKEY_INDEX |IB_QP_PORT ;return is_valid_mask (attr_mask, req, opt); }else if (cur_state ==IB_QPS_INIT && new_state ==IB_QPS_INIT ) {
Greg Kroah-Hartman
maintainerPATCH 177/350 uio: ensure class is registered before devices
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandre Belloni <[email protected]>
[ Upstream commit ae61cf5b9913027c6953a79ed3894da4f47061bd ]
When both uio and the uio drivers are built in the kernel, it is possible for a driver to register devices before the uio class is registered.
This may result in a NULL pointer dereference later on in get_device_parent() when accessing the class glue_dirs spinlock.
The trace looks like that:
Unable to handle kernel NULL pointer dereference at virtual address 00000140 [...] [<ffff0000089cc234>] _raw_spin_lock+0x14/0x48 [<ffff0000084f56bc>] device_add+0x154/0x6a0 [<ffff0000084f5e48>] device_create_groups_vargs+0x120/0x128 [<ffff0000084f5edc>] device_create+0x54/0x60 [<ffff0000086e72c0>] __uio_register_device+0x120/0x4a8 [<ffff000008528b7c>] jaguar2_pci_probe+0x2d4/0x558 [<ffff0000083fc18c>] local_pci_probe+0x3c/0xb8 [<ffff0000083fd81c>] pci_device_probe+0x11c/0x180 [<ffff0000084f88bc>] driver_probe_device+0x22c/0x2d8 [<ffff0000084f8a24>] __driver_attach+0xbc/0xc0 [<ffff0000084f69fc>] bus_for_each_dev+0x4c/0x98 [<ffff0000084f81b8>] driver_attach+0x20/0x28 [<ffff0000084f7d08>] bus_add_driver+0x1b8/0x228 [<ffff0000084f93c0>] driver_register+0x60/0xf8 [<ffff0000083fb918>] __pci_register_driver+0x40/0x48
Return EPROBE_DEFER in that case so the driver can register the device later.
--- drivers/uio/uio.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/uio/uio.c +9 -0
@@ -275,6 +275,8 @@ static struct class uio_class = { .dev_groups = uio_groups, }; +bool uio_class_registered; +/* * device functions */
@@ -877,6 +879,9 @@ static int init_uio_class(void)printk (KERN_ERR "class_register failed for uio\n" ); goto err_class_register; } + + uio_class_registered = true; +return 0 ; err_class_register:
@@ -887,6 +892,7 @@ exit:static void release_uio_class (void ) { + uio_class_registered = false;class_unregister (&uio_class);uio_major_cleanup (); }
@@ -913,6 +919,9 @@ int __uio_register_device(struct modulestruct uio_device *idev;int ret =0 ; +if (!uio_class_registered) +return -EPROBE_DEFER ; +if (!parent || !info || !info->name || !info->version)return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 178/350 scsi: lpfc: Correct soft lockup when running mds diagnostics
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Smart <[email protected]>
[ Upstream commit 0ef01a2d95fd62bb4f536e7ce4d5e8e74b97a244 ]
When running an mds diagnostic that passes frames with the switch, soft lockups are detected. The driver is in a CQE processing loop and has sufficient amount of traffic that it never exits the ring processing routine, thus the "lockup".
Cap the number of elements in the work processing routine to 64 elements. This ensures that the cpu will be given up and the handler reschedule to process additional items.
--- drivers/scsi/lpfc/lpfc_sli.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/scsi/lpfc/lpfc_sli.c +7 -0
@@ -3790,6 +3790,7 @@ lpfc_sli_handle_slow_ring_event_s4(strucstruct hbq_dmabuf *dmabuf;struct lpfc_cq_event *cq_event;unsigned long iflag; +int count =0 ;spin_lock_irqsave (&phba->hbalock, iflag); phba->hba_flag &= ~HBA_SP_QUEUE_EVT ;
@@ -3811,16 +3812,22 @@ lpfc_sli_handle_slow_ring_event_s4(strucif (irspiocbq)lpfc_sli_sp_handle_rspiocb (phba, pring, irspiocbq); + count++;break ;case CQE_CODE_RECEIVE :case CQE_CODE_RECEIVE_V1 : dmabuf = container_of(cq_event, struct hbq_dmabuf, cq_event);lpfc_sli4_handle_received_buffer (phba, dmabuf); + count++;break ;default :break ; } + +/* Limit the number of events to 64 to avoid soft lockups */ +if (count ==64 ) +break ; } }
Greg Kroah-Hartman
maintainerPATCH 179/350 scsi: lpfc: Correct race with abort on completion path
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Smart <[email protected]>
[ Upstream commit ca7fb76e091f889cfda1287c07a9358f73832b39 ]
On io completion, the driver is taking an adapter wide lock and nulling the scsi command back pointer. The nulling of the back pointer is to signify the io was completed and the scsi_done() routine was called. However, the routine makes no check to see if the abort routine had done the same thing and possibly nulled the pointer. Thus it may doubly-complete the io.
Make the following mods:
- Check to make sure forward progress (call scsi_done()) only happens if the command pointer was non-null.
- As the taking of the lock, which is adapter wide, is very costly on a system under load, null the pointer using an xchg operation rather than under lock.
--- drivers/scsi/lpfc/lpfc_scsi.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/scsi/lpfc/lpfc_scsi.c +11 -3
@@ -4140,9 +4140,17 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba }lpfc_scsi_unprep_dma_buf (phba, lpfc_cmd); -spin_lock_irqsave (&phba->hbalock, flags); - lpfc_cmd->pCmd =NULL ; -spin_unlock_irqrestore (&phba->hbalock, flags); +/* If pCmd was set to NULL from abort path, do not call scsi_done */ +if (xchg (&lpfc_cmd->pCmd,NULL ) ==NULL ) { +lpfc_printf_vlog (vport,KERN_INFO ,LOG_FCP , +"0711 FCP cmd already NULL, sid: 0x%06x, " +"did: 0x%06x, oxid: 0x%04x\n" , + vport->fc_myDID, + (pnode) ? pnode->nlp_DID :0 , + phba->sli_rev ==LPFC_SLI_REV4 ? + lpfc_cmd->cur_iocbq.sli4_xritag :0xffff ); +return ; + }/* The sdev is not guaranteed to be valid post scsi_done upcall. */ cmd->scsi_done (cmd);
Greg Kroah-Hartman
maintainerPATCH 180/350 f2fs: avoid sleeping under spin_lock
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhikang Zhang <[email protected]>
[ Upstream commit b430f7263673eab1dc40e662ae3441a9619d16b8 ]
In the call trace below, we might sleep in function dput().
So in order to avoid sleeping under spin_lock, we remove f2fs_mark_inode_dirty_sync from __try_update_largest_extent && __drop_largest_extent.
BUG: sleeping function called from invalid context at fs/dcache.c:796 Call trace: dump_backtrace+0x0/0x3f4 show_stack+0x24/0x30 dump_stack+0xe0/0x138 ___might_sleep+0x2a8/0x2c8 __might_sleep+0x78/0x10c dput+0x7c/0x750 block_dump___mark_inode_dirty+0x120/0x17c __mark_inode_dirty+0x344/0x11f0 f2fs_mark_inode_dirty_sync+0x40/0x50 __insert_extent_tree+0x2e0/0x2f4 f2fs_update_extent_tree_range+0xcf4/0xde8 f2fs_update_extent_cache+0x114/0x12c f2fs_update_data_blkaddr+0x40/0x50 write_data_page+0x150/0x314 do_write_data_page+0x648/0x2318 __write_data_page+0xdb4/0x1640 f2fs_write_cache_pages+0x768/0xafc __f2fs_write_data_pages+0x590/0x1218 f2fs_write_data_pages+0x64/0x74 do_writepages+0x74/0xe4 __writeback_single_inode+0xdc/0x15f0 writeback_sb_inodes+0x574/0xc98 __writeback_inodes_wb+0x190/0x204 wb_writeback+0x730/0xf14 wb_check_old_data_flush+0x1bc/0x1c8 wb_workfn+0x554/0xf74 process_one_work+0x440/0x118c worker_thread+0xac/0x974 kthread+0x1a0/0x1c8 ret_from_fork+0x10/0x1c
--- fs/f2fs/extent_cache.c | 51 ++++++++++++++++++++++++++++++------------------- fs/f2fs/f2fs.h | 7 +++--- 2 files changed, 36 insertions(+), 22 deletions(-)
fs/f2fs/extent_cache.c +32 -19
@@ -308,14 +308,13 @@ static unsigned int __free_extent_tree(sreturn count -atomic_read (&et->node_cnt); } -static void __drop_largest_extent (struct inode *inode, +static void __drop_largest_extent (struct extent_tree *et,pgoff_t fofs,unsigned int len) { -struct extent_info *largest = &F2FS_I (inode)->extent_tree->largest; - -if (fofs < largest->fofs + largest->len && fofs + len > largest->fofs) { - largest->len =0 ; -f2fs_mark_inode_dirty_sync (inode, true); +if (fofs < et->largest.fofs + et->largest.len && + fofs + len > et->largest.fofs) { + et->largest.len =0 ; + et->largest_updated = true; } }
@@ -416,12 +415,11 @@ out:return ret; } -static struct extent_node *__try_merge_extent_node (struct inode *inode, +static struct extent_node *__try_merge_extent_node (struct f2fs_sb_info *sbi,struct extent_tree *et,struct extent_info *ei,struct extent_node *prev_ex,struct extent_node *next_ex) { -struct f2fs_sb_info *sbi =F2FS_I_SB (inode);struct extent_node *en =NULL ;if (prev_ex &&__is_back_mergeable (ei, &prev_ex->ei)) {
@@ -443,7 +441,7 @@ static struct extent_node *__try_merge_eif (!en)return NULL ; -__try_update_largest_extent (inode, et, en); +__try_update_largest_extent (et, en);spin_lock (&sbi->extent_lock);if (!list_empty (&en->list)) {
@@ -454,12 +452,11 @@ static struct extent_node *__try_merge_ereturn en; } -static struct extent_node *__insert_extent_tree (struct inode *inode, +static struct extent_node *__insert_extent_tree (struct f2fs_sb_info *sbi,struct extent_tree *et,struct extent_info *ei,struct rb_node **insert_p,struct rb_node *insert_parent) { -struct f2fs_sb_info *sbi =F2FS_I_SB (inode);struct rb_node **p;struct rb_node *parent =NULL ;struct extent_node *en =NULL ;
@@ -476,7 +473,7 @@ do_insert:if (!en)return NULL ; -__try_update_largest_extent (inode, et, en); +__try_update_largest_extent (et, en);/* update in global extent list */ spin_lock (&sbi->extent_lock);
@@ -497,6 +494,7 @@ static void f2fs_update_extent_tree_rangstruct rb_node **insert_p =NULL , *insert_parent =NULL ;unsigned int end = fofs + len;unsigned int pos = (unsigned int )fofs; +bool updated = false;if (!et)return ;
@@ -517,7 +515,7 @@ static void f2fs_update_extent_tree_rang* drop largest extent before lookup, in case it's already * been shrunk from extent tree */ -__drop_largest_extent (inode, fofs, len); +__drop_largest_extent (et, fofs, len);/* 1. lookup first extent node in range [fofs, fofs + len - 1] */ en = (struct extent_node *)f2fs_lookup_rb_tree_ret(&et->root,
@@ -550,7 +548,7 @@ static void f2fs_update_extent_tree_rangset_extent_info (&ei, end, end - dei.fofs + dei.blk, org_end - end); - en1 =__insert_extent_tree (inode, et, &ei, + en1 =__insert_extent_tree (sbi, et, &ei,NULL ,NULL ); next_en = en1; }else {
@@ -570,7 +568,7 @@ static void f2fs_update_extent_tree_rang }if (parts) -__try_update_largest_extent (inode, et, en); +__try_update_largest_extent (et, en);else __release_extent_node (sbi, et, en);
@@ -590,15 +588,16 @@ static void f2fs_update_extent_tree_rangif (blkaddr) {set_extent_info (&ei, fofs, blkaddr, len); -if (!__try_merge_extent_node (inode, et, &ei, prev_en, next_en)) -__insert_extent_tree (inode, et, &ei, +if (!__try_merge_extent_node (sbi, et, &ei, prev_en, next_en)) +__insert_extent_tree (sbi, et, &ei, insert_p, insert_parent);/* give up extent_cache, if split and small updates happen */ if (dei.len >=1 && prev.len <F2FS_MIN_EXTENT_LEN && et->largest.len <F2FS_MIN_EXTENT_LEN ) { -__drop_largest_extent (inode,0 ,UINT_MAX ); + et->largest.len =0 ; + et->largest_updated = true;set_inode_flag (inode,FI_NO_EXTENT ); } }
@@ -606,7 +605,15 @@ static void f2fs_update_extent_tree_rangif (is_inode_flag_set (inode,FI_NO_EXTENT ))__free_extent_tree (sbi, et); +if (et->largest_updated) { + et->largest_updated = false; + updated = true; + } +write_unlock (&et->lock); + +if (updated) +f2fs_mark_inode_dirty_sync (inode, true); }unsigned int f2fs_shrink_extent_tree (struct f2fs_sb_info *sbi,int nr_shrink)
@@ -705,6 +712,7 @@ void f2fs_drop_extent_tree(struct inode {struct f2fs_sb_info *sbi =F2FS_I_SB (inode);struct extent_tree *et =F2FS_I (inode)->extent_tree; +bool updated = false;if (!f2fs_may_extent_tree (inode))return ;
@@ -713,8 +721,13 @@ void f2fs_drop_extent_tree(struct inodewrite_lock (&et->lock);__free_extent_tree (sbi, et); -__drop_largest_extent (inode,0 ,UINT_MAX ); +if (et->largest.len) { + et->largest.len =0 ; + updated = true; + }write_unlock (&et->lock); +if (updated) +f2fs_mark_inode_dirty_sync (inode, true); }void f2fs_destroy_extent_tree (struct inode *inode)
fs/f2fs/f2fs.h +4 -3
@@ -556,6 +556,7 @@ struct extent_tree {struct list_head list;/* to be used by sbi->zombie_list */ rwlock_t lock;/* protect extent info rb-tree */ atomic_t node_cnt;/* # of extent node in rb-tree*/ +bool largest_updated;/* largest extent updated */ };/*
@@ -736,12 +737,12 @@ static inline bool __is_front_mergeable( }extern void f2fs_mark_inode_dirty_sync (struct inode *inode,bool sync); -static inline void __try_update_largest_extent (struct inode *inode, -struct extent_tree *et,struct extent_node *en) +static inline void __try_update_largest_extent (struct extent_tree *et, +struct extent_node *en) {if (en->ei.len > et->largest.len) { et->largest = en->ei; -f2fs_mark_inode_dirty_sync (inode, true); + et->largest_updated = true; } }
Greg Kroah-Hartman
maintainerPATCH 181/350 f2fs: report error if quota off error during umount
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yunlei He <[email protected]>
[ Upstream commit cda9cc595f0bb6ffa51a4efc4b6533dfa4039b4c ]
Now, we depend on fsck to ensure quota file data is ok, so we scan whole partition if checkpoint without umount flag. It's same for quota off error case, which may make quota file data inconsistent.
generic/019 reports below error:
__quota_error: 1160 callbacks suppressed
Quota error (device zram1): write_blk: dquota write failed
Quota error (device zram1): qtree_write_dquot: Error -28 occurred while creating quota Quota error (device zram1): write_blk: dquota write failed
Quota error (device zram1): qtree_write_dquot: Error -28 occurred while creating quota Quota error (device zram1): write_blk: dquota write failed
Quota error (device zram1): qtree_write_dquot: Error -28 occurred while creating quota Quota error (device zram1): write_blk: dquota write failed
Quota error (device zram1): qtree_write_dquot: Error -28 occurred while creating quota Quota error (device zram1): write_blk: dquota write failed
Quota error (device zram1): qtree_write_dquot: Error -28 occurred while creating quota
VFS: Busy inodes after unmount of zram1. Self-destruct in 5 seconds. Have a nice day...
If we failed in below path due to fail to write dquot block, we will miss to release quota inode, fix it.
- f2fs_put_super
- f2fs_quota_off_umount
- f2fs_quota_off
- f2fs_quota_sync <-- failed
- dquot_quota_off <-- missed to call
--- fs/f2fs/super.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
fs/f2fs/super.c +16 -3
@@ -1820,7 +1820,9 @@ static int f2fs_quota_off(struct super_bif (!inode || !igrab (inode))return dquot_quota_off (sb, type); -f2fs_quota_sync (sb, type); + err =f2fs_quota_sync (sb, type); +if (err) + goto out_put; err =dquot_quota_off (sb, type);if (err ||f2fs_sb_has_quota_ino (sb))
@@ -1839,9 +1841,20 @@ out_put:void f2fs_quota_off_umount (struct super_block *sb) {int type; +int err; -for (type =0 ; type <MAXQUOTAS ; type++) -f2fs_quota_off (sb, type); +for (type =0 ; type <MAXQUOTAS ; type++) { + err =f2fs_quota_off (sb, type); +if (err) { +int ret =dquot_quota_off (sb, type); + +f2fs_msg (sb,KERN_ERR , +"Fail to turn off disk quota " +"(type: %d, err: %d, ret:%d), Please " +"run fsck to fix it." , type, err, ret); +set_sbi_flag (F2FS_SB (sb),SBI_NEED_FSCK ); + } + } }static int f2fs_get_projid (struct inode *inode,kprojid_t *projid)
Greg Kroah-Hartman
maintainerPATCH 182/350 signal: Always deliver the kernels SIGKILL and SIGSTOP to a pid namespace init
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Eric W. Biederman" <[email protected]>
[ Upstream commit 3597dfe01d12f570bc739da67f857fd222a3ea66 ]
Instead of playing whack-a-mole and changing SEND_SIG_PRIV to SEND_SIG_FORCED throughout the kernel to ensure a pid namespace init gets signals sent by the kernel, stop allowing a pid namespace init to ignore SIGKILL or SIGSTOP sent by the kernel. A pid namespace init is only supposed to be able to ignore signals sent from itself and children with SIG_DFL.
--- kernel/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/signal.c +1 -1
@@ -1009,7 +1009,7 @@ static int __send_signal(int sig, struct result =TRACE_SIGNAL_IGNORED ;if (!prepare_signal (sig, t, - from_ancestor_ns || (info ==SEND_SIG_FORCED ))) + from_ancestor_ns || (info ==SEND_SIG_PRIV ) || (info ==SEND_SIG_FORCED ))) goto ret; pending = group ? &t->signal->shared_pending : &t->pending;
Greg Kroah-Hartman
maintainerPATCH 183/350 mfd: menelaus: Fix possible race condition and leak
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandre Belloni <[email protected]>
[ Upstream commit 9612f8f503804d2fd2f63aa6ba1e58bba4612d96 ]
The IRQ work is added before the struct rtc is allocated and registered, but this struct is used in the IRQ handler. This may lead to a NULL pointer dereference.
Switch to devm_rtc_allocate_device/rtc_register_device to allocate the rtc before calling menelaus_add_irq_work.
Also, this solves a possible leak as the RTC is never released.
--- drivers/mfd/menelaus.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/mfd/menelaus.c +9 -4
@@ -1094,6 +1094,7 @@ static void menelaus_rtc_alarm_work(strustatic inline void menelaus_rtc_init (struct menelaus_chip *m) {int alarm = (m->client->irq >0 ); +int err;/* assume 32KDETEN pin is pulled high */ if (!(menelaus_read_reg (MENELAUS_OSC_CTRL ) &0x80 )) {
@@ -1101,6 +1102,12 @@ static inline void menelaus_rtc_init(strreturn ; } + m->rtc =devm_rtc_allocate_device (&m->client->dev); +if (IS_ERR (m->rtc)) +return ; + + m->rtc->ops = &menelaus_rtc_ops; +/* support RTC alarm; it can issue wakeups */ if (alarm) { if (menelaus_add_irq_work(MENELAUS_RTCALM_IRQ,
@@ -1125,10 +1132,8 @@ static inline void menelaus_rtc_init(strmenelaus_write_reg (MENELAUS_RTC_CTRL , m->rtc_control); } - m->rtc =rtc_device_register (DRIVER_NAME , - &m->client->dev, - &menelaus_rtc_ops,THIS_MODULE ); -if (IS_ERR (m->rtc)) { + err =rtc_register_device (m->rtc); +if (err) {if (alarm) {menelaus_remove_irq_work (MENELAUS_RTCALM_IRQ );device_init_wakeup (&m->client->dev,0 );
Greg Kroah-Hartman
maintainerPATCH 184/350 dmaengine: dma-jz4780: Return error if not probed from DT
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Cercueil <[email protected]>
[ Upstream commit 54f919a04cf221bc1601d1193682d4379dacacbd ]
The driver calls clk_get() with the clock name set to NULL, which means that the driver could only work when probed from devicetree. From now on, we explicitly require the driver to be probed from devicetree.
--- drivers/dma/dma-jz4780.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/dma/dma-jz4780.c +5 -0
@@ -761,6 +761,11 @@ static int jz4780_dma_probe(struct platfstruct resource *res;int i, ret; +if (!dev->of_node) { +dev_err (dev,"This driver must be probed from devicetree\n" ); +return -EINVAL ; + } + jzdma =devm_kzalloc (dev,sizeof (*jzdma),GFP_KERNEL );if (!jzdma)return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 185/350 IB/rxe: fix for duplicate request processing and ack psns
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vijay Immanuel <[email protected]>
[ Upstream commit b97db58557f4aa6d9903f8e1deea6b3d1ed0ba43 ]
Don't reset the resp opcode for a replayed read response. The resp opcode could be in the middle of a write or send sequence, when the duplicate read request was received.
An example sequence is as follows:
- Receive read request for 12KB PSN 20. Transmit read response first, middle and last with PSNs 20,21,22.
- Receive write first PSN 23.
At this point the resp psn is 24 and resp opcode is write first.
- The sender notices that PSN 20 is dropped and retransmits. Receive read request for 12KB PSN 20. Transmit read response first, middle and last with PSNs 20,21,22. The resp opcode is set to -1, the resp psn remains 24.
- Receive write first PSN 23. This is processed by duplicate_request(). The resp opcode remains -1 and resp psn remains 24.
- Receive write middle PSN 24. check_op_seq() reports a missing first error since the resp opcode is -1.
When sending an ack for a duplicate send or write request, use the psn of the previous ack sent. Do not use the psn of a read response for the ack.
An example sequence is as follows:
- Receive write PSN 30. Transmit ACK for PSN 30.
- Receive read request 4KB PSN 31. Transmit read response with PSN 31. The resp psn is now 32.
- The sender notices that PSN 30 is dropped and retransmits. Receive write PSN 30. duplicate_request() sends an ACK with PSN 31. That is incorrect since PSN 31 was a read request.
--- drivers/infiniband/sw/rxe/rxe_resp.c | 8 ++++++-- drivers/infiniband/sw/rxe/rxe_verbs.h | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/infiniband/sw/rxe/rxe_resp.c +6 -2
@@ -682,6 +682,7 @@ static enum resp_states read_reply(strucrxe_advance_resp_resource (qp); res->type =RXE_READ_MASK ; + res->replay =0 ; res->read.va = qp->resp.va; res->read.va_org = qp->resp.va;
@@ -752,7 +753,8 @@ static enum resp_states read_reply(struc state =RESPST_DONE ; }else { qp->resp.res =NULL ; - qp->resp.opcode =-1 ; +if (!res->replay) + qp->resp.opcode =-1 ;if (psn_compare (res->cur_psn, qp->resp.psn) >=0 ) qp->resp.psn = res->cur_psn; state =RESPST_CLEANUP ;
@@ -814,6 +816,7 @@ static enum resp_states execute(struct r/* next expected psn, read handles this separately */ qp->resp.psn = (pkt->psn +1 ) &BTH_PSN_MASK ; + qp->resp.ack_psn = qp->resp.psn; qp->resp.opcode = pkt->opcode; qp->resp.status =IB_WC_SUCCESS ;
@@ -1060,7 +1063,7 @@ static enum resp_states duplicate_reques struct rxe_pkt_info *pkt) {enum resp_states rc; -u32 prev_psn = (qp->resp.psn -1 ) &BTH_PSN_MASK ; +u32 prev_psn = (qp->resp.ack_psn -1 ) &BTH_PSN_MASK ;if (pkt->mask &RXE_SEND_MASK || pkt->mask &RXE_WRITE_MASK ) {
@@ -1103,6 +1106,7 @@ static enum resp_states duplicate_reques res->state = (pkt->psn == res->first_psn) ? rdatm_res_state_new : rdatm_res_state_replay; + res->replay =1 ;/* Reset the resource, except length. */ res->read.va_org = iova;
drivers/infiniband/sw/rxe/rxe_verbs.h +2 -0
@@ -171,6 +171,7 @@ enum rdatm_res_state {struct resp_res {int type; +int replay;u32 first_psn;u32 last_psn;u32 cur_psn;
@@ -195,6 +196,7 @@ struct rxe_resp_info {enum rxe_qp_state state;u32 msn;u32 psn; +u32 ack_psn;int opcode;int drop_msg;int goto_error;
Greg Kroah-Hartman
maintainerPATCH 186/350 ALSA: hda: Check the non-cached stream buffers more explicitly
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 78c9be61c3a5cd9e2439fd27a5ffad73a81958c7 ]
Introduce a new flag, uc_buffer, to indicate that the controller requires the non-cached pages for stream buffers, either as a chip-specific requirement or specified via snoop=0 option. This improves the code-readability.
Also, this patch fixes the incorrect behavior for C-Media chip where the stream buffers were never handled as non-cached due to the check of driver_type even if you pass snoop=0 option.
--- sound/pci/hda/hda_controller.h | 1 + sound/pci/hda/hda_intel.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-)
sound/pci/hda/hda_controller.h +1 -0
@@ -160,6 +160,7 @@ struct azx { unsigned int msi:1; unsigned int probing:1; /* codec probing phase */ unsigned int snoop:1; + unsigned int uc_buffer:1; /* non-cached pages for stream buffers */ unsigned int align_buffer_size:1; unsigned int region_requested:1; unsigned int disabled:1; /* disabled by vga_switcheroo */
sound/pci/hda/hda_intel.c +8 -3
@@ -410,7 +410,7 @@ static void __mark_pages_wc(struct azx *#ifdef CONFIG_SND_DMA_SGBUF if (dmab->dev.type ==SNDRV_DMA_TYPE_DEV_SG ) {struct snd_sg_buf *sgbuf = dmab->private_data; -if (chip->driver_type ==AZX_DRIVER_CMEDIA ) +if (!chip->uc_buffer)return ;/* deal with only CORB/RIRB buffers */ if (on)set_pages_array_wc (sgbuf->page_table, sgbuf->pages);
@@ -1636,6 +1636,7 @@ static void azx_check_snoop_available(stdev_info (chip->card->dev,"Force to %s mode by module option\n" , snoop ?"snoop" :"non-snoop" ); chip->snoop = snoop; + chip->uc_buffer = !snoop;return ; }
@@ -1656,8 +1657,12 @@ static void azx_check_snoop_available(st snoop = false; chip->snoop = snoop; -if (!snoop) +if (!snoop) {dev_info (chip->card->dev,"Force to non-snoop mode\n" ); +/* C-Media requires non-cached pages only for CORB/RIRB */ +if (chip->driver_type !=AZX_DRIVER_CMEDIA ) + chip->uc_buffer = true; + } }static void azx_probe_work (struct work_struct *work)
@@ -2096,7 +2101,7 @@ static void pcm_mmap_prepare(struct snd_#ifdef CONFIG_X86 struct azx_pcm *apcm =snd_pcm_substream_chip (substream);struct azx *chip = apcm->chip; -if (!azx_snoop (chip) && chip->driver_type !=AZX_DRIVER_CMEDIA ) +if (chip->uc_buffer) area->vm_page_prot =pgprot_writecombine (area->vm_page_prot);#endif }
Greg Kroah-Hartman
maintainerPATCH 187/350 cpupower: Fix AMD Family 0x17 msr_pstate size
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prarit Bhargava <[email protected]>
[ Upstream commit 8c22e2f695920ebd94f9a53bcf2a65eb36d4dba1 ]
The msr_pstate data is only 63 bits long and should be 64 bits.
Add in the missing bit from res1 for AMD Family 0x17.
Reference: https://www.amd.com/system/files/TechDocs/54945_PPR_Family_17h_Models_00h-0Fh.pdf, page 138.
--- tools/power/cpupower/utils/helpers/amd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/power/cpupower/utils/helpers/amd.c +1 -1
@@ -33,7 +33,7 @@ union msr_pstate { unsigned vid:8; unsigned iddval:8; unsigned idddiv:2; - unsigned res1:30; + unsigned res1:31; unsigned en:1; } fam17h_bits;unsigned long long val;
Greg Kroah-Hartman
maintainerPATCH 188/350 Revert "f2fs: fix to clear PG_checked flag in set_page_dirty()"
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jaegeuk Kim <[email protected]>
commit 164a63fa6b384e30ceb96ed80bc7dc3379bc0960 upstream.
This reverts commit 66110abc4c931f879d70e83e1281f891699364bf.
If we clear the cold data flag out of the writeback flow, we can miscount -1 by end_io, which incurs a deadlock caused by all I/Os being blocked during heavy GC.
Balancing F2FS Async:
- IO (CP: 1, Data: -1, Flush: ( 0 0 1), Discard: ( ...
GC thread: IRQ
- move_data_page()
- set_page_dirty()
- clear_cold_data()
- f2fs_write_end_io()
- type = WB_DATA_TYPE(page); here, we get wrong type
- dec_page_count(sbi, type);
- f2fs_wait_on_page_writeback()
--- fs/f2fs/data.c | 4 ---- 1 file changed, 4 deletions(-)
fs/f2fs/data.c +0 -4
@@ -2501,10 +2501,6 @@ static int f2fs_set_data_page_dirty(struif (!PageUptodate (page))SetPageUptodate (page); -/* don't remain PG_checked flag which was set during GC */ -if (is_cold_data (page)) -clear_cold_data (page); -if (f2fs_is_atomic_file (inode) && !f2fs_is_commit_atomic_write (inode)) {if (!IS_ATOMIC_WRITTEN_PAGE (page)) {f2fs_register_inmem_page (inode, page);
Greg Kroah-Hartman
maintainerPATCH 189/350 f2fs: fix to recover cold bit of inode block during POR
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
commit ef2a007134b4eaa39264c885999f296577bc87d2 upstream.
Testcase to reproduce this bug:
1. mkfs.f2fs /dev/sdd
2. mount -t f2fs /dev/sdd /mnt/f2fs
3. touch /mnt/f2fs/file
4. sync
5. chattr +A /mnt/f2fs/file
6. xfs_io -f /mnt/f2fs/file -c "fsync"
7. godown /mnt/f2fs
8. umount /mnt/f2fs
9. mount -t f2fs /dev/sdd /mnt/f2fs
10. chattr -A /mnt/f2fs/file
11. xfs_io -f /mnt/f2fs/file -c "fsync"
12. umount /mnt/f2fs
13. mount -t f2fs /dev/sdd /mnt/f2fs
14. lsattr /mnt/f2fs/file
-----------------N- /mnt/f2fs/file
But actually, we expect the corrct result is:
-------A---------N- /mnt/f2fs/file
The reason is in step 9) we missed to recover cold bit flag in inode block, so later, in fsync, we will skip write inode block due to below condition check, result in lossing data in another SPOR.
f2fs_fsync_node_pages()
if (!IS_DNODE(page) || !is_cold_node(page)) continue;
Note that, I guess that some non-dir inode has already lost cold bit during POR, so in order to reenable recovery for those inode, let's try to recover cold bit in f2fs_iget() to save more fsynced data.
--- fs/f2fs/inode.c | 6 ++++++ fs/f2fs/node.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-)
fs/f2fs/inode.c +6 -0
@@ -287,6 +287,12 @@ static int do_read_inode(struct inode *iif (f2fs_has_inline_data (inode) && !f2fs_exist_data (inode))__recover_inline_status (inode, node_page); +/* try to recover cold bit for non-dir inode */ +if (!S_ISDIR (inode->i_mode) && !is_cold_node (node_page)) { +set_cold_node (node_page, false); +set_page_dirty (node_page); + } +/* get rdev by using inline_info */ __get_inode_rdev (inode, ri);
fs/f2fs/node.c +1 -1
@@ -2356,7 +2356,7 @@ retry:if (!PageUptodate (ipage))SetPageUptodate (ipage);fill_node_footer (ipage, ino, ino,0 , true); -set_cold_node (page, false); +set_cold_node (ipage, false); src =F2FS_INODE (page); dst =F2FS_INODE (ipage);
Greg Kroah-Hartman
maintainerPATCH 190/350 f2fs: fix to account IO correctly
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
commit 4c58ed076875f36dae0f240da1e25e99e5d4afb8 upstream.
Below race can cause reversed reference on dirty count, fix it by relocating __submit_bio() and inc_page_count().
Thread A Thread B
- f2fs_inplace_write_data
- f2fs_submit_page_bio
- __submit_bio
- f2fs_write_end_io
- dec_page_count
- inc_page_count
--- fs/f2fs/data.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/data.c +2 -2
@@ -460,10 +460,10 @@ int f2fs_submit_page_bio(struct f2fs_io_bio_set_op_attrs (bio, fio->op, fio->op_flags); -__submit_bio (fio->sbi, bio, fio->type); -if (!is_read_io (fio->op))inc_page_count (fio->sbi,WB_DATA_TYPE (fio->page)); + +__submit_bio (fio->sbi, bio, fio->type);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 191/350 OPP: Free OPP table properly on performance state irregularities
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viresh Kumar <[email protected]>
commit 2fbb8670b4ff4454f1c0de510f788d737edc4b90 upstream.
The OPP table was freed, but not the individual OPPs which is done from _dev_pm_opp_remove_table(). Fix it by calling _dev_pm_opp_remove_table() as well.
--- drivers/opp/of.c | 1 + 1 file changed, 1 insertion(+)
drivers/opp/of.c +1 -0
@@ -425,6 +425,7 @@ static int _of_add_opp_table_v2(struct ddev_err (dev,"Not all nodes have performance state set (%d: %d)\n" , count, pstate_count); ret = -ENOENT ; +_dev_pm_opp_remove_table (opp_table, dev, false); goto put_opp_table; }
Greg Kroah-Hartman
maintainerPATCH 192/350 arm: dts: exynos: Add missing cooling device properties for CPUs
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viresh Kumar <[email protected]>
commit 672f33198bee21ee91e6af2cb8f67cfc8bc97ec1 upstream.
The cooling device properties, like "#cooling-cells" and "dynamic-power-coefficient", should either be present for all the CPUs of a cluster or none. If these are present only for a subset of CPUs of a cluster then things will start falling apart as soon as the CPUs are brought online in a different order. For example, this will happen because the operating system looks for such properties in the CPU node it is trying to bring up, so that it can register a cooling device.
Add such missing properties.
Fix other missing properties (clocks, OPP, clock latency) as well to make it all work.
--- arch/arm/boot/dts/exynos3250.dtsi | 16 ++++++++++++++++ arch/arm/boot/dts/exynos4210.dtsi | 13 +++++++++++++ arch/arm/boot/dts/exynos4412.dtsi | 9 +++++++++ arch/arm/boot/dts/exynos5250.dtsi | 23 +++++++++++++++++++++++ 4 files changed, 61 insertions(+)
arch/arm/boot/dts/exynos3250.dtsi +16 -0
@@ -78,6 +78,22 @@ compatible = "arm,cortex-a7"; reg = <1>; clock-frequency = <1000000000>; + clocks = <&cmu CLK_ARM_CLK>; + clock-names = "cpu"; + #cooling-cells = <2>; + + operating-points = < + 1000000 1150000 + 900000 1112500 + 800000 1075000 + 700000 1037500 + 600000 1000000 + 500000 962500 + 400000 925000 + 300000 887500 + 200000 850000 + 100000 850000 + >; }; };
arch/arm/boot/dts/exynos4210.dtsi +13 -0
@@ -55,6 +55,19 @@ device_type = "cpu"; compatible = "arm,cortex-a9"; reg = <0x901>; + clocks = <&clock CLK_ARM_CLK>; + clock-names = "cpu"; + clock-latency = <160000>; + + operating-points = < + 1200000 1250000 + 1000000 1150000 + 800000 1075000 + 500000 975000 + 400000 975000 + 200000 950000 + >; + #cooling-cells = <2>; /* min followed by max */ }; };
arch/arm/boot/dts/exynos4412.dtsi +9 -0
@@ -49,21 +49,30 @@ device_type = "cpu"; compatible = "arm,cortex-a9"; reg = <0xA01>; + clocks = <&clock CLK_ARM_CLK>; + clock-names = "cpu"; operating-points-v2 = <&cpu0_opp_table>; + #cooling-cells = <2>; /* min followed by max */ }; cpu@a02 { device_type = "cpu"; compatible = "arm,cortex-a9"; reg = <0xA02>; + clocks = <&clock CLK_ARM_CLK>; + clock-names = "cpu"; operating-points-v2 = <&cpu0_opp_table>; + #cooling-cells = <2>; /* min followed by max */ }; cpu@a03 { device_type = "cpu"; compatible = "arm,cortex-a9"; reg = <0xA03>; + clocks = <&clock CLK_ARM_CLK>; + clock-names = "cpu"; operating-points-v2 = <&cpu0_opp_table>; + #cooling-cells = <2>; /* min followed by max */ }; };
arch/arm/boot/dts/exynos5250.dtsi +23 -0
@@ -84,6 +84,29 @@ compatible = "arm,cortex-a15"; reg = <1>; clock-frequency = <1700000000>; + clocks = <&clock CLK_ARM_CLK>; + clock-names = "cpu"; + clock-latency = <140000>; + + operating-points = < + 1700000 1300000 + 1600000 1250000 + 1500000 1225000 + 1400000 1200000 + 1300000 1150000 + 1200000 1125000 + 1100000 1100000 + 1000000 1075000 + 900000 1050000 + 800000 1025000 + 700000 1012500 + 600000 1000000 + 500000 975000 + 400000 950000 + 300000 937500 + 200000 925000 + >; + #cooling-cells = <2>; /* min followed by max */ }; };
Greg Kroah-Hartman
maintainerPATCH 193/350 ARM: dts: exynos: Convert exynos5250.dtsi to opp-v2 bindings
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
commit eb9e16d8573e243f8175647f851eb5085dbe97a4 upstream.
Convert Exynos5250 to OPP-v2 bindings. This is a preparation to add proper support for suspend operation point, which cannot be marked in opp-v1.
--- arch/arm/boot/dts/exynos5250.dtsi | 130 +++++++++++++++++++++++++------------- 1 file changed, 88 insertions(+), 42 deletions(-)
arch/arm/boot/dts/exynos5250.dtsi +88 -42
@@ -54,62 +54,108 @@ device_type = "cpu"; compatible = "arm,cortex-a15"; reg = <0>; - clock-frequency = <1700000000>; clocks = <&clock CLK_ARM_CLK>; clock-names = "cpu"; - clock-latency = <140000>; - - operating-points = < - 1700000 1300000 - 1600000 1250000 - 1500000 1225000 - 1400000 1200000 - 1300000 1150000 - 1200000 1125000 - 1100000 1100000 - 1000000 1075000 - 900000 1050000 - 800000 1025000 - 700000 1012500 - 600000 1000000 - 500000 975000 - 400000 950000 - 300000 937500 - 200000 925000 - >; + operating-points-v2 = <&cpu0_opp_table>; #cooling-cells = <2>; /* min followed by max */ }; cpu@1 { device_type = "cpu"; compatible = "arm,cortex-a15"; reg = <1>; - clock-frequency = <1700000000>; clocks = <&clock CLK_ARM_CLK>; clock-names = "cpu"; - clock-latency = <140000>; - - operating-points = < - 1700000 1300000 - 1600000 1250000 - 1500000 1225000 - 1400000 1200000 - 1300000 1150000 - 1200000 1125000 - 1100000 1100000 - 1000000 1075000 - 900000 1050000 - 800000 1025000 - 700000 1012500 - 600000 1000000 - 500000 975000 - 400000 950000 - 300000 937500 - 200000 925000 - >; + operating-points-v2 = <&cpu0_opp_table>; #cooling-cells = <2>; /* min followed by max */ }; }; + cpu0_opp_table: opp_table0 { + compatible = "operating-points-v2"; + opp-shared; + + opp-200000000 { + opp-hz = /bits/ 64 <200000000>; + opp-microvolt = <925000>; + clock-latency-ns = <140000>; + }; + opp-300000000 { + opp-hz = /bits/ 64 <300000000>; + opp-microvolt = <937500>; + clock-latency-ns = <140000>; + }; + opp-400000000 { + opp-hz = /bits/ 64 <400000000>; + opp-microvolt = <950000>; + clock-latency-ns = <140000>; + }; + opp-500000000 { + opp-hz = /bits/ 64 <500000000>; + opp-microvolt = <975000>; + clock-latency-ns = <140000>; + }; + opp-600000000 { + opp-hz = /bits/ 64 <600000000>; + opp-microvolt = <1000000>; + clock-latency-ns = <140000>; + }; + opp-700000000 { + opp-hz = /bits/ 64 <700000000>; + opp-microvolt = <1012500>; + clock-latency-ns = <140000>; + }; + opp-800000000 { + opp-hz = /bits/ 64 <800000000>; + opp-microvolt = <1025000>; + clock-latency-ns = <140000>; + }; + opp-900000000 { + opp-hz = /bits/ 64 <900000000>; + opp-microvolt = <1050000>; + clock-latency-ns = <140000>; + }; + opp-1000000000 { + opp-hz = /bits/ 64 <1000000000>; + opp-microvolt = <1075000>; + clock-latency-ns = <140000>; + }; + opp-1100000000 { + opp-hz = /bits/ 64 <1100000000>; + opp-microvolt = <1100000>; + clock-latency-ns = <140000>; + }; + opp-1200000000 { + opp-hz = /bits/ 64 <1200000000>; + opp-microvolt = <1125000>; + clock-latency-ns = <140000>; + }; + opp-1300000000 { + opp-hz = /bits/ 64 <1300000000>; + opp-microvolt = <1150000>; + clock-latency-ns = <140000>; + }; + opp-1400000000 { + opp-hz = /bits/ 64 <1400000000>; + opp-microvolt = <1200000>; + clock-latency-ns = <140000>; + }; + opp-1500000000 { + opp-hz = /bits/ 64 <1500000000>; + opp-microvolt = <1225000>; + clock-latency-ns = <140000>; + }; + opp-1600000000 { + opp-hz = /bits/ 64 <1600000000>; + opp-microvolt = <1250000>; + clock-latency-ns = <140000>; + }; + opp-1700000000 { + opp-hz = /bits/ 64 <1700000000>; + opp-microvolt = <1300000>; + clock-latency-ns = <140000>; + }; + }; + soc: soc { sysram@2020000 { compatible = "mmio-sram";
Greg Kroah-Hartman
maintainerPATCH 194/350 ARM: dts: exynos: Mark 1 GHz CPU OPP as suspend OPP on Exynos5250
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
commit 645b23da6f8b47f295fa87051335d41d139717a5 upstream.
1 GHz CPU OPP is the default boot value for the Exynos5250 SOC, so mark it as suspend OPP. This fixes suspend/resume on Samsung Exynos5250 Snow Chomebook, which was broken since switching to generic cpufreq-dt driver in v4.3.
--- arch/arm/boot/dts/exynos5250.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/exynos5250.dtsi +1 -0
@@ -118,6 +118,7 @@ opp-hz = /bits/ 64 <1000000000>; opp-microvolt = <1075000>; clock-latency-ns = <140000>; + opp-suspend; }; opp-1100000000 { opp-hz = /bits/ 64 <1100000000>;
Greg Kroah-Hartman
maintainerPATCH 195/350 xen-swiotlb: use actually allocated size on check physical continuous
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Jin <[email protected]>
commit 7250f422da0480d8512b756640f131b9b893ccda upstream.
xen_swiotlb_{alloc,free}_coherent() allocate/free memory based on the order of the pages and not size argument (bytes). This is inconsistent with range_straddles_page_boundary and memset which use the 'size' value, which may lead to not exchanging memory with Xen (range_straddles_page_boundary() returned true). And then the call to xen_swiotlb_free_coherent() would actually try to exchange the memory with Xen, leading to the kernel hitting an BUG (as the hypercall returned an error).
This patch fixes it by making the 'size' variable be of the same size as the amount of memory allocated.
--- drivers/xen/swiotlb-xen.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/xen/swiotlb-xen.c +6 -0
@@ -303,6 +303,9 @@ xen_swiotlb_alloc_coherent(struct device*/ flags &= ~(__GFP_DMA | __GFP_HIGHMEM); +/* Convert the size to actually allocated. */ + size =1UL << (order +XEN_PAGE_SHIFT ); +/* On ARM this function returns an ioremap'ped virtual address for * which virt_to_phys doesn't return the corresponding physical * address. In fact on ARM virt_to_phys only works for kernel direct
@@ -351,6 +354,9 @@ xen_swiotlb_free_coherent(struct device* physical address */ phys =xen_bus_to_phys (dev_addr); +/* Convert the size to actually allocated. */ + size =1UL << (order +XEN_PAGE_SHIFT ); +if (((dev_addr + size -1 <= dma_mask)) ||range_straddles_page_boundary (phys, size))xen_destroy_contiguous_region (phys, order);
Greg Kroah-Hartman
maintainerPATCH 196/350 tpm: Restore functionality to xen vtpm driver.
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dr. Greg Wettstein <[email protected]>
commit e487a0f52301293152a6f8c4e217f2a11dd808e3 upstream.
Functionality of the xen-tpmfront driver was lost secondary to the introduction of xenbus multi-page support in commit ccc9d90a9a8b ("xenbus_client: Extend interface to support multi-page ring").
In this commit pointer to location of where the shared page address is stored was being passed to the xenbus_grant_ring() function rather then the address of the shared page itself. This resulted in a situation where the driver would attach to the vtpm-stubdom but any attempt to send a command to the stub domain would timeout.
A diagnostic finding for this regression is the following error message being generated when the xen-tpmfront driver probes for a device:
<3>vtpm vtpm-0: tpm_transmit: tpm_send: error -62
<3>vtpm vtpm-0: A TPM error (-62) occurred attempting to determine the timeouts
This fix is relevant to all kernels from 4.1 forward which is the release in which multi-page xenbus support was introduced.
Daniel De Graaf formulated the fix by code inspection after the regression point was located.
--- drivers/char/tpm/xen-tpmfront.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/xen-tpmfront.c +1 -1
@@ -264,7 +264,7 @@ static int setup_ring(struct xenbus_devireturn -ENOMEM ; } - rv =xenbus_grant_ring (dev, &priv->shr,1 , &gref); + rv =xenbus_grant_ring (dev, priv->shr,1 , &gref);if (rv <0 )return rv;
Greg Kroah-Hartman
maintainerPATCH 197/350 xen/blkfront: avoid NULL blkfront_info dereference on device removal
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vasilis Liaskovitis <[email protected]>
commit f92898e7f32e3533bfd95be174044bc349d416ca upstream.
If a block device is hot-added when we are out of grants, gnttab_grant_foreign_access fails with -ENOSPC (log message "28 granting access to ring page") in this code path:
talk_to_blkback ->
setup_blkring -> xenbus_grant_ring -> gnttab_grant_foreign_access
and the failing path in talk_to_blkback sets the driver_data to NULL:
destroy_blkring:
blkif_free(info, 0);
mutex_lock(&blkfront_mutex);
free_info(info);
mutex_unlock(&blkfront_mutex);
dev_set_drvdata(&dev->dev, NULL);This results in a NULL pointer BUG when blkfront_remove and blkif_free try to access the failing device's NULL struct blkfront_info.
--- drivers/block/xen-blkfront.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/block/xen-blkfront.c +3 -0
@@ -2475,6 +2475,9 @@ static int blkfront_remove(struct xenbusdev_dbg (&xbdev->dev,"%s removed" , xbdev->nodename); +if (!info) +return 0 ; +blkif_free (info,0 );mutex_lock (&info->mutex);
Greg Kroah-Hartman
maintainerPATCH 198/350 xen/balloon: Support xend-based toolstack
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boris Ostrovsky <[email protected]>
commit 3aa6c19d2f38be9c6e9a8ad5fa8e3c9d29ee3c35 upstream.
Xend-based toolstacks don't have static-max entry in xenstore. The equivalent node for those toolstacks is memory_static_max.
--- drivers/xen/xen-balloon.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/xen/xen-balloon.c +8 -5
@@ -75,12 +75,15 @@ static void watch_target(struct xenbus_wif (!watch_fired) { watch_fired = true; - err =xenbus_scanf (XBT_NIL ,"memory" ,"static-max" ,"%llu" , - &static_max); -if (err !=1 ) - static_max = new_target; -else + +if ((xenbus_scanf (XBT_NIL ,"memory" ,"static-max" , +"%llu" , &static_max) ==1 ) || + (xenbus_scanf (XBT_NIL ,"memory" ,"memory_static_max" , +"%llu" , &static_max) ==1 )) static_max >>=PAGE_SHIFT -10 ; +else + static_max = new_target; + target_diff = (xen_pv_domain () ||xen_initial_domain ()) ?0 : static_max - balloon_stats.target_pages; }
Greg Kroah-Hartman
maintainerPATCH 199/350 xen: fix race in xen_qlock_wait()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
commit 2ac2a7d4d9ff4e01e36f9c3d116582f6f655ab47 upstream.
In the following situation a vcpu waiting for a lock might not be woken up from xen_poll_irq():
CPU 1: CPU 2: CPU 3:
takes a spinlock
tries to get lock
-> xen_qlock_wait()
frees the lock
-> xen_qlock_kick(cpu2)
-> xen_clear_irq_pending()
takes lock again
tries to get lock
-> *lock = _Q_SLOW_VAL
-> *lock == _Q_SLOW_VAL ?
-> xen_poll_irq()frees the lock
-> xen_qlock_kick(cpu3)
And cpu 2 will sleep forever.
This can be avoided easily by modifying xen_qlock_wait() to call xen_poll_irq() only if the related irq was not pending and to call xen_clear_irq_pending() only if it was pending.
--- arch/x86/xen/spinlock.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
arch/x86/xen/spinlock.c +5 -10
@@ -45,17 +45,12 @@ static void xen_qlock_wait(u8 *byte, u8if (irq ==-1 )return ; -/* clear pending */ -xen_clear_irq_pending (irq); -barrier (); +/* If irq pending already clear it and return. */ +if (xen_test_irq_pending (irq)) { +xen_clear_irq_pending (irq); +return ; + } -/* -* We check the byte value after clearing pending IRQ to make sure -* that we won't miss a wakeup event because of the clearing. -* -* The sync_clear_bit() call in xen_clear_irq_pending() is atomic. -* So it is effectively a memory barrier for x86. -*/ if (READ_ONCE (*byte) != val)return ;
Greg Kroah-Hartman
maintainerPATCH 200/350 xen: make xen_qlock_wait() nestable
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
commit a856531951dc8094359dfdac21d59cee5969c18e upstream.
xen_qlock_wait() isn't safe for nested calls due to interrupts. A call of xen_qlock_kick() might be ignored in case a deeper nesting level was active right before the call of xen_poll_irq():
CPU 1: CPU 2:spin_lock(lock1)
spin_lock(lock1)
-> xen_qlock_wait()
-> xen_clear_irq_pending()
Interrupt happens
spin_unlock(lock1)
-> xen_qlock_kick(CPU 2)
spin_lock_irqsave(lock2)
spin_lock_irqsave(lock2)
-> xen_qlock_wait()
-> xen_clear_irq_pending()
clears kick for lock1
-> xen_poll_irq()spin_unlock_irq_restore(lock2)
-> xen_qlock_kick(CPU 2)
wakes up
spin_unlock_irq_restore(lock2) IRET
resumes in xen_qlock_wait() -> xen_poll_irq() never wakes up
The solution is to disable interrupts in xen_qlock_wait() and not to poll for the irq in case xen_qlock_wait() is called in nmi context.
--- arch/x86/xen/spinlock.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)
arch/x86/xen/spinlock.c +10 -14
@@ -39,29 +39,25 @@ static void xen_qlock_kick(int cpu)*/ static void xen_qlock_wait (u8 *byte,u8 val) { +unsigned long flags;int irq =__this_cpu_read (lock_kicker_irq);/* If kicker interrupts not initialized yet, just spin */ -if (irq ==-1 ) +if (irq ==-1 ||in_nmi ())return ; -/* If irq pending already clear it and return. */ +/* Guard against reentry. */ +local_irq_save (flags); + +/* If irq pending already clear it. */ if (xen_test_irq_pending (irq)) {xen_clear_irq_pending (irq); -return ; + }else if (READ_ONCE (*byte) == val) { +/* Block until irq becomes pending (or a spurious wakeup) */ +xen_poll_irq (irq); } -if (READ_ONCE (*byte) != val) -return ; - -/* -* If an interrupt happens here, it will leave the wakeup irq -* pending, which will cause xen_poll_irq() to return -* immediately. -*/ - -/* Block until irq becomes pending (or perhaps a spurious wakeup) */ -xen_poll_irq (irq); +local_irq_restore (flags); }static irqreturn_t dummy_handler (int irq,void *dev_id)
Greg Kroah-Hartman
maintainerPATCH 201/350 xen/pvh: increase early stack size
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roger Pau Monne <[email protected]>
commit 7deecbda3026f5e2a8cc095d7ef7261a920efcf2 upstream.
While booting on an AMD EPYC box the stack canary would detect stack overflows when using the current PVH early stack size (256). Switch to using the value defined by BOOT_STACK_SIZE, which prevents the stack overflow.
--- arch/x86/xen/xen-pvh.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/xen/xen-pvh.S +1 -1
@@ -181,7 +181,7 @@ canary: .fill 48, 1, 0 early_stack: - .fill 256, 1, 0 + .fill BOOT_STACK_SIZE, 1, 0 early_stack_end: ELFNOTE(Xen, XEN_ELFNOTE_PHYS32_ENTRY,
Greg Kroah-Hartman
maintainerPATCH 202/350 xen/pvh: dont try to unplug emulated devices
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
commit e6111161c0a02d58919d776eec94b313bb57911f upstream.
A Xen PVH guest has no associated qemu device model, so trying to unplug any emulated devices is making no sense at all.
Bail out early from xen_unplug_emulated_devices() when running as PVH guest. This will avoid issuing the boot message:
[ 0.000000] Xen Platform PCI: unrecognised magic value
--- arch/x86/xen/platform-pci-unplug.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/xen/platform-pci-unplug.c +4 -0
@@ -146,6 +146,10 @@ void xen_unplug_emulated_devices(void) {int r; +/* PVH guests don't have emulated devices. */ +if (xen_pvh_domain ()) +return ; +/* user explicitly requested no unplug */ if (xen_emul_unplug &XEN_UNPLUG_NEVER )return ;
Greg Kroah-Hartman
maintainerPATCH 203/350 libertas: dont set URB_ZERO_PACKET on IN USB transfer
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lubomir Rintel <[email protected]>
commit 6528d88047801b80d2a5370ad46fb6eff2f509e0 upstream.
The USB core gets rightfully upset:
usb 1-1: BOGUS urb flags, 240 --> 200
WARNING: CPU: 0 PID: 60 at drivers/usb/core/urb.c:503 usb_submit_urb+0x2f8/0x3ed Modules linked in: CPU: 0 PID: 60 Comm: kworker/0:3 Not tainted 4.19.0-rc6-00319-g5206d00a45c7 #39 Hardware name: OLPC XO/XO, BIOS OLPC Ver 1.00.01 06/11/2014 Workqueue: events request_firmware_work_func EIP: usb_submit_urb+0x2f8/0x3ed Code: 75 06 8b 8f 80 00 00 00 8d 47 78 89 4d e4 89 55 e8 e8 35 1c f6 ff 8b 55 e8 56 52 8b 4d e4 51 50 68 e3 ce c7 c0 e8 ed 18 c6 ff <0f> 0b 83 c4 14 80 7d ef 01 74 0a 80 7d ef 03 0f 85 b8 00 00 00 8b EAX: 00000025 EBX: ce7d4980 ECX: 00000000 EDX: 00000001 ESI: 00000200 EDI: ce7d8800 EBP: ce7f5ea8 ESP: ce7f5e70 DS: 007b ES: 007b FS: 0000 GS: 00e0 SS: 0068 EFLAGS: 00210292 CR0: 80050033 CR2: 00000000 CR3: 00e80000 CR4: 00000090 Call Trace: ? if_usb_fw_timeo+0x64/0x64 __if_usb_submit_rx_urb+0x85/0xe6 ? if_usb_fw_timeo+0x64/0x64 if_usb_submit_rx_urb_fwload+0xd/0xf if_usb_prog_firmware+0xc0/0x3db ? _request_firmware+0x54/0x47b ? _request_firmware+0x89/0x47b ? if_usb_probe+0x412/0x412 lbs_fw_loaded+0x55/0xa6 ? debug_smp_processor_id+0x12/0x14 helper_firmware_cb+0x3c/0x3f request_firmware_work_func+0x37/0x6f process_one_work+0x164/0x25a worker_thread+0x1c4/0x284 kthread+0xec/0xf1 ? cancel_delayed_work_sync+0xf/0xf ? kthread_create_on_node+0x1a/0x1a ret_from_fork+0x2e/0x38 ---[ end trace 3ef1e3b2dd53852f ]---
--- drivers/net/wireless/marvell/libertas/if_usb.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/wireless/marvell/libertas/if_usb.c +0 -2
@@ -456,8 +456,6 @@ static int __if_usb_submit_rx_urb(structMRVDRV_ETH_RX_PACKET_BUFFER_SIZE , callbackfn, cardp); - cardp->rx_urb->transfer_flags |=URB_ZERO_PACKET ; -lbs_deb_usb2 (&cardp->udev->dev,"Pointer for rx_urb %p\n" , cardp->rx_urb);if ((ret =usb_submit_urb (cardp->rx_urb,GFP_ATOMIC ))) {lbs_deb_usbd (&cardp->udev->dev,"Submit Rx URB failed: %d\n" , ret);
Greg Kroah-Hartman
maintainerPATCH 204/350 usbip:vudc: BUG kmalloc-2048 (Not tainted): Poison overwritten
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuah Khan (Samsung OSG) <[email protected]>
commit e28fd56ad5273be67d0fae5bedc7e1680e729952 upstream.
In rmmod path, usbip_vudc does platform_device_put() twice once from platform_device_unregister() and then from put_vudc_device().
The second put results in:
BUG kmalloc-2048 (Not tainted): Poison overwritten error or
BUG: KASAN: use-after-free in kobject_put+0x1e/0x230 if KASAN is
enabled.
[ 169.042156] calling init+0x0/0x1000 [usbip_vudc] @ 1697 [ 169.042396] ============================================================================= [ 169.043678] probe of usbip-vudc.0 returned 1 after 350 usecs [ 169.044508] BUG kmalloc-2048 (Not tainted): Poison overwritten [ 169.044509] ----------------------------------------------------------------------------- ... [ 169.057849] INFO: Freed in device_release+0x2b/0x80 age=4223 cpu=3 pid=1693 [ 169.057852] kobject_put+0x86/0x1b0 [ 169.057853] 0xffffffffc0c30a96 [ 169.057855] __x64_sys_delete_module+0x157/0x240
Fix it to call platform_device_del() instead and let put_vudc_device() do the platform_device_put().
--- drivers/usb/usbip/vudc_main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/usb/usbip/vudc_main.c +9 -1
@@ -73,6 +73,10 @@ static int __init init(void) cleanup:list_for_each_entry_safe (udc_dev, udc_dev2, &vudc_devices, dev_entry) {list_del (&udc_dev->dev_entry); +/* +* Just do platform_device_del() here, put_vudc_device() +* calls the platform_device_put() +*/ platform_device_del (udc_dev->pdev);put_vudc_device (udc_dev); }
@@ -89,7 +93,11 @@ static void __exit cleanup(void)list_for_each_entry_safe (udc_dev, udc_dev2, &vudc_devices, dev_entry) {list_del (&udc_dev->dev_entry); -platform_device_unregister (udc_dev->pdev); +/* +* Just do platform_device_del() here, put_vudc_device() +* calls the platform_device_put() +*/ +platform_device_del (udc_dev->pdev);put_vudc_device (udc_dev); }platform_driver_unregister (&vudc_driver);
Greg Kroah-Hartman
maintainerPATCH 205/350 usb: typec: tcpm: Fix APDO PPS order checking to be based on voltage
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adam Thomson <[email protected]>
commit 1b6af2f58c2b1522e0804b150ca95e50a9e80ea7 upstream.
Current code mistakenly checks against max current to determine order but this should be max voltage. This commit fixes the issue so order is correctly determined, thus avoiding failure based on a higher voltage PPS APDO having a lower maximum current output, which is actually valid.
--- drivers/usb/typec/tcpm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/typec/tcpm.c +2 -2
@@ -1383,8 +1383,8 @@ static enum pdo_err tcpm_caps_err(structif (pdo_apdo_type (pdo[i]) !=APDO_TYPE_PPS )break ; -if (pdo_pps_apdo_max_current (pdo[i]) < -pdo_pps_apdo_max_current (pdo[i -1 ])) +if (pdo_pps_apdo_max_voltage (pdo[i]) < +pdo_pps_apdo_max_voltage (pdo[i -1 ]))return PDO_ERR_PPS_APDO_NOT_SORTED ; else if (pdo_pps_apdo_min_voltage(pdo[i]) == pdo_pps_apdo_min_voltage(pdo[i - 1]) &&
Greg Kroah-Hartman
maintainerPATCH 206/350 usb: gadget: udc: renesas_usb3: Fix b-device mode for "workaround"
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yoshihiro Shimoda <[email protected]>
commit afc92514a34c7414b28047b1205a6b709103c699 upstream.
If the "workaround_for_vbus" is true, the driver will not call usb_disconnect(). So, since the controller keeps some registers' value, the driver doesn't re-enumarate suitable speed after the b-device mode is disabled. To fix the issue, this patch adds usb_disconnect() calling in renesas_usb3_b_device_write() if workaround_for_vbus is true.
--- drivers/usb/gadget/udc/renesas_usb3.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/gadget/udc/renesas_usb3.c +3 -0
@@ -2377,6 +2377,9 @@ static ssize_t renesas_usb3_b_device_wrielse usb3->forced_b_device = false; +if (usb3->workaround_for_vbus) +usb3_disconnect (usb3); +/* Let this driver call usb3_connect() anyway */ usb3_check_id (usb3);
Greg Kroah-Hartman
maintainerPATCH 207/350 mt76: mt76x2: fix multi-interface beacon configuration
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Fietkau <[email protected]>
commit 5289976ad887deb07c76df7eecf553c264aeebed upstream.
If the first virtual interface is a station (or an AP with beacons temporarily disabled), the beacon of the second interface needs to occupy hardware beacon slot 0.
For some reason the beacon index was incorrectly masked with the virtual interface beacon mask, which prevents the secondary interface from sending beacons unless the first one also does.
--- drivers/net/wireless/mediatek/mt76/mt76x2_mac.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x2_mac.c +1 -2
@@ -725,8 +725,7 @@ __mt76x2_mac_set_beacon(struct mt76x2_deif (skb) { ret =mt76_write_beacon (dev, beacon_addr, skb);if (!ret) - dev->beacon_data_mask |=BIT (bcn_idx) & - dev->beacon_mask; + dev->beacon_data_mask |=BIT (bcn_idx); }else { dev->beacon_data_mask &= ~BIT (bcn_idx);for (i =0 ; i < beacon_len; i +=4 )
Greg Kroah-Hartman
maintainerPATCH 208/350 iwlwifi: mvm: check return value of rs_rate_from_ucode_rate()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Coelho <[email protected]>
commit 3d71c3f1f50cf309bd20659422af549bc784bfff upstream.
The rs_rate_from_ucode_rate() function may return -EINVAL if the rate is invalid, but none of the callsites check for the error, potentially making us access arrays with index IWL_RATE_INVALID, which is larger than the arrays, causing an out-of-bounds access. This will trigger KASAN warnings, such as the one reported in the bugzilla issue mentioned below.
This fixes https://bugzilla.kernel.org/show_bug.cgi?id=200659
--- drivers/net/wireless/intel/iwlwifi/mvm/rs.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/rs.c +19 -5
@@ -1218,7 +1218,11 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm !(info->flags & IEEE80211_TX_STAT_AMPDU)) return; -rs_rate_from_ucode_rate (tx_resp_hwrate, info->band, &tx_resp_rate); +if (rs_rate_from_ucode_rate (tx_resp_hwrate, info->band, + &tx_resp_rate)) { +WARN_ON_ONCE (1 ); +return ; + }#ifdef CONFIG_MAC80211_DEBUGFS /* Disable last tx check if we are debugging with fixed rate but
@@ -1269,7 +1273,10 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm*/ table = &lq_sta->lq; lq_hwrate =le32_to_cpu (table->rs_table[0 ]); -rs_rate_from_ucode_rate (lq_hwrate, info->band, &lq_rate); +if (rs_rate_from_ucode_rate (lq_hwrate, info->band, &lq_rate)) { +WARN_ON_ONCE (1 ); +return ; + }/* Here we actually compare this rate to the latest LQ command */ if (lq_color !=LQ_FLAG_COLOR_GET (table->flags)) {
@@ -1371,8 +1378,12 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm/* Collect data for each rate used during failed TX attempts */ for (i =0 ; i <= retries; ++i) { lq_hwrate =le32_to_cpu (table->rs_table[i]); -rs_rate_from_ucode_rate (lq_hwrate, info->band, - &lq_rate); +if (rs_rate_from_ucode_rate (lq_hwrate, info->band, + &lq_rate)) { +WARN_ON_ONCE (1 ); +return ; + } +/* * Only collect stats if retried rate is in the same RS * table as active/search.
@@ -3241,7 +3252,10 @@ static void rs_build_rates_table_from_fifor (i =0 ; i < num_rates; i++) lq_cmd->rs_table[i] = ucode_rate_le32; -rs_rate_from_ucode_rate (ucode_rate, band, &rate); +if (rs_rate_from_ucode_rate (ucode_rate, band, &rate)) { +WARN_ON_ONCE (1 ); +return ; + }if (is_mimo (&rate)) lq_cmd->mimo_delim = num_rates -1 ;
Greg Kroah-Hartman
maintainerPATCH 209/350 net/ipv4: defensive cipso option parsing
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Nuernberger <[email protected]>
commit 076ed3da0c9b2f88d9157dbe7044a45641ae369e upstream.
commit 40413955ee26 ("Cipso: cipso_v4_optptr enter infinite loop") fixed a possible infinite loop in the IP option parsing of CIPSO. The fix assumes that ip_options_compile filtered out all zero length options and that no other one-byte options beside IPOPT_END and IPOPT_NOOP exist. While this assumption currently holds true, add explicit checks for zero length and invalid length options to be safe for the future. Even though ip_options_compile should have validated the options, the introduction of new one-byte options can still confuse this code without the additional checks.
--- net/ipv4/cipso_ipv4.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
net/ipv4/cipso_ipv4.c +7 -4
@@ -1512,7 +1512,7 @@ static int cipso_v4_parsetag_loc(const s* * Description: * Parse the packet's IP header looking for a CIPSO option. Returns a pointer -* to the start of the CIPSO option on success, NULL if one if not found. +* to the start of the CIPSO option on success, NULL if one is not found. * */ unsigned char *cipso_v4_optptr (const struct sk_buff *skb)
@@ -1522,10 +1522,8 @@ unsigned char *cipso_v4_optptr(const strint optlen;int taglen; -for (optlen = iph->ihl*4 -sizeof (struct iphdr ); optlen >0 ; ) { +for (optlen = iph->ihl*4 -sizeof (struct iphdr ); optlen >1 ; ) {switch (optptr[0 ]) { -case IPOPT_CIPSO : -return optptr;case IPOPT_END :return NULL ;case IPOPT_NOOP :
@@ -1534,6 +1532,11 @@ unsigned char *cipso_v4_optptr(const strdefault : taglen = optptr[1 ]; } +if (!taglen || taglen > optlen) +return NULL ; +if (optptr[0 ] ==IPOPT_CIPSO ) +return optptr; + optlen -= taglen; optptr += taglen; }
Greg Kroah-Hartman
maintainerPATCH 210/350 dmaengine: ppc4xx: fix off-by-one build failure
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Lamparter <[email protected]>
commit 27d8d2d7a9b7eb05c4484b74b749eaee7b50b845 upstream.
There are two poly_store, but one should have been poly_show.
|adma.c:4382:16: error: conflicting types for 'poly_store' | static ssize_t poly_store(struct device_driver *dev, const char *buf, | ^~~~~~~~~~ |adma.c:4363:16: note: previous definition of 'poly_store' was here | static ssize_t poly_store(struct device_driver *dev, char *buf) | ^~~~~~~~~~
--- drivers/dma/ppc4xx/adma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/ppc4xx/adma.c +1 -1
@@ -4360,7 +4360,7 @@ static ssize_t enable_store(struct devic }static DRIVER_ATTR_RW (enable); -static ssize_t poly_store (struct device_driver *dev,char *buf) +static ssize_t poly_show (struct device_driver *dev,char *buf) {ssize_t size =0 ;u32 reg;
Greg Kroah-Hartman
maintainerPATCH 211/350 libnvdimm: Hold reference on parent while scheduling async init
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Duyck <[email protected]>
commit b6eae0f61db27748606cc00dafcfd1e2c032f0a5 upstream.
Unlike asynchronous initialization in the core we have not yet associated the device with the parent, and as such the device doesn't hold a reference to the parent.
In order to resolve that we should be holding a reference on the parent until the asynchronous initialization has completed.
--- drivers/nvdimm/bus.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/nvdimm/bus.c +4 -0
@@ -488,6 +488,8 @@ static void nd_async_device_register(voiput_device (dev); }put_device (dev); +if (dev->parent) +put_device (dev->parent); }static void nd_async_device_unregister (void *d,async_cookie_t cookie)
@@ -507,6 +509,8 @@ void __nd_device_register(struct deviceif (!dev)return ; dev->bus = &nvdimm_bus_type; +if (dev->parent) +get_device (dev->parent);get_device (dev);async_schedule_domain (nd_async_device_register, dev, &nd_async_domain);
Greg Kroah-Hartman
maintainerPATCH 212/350 libnvdimm, region: Fail badblocks listing for inactive regions
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Williams <[email protected]>
commit 5d394eee2c102453278d81d9a7cf94c80253486a upstream.
While experimenting with region driver loading the following backtrace was triggered:
INFO: trying to register non-static key.
the code is fine but needs lockdep annotation.
turning off the locking correctness validator.
[..]
Call Trace: dump_stack+0x85/0xcb register_lock_class+0x571/0x580 ? __lock_acquire+0x2ba/0x1310 ? kernfs_seq_start+0x2a/0x80 __lock_acquire+0xd4/0x1310 ? dev_attr_show+0x1c/0x50 ? __lock_acquire+0x2ba/0x1310 ? kernfs_seq_start+0x2a/0x80 ? lock_acquire+0x9e/0x1a0 lock_acquire+0x9e/0x1a0 ? dev_attr_show+0x1c/0x50 badblocks_show+0x70/0x190 ? dev_attr_show+0x1c/0x50 dev_attr_show+0x1c/0x50
This results from a missing successful call to devm_init_badblocks() from nd_region_probe(). Block attempts to show badblocks while the region is not enabled.
--- drivers/nvdimm/region_devs.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/nvdimm/region_devs.c +9 -2
@@ -545,10 +545,17 @@ static ssize_t region_badblocks_show(str struct device_attribute *attr, char *buf) { struct nd_region *nd_region = to_nd_region(dev); +ssize_t rc; -return badblocks_show (&nd_region->bb, buf,0 ); -} +device_lock (dev); +if (dev->driver) + rc =badblocks_show (&nd_region->bb, buf,0 ); +else + rc = -ENXIO ; +device_unlock (dev); +return rc; +} static DEVICE_ATTR(badblocks, 0444, region_badblocks_show, NULL); static ssize_t resource_show(struct device *dev,
Greg Kroah-Hartman
maintainerPATCH 213/350 libnvdimm, pmem: Fix badblocks population for raw namespaces
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Williams <[email protected]>
commit 91ed7ac444ef749603a95629a5ec483988c4f14b upstream.
The driver is only initializing bb_res in the devm_memremap_pages() paths, but the raw namespace case is passing an uninitialized bb_res to nvdimm_badblocks_populate().
--- drivers/nvdimm/pmem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nvdimm/pmem.c +3 -1
@@ -393,9 +393,11 @@ static int pmem_attach_disk(struct devic addr =devm_memremap_pages (dev, &pmem->pgmap); pmem->pfn_flags |=PFN_MAP ;memcpy (&bb_res, &pmem->pgmap.res,sizeof (bb_res)); - }else + }else { addr =devm_memremap (dev, pmem->phys_addr, pmem->size,ARCH_MEMREMAP_PMEM ); +memcpy (&bb_res, &nsio->res,sizeof (bb_res)); + }/* * At release time the queue must be frozen before
Greg Kroah-Hartman
maintainerPATCH 214/350 ASoC: intel: skylake: Add missing break in skl_tplg_get_token()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 9c80c5a8831471e0a3e139aad1b0d4c0fdc50b2f upstream.
skl_tplg_get_token() misses a break in the big switch() block for SKL_TKN_U8_CORE_ID entry.
Spotted nicely by -Wimplicit-fallthrough compiler option.
--- sound/soc/intel/skylake/skl-topology.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/intel/skylake/skl-topology.c +1 -0
@@ -2458,6 +2458,7 @@ static int skl_tplg_get_token(struct devcase SKL_TKN_U8_CORE_ID : mconfig->core_id = tkn_elem->value; +break ;case SKL_TKN_U8_MOD_TYPE : mconfig->m_type = tkn_elem->value;
Greg Kroah-Hartman
maintainerPATCH 215/350 ASoC: sta32x: set ->component pointer in private struct
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Mack <[email protected]>
commit 747df19747bc9752cd40b9cce761e17a033aa5c2 upstream.
The ESD watchdog code in sta32x_watchdog() dereferences the pointer which is never assigned.
This is a regression from a1be4cead9b950 ("ASoC: sta32x: Convert to direct regmap API usage.") which went unnoticed since nobody seems to use that ESD workaround.
--- sound/soc/codecs/sta32x.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/codecs/sta32x.c +3 -0
@@ -879,6 +879,9 @@ static int sta32x_probe(struct snd_soc_cstruct sta32x_priv *sta32x =snd_soc_component_get_drvdata (component);struct sta32x_platform_data *pdata = sta32x->pdata;int i, ret =0 , thermal =0 ; + + sta32x->component = component; + ret =regulator_bulk_enable (ARRAY_SIZE (sta32x->supplies), sta32x->supplies);if (ret !=0 ) {
Greg Kroah-Hartman
maintainerPATCH 216/350 IB/mlx5: Fix MR cache initialization
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Artemy Kovalyov <[email protected]>
commit 013c2403bf32e48119aeb13126929f81352cc7ac upstream.
Schedule MR cache work only after bucket was initialized.
--- drivers/infiniband/hw/mlx5/mr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/mr.c +1 -1
@@ -691,7 +691,6 @@ int mlx5_mr_cache_init(struct mlx5_ib_deinit_completion (&ent->compl);INIT_WORK (&ent->work, cache_work_func);INIT_DELAYED_WORK (&ent->dwork, delayed_cache_work_func); -queue_work (cache->wq, &ent->work);if (i >MR_CACHE_LAST_STD_ENTRY ) {mlx5_odp_init_mr_cache_entry (ent);
@@ -711,6 +710,7 @@ int mlx5_mr_cache_init(struct mlx5_ib_de ent->limit = dev->mdev->profile->mr_cache[i].limit; else ent->limit = 0; +queue_work (cache->wq, &ent->work); } err =mlx5_mr_cache_debugfs_init (dev);
Greg Kroah-Hartman
maintainerPATCH 217/350 IB/rxe: Revise the ib_wr_opcode enum
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
commit 9a59739bd01f77db6fbe2955a4fce165f0f43568 upstream.
This enum has become part of the uABI, as both RXE and the ib_uverbs_post_send() command expect userspace to supply values from this enum. So it should be properly placed in include/uapi/rdma.
In userspace this enum is called 'enum ibv_wr_opcode' as part of libibverbs.h. That enum defines different values for IB_WR_LOCAL_INV, IB_WR_SEND_WITH_INV, and IB_WR_LSO. These were introduced (incorrectly, it turns out) into libiberbs in 2015.
The kernel has changed its mind on the numbering for several of the IB_WC values over the years, but has remained stable on IB_WR_LOCAL_INV and below.
Based on this we can conclude that there is no real user space user of the values beyond IB_WR_ATOMIC_FETCH_AND_ADD, as they have never worked via rdma-core. This is confirmed by inspection, only rxe uses the kernel enum and implements the latter operations. rxe has clearly never worked with these attributes from userspace. Other drivers that support these opcodes implement the functionality without calling out to the kernel.
To make IB_WR_SEND_WITH_INV and related work for RXE in userspace we choose to renumber the IB_WR enum in the kernel to match the uABI that userspace has bee using since before Soft RoCE was merged. This is an overall simpler configuration for the whole software stack, and obviously can't break anything existing.
--- include/rdma/ib_verbs.h | 34 ++++++++++++++++++++-------------- include/uapi/rdma/ib_user_verbs.h | 20 +++++++++++++++++++- 2 files changed, 39 insertions(+), 15 deletions(-)
include/rdma/ib_verbs.h +20 -14
@@ -1296,21 +1296,27 @@ struct ib_qp_attr { };enum ib_wr_opcode { -IB_WR_RDMA_WRITE , -IB_WR_RDMA_WRITE_WITH_IMM , -IB_WR_SEND , -IB_WR_SEND_WITH_IMM , -IB_WR_RDMA_READ , -IB_WR_ATOMIC_CMP_AND_SWP , -IB_WR_ATOMIC_FETCH_AND_ADD , -IB_WR_LSO , -IB_WR_SEND_WITH_INV , -IB_WR_RDMA_READ_WITH_INV , -IB_WR_LOCAL_INV , -IB_WR_REG_MR , -IB_WR_MASKED_ATOMIC_CMP_AND_SWP , -IB_WR_MASKED_ATOMIC_FETCH_AND_ADD , +/* These are shared with userspace */ +IB_WR_RDMA_WRITE =IB_UVERBS_WR_RDMA_WRITE , +IB_WR_RDMA_WRITE_WITH_IMM =IB_UVERBS_WR_RDMA_WRITE_WITH_IMM , +IB_WR_SEND =IB_UVERBS_WR_SEND , +IB_WR_SEND_WITH_IMM =IB_UVERBS_WR_SEND_WITH_IMM , +IB_WR_RDMA_READ =IB_UVERBS_WR_RDMA_READ , +IB_WR_ATOMIC_CMP_AND_SWP =IB_UVERBS_WR_ATOMIC_CMP_AND_SWP , +IB_WR_ATOMIC_FETCH_AND_ADD =IB_UVERBS_WR_ATOMIC_FETCH_AND_ADD , +IB_WR_LSO =IB_UVERBS_WR_TSO , +IB_WR_SEND_WITH_INV =IB_UVERBS_WR_SEND_WITH_INV , +IB_WR_RDMA_READ_WITH_INV =IB_UVERBS_WR_RDMA_READ_WITH_INV , +IB_WR_LOCAL_INV =IB_UVERBS_WR_LOCAL_INV , +IB_WR_MASKED_ATOMIC_CMP_AND_SWP = +IB_UVERBS_WR_MASKED_ATOMIC_CMP_AND_SWP , +IB_WR_MASKED_ATOMIC_FETCH_AND_ADD = +IB_UVERBS_WR_MASKED_ATOMIC_FETCH_AND_ADD , + +/* These are kernel only and can not be issued by userspace */ +IB_WR_REG_MR =0x20 ,IB_WR_REG_SIG_MR , +/* reserve values for low level drivers' internal use. * These values will not be used at all in the ib core layer. */
include/uapi/rdma/ib_user_verbs.h +19 -1
@@ -762,10 +762,28 @@ struct ib_uverbs_sge {__u32 lkey; }; +enum ib_uverbs_wr_opcode { +IB_UVERBS_WR_RDMA_WRITE =0 , +IB_UVERBS_WR_RDMA_WRITE_WITH_IMM =1 , +IB_UVERBS_WR_SEND =2 , +IB_UVERBS_WR_SEND_WITH_IMM =3 , +IB_UVERBS_WR_RDMA_READ =4 , +IB_UVERBS_WR_ATOMIC_CMP_AND_SWP =5 , +IB_UVERBS_WR_ATOMIC_FETCH_AND_ADD =6 , +IB_UVERBS_WR_LOCAL_INV =7 , +IB_UVERBS_WR_BIND_MW =8 , +IB_UVERBS_WR_SEND_WITH_INV =9 , +IB_UVERBS_WR_TSO =10 , +IB_UVERBS_WR_RDMA_READ_WITH_INV =11 , +IB_UVERBS_WR_MASKED_ATOMIC_CMP_AND_SWP =12 , +IB_UVERBS_WR_MASKED_ATOMIC_FETCH_AND_ADD =13 , +/* Review enum ib_wr_opcode before modifying this */ +}; +struct ib_uverbs_send_wr {__aligned_u64 wr_id;__u32 num_sge; -__u32 opcode; +__u32 opcode;/* see enum ib_uverbs_wr_opcode */ __u32 send_flags;union {__be32 imm_data;
Greg Kroah-Hartman
maintainerPATCH 218/350 jbd2: fix use after free in jbd2_log_do_checkpoint()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit ccd3c4373eacb044eb3832966299d13d2631f66f upstream.
The code cleaning transaction's lists of checkpoint buffers has a bug where it increases bh refcount only after releasing journal->j_list_lock. Thus the following race is possible:
CPU0 CPU1jbd2_log_do_checkpoint()
jbd2_journal_try_to_free_buffers()
__journal_try_to_free_buffer(bh)
...
while (transaction->t_checkpoint_io_list)
...
if (buffer_locked(bh)) {<-- IO completes now, buffer gets unlocked -->
spin_unlock(&journal->j_list_lock);
spin_lock(&journal->j_list_lock);
__jbd2_journal_remove_checkpoint(jh);
spin_unlock(&journal->j_list_lock);
try_to_free_buffers(page);
get_bh(bh) <-- accesses freed bhFix the problem by grabbing bh reference before unlocking journal->j_list_lock.
--- fs/jbd2/checkpoint.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/jbd2/checkpoint.c +2 -2
@@ -251,8 +251,8 @@ restart: bh =jh2bh (jh);if (buffer_locked (bh)) { -spin_unlock (&journal->j_list_lock);get_bh (bh); +spin_unlock (&journal->j_list_lock);wait_on_buffer (bh);/* the journal_head may have gone by now */ BUFFER_TRACE (bh,"brelse" );
@@ -333,8 +333,8 @@ restart2: jh = transaction->t_checkpoint_io_list; bh =jh2bh (jh);if (buffer_locked (bh)) { -spin_unlock (&journal->j_list_lock);get_bh (bh); +spin_unlock (&journal->j_list_lock);wait_on_buffer (bh);/* the journal_head may have gone by now */ BUFFER_TRACE (bh,"brelse" );
Greg Kroah-Hartman
maintainerPATCH 219/350 gfs2_meta: ->mount() can get NULL dev_name
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit 3df629d873f8683af6f0d34dfc743f637966d483 upstream.
get in sync with mount_bdev() handling of the same
--- fs/gfs2/ops_fstype.c | 3 +++ 1 file changed, 3 insertions(+)
fs/gfs2/ops_fstype.c +3 -0
@@ -1333,6 +1333,9 @@ static struct dentry *gfs2_mount_meta(ststruct path path;int error; +if (!dev_name || !*dev_name) +return ERR_PTR (-EINVAL ); + error =kern_path (dev_name,LOOKUP_FOLLOW , &path);if (error) { pr_warn("path_lookup on %s returned error %d\n",
Greg Kroah-Hartman
maintainerPATCH 220/350 ext4: fix EXT4_IOC_SWAP_BOOT
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
commit 18aded17492088962ef43f00825179598b3e8c58 upstream.
The code EXT4_IOC_SWAP_BOOT ioctl hasn't been updated in a while, and it's a bit broken with respect to more modern ext4 kernels, especially metadata checksums.
Other problems fixed with this commit:
* Don't allow installing a DAX, swap file, or an encrypted file as a boot loader.
* Respect the immutable and append-only flags.
* Wait until any DIO operations are finished *before* calling truncate_inode_pages().
* Don't swap inode->i_flags, since these flags have nothing to do with the inode blocks --- and it will give the IMA/audit code heartburn when the inode is evicted.
--- fs/ext4/ioctl.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-)
fs/ext4/ioctl.c +27 -6
@@ -67,7 +67,6 @@ static void swap_inode_data(struct inode ei1 =EXT4_I (inode1); ei2 =EXT4_I (inode2); -swap (inode1->i_flags, inode2->i_flags);swap (inode1->i_version, inode2->i_version);swap (inode1->i_blocks, inode2->i_blocks);swap (inode1->i_bytes, inode2->i_bytes);
@@ -85,6 +84,21 @@ static void swap_inode_data(struct inodei_size_write (inode2, isize); } +static void reset_inode_seed (struct inode *inode) +{ +struct ext4_inode_info *ei =EXT4_I (inode); +struct ext4_sb_info *sbi =EXT4_SB (inode->i_sb); +__le32 inum =cpu_to_le32 (inode->i_ino); +__le32 gen =cpu_to_le32 (inode->i_generation); +__u32 csum; + +if (!ext4_has_metadata_csum (inode->i_sb)) +return ; + + csum =ext4_chksum (sbi, sbi->s_csum_seed, (__u8 *)&inum,sizeof (inum)); + ei->i_csum_seed =ext4_chksum (sbi, csum, (__u8 *)&gen,sizeof (gen)); +} +/** * Swap the information from the given @inode and the inode * EXT4_BOOT_LOADER_INO. It will basically swap i_data and all other
@@ -102,10 +116,13 @@ static long swap_inode_boot_loader(strucstruct inode *inode_bl;struct ext4_inode_info *ei_bl; -if (inode->i_nlink !=1 || !S_ISREG (inode->i_mode)) +if (inode->i_nlink !=1 || !S_ISREG (inode->i_mode) || +IS_SWAPFILE (inode) ||IS_ENCRYPTED (inode) || +ext4_has_inline_data (inode))return -EINVAL ; -if (!inode_owner_or_capable (inode) || !capable (CAP_SYS_ADMIN )) +if (IS_RDONLY (inode) ||IS_APPEND (inode) ||IS_IMMUTABLE (inode) || + !inode_owner_or_capable (inode) || !capable (CAP_SYS_ADMIN ))return -EPERM ; inode_bl =ext4_iget (sb,EXT4_BOOT_LOADER_INO );
@@ -120,13 +137,13 @@ static long swap_inode_boot_loader(struc* that only 1 swap_inode_boot_loader is running. */ lock_two_nondirectories (inode, inode_bl); -truncate_inode_pages (&inode->i_data,0 ); -truncate_inode_pages (&inode_bl->i_data,0 ); -/* Wait for all existing dio workers */ inode_dio_wait (inode);inode_dio_wait (inode_bl); +truncate_inode_pages (&inode->i_data,0 ); +truncate_inode_pages (&inode_bl->i_data,0 ); + handle =ext4_journal_start (inode_bl,EXT4_HT_MOVE_EXTENTS ,2 );if (IS_ERR (handle)) { err = -EINVAL ;
@@ -159,6 +176,8 @@ static long swap_inode_boot_loader(struc inode->i_generation =prandom_u32 (); inode_bl->i_generation =prandom_u32 (); +reset_inode_seed (inode); +reset_inode_seed (inode_bl);ext4_discard_preallocations (inode);
@@ -169,6 +188,7 @@ static long swap_inode_boot_loader(struc inode->i_ino, err);/* Revert all changes: */ swap_inode_data (inode, inode_bl); +ext4_mark_inode_dirty (handle, inode); }else { err =ext4_mark_inode_dirty (handle, inode_bl);if (err <0 ) {
@@ -178,6 +198,7 @@ static long swap_inode_boot_loader(struc/* Revert all changes: */ swap_inode_data (inode, inode_bl);ext4_mark_inode_dirty (handle, inode); +ext4_mark_inode_dirty (handle, inode_bl); } }ext4_journal_stop (handle);
Greg Kroah-Hartman
maintainerPATCH 221/350 ext4: initialize retries variable in ext4_da_write_inline_data_begin()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Czerner <[email protected]>
commit 625ef8a3acd111d5f496d190baf99d1a815bd03e upstream.
Variable retries is not initialized in ext4_da_write_inline_data_begin() which can lead to nondeterministic number of retries in case we hit ENOSPC. Initialize retries to zero as we do everywhere else.
--- fs/ext4/inline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/inline.c +1 -1
@@ -863,7 +863,7 @@ int ext4_da_write_inline_data_begin(struhandle_t *handle;struct page *page;struct ext4_iloc iloc; -int retries; +int retries =0 ; ret =ext4_get_inode_loc (inode, &iloc);if (ret)
Greg Kroah-Hartman
maintainerPATCH 222/350 ext4: fix setattr project check in fssetxattr ioctl
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Shilong <[email protected]>
commit dc7ac6c4cae3b58724c2f1e21a7c05ce19ecd5a8 upstream.
Currently, project quota could be changed by fssetxattr ioctl, and existed permission check inode_owner_or_capable() is obviously not enough, just think that common users could change project id of file, that could make users to break project quota easily.
This patch try to follow same regular of xfs project quota:
"Project Quota ID state is only allowed to change from within the init namespace. Enforce that restriction only if we are trying to change the quota ID state. Everything else is allowed in user namespaces."
Besides that, check and set project id'state should be an atomic operation, protect whole operation with inode lock, ext4_ioctl_setproject() is only used for ioctl EXT4_IOC_FSSETXATTR, we have held mnt_want_write_file() before ext4_ioctl_setflags(), and ext4_ioctl_setproject() is called after ext4_ioctl_setflags(), we could share codes, so remove it inside ext4_ioctl_setproject().
--- fs/ext4/ioctl.c | 60 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 23 deletions(-)
fs/ext4/ioctl.c +37 -23
@@ -360,19 +360,14 @@ static int ext4_ioctl_setproject(structif (projid_eq (kprojid,EXT4_I (inode)->i_projid))return 0 ; - err =mnt_want_write_file (filp); -if (err) -return err; - err = -EPERM ; -inode_lock (inode);/* Is it quota file? Do not allow user to mess with it */ if (ext4_is_quota_file (inode)) - goto out_unlock; +return err; err =ext4_get_inode_loc (inode, &iloc);if (err) - goto out_unlock; +return err; raw_inode =ext4_raw_inode (&iloc);if (!EXT4_FITS_IN_INODE (raw_inode, ei, i_projid)) {
@@ -380,7 +375,7 @@ static int ext4_ioctl_setproject(structEXT4_SB (sb)->s_want_extra_isize, &iloc);if (err) - goto out_unlock; +return err; }else {brelse (iloc.bh); }
@@ -390,10 +385,8 @@ static int ext4_ioctl_setproject(struct handle =ext4_journal_start (inode,EXT4_HT_QUOTA ,EXT4_QUOTA_INIT_BLOCKS (sb) +EXT4_QUOTA_DEL_BLOCKS (sb) +3 ); -if (IS_ERR (handle)) { - err =PTR_ERR (handle); - goto out_unlock; - } +if (IS_ERR (handle)) +return PTR_ERR (handle); err =ext4_reserve_inode_write (handle, inode, &iloc);if (err)
@@ -421,9 +414,6 @@ out_dirty: err = rc; out_stop:ext4_journal_stop (handle); -out_unlock: -inode_unlock (inode); -mnt_drop_write_file (filp); return err; }#else
@@ -647,6 +637,30 @@ group_add_out:return err; } +static int ext4_ioctl_check_project (struct inode *inode,struct fsxattr *fa) +{ +/* +* Project Quota ID state is only allowed to change from within the init +* namespace. Enforce that restriction only if we are trying to change +* the quota ID state. Everything else is allowed in user namespaces. +*/ +if (current_user_ns () == &init_user_ns) +return 0 ; + +if (__kprojid_val (EXT4_I (inode)->i_projid) != fa->fsx_projid) +return -EINVAL ; + +if (ext4_test_inode_flag (inode,EXT4_INODE_PROJINHERIT )) { +if (!(fa->fsx_xflags &FS_XFLAG_PROJINHERIT )) +return -EINVAL ; + }else { +if (fa->fsx_xflags &FS_XFLAG_PROJINHERIT ) +return -EINVAL ; + } + +return 0 ; +} +long ext4_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) {struct inode *inode =file_inode (filp);
@@ -1046,19 +1060,19 @@ resizefs_out:return err;inode_lock (inode); + err =ext4_ioctl_check_project (inode, &fa); +if (err) + goto out; flags = (ei->i_flags & ~EXT4_FL_XFLAG_VISIBLE ) | (flags &EXT4_FL_XFLAG_VISIBLE ); err =ext4_ioctl_setflags (inode, flags); -inode_unlock (inode); -mnt_drop_write_file (filp);if (err) -return err; - + goto out; err =ext4_ioctl_setproject (filp, fa.fsx_projid); -if (err) -return err; - -return 0 ; +out: +inode_unlock (inode); +mnt_drop_write_file (filp); +return err; }case EXT4_IOC_SHUTDOWN :return ext4_shutdown (sb, arg);
Greg Kroah-Hartman
maintainerPATCH 223/350 ext4: propagate error from dquot_initialize() in EXT4_IOC_FSSETXATTR
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Shilong <[email protected]>
commit 182a79e0c17147d2c2d3990a9a7b6b58a1561c7a upstream.
We return most failure of dquota_initialize() except inode evict, this could make a bit sense, for example we allow file removal even quota files are broken?
But it dosen't make sense to allow setting project if quota files etc are broken.
--- fs/ext4/ioctl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ext4/ioctl.c +3 -1
@@ -380,7 +380,9 @@ static int ext4_ioctl_setproject(structbrelse (iloc.bh); } -dquot_initialize (inode); + err =dquot_initialize (inode); +if (err) +return err; handle = ext4_journal_start(inode, EXT4_HT_QUOTA, EXT4_QUOTA_INIT_BLOCKS(sb) +
Greg Kroah-Hartman
maintainerPATCH 224/350 ext4: fix use-after-free race in ext4_remount()s error path
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
commit 33458eaba4dfe778a426df6a19b7aad2ff9f7eec upstream.
It's possible for ext4_show_quota_options() to try reading s_qf_names[i] while it is being modified by ext4_remount() --- most notably, in ext4_remount's error path when the original values of the quota file name gets restored.
--- fs/ext4/ext4.h | 3 +- fs/ext4/super.c | 73 ++++++++++++++++++++++++++++++++++++-------------------- 2 files changed, 50 insertions(+), 26 deletions(-)
fs/ext4/ext4.h +2 -1
@@ -1387,7 +1387,8 @@ struct ext4_sb_info {u32 s_min_batch_time;struct block_device *journal_bdev;#ifdef CONFIG_QUOTA -char *s_qf_names[EXT4_MAXQUOTAS ];/* Names of quota files with journalled quota */ +/* Names of quota files with journalled quota */ +char __rcu *s_qf_names[EXT4_MAXQUOTAS ];int s_jquota_fmt;/* Format of quota to use */ #endif unsigned int s_want_extra_isize;/* New inodes should reserve # bytes */
fs/ext4/super.c +48 -25
167 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 225/350 selinux: fix mounting of cgroup2 under older policies
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephen Smalley <[email protected]>
commit 7bb185edb0306bb90029a5fa6b9cff900ffdbf4b upstream.
commit 901ef845fa2469c ("selinux: allow per-file labeling for cgroupfs") broke mounting of cgroup2 under older SELinux policies which lacked a genfscon rule for cgroup2. This prevents mounting of cgroup2 even when SELinux is permissive.
Change the handling when there is no genfscon rule in policy to just mark the inode unlabeled and not return an error to the caller. This permits mounting and access if allowed by policy, e.g. to unconfined domains.
I also considered changing the behavior of security_genfs_sid() to never return -ENOENT, but the current behavior is relied upon by other callers to perform caller-specific handling.
--- security/selinux/hooks.c | 5 +++++ 1 file changed, 5 insertions(+)
security/selinux/hooks.c +5 -0
@@ -1509,6 +1509,11 @@ static int selinux_genfs_get_sid(struct } rc =security_genfs_sid (&selinux_state, sb->s_type->name, path, tclass, sid); +if (rc == -ENOENT ) { +/* No match in policy, mark as unlabeled. */ + *sid =SECINITSID_UNLABELED ; + rc =0 ; + } }free_page ((unsigned long )buffer);return rc;
Greg Kroah-Hartman
maintainerPATCH 226/350 HID: wacom: Work around HID descriptor bug in DTK-2451 and DTH-2452
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gerecke <[email protected]>
commit 11db8173dbab7a94cf5ba5225fcedbfc0f3b7e54 upstream.
The DTK-2451 and DTH-2452 have a buggy HID descriptor which incorrectly contains a Cintiq-like report, complete with pen tilt, rotation, twist, serial number, etc. The hardware doesn't actually support this data but our driver duitifully sets up the device as though it does. To ensure userspace has a correct view of devices without updated firmware, we clean up this incorrect data in wacom_setup_device_quirks.
We're also careful to clear the WACOM_QUIRK_TOOLSERIAL flag since its presence causes the driver to wait for serial number information (via wacom_wac_pen_serial_enforce) that never comes, resulting in
the pen being non-responsive.
--- drivers/hid/wacom_wac.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/hid/wacom_wac.c +19 -0
@@ -3335,6 +3335,7 @@ static void wacom_setup_intuos(struct wavoid wacom_setup_device_quirks (struct wacom *wacom) { +struct wacom_wac *wacom_wac = &wacom->wacom_wac;struct wacom_features *features = &wacom->wacom_wac.features;/* The pen and pad share the same interface on most devices */
@@ -3464,6 +3465,24 @@ void wacom_setup_device_quirks(struct waif (features->type ==REMOTE ) features->device_type |=WACOM_DEVICETYPE_WL_MONITOR ; + +/* HID descriptor for DTK-2451 / DTH-2452 claims to report lots +* of things it shouldn't. Lets fix up the damage... +*/ +if (wacom->hdev->product ==0x382 || wacom->hdev->product ==0x37d ) { + features->quirks &= ~WACOM_QUIRK_TOOLSERIAL ; +__clear_bit (BTN_TOOL_BRUSH , wacom_wac->pen_input->keybit); +__clear_bit (BTN_TOOL_PENCIL , wacom_wac->pen_input->keybit); +__clear_bit (BTN_TOOL_AIRBRUSH , wacom_wac->pen_input->keybit); +__clear_bit (ABS_Z , wacom_wac->pen_input->absbit); +__clear_bit (ABS_DISTANCE , wacom_wac->pen_input->absbit); +__clear_bit (ABS_TILT_X , wacom_wac->pen_input->absbit); +__clear_bit (ABS_TILT_Y , wacom_wac->pen_input->absbit); +__clear_bit (ABS_WHEEL , wacom_wac->pen_input->absbit); +__clear_bit (ABS_MISC , wacom_wac->pen_input->absbit); +__clear_bit (MSC_SERIAL , wacom_wac->pen_input->mscbit); +__clear_bit (EV_MSC , wacom_wac->pen_input->evbit); + } } int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
Greg Kroah-Hartman
maintainerPATCH 227/350 HID: hiddev: fix potential Spectre v1
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
commit f11274396a538b31bc010f782e05c2ce3f804c13 upstream.
uref->usage_index can be indirectly controlled by userspace, hence leading to a potential exploitation of the Spectre variant 1 vulnerability.
This field is used as an array index by the hiddev_ioctl_usage() function, when 'cmd' is either HIDIOCGCOLLECTIONINDEX, HIDIOCGUSAGES or HIDIOCSUSAGES.
For cmd == HIDIOCGCOLLECTIONINDEX case, uref->usage_index is compared to field->maxusage and then used as an index to dereference field->usage array. The same thing happens to the cmd == HIDIOC{G,S}USAGES cases, where uref->usage_index is checked against an array maximum value and then it is used as an index in an array.
This is a summary of the HIDIOCGCOLLECTIONINDEX case, which matches the traditional Spectre V1 first load:
copy_from_user(uref, user_arg, sizeof(*uref)) if (uref->usage_index >= field->maxusage) goto inval; i = field->usage[uref->usage_index].collection_index; return i;
This patch fixes this by sanitizing field uref->usage_index before using it to index field->usage (HIDIOCGCOLLECTIONINDEX) or field->value in HIDIOC{G,S}USAGES arrays, thus, avoiding speculation in the first load.
v2: Contemplate cmd == HIDIOC{G,S}USAGES case
--- drivers/hid/usbhid/hiddev.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/hid/usbhid/hiddev.c +14 -4
@@ -512,14 +512,24 @@ static noinline int hiddev_ioctl_usage(sif (cmd ==HIDIOCGCOLLECTIONINDEX ) {if (uref->usage_index >= field->maxusage) goto inval; + uref->usage_index = +array_index_nospec (uref->usage_index, + field->maxusage); }else if (uref->usage_index >= field->report_count) goto inval; } -if ((cmd ==HIDIOCGUSAGES || cmd ==HIDIOCSUSAGES ) && - (uref_multi->num_values >HID_MAX_MULTI_USAGES || - uref->usage_index + uref_multi->num_values > field->report_count)) - goto inval; +if (cmd ==HIDIOCGUSAGES || cmd ==HIDIOCSUSAGES ) { +if (uref_multi->num_values >HID_MAX_MULTI_USAGES || + uref->usage_index + uref_multi->num_values > + field->report_count) + goto inval; + + uref->usage_index = +array_index_nospec (uref->usage_index, + field->report_count - + uref_multi->num_values); + }switch (cmd) {case HIDIOCGUSAGE :
Greg Kroah-Hartman
maintainerPATCH 228/350 EDAC, amd64: Add Family 17h, models 10h-2fh support
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Jin <[email protected]>
commit 8960de4a5ca7980ed1e19e7ca5a774d3b7a55c38 upstream.
Add new device IDs for family 17h, models 10h-2fh.
This is required by amd64_edac_mod in order to properly detect PCI device functions 0 and 6.
--- drivers/edac/amd64_edac.c | 14 ++++++++++++++ drivers/edac/amd64_edac.h | 3 +++ 2 files changed, 17 insertions(+)
drivers/edac/amd64_edac.c +14 -0
@@ -2200,6 +2200,15 @@ static struct amd64_family_type family_t .dbam_to_cs = f17_base_addr_to_cs_size, } }, + [F17_M10H_CPUS ] = { + .ctl_name ="F17h_M10h" , + .f0_id =PCI_DEVICE_ID_AMD_17H_M10H_DF_F0 , + .f6_id =PCI_DEVICE_ID_AMD_17H_M10H_DF_F6 , + .ops = { + .early_channel_count = f17_early_channel_count, + .dbam_to_cs = f17_base_addr_to_cs_size, + } + }, };/*
@@ -3188,6 +3197,11 @@ static struct amd64_family_type *per_fambreak ;case 0x17 : +if (pvt->model >=0x10 && pvt->model <=0x2f ) { + fam_type = &family_types[F17_M10H_CPUS ]; + pvt->ops = &family_types[F17_M10H_CPUS ].ops; +break ; + } fam_type = &family_types[F17_CPUS ]; pvt->ops = &family_types[F17_CPUS ].ops;break ;
drivers/edac/amd64_edac.h +3 -0
@@ -115,6 +115,8 @@#define PCI_DEVICE_ID_AMD_16H_M30H_NB_F2 0x1582#define PCI_DEVICE_ID_AMD_17H_DF_F0 0x1460#define PCI_DEVICE_ID_AMD_17H_DF_F6 0x1466 +#define PCI_DEVICE_ID_AMD_17H_M10H_DF_F0 0x15e8 +#define PCI_DEVICE_ID_AMD_17H_M10H_DF_F6 0x15ee/* * Function 1 - Address Map
@@ -281,6 +283,7 @@ enum amd_families {F16_CPUS ,F16_M30H_CPUS ,F17_CPUS , +F17_M10H_CPUS , NUM_FAMILIES, };
Greg Kroah-Hartman
maintainerPATCH 229/350 EDAC, {i7core,sb,skx}_edac: Fix uncorrected error counting
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Luck <[email protected]>
commit 432de7fd7630c84ad24f1c2acd1e3bb4ce3741ca upstream.
The count of errors is picked up from bits 52:38 of the machine check bank status register. But this is the count of *corrected* errors. If an uncorrected error is being logged, the h/w sets this field to 0. Which means that when edac_mc_handle_error() is called, the EDAC core will carefully add zero to the appropriate uncorrected error counts.
--- drivers/edac/i7core_edac.c | 1 + drivers/edac/sb_edac.c | 1 + drivers/edac/skx_edac.c | 1 + 3 files changed, 3 insertions(+)
drivers/edac/i7core_edac.c +1 -0
@@ -1711,6 +1711,7 @@ static void i7core_mce_output_error(struu32 errnum =find_first_bit (&error,32 );if (uncorrected_error) { + core_err_cnt =1 ;if (ripv) tp_event =HW_EVENT_ERR_FATAL ;else
drivers/edac/sb_edac.c +1 -0
@@ -2881,6 +2881,7 @@ static void sbridge_mce_output_error(str recoverable =GET_BITFIELD (m->status,56 ,56 );if (uncorrected_error) { + core_err_cnt =1 ;if (ripv) { type ="FATAL" ; tp_event =HW_EVENT_ERR_FATAL ;
drivers/edac/skx_edac.c +1 -0
@@ -959,6 +959,7 @@ static void skx_mce_output_error(struct recoverable =GET_BITFIELD (m->status,56 ,56 );if (uncorrected_error) { + core_err_cnt =1 ;if (ripv) { type ="FATAL" ; tp_event =HW_EVENT_ERR_FATAL ;
Greg Kroah-Hartman
maintainerPATCH 230/350 EDAC, skx_edac: Fix logical channel intermediate decoding
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qiuxu Zhuo <[email protected]>
commit 8f18973877204dc8ca4ce1004a5d28683b9a7086 upstream.
The code "lchan = (lchan << 1) | ~lchan" for logical channel intermediate decoding is wrong. The wrong intermediate decoding result is {0xffffffff, 0xfffffffe}.
Fix it by replacing '~' with '!'. The correct intermediate decoding result is {0x1, 0x2}.
--- drivers/edac/skx_edac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/edac/skx_edac.c +1 -1
@@ -668,7 +668,7 @@ sad_found:break ;case 2 : lchan = (addr >> shift) %2 ; - lchan = (lchan <<1 ) | ~lchan; + lchan = (lchan <<1 ) | !lchan;break ;case 3 : lchan = ((addr >> shift) %2 ) <<1 ;
Greg Kroah-Hartman
maintainerPATCH 231/350 ARM: dts: dra7: Fix up unaligned access setting for PCIe EP
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vignesh R <[email protected]>
commit 6d0af44a82be87c13f2320821e9fbb8b8cf5a56f upstream.
Bit positions of PCIE_SS1_AXI2OCP_LEGACY_MODE_ENABLE and PCIE_SS1_AXI2OCP_LEGACY_MODE_ENABLE in CTRL_CORE_SMA_SW_7 are incorrectly documented in the TRM. In fact, the bit positions are swapped. Update the DT bindings for PCIe EP to reflect the same.
--- arch/arm/boot/dts/dra7.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/dra7.dtsi +1 -1
@@ -354,7 +354,7 @@ ti,hwmods = "pcie1"; phys = <&pcie1_phy>; phy-names = "pcie-phy0"; - ti,syscon-unaligned-access = <&scm_conf1 0x14 2>; + ti,syscon-unaligned-access = <&scm_conf1 0x14 1>; status = "disabled"; }; };
Greg Kroah-Hartman
maintainerPATCH 232/350 PCI/ASPM: Fix link_state teardown on device removal
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Wunner <[email protected]>
commit aeae4f3e5c38d47bdaef50446dc0ec857307df68 upstream.
Upon removal of the last device on a bus, the link_state of the bridge leading to that bus is sought to be torn down by having pci_stop_dev() call pcie_aspm_exit_link_state().
When ASPM was originally introduced by commit 7d715a6c1ae5 ("PCI: add PCI Express ASPM support"), it determined whether the device being removed is the last one by calling list_empty() on the bridge's subordinate devices list. That didn't work because the device is only removed from the list slightly later in pci_destroy_dev().
Commit 3419c75e15f8 ("PCI: properly clean up ASPM link state on device remove") attempted to fix it by calling list_is_last(), but that's not correct either because it checks whether the device is at the *end* of the list, not whether it's the last one *left* in the list. If the user removes the device which happens to be at the end of the list via sysfs but other devices are preceding the device in the list, the link_state is torn down prematurely.
The real fix is to move the invocation of pcie_aspm_exit_link_state() to pci_destroy_dev() and reinstate the call to list_empty(). Remove a duplicate check for dev->bus->self because pcie_aspm_exit_link_state() already contains an identical check.
--- drivers/pci/pcie/aspm.c | 2 +- drivers/pci/remove.c | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/pci/pcie/aspm.c +1 -1
@@ -991,7 +991,7 @@ void pcie_aspm_exit_link_state(struct pc* All PCIe functions are in one slot, remove one function will remove * the whole slot, so just wait until we are the last function left. */ -if (!list_is_last (&pdev->bus_list, &parent->subordinate->devices)) +if (!list_empty (&parent->subordinate->devices)) goto out; link = parent->link_state;
drivers/pci/remove.c +1 -3
@@ -26,9 +26,6 @@ static void pci_stop_dev(struct pci_devpci_dev_assign_added (dev, false); } - -if (dev->bus->self) -pcie_aspm_exit_link_state (dev); }static void pci_destroy_dev (struct pci_dev *dev)
@@ -42,6 +39,7 @@ static void pci_destroy_dev(struct pci_dlist_del (&dev->bus_list);up_write (&pci_bus_sem); +pcie_aspm_exit_link_state (dev);pci_bridge_d3_update (dev);pci_free_resources (dev);put_device (&dev->dev);
Greg Kroah-Hartman
maintainerPATCH 233/350 PCI: Add Device IDs for Intel GPU "spurious interrupt" quirk
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bin Meng <[email protected]>
commit d0c9606b31a21028fb5b753c8ad79626292accfd upstream.
Add Device IDs to the Intel GPU "spurious interrupt" quirk table.
For these devices, unplugging the VGA cable and plugging it in again causes spurious interrupts from the IGD. Linux eventually disables the interrupt, but of course that disables any other devices sharing the interrupt.
The theory is that this is a VGA BIOS defect: it should have disabled the IGD interrupt but failed to do so.
See f67fd55fa96f ("PCI: Add quirk for still enabled interrupts on Intel Sandy Bridge GPUs") and 7c82126a94e6 ("PCI: Add new ID for Intel GPU "spurious interrupt" quirk") for some history.
[bhelgaas: See link below for discussion about how to fix this more generically instead of adding device IDs for every new Intel GPU. I hope this is the last patch to add device IDs.]
--- drivers/pci/quirks.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/pci/quirks.c +4 -0
@@ -3177,7 +3177,11 @@ static void disable_igfx_irq(struct pci_pci_iounmap (dev, regs); } +DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_INTEL ,0x0042 , disable_igfx_irq); +DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_INTEL ,0x0046 , disable_igfx_irq); +DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_INTEL ,0x004a , disable_igfx_irq);DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_INTEL ,0x0102 , disable_igfx_irq); +DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_INTEL ,0x0106 , disable_igfx_irq);DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_INTEL ,0x010a , disable_igfx_irq);DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_INTEL ,0x0152 , disable_igfx_irq);
Greg Kroah-Hartman
maintainerPATCH 234/350 PCI: vmd: White list for fast interrupt handlers
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keith Busch <[email protected]>
commit a7f58b9ecfd3c0f63703ec10f4a592cc38dbd1b8 upstream.
Devices with slow interrupt handlers are significantly harming performance when their interrupt vector is shared with a fast device.
Create a class code white list for devices with known fast interrupt handlers and let all other devices share a single vector so that they don't interfere with performance.
At the moment, only the NVM Express class code is on the list, but more may be added if VMD users desire to use other low-latency devices in these domains.
--- drivers/pci/controller/vmd.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/pci/controller/vmd.c +12 -1
@@ -197,9 +197,20 @@ static struct vmd_irq_list *vmd_next_irqint i, best =1 ;unsigned long flags; -if (pci_is_bridge (msi_desc_to_pci_dev (desc)) || vmd->msix_count ==1 ) +if (vmd->msix_count ==1 )return &vmd->irqs[0 ]; +/* +* White list for fast-interrupt handlers. All others will share the +* "slow" interrupt vector. +*/ +switch (msi_desc_to_pci_dev (desc)->class) { +case PCI_CLASS_STORAGE_EXPRESS : +break ; +default : +return &vmd->irqs[0 ]; + } +raw_spin_lock_irqsave (&list_lock, flags);for (i =1 ; i < vmd->msix_count; i++)if (vmd->irqs[i].count < vmd->irqs[best].count)
Greg Kroah-Hartman
maintainerPATCH 235/350 signal/GenWQE: Fix sending of SIGKILL
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric W. Biederman <[email protected]>
commit 0ab93e9c99f8208c0a1a7b7170c827936268c996 upstream.
The genweq_add_file and genwqe_del_file by caching current without using reference counting embed the assumption that a file descriptor will never be passed from one process to another. It even embeds the assumption that the the thread that opened the file will be in
existence when the process terminates. Neither of which are
guaranteed to be true.
Therefore replace caching the task_struct of the opener with pid of the openers thread group id. All the knowledge of the opener is used for is as the target of SIGKILL and a SIGKILL will kill the entire process group.
Rename genwqe_force_sig to genwqe_terminate, remove it's unncessary signal argument, update it's ownly caller, and use kill_pid instead of force_sig.
The work force_sig does in changing signal handling state is not relevant to SIGKILL sent as SEND_SIG_PRIV. The exact same processess will be killed just with less work, and less confusion. The work done by force_sig is really only needed for handling syncrhonous exceptions.
It will still be possible to cause genwqe_device_remove to wait 8 seconds by passing a file descriptor to another process but the possible user after free is fixed.
--- drivers/misc/genwqe/card_base.h | 2 +- drivers/misc/genwqe/card_dev.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/misc/genwqe/card_base.h +1 -1
@@ -408,7 +408,7 @@ struct genwqe_file {struct file *filp;struct fasync_struct *async_queue; -struct task_struct *owner; +struct pid *opener;struct list_head list;/* entry in list of open files */ spinlock_t map_lock;/* lock for dma_mappings */
drivers/misc/genwqe/card_dev.c +5 -4
@@ -52,7 +52,7 @@ static void genwqe_add_file(struct genwq {unsigned long flags; - cfile->owner = current; + cfile->opener =get_pid (task_tgid (current));spin_lock_irqsave (&cd->file_lock, flags);list_add (&cfile->list, &cd->file_list);spin_unlock_irqrestore (&cd->file_lock, flags);
@@ -65,6 +65,7 @@ static int genwqe_del_file(struct genwqespin_lock_irqsave (&cd->file_lock, flags);list_del (&cfile->list);spin_unlock_irqrestore (&cd->file_lock, flags); +put_pid (cfile->opener);return 0 ; }
@@ -275,7 +276,7 @@ static int genwqe_kill_fasync(struct genreturn files; } -static int genwqe_force_sig (struct genwqe_dev *cd,int sig) +static int genwqe_terminate (struct genwqe_dev *cd) {unsigned int files =0 ;unsigned long flags;
@@ -283,7 +284,7 @@ static int genwqe_force_sig(struct genwqspin_lock_irqsave (&cd->file_lock, flags);list_for_each_entry (cfile, &cd->file_list, list) { -force_sig (sig, cfile->owner); +kill_pid (cfile->opener,SIGKILL ,1 ); files++; }spin_unlock_irqrestore (&cd->file_lock, flags);
@@ -1357,7 +1358,7 @@ static int genwqe_inform_and_stop_procesdev_warn (&pci_dev->dev,"[%s] send SIGKILL and wait ...\n" , __func__); - rc =genwqe_force_sig (cd,SIGKILL );/* force terminate */ + rc =genwqe_terminate (cd);if (rc) {/* Give kill_timout more seconds to end processes */ for (i = 0; (i < GENWQE_KILL_TIMEOUT) &&
Greg Kroah-Hartman
maintainerPATCH 236/350 signal: Guard against negative signal numbers in copy_siginfo_from_user32
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric W. Biederman <[email protected]>
commit a36700589b85443e28170be59fa11c8a104130a5 upstream.
While fixing an out of bounds array access in known_siginfo_layout reported by the kernel test robot it became apparent that the same bug exists in siginfo_layout and affects copy_siginfo_from_user32.
The straight forward fix that makes guards against making this mistake in the future and should keep the code size small is to just take an unsigned signal number instead of a signed signal number, as I did to fix known_siginfo_layout.
--- include/linux/signal.h | 2 +- kernel/signal.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/linux/signal.h +1 -1
@@ -36,7 +36,7 @@ enum siginfo_layout { SIL_SYS, }; -enum siginfo_layout siginfo_layout (int sig,int si_code); +enum siginfo_layout siginfo_layout (unsigned sig,int si_code);/* * Define some primitives to manipulate sigset_t.
kernel/signal.c +1 -1
@@ -2804,7 +2804,7 @@ COMPAT_SYSCALL_DEFINE2(rt_sigpending, co }#endif -enum siginfo_layout siginfo_layout (int sig,int si_code) +enum siginfo_layout siginfo_layout (unsigned sig,int si_code) {enum siginfo_layout layout =SIL_KILL ;if ((si_code >SI_USER ) && (si_code <SI_KERNEL )) {
Greg Kroah-Hartman
maintainerPATCH 237/350 crypto: lrw - Fix out-of bounds access on counter overflow
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ondrej Mosnacek <[email protected]>
commit fbe1a850b3b1522e9fc22319ccbbcd2ab05328d2 upstream.
When the LRW block counter overflows, the current implementation returns 128 as the index to the precomputed multiplication table, which has 128 entries. This patch fixes it to return the correct value (127).
--- crypto/lrw.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
crypto/lrw.c +6 -1
@@ -143,7 +143,12 @@ static inline int get_index128(be128 *blreturn x +ffz (val); } -return x; +/* +* If we get here, then x == 128 and we are incrementing the counter +* from all ones to all zeros. This means we must return index 127, i.e. +* the one corresponding to key2*{ 1,...,1 }. +*/ +return 127 ; }static int post_crypt (struct skcipher_request *req)
Greg Kroah-Hartman
maintainerPATCH 238/350 crypto: tcrypt - fix ghash-generic speed test
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Horia Geantă <[email protected]>
commit 331351f89c36bf7d03561a28b6f64fa10a9f6f3a upstream.
ghash is a keyed hash algorithm, thus setkey needs to be called. Otherwise the following error occurs:
$ modprobe tcrypt mode=318 sec=1 testing speed of async ghash-generic (ghash-generic) tcrypt: test 0 ( 16 byte blocks, 16 bytes per update, 1 updates): tcrypt: hashing failed ret=-126
--- crypto/tcrypt.c | 3 +++ 1 file changed, 3 insertions(+)
crypto/tcrypt.c +3 -0
@@ -1097,6 +1097,9 @@ static void test_ahash_speed_common(consbreak ; } +if (speed[i].klen) +crypto_ahash_setkey (tfm, tvmem[0 ], speed[i].klen); +pr_info ("test%3u " "(%5u byte blocks,%5u bytes per update,%4u updates): " , i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen);
Greg Kroah-Hartman
maintainerPATCH 239/350 crypto: aesni - dont use GFP_ATOMIC allocation if the request doesnt cross a page in gcm
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
commit a788848116454d753b13a4888e0e31ada3c4d393 upstream.
This patch fixes gcmaes_crypt_by_sg so that it won't use memory allocation if the data doesn't cross a page boundary.
Authenticated encryption may be used by dm-crypt. If the encryption or decryption fails, it would result in I/O error and filesystem corruption. The function gcmaes_crypt_by_sg is using GFP_ATOMIC allocation that can fail anytime. This patch fixes the logic so that it won't attempt the failing allocation if the data doesn't cross a page boundary.
--- arch/x86/crypto/aesni-intel_glue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/crypto/aesni-intel_glue.c +1 -1
@@ -817,7 +817,7 @@ static int gcmaes_crypt_by_sg(bool enc,/* Linearize assoc, if not already linear */ if (req->src->length >= assoclen && req->src->length && (!PageHighMem (sg_page (req->src)) || - req->src->offset + req->src->length <PAGE_SIZE )) { + req->src->offset + req->src->length <=PAGE_SIZE )) {scatterwalk_start (&assoc_sg_walk, req->src); assoc =scatterwalk_map (&assoc_sg_walk); }else {
Greg Kroah-Hartman
maintainerPATCH 240/350 crypto: morus/generic - fix for big endian systems
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit 5a8dedfa3276e88c5865f265195d63d72aec3e72 upstream.
Omit the endian swabbing when folding the lengths of the assoc and crypt input buffers into the state to finalize the tag. This is not necessary given that the memory representation of the state is in machine native endianness already.
This fixes an error reported by tcrypt running on a big endian system:
alg: aead: Test 2 failed on encryption for morus640-generic 00000000: a8 30 ef fb e6 26 eb 23 b0 87 dd 98 57 f3 e1 4b 00000010: 21
alg: aead: Test 2 failed on encryption for morus1280-generic 00000000: 88 19 1b fb 1c 29 49 0e ee 82 2f cb 97 a6 a5 ee 00000010: 5f
--- crypto/morus1280.c | 7 ++----- crypto/morus640.c | 16 ++++------------ 2 files changed, 6 insertions(+), 17 deletions(-)
crypto/morus1280.c +2 -5
@@ -385,14 +385,11 @@ static void crypto_morus1280_final(strucstruct morus1280_block *tag_xor, u64 assoclen, u64 cryptlen) { - u64 assocbits = assoclen * 8; -u64 cryptbits = cryptlen *8 ; - struct morus1280_block tmp;unsigned int i; - tmp.words[0 ] =cpu_to_le64 (assocbits); - tmp.words[1 ] =cpu_to_le64 (cryptbits); + tmp.words[0 ] = assoclen *8 ; + tmp.words[1 ] = cryptlen *8 ; tmp.words[2 ] =0 ; tmp.words[3 ] =0 ;
crypto/morus640.c +4 -12
@@ -384,21 +384,13 @@ static void crypto_morus640_final(structstruct morus640_block *tag_xor, u64 assoclen, u64 cryptlen) { - u64 assocbits = assoclen * 8; -u64 cryptbits = cryptlen *8 ; - -u32 assocbits_lo = (u32 )assocbits; -u32 assocbits_hi = (u32)(assocbits >>32 ); -u32 cryptbits_lo = (u32 )cryptbits; -u32 cryptbits_hi = (u32)(cryptbits >>32 ); - struct morus640_block tmp;unsigned int i; - tmp.words[0 ] =cpu_to_le32 (assocbits_lo); - tmp.words[1 ] =cpu_to_le32 (assocbits_hi); - tmp.words[2 ] =cpu_to_le32 (cryptbits_lo); - tmp.words[3 ] =cpu_to_le32 (cryptbits_hi); + tmp.words[0 ] =lower_32_bits (assoclen *8 ); + tmp.words[1 ] =upper_32_bits (assoclen *8 ); + tmp.words[2 ] =lower_32_bits (cryptlen *8 ); + tmp.words[3 ] =upper_32_bits (cryptlen *8 );for (i =0 ; i <MORUS_BLOCK_WORDS ; i++) state->s[4 ].words[i] ^= state->s[0 ].words[i];
Greg Kroah-Hartman
maintainerPATCH 241/350 crypto: aegis/generic - fix for big endian systems
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit 4a34e3c2f2f48f47213702a84a123af0fe21ad60 upstream.
Use the correct __le32 annotation and accessors to perform the single round of AES encryption performed inside the AEGIS transform. Otherwise, tcrypt reports:
alg: aead: Test 1 failed on encryption for aegis128-generic 00000000: 6c 25 25 4a 3c 10 1d 27 2b c1 d4 84 9a ef 7f 6e
alg: aead: Test 1 failed on encryption for aegis128l-generic 00000000: cd c6 e3 b8 a0 70 9d 8e c2 4f 6f fe 71 42 df 28
alg: aead: Test 1 failed on encryption for aegis256-generic 00000000: aa ed 07 b1 96 1d e9 e6 f2 ed b5 8e 1c 5f dc 1c
--- crypto/aegis.h | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)
crypto/aegis.h +10 -12
@@ -21,7 +21,7 @@union aegis_block {__le64 words64[AEGIS_BLOCK_SIZE /sizeof (__le64)]; -u32 words32[AEGIS_BLOCK_SIZE /sizeof (u32)]; +__le32 words32[AEGIS_BLOCK_SIZE /sizeof (__le32)];u8 bytes[AEGIS_BLOCK_SIZE ]; };
@@ -57,24 +57,22 @@ static void crypto_aegis_aesenc(union aeconst union aegis_block *src, const union aegis_block *key) { - u32 *d = dst->words32; const u8 *s = src->bytes; -const u32 *k = key->words32;const u32 *t0 = crypto_ft_tab[0 ];const u32 *t1 = crypto_ft_tab[1 ];const u32 *t2 = crypto_ft_tab[2 ];const u32 *t3 = crypto_ft_tab[3 ];u32 d0, d1, d2, d3; - d0 = t0[s[0 ]] ^ t1[s[5 ]] ^ t2[s[10 ]] ^ t3[s[15 ]] ^ k[0 ]; - d1 = t0[s[4 ]] ^ t1[s[9 ]] ^ t2[s[14 ]] ^ t3[s[3 ]] ^ k[1 ]; - d2 = t0[s[8 ]] ^ t1[s[13 ]] ^ t2[s[2 ]] ^ t3[s[7 ]] ^ k[2 ]; - d3 = t0[s[12 ]] ^ t1[s[1 ]] ^ t2[s[6 ]] ^ t3[s[11 ]] ^ k[3 ]; - - d[0 ] = d0; - d[1 ] = d1; - d[2 ] = d2; - d[3 ] = d3; + d0 = t0[s[0 ]] ^ t1[s[5 ]] ^ t2[s[10 ]] ^ t3[s[15 ]]; + d1 = t0[s[4 ]] ^ t1[s[9 ]] ^ t2[s[14 ]] ^ t3[s[3 ]]; + d2 = t0[s[8 ]] ^ t1[s[13 ]] ^ t2[s[2 ]] ^ t3[s[7 ]]; + d3 = t0[s[12 ]] ^ t1[s[1 ]] ^ t2[s[6 ]] ^ t3[s[11 ]]; + + dst->words32[0 ] =cpu_to_le32 (d0) ^ key->words32[0 ]; + dst->words32[1 ] =cpu_to_le32 (d1) ^ key->words32[1 ]; + dst->words32[2 ] =cpu_to_le32 (d2) ^ key->words32[2 ]; + dst->words32[3 ] =cpu_to_le32 (d3) ^ key->words32[3 ]; }#endif /* _CRYPTO_AEGIS_H */
Greg Kroah-Hartman
maintainerPATCH 242/350 crypto: speck - remove Speck
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason A. Donenfeld <[email protected]>
commit 578bdaabd015b9b164842c3e8ace9802f38e7ecc upstream.
These are unused, undesired, and have never actually been used by anybody. The original authors of this code have changed their mind about its inclusion. While originally proposed for disk encryption on low-end devices, the idea was discarded [1] in favor of something else before that could really get going. Therefore, this patch removes Speck.
[1] https://marc.info/?l=linux-crypto-vger&m=153359499015659
--- Documentation/filesystems/fscrypt.rst | 10 arch/arm/crypto/Kconfig | 6 arch/arm/crypto/Makefile | 2 arch/arm/crypto/speck-neon-core.S | 434 ------------------- arch/arm/crypto/speck-neon-glue.c | 288 ------------- arch/arm64/crypto/Kconfig | 6 arch/arm64/crypto/Makefile | 3 arch/arm64/crypto/speck-neon-core.S | 352 ---------------- arch/arm64/crypto/speck-neon-glue.c | 282 ------------ arch/m68k/configs/amiga_defconfig | 1 arch/m68k/configs/apollo_defconfig | 1 arch/m68k/configs/atari_defconfig | 1 arch/m68k/configs/bvme6000_defconfig | 1 arch/m68k/configs/hp300_defconfig | 1 arch/m68k/configs/mac_defconfig | 1 arch/m68k/configs/multi_defconfig | 1 arch/m68k/configs/mvme147_defconfig | 1 arch/m68k/configs/mvme16x_defconfig | 1 arch/m68k/configs/q40_defconfig | 1 arch/m68k/configs/sun3_defconfig | 1 arch/m68k/configs/sun3x_defconfig | 1 arch/s390/defconfig | 1 crypto/Kconfig | 14 crypto/Makefile | 1 crypto/speck.c | 307 -------------- crypto/testmgr.c | 24 - crypto/testmgr.h | 738 ---------------------------------- fs/crypto/fscrypt_private.h | 4 fs/crypto/keyinfo.c | 10 include/crypto/speck.h | 62 -- include/uapi/linux/fs.h | 4 31 files changed, 2 insertions(+), 2558 deletions(-)
Documentation/filesystems/fscrypt.rst +0 -10
@@ -191,21 +191,11 @@ Currently, the following pairs of encryp - AES-256-XTS for contents and AES-256-CTS-CBC for filenames - AES-128-CBC for contents and AES-128-CTS-CBC for filenames -- Speck128/256-XTS for contents and Speck128/256-CTS-CBC for filenames It is strongly recommended to use AES-256-XTS for contents encryption. AES-128-CBC was added only for low-powered embedded devices with crypto accelerators such as CAAM or CESA that do not support XTS. -Similarly, Speck128/256 support was only added for older or low-end -CPUs which cannot do AES fast enough -- especially ARM CPUs which have -NEON instructions but not the Cryptography Extensions -- and for which -it would not otherwise be feasible to use encryption at all. It is -not recommended to use Speck on CPUs that have AES instructions. -Speck support is only available if it has been enabled in the crypto -API via CONFIG_CRYPTO_SPECK. Also, on ARM platforms, to get -acceptable performance CONFIG_CRYPTO_SPECK_NEON must be enabled. - New encryption modes can be added relatively easily, without changes to individual filesystems. However, authenticated encryption (AE) modes are not currently supported because of the difficulty of dealing
arch/arm/crypto/Kconfig +0 -6
@@ -121,10 +121,4 @@ config CRYPTO_CHACHA20_NEON select CRYPTO_BLKCIPHER select CRYPTO_CHACHA20 -config CRYPTO_SPECK_NEON - tristate "NEON accelerated Speck cipher algorithms" - depends on KERNEL_MODE_NEON - select CRYPTO_BLKCIPHER - select CRYPTO_SPECK - endif
arch/arm/crypto/Makefile +0 -2
@@ -10,7 +10,6 @@ obj-$(CONFIG_CRYPTO_SHA1_ARM_NEON) += sh obj-$(CONFIG_CRYPTO_SHA256_ARM) += sha256-arm.o obj-$(CONFIG_CRYPTO_SHA512_ARM) += sha512-arm.o obj-$(CONFIG_CRYPTO_CHACHA20_NEON) += chacha20-neon.o -obj-$(CONFIG_CRYPTO_SPECK_NEON) += speck-neon.o ce-obj-$(CONFIG_CRYPTO_AES_ARM_CE) += aes-arm-ce.o ce-obj-$(CONFIG_CRYPTO_SHA1_ARM_CE) += sha1-arm-ce.o
@@ -54,7 +53,6 @@ ghash-arm-ce-y := ghash-ce-core.o ghash- crct10dif-arm-ce-y := crct10dif-ce-core.o crct10dif-ce-glue.o crc32-arm-ce-y:= crc32-ce-core.o crc32-ce-glue.o chacha20-neon-y := chacha20-neon-core.o chacha20-neon-glue.o -speck-neon-y := speck-neon-core.o speck-neon-glue.o ifdef REGENERATE_ARM_CRYPTO quiet_cmd_perl = PERL $@
arch/arm/crypto/speck-neon-core.S deleted +0 -434
434 lines not on this page · raw message
arch/arm/crypto/speck-neon-glue.c deleted +0 -288
288 lines not on this page · raw message
arch/arm64/crypto/Kconfig +0 -6
@@ -119,10 +119,4 @@ config CRYPTO_AES_ARM64_BS select CRYPTO_AES_ARM64 select CRYPTO_SIMD -config CRYPTO_SPECK_NEON - tristate "NEON accelerated Speck cipher algorithms" - depends on KERNEL_MODE_NEON - select CRYPTO_BLKCIPHER - select CRYPTO_SPECK - endif
arch/arm64/crypto/Makefile +0 -3
@@ -56,9 +56,6 @@ sha512-arm64-y := sha512-glue.o sha512-c obj-$(CONFIG_CRYPTO_CHACHA20_NEON) += chacha20-neon.o chacha20-neon-y := chacha20-neon-core.o chacha20-neon-glue.o -obj-$(CONFIG_CRYPTO_SPECK_NEON) += speck-neon.o -speck-neon-y := speck-neon-core.o speck-neon-glue.o - obj-$(CONFIG_CRYPTO_AES_ARM64) += aes-arm64.o aes-arm64-y := aes-cipher-core.o aes-cipher-glue.o
arch/arm64/crypto/speck-neon-core.S deleted +0 -352
352 lines not on this page · raw message
arch/arm64/crypto/speck-neon-glue.c deleted +0 -282
282 lines not on this page · raw message
arch/m68k/configs/amiga_defconfig +0 -1
@@ -650,7 +650,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/apollo_defconfig +0 -1
@@ -609,7 +609,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/atari_defconfig +0 -1
@@ -631,7 +631,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/bvme6000_defconfig +0 -1
@@ -601,7 +601,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/hp300_defconfig +0 -1
@@ -611,7 +611,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/mac_defconfig +0 -1
@@ -633,7 +633,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/multi_defconfig +0 -1
@@ -713,7 +713,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/mvme147_defconfig +0 -1
@@ -601,7 +601,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/mvme16x_defconfig +0 -1
@@ -601,7 +601,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/q40_defconfig +0 -1
@@ -624,7 +624,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/sun3_defconfig +0 -1
@@ -602,7 +602,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/sun3x_defconfig +0 -1
@@ -603,7 +603,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/s390/defconfig +0 -1
@@ -221,7 +221,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_DEFLATE=m
crypto/Kconfig +0 -14
@@ -1590,20 +1590,6 @@ config CRYPTO_SM4 If unsure, say N. -config CRYPTO_SPECK - tristate "Speck cipher algorithm" - select CRYPTO_ALGAPI - help - Speck is a lightweight block cipher that is tuned for optimal - performance in software (rather than hardware). - - Speck may not be as secure as AES, and should only be used on systems - where AES is not fast enough. - - See also: <https://eprint.iacr.org/2013/404.pdf> - - If unsure, say N. - config CRYPTO_TEA tristate "TEA, XTEA and XETA cipher algorithms" select CRYPTO_ALGAPI
crypto/Makefile +0 -1
@@ -115,7 +115,6 @@ obj-$(CONFIG_CRYPTO_TEA) += tea.o obj-$(CONFIG_CRYPTO_KHAZAD) += khazad.o obj-$(CONFIG_CRYPTO_ANUBIS) += anubis.o obj-$(CONFIG_CRYPTO_SEED) += seed.o -obj-$(CONFIG_CRYPTO_SPECK) += speck.o obj-$(CONFIG_CRYPTO_SALSA20) += salsa20_generic.o obj-$(CONFIG_CRYPTO_CHACHA20) += chacha20_generic.o obj-$(CONFIG_CRYPTO_POLY1305) += poly1305_generic.o
crypto/speck.c deleted +0 -307
307 lines not on this page · raw message
crypto/testmgr.c +0 -24
@@ -3001,18 +3001,6 @@ static const struct alg_test_desc alg_te .cipher = __VECS(sm4_tv_template) } }, { - .alg = "ecb(speck128)", - .test = alg_test_skcipher, - .suite = { - .cipher = __VECS(speck128_tv_template) - } - }, { - .alg = "ecb(speck64)", - .test = alg_test_skcipher, - .suite = { - .cipher = __VECS(speck64_tv_template) - } - }, { .alg = "ecb(tea)", .test = alg_test_skcipher, .suite = {
@@ -3540,18 +3528,6 @@ static const struct alg_test_desc alg_te .cipher = __VECS(serpent_xts_tv_template) } }, { - .alg = "xts(speck128)", - .test = alg_test_skcipher, - .suite = { - .cipher = __VECS(speck128_xts_tv_template) - } - }, { - .alg = "xts(speck64)", - .test = alg_test_skcipher, - .suite = { - .cipher = __VECS(speck64_xts_tv_template) - } - }, { .alg = "xts(twofish)", .test = alg_test_skcipher, .suite = {
crypto/testmgr.h +0 -738
744 lines not on this page · raw message
fs/crypto/fscrypt_private.h +0 -4
@@ -83,10 +83,6 @@ static inline bool fscrypt_valid_enc_mod filenames_mode == FS_ENCRYPTION_MODE_AES_256_CTS)return true; -if (contents_mode ==FS_ENCRYPTION_MODE_SPECK128_256_XTS && - filenames_mode ==FS_ENCRYPTION_MODE_SPECK128_256_CTS ) -return true; -return false; }
fs/crypto/keyinfo.c +0 -10
@@ -174,16 +174,6 @@ static struct fscrypt_mode { .cipher_str = "cts(cbc(aes))", .keysize = 16, }, - [FS_ENCRYPTION_MODE_SPECK128_256_XTS] = { - .friendly_name = "Speck128/256-XTS", - .cipher_str = "xts(speck128)", - .keysize = 64, - }, - [FS_ENCRYPTION_MODE_SPECK128_256_CTS] = { - .friendly_name = "Speck128/256-CTS-CBC", - .cipher_str = "cts(cbc(speck128))", - .keysize = 32, - }, }; static struct fscrypt_mode *
include/crypto/speck.h deleted +0 -62
62 lines not on this page · raw message
include/uapi/linux/fs.h +2 -2
@@ -279,8 +279,8 @@ struct fsxattr {#define FS_ENCRYPTION_MODE_AES_256_CTS 4#define FS_ENCRYPTION_MODE_AES_128_CBC 5#define FS_ENCRYPTION_MODE_AES_128_CTS 6 -#define FS_ENCRYPTION_MODE_SPECK128_256_XTS 7 -#define FS_ENCRYPTION_MODE_SPECK128_256_CTS 8 +#define FS_ENCRYPTION_MODE_SPECK128_256_XTS 7/* Removed, do not use. */ +#define FS_ENCRYPTION_MODE_SPECK128_256_CTS 8/* Removed, do not use. */ struct fscrypt_policy {__u8 version;
Greg Kroah-Hartman
maintainerPATCH 243/350 mm: /proc/pid/smaps_rollup: fix NULL pointer deref in smaps_pte_range()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vlastimil Babka <[email protected]>
commit fa76da461bb0be13c8339d984dcf179151167c8f upstream.
Leonardo reports an apparent regression in 4.19-rc7:
BUG: unable to handle kernel NULL pointer dereference at 00000000000000f0 PGD 0 P4D 0 Oops: 0000 [#1] PREEMPT SMP PTI CPU: 3 PID: 6032 Comm: python Not tainted 4.19.0-041900rc7-lowlatency #201810071631 Hardware name: LENOVO 80UG/Toronto 4A2, BIOS 0XCN45WW 08/09/2018 RIP: 0010:smaps_pte_range+0x32d/0x540 Code: 80 00 00 00 00 74 a9 48 89 de 41 f6 40 52 40 0f 85 04 02 00 00 49 2b 30 48 c1 ee 0c 49 03 b0 98 00 00 00 49 8b 80 a0 00 00 00 <48> 8b b8 f0 00 00 00 e8 b7 ef ec ff 48 85 c0 0f 84 71 ff ff ff a8 RSP: 0018:ffffb0cbc484fb88 EFLAGS: 00010202 RAX: 0000000000000000 RBX: 0000560ddb9e9000 RCX: 0000000000000000 RDX: 0000000000000000 RSI: 0000000560ddb9e9 RDI: 0000000000000001 RBP: ffffb0cbc484fbc0 R08: ffff94a5a227a578 R09: ffff94a5a227a578 R10: 0000000000000000 R11: 0000560ddbbe7000 R12: ffffe903098ba728 R13: ffffb0cbc484fc78 R14: ffffb0cbc484fcf8 R15: ffff94a5a2e9cf48 FS: 00007f6dfb683740(0000) GS:ffff94a5aaf80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000000000f0 CR3: 000000011c118001 CR4: 00000000003606e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: __walk_page_range+0x3c2/0x6f0 walk_page_vma+0x42/0x60 smap_gather_stats+0x79/0xe0 ? gather_pte_stats+0x320/0x320 ? gather_hugetlb_stats+0x70/0x70 show_smaps_rollup+0xcd/0x1c0 seq_read+0x157/0x400 __vfs_read+0x3a/0x180 ? security_file_permission+0x93/0xc0 ? security_file_permission+0x93/0xc0 vfs_read+0x8f/0x140 ksys_read+0x55/0xc0 __x64_sys_read+0x1a/0x20 do_syscall_64+0x5a/0x110 entry_SYSCALL_64_after_hwframe+0x44/0xa9
Decoded code matched to local compilation+disassembly points to smaps_pte_entry():
} else if (unlikely(IS_ENABLED(CONFIG_SHMEM) && mss->check_shmem_swap
&& pte_none(*pte))) {
page = find_get_entry(vma->vm_file->f_mapping,
linear_page_index(vma, addr));Here, vma->vm_file is NULL. mss->check_shmem_swap should be false in that case, however for smaps_rollup, smap_gather_stats() can set the flag true for one vma and leave it true for subsequent vma's where it should be false.
To fix, reset the check_shmem_swap flag to false. There's also related bug which sets mss->swap to shmem_swapped, which in the context of smaps_rollup overwrites any value accumulated from previous vma's. Fix that as well.
Note that the report suggests a regression between 4.17.19 and 4.19-rc7, which makes the 4.19 series ending with commit 258f669e7e88 ("mm:/proc/pid/smaps_rollup: convert to single value seq_file") suspicious. But the mss was reused for rollup since 493b0e9d945f ("mm: add /proc/pid/smaps_rollup") so let's play it safe with the stable backport.
--- fs/proc/task_mmu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/proc/task_mmu.c +3 -1
@@ -767,6 +767,8 @@ static int show_smap(struct seq_file *m, smaps_walk.private = mss;#ifdef CONFIG_SHMEM +/* In case of smaps_rollup, reset the value from previous vma */ + mss->check_shmem_swap = false;if (vma->vm_file &&shmem_mapping (vma->vm_file->f_mapping)) {/* * For shared or readonly shmem mappings we know that all
@@ -782,7 +784,7 @@ static int show_smap(struct seq_file *m,if (!shmem_swapped || (vma->vm_flags &VM_SHARED ) || !(vma->vm_flags &VM_WRITE )) { - mss->swap = shmem_swapped; + mss->swap += shmem_swapped; }else { mss->check_shmem_swap = true; smaps_walk.pte_hole = smaps_pte_hole;
Greg Kroah-Hartman
maintainerPATCH 244/350 ima: fix showing large violations or runtime_measurements_count
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 1e4c8dafbb6bf72fb5eca035b861e39c5896c2b7 upstream.
The 12 character temporary buffer is not necessarily long enough to hold a 'long' value. Increase it.
--- security/integrity/ima/ima_fs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
security/integrity/ima/ima_fs.c +3 -3
@@ -42,14 +42,14 @@ static int __init default_canonical_fmt___setup ("ima_canonical_fmt" , default_canonical_fmt_setup);static int valid_policy =1 ; -#define TMPBUFLEN 12 +static ssize_t ima_show_htable_value (char __user *buf,size_t count,loff_t *ppos,atomic_long_t *val) { -char tmpbuf[TMPBUFLEN ]; +char tmpbuf[32 ];/* greater than largest 'long' string value */ ssize_t len; - len =scnprintf (tmpbuf,TMPBUFLEN ,"%li\n" ,atomic_long_read (val)); + len =scnprintf (tmpbuf,sizeof (tmpbuf),"%li\n" ,atomic_long_read (val));return simple_read_from_buffer (buf, count, ppos, tmpbuf, len); }
Greg Kroah-Hartman
maintainerPATCH 245/350 hugetlbfs: dirty pages as they are added to pagecache
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mike Kravetz <[email protected]>
commit 22146c3ce98962436e401f7b7016a6f664c9ffb5 upstream.
Some test systems were experiencing negative huge page reserve counts and incorrect file block counts. This was traced to /proc/sys/vm/drop_caches removing clean pages from hugetlbfs file pagecaches. When non-hugetlbfs explicit code removes the pages, the appropriate accounting is not performed.
This can be recreated as follows:
fallocate -l 2M /dev/hugepages/foo
echo 1 > /proc/sys/vm/drop_caches
fallocate -l 2M /dev/hugepages/foo
grep -i huge /proc/meminfo
AnonHugePages: 0 kB
ShmemHugePages: 0 kB
HugePages_Total: 2048
HugePages_Free: 2047
HugePages_Rsvd: 18446744073709551615
HugePages_Surp: 0
Hugepagesize: 2048 kB
Hugetlb: 4194304 kB
ls -lsh /dev/hugepages/foo
4.0M -rw-r--r--. 1 root root 2.0M Oct 17 20:05 /dev/hugepages/foo
To address this issue, dirty pages as they are added to pagecache. This can easily be reproduced with fallocate as shown above. Read faulted pages will eventually end up being marked dirty. But there is a window where they are clean and could be impacted by code such as drop_caches. So, just dirty them all as they are added to the pagecache.
--- mm/hugetlb.c | 6 ++++++ 1 file changed, 6 insertions(+)
mm/hugetlb.c +6 -0
@@ -3678,6 +3678,12 @@ int huge_add_to_page_cache(struct page *return err;ClearPagePrivate (page); +/* +* set page dirty so that it will not be removed from cache/file +* by non-hugetlbfs specific code paths. +*/ +set_page_dirty (page); +spin_lock (&inode->i_lock); inode->i_blocks +=blocks_per_huge_page (h);spin_unlock (&inode->i_lock);
Greg Kroah-Hartman
maintainerPATCH 246/350 mm/rmap: map_pte() was not handling private ZONE_DEVICE page properly
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ralph Campbell <[email protected]>
commit aab8d0520e6e7c2a61f71195e6ce7007a4843afb upstream.
Private ZONE_DEVICE pages use a special pte entry and thus are not present. Properly handle this case in map_pte(), it is already handled in check_pte(), the map_pte() part was lost in some rebase most probably.
Without this patch the slow migration path can not migrate back to any private ZONE_DEVICE memory to regular memory. This was found after stress testing migration back to system memory. This ultimatly can lead to the CPU constantly page fault looping on the special swap entry.
--- mm/page_vma_mapped.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
mm/page_vma_mapped.c +23 -1
@@ -21,7 +21,29 @@ static bool map_pte(struct page_vma_mappif (!is_swap_pte (*pvmw->pte))return false; }else { -if (!pte_present (*pvmw->pte)) +/* +* We get here when we are trying to unmap a private +* device page from the process address space. Such +* page is not CPU accessible and thus is mapped as +* a special swap entry, nonetheless it still does +* count as a valid regular mapping for the page (and +* is accounted as such in page maps count). +* +* So handle this special case as if it was a normal +* page mapping ie lock CPU page table and returns +* true. +* +* For more details on device private memory see HMM +* (include/linux/hmm.h or mm/hmm.c). +*/ +if (is_swap_pte (*pvmw->pte)) { +swp_entry_t entry; + +/* Handle un-addressable ZONE_DEVICE memory */ + entry =pte_to_swp_entry (*pvmw->pte); +if (!is_device_private_entry (entry)) +return false; + }else if (!pte_present (*pvmw->pte))return false; } }
Greg Kroah-Hartman
maintainerPATCH 247/350 mm/hmm: fix race between hmm_mirror_unregister() and mmu_notifier callback
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ralph Campbell <[email protected]>
commit 86a2d59841ab0b147ffc1b7b3041af87927cf312 upstream.
In hmm_mirror_unregister(), mm->hmm is set to NULL and then mmu_notifier_unregister_no_release() is called. That creates a small window where mmu_notifier can call mmu_notifier_ops with mm->hmm equal to NULL. Fix this by first unregistering mmu notifier callbacks and then setting mm->hmm to NULL.
Similarly in hmm_register(), set mm->hmm before registering mmu_notifier callbacks so callback functions always see mm->hmm set.
--- mm/hmm.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-)
mm/hmm.c +21 -15
@@ -91,16 +91,6 @@ static struct hmm *hmm_register(struct mspin_lock_init (&hmm->lock); hmm->mm = mm; -/* -* We should only get here if hold the mmap_sem in write mode ie on -* registration of first mirror through hmm_mirror_register() -*/ - hmm->mmu_notifier.ops = &hmm_mmu_notifier_ops; -if (__mmu_notifier_register (&hmm->mmu_notifier, mm)) { -kfree (hmm); -return NULL ; - } -spin_lock (&mm->page_table_lock);if (!mm->hmm) mm->hmm = hmm;
@@ -108,12 +98,27 @@ static struct hmm *hmm_register(struct m cleanup = true;spin_unlock (&mm->page_table_lock); -if (cleanup) { -mmu_notifier_unregister (&hmm->mmu_notifier, mm); -kfree (hmm); - } +if (cleanup) + goto error; + +/* +* We should only get here if hold the mmap_sem in write mode ie on +* registration of first mirror through hmm_mirror_register() +*/ + hmm->mmu_notifier.ops = &hmm_mmu_notifier_ops; +if (__mmu_notifier_register (&hmm->mmu_notifier, mm)) + goto error_mm;return mm->hmm; + +error_mm: +spin_lock (&mm->page_table_lock); +if (mm->hmm == hmm) + mm->hmm =NULL ; +spin_unlock (&mm->page_table_lock); +error: +kfree (hmm); +return NULL ; }void hmm_mm_destroy (struct mm_struct *mm)
@@ -275,12 +280,13 @@ void hmm_mirror_unregister(struct hmm_miif (!should_unregister || mm ==NULL )return ; +mmu_notifier_unregister_no_release (&hmm->mmu_notifier, mm); +spin_lock (&mm->page_table_lock);if (mm->hmm == hmm) mm->hmm =NULL ;spin_unlock (&mm->page_table_lock); -mmu_notifier_unregister_no_release (&hmm->mmu_notifier, mm);kfree (hmm); }EXPORT_SYMBOL (hmm_mirror_unregister);
Greg Kroah-Hartman
maintainerPATCH 248/350 KVM: arm/arm64: Ensure only THP is candidate for adjustment
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Punit Agrawal <[email protected]>
commit fd2ef358282c849c193aa36dadbf4f07f7dcd29b upstream.
PageTransCompoundMap() returns true for hugetlbfs and THP hugepages. This behaviour incorrectly leads to stage 2 faults for unsupported hugepage sizes (e.g., 64K hugepage with 4K pages) to be treated as THP faults.
Tighten the check to filter out hugetlbfs pages. This also leads to consistently mapping all unsupported hugepage sizes as PTE level entries at stage 2.
--- virt/kvm/arm/mmu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
virt/kvm/arm/mmu.c +7 -1
@@ -1201,8 +1201,14 @@ static bool transparent_hugepage_adjust( {kvm_pfn_t pfn = *pfnp;gfn_t gfn = *ipap >>PAGE_SHIFT ; +struct page *page =pfn_to_page (pfn); -if (PageTransCompoundMap (pfn_to_page (pfn))) { +/* +* PageTransCompoungMap() returns true for THP and +* hugetlbfs. Make sure the adjustment is done only for THP +* pages. +*/ +if (!PageHuge (page) &&PageTransCompoundMap (page)) {unsigned long mask;/* * The address we faulted on is backed by a transparent huge
Greg Kroah-Hartman
maintainerPATCH 249/350 KVM: arm64: Fix caching of host MDCR_EL2 value
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Rutland <[email protected]>
commit da5a3ce66b8bb51b0ea8a89f42aac153903f90fb upstream.
At boot time, KVM stashes the host MDCR_EL2 value, but only does this when the kernel is not running in hyp mode (i.e. is non-VHE). In these cases, the stashed value of MDCR_EL2.HPMN happens to be zero, which can lead to CONSTRAINED UNPREDICTABLE behaviour.
Since we use this value to derive the MDCR_EL2 value when switching to/from a guest, after a guest have been run, the performance counters do not behave as expected. This has been observed to result in accesses via PMXEVTYPER_EL0 and PMXEVCNTR_EL0 not affecting the relevant counters, resulting in events not being counted. In these cases, only the fixed-purpose cycle counter appears to work as expected.
Fix this by always stashing the host MDCR_EL2 value, regardless of VHE.
--- virt/kvm/arm/arm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
virt/kvm/arm/arm.c +2 -2
@@ -1244,8 +1244,6 @@ static void cpu_init_hyp_mode(void *dumm__cpu_init_hyp_mode (pgd_ptr, hyp_stack_ptr, vector_ptr);__cpu_init_stage2 (); - -kvm_arm_init_debug (); }static void cpu_hyp_reset (void )
@@ -1269,6 +1267,8 @@ static void cpu_hyp_reinit(void)cpu_init_hyp_mode (NULL ); } +kvm_arm_init_debug (); +if (vgic_present)kvm_vgic_init_cpu_hardware (); }
Greg Kroah-Hartman
maintainerPATCH 250/350 kbuild: fix kernel/bounds.c W=1 warning
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit 6a32c2469c3fbfee8f25bcd20af647326650a6cf upstream.
Building any configuration with 'make W=1' produces a warning:
kernel/bounds.c:16:6: warning: no previous prototype for 'foo' [-Wmissing-prototypes]
When also passing -Werror, this prevents us from building any other files. Nobody ever calls the function, but we can't make it 'static' either since we want the compiler output.
Calling it 'main' instead however avoids the warning, because gcc does not insist on having a declaration for main.
--- kernel/bounds.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/bounds.c +3 -1
@@ -13,7 +13,7 @@#include <linux/log2.h> #include <linux/spinlock_types.h> -void foo (void ) +int main (void ) {/* The enum constants to put into include/generated/bounds.h */ DEFINE (NR_PAGEFLAGS , __NR_PAGEFLAGS);
@@ -23,4 +23,6 @@ void foo(void)#endif DEFINE (SPINLOCK_SIZE ,sizeof (spinlock_t));/* End of constants */ + +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 251/350 iio: ad5064: Fix regulator handling
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lars-Peter Clausen <[email protected]>
commit 8911a43bc198877fad9f4b0246a866b26bb547ab upstream.
The correct way to handle errors returned by regualtor_get() and friends is to propagate the error since that means that an regulator was specified, but something went wrong when requesting it.
For handling optional regulators, e.g. when the device has an internal vref, regulator_get_optional() should be used to avoid getting the dummy regulator that the regulator core otherwise provides.
--- drivers/iio/dac/ad5064.c | 53 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 15 deletions(-)
drivers/iio/dac/ad5064.c +38 -15
@@ -808,6 +808,40 @@ static int ad5064_set_config(struct ad50return ad5064_write (st, cmd,0 , val,0 ); } +static int ad5064_request_vref (struct ad5064_state *st,struct device *dev) +{ +unsigned int i; +int ret; + +for (i =0 ; i <ad5064_num_vref (st); ++i) + st->vref_reg[i].supply =ad5064_vref_name (st, i); + +if (!st->chip_info->internal_vref) +return devm_regulator_bulk_get (dev,ad5064_num_vref (st), + st->vref_reg); + +/* +* This assumes that when the regulator has an internal VREF +* there is only one external VREF connection, which is +* currently the case for all supported devices. +*/ + st->vref_reg[0 ].consumer =devm_regulator_get_optional (dev,"vref" ); +if (!IS_ERR (st->vref_reg[0 ].consumer)) +return 0 ; + + ret =PTR_ERR (st->vref_reg[0 ].consumer); +if (ret != -ENODEV ) +return ret; + +/* If no external regulator was supplied use the internal VREF */ + st->use_internal_vref = true; + ret =ad5064_set_config (st,AD5064_CONFIG_INT_VREF_ENABLE ); +if (ret) +dev_err (dev,"Failed to enable internal vref: %d\n" , ret); + +return ret; +} +static int ad5064_probe (struct device *dev,enum ad5064_type type,const char *name,ad5064_write_func write) {
@@ -828,22 +862,11 @@ static int ad5064_probe(struct device *d st->dev = dev; st->write = write; -for (i =0 ; i <ad5064_num_vref (st); ++i) - st->vref_reg[i].supply =ad5064_vref_name (st, i); + ret =ad5064_request_vref (st, dev); +if (ret) +return ret; - ret =devm_regulator_bulk_get (dev,ad5064_num_vref (st), - st->vref_reg); -if (ret) { -if (!st->chip_info->internal_vref) -return ret; - st->use_internal_vref = true; - ret =ad5064_set_config (st,AD5064_CONFIG_INT_VREF_ENABLE ); -if (ret) { -dev_err (dev,"Failed to enable internal vref: %d\n" , - ret); -return ret; - } - }else { +if (!st->use_internal_vref) { ret =regulator_bulk_enable (ad5064_num_vref (st), st->vref_reg);if (ret)return ret;
Greg Kroah-Hartman
maintainerPATCH 252/350 iio: adc: imx25-gcq: Fix leak of device_node in mx25_gcq_setup_cfgs()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Khoroshilov <[email protected]>
commit d3fa21c73c391975488818b085b894c2980ea052 upstream.
Leaving for_each_child_of_node loop we should release child device node, if it is not stored for future use.
Found by Linux Driver Verification project (linuxtesting.org).
JC: I'm not sending this as a quick fix as it's been wrong for years, but good to pick up for stable after the merge window.
--- drivers/iio/adc/fsl-imx25-gcq.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/iio/adc/fsl-imx25-gcq.c +6 -0
@@ -209,12 +209,14 @@ static int mx25_gcq_setup_cfgs(struct pl ret =of_property_read_u32 (child,"reg" , ®);if (ret) {dev_err (dev,"Failed to get reg property\n" ); +of_node_put (child);return ret; }if (reg >=MX25_NUM_CFGS ) {dev_err (dev,"reg value is greater than the number of available configuration registers\n" ); +of_node_put (child);return -EINVAL ; }
@@ -228,6 +230,7 @@ static int mx25_gcq_setup_cfgs(struct plif (IS_ERR (priv->vref[refp])) {dev_err (dev,"Error, trying to use external voltage reference without a vref-%s regulator." , mx25_gcq_refp_names[refp]); +of_node_put (child);return PTR_ERR (priv->vref[refp]); } priv->channel_vref_mv[reg] =
@@ -240,6 +243,7 @@ static int mx25_gcq_setup_cfgs(struct plbreak ;default :dev_err (dev,"Invalid positive reference %d\n" , refp); +of_node_put (child);return -EINVAL ; }
@@ -254,10 +258,12 @@ static int mx25_gcq_setup_cfgs(struct plif ((refp &MX25_ADCQ_CFG_REFP_MASK ) != refp) {dev_err (dev,"Invalid fsl,adc-refp property value\n" ); +of_node_put (child);return -EINVAL ; }if ((refn &MX25_ADCQ_CFG_REFN_MASK ) != refn) {dev_err (dev,"Invalid fsl,adc-refn property value\n" ); +of_node_put (child);return -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 253/350 iio: adc: at91: fix acking DRDY irq on simple conversions
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eugen Hristev <[email protected]>
commit bc1b45326223e7e890053cf6266357adfa61942d upstream.
When doing simple conversions, the driver did not acknowledge the DRDY irq. If this irq status is not acked, it will be left pending, and as soon as a trigger is enabled, the irq handler will be called, it doesn't know why this status has occurred because no channel is pending, and then it will go int a irq loop and board will hang.
To avoid this situation, read the LCDR after a raw conversion is done.
--- drivers/iio/adc/at91_adc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/adc/at91_adc.c +2 -0
@@ -279,6 +279,8 @@ static void handle_adc_eoc_trigger(int iiio_trigger_poll (idev->trig); }else { st->last_value =at91_adc_readl (st,AT91_ADC_CHAN (st, st->chnb)); +/* Needed to ACK the DRDY interruption */ +at91_adc_readl (st,AT91_ADC_LCDR ); st->done = true;wake_up_interruptible (&st->wq_data_avail); }
Greg Kroah-Hartman
maintainerPATCH 254/350 iio: adc: at91: fix wrong channel number in triggered buffer mode
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eugen Hristev <[email protected]>
commit aea835f2dc8a682942b859179c49ad1841a6c8b9 upstream.
When channels are registered, the hardware channel number is not the actual iio channel number.
This is because the driver is probed with a certain number of accessible channels. Some pins are routed and some not, depending on the description of the board in the DT.
Because of that, channels 0,1,2,3 can correspond to hardware channels 2,3,4,5 for example.
In the buffered triggered case, we need to do the translation accordingly. Fixed the channel number to stop reading the wrong channel.
--- drivers/iio/adc/at91_adc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/adc/at91_adc.c +3 -1
@@ -248,12 +248,14 @@ static irqreturn_t at91_adc_trigger_handstruct iio_poll_func *pf = p;struct iio_dev *idev = pf->indio_dev;struct at91_adc_state *st =iio_priv (idev); +struct iio_chan_spec const *chan;int i, j =0 ;for (i =0 ; i < idev->masklength; i++) {if (!test_bit (i, idev->active_scan_mask))continue ; - st->buffer[j] =at91_adc_readl (st,AT91_ADC_CHAN (st, i)); + chan = idev->channels + i; + st->buffer[j] =at91_adc_readl (st,AT91_ADC_CHAN (st, chan->channel)); j++; }
Greg Kroah-Hartman
maintainerPATCH 255/350 w1: omap-hdq: fix missing bus unregister at removal
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Kemnade <[email protected]>
commit a007734618fee1bf35556c04fa498d41d42c7301 upstream.
The bus master was not removed after unloading the module or unbinding the driver. That lead to oopses like this
[ 127.842987] Unable to handle kernel paging request at virtual address bf01d04c [ 127.850646] pgd = 70e3cd9a [ 127.853698] [bf01d04c] *pgd=8f908811, *pte=00000000, *ppte=00000000 [ 127.860412] Internal error: Oops: 80000007 [#1] PREEMPT SMP ARM [ 127.866668] Modules linked in: bq27xxx_battery overlay [last unloaded: omap_hdq] [ 127.874542] CPU: 0 PID: 1022 Comm: w1_bus_master1 Not tainted 4.19.0-rc4-00001-g2d51da718324 #12 [ 127.883819] Hardware name: Generic OMAP36xx (Flattened Device Tree) [ 127.890441] PC is at 0xbf01d04c [ 127.893798] LR is at w1_search_process_cb+0x4c/0xfc [ 127.898956] pc : [<bf01d04c>] lr : [<c05f9580>] psr: a0070013 [ 127.905609] sp : cf885f48 ip : bf01d04c fp : ddf1e11c [ 127.911132] r10: cf8fe040 r9 : c05f8d00 r8 : cf8fe040 [ 127.916656] r7 : 000000f0 r6 : cf8fe02c r5 : cf8fe000 r4 : cf8fe01c [ 127.923553] r3 : c05f8d00 r2 : 000000f0 r1 : cf8fe000 r0 : dde1ef10 [ 127.930450] Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none [ 127.938018] Control: 10c5387d Table: 8f8f0019 DAC: 00000051 [ 127.944091] Process w1_bus_master1 (pid: 1022, stack limit = 0x9135699f) [ 127.951171] Stack: (0xcf885f48 to 0xcf886000) [ 127.955810] 5f40: cf8fe000 00000000 cf884000 cf8fe090 000003e8 c05f8d00 [ 127.964477] 5f60: dde5fc34 c05f9700 ddf1e100 ddf1e540 cf884000 cf8fe000 c05f9694 00000000 [ 127.973114] 5f80: dde5fc34 c01499a4 00000000 ddf1e540 c0149874 00000000 00000000 00000000 [ 127.981781] 5fa0: 00000000 00000000 00000000 c01010e8 00000000 00000000 00000000 00000000 [ 127.990447] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 127.999114] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000 [ 128.007781] [<c05f9580>] (w1_search_process_cb) from [<c05f9700>] (w1_process+0x6c/0x118) [ 128.016479] [<c05f9700>] (w1_process) from [<c01499a4>] (kthread+0x130/0x148) [ 128.024047] [<c01499a4>] (kthread) from [<c01010e8>] (ret_from_fork+0x14/0x2c) [ 128.031677] Exception stack(0xcf885fb0 to 0xcf885ff8) [ 128.037017] 5fa0: 00000000 00000000 00000000 00000000 [ 128.045684] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 128.054351] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000 [ 128.061340] Code: bad PC value [ 128.064697] ---[ end trace af066e33c0e14119 ]---
--- drivers/w1/masters/omap_hdq.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/w1/masters/omap_hdq.c +2 -0
@@ -763,6 +763,8 @@ static int omap_hdq_remove(struct platfo/* remove module dependency */ pm_runtime_disable (&pdev->dev); +w1_remove_master_device (&omap_w1_master); +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 256/350 smb3: allow stats which track session and share reconnects to be reset
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit 2c887635cd6ab3af619dc2be94e5bf8f2e172b78 upstream.
Currently, "echo 0 > /proc/fs/cifs/Stats" resets all of the stats except the session and share reconnect counts. Fix it to reset those as well.
--- fs/cifs/cifs_debug.c | 3 +++ 1 file changed, 3 insertions(+)
fs/cifs/cifs_debug.c +3 -0
@@ -383,6 +383,9 @@ static ssize_t cifs_stats_proc_write(stratomic_set (&totBufAllocCount,0 );atomic_set (&totSmBufAllocCount,0 );#endif /* CONFIG_CIFS_STATS2 */ +atomic_set (&tcpSesReconnectCount,0 ); +atomic_set (&tconInfoReconnectCount,0 ); +spin_lock (&GlobalMid_Lock); GlobalMaxActiveXid =0 ; GlobalCurrentXid =0 ;
Greg Kroah-Hartman
maintainerPATCH 257/350 smb3: do not attempt cifs operation in smb3 query info error path
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit 1e77a8c204c9d1b655c61751b8ad0fde22421dbb upstream.
If backupuid mount option is sent, we can incorrectly retry (on access denied on query info) with a cifs (FindFirst) operation on an smb3 mount which causes the server to force the session close.
We set backup intent on open so no need for this fallback.
See kernel bugzilla 201435
--- fs/cifs/inode.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
fs/cifs/inode.c +9 -1
@@ -779,7 +779,15 @@ cifs_get_inode_info(struct inode **inode }else if (rc == -EREMOTE ) {cifs_create_dfs_fattr (&fattr, sb); rc =0 ; - }else if (rc == -EACCES &&backup_cred (cifs_sb)) { + }else if ((rc == -EACCES ) &&backup_cred (cifs_sb) && + (strcmp (server->vals->version_string,SMB1_VERSION_STRING ) + ==0 )) { +/* +* For SMB2 and later the backup intent flag is already +* sent if needed on open and there is no path based +* FindFirst operation to use to retry with +*/ + srchinf =kzalloc (sizeof (struct cifs_search_info ),GFP_KERNEL );if (srchinf ==NULL ) {
Greg Kroah-Hartman
maintainerPATCH 258/350 smb3: on kerberos mount if server doesnt specify auth type use krb5
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit 926674de6705f0f1dbf29a62fd758d0977f535d6 upstream.
Some servers (e.g. Azure) do not include a spnego blob in the SMB3 negotiate protocol response, so on kerberos mounts ("sec=krb5") we can fail, as we expected the server to list its supported auth types (OIDs in the spnego blob in the negprot response). Change this so that on krb5 mounts we default to trying krb5 if the server doesn't list its supported protocol mechanisms.
--- fs/cifs/cifs_spnego.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/cifs/cifs_spnego.c +4 -2
@@ -147,8 +147,10 @@ cifs_get_spnego_key(struct cifs_ses *sessprintf (dp,";sec=krb5" ); else if (server->sec_mskerberos) sprintf(dp, ";sec=mskrb5"); - else - goto out; + else { +cifs_dbg (VFS ,"unknown or missing server auth type, use krb5\n" ); +sprintf (dp,";sec=krb5" ); + } dp = description +strlen (description); sprintf(dp, ";uid=0x%x",
Greg Kroah-Hartman
maintainerPATCH 259/350 printk: Fix panic caused by passing log_buf_len to command line
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: He Zhe <[email protected]>
commit 277fcdb2cfee38ccdbe07e705dbd4896ba0c9930 upstream.
log_buf_len_setup does not check input argument before passing it to simple_strtoull. The argument would be a NULL pointer if "log_buf_len", without its value, is set in command line and thus causes the following panic.
PANIC: early exception 0xe3 IP 10:ffffffffaaeacd0d error 0 cr2 0x0
[ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.19.0-rc4-yocto-standard+ #1 [ 0.000000] RIP: 0010:_parse_integer_fixup_radix+0xd/0x70 ... [ 0.000000] Call Trace: [ 0.000000] simple_strtoull+0x29/0x70 [ 0.000000] memparse+0x26/0x90 [ 0.000000] log_buf_len_setup+0x17/0x22 [ 0.000000] do_early_param+0x57/0x8e [ 0.000000] parse_args+0x208/0x320 [ 0.000000] ? rdinit_setup+0x30/0x30 [ 0.000000] parse_early_options+0x29/0x2d [ 0.000000] ? rdinit_setup+0x30/0x30 [ 0.000000] parse_early_param+0x36/0x4d [ 0.000000] setup_arch+0x336/0x99e [ 0.000000] start_kernel+0x6f/0x4ee [ 0.000000] x86_64_start_reservations+0x24/0x26 [ 0.000000] x86_64_start_kernel+0x6f/0x72 [ 0.000000] secondary_startup_64+0xa4/0xb0
This patch adds a check to prevent the panic.
--- kernel/printk/printk.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
kernel/printk/printk.c +6 -1
@@ -1047,7 +1047,12 @@ static void __init log_buf_len_update(un/* save requested log_buf_len since it's too early to process it */ static int __init log_buf_len_setup (char *str) { -unsigned size =memparse (str, &str); +unsigned int size; + +if (!str) +return -EINVAL ; + + size =memparse (str, &str);log_buf_len_update (size);
Greg Kroah-Hartman
maintainerPATCH 260/350 genirq: Fix race on spurious interrupt detection
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Wunner <[email protected]>
commit 746a923b863a1065ef77324e1e43f19b1a3eab5c upstream.
Commit 1e77d0a1ed74 ("genirq: Sanitize spurious interrupt detection of threaded irqs") made detection of spurious interrupts work for threaded handlers by:
a) incrementing a counter every time the thread returns IRQ_HANDLED, and
b) checking whether that counter has increased every time the thread is woken.
However for oneshot interrupts, the commit unmasks the interrupt before incrementing the counter. If another interrupt occurs right after unmasking but before the counter is incremented, that interrupt is incorrectly considered spurious:
time
| irq_thread() | irq_thread_fn() | action->thread_fn() | irq_finalize_oneshot() | unmask_threaded_irq() /* interrupt is unmasked */ | | /* interrupt fires, incorrectly deemed spurious */ | | atomic_inc(&desc->threads_handled); /* counter is incremented */
v
This is observed with a hi3110 CAN controller receiving data at high volume (from a separate machine sending with "cangen -g 0 -i -x"): The controller signals a huge number of interrupts (hundreds of millions per day) and every second there are about a dozen which are deemed spurious.
In theory with high CPU load and the presence of higher priority tasks, the number of incorrectly detected spurious interrupts might increase beyond the 99,900 threshold and cause disablement of the interrupt.
In practice it just increments the spurious interrupt count. But that can cause people to waste time investigating it over and over.
Fix it by moving the accounting before the invocation of irq_finalize_oneshot().
[ tglx: Folded change log update ]
--- kernel/irq/manage.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
kernel/irq/manage.c +6 -2
@@ -920,6 +920,9 @@ irq_forced_thread_fn(struct irq_desc *delocal_bh_disable (); ret = action->thread_fn (action->irq, action->dev_id); +if (ret ==IRQ_HANDLED ) +atomic_inc (&desc->threads_handled); +irq_finalize_oneshot (desc, action);local_bh_enable ();return ret;
@@ -936,6 +939,9 @@ static irqreturn_t irq_thread_fn(structirqreturn_t ret; ret = action->thread_fn (action->irq, action->dev_id); +if (ret ==IRQ_HANDLED ) +atomic_inc (&desc->threads_handled); +irq_finalize_oneshot (desc, action);return ret; }
@@ -1013,8 +1019,6 @@ static int irq_thread(void *data)irq_thread_check_affinity (desc, action); action_ret =handler_fn (desc, action); -if (action_ret ==IRQ_HANDLED ) -atomic_inc (&desc->threads_handled);if (action_ret ==IRQ_WAKE_THREAD )irq_wake_secondary (desc, action);
Greg Kroah-Hartman
maintainerPATCH 261/350 NFC: nfcmrvl_uart: fix OF child-node lookup
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 5bf59773aaf36dd62117dc83d50e1bbf9ef432da upstream.
Use the new of_get_compatible_child() helper to lookup the nfc child node instead of using of_find_compatible_node(), which searches the entire tree from a given start node and thus can return an unrelated (i.e. non-child) node.
This also addresses a potential use-after-free (e.g. after probe deferral) as the tree-wide helper drops a reference to its first argument (i.e. the parent node).
--- drivers/nfc/nfcmrvl/uart.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/nfc/nfcmrvl/uart.c +2 -3
@@ -73,10 +73,9 @@ static int nfcmrvl_uart_parse_dt(structstruct device_node *matched_node;int ret; - matched_node =of_find_compatible_node (node,NULL ,"marvell,nfc-uart" ); + matched_node =of_get_compatible_child (node,"marvell,nfc-uart" );if (!matched_node) { - matched_node =of_find_compatible_node (node,NULL , -"mrvl,nfc-uart" ); + matched_node =of_get_compatible_child (node,"mrvl,nfc-uart" );if (!matched_node)return -ENODEV ; }
Greg Kroah-Hartman
maintainerPATCH 262/350 NFSv4.1: Fix the r/wsize checking
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
commit 943cff67b842839f4f35364ba2db5c2d3f025d94 upstream.
The intention of nfs4_session_set_rwsize() was to cap the r/wsize to the buffer sizes negotiated by the CREATE_SESSION. The initial code had a bug whereby we would not check the values negotiated by nfs_probe_fsinfo() (the assumption being that CREATE_SESSION will always negotiate buffer values that are sane w.r.t. the server's preferred r/wsizes) but would only check values set by the user in the 'mount' command.
The code was changed in 4.11 to _always_ set the r/wsize, meaning that we now never use the server preferred r/wsizes. This is the regression that this patch fixes.
Also rename the function to nfs4_session_limit_rwsize() in order to avoid future confusion.
--- fs/nfs/nfs4client.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
fs/nfs/nfs4client.c +9 -7
@@ -935,10 +935,10 @@ EXPORT_SYMBOL_GPL(nfs4_set_ds_client);/* * Session has been established, and the client marked ready. -* Set the mount rsize and wsize with negotiated fore channel -* attributes which will be bound checked in nfs_server_set_fsinfo. +* Limit the mount rsize, wsize and dtsize using negotiated fore +* channel attributes. */ -static void nfs4_session_set_rwsize (struct nfs_server *server) +static void nfs4_session_limit_rwsize (struct nfs_server *server) {#ifdef CONFIG_NFS_V4_1 struct nfs4_session *sess;
@@ -951,9 +951,11 @@ static void nfs4_session_set_rwsize(stru server_resp_sz = sess->fc_attrs.max_resp_sz - nfs41_maxread_overhead; server_rqst_sz = sess->fc_attrs.max_rqst_sz - nfs41_maxwrite_overhead; -if (!server->rsize || server->rsize > server_resp_sz) +if (server->dtsize > server_resp_sz) + server->dtsize = server_resp_sz; +if (server->rsize > server_resp_sz) server->rsize = server_resp_sz; -if (!server->wsize || server->wsize > server_rqst_sz) +if (server->wsize > server_rqst_sz) server->wsize = server_rqst_sz;#endif /* CONFIG_NFS_V4_1 */ }
@@ -1000,12 +1002,12 @@ static int nfs4_server_common_setup(stru (unsigned long long) server->fsid.minor);nfs_display_fhandle (mntfh,"Pseudo-fs root FH" ); -nfs4_session_set_rwsize (server); - error =nfs_probe_fsinfo (server, mntfh, fattr);if (error <0 ) goto out; +nfs4_session_limit_rwsize (server); +if (server->namelen ==0 || server->namelen >NFS4_MAXNAMLEN ) server->namelen =NFS4_MAXNAMLEN ;
Greg Kroah-Hartman
maintainerPATCH 263/350 nfs: Fix a missed page unlock after pg_doio()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Coddington <[email protected]>
commit fdbd1a2e4a71adcb1ae219fcfd964930d77a7f84 upstream.
We must check pg_error and call error_cleanup after any call to pg_doio. Currently, we are skipping the unlock of a page if we encounter an error in nfs_pageio_complete() before handing off the work to the RPC layer.
--- fs/nfs/pagelist.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-)
fs/nfs/pagelist.c +21 -19
@@ -1110,6 +1110,20 @@ static int nfs_pageio_add_request_mirrorreturn ret; } +static void nfs_pageio_error_cleanup (struct nfs_pageio_descriptor *desc) +{ +u32 midx; +struct nfs_pgio_mirror *mirror; + +if (!desc->pg_error) +return ; + +for (midx =0 ; midx < desc->pg_mirror_count; midx++) { + mirror = &desc->pg_mirrors[midx]; + desc->pg_completion_ops->error_cleanup (&mirror->pg_list); + } +} +int nfs_pageio_add_request (struct nfs_pageio_descriptor *desc,struct nfs_page *req) {
@@ -1160,25 +1174,11 @@ int nfs_pageio_add_request(struct nfs_pareturn 1 ; out_failed: -/* -* We might have failed before sending any reqs over wire. -* Clean up rest of the reqs in mirror pg_list. -*/ -if (desc->pg_error) { -struct nfs_pgio_mirror *mirror; -void (*func)(struct list_head *); - -/* remember fatal errors */ -if (nfs_error_is_fatal (desc->pg_error)) -nfs_context_set_write_error (req->wb_context, - desc->pg_error); - - func = desc->pg_completion_ops->error_cleanup; -for (midx =0 ; midx < desc->pg_mirror_count; midx++) { - mirror = &desc->pg_mirrors[midx]; -func (&mirror->pg_list); - } - } +/* remember fatal errors */ +if (nfs_error_is_fatal (desc->pg_error)) +nfs_context_set_write_error (req->wb_context, + desc->pg_error); +nfs_pageio_error_cleanup (desc);return 0 ; }
@@ -1250,6 +1250,8 @@ void nfs_pageio_complete(struct nfs_pagefor (midx =0 ; midx < desc->pg_mirror_count; midx++)nfs_pageio_complete_mirror (desc, midx); +if (desc->pg_error <0 ) +nfs_pageio_error_cleanup (desc);if (desc->pg_ops->pg_cleanup) desc->pg_ops->pg_cleanup (desc);nfs_pageio_cleanup_mirroring (desc);
Greg Kroah-Hartman
maintainerPATCH 264/350 nfsd: correctly decrement odstate refcount in error path
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Elble <[email protected]>
commit bd8d725078867cda250fe94b9c5a067b4a64ca74 upstream.
alloc_init_deleg() both allocates an nfs4_delegation, and bumps the refcount on odstate. So after this point, we need to put_clnt_odstate() and nfs4_put_stid() to not leave the odstate refcount inappropriately bumped.
--- fs/nfsd/nfs4state.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/nfsd/nfs4state.c +1 -2
@@ -4361,7 +4361,7 @@ nfs4_set_delegation(struct nfs4_client * fl =nfs4_alloc_init_lease (dp,NFS4_OPEN_DELEGATE_READ );if (!fl) - goto out_stid; + goto out_clnt_odstate; status =vfs_setlease (fp->fi_deleg_file, fl->fl_type, &fl,NULL );if (fl)
@@ -4386,7 +4386,6 @@ out_unlock:vfs_setlease (fp->fi_deleg_file,F_UNLCK ,NULL , (void **)&dp); out_clnt_odstate:put_clnt_odstate (dp->dl_clnt_odstate); -out_stid:nfs4_put_stid (&dp->dl_stid); out_delegees:put_deleg_file (fp);
Greg Kroah-Hartman
maintainerPATCH 265/350 nfsd: Fix an Oops in free_session()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
commit bb6ad5572c0022e17e846b382d7413cdcf8055be upstream.
In call_xpt_users(), we delete the entry from the list, but we do not reinitialise it. This triggers the list poisoning when we later call unregister_xpt_user() in nfsd4_del_conns().
--- net/sunrpc/svc_xprt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sunrpc/svc_xprt.c +1 -1
@@ -989,7 +989,7 @@ static void call_xpt_users(struct svc_xpspin_lock (&xprt->xpt_lock);while (!list_empty (&xprt->xpt_users)) { u = list_first_entry(&xprt->xpt_users, struct svc_xpt_user, list); -list_del (&u->list); +list_del_init (&u->list); u->callback (u); }spin_unlock (&xprt->xpt_lock);
Greg Kroah-Hartman
maintainerPATCH 266/350 lockd: fix access beyond unterminated strings in prints
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amir Goldstein <[email protected]>
commit 93f38b6fae0ea8987e22d9e6c38f8dfdccd867ee upstream.
printk format used %*s instead of %.*s, so hostname_len does not limit the number of bytes accessed from hostname.
--- fs/lockd/host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/lockd/host.c +1 -1
@@ -341,7 +341,7 @@ struct nlm_host *nlmsvc_lookup_host(cons };struct lockd_net *ln =net_generic (net, lockd_net_id); -dprintk ("lockd: %s(host='%*s', vers=%u, proto=%s)\n" , __func__, +dprintk ("lockd: %s(host='%.*s', vers=%u, proto=%s)\n" , __func__, (int )hostname_len, hostname, rqstp->rq_vers, (rqstp->rq_prot ==IPPROTO_UDP ?"udp" :"tcp" ));
Greg Kroah-Hartman
maintainerPATCH 267/350 dm ioctl: harden copy_params()s copy_from_user() from malicious users
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wenwen Wang <[email protected]>
commit 800a7340ab7dd667edf95e74d8e4f23a17e87076 upstream.
In copy_params(), the struct 'dm_ioctl' is first copied from the user space buffer 'user' to 'param_kernel' and the field 'data_size' is checked against 'minimum_data_size' (size of 'struct dm_ioctl' payload up to its 'data' member). If the check fails, an error code EINVAL will be returned. Otherwise, param_kernel->data_size is used to do a second copy, which copies from the same user-space buffer to 'dmi'. After the second copy, only 'dmi->data_size' is checked against 'param_kernel->data_size'. Given that the buffer 'user' resides in the user space, a malicious user-space process can race to change the content in the buffer between the two copies. This way, the attacker can inject inconsistent data into 'dmi' (versus previously validated 'param_kernel').
Fix redundant copying of 'minimum_data_size' from user-space buffer by using the first copy stored in 'param_kernel'. Also remove the 'data_size' check after the second copy because it is now unnecessary.
--- drivers/md/dm-ioctl.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/md/dm-ioctl.c +6 -12
@@ -1720,8 +1720,7 @@ static void free_params(struct dm_ioctl }static int copy_params (struct dm_ioctl __user *user,struct dm_ioctl *param_kernel, -int ioctl_flags, -struct dm_ioctl **param,int *param_flags) +int ioctl_flags,struct dm_ioctl **param,int *param_flags) {struct dm_ioctl *dmi;int secure_data;
@@ -1762,18 +1761,13 @@ static int copy_params(struct dm_ioctl _ *param_flags |=DM_PARAMS_MALLOC ; -if (copy_from_user (dmi, user, param_kernel->data_size)) - goto bad; +/* Copy from param_kernel (which was already copied from user) */ +memcpy (dmi, param_kernel, minimum_data_size); -data_copied: -/* -* Abort if something changed the ioctl data while it was being copied. -*/ -if (dmi->data_size != param_kernel->data_size) { -DMERR ("rejecting ioctl: data size modified while processing parameters" ); +if (copy_from_user (&dmi->data, (char __user *)user + minimum_data_size, + param_kernel->data_size - minimum_data_size)) goto bad; - } - +data_copied:/* Wipe the user buffer so we do not return it to userspace */ if (secure_data &&clear_user (user, param_kernel->data_size)) goto bad;
Greg Kroah-Hartman
maintainerPATCH 268/350 dm zoned: fix metadata block ref counting
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
commit 33c2865f8d011a2ca9f67124ddab9dc89382e9f1 upstream.
Since the ref field of struct dmz_mblock is always used with the spinlock of struct dmz_metadata locked, there is no need to use an atomic_t type. Change the type of the ref field to an unsigne integer.
--- drivers/md/dm-zoned-metadata.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
drivers/md/dm-zoned-metadata.c +11 -9
@@ -99,7 +99,7 @@ struct dmz_mblock {struct rb_node node;struct list_head link;sector_t no; -atomic_t ref; +unsigned int ref;unsigned long state;struct page *page;void *data;
@@ -296,7 +296,7 @@ static struct dmz_mblock *dmz_alloc_mbloRB_CLEAR_NODE (&mblk->node);INIT_LIST_HEAD (&mblk->link); -atomic_set (&mblk->ref,0 ); + mblk->ref =0 ; mblk->state =0 ; mblk->no = mblk_no; mblk->data =page_address (mblk->page);
@@ -397,7 +397,7 @@ static struct dmz_mblock *dmz_fetch_mbloreturn NULL ;spin_lock (&zmd->mblk_lock); -atomic_inc (&mblk->ref); + mblk->ref++;set_bit (DMZ_META_READING , &mblk->state);dmz_insert_mblock (zmd, mblk);spin_unlock (&zmd->mblk_lock);
@@ -484,7 +484,8 @@ static void dmz_release_mblock(struct dmspin_lock (&zmd->mblk_lock); -if (atomic_dec_and_test (&mblk->ref)) { + mblk->ref--; +if (mblk->ref ==0 ) {if (test_bit (DMZ_META_ERROR , &mblk->state)) {rb_erase (&mblk->node, &zmd->mblk_rbtree);dmz_free_mblock (zmd, mblk);
@@ -511,7 +512,8 @@ static struct dmz_mblock *dmz_get_mblock mblk =dmz_lookup_mblock (zmd, mblk_no);if (mblk) {/* Cache hit: remove block from LRU list */ -if (atomic_inc_return (&mblk->ref) ==1 && + mblk->ref++; +if (mblk->ref ==1 && !test_bit (DMZ_META_DIRTY , &mblk->state))list_del_init (&mblk->link); }
@@ -753,7 +755,7 @@ int dmz_flush_metadata(struct dmz_metadaspin_lock (&zmd->mblk_lock);clear_bit (DMZ_META_DIRTY , &mblk->state); -if (atomic_read (&mblk->ref) ==0 ) +if (mblk->ref ==0 )list_add_tail (&mblk->link, &zmd->mblk_lru_list);spin_unlock (&zmd->mblk_lock); }
@@ -2308,7 +2310,7 @@ static void dmz_cleanup_metadata(struct mblk =list_first_entry (&zmd->mblk_dirty_list, struct dmz_mblock, link);dmz_dev_warn (zmd->dev,"mblock %llu still in dirty list (ref %u)" , - (u64 )mblk->no,atomic_read (&mblk->ref)); + (u64 )mblk->no, mblk->ref);list_del_init (&mblk->link);rb_erase (&mblk->node, &zmd->mblk_rbtree);dmz_free_mblock (zmd, mblk);
@@ -2326,8 +2328,8 @@ static void dmz_cleanup_metadata(struct root = &zmd->mblk_rbtree;rbtree_postorder_for_each_entry_safe (mblk, next, root, node) {dmz_dev_warn (zmd->dev,"mblock %llu ref %u still in rbtree" , - (u64 )mblk->no,atomic_read (&mblk->ref)); -atomic_set (&mblk->ref,0 ); + (u64 )mblk->no, mblk->ref); + mblk->ref =0 ;dmz_free_mblock (zmd, mblk); }
Greg Kroah-Hartman
maintainerPATCH 269/350 dm zoned: fix various dmz_get_mblock() issues
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
commit 3d4e738311327bc4ba1d55fbe2f1da3de4a475f9 upstream.
dmz_fetch_mblock() called from dmz_get_mblock() has a race since the allocation of the new metadata block descriptor and its insertion in the cache rbtree with the READING state is not atomic. Two different contexts requesting the same block may end up each adding two different descriptors of the same block to the cache.
Another problem for this function is that the BIO for processing the block read is allocated after the metadata block descriptor is inserted in the cache rbtree. If the BIO allocation fails, the metadata block descriptor is freed without first being removed from the rbtree.
Fix the first problem by checking again if the requested block is not in the cache right before inserting the newly allocated descriptor, atomically under the mblk_lock spinlock. The second problem is fixed by simply allocating the BIO before inserting the new block in the cache.
Finally, since dmz_fetch_mblock() also increments a block reference counter, rename the function to dmz_get_mblock_slow(). To be symmetric and clear, also rename dmz_lookup_mblock() to dmz_get_mblock_fast() and increment the block reference counter directly in that function rather than in dmz_get_mblock().
--- drivers/md/dm-zoned-metadata.c | 66 ++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 24 deletions(-)
drivers/md/dm-zoned-metadata.c +42 -24
@@ -339,10 +339,11 @@ static void dmz_insert_mblock(struct dmz }/* -* Lookup a metadata block in the rbtree. +* Lookup a metadata block in the rbtree. If the block is found, increment +* its reference count. */ -static struct dmz_mblock *dmz_lookup_mblock (struct dmz_metadata *zmd, -sector_t mblk_no) +static struct dmz_mblock *dmz_get_mblock_fast (struct dmz_metadata *zmd, +sector_t mblk_no) {struct rb_root *root = &zmd->mblk_rbtree;struct rb_node *node = root->rb_node;
@@ -350,8 +351,17 @@ static struct dmz_mblock *dmz_lookup_mblwhile (node) { mblk = container_of(node, struct dmz_mblock, node); -if (mblk->no == mblk_no) +if (mblk->no == mblk_no) { +/* +* If this is the first reference to the block, +* remove it from the LRU list. +*/ + mblk->ref++; +if (mblk->ref ==1 && + !test_bit (DMZ_META_DIRTY , &mblk->state)) +list_del_init (&mblk->link);return mblk; + } node = (mblk->no < mblk_no) ? node->rb_left : node->rb_right; }
@@ -382,32 +392,47 @@ static void dmz_mblock_bio_end_io(struct }/* -* Read a metadata block from disk. +* Read an uncached metadata block from disk and add it to the cache. */ -static struct dmz_mblock *dmz_fetch_mblock (struct dmz_metadata *zmd, -sector_t mblk_no) +static struct dmz_mblock *dmz_get_mblock_slow (struct dmz_metadata *zmd, +sector_t mblk_no) { -struct dmz_mblock *mblk; +struct dmz_mblock *mblk, *m;sector_t block = zmd->sb[zmd->mblk_primary].block + mblk_no;struct bio *bio; -/* Get block and insert it */ +/* Get a new block and a BIO to read it */ mblk =dmz_alloc_mblock (zmd, mblk_no);if (!mblk)return NULL ; -spin_lock (&zmd->mblk_lock); - mblk->ref++; -set_bit (DMZ_META_READING , &mblk->state); -dmz_insert_mblock (zmd, mblk); -spin_unlock (&zmd->mblk_lock); - bio =bio_alloc (GFP_NOIO ,1 );if (!bio) {dmz_free_mblock (zmd, mblk);return NULL ; } +spin_lock (&zmd->mblk_lock); + +/* +* Make sure that another context did not start reading +* the block already. +*/ + m =dmz_get_mblock_fast (zmd, mblk_no); +if (m) { +spin_unlock (&zmd->mblk_lock); +dmz_free_mblock (zmd, mblk); +bio_put (bio); +return m; + } + + mblk->ref++; +set_bit (DMZ_META_READING , &mblk->state); +dmz_insert_mblock (zmd, mblk); + +spin_unlock (&zmd->mblk_lock); + +/* Submit read BIO */ bio->bi_iter.bi_sector =dmz_blk2sect (block);bio_set_dev (bio, zmd->dev->bdev); bio->bi_private = mblk;
@@ -509,19 +534,12 @@ static struct dmz_mblock *dmz_get_mblock/* Check rbtree */ spin_lock (&zmd->mblk_lock); - mblk =dmz_lookup_mblock (zmd, mblk_no); -if (mblk) { -/* Cache hit: remove block from LRU list */ - mblk->ref++; -if (mblk->ref ==1 && - !test_bit (DMZ_META_DIRTY , &mblk->state)) -list_del_init (&mblk->link); - } + mblk =dmz_get_mblock_fast (zmd, mblk_no);spin_unlock (&zmd->mblk_lock);if (!mblk) {/* Cache miss: read the block from disk */ - mblk =dmz_fetch_mblock (zmd, mblk_no); + mblk =dmz_get_mblock_slow (zmd, mblk_no);if (!mblk)return ERR_PTR (-ENOMEM ); }
Greg Kroah-Hartman
maintainerPATCH 270/350 media: ov7670: make "xclk" clock optional
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lubomir Rintel <[email protected]>
commit 786fa584eda86d6598db3b87c61dc81f68808d11 upstream.
When the "xclk" clock was added, it was made mandatory. This broke the driver on an OLPC plaform which doesn't know such clock. Make it optional.
Tested on a OLPC XO-1 laptop.
--- drivers/media/i2c/ov7670.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
drivers/media/i2c/ov7670.c +17 -10
@@ -1810,17 +1810,24 @@ static int ov7670_probe(struct i2c_clien info->pclk_hb_disable = true; } - info->clk =devm_clk_get (&client->dev,"xclk" ); -if (IS_ERR (info->clk)) -return PTR_ERR (info->clk); - ret =clk_prepare_enable (info->clk); -if (ret) -return ret; + info->clk =devm_clk_get (&client->dev,"xclk" );/* optional */ +if (IS_ERR (info->clk)) { + ret =PTR_ERR (info->clk); +if (ret == -ENOENT ) + info->clk =NULL ; +else +return ret; + } +if (info->clk) { + ret =clk_prepare_enable (info->clk); +if (ret) +return ret; - info->clock_speed =clk_get_rate (info->clk) /1000000 ; -if (info->clock_speed <10 || info->clock_speed >48 ) { - ret = -EINVAL ; - goto clk_disable; + info->clock_speed =clk_get_rate (info->clk) /1000000 ; +if (info->clock_speed <10 || info->clock_speed >48 ) { + ret = -EINVAL ; + goto clk_disable; + } } ret =ov7670_init_gpio (client, info);
Greg Kroah-Hartman
maintainerPATCH 271/350 fsnotify: Fix busy inodes during unmount
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit 721fb6fbfd2132164c2e8777cc837f9b2c1794dc upstream.
Detaching of mark connector from fsnotify_put_mark() can race with unmounting of the filesystem like:
CPU1 CPU2fsnotify_put_mark()
spin_lock(&conn->lock);
...
inode = fsnotify_detach_connector_from_object(conn) spin_unlock(&conn->lock);
generic_shutdown_super()
fsnotify_unmount_inodes()
sees connector detached for inode
-> nothing to do
evict_inode()
barfs on pending inode reference
iput(inode);
Resulting in "Busy inodes after unmount" message and possible kernel oops. Make fsnotify_unmount_inodes() properly wait for outstanding inode references from detached connectors.
Note that the accounting of outstanding inode references in the superblock can cause some cacheline contention on the counter. OTOH it happens only during deletion of the last notification mark from an inode (or during unlinking of watched inode) and that is not too bad. I have measured time to create & delete inotify watch 100000 times from 64 processes in parallel (each process having its own inotify group and its own file on a shared superblock) on a 64 CPU machine. Average and standard deviation of 15 runs look like:
Avg Stddev
Vanilla 9.817400 0.276165
Fixed 9.710467 0.228294
So there's no statistically significant difference.
--- fs/notify/fsnotify.c | 3 +++ fs/notify/mark.c | 39 +++++++++++++++++++++++++++++++-------- include/linux/fs.h | 3 +++ 3 files changed, 37 insertions(+), 8 deletions(-)
fs/notify/fsnotify.c +3 -0
@@ -96,6 +96,9 @@ void fsnotify_unmount_inodes(struct supeif (iput_inode)iput (iput_inode); +/* Wait for outstanding inode references from connectors */ +wait_var_event (&sb->s_fsnotify_inode_refs, + !atomic_long_read (&sb->s_fsnotify_inode_refs)); }/*
fs/notify/mark.c +31 -8
@@ -161,15 +161,18 @@ static void fsnotify_connector_destroy_w } } -static struct inode *fsnotify_detach_connector_from_object ( -struct fsnotify_mark_connector *conn) +static void *fsnotify_detach_connector_from_object ( +struct fsnotify_mark_connector *conn, +unsigned int *type) {struct inode *inode =NULL ; + *type = conn->type;if (conn->type ==FSNOTIFY_OBJ_TYPE_INODE ) { inode = conn->inode;rcu_assign_pointer (inode->i_fsnotify_marks,NULL ); inode->i_fsnotify_mask =0 ; +atomic_long_inc (&inode->i_sb->s_fsnotify_inode_refs); conn->inode =NULL ; conn->type =FSNOTIFY_OBJ_TYPE_DETACHED ; }else if (conn->type ==FSNOTIFY_OBJ_TYPE_VFSMOUNT ) {
@@ -193,10 +196,29 @@ static void fsnotify_final_mark_destroy(fsnotify_put_group (group); } +/* Drop object reference originally held by a connector */ +static void fsnotify_drop_object (unsigned int type,void *objp) +{ +struct inode *inode; +struct super_block *sb; + +if (!objp) +return ; +/* Currently only inode references are passed to be dropped */ +if (WARN_ON_ONCE (type !=FSNOTIFY_OBJ_TYPE_INODE )) +return ; + inode = objp; + sb = inode->i_sb; +iput (inode); +if (atomic_long_dec_and_test (&sb->s_fsnotify_inode_refs)) +wake_up_var (&sb->s_fsnotify_inode_refs); +} +void fsnotify_put_mark (struct fsnotify_mark *mark) {struct fsnotify_mark_connector *conn; -struct inode *inode =NULL ; +void *objp =NULL ; +unsigned int type =FSNOTIFY_OBJ_TYPE_DETACHED ;bool free_conn = false;/* Catch marks that were actually never attached to object */
@@ -216,7 +238,7 @@ void fsnotify_put_mark(struct fsnotify_m conn = mark->connector;hlist_del_init_rcu (&mark->obj_list);if (hlist_empty (&conn->list)) { - inode =fsnotify_detach_connector_from_object (conn); + objp =fsnotify_detach_connector_from_object (conn, &type); free_conn = true; }else {__fsnotify_recalc_mask (conn);
@@ -224,7 +246,7 @@ void fsnotify_put_mark(struct fsnotify_m mark->connector =NULL ;spin_unlock (&conn->lock); -iput (inode); +fsnotify_drop_object (type, objp);if (free_conn) {spin_lock (&destroy_lock);
@@ -702,7 +724,8 @@ void fsnotify_destroy_marks(struct fsnot {struct fsnotify_mark_connector *conn;struct fsnotify_mark *mark, *old_mark =NULL ; -struct inode *inode; +void *objp; +unsigned int type; conn =fsnotify_grab_connector (connp);if (!conn)
@@ -728,11 +751,11 @@ void fsnotify_destroy_marks(struct fsnot* mark references get dropped. It would lead to strange results such * as delaying inode deletion or blocking unmount. */ - inode =fsnotify_detach_connector_from_object (conn); + objp =fsnotify_detach_connector_from_object (conn, &type);spin_unlock (&conn->lock);if (old_mark)fsnotify_put_mark (old_mark); -iput (inode); +fsnotify_drop_object (type, objp); }/*
include/linux/fs.h +3 -0
@@ -1416,6 +1416,9 @@ struct super_block {/* Number of inodes with nlink == 0 but still referenced */ atomic_long_t s_remove_count; +/* Pending fsnotify inode refs */ +atomic_long_t s_fsnotify_inode_refs; +/* Being remounted read-only */ int s_readonly_remount;
Greg Kroah-Hartman
maintainerPATCH 272/350 powerpc/msi: Fix compile error on mpc83xx
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Leroy <[email protected]>
commit 0f99153def98134403c9149128e59d3e1786cf04 upstream.
mpic_get_primary_version() is not defined when not using MPIC. The compile error log like:
arch/powerpc/sysdev/built-in.o: In function `fsl_of_msi_probe':
fsl_msi.c:(.text+0x150c): undefined reference to `fsl_mpic_primary_get_version'
--- arch/powerpc/include/asm/mpic.h | 7 +++++++ 1 file changed, 7 insertions(+)
arch/powerpc/include/asm/mpic.h +7 -0
@@ -393,7 +393,14 @@ extern struct bus_type mpic_subsys;#define MPIC_REGSET_TSI108 MPIC_REGSET(1)/* Tsi108/109 PIC */ /* Get the version of primary MPIC */ +#ifdef CONFIG_MPIC extern u32 fsl_mpic_primary_get_version (void ); +#else +static inline u32 fsl_mpic_primary_get_version (void ) +{ +return 0 ; +} +#endif /* Allocate the controller structure and setup the linux irq descs * for the range if interrupts passed in. No HW initialization is
Greg Kroah-Hartman
maintainerPATCH 273/350 powerpc/tm: Fix HFSCR bit for no suspend case
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Neuling <[email protected]>
commit dd9a8c5a87395b6f05552c3b44e42fdc95760552 upstream.
Currently on P9N DD2.1 we end up taking infinite TM facility unavailable exceptions on the first TM usage by userspace.
In the special case of TM no suspend (P9N DD2.1), Linux is told TM is off via CPU dt-ftrs but told to (partially) use it via OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED. So HFSCR[TM] will be off from dt-ftrs but we need to turn it on for the no suspend case.
This patch fixes this by enabling HFSCR TM in this case.
--- arch/powerpc/kernel/setup_64.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
arch/powerpc/kernel/setup_64.c +12 -6
@@ -242,13 +242,19 @@ static void cpu_ready_for_interrupts(voi }/* -* Fixup HFSCR:TM based on CPU features. The bit is set by our -* early asm init because at that point we haven't updated our -* CPU features from firmware and device-tree. Here we have, -* so let's do it. +* Set HFSCR:TM based on CPU features: +* In the special case of TM no suspend (P9N DD2.1), Linux is +* told TM is off via the dt-ftrs but told to (partially) use +* it via OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED. So HFSCR[TM] +* will be off from dt-ftrs but we need to turn it on for the +* no suspend case. */ -if (cpu_has_feature (CPU_FTR_HVMODE ) && !cpu_has_feature (CPU_FTR_TM_COMP )) -mtspr (SPRN_HFSCR ,mfspr (SPRN_HFSCR ) & ~HFSCR_TM ); +if (cpu_has_feature (CPU_FTR_HVMODE )) { +if (cpu_has_feature (CPU_FTR_TM_COMP )) +mtspr (SPRN_HFSCR ,mfspr (SPRN_HFSCR ) |HFSCR_TM ); +else +mtspr (SPRN_HFSCR ,mfspr (SPRN_HFSCR ) & ~HFSCR_TM ); + }/* Set IR and DR in PACA MSR */ get_paca ()->kernel_msr =MSR_KERNEL ;
Greg Kroah-Hartman
maintainerPATCH 274/350 powerpc/64s/hash: Do not use PPC_INVALIDATE_ERAT on CPUs before POWER9
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Piggin <[email protected]>
commit bc276ecba132caccb1fda5863a652c15def2b8c6 upstream.
PPC_INVALIDATE_ERAT is slbia IH=7 which is a new variant introduced with POWER9, and the result is undefined on earlier CPUs.
Commits 7b9f71f974 ("powerpc/64s: POWER9 machine check handler") and d4748276ae ("powerpc/64s: Improve local TLB flush for boot and MCE on POWER9") caused POWER7/8 code to use this instruction. Remove it. An ERAT flush can be made by invalidatig the SLB, but before POWER9 that requires a flush and rebolt.
--- arch/powerpc/kernel/mce_power.c | 7 +++++++ arch/powerpc/mm/hash_native_64.c | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-)
arch/powerpc/kernel/mce_power.c +7 -0
@@ -97,6 +97,13 @@ static void flush_and_reload_slb(void)static void flush_erat (void ) { +#ifdef CONFIG_PPC_BOOK3S_64 +if (!early_cpu_has_feature (CPU_FTR_ARCH_300 )) { +flush_and_reload_slb (); +return ; + } +#endif +/* PPC_INVALIDATE_ERAT can only be used on ISA v3 and newer */ asm volatile(PPC_INVALIDATE_ERAT : : :"memory"); }
arch/powerpc/mm/hash_native_64.c +2 -2
@@ -115,6 +115,8 @@ static void tlbiel_all_isa300(unsigned itlbiel_hash_set_isa300 (0 , is,0 ,2 ,1 ); asmvolatile ("ptesync" : : :"memory" ); + + asmvolatile (PPC_INVALIDATE_ERAT "; isync" : : :"memory" ); }void hash__tlbiel_all (unsigned int action)
@@ -140,8 +142,6 @@ void hash__tlbiel_all(unsigned int actiotlbiel_all_isa206 (POWER7_TLB_SETS , is); else WARN(1, "%s called on pre-POWER7 CPU\n", __func__); - - asmvolatile (PPC_INVALIDATE_ERAT "; isync" : : :"memory" ); } static inline unsigned long ___tlbie(unsigned long vpn, int psize,
Greg Kroah-Hartman
maintainerPATCH 275/350 MIPS: memset: Fix CPU_DADDI_WORKAROUNDS `small_fixup regression
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit 2f7619ae90bf78cf576b5e72087aab0435266fdb upstream.
Fix a commit 8a8158c85e1e ("MIPS: memset.S: EVA & fault support for small_memset") regression and remove assembly warnings:
arch/mips/lib/memset.S: Assembler messages:arch/mips/lib/memset.S:243: Warning: Macro instruction expanded into multiple instructions in a branch delay slot
triggering with the CPU_DADDI_WORKAROUNDS option set and this code:
PTR_SUBU a2, t1, a0 jr ra PTR_ADDIU a2, 1
This is because with that option in place the DADDIU instruction, which the PTR_ADDIU CPP macro expands to, becomes a GAS macro, which in turn expands to an LI/DADDU (or actually ADDIU/DADDU) sequence:
13c: 01a4302f dsubu a2,t1,a0
140: 03e00008 jr ra
144: 24010001 li at,1
148: 00c1302d daddu a2,a2,at
...
Correct this by switching off the `noreorder' assembly mode and letting GAS schedule this jump's delay slot, as there is nothing special about it that would require manual scheduling. With this change in place correct code is produced:
13c: 01a4302f dsubu a2,t1,a0
140: 24010001 li at,1
144: 03e00008 jr ra
148: 00c1302d daddu a2,a2,at
...
Patchwork: https://patchwork.linux-mips.org/patch/20833/
--- arch/mips/lib/memset.S | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/mips/lib/memset.S +3 -1
@@ -262,9 +262,11 @@ nop .Lsmall_fixup\@: + .set reorder PTR_SUBU a2, t1, a0 + PTR_ADDIU a2, 1 jr ra - PTR_ADDIU a2, 1 + .set noreorder .endm
Greg Kroah-Hartman
maintainerPATCH 276/350 MIPS: OCTEON: fix out of bounds array access on CN68XX
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaro Koskinen <[email protected]>
commit c0fae7e2452b90c31edd2d25eb3baf0c76b400ca upstream.
The maximum number of interfaces is returned by cvmx_helper_get_number_of_interfaces(), and the value is used to access interface_port_count[]. When CN68XX support was added, we forgot to increase the array size. Fix that.
Patchwork: https://patchwork.linux-mips.org/patch/20949/
--- arch/mips/cavium-octeon/executive/cvmx-helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/cavium-octeon/executive/cvmx-helper.c +1 -1
@@ -67,7 +67,7 @@ void (*cvmx_override_pko_queue_priority)void (*cvmx_override_ipd_port_setup) (int ipd_port);/* Port count per interface */ -static int interface_port_count[5 ]; +static int interface_port_count[9 ];/** * Return the number of interfaces the chip has. Each interface
Greg Kroah-Hartman
maintainerPATCH 277/350 rtc: ds1307: fix ds1339 wakealarm support
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Soeren Moch <[email protected]>
commit 7dceef78f310f5351735060d78a1777c69606016 upstream.
Commit 51ed73eb998a1c79a2b0e9bed68f75a8a2c93b9b ("rtc: ds1340: Add support for trickle charger.") breaks ds1339 wakealarm support by limiting accessible registers. Fix this.
--- drivers/rtc/rtc-ds1307.c | 1 - 1 file changed, 1 deletion(-)
drivers/rtc/rtc-ds1307.c +0 -1
@@ -1372,7 +1372,6 @@ static void ds1307_clks_register(structstatic const struct regmap_config regmap_config = { .reg_bits =8 , .val_bits =8 , - .max_register =0x9 , }; static int ds1307_probe(struct i2c_client *client,
Greg Kroah-Hartman
maintainerPATCH 278/350 rtc: cmos: Fix non-ACPI undefined reference to `hpet_rtc_interrupt
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit d197a253855d2d8e507a003880aab35c4e2473db upstream.
Fix a commit 311ee9c151ad ("rtc: cmos: allow using ACPI for RTC alarm instead of HPET") `rtc-cmos' regression causing a link error:
drivers/rtc/rtc-cmos.o: In function `cmos_platform_probe':
rtc-cmos.c:(.init.text+0x33c): undefined reference to hpet_rtc_interrupt' rtc-cmos.c:(.init.text+0x3f4): undefined reference to hpet_rtc_interrupt'
with non-ACPI platforms using this driver. The cause is the change of the condition guarding the use of `hpet_rtc_interrupt'.
Previously it was a call to `is_hpet_enabled'. That function is static inline and has a hardcoded 0 result for non-ACPI platforms, which imply !HPET_EMULATE_RTC. Consequently the compiler optimized the whole block away including the reference to `hpet_rtc_interrupt', which never made it to the link stage.
Now the guarding condition is a call to `use_hpet_alarm', which is not static inline and therefore the compiler may not be able to prove that it actually always returns 0 for non-ACPI platforms. Consequently the build breaks with an unsatisfied reference, because `hpet_rtc_interrupt' is nowhere defined at link time.
Fix the problem by marking use_hpet_alarm' inline. As the inline' keyword serves as an optimization hint rather than a requirement the compiler is still free to choose whether inlining will be beneficial or not for ACPI platforms.
--- drivers/rtc/rtc-cmos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-cmos.c +1 -1
@@ -167,7 +167,7 @@ static inline int hpet_unregister_irq_ha#endif /* Don't use HPET for RTC Alarm event if ACPI Fixed event is used */ -static int use_hpet_alarm (void ) +static inline int use_hpet_alarm (void ) {return is_hpet_enabled () && !use_acpi_alarm; }
Greg Kroah-Hartman
maintainerPATCH 279/350 rtc: cmos: Remove the `use_acpi_alarm module parameter for !ACPI
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit bc51098cdd9573bfdecfd02fc8ed474419d73ea0 upstream.
Fix a problem with commit 311ee9c151ad ("rtc: cmos: allow using ACPI for RTC alarm instead of HPET") defining `use_acpi_alarm' module parameter even for non-ACPI platforms, which ignore it. Wrap the definition into #ifdef CONFIG_ACPI and use a static inline wrapper function, hardcoded to return 0 and consequently optimized away for !ACPI, following the existing pattern with HPET handling functions.
--- drivers/rtc/rtc-cmos.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-)
drivers/rtc/rtc-cmos.c +20 -7
@@ -50,6 +50,7 @@/* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */ #include <linux/mc146818rtc.h> +#ifdef CONFIG_ACPI /* * Use ACPI SCI to replace HPET interrupt for RTC Alarm event *
@@ -61,6 +62,18 @@static bool use_acpi_alarm;module_param (use_acpi_alarm, bool,0444 ); +static inline int cmos_use_acpi_alarm (void ) +{ +return use_acpi_alarm; +} +#else /* !CONFIG_ACPI */ + +static inline int cmos_use_acpi_alarm (void ) +{ +return 0 ; +} +#endif +struct cmos_rtc {struct rtc_device *rtc;struct device *dev;
@@ -169,7 +182,7 @@ static inline int hpet_unregister_irq_ha/* Don't use HPET for RTC Alarm event if ACPI Fixed event is used */ static inline int use_hpet_alarm (void ) { -return is_hpet_enabled () && !use_acpi_alarm; +return is_hpet_enabled () && !cmos_use_acpi_alarm (); }/*----------------------------------------------------------------*/
@@ -340,7 +353,7 @@ static void cmos_irq_enable(struct cmos_if (use_hpet_alarm ())hpet_set_rtc_irq_bit (mask); -if ((mask &RTC_AIE ) && use_acpi_alarm) { +if ((mask &RTC_AIE ) &&cmos_use_acpi_alarm ()) {if (cmos->wake_on) cmos->wake_on (cmos->dev); }
@@ -358,7 +371,7 @@ static void cmos_irq_disable(struct cmosif (use_hpet_alarm ())hpet_mask_rtc_irq_bit (mask); -if ((mask &RTC_AIE ) && use_acpi_alarm) { +if ((mask &RTC_AIE ) &&cmos_use_acpi_alarm ()) {if (cmos->wake_off) cmos->wake_off (cmos->dev); }
@@ -980,7 +993,7 @@ static int cmos_suspend(struct device *d }spin_unlock_irq (&rtc_lock); -if ((tmp &RTC_AIE ) && !use_acpi_alarm) { +if ((tmp &RTC_AIE ) && !cmos_use_acpi_alarm ()) { cmos->enabled_wake =1 ;if (cmos->wake_on) cmos->wake_on (dev);
@@ -1031,7 +1044,7 @@ static void cmos_check_wkalrm(struct dev* ACPI RTC wake event is cleared after resume from STR, * ACK the rtc irq here */ -if (t_now >= cmos->alarm_expires && use_acpi_alarm) { +if (t_now >= cmos->alarm_expires &&cmos_use_acpi_alarm ()) {cmos_interrupt (0 , (void *)cmos->rtc);return ; }
@@ -1053,7 +1066,7 @@ static int __maybe_unused cmos_resume(ststruct cmos_rtc *cmos =dev_get_drvdata (dev);unsigned char tmp; -if (cmos->enabled_wake && !use_acpi_alarm) { +if (cmos->enabled_wake && !cmos_use_acpi_alarm ()) {if (cmos->wake_off) cmos->wake_off (dev);else
@@ -1132,7 +1145,7 @@ static u32 rtc_handler(void *context)* Or else, ACPI SCI is enabled during suspend/resume only, * update rtc irq in that case. */ -if (use_acpi_alarm) +if (cmos_use_acpi_alarm ())cmos_interrupt (0 , (void *)cmos->rtc);else {/* Fix me: can we use cmos_interrupt() here as well? */
Greg Kroah-Hartman
maintainerPATCH 280/350 power: supply: twl4030-charger: fix OF sibling-node lookup
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 9844fb2e351311210e6660a9a1c62d17424a6145 upstream.
Use the new of_get_compatible_child() helper to lookup the usb sibling node instead of using of_find_compatible_node(), which searches the entire tree from a given start node and thus can return an unrelated (non-sibling) node.
This also addresses a potential use-after-free (e.g. after probe deferral) as the tree-wide helper drops a reference to its first argument (i.e. the parent device node).
While at it, also fix the related phy-node reference leak.
--- drivers/power/supply/twl4030_charger.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/power/supply/twl4030_charger.c +3 -2
@@ -996,12 +996,13 @@ static int twl4030_bci_probe(struct platif (bci->dev->of_node) {struct device_node *phynode; - phynode =of_find_compatible_node (bci->dev->of_node->parent, -NULL ,"ti,twl4030-usb" ); + phynode =of_get_compatible_child (bci->dev->of_node->parent, +"ti,twl4030-usb" );if (phynode) { bci->usb_nb.notifier_call = twl4030_bci_usb_ncb; bci->transceiver =devm_usb_get_phy_by_node ( bci->dev, phynode, &bci->usb_nb); +of_node_put (phynode);if (IS_ERR (bci->transceiver)) { ret =PTR_ERR (bci->transceiver);if (ret == -EPROBE_DEFER )
Greg Kroah-Hartman
maintainerPATCH 281/350 ocxl: Fix access to the AFU Descriptor Data
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Lombard <[email protected]>
commit 6f8e45f7eb1bee5efdbe4a9cfe4a45627403c5fb upstream.
The AFU Information DVSEC capability is a means to extract common, general information about all of the AFUs associated with a Function independent of the specific functionality that each AFU provides. Write in the AFU Index field allows to access to the descriptor data for each AFU.
With the current code, we are not able to access to these specific data when the index >= 1 because we are writing to the wrong location. All requests to the data of each AFU are pointing to those of the AFU 0, which could have impacts when using a card with more than one AFU per function.
This patch fixes the access to the AFU Descriptor Data indexed by the AFU Info Index field.
--- drivers/misc/ocxl/config.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/misc/ocxl/config.c +3 -1
@@ -280,7 +280,9 @@ int ocxl_config_check_afu_index(struct pu32 val;int rc, templ_major, templ_minor, len; -pci_write_config_word (dev, fn->dvsec_afu_info_pos, afu_idx); +pci_write_config_byte (dev, + fn->dvsec_afu_info_pos +OCXL_DVSEC_AFU_INFO_AFU_IDX , + afu_idx); rc =read_afu_info (dev, fn,OCXL_DVSEC_TEMPL_VERSION , &val);if (rc)return rc;
Greg Kroah-Hartman
maintainerPATCH 282/350 iommu/arm-smmu: Ensure that page-table updates are visible before TLBI
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Will Deacon <[email protected]>
commit 7d321bd3542500caf125249f44dc37cb4e738013 upstream.
The IO-pgtable code relies on the driver TLB invalidation callbacks to ensure that all page-table updates are visible to the IOMMU page-table walker.
In the case that the page-table walker is cache-coherent, we cannot rely on an implicit DSB from the DMA-mapping code, so we must ensure that we execute a DSB in our tlb_add_flush() callback prior to triggering the invalidation.
--- drivers/iommu/arm-smmu.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/iommu/arm-smmu.c +6 -0
@@ -469,6 +469,9 @@ static void arm_smmu_tlb_inv_range_nosynbool stage1 = cfg->cbar !=CBAR_TYPE_S2_TRANS ;void __iomem *reg =ARM_SMMU_CB (smmu_domain->smmu, cfg->cbndx); +if (smmu_domain->smmu->features &ARM_SMMU_FEAT_COHERENT_WALK ) +wmb (); +if (stage1) { reg += leaf ?ARM_SMMU_CB_S1_TLBIVAL :ARM_SMMU_CB_S1_TLBIVA ;
@@ -510,6 +513,9 @@ static void arm_smmu_tlb_inv_vmid_nosyncstruct arm_smmu_domain *smmu_domain = cookie;void __iomem *base =ARM_SMMU_GR0 (smmu_domain->smmu); +if (smmu_domain->smmu->features &ARM_SMMU_FEAT_COHERENT_WALK ) +wmb (); +writel_relaxed (smmu_domain->cfg.vmid, base +ARM_SMMU_GR0_TLBIVMID ); }
Greg Kroah-Hartman
maintainerPATCH 283/350 TC: Set DMA masks for devices
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit 3f2aa244ee1a0d17ed5b6c86564d2c1b24d1c96b upstream.
Fix a TURBOchannel support regression with commit 205e1b7f51e4 ("dma-mapping: warn when there is no coherent_dma_mask") that caused coherent DMA allocations to produce a warning such as:
defxx: v1.11 2014/07/01 Lawrence V. Stefani and others
tc1: DEFTA at MMIO addr = 0x1e900000, IRQ = 20, Hardware addr = 08-00-2b-a3-a3-29
------------[ cut here ]------------
WARNING: CPU: 0 PID: 1 at ./include/linux/dma-mapping.h:516 dfx_dev_register+0x670/0x678
Modules linked in:
CPU: 0 PID: 1 Comm: swapper Not tainted 4.19.0-rc6 #2
Stack : ffffffff8009ffc0 fffffffffffffec0 0000000000000000 ffffffff80647650
0000000000000000 0000000000000000 ffffffff806f5f80 ffffffffffffffff
0000000000000000 0000000000000000 0000000000000001 ffffffff8065d4e8
98000000031b6300 ffffffff80563478 ffffffff805685b0 ffffffffffffffff
0000000000000000 ffffffff805d6720 0000000000000204 ffffffff80388df8
0000000000000000 0000000000000009 ffffffff8053efd0 ffffffff806657d0
0000000000000000 ffffffff803177f8 0000000000000000 ffffffff806d0000
9800000003078000 980000000307b9e0 000000001e900000 ffffffff80067940
0000000000000000 ffffffff805d6720 0000000000000204 ffffffff80388df8
ffffffff805176c0 ffffffff8004dc78 0000000000000000 ffffffff80067940
...
Call Trace:
[<ffffffff8004dc78>] show_stack+0xa0/0x130
[<ffffffff80067940>] __warn+0x128/0x170
---[ end trace b1d1e094f67f3bb2 ]---This is because the TURBOchannel bus driver fails to set the coherent DMA mask for devices enumerated.
Set the regular and coherent DMA masks for TURBOchannel devices then, observing that the bus protocol supports a 34-bit (16GiB) DMA address space, by interpreting the value presented in the address cycle across the 32 `ad' lines as a 32-bit word rather than byte address[1]. The architectural size of the TURBOchannel DMA address space exceeds the maximum amount of RAM any actual TURBOchannel system in existence may have, hence both masks are the same.
This removes the warning shown above.
References:
[1] "TURBOchannel Hardware Specification", EK-369AA-OD-007B, Digital
Equipment Corporation, January 1993, Section "DMA", pp. 1-15 -- 1-17
Patchwork: https://patchwork.linux-mips.org/patch/20835/
--- drivers/tc/tc.c | 8 +++++++- include/linux/tc.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-)
drivers/tc/tc.c +7 -1
@@ -2,7 +2,7 @@* TURBOchannel bus services. * * Copyright (c) Harald Koerfgen, 1998 -* Copyright (c) 2001, 2003, 2005, 2006 Maciej W. Rozycki +* Copyright (c) 2001, 2003, 2005, 2006, 2018 Maciej W. Rozycki * Copyright (c) 2005 James Simmons * * This file is subject to the terms and conditions of the GNU
@@ -10,6 +10,7 @@* directory of this archive for more details. */ #include <linux/compiler.h> +#include <linux/dma-mapping.h> #include <linux/errno.h> #include <linux/init.h> #include <linux/ioport.h>
@@ -92,6 +93,11 @@ static void __init tc_bus_add_devices(st tdev->dev.bus = &tc_bus_type; tdev->slot = slot; +/* TURBOchannel has 34-bit DMA addressing (16GiB space). */ + tdev->dma_mask =DMA_BIT_MASK (34 ); + tdev->dev.dma_mask = &tdev->dma_mask; + tdev->dev.coherent_dma_mask =DMA_BIT_MASK (34 ); +for (i =0 ; i <8 ; i++) { tdev->firmware[i] =readb (module + offset +TC_FIRM_VER +4 * i);
include/linux/tc.h +1 -0
@@ -84,6 +84,7 @@ struct tc_dev {device. */ struct device dev;/* Generic device interface. */ struct resource resource;/* Address space of this device. */ +u64 dma_mask;/* DMA addressable range. */ char vendor[9 ];char name[9 ];char firmware[9 ];
Greg Kroah-Hartman
maintainerPATCH 284/350 net: bcmgenet: fix OF child-node lookup
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit d397dbe606120a1ea1b11b0020c3f7a3852da5ac upstream.
Use the new of_get_compatible_child() helper to lookup the mdio child node instead of using of_find_compatible_node(), which searches the entire tree from a given start node and thus can return an unrelated (i.e. non-child) node.
This also addresses a potential use-after-free (e.g. after probe deferral) as the tree-wide helper drops a reference to its first argument (i.e. the node of the device being probed).
--- drivers/net/ethernet/broadcom/genet/bcmmii.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/broadcom/genet/bcmmii.c +1 -1
@@ -342,7 +342,7 @@ static struct device_node *bcmgenet_mii_if (!compat)return NULL ; - priv->mdio_dn =of_find_compatible_node (dn,NULL , compat); + priv->mdio_dn =of_get_compatible_child (dn, compat);kfree (compat);if (!priv->mdio_dn) {dev_err (kdev,"unable to find MDIO bus node\n" );
Greg Kroah-Hartman
maintainerPATCH 285/350 media: v4l2-tpg: fix kernel oops when enabling HFLIP and OSD
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit 250854eed5d45a73d81e4137dfd85180af6f2ec3 upstream.
When the OSD is on (i.e. vivid displays text on top of the test pattern), and you enable hflip, then the driver crashes.
The cause turned out to be a division of a negative number by an unsigned value. You expect that -8 / 2U would be -4, but in reality it is 2147483644 :-(
--- drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +1 -1
@@ -1770,7 +1770,7 @@ typedef struct { u16 __; u8 _; } __packe pos[7 ] = (chr & (0x01 <<0 ) ? fg : bg); \ } \ \ - pos += (tpg->hflip ?-8 :8 ) / hdiv; \ + pos += (tpg->hflip ?-8 :8 ) / (int )hdiv; \ } \ } \ }while (0 )
Greg Kroah-Hartman
maintainerPATCH 286/350 Revert "media: dvbsky: use just one mutex for serializing device R/W ops"
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mauro Carvalho Chehab <[email protected]>
commit 9afc82194de9a1ce298f0d77d7d779d585bf962c upstream.
As pointed at:
https://bugzilla.kernel.org/show_bug.cgi?id=199323
This patch causes a bad effect on RPi. I suspect that the root cause is at the USB out of tree RPi driver, with uses high priority interrupts instead of normal ones. Anyway, as this patch is mostly a cleanup, better to revert it.
This reverts commit 7d95fb746c4eece67308f1642a666ea1ebdbd2cc.
--- drivers/media/usb/dvb-usb-v2/dvbsky.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/media/usb/dvb-usb-v2/dvbsky.c +10 -6
@@ -31,6 +31,7 @@ MODULE_PARM_DESC(disable_rc, "Disable inDVB_DEFINE_MOD_OPT_ADAPTER_NR (adapter_nr);struct dvbsky_state { +struct mutex stream_mutex;u8 ibuf[DVBSKY_BUF_LEN ];u8 obuf[DVBSKY_BUF_LEN ];u8 last_lock;
@@ -67,17 +68,18 @@ static int dvbsky_usb_generic_rw(structstatic int dvbsky_stream_ctrl (struct dvb_usb_device *d,u8 onoff) { +struct dvbsky_state *state =d_to_priv (d);int ret; -static u8 obuf_pre[3 ] = {0x37 ,0 ,0 }; -static u8 obuf_post[3 ] = {0x36 ,3 ,0 }; +u8 obuf_pre[3 ] = {0x37 ,0 ,0 }; +u8 obuf_post[3 ] = {0x36 ,3 ,0 }; -mutex_lock (&d->usb_mutex); - ret =dvb_usbv2_generic_rw_locked (d, obuf_pre,3 ,NULL ,0 ); +mutex_lock (&state->stream_mutex); + ret =dvbsky_usb_generic_rw (d, obuf_pre,3 ,NULL ,0 );if (!ret && onoff) {msleep (20 ); - ret =dvb_usbv2_generic_rw_locked (d, obuf_post,3 ,NULL ,0 ); + ret =dvbsky_usb_generic_rw (d, obuf_post,3 ,NULL ,0 ); } -mutex_unlock (&d->usb_mutex); +mutex_unlock (&state->stream_mutex);return ret; }
@@ -606,6 +608,8 @@ static int dvbsky_init(struct dvb_usb_deif (ret) return ret; */ +mutex_init (&state->stream_mutex); + state->last_lock =0 ;return 0 ;
Greg Kroah-Hartman
maintainerPATCH 287/350 kgdboc: Passing ekgdboc to command line causes panic
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: He Zhe <[email protected]>
commit 1bd54d851f50dea6af30c3e6ff4f3e9aab5558f9 upstream.
kgdboc_option_setup does not check input argument before passing it to strlen. The argument would be a NULL pointer if "ekgdboc", without its value, is set in command line and thus cause the following panic.
PANIC: early exception 0xe3 IP 10:ffffffff8fbbb620 error 0 cr2 0x0
[ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.18-rc8+ #1 [ 0.000000] RIP: 0010:strlen+0x0/0x20 ... [ 0.000000] Call Trace [ 0.000000] ? kgdboc_option_setup+0x9/0xa0 [ 0.000000] ? kgdboc_early_init+0x6/0x1b [ 0.000000] ? do_early_param+0x4d/0x82 [ 0.000000] ? parse_args+0x212/0x330 [ 0.000000] ? rdinit_setup+0x26/0x26 [ 0.000000] ? parse_early_options+0x20/0x23 [ 0.000000] ? rdinit_setup+0x26/0x26 [ 0.000000] ? parse_early_param+0x2d/0x39 [ 0.000000] ? setup_arch+0x2f7/0xbf4 [ 0.000000] ? start_kernel+0x5e/0x4c2 [ 0.000000] ? load_ucode_bsp+0x113/0x12f [ 0.000000] ? secondary_startup_64+0xa5/0xb0
This patch adds a check to prevent the panic.
--- drivers/tty/serial/kgdboc.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/tty/serial/kgdboc.c +5 -0
@@ -130,6 +130,11 @@ static void kgdboc_unregister_kbd(void)static int kgdboc_option_setup (char *opt) { +if (!opt) { +pr_err ("kgdboc: config string not provided\n" ); +return -EINVAL ; + } +if (strlen (opt) >=MAX_CONFIG_LEN ) {printk (KERN_ERR "kgdboc: config string too long\n" );return -ENOSPC ;
Greg Kroah-Hartman
maintainerPATCH 288/350 media: cec: make cec_get_edid_spa_location() an inline function
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit b915bf575d5b7774d0f22d57d6c143e07dcaade2 upstream.
This function is needed by both V4L2 and CEC, so move this to cec.h as a static inline since there are no obvious shared modules between the two subsystems.
This patch, together with the following ones, fixes a dependency bug: if CEC_CORE is disabled, then building adv7604 (and other HDMI receivers) will fail because an essential function is now stubbed out.
--- drivers/media/cec/cec-edid.c | 60 ------------------------------------ include/media/cec.h | 70 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 60 deletions(-)
drivers/media/cec/cec-edid.c +0 -60
@@ -10,66 +10,6 @@#include <linux/types.h> #include <media/cec.h> -/* -* This EDID is expected to be a CEA-861 compliant, which means that there are -* at least two blocks and one or more of the extensions blocks are CEA-861 -* blocks. -* -* The returned location is guaranteed to be < size - 1. -*/ -static unsigned int cec_get_edid_spa_location (const u8 *edid,unsigned int size) -{ -unsigned int blocks = size /128 ; -unsigned int block; -u8 d; - -/* Sanity check: at least 2 blocks and a multiple of the block size */ -if (blocks <2 || size %128 ) -return 0 ; - -/* -* If there are fewer extension blocks than the size, then update -* 'blocks'. It is allowed to have more extension blocks than the size, -* since some hardware can only read e.g. 256 bytes of the EDID, even -* though more blocks are present. The first CEA-861 extension block -* should normally be in block 1 anyway. -*/ -if (edid[0x7e ] +1 < blocks) - blocks = edid[0x7e ] +1 ; - -for (block =1 ; block < blocks; block++) { -unsigned int offset = block *128 ; - -/* Skip any non-CEA-861 extension blocks */ -if (edid[offset] !=0x02 || edid[offset +1 ] !=0x03 ) -continue ; - -/* search Vendor Specific Data Block (tag 3) */ - d = edid[offset +2 ] &0x7f ; -/* Check if there are Data Blocks */ -if (d <=4 ) -continue ; -if (d >4 ) { -unsigned int i = offset +4 ; -unsigned int end = offset + d; - -/* Note: 'end' is always < 'size' */ -do { -u8 tag = edid[i] >>5 ; -u8 len = edid[i] &0x1f ; - -if (tag ==3 && len >=5 && i + len <= end && - edid[i +1 ] ==0x03 && - edid[i +2 ] ==0x0c && - edid[i +3 ] ==0x00 ) -return i +4 ; - i += len +1 ; - }while (i < end); - } - } -return 0 ; -} -u16 cec_get_edid_phys_addr (const u8 *edid,unsigned int size,unsigned int *offset) {
include/media/cec.h +70 -0
74 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 289/350 media: cec: integrate cec_validate_phys_addr() in cec-api.c
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit e81bff39489a06384822bb38ce7a59f9e365bbe9 upstream.
The cec_phys_addr_validate() function will be moved to V4L2, so use a simplified variant of that function in cec-api.c. cec now no longer calls cec_phys_addr_validate() and it can be safely moved to V4L2.
--- drivers/media/cec/cec-api.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/media/cec/cec-api.c +18 -1
@@ -101,6 +101,23 @@ static long cec_adap_g_phys_addr(structreturn 0 ; } +static int cec_validate_phys_addr (u16 phys_addr) +{ +int i; + +if (phys_addr ==CEC_PHYS_ADDR_INVALID ) +return 0 ; +for (i =0 ; i <16 ; i +=4 ) +if (phys_addr & (0xf << i)) +break ; +if (i ==16 ) +return 0 ; +for (i +=4 ; i <16 ; i +=4 ) +if ((phys_addr & (0xf << i)) ==0 ) +return -EINVAL ; +return 0 ; +} +static long cec_adap_s_phys_addr (struct cec_adapter *adap,struct cec_fh *fh,bool block,__u16 __user *parg) {
@@ -112,7 +129,7 @@ static long cec_adap_s_phys_addr(structif (copy_from_user (&phys_addr, parg,sizeof (phys_addr)))return -EFAULT ; - err =cec_phys_addr_validate (phys_addr,NULL ,NULL ); + err =cec_validate_phys_addr (phys_addr);if (err)return err;mutex_lock (&adap->lock);
Greg Kroah-Hartman
maintainerPATCH 290/350 xen: fix xen_qlock_wait()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
commit d3132b3860f6cf35ff7609a76bbcdbb814bd027c upstream.
Commit a856531951dc80 ("xen: make xen_qlock_wait() nestable") introduced a regression for Xen guests running fully virtualized (HVM or PVH mode). The Xen hypervisor wouldn't return from the poll hypercall with interrupts disabled in case of an interrupt (for PV guests it does).
So instead of disabling interrupts in xen_qlock_wait() use a nesting counter to avoid calling xen_clear_irq_pending() in case xen_qlock_wait() is nested.
--- arch/x86/xen/spinlock.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
arch/x86/xen/spinlock.c +8 -6
@@ -9,6 +9,7 @@#include <linux/log2.h> #include <linux/gfp.h> #include <linux/slab.h> +#include <linux/atomic.h> #include <asm/paravirt.h> #include <asm/qspinlock.h>
@@ -21,6 +22,7 @@ static DEFINE_PER_CPU(int, lock_kicker_irq) = -1; static DEFINE_PER_CPU(char *, irq_name); +static DEFINE_PER_CPU(atomic_t, xen_qlock_wait_nest);static bool xen_pvspin = true;static void xen_qlock_kick (int cpu)
@@ -39,25 +41,25 @@ static void xen_qlock_kick(int cpu)*/ static void xen_qlock_wait (u8 *byte,u8 val) { -unsigned long flags;int irq =__this_cpu_read (lock_kicker_irq); +atomic_t *nest_cnt =this_cpu_ptr (&xen_qlock_wait_nest);/* If kicker interrupts not initialized yet, just spin */ if (irq ==-1 ||in_nmi ())return ; -/* Guard against reentry. */ -local_irq_save (flags); +/* Detect reentry. */ +atomic_inc (nest_cnt); -/* If irq pending already clear it. */ -if (xen_test_irq_pending (irq)) { +/* If irq pending already and no nested call clear it. */ +if (atomic_read (nest_cnt) ==1 &&xen_test_irq_pending (irq)) {xen_clear_irq_pending (irq); }else if (READ_ONCE (*byte) == val) {/* Block until irq becomes pending (or a spurious wakeup) */ xen_poll_irq (irq); } -local_irq_restore (flags); +atomic_dec (nest_cnt); }static irqreturn_t dummy_handler (int irq,void *dev_id)
Greg Kroah-Hartman
maintainerPATCH 291/350 xen: remove size limit of privcmd-buf mapping interface
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
commit 3941552aec1e04d63999988a057ae09a1c56ebeb upstream.
Currently the size of hypercall buffers allocated via /dev/xen/hypercall is limited to a default of 64 memory pages. For live migration of guests this might be too small as the page dirty bitmask needs to be sized according to the size of the guest. This means migrating a 8GB sized guest is already exhausting the default buffer size for the dirty bitmap.
There is no sensible way to set a sane limit, so just remove it completely. The device node's usage is limited to root anyway, so there is no additional DOS scenario added by allowing unlimited buffers.
While at it make the error path for the -ENOMEM case a little bit cleaner by setting n_pages to the number of successfully allocated pages instead of the target size.
--- drivers/xen/privcmd-buf.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-)
drivers/xen/privcmd-buf.c +4 -18
@@ -21,15 +21,9 @@MODULE_LICENSE ("GPL" ); -static unsigned int limit =64 ; -module_param (limit, uint,0644 ); -MODULE_PARM_DESC (limit,"Maximum number of pages that may be allocated by " -"the privcmd-buf device per open file" ); -struct privcmd_buf_private {struct mutex lock;struct list_head list; -unsigned int allocated; };struct privcmd_buf_vma_private {
@@ -60,13 +54,10 @@ static void privcmd_buf_vmapriv_free(str {unsigned int i; - vma_priv->file_priv->allocated -= vma_priv->n_pages; -list_del (&vma_priv->list);for (i =0 ; i < vma_priv->n_pages; i++) -if (vma_priv->pages[i]) -__free_page (vma_priv->pages[i]); +__free_page (vma_priv->pages[i]);kfree (vma_priv); }
@@ -146,8 +137,7 @@ static int privcmd_buf_mmap(struct fileunsigned int i;int ret =0 ; -if (!(vma->vm_flags &VM_SHARED ) || count > limit || - file_priv->allocated + count > limit) +if (!(vma->vm_flags &VM_SHARED ))return -EINVAL ; vma_priv = kzalloc(sizeof(*vma_priv) + count * sizeof(void *),
@@ -155,19 +145,15 @@ static int privcmd_buf_mmap(struct fileif (!vma_priv)return -ENOMEM ; - vma_priv->n_pages = count; - count =0 ; -for (i =0 ; i < vma_priv->n_pages; i++) { +for (i =0 ; i < count; i++) { vma_priv->pages[i] =alloc_page (GFP_KERNEL | __GFP_ZERO);if (!vma_priv->pages[i])break ; - count++; + vma_priv->n_pages++; }mutex_lock (&file_priv->lock); - file_priv->allocated += count; - vma_priv->file_priv = file_priv; vma_priv->users =1 ;
Greg Kroah-Hartman
maintainerPATCH 292/350 xen-blkfront: fix kernel panic with negotiate_mq error path
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manjunath Patil <[email protected]>
commit 6cc4a0863c9709c512280c64e698d68443ac8053 upstream.
info->nr_rings isn't adjusted in case of ENOMEM error from negotiate_mq(). This leads to kernel panic in error path.
Typical call stack involving panic -
#8 page_fault at ffffffff8175936f
[exception RIP: blkif_free_ring+33]
RIP: ffffffffa0149491 RSP: ffff8804f7673c08 RFLAGS: 00010292
...
#9 blkif_free at ffffffffa0149aaa [xen_blkfront]
#10 talk_to_blkback at ffffffffa014c8cd [xen_blkfront] #11 blkback_changed at ffffffffa014ea8b [xen_blkfront] #12 xenbus_otherend_changed at ffffffff81424670
#13 backend_changed at ffffffff81426dc3
#14 xenwatch_thread at ffffffff81422f29
#15 kthread at ffffffff810abe6a
#16 ret_from_fork at ffffffff81754078
--- drivers/block/xen-blkfront.c | 1 + 1 file changed, 1 insertion(+)
drivers/block/xen-blkfront.c +1 -0
@@ -1911,6 +1911,7 @@ static int negotiate_mq(struct blkfront_ GFP_KERNEL);if (!info->rinfo) {xenbus_dev_fatal (info->xbdev, -ENOMEM ,"allocating ring_info structure" ); + info->nr_rings =0 ;return -ENOMEM ; }
Greg Kroah-Hartman
maintainerPATCH 293/350 media: cec: add new tx/rx status bits to detect aborts/timeouts
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit 7ec2b3b941a666a942859684281b5f6460a0c234 upstream.
If the HDMI cable is disconnected or the CEC adapter is manually unconfigured, then all pending transmits and wait-for-replies are aborted. Signal this with new status bits (CEC_RX/TX_STATUS_ABORTED).
If due to (usually) a driver bug a transmit never ends (i.e. the transmit_done was never called by the driver), then when this times out the message is marked with CEC_TX_STATUS_TIMEOUT.
This should not happen and is an indication of a driver bug.
Without a separate status bit for this it was impossible to detect this from userspace.
The 'transmit timed out' kernel message is now a warning, so this should be more prominent in the kernel log as well.
--- Documentation/media/uapi/cec/cec-ioc-receive.rst | 25 +++++++- drivers/media/cec/cec-adap.c | 68 ++++++----------------- include/uapi/linux/cec.h | 3 + 3 files changed, 45 insertions(+), 51 deletions(-)
Documentation/media/uapi/cec/cec-ioc-receive.rst +23 -2
@@ -16,10 +16,10 @@ CEC_RECEIVE, CEC_TRANSMIT - Receive or t Synopsis ======== -.. c:function:: int ioctl( int fd, CEC_RECEIVE, struct cec_msg *argp ) +.. c:function:: int ioctl( int fd, CEC_RECEIVE, struct cec_msg \*argp ) :name: CEC_RECEIVE -.. c:function:: int ioctl( int fd, CEC_TRANSMIT, struct cec_msg *argp ) +.. c:function:: int ioctl( int fd, CEC_TRANSMIT, struct cec_msg \*argp ) :name: CEC_TRANSMIT Arguments
@@ -272,6 +272,19 @@ View On' messages from initiator 0xf ('U - The transmit failed after one or more retries. This status bit is mutually exclusive with :ref:`CEC_TX_STATUS_OK <CEC-TX-STATUS-OK>`. Other bits can still be set to explain which failures were seen. + * .. _`CEC-TX-STATUS-ABORTED`: + + - ``CEC_TX_STATUS_ABORTED`` + - 0x40 + - The transmit was aborted due to an HDMI disconnect, or the adapter + was unconfigured, or a transmit was interrupted, or the driver + returned an error when attempting to start a transmit. + * .. _`CEC-TX-STATUS-TIMEOUT`: + + - ``CEC_TX_STATUS_TIMEOUT`` + - 0x80 + - The transmit timed out. This should not normally happen and this + indicates a driver problem. .. tabularcolumns:: |p{5.6cm}|p{0.9cm}|p{11.0cm}|
@@ -300,6 +313,14 @@ View On' messages from initiator 0xf ('U - The message was received successfully but the reply was ``CEC_MSG_FEATURE_ABORT``. This status is only set if this message was the reply to an earlier transmitted message. + * .. _`CEC-RX-STATUS-ABORTED`: + + - ``CEC_RX_STATUS_ABORTED`` + - 0x08 + - The wait for a reply to an earlier transmitted message was aborted + because the HDMI cable was disconnected, the adapter was unconfigured + or the :ref:`CEC_TRANSMIT <CEC_RECEIVE>` that waited for a + reply was interrupted.
drivers/media/cec/cec-adap.c +19 -49
128 lines not on this page · raw message
include/uapi/linux/cec.h +3 -0
@@ -152,10 +152,13 @@ static inline void cec_msg_set_reply_to(#define CEC_TX_STATUS_LOW_DRIVE (1 << 3)#define CEC_TX_STATUS_ERROR (1 << 4)#define CEC_TX_STATUS_MAX_RETRIES (1 << 5) +#define CEC_TX_STATUS_ABORTED (1 << 6) +#define CEC_TX_STATUS_TIMEOUT (1 << 7)#define CEC_RX_STATUS_OK (1 << 0)#define CEC_RX_STATUS_TIMEOUT (1 << 1)#define CEC_RX_STATUS_FEATURE_ABORT (1 << 2) +#define CEC_RX_STATUS_ABORTED (1 << 3)static inline int cec_msg_status_is_ok (const struct cec_msg *msg) {
Greg Kroah-Hartman
maintainerPATCH 294/350 media: cec: fix the Signal Free Time calculation
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit 7d867a1b765e2b70815fec4964d7822a976ed349 upstream.
The calculation of the Signal Free Time in the framework was not correct. If a message was received, then the next transmit should be considered a New Initiator and use a shorter SFT value.
This was not done with the result that if both sides where continually sending messages, they both could use the same SFT value and one side could deny the other side access to the bus.
Note that this fix does not take the corner case into account where a receive is in progress when you call adap_transmit.
--- drivers/media/cec/cec-adap.c | 26 +++++++------------------- include/media/cec.h | 2 +- 2 files changed, 8 insertions(+), 20 deletions(-)
drivers/media/cec/cec-adap.c +7 -19
@@ -497,9 +497,11 @@ int cec_thread_func(void *_adap)if (data->attempts) {/* should be >= 3 data bit periods for a retry */ signal_free_time =CEC_SIGNAL_FREE_TIME_RETRY ; - }else if (data->new_initiator) { + }else if (adap->last_initiator != +cec_msg_initiator (&data->msg)) {/* should be >= 5 data bit periods for new initiator */ signal_free_time =CEC_SIGNAL_FREE_TIME_NEW_INITIATOR ; + adap->last_initiator =cec_msg_initiator (&data->msg); }else {/* * should be >= 7 data bit periods for sending another
@@ -684,7 +686,6 @@ int cec_transmit_msg_fh(struct cec_adapt struct cec_fh *fh, bool block) {struct cec_data *data; -u8 last_initiator =0xff ; msg->rx_ts =0 ; msg->tx_ts =0 ;
@@ -794,23 +795,6 @@ int cec_transmit_msg_fh(struct cec_adapt data->adap = adap; data->blocking = block; -/* -* Determine if this message follows a message from the same -* initiator. Needed to determine the free signal time later on. -*/ -if (msg->len >1 ) { -if (!(list_empty (&adap->transmit_queue))) { -const struct cec_data *last; - - last =list_last_entry (&adap->transmit_queue, - const struct cec_data, list); - last_initiator =cec_msg_initiator (&last->msg); - }else if (adap->transmitting) { - last_initiator = -cec_msg_initiator (&adap->transmitting->msg); - } - } - data->new_initiator = last_initiator !=cec_msg_initiator (msg);init_completion (&data->c);INIT_DELAYED_WORK (&data->work, cec_wait_timeout);
@@ -998,6 +982,8 @@ void cec_received_msg_ts(struct cec_adapmutex_lock (&adap->lock);dprintk (2 ,"%s: %*ph\n" , __func__, msg->len, msg->msg); + adap->last_initiator =0xff ; +/* Check if this message was for us (directed or broadcast). */ if (!cec_msg_is_broadcast (msg)) valid_la =cec_has_log_addr (adap, msg_dest);
@@ -1460,6 +1446,8 @@ void __cec_s_phys_addr(struct cec_adapte }mutex_lock (&adap->devnode.lock); + adap->last_initiator =0xff ; +if ((adap->needs_hpd ||list_empty (&adap->devnode.fhs)) && adap->ops->adap_enable (adap, true)) {mutex_unlock (&adap->devnode.lock);
include/media/cec.h +1 -1
@@ -63,7 +63,6 @@ struct cec_data {struct delayed_work work;struct completion c;u8 attempts; -bool new_initiator;bool blocking;bool completed; };
@@ -174,6 +173,7 @@ struct cec_adapter {bool is_configuring;bool is_configured;bool cec_pin_is_high; +u8 last_initiator;u32 monitor_all_cnt;u32 monitor_pin_cnt;u32 follower_cnt;
Greg Kroah-Hartman
maintainerPATCH 295/350 media: cec: forgot to cancel delayed work
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit 490d84f6d73c12f4204241cff8651eed60aae914 upstream.
If the wait for completion was interrupted, then make sure to cancel any delayed work.
This can only happen if a transmit is waiting for a reply, and you press Ctrl-C or reboot/poweroff or something like that which interrupts the thread waiting for the reply and then proceeds to delete the CEC message.
Since the delayed work wasn't canceled, once it would trigger it referred to stale data and resulted in a kernel oops.
--- drivers/media/cec/cec-adap.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/cec/cec-adap.c +2 -0
@@ -815,6 +815,8 @@ int cec_transmit_msg_fh(struct cec_adapt*/ mutex_unlock (&adap->lock);wait_for_completion_killable (&data->c); +if (!data->completed) +cancel_delayed_work_sync (&data->work);mutex_lock (&adap->lock);/* Cancel the transmit if it was interrupted */
Greg Kroah-Hartman
maintainerPATCH 296/350 media: em28xx: use a default format if TRY_FMT fails
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mauro Carvalho Chehab <[email protected]>
commit f823ce2a1202d47110a7ef86b65839f0be8adc38 upstream.
Follow the V4L2 spec, as warned by v4l2-compliance:
warn: v4l2-test-formats.cpp(732): TRY_FMT cannot handle an invalid pixelformat.
warn: v4l2-test-formats.cpp(733): This may or may not be a problem. For more information see:
warn: v4l2-test-formats.cpp(734): http://www.mail-archive.com/[email protected]/msg56550.html
--- drivers/media/usb/em28xx/em28xx-video.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/usb/em28xx/em28xx-video.c +3 -3
@@ -1471,9 +1471,9 @@ static int vidioc_try_fmt_vid_cap(struct fmt =format_by_fourcc (f->fmt.pix.pixelformat);if (!fmt) { -em28xx_videodbg ("Fourcc format (%08x) invalid.\n" , - f->fmt.pix.pixelformat); -return -EINVAL ; + fmt = &format[0 ]; +em28xx_videodbg ("Fourcc format (%08x) invalid. Using default (%08x).\n" , + f->fmt.pix.pixelformat, fmt->fourcc); }if (dev->board.is_em2800) {
Greg Kroah-Hartman
maintainerPATCH 297/350 media: tvp5150: avoid going past array on v4l2_querymenu()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mauro Carvalho Chehab <[email protected]>
commit 5c4c4505b716cb782ad7263091edc466c4d1fbd4 upstream.
The parameters of v4l2_ctrl_new_std_menu_items() are tricky: instead of the number of possible values, it requires the number of the maximum value. In other words, the ARRAY_SIZE() value should be decremented, otherwise it will go past the array bounds, as warned by KASAN:
[ 279.839688] BUG: KASAN: global-out-of-bounds in v4l2_querymenu+0x10d/0x180 [videodev] [ 279.839709] Read of size 8 at addr ffffffffc10a4cb0 by task v4l2-compliance/16676
[ 279.839736] CPU: 1 PID: 16676 Comm: v4l2-compliance Not tainted 4.18.0-rc2+ #120 [ 279.839741] Hardware name: /NUC5i7RYB, BIOS RYBDWi35.86A.0364.2017.0511.0949 05/11/2017 [ 279.839743] Call Trace: [ 279.839758] dump_stack+0x71/0xab [ 279.839807] ? v4l2_querymenu+0x10d/0x180 [videodev] [ 279.839817] print_address_description+0x1c9/0x270 [ 279.839863] ? v4l2_querymenu+0x10d/0x180 [videodev] [ 279.839871] kasan_report+0x237/0x360 [ 279.839918] v4l2_querymenu+0x10d/0x180 [videodev] [ 279.839964] __video_do_ioctl+0x2c8/0x590 [videodev] [ 279.840011] ? copy_overflow+0x20/0x20 [videodev] [ 279.840020] ? avc_ss_reset+0xa0/0xa0 [ 279.840028] ? check_stack_object+0x21/0x60 [ 279.840036] ? __check_object_size+0xe7/0x240 [ 279.840080] video_usercopy+0xed/0x730 [videodev] [ 279.840123] ? copy_overflow+0x20/0x20 [videodev] [ 279.840167] ? v4l_enumstd+0x40/0x40 [videodev] [ 279.840177] ? __handle_mm_fault+0x9f9/0x1ba0 [ 279.840186] ? __pmd_alloc+0x2c0/0x2c0 [ 279.840193] ? __vfs_write+0xb6/0x350 [ 279.840200] ? kernel_read+0xa0/0xa0 [ 279.840244] ? video_usercopy+0x730/0x730 [videodev] [ 279.840284] v4l2_ioctl+0xa1/0xb0 [videodev] [ 279.840295] do_vfs_ioctl+0x117/0x8a0 [ 279.840303] ? selinux_file_ioctl+0x211/0x2f0 [ 279.840313] ? ioctl_preallocate+0x120/0x120 [ 279.840319] ? selinux_capable+0x20/0x20 [ 279.840332] ksys_ioctl+0x70/0x80 [ 279.840342] __x64_sys_ioctl+0x3d/0x50 [ 279.840351] do_syscall_64+0x6d/0x1c0 [ 279.840361] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 279.840367] RIP: 0033:0x7fdfb46275d7 [ 279.840369] Code: b3 66 90 48 8b 05 b1 48 2d 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 81 48 2d 00 f7 d8 64 89 01 48 [ 279.840474] RSP: 002b:00007ffee1179038 EFLAGS: 00000202 ORIG_RAX: 0000000000000010 [ 279.840483] RAX: ffffffffffffffda RBX: 00007ffee1179180 RCX: 00007fdfb46275d7 [ 279.840488] RDX: 00007ffee11790c0 RSI: 00000000c02c5625 RDI: 0000000000000003 [ 279.840493] RBP: 0000000000000002 R08: 0000000000000020 R09: 00000000009f0902 [ 279.840497] R10: 0000000000000000 R11: 0000000000000202 R12: 00007ffee117a5a0 [ 279.840501] R13: 00007ffee11790c0 R14: 0000000000000002 R15: 0000000000000000
[ 279.840515] The buggy address belongs to the variable: [ 279.840535] tvp5150_test_patterns+0x10/0xffffffffffffe360 [tvp5150]
--- drivers/media/i2c/tvp5150.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/tvp5150.c +1 -1
@@ -1534,7 +1534,7 @@ static int tvp5150_probe(struct i2c_clie 27000000, 1, 27000000);v4l2_ctrl_new_std_menu_items (&core->hdl, &tvp5150_ctrl_ops,V4L2_CID_TEST_PATTERN , -ARRAY_SIZE (tvp5150_test_patterns), +ARRAY_SIZE (tvp5150_test_patterns) -1 ,0 ,0 , tvp5150_test_patterns); sd->ctrl_handler = &core->hdl;if (core->hdl.error) {
Greg Kroah-Hartman
maintainerPATCH 298/350 media: em28xx: fix input name for Terratec AV 350
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mauro Carvalho Chehab <[email protected]>
commit 15644bfa195bd166d0a5ed76ae2d587f719c3dac upstream.
Instead of using a register value, use an AMUX name, as otherwise VIDIOC_G_AUDIO would fail.
--- drivers/media/usb/em28xx/em28xx-cards.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/usb/em28xx/em28xx-cards.c +2 -2
@@ -2141,13 +2141,13 @@ const struct em28xx_board em28xx_boards[ .input = { { .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, - .amux = EM28XX_AUDIO_SRC_LINE, + .amux = EM28XX_AMUX_LINE_IN, .gpio = terratec_av350_unmute_gpio, }, { .type = EM28XX_VMUX_SVIDEO, .vmux = TVP5150_SVIDEO, - .amux = EM28XX_AUDIO_SRC_LINE, + .amux = EM28XX_AMUX_LINE_IN, .gpio = terratec_av350_unmute_gpio, } }, },
Greg Kroah-Hartman
maintainerPATCH 299/350 media: em28xx: make v4l2-compliance happier by starting sequence on zero
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mauro Carvalho Chehab <[email protected]>
commit afeaade90db4c5dab93f326d9582be1d5954a198 upstream.
The v4l2-compliance tool complains if a video doesn't start with a zero sequence number.
While this shouldn't cause any real problem for apps, let's make it happier, in order to better check the v4l2-compliance differences before and after patchsets.
This is actually an old issue. It is there since at least its videobuf2 conversion, e. g. changeset 3829fadc461 ("[media]
em28xx: convert to videobuf2"), if VB1 wouldn't suffer from the same issue.
--- drivers/media/usb/em28xx/em28xx-video.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/usb/em28xx/em28xx-video.c +2 -0
@@ -1093,6 +1093,8 @@ int em28xx_start_analog_streaming(structem28xx_videodbg ("%s\n" , __func__); + dev->v4l2->field_count =0 ; +/* * Make sure streaming is not already in progress for this type * of filehandle (e.g. video, vbi)
Greg Kroah-Hartman
maintainerPATCH 300/350 media: em28xx: fix handler for vidioc_s_input()
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mauro Carvalho Chehab <[email protected]>
commit 258c430456ba5f0005043762e14fc3be35983aaf upstream.
The a->index is not the name of the internal amux entry, but, instead a value from zero to the maximum number of audio inputs.
As the actual available inputs depend on each board, build it dynamically.
This is broken for a really long time. On a quick check, since at least commit 195a4ef627e1 ("V4L/DVB (6585): Convert em28xx to video_ioctl2") this was not implemented right.
--- drivers/media/usb/em28xx/em28xx-cards.c | 29 ++++++++++ drivers/media/usb/em28xx/em28xx-video.c | 86 ++++++++++++++++++++++++++++---- drivers/media/usb/em28xx/em28xx.h | 8 ++ 3 files changed, 113 insertions(+), 10 deletions(-)
drivers/media/usb/em28xx/em28xx-cards.c +29 -0
@@ -3041,6 +3041,9 @@ static int em28xx_hint_board(struct em28static void em28xx_card_setup (struct em28xx *dev) { +int i, j, idx; +bool duplicate_entry; +/* * If the device can be a webcam, seek for a sensor. * If sensor is not found, then it isn't a webcam.
@@ -3197,6 +3200,32 @@ static void em28xx_card_setup(struct em2/* Allow override tuner type by a module parameter */ if (tuner >=0 ) dev->tuner_type = tuner; + +/* +* Dynamically generate a list of valid audio inputs for this +* specific board, mapping them via enum em28xx_amux. +*/ + + idx =0 ; +for (i =0 ; i <MAX_EM28XX_INPUT ; i++) { +if (!INPUT (i)->type) +continue ; + +/* Skip already mapped audio inputs */ + duplicate_entry = false; +for (j =0 ; j < idx; j++) { +if (INPUT (i)->amux == dev->amux_map[j]) { + duplicate_entry = true; +break ; + } + } +if (duplicate_entry) +continue ; + + dev->amux_map[idx++] =INPUT (i)->amux; + } +for (; idx <MAX_EM28XX_INPUT ; idx++) + dev->amux_map[idx] =EM28XX_AMUX_UNUSED ; }void em28xx_setup_xc3028 (struct em28xx *dev,struct xc2028_ctrl *ctl)
drivers/media/usb/em28xx/em28xx-video.c +77 -9
138 lines not on this page · raw message
drivers/media/usb/em28xx/em28xx.h +7 -1
@@ -335,6 +335,9 @@ enum em28xx_usb_audio_type {/** * em28xx_amux - describes the type of audio input used by em28xx * +* @EM28XX_AMUX_UNUSED: +* Used only on em28xx dev->map field, in order to mark an entry +* as unused. * @EM28XX_AMUX_VIDEO: * On devices without AC97, this is the only value that it is currently * allowed.
@@ -369,7 +372,8 @@ enum em28xx_usb_audio_type {* same time, via the alsa mux. */ enum em28xx_amux { -EM28XX_AMUX_VIDEO , +EM28XX_AMUX_UNUSED =-1 , +EM28XX_AMUX_VIDEO =0 ,EM28XX_AMUX_LINE_IN ,/* Some less-common mixer setups */
@@ -692,6 +696,8 @@ struct em28xx {unsigned int ctl_input;// selected input unsigned int ctl_ainput;// selected audio input unsigned int ctl_aoutput;// selected audio output +enum em28xx_amux amux_map[MAX_EM28XX_INPUT ]; +int mute;int volume;
Greg Kroah-Hartman
maintainerPATCH 301/350 media: adv7604: when the EDID is cleared, unconfigure CEC as well
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit e7da89926f6dc6cf855f5ffdf79ef99a1b115ca7 upstream.
When there is no EDID the CEC adapter should be unconfigured as well. So call cec_phys_addr_invalidate() when this happens.
--- drivers/media/i2c/adv7604.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/i2c/adv7604.c +3 -1
@@ -2284,8 +2284,10 @@ static int adv76xx_set_edid(struct v4l2_ state->aspect_ratio.numerator =16 ; state->aspect_ratio.denominator =9 ; -if (!state->edid.present) +if (!state->edid.present) { state->edid.blocks =0 ; +cec_phys_addr_invalidate (state->cec_adap); + }v4l2_dbg (2 , debug, sd,"%s: clear EDID pad %d, edid.present = 0x%x\n" , __func__, edid->pad, state->edid.present);
Greg Kroah-Hartman
maintainerPATCH 302/350 media: adv7842: when the EDID is cleared, unconfigure CEC as well
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit ab83203e181015b099720aff43ffabc1812e0fb3 upstream.
When there is no EDID the CEC adapter should be unconfigured as well. So call cec_phys_addr_invalidate() when this happens.
--- drivers/media/i2c/adv7842.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/i2c/adv7842.c +3 -1
@@ -786,8 +786,10 @@ static int edid_write_hdmi_segment(struc/* Disable I2C access to internal EDID ram from HDMI DDC ports */ rep_write_and_or (sd,0x77 ,0xf3 ,0x00 ); -if (!state->hdmi_edid.present) +if (!state->hdmi_edid.present) { +cec_phys_addr_invalidate (state->cec_adap);return 0 ; + } pa =cec_get_edid_phys_addr (edid,256 , &spa_loc); err =cec_phys_addr_validate (pa, &pa,NULL );
Greg Kroah-Hartman
maintainerPATCH 303/350 drm/mediatek: fix OF sibling-node lookup
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit ceff2f4dcd44abf35864d9a99f85ac619e89a01d upstream.
Use the new of_get_compatible_child() helper to lookup the sibling instead of using of_find_compatible_node(), which searches the entire tree from a given start node and thus can return an unrelated (i.e. non-sibling) node.
This also addresses a potential use-after-free (e.g. after probe deferral) as the tree-wide helper drops a reference to its first argument (i.e. the parent device node).
While at it, also fix the related cec-node reference leak.
--- drivers/gpu/drm/mediatek/mtk_hdmi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/mediatek/mtk_hdmi.c +3 -2
@@ -1446,8 +1446,7 @@ static int mtk_hdmi_dt_parse_pdata(struc }/* The CEC module handles HDMI hotplug detection */ - cec_np =of_find_compatible_node (np->parent,NULL , -"mediatek,mt8173-cec" ); + cec_np =of_get_compatible_child (np->parent,"mediatek,mt8173-cec" );if (!cec_np) {dev_err (dev,"Failed to find CEC node\n" );return -EINVAL ;
@@ -1457,8 +1456,10 @@ static int mtk_hdmi_dt_parse_pdata(strucif (!cec_pdev) {dev_err (hdmi->dev,"Waiting for CEC device %pOF\n" , cec_np); +of_node_put (cec_np);return -EPROBE_DEFER ; } +of_node_put (cec_np); hdmi->cec_dev = &cec_pdev->dev;/*
Greg Kroah-Hartman
maintainerPATCH 304/350 media: media colorspaces*.rst: rename AdobeRGB to opRGB
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit a58c37978cf02f6d35d05ee4e9288cb8455f1401 upstream.
Drop all Adobe references and use the official opRGB standard instead.
--- Documentation/media/uapi/v4l/biblio.rst | 10 ---------- Documentation/media/uapi/v4l/colorspaces-defs.rst | 8 ++++---- Documentation/media/uapi/v4l/colorspaces-details.rst | 13 ++++++------- 3 files changed, 10 insertions(+), 21 deletions(-)
Documentation/media/uapi/v4l/biblio.rst +0 -10
@@ -226,16 +226,6 @@ xvYCC :author: International Electrotechnical Commission (http://www.iec.ch) -.. _adobergb: - -AdobeRGB -======== - - -:title: Adobe© RGB (1998) Color Image Encoding Version 2005-05 - -:author: Adobe Systems Incorporated (http://www.adobe.com) - .. _oprgb: opRGB
Documentation/media/uapi/v4l/colorspaces-defs.rst +4 -4
@@ -51,8 +51,8 @@ whole range, 0-255, dividing the angular - See :ref:`col-rec709`. * - ``V4L2_COLORSPACE_SRGB`` - See :ref:`col-srgb`. - * - ``V4L2_COLORSPACE_ADOBERGB`` - - See :ref:`col-adobergb`. + * - ``V4L2_COLORSPACE_OPRGB`` + - See :ref:`col-oprgb`. * - ``V4L2_COLORSPACE_BT2020`` - See :ref:`col-bt2020`. * - ``V4L2_COLORSPACE_DCI_P3``
@@ -90,8 +90,8 @@ whole range, 0-255, dividing the angular - Use the Rec. 709 transfer function. * - ``V4L2_XFER_FUNC_SRGB`` - Use the sRGB transfer function. - * - ``V4L2_XFER_FUNC_ADOBERGB`` - - Use the AdobeRGB transfer function. + * - ``V4L2_XFER_FUNC_OPRGB`` + - Use the opRGB transfer function. * - ``V4L2_XFER_FUNC_SMPTE240M`` - Use the SMPTE 240M transfer function. * - ``V4L2_XFER_FUNC_NONE``
Documentation/media/uapi/v4l/colorspaces-details.rst +6 -7
@@ -290,15 +290,14 @@ Y' is clamped to the range [0…1] and C 170M/BT.601. The Y'CbCr quantization is limited range. -.. _col-adobergb: +.. _col-oprgb: -Colorspace Adobe RGB (V4L2_COLORSPACE_ADOBERGB) +Colorspace opRGB (V4L2_COLORSPACE_OPRGB) =============================================== -The :ref:`adobergb` standard defines the colorspace used by computer -graphics that use the AdobeRGB colorspace. This is also known as the -:ref:`oprgb` standard. The default transfer function is -``V4L2_XFER_FUNC_ADOBERGB``. The default Y'CbCr encoding is +The :ref:`oprgb` standard defines the colorspace used by computer +graphics that use the opRGB colorspace. The default transfer function is +``V4L2_XFER_FUNC_OPRGB``. The default Y'CbCr encoding is ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited range.
@@ -312,7 +311,7 @@ The chromaticities of the primary colors .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}| -.. flat-table:: Adobe RGB Chromaticities +.. flat-table:: opRGB Chromaticities :header-rows: 1 :stub-columns: 0 :widths: 1 1 2
Greg Kroah-Hartman
maintainerPATCH 305/350 media: replace ADOBERGB by OPRGB
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit db0340182444612bcadb98bdec22f651aa42266c upstream.
The CTA-861 standards have been updated to refer to opRGB instead of AdobeRGB. The official standard is in fact named opRGB, so switch to that.
The two old defines referring to ADOBERGB in the public API are put under #ifndef __KERNEL__ and a comment mentions that they are deprecated.
--- Documentation/media/videodev2.h.rst.exceptions | 6 drivers/media/common/v4l2-tpg/v4l2-tpg-colors.c | 262 ++++++++++++------------ drivers/media/i2c/adv7511.c | 2 drivers/media/i2c/adv7604.c | 2 drivers/media/i2c/tc358743.c | 4 drivers/media/platform/vivid/vivid-core.h | 2 drivers/media/platform/vivid/vivid-ctrls.c | 6 drivers/media/platform/vivid/vivid-vid-out.c | 2 drivers/media/v4l2-core/v4l2-dv-timings.c | 8 include/uapi/linux/videodev2.h | 23 +- 10 files changed, 165 insertions(+), 152 deletions(-)
Documentation/media/videodev2.h.rst.exceptions +4 -2
@@ -56,7 +56,8 @@ replace symbol V4L2_MEMORY_USERPTR :c:ty # Documented enum v4l2_colorspace replace symbol V4L2_COLORSPACE_470_SYSTEM_BG :c:type:`v4l2_colorspace` replace symbol V4L2_COLORSPACE_470_SYSTEM_M :c:type:`v4l2_colorspace` -replace symbol V4L2_COLORSPACE_ADOBERGB :c:type:`v4l2_colorspace` +replace symbol V4L2_COLORSPACE_OPRGB :c:type:`v4l2_colorspace` +replace define V4L2_COLORSPACE_ADOBERGB :c:type:`v4l2_colorspace` replace symbol V4L2_COLORSPACE_BT2020 :c:type:`v4l2_colorspace` replace symbol V4L2_COLORSPACE_DCI_P3 :c:type:`v4l2_colorspace` replace symbol V4L2_COLORSPACE_DEFAULT :c:type:`v4l2_colorspace`
@@ -69,7 +70,8 @@ replace symbol V4L2_COLORSPACE_SRGB :c:t # Documented enum v4l2_xfer_func replace symbol V4L2_XFER_FUNC_709 :c:type:`v4l2_xfer_func` -replace symbol V4L2_XFER_FUNC_ADOBERGB :c:type:`v4l2_xfer_func` +replace symbol V4L2_XFER_FUNC_OPRGB :c:type:`v4l2_xfer_func` +replace define V4L2_XFER_FUNC_ADOBERGB :c:type:`v4l2_xfer_func` replace symbol V4L2_XFER_FUNC_DCI_P3 :c:type:`v4l2_xfer_func` replace symbol V4L2_XFER_FUNC_DEFAULT :c:type:`v4l2_xfer_func` replace symbol V4L2_XFER_FUNC_NONE :c:type:`v4l2_xfer_func`
drivers/media/common/v4l2-tpg/v4l2-tpg-colors.c +131 -131
358 lines not on this page · raw message
drivers/media/i2c/adv7511.c +1 -1
@@ -1355,7 +1355,7 @@ static int adv7511_set_fmt(struct v4l2_s state->xfer_func = format->format.xfer_func;switch (format->format.colorspace) { -case V4L2_COLORSPACE_ADOBERGB : +case V4L2_COLORSPACE_OPRGB : c =HDMI_COLORIMETRY_EXTENDED ; ec = y ?HDMI_EXTENDED_COLORIMETRY_ADOBE_YCC_601 :HDMI_EXTENDED_COLORIMETRY_ADOBE_RGB ;
drivers/media/i2c/adv7604.c +1 -1
@@ -2476,7 +2476,7 @@ static int adv76xx_log_status(struct v4l"YCbCr Bt.601 (16-235)" ,"YCbCr Bt.709 (16-235)" ,"xvYCC Bt.601" ,"xvYCC Bt.709" ,"YCbCr Bt.601 (0-255)" ,"YCbCr Bt.709 (0-255)" , -"sYCC" ,"Adobe YCC 601" ,"AdobeRGB" ,"invalid" ,"invalid" , +"sYCC" ,"opYCC 601" ,"opRGB" ,"invalid" ,"invalid" ,"invalid" ,"invalid" ,"invalid" }; static const char * const rgb_quantization_range_txt[] = {
drivers/media/i2c/tc358743.c +2 -2
@@ -1243,9 +1243,9 @@ static int tc358743_log_status(struct v4u8 vi_status3 =i2c_rd8 (sd,VI_STATUS3 );const int deep_color_mode[4 ] = {8 ,10 ,12 ,16 };static const char *const input_color_space[] = { -"RGB" ,"YCbCr 601" ,"Adobe RGB" ,"YCbCr 709" ,"NA (4)" , +"RGB" ,"YCbCr 601" ,"opRGB" ,"YCbCr 709" ,"NA (4)" ,"xvYCC 601" ,"NA(6)" ,"xvYCC 709" ,"NA(8)" ,"sYCC601" , -"NA(10)" ,"NA(11)" ,"NA(12)" ,"Adobe YCC 601" }; +"NA(10)" ,"NA(11)" ,"NA(12)" ,"opYCC 601" };v4l2_info (sd,"-----Chip status-----\n" ); v4l2_info(sd, "Chip ID: 0x%02x\n",
drivers/media/platform/vivid/vivid-core.h +1 -1
@@ -111,7 +111,7 @@ enum vivid_colorspace {VIVID_CS_170M ,VIVID_CS_709 ,VIVID_CS_SRGB , -VIVID_CS_ADOBERGB , +VIVID_CS_OPRGB ,VIVID_CS_2020 ,VIVID_CS_DCI_P3 , VIVID_CS_240M,
drivers/media/platform/vivid/vivid-ctrls.c +3 -3
@@ -348,7 +348,7 @@ static int vivid_vid_cap_s_ctrl(struct vV4L2_COLORSPACE_SMPTE170M ,V4L2_COLORSPACE_REC709 ,V4L2_COLORSPACE_SRGB , -V4L2_COLORSPACE_ADOBERGB , +V4L2_COLORSPACE_OPRGB ,V4L2_COLORSPACE_BT2020 ,V4L2_COLORSPACE_DCI_P3 , V4L2_COLORSPACE_SMPTE240M,
@@ -729,7 +729,7 @@ static const char * const vivid_ctrl_col"SMPTE 170M" ,"Rec. 709" ,"sRGB" , -"AdobeRGB" , +"opRGB" ,"BT.2020" ,"DCI-P3" , "SMPTE 240M",
@@ -752,7 +752,7 @@ static const char * const vivid_ctrl_xfe"Default" ,"Rec. 709" ,"sRGB" , -"AdobeRGB" , +"opRGB" ,"SMPTE 240M" ,"None" , "DCI-P3",
drivers/media/platform/vivid/vivid-vid-out.c +1 -1
@@ -413,7 +413,7 @@ int vivid_try_fmt_vid_out(struct file *f mp->colorspace =V4L2_COLORSPACE_SMPTE170M ; }else if (mp->colorspace !=V4L2_COLORSPACE_SMPTE170M && mp->colorspace !=V4L2_COLORSPACE_REC709 && - mp->colorspace !=V4L2_COLORSPACE_ADOBERGB && + mp->colorspace !=V4L2_COLORSPACE_OPRGB && mp->colorspace !=V4L2_COLORSPACE_BT2020 && mp->colorspace !=V4L2_COLORSPACE_SRGB ) { mp->colorspace =V4L2_COLORSPACE_REC709 ;
drivers/media/v4l2-core/v4l2-dv-timings.c +4 -4
@@ -838,8 +838,8 @@ v4l2_hdmi_rx_colorimetry(const struct hdcase HDMI_COLORIMETRY_EXTENDED :switch (avi->extended_colorimetry) {case HDMI_EXTENDED_COLORIMETRY_ADOBE_RGB : - c.colorspace =V4L2_COLORSPACE_ADOBERGB ; - c.xfer_func =V4L2_XFER_FUNC_ADOBERGB ; + c.colorspace =V4L2_COLORSPACE_OPRGB ; + c.xfer_func =V4L2_XFER_FUNC_OPRGB ;break ;case HDMI_EXTENDED_COLORIMETRY_BT2020 : c.colorspace =V4L2_COLORSPACE_BT2020 ;
@@ -909,9 +909,9 @@ v4l2_hdmi_rx_colorimetry(const struct hd c.xfer_func =V4L2_XFER_FUNC_SRGB ;break ;case HDMI_EXTENDED_COLORIMETRY_ADOBE_YCC_601 : - c.colorspace =V4L2_COLORSPACE_ADOBERGB ; + c.colorspace =V4L2_COLORSPACE_OPRGB ; c.ycbcr_enc =V4L2_YCBCR_ENC_601 ; - c.xfer_func =V4L2_XFER_FUNC_ADOBERGB ; + c.xfer_func =V4L2_XFER_FUNC_OPRGB ;break ;case HDMI_EXTENDED_COLORIMETRY_BT2020 : c.colorspace =V4L2_COLORSPACE_BT2020 ;
include/uapi/linux/videodev2.h +17 -6
@@ -225,8 +225,8 @@ enum v4l2_colorspace {/* For RGB colorspaces such as produces by most webcams. */ V4L2_COLORSPACE_SRGB =8 , -/* AdobeRGB colorspace */ -V4L2_COLORSPACE_ADOBERGB =9 , +/* opRGB colorspace */ +V4L2_COLORSPACE_OPRGB =9 ,/* BT.2020 colorspace, used for UHDTV. */ V4L2_COLORSPACE_BT2020 = 10,
@@ -258,7 +258,7 @@ enum v4l2_xfer_func {* * V4L2_COLORSPACE_SRGB, V4L2_COLORSPACE_JPEG: V4L2_XFER_FUNC_SRGB * -* V4L2_COLORSPACE_ADOBERGB: V4L2_XFER_FUNC_ADOBERGB +* V4L2_COLORSPACE_OPRGB: V4L2_XFER_FUNC_OPRGB * * V4L2_COLORSPACE_SMPTE240M: V4L2_XFER_FUNC_SMPTE240M *
@@ -269,7 +269,7 @@ enum v4l2_xfer_func {V4L2_XFER_FUNC_DEFAULT =0 ,V4L2_XFER_FUNC_709 =1 ,V4L2_XFER_FUNC_SRGB =2 , -V4L2_XFER_FUNC_ADOBERGB =3 , +V4L2_XFER_FUNC_OPRGB =3 ,V4L2_XFER_FUNC_SMPTE240M =4 ,V4L2_XFER_FUNC_NONE =5 , V4L2_XFER_FUNC_DCI_P3 = 6,
@@ -281,7 +281,7 @@ enum v4l2_xfer_func {* This depends on the colorspace. */ #define V4L2_MAP_XFER_FUNC_DEFAULT (colsp) \ - ((colsp) == V4L2_COLORSPACE_ADOBERGB ? V4L2_XFER_FUNC_ADOBERGB : \ + ((colsp) == V4L2_COLORSPACE_OPRGB ? V4L2_XFER_FUNC_OPRGB : \ ((colsp) == V4L2_COLORSPACE_SMPTE240M ? V4L2_XFER_FUNC_SMPTE240M : \ ((colsp) == V4L2_COLORSPACE_DCI_P3 ? V4L2_XFER_FUNC_DCI_P3 : \ ((colsp) == V4L2_COLORSPACE_RAW ? V4L2_XFER_FUNC_NONE : \
@@ -295,7 +295,7 @@ enum v4l2_ycbcr_encoding {* * V4L2_COLORSPACE_SMPTE170M, V4L2_COLORSPACE_470_SYSTEM_M, * V4L2_COLORSPACE_470_SYSTEM_BG, V4L2_COLORSPACE_SRGB, -* V4L2_COLORSPACE_ADOBERGB and V4L2_COLORSPACE_JPEG: V4L2_YCBCR_ENC_601 +* V4L2_COLORSPACE_OPRGB and V4L2_COLORSPACE_JPEG: V4L2_YCBCR_ENC_601 * * V4L2_COLORSPACE_REC709 and V4L2_COLORSPACE_DCI_P3: V4L2_YCBCR_ENC_709 *
@@ -382,6 +382,17 @@ enum v4l2_quantization { (((is_rgb_or_hsv) || (colsp) == V4L2_COLORSPACE_JPEG) ? \ V4L2_QUANTIZATION_FULL_RANGE : V4L2_QUANTIZATION_LIM_RANGE)) +/* +* Deprecated names for opRGB colorspace (IEC 61966-2-5) +* +* WARNING: Please don't use these deprecated defines in your code, as +* there is a chance we have to remove them in the future. +*/ +#ifndef __KERNEL__ +#define V4L2_COLORSPACE_ADOBERGB V4L2_COLORSPACE_OPRGB +#define V4L2_XFER_FUNC_ADOBERGB V4L2_XFER_FUNC_OPRGB +#endif +enum v4l2_priority {V4L2_PRIORITY_UNSET =0 ,/* not initialized */ V4L2_PRIORITY_BACKGROUND =1 ,
Greg Kroah-Hartman
maintainerPATCH 306/350 media: hdmi.h: rename ADOBE_RGB to OPRGB and ADOBE_YCC to OPYCC
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit 463659a08d7999d5461fa45b35b17686189a70ca upstream.
These names have been renamed in the CTA-861 standard due to trademark issues. Replace them here as well so they are in sync with the standard.
--- drivers/media/i2c/adv7511.c | 4 ++-- drivers/media/v4l2-core/v4l2-dv-timings.c | 4 ++-- drivers/video/hdmi.c | 8 ++++---- include/linux/hdmi.h | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-)
drivers/media/i2c/adv7511.c +2 -2
@@ -1357,8 +1357,8 @@ static int adv7511_set_fmt(struct v4l2_sswitch (format->format.colorspace) {case V4L2_COLORSPACE_OPRGB : c =HDMI_COLORIMETRY_EXTENDED ; - ec = y ?HDMI_EXTENDED_COLORIMETRY_ADOBE_YCC_601 : -HDMI_EXTENDED_COLORIMETRY_ADOBE_RGB ; + ec = y ?HDMI_EXTENDED_COLORIMETRY_OPYCC_601 : +HDMI_EXTENDED_COLORIMETRY_OPRGB ;break ;case V4L2_COLORSPACE_SMPTE170M : c = y ?HDMI_COLORIMETRY_ITU_601 :HDMI_COLORIMETRY_NONE ;
drivers/media/v4l2-core/v4l2-dv-timings.c +2 -2
@@ -837,7 +837,7 @@ v4l2_hdmi_rx_colorimetry(const struct hdswitch (avi->colorimetry) {case HDMI_COLORIMETRY_EXTENDED :switch (avi->extended_colorimetry) { -case HDMI_EXTENDED_COLORIMETRY_ADOBE_RGB : +case HDMI_EXTENDED_COLORIMETRY_OPRGB : c.colorspace =V4L2_COLORSPACE_OPRGB ; c.xfer_func =V4L2_XFER_FUNC_OPRGB ;break ;
@@ -908,7 +908,7 @@ v4l2_hdmi_rx_colorimetry(const struct hd c.ycbcr_enc =V4L2_YCBCR_ENC_601 ; c.xfer_func =V4L2_XFER_FUNC_SRGB ;break ; -case HDMI_EXTENDED_COLORIMETRY_ADOBE_YCC_601 : +case HDMI_EXTENDED_COLORIMETRY_OPYCC_601 : c.colorspace =V4L2_COLORSPACE_OPRGB ; c.ycbcr_enc =V4L2_YCBCR_ENC_601 ; c.xfer_func =V4L2_XFER_FUNC_OPRGB ;
drivers/video/hdmi.c +4 -4
@@ -592,10 +592,10 @@ hdmi_extended_colorimetry_get_name(enumreturn "xvYCC 709" ;case HDMI_EXTENDED_COLORIMETRY_S_YCC_601 :return "sYCC 601" ; -case HDMI_EXTENDED_COLORIMETRY_ADOBE_YCC_601 : -return "Adobe YCC 601" ; -case HDMI_EXTENDED_COLORIMETRY_ADOBE_RGB : -return "Adobe RGB" ; +case HDMI_EXTENDED_COLORIMETRY_OPYCC_601 : +return "opYCC 601" ; +case HDMI_EXTENDED_COLORIMETRY_OPRGB : +return "opRGB" ;case HDMI_EXTENDED_COLORIMETRY_BT2020_CONST_LUM :return "BT.2020 Constant Luminance" ;case HDMI_EXTENDED_COLORIMETRY_BT2020 :
include/linux/hdmi.h +2 -2
@@ -101,8 +101,8 @@ enum hdmi_extended_colorimetry {HDMI_EXTENDED_COLORIMETRY_XV_YCC_601 ,HDMI_EXTENDED_COLORIMETRY_XV_YCC_709 ,HDMI_EXTENDED_COLORIMETRY_S_YCC_601 , -HDMI_EXTENDED_COLORIMETRY_ADOBE_YCC_601 , -HDMI_EXTENDED_COLORIMETRY_ADOBE_RGB , +HDMI_EXTENDED_COLORIMETRY_OPYCC_601 , +HDMI_EXTENDED_COLORIMETRY_OPRGB ,/* The following EC values are only defined in CEA-861-F. */ HDMI_EXTENDED_COLORIMETRY_BT2020_CONST_LUM,
Greg Kroah-Hartman
maintainerPATCH 307/350 arm64: lse: remove -fcall-used-x0 flag
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tri Vo <[email protected]>
commit 2a6c7c367de82951c98a290a21156770f6f82c84 upstream.
x0 is not callee-saved in the PCS. So there is no need to specify -fcall-used-x0.
Clang doesn't currently support -fcall-used flags. This patch will help building the kernel with clang.
--- arch/arm64/lib/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/lib/Makefile +1 -1
@@ -12,7 +12,7 @@ lib-y := bitops.o clear_user.o delay.o # when supported by the CPU. Result and argument registers are handled # correctly, based on the function prototype. lib-$(CONFIG_ARM64_LSE_ATOMICS) += atomic_ll_sc.o -CFLAGS_atomic_ll_sc.o := -fcall-used-x0 -ffixed-x1 -ffixed-x2 \ +CFLAGS_atomic_ll_sc.o := -ffixed-x1 -ffixed-x2 \ -ffixed-x3 -ffixed-x4 -ffixed-x5 -ffixed-x6 \ -ffixed-x7 -fcall-saved-x8 -fcall-saved-x9 \ -fcall-saved-x10 -fcall-saved-x11 -fcall-saved-x12 \
Greg Kroah-Hartman
maintainerPATCH 308/350 rpmsg: smd: fix memory leak on channel create
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Colin Ian King <[email protected]>
commit 940c620d6af8fca7d115de40f19870fba415efac upstream.
Currently a failed allocation of channel->name leads to an immediate return without freeing channel. Fix this by setting ret to -ENOMEM and jumping to an exit path that kfree's channel.
Detected by CoverityScan, CID#1473692 ("Resource Leak")
--- drivers/rpmsg/qcom_smd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/rpmsg/qcom_smd.c +5 -2
@@ -1114,8 +1114,10 @@ static struct qcom_smd_channel *qcom_smd channel->edge = edge; channel->name =kstrdup (name,GFP_KERNEL ); -if (!channel->name) -return ERR_PTR (-ENOMEM ); +if (!channel->name) { + ret = -ENOMEM ; + goto free_channel; + }spin_lock_init (&channel->tx_lock);spin_lock_init (&channel->recv_lock);
@@ -1165,6 +1167,7 @@ static struct qcom_smd_channel *qcom_smd free_name_and_channel:kfree (channel->name); +free_channel:kfree (channel);return ERR_PTR (ret);
Greg Kroah-Hartman
maintainerPATCH 309/350 Cramfs: fix abad comparison when wrap-arounds occur
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Pitre <[email protected]>
commit 672ca9dd13f1aca0c17516f76fc5b0e8344b3e46 upstream.
It is possible for corrupted filesystem images to produce very large block offsets that may wrap when a length is added, and wrongly pass the buffer size test.
--- fs/cramfs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/cramfs/inode.c +2 -1
@@ -202,7 +202,8 @@ static void *cramfs_blkdev_read(struct scontinue ; blk_offset = (blocknr - buffer_blocknr[i]) <<PAGE_SHIFT ; blk_offset += offset; -if (blk_offset + len >BUFFER_SIZE ) +if (blk_offset >BUFFER_SIZE || + blk_offset + len >BUFFER_SIZE )continue ;return read_buffers[i] + blk_offset; }
Greg Kroah-Hartman
maintainerPATCH 310/350 ARM: dts: socfpga: Fix SDRAM node address for Arria10
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thor Thayer <[email protected]>
commit ce3bf934f919a7d675c5b7fa4cc233ded9c6256e upstream.
The address in the SDRAM node was incorrect. Fix this to agree with the correct address and to match the reg definition block.
--- arch/arm/boot/dts/socfpga_arria10.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/socfpga_arria10.dtsi +1 -1
@@ -601,7 +601,7 @@ status = "disabled"; }; - sdr: sdr@ffc25000 { + sdr: sdr@ffcfb100 { compatible = "altr,sdr-ctl", "syscon"; reg = <0xffcfb100 0x80>; };
Greg Kroah-Hartman
maintainerPATCH 311/350 arm64: dts: stratix10: Correct System Manager register size
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thor Thayer <[email protected]>
commit 74121b9aa3cd571ddfff014a9f47db36cae3cda9 upstream.
Correct the register size of the System Manager node.
--- arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi +1 -1
@@ -327,7 +327,7 @@ sysmgr: sysmgr@ffd12000 { compatible = "altr,sys-mgr", "syscon"; - reg = <0xffd12000 0x1000>; + reg = <0xffd12000 0x228>; }; /* Local timer */
Greg Kroah-Hartman
maintainerPATCH 312/350 soc: qcom: rmtfs-mem: Validate that scm is available
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bjorn Andersson <[email protected]>
commit 137dc5843faeacabf48fc22a8dc58c4e0b4f0927 upstream.
The scm device must be present in order for the rmtfs driver to configure memory permissions for the rmtfs memory region, so check that it is probed before continuing.
--- drivers/soc/qcom/rmtfs_mem.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/soc/qcom/rmtfs_mem.c +5 -0
@@ -212,6 +212,11 @@ static int qcom_rmtfs_mem_probe(struct pdev_err (&pdev->dev,"failed to parse qcom,vmid\n" ); goto remove_cdev; }else if (!ret) { +if (!qcom_scm_is_available ()) { + ret = -EPROBE_DEFER ; + goto remove_cdev; + } + perms[0 ].vmid =QCOM_SCM_VMID_HLOS ; perms[0 ].perm =QCOM_SCM_PERM_RW ; perms[1 ].vmid = vmid;
Greg Kroah-Hartman
maintainerPATCH 313/350 soc/tegra: pmc: Fix child-node lookup
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 1dc6bd5e39a29453bdcc17348dd2a89f1aa4004e upstream.
Fix child-node lookup during probe, which ended up searching the whole device tree depth-first starting at the parent rather than just matching on its children.
To make things worse, the parent pmc node could end up being prematurely freed as of_find_node_by_name() drops a reference to its first argument.
--- drivers/soc/tegra/pmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/tegra/pmc.c +1 -1
@@ -1288,7 +1288,7 @@ static void tegra_pmc_init_tsense_reset(if (!pmc->soc->has_tsense_reset)return ; - np =of_find_node_by_name (pmc->dev->of_node,"i2c-thermtrip" ); + np =of_get_child_by_name (pmc->dev->of_node,"i2c-thermtrip" );if (!np) {dev_warn (dev,"i2c-thermtrip node not found, %s.\n" , disabled);return ;
Greg Kroah-Hartman
maintainerPATCH 314/350 selftests/ftrace: Fix synthetic event test to delete event correctly
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu <[email protected]>
commit 0d0352d8b3d6d7ca9a710b40e194cbbaeb841c88 upstream.
Fix the synthetic event test case to remove event correctly. If redirecting command to synthetic_event file without append mode, it cleans up all existing events and execute (parse) the command. This means "delete event" always fails to find the target event.
Since previous synthetic event has a bug which doesn't return -ENOENT even if it fails to find the deleting event, this test passed. But fixing that bug, this test fails because this test itself has a bug.
This fixes that bug by trying to delete event right after adding an event, and use append mode redirection ('>>') instead of normal redirection ('>').
--- tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic-event-createremove.tc | 12 +++++----- 1 file changed, 6 insertions(+), 6 deletions(-)
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic-event-createremove.tc +6 -6
@@ -35,18 +35,18 @@ fi reset_trigger -echo "Test create synthetic event with an error" -echo 'wakeup_latency u64 lat pid_t pid char' > synthetic_events > /dev/null +echo "Test remove synthetic event" +echo '!wakeup_latency u64 lat pid_t pid char comm[16]' >> synthetic_events if [ -d events/synthetic/wakeup_latency ]; then - fail "Created wakeup_latency synthetic event with an invalid format" + fail "Failed to delete wakeup_latency synthetic event" fi reset_trigger -echo "Test remove synthetic event" -echo '!wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events +echo "Test create synthetic event with an error" +echo 'wakeup_latency u64 lat pid_t pid char' > synthetic_events > /dev/null if [ -d events/synthetic/wakeup_latency ]; then - fail "Failed to delete wakeup_latency synthetic event" + fail "Created wakeup_latency synthetic event with an invalid format" fi do_reset
Greg Kroah-Hartman
maintainerPATCH 315/350 selftests/powerpc: Fix ptrace tm failure
In reply to Greg Kroah-Hartman4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
commit 48dc0ef19044bfb69193302fbe3a834e3331b7ae upstream.
Test ptrace-tm-spd-gpr fails on current kernel (4.19) due to a segmentation fault that happens on the child process prior to setting cptr[2] = 1. This causes the parent process to wait forever at 'while (!pptr[2])' and the test to be killed by the test harness framework by timeout, thus, failing.
The segmentation fault happens because of a inline assembly being generated as:
0x10000355c <tm_spd_gpr+492> lfs f0, 0(0)
This is reading memory position 0x0 and causing the segmentation fault.
This code is being generated by ASM_LOAD_FPR_SINGLE_PRECISION(flt_4), where flt_4 is passed to the inline assembly block as:
[flt_4] "r" (&d)
Since the inline assembly 'r' constraint means any GPR, gpr0 is being chosen, thus causing this issue when issuing a Load Floating-Point Single instruction.
This patch simply changes the constraint to 'b', which specify that this register will be used as base, and r0 is not allowed to be used, avoiding this issue.
Other than that, removing flt_2 register from the input operands, since it is not used by the inline assembly code at all.
--- tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-gpr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-gpr.c +2 -2
@@ -67,8 +67,8 @@ trans:"3: ;" : [res] "=r" (result), [texasr] "=r" (texasr) : [gpr_1]"i"(GPR_1), [gpr_2]"i"(GPR_2), [gpr_4]"i"(GPR_4), - [sprn_texasr] "i" (SPRN_TEXASR), [flt_1] "r" (&a), - [flt_2] "r" (&b), [flt_4] "r" (&d) + [sprn_texasr] "i" (SPRN_TEXASR), [flt_1] "b" (&a), + [flt_4] "b" (&d) : "memory", "r5", "r6", "r7","r8" ,"r9" ,"r10" ,"r11" ,"r12" ,"r13" ,"r14" ,"r15" , "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",