4.14.192-rc1 review
Greg Kroah-Hartman
maintainercover 4.14.192-rc1 review
This is the start of the stable review cycle for the 4.14.192 release. There are 51 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 05 Aug 2020 12:18:33 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.192-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.14.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 4.14.192-rc1
Thomas Gleixner <[email protected]>
x86/i8259: Use printk_deferred() to prevent deadlock
Wanpeng Li <[email protected]>
KVM: LAPIC: Prevent setting the tscdeadline timer if the lapic is hw disabled
Andrea Righi <[email protected]>
xen-netfront: fix potential deadlock in xennet_remove()
Navid Emamdoost <[email protected]>
cxgb4: add missing release on skb in uld_send()
Josh Poimboeuf <[email protected]>
x86/unwind/orc: Fix ORC for newly forked tasks
Raviteja Narayanam <[email protected]>
Revert "i2c: cadence: Fix the hold bit setting"
Yoshihiro Shimoda <[email protected]>
net: ethernet: ravb: exit if re-initialization fails in tx timeout
Liam Beguin <[email protected]>
parisc: add support for cmpxchg on u8 pointers
Navid Emamdoost <[email protected]>
nfc: s3fwrn5: add missing release on skb in s3fwrn5_recv_frame
Laurence Oberman <[email protected]>
qed: Disable "MFW indication via attention" SPAM every 5 minutes
Geert Uytterhoeven <[email protected]>
usb: hso: Fix debug compile warning on sparc32
Robin Murphy <[email protected]>
arm64: csum: Fix handling of bad packets
Sami Tolvanen <[email protected]>
arm64/alternatives: move length validation inside the subsection
Remi Pommarel <[email protected]>
mac80211: mesh: Free pending skb when destroying a mpath
Remi Pommarel <[email protected]>
mac80211: mesh: Free ie data when leaving mesh
Andrii Nakryiko <[email protected]>
bpf: Fix map leak in HASH_OF_MAPS map
Thomas Falcon <[email protected]>
ibmvnic: Fix IRQ mapping disposal in error path
Ido Schimmel <[email protected]>
mlxsw: core: Free EMAD transactions using kfree_rcu()
Ido Schimmel <[email protected]>
mlxsw: core: Increase scope of RCU read-side critical section
Jakub Kicinski <[email protected]>
mlx4: disable device on shutdown
Johan Hovold <[email protected]>
net: lan78xx: fix transfer-buffer memory leak
Johan Hovold <[email protected]>
net: lan78xx: add missing endpoint sanity check
Michael Karcher <[email protected]>
sh: Fix validation of system call number
Tanner Love <[email protected]>
selftests/net: rxtimestamp: fix clang issues for target arch PowerPC
YueHaibing <[email protected]>
net/x25: Fix null-ptr-deref in x25_disconnect
Xiyu Yang <[email protected]>
net/x25: Fix x25_neigh refcnt leak when x25 disconnect
Rik van Riel <[email protected]>
xfs: fix missed wakeup on l_flush_wait
Peilin Ye <[email protected]>
rds: Prevent kernel-infoleak in rds_notify_queue_get()
Joerg Roedel <[email protected]>
x86, vmlinux.lds: Page-align end of ..page_aligned sections
Sami Tolvanen <[email protected]>
x86/build/lto: Fix truncated .bss with -fdata-sections
Wang Hai <[email protected]>
9p/trans_fd: Fix concurrency del of req_list in p9_fd_cancelled/p9_read_work
Dominique Martinet <[email protected]>
9p/trans_fd: abort p9_read_work if req status changed
Linus Torvalds <[email protected]>
random32: remove net_rand_state from the latent entropy gcc plugin
Willy Tarreau <[email protected]>
random: fix circular include dependency on arm64 after addition of percpu.h
Sheng Yong <[email protected]>
f2fs: check if file namelen exceeds max value
Jaegeuk Kim <[email protected]>
f2fs: check memory boundary by insane namelen
Steve Cohen <[email protected]>
drm: hold gem reference until object is no longer accessed
Peilin Ye <[email protected]>
drm/amdgpu: Prevent kernel-infoleak in amdgpu_info_ioctl()
Grygorii Strashko <[email protected]>
ARM: percpu.h: fix build error
Willy Tarreau <[email protected]>
random32: update the net random state on interrupt and activity
Will Deacon <[email protected]>
ARM: 8986/1: hw_breakpoint: Don't invoke overflow handler on uaccess watchpoints
Pi-Hsun Shih <[email protected]>
wireless: Use offsetof instead of custom macro.
Robert Hancock <[email protected]>
PCI/ASPM: Disable ASPM on ASMedia ASM1083/1085 PCIe-to-PCI bridge
Sasha Levin <[email protected]>
x86/kvm: Be careful not to clear KVM_VCPU_FLUSH_TLB bit
Navid Emamdoost <[email protected]>
ath9k: release allocated buffer if timed out
Navid Emamdoost <[email protected]>
ath9k_htc: release allocated buffer if timed out
Sasha Levin <[email protected]>
iio: imu: adis16400: fix memory leak
Navid Emamdoost <[email protected]>
media: rc: prevent memory leak in cx23888_ir_probe
Navid Emamdoost <[email protected]>
crypto: ccp - Release all allocated memory if sha type is invalid
Wei Yongjun <[email protected]>
net: phy: mdio-bcm-unimac: fix potential NULL dereference in unimac_mdio_probe()
Jason Yan <[email protected]>
scsi: libsas: direct call probe and destruct
-------------
Diffstat:
Makefile | 4 +- arch/arm/include/asm/percpu.h | 2 + arch/arm/kernel/hw_breakpoint.c | 27 +++++++-- arch/arm64/include/asm/alternative.h | 4 +- arch/arm64/include/asm/checksum.h | 5 +- arch/parisc/include/asm/cmpxchg.h | 2 + arch/parisc/lib/bitops.c | 12 ++++ arch/sh/kernel/entry-common.S | 6 +- arch/x86/kernel/i8259.c | 2 +- arch/x86/kernel/unwind_orc.c | 8 ++- arch/x86/kernel/vmlinux.lds.S | 3 +- arch/x86/kvm/lapic.c | 2 +- arch/x86/kvm/x86.c | 3 + drivers/char/random.c | 1 + drivers/crypto/ccp/ccp-ops.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 3 +- drivers/gpu/drm/drm_gem.c | 10 ++-- drivers/i2c/busses/i2c-cadence.c | 9 +-- drivers/iio/imu/adis16400_buffer.c | 5 +- drivers/media/pci/cx23885/cx23888-ir.c | 5 +- drivers/net/ethernet/chelsio/cxgb4/sge.c | 1 + drivers/net/ethernet/ibm/ibmvnic.c | 2 +- drivers/net/ethernet/mellanox/mlx4/main.c | 2 + drivers/net/ethernet/mellanox/mlxsw/core.c | 8 ++- drivers/net/ethernet/qlogic/qed/qed_int.c | 3 +- drivers/net/ethernet/renesas/ravb_main.c | 26 ++++++++- drivers/net/phy/mdio-bcm-unimac.c | 2 + drivers/net/usb/hso.c | 5 +- drivers/net/usb/lan78xx.c | 6 ++ drivers/net/wireless/ath/ath9k/htc_hst.c | 3 + drivers/net/wireless/ath/ath9k/wmi.c | 1 + drivers/net/xen-netfront.c | 64 ++++++++++++++-------- drivers/nfc/s3fwrn5/core.c | 1 + drivers/pci/quirks.c | 13 +++++ drivers/scsi/libsas/sas_ata.c | 1 - drivers/scsi/libsas/sas_discover.c | 32 ++++++----- drivers/scsi/libsas/sas_expander.c | 8 +-- drivers/scsi/libsas/sas_internal.h | 1 + drivers/scsi/libsas/sas_port.c | 3 + fs/f2fs/dir.c | 12 +++- fs/xfs/xfs_log.c | 9 ++- include/asm-generic/vmlinux.lds.h | 5 +- include/linux/random.h | 3 + include/scsi/libsas.h | 3 +- include/scsi/scsi_transport_sas.h | 1 + include/uapi/linux/wireless.h | 5 +- kernel/bpf/hashtab.c | 12 +++- kernel/time/timer.c | 8 +++ lib/random32.c | 2 +- net/9p/trans_fd.c | 32 ++++++++--- net/mac80211/cfg.c | 1 + net/mac80211/mesh_pathtbl.c | 1 + net/rds/recv.c | 3 +- net/x25/x25_subr.c | 6 ++ .../networking/timestamping/rxtimestamp.c | 3 +- 55 files changed, 292 insertions(+), 112 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/51 scsi: libsas: direct call probe and destruct
From: Jason Yan <[email protected]>
[ Upstream commit 0558f33c06bb910e2879e355192227a8e8f0219d ]
In commit 87c8331fcf72 ("[SCSI] libsas: prevent domain rediscovery competing with ata error handling") introduced disco mutex to prevent rediscovery competing with ata error handling and put the whole revalidation in the mutex. But the rphy add/remove needs to wait for the error handling which also grabs the disco mutex. This may leads to dead lock.So the probe and destruct event were introduce to do the rphy add/remove asynchronously and out of the lock.
The asynchronously processed workers makes the whole discovery process not atomic, the other events may interrupt the process. For example, if a loss of signal event inserted before the probe event, the sas_deform_port() is called and the port will be deleted.
And sas_port_delete() may run before the destruct event, but the port-x:x is the top parent of end device or expander. This leads to a kernel WARNING such as:
[ 82.042979] sysfs group 'power' not found for kobject 'phy-1:0:22' [ 82.042983] ------------[ cut here ]------------ [ 82.042986] WARNING: CPU: 54 PID: 1714 at fs/sysfs/group.c:237 sysfs_remove_group+0x94/0xa0 [ 82.043059] Call trace: [ 82.043082] [<ffff0000082e7624>] sysfs_remove_group+0x94/0xa0 [ 82.043085] [<ffff00000864e320>] dpm_sysfs_remove+0x60/0x70 [ 82.043086] [<ffff00000863ee10>] device_del+0x138/0x308 [ 82.043089] [<ffff00000869a2d0>] sas_phy_delete+0x38/0x60 [ 82.043091] [<ffff00000869a86c>] do_sas_phy_delete+0x6c/0x80 [ 82.043093] [<ffff00000863dc20>] device_for_each_child+0x58/0xa0 [ 82.043095] [<ffff000008696f80>] sas_remove_children+0x40/0x50 [ 82.043100] [<ffff00000869d1bc>] sas_destruct_devices+0x64/0xa0 [ 82.043102] [<ffff0000080e93bc>] process_one_work+0x1fc/0x4b0 [ 82.043104] [<ffff0000080e96c0>] worker_thread+0x50/0x490 [ 82.043105] [<ffff0000080f0364>] kthread+0xfc/0x128 [ 82.043107] [<ffff0000080836c0>] ret_from_fork+0x10/0x50
Make probe and destruct a direct call in the disco and revalidate function, but put them outside the lock. The whole discovery or revalidate won't be interrupted by other events. And the DISCE_PROBE and DISCE_DESTRUCT event are deleted as a result of the direct call.
Introduce a new list to destruct the sas_port and put the port delete after the destruct. This makes sure the right order of destroying the sysfs kobject and fix the warning above.
In sas_ex_revalidate_domain() have a loop to find all broadcasted device, and sometimes we have a chance to find the same expander twice. Because the sas_port will be deleted at the end of the whole revalidate process, sas_port with the same name cannot be added before this. Otherwise the sysfs will complain of creating duplicate filename. Since the LLDD will send broadcast for every device change, we can only process one expander's revalidation.
[mkp: kbuild test robot warning]
--- drivers/scsi/libsas/sas_ata.c | 1 - drivers/scsi/libsas/sas_discover.c | 32 +++++++++++++++++------------- drivers/scsi/libsas/sas_expander.c | 8 +++----- drivers/scsi/libsas/sas_internal.h | 1 + drivers/scsi/libsas/sas_port.c | 3 +++ include/scsi/libsas.h | 3 +-- include/scsi/scsi_transport_sas.h | 1 + 7 files changed, 27 insertions(+), 22 deletions(-)
drivers/scsi/libsas/sas_ata.c +0 -1
@@ -730,7 +730,6 @@ int sas_discover_sata(struct domain_device *dev)if (res)return res; -sas_discover_event (dev->port,DISCE_PROBE );return 0 ; }
drivers/scsi/libsas/sas_discover.c +18 -14
@@ -221,13 +221,9 @@ void sas_notify_lldd_dev_gone(struct domain_device *dev) } } -static void sas_probe_devices (struct work_struct *work) +static void sas_probe_devices (struct asd_sas_port *port) {struct domain_device *dev, *n; -struct sas_discovery_event *ev =to_sas_discovery_event (work); -struct asd_sas_port *port = ev->port; - -clear_bit (DISCE_PROBE , &port->disc.pending);/* devices must be domain members before link recovery and probe */ list_for_each_entry (dev, &port->disco_list, disco_list_node) {
@@ -303,7 +299,6 @@ int sas_discover_end_dev(struct domain_device *dev) res =sas_notify_lldd_dev_found (dev);if (res)return res; -sas_discover_event (dev->port,DISCE_PROBE );return 0 ; }
@@ -362,13 +357,9 @@ static void sas_unregister_common_dev(struct asd_sas_port *port, struct domain_dsas_put_device (dev); } -static void sas_destruct_devices (struct work_struct *work) +void sas_destruct_devices (struct asd_sas_port *port) {struct domain_device *dev, *n; -struct sas_discovery_event *ev =to_sas_discovery_event (work); -struct asd_sas_port *port = ev->port; - -clear_bit (DISCE_DESTRUCT , &port->disc.pending);list_for_each_entry_safe (dev, n, &port->destroy_list, disco_list_node) {list_del_init (&dev->disco_list_node);
@@ -379,6 +370,16 @@ static void sas_destruct_devices(struct work_struct *work) } } +static void sas_destruct_ports (struct asd_sas_port *port) +{ +struct sas_port *sas_port, *p; + +list_for_each_entry_safe (sas_port, p, &port->sas_port_del_list, del_list) { +list_del_init (&sas_port->del_list); +sas_port_delete (sas_port); + } +} +void sas_unregister_dev (struct asd_sas_port *port,struct domain_device *dev) { if (!test_bit(SAS_DEV_DESTROY, &dev->state) &&
@@ -393,7 +394,6 @@ void sas_unregister_dev(struct asd_sas_port *port, struct domain_device *dev)if (!test_and_set_bit (SAS_DEV_DESTROY , &dev->state)) {sas_rphy_unlink (dev->rphy);list_move_tail (&dev->disco_list_node, &port->destroy_list); -sas_discover_event (dev->port,DISCE_DESTRUCT ); } }
@@ -499,6 +499,8 @@ static void sas_discover_domain(struct work_struct *work) port->port_dev =NULL ; } +sas_probe_devices (port); +SAS_DPRINTK ("DONE DISCOVERY on port %d, pid:%d, result:%d\n" , port->id,task_pid_nr (current), error); }
@@ -532,6 +534,10 @@ static void sas_revalidate_domain(struct work_struct *work) port->id, task_pid_nr(current), res); out:mutex_unlock (&ha->disco_mutex); + +sas_destruct_devices (port); +sas_destruct_ports (port); +sas_probe_devices (port); }/* ---------- Events ---------- */
@@ -587,10 +593,8 @@ void sas_init_disc(struct sas_discovery *disc, struct asd_sas_port *port)static const work_func_t sas_event_fns[DISC_NUM_EVENTS ] = { [DISCE_DISCOVER_DOMAIN ] = sas_discover_domain, [DISCE_REVALIDATE_DOMAIN ] = sas_revalidate_domain, - [DISCE_PROBE ] = sas_probe_devices, [DISCE_SUSPEND ] = sas_suspend_devices, [DISCE_RESUME ] = sas_resume_devices, - [DISCE_DESTRUCT ] = sas_destruct_devices, }; disc->pending =0 ;
drivers/scsi/libsas/sas_expander.c +3 -5
@@ -1946,7 +1946,8 @@ static void sas_unregister_devs_sas_addr(struct domain_device *parent,sas_port_delete_phy (phy->port, phy->phy);sas_device_set_phy (found, phy->port);if (phy->port->num_phys ==0 ) -sas_port_delete (phy->port); +list_add_tail (&phy->port->del_list, + &parent->port->sas_port_del_list); phy->port =NULL ; } }
@@ -2156,7 +2157,7 @@ int sas_ex_revalidate_domain(struct domain_device *port_dev)struct domain_device *dev =NULL ; res =sas_find_bcast_dev (port_dev, &dev); -while (res ==0 && dev) { +if (res ==0 && dev) {struct expander_device *ex = &dev->ex_dev;int i =0 , phy_id;
@@ -2168,9 +2169,6 @@ int sas_ex_revalidate_domain(struct domain_device *port_dev) res =sas_rediscover (dev, phy_id); i = phy_id +1 ; }while (i < ex->num_phys); - - dev =NULL ; - res =sas_find_bcast_dev (port_dev, &dev); }return res; }
drivers/scsi/libsas/sas_internal.h +1 -0
@@ -98,6 +98,7 @@ int sas_try_ata_reset(struct asd_sas_phy *phy);void sas_hae_reset (struct work_struct *work);void sas_free_device (struct kref *kref); +void sas_destruct_devices (struct asd_sas_port *port);#ifdef CONFIG_SCSI_SAS_HOST_SMP extern void sas_smp_host_handler (struct bsg_job *job,struct Scsi_Host *shost);
drivers/scsi/libsas/sas_port.c +3 -0
@@ -66,6 +66,7 @@ static void sas_resume_port(struct asd_sas_phy *phy) rc =sas_notify_lldd_dev_found (dev);if (rc) {sas_unregister_dev (port, dev); +sas_destruct_devices (port);continue ; }
@@ -219,6 +220,7 @@ void sas_deform_port(struct asd_sas_phy *phy, int gone)if (port->num_phys ==1 ) {sas_unregister_domain_devices (port, gone); +sas_destruct_devices (port);sas_port_delete (port->port); port->port =NULL ; }else {
@@ -323,6 +325,7 @@ static void sas_init_port(struct asd_sas_port *port,INIT_LIST_HEAD (&port->dev_list);INIT_LIST_HEAD (&port->disco_list);INIT_LIST_HEAD (&port->destroy_list); +INIT_LIST_HEAD (&port->sas_port_del_list);spin_lock_init (&port->phy_list_lock);INIT_LIST_HEAD (&port->phy_list); port->ha = sas_ha;
include/scsi/libsas.h +1 -2
@@ -87,10 +87,8 @@ enum discover_event {DISCE_DISCOVER_DOMAIN =0U ,DISCE_REVALIDATE_DOMAIN =1 ,DISCE_PORT_GONE =2 , -DISCE_PROBE =3 ,DISCE_SUSPEND =4 ,DISCE_RESUME =5 , -DISCE_DESTRUCT =6 , DISC_NUM_EVENTS = 7, };
@@ -269,6 +267,7 @@ struct asd_sas_port {struct list_head dev_list;struct list_head disco_list;struct list_head destroy_list; +struct list_head sas_port_del_list;enum sas_linkrate linkrate;struct sas_work work;
include/scsi/scsi_transport_sas.h +1 -0
@@ -156,6 +156,7 @@ struct sas_port {struct mutex phy_list_mutex;struct list_head phy_list; +struct list_head del_list;/* libsas only */ };#define dev_to_sas_port (d) \
Signature · 1 line
2.25.1
Re: [PATCH 4.14 01/51] scsi: libsas: direct call probe and destruct
Quoted 4 lines · Greg Kroah-Hartman
From: Jason Yan <[email protected]>
[ Upstream commit
0558f33c06bb910e2879e355192227a8e8f0219d]
Hi Greg,
This patch was one of a series from Jason to fix this WARN issue, below:
https://lore.kernel.org/linux-scsi/[email protected]/
I'm doubtful that it should be taken in isolation. Maybe 1 or 2 other patches are required.
The WARN was really annoying, so we could spend a bit of time to test a backport of what is strictly required. Let us know.
Thanks,
John
Quoted 65 lines
In commit
87c8331fcf72("[SCSI] libsas: prevent domain rediscovery competing with ata error handling") introduced disco mutex to prevent rediscovery competing with ata error handling and put the whole revalidation in the mutex. But the rphy add/remove needs to wait for the error handling which also grabs the disco mutex. This may leads to dead lock.So the probe and destruct event were introduce to do the rphy add/remove asynchronously and out of the lock.The asynchronously processed workers makes the whole discovery process not atomic, the other events may interrupt the process. For example, if a loss of signal event inserted before the probe event, the
sas_deform_port()is called and the port will be deleted.And
sas_port_delete()may run before the destruct event, but the port-x:x is the top parent of end device or expander. This leads to a kernel WARNING such as:[ 82.042979] sysfs group 'power' not found for kobject 'phy-1:0:22' [ 82.042983] ------------[ cut here ]------------ [ 82.042986] WARNING: CPU: 54 PID: 1714 at fs/sysfs/group.c:237 sysfs_remove_group+0x94/0xa0 [ 82.043059] Call trace: [ 82.043082] [<ffff0000082e7624>] sysfs_remove_group+0x94/0xa0 [ 82.043085] [<ffff00000864e320>] dpm_sysfs_remove+0x60/0x70 [ 82.043086] [<ffff00000863ee10>] device_del+0x138/0x308 [ 82.043089] [<ffff00000869a2d0>] sas_phy_delete+0x38/0x60 [ 82.043091] [<ffff00000869a86c>] do_sas_phy_delete+0x6c/0x80 [ 82.043093] [<ffff00000863dc20>] device_for_each_child+0x58/0xa0 [ 82.043095] [<ffff000008696f80>] sas_remove_children+0x40/0x50 [ 82.043100] [<ffff00000869d1bc>] sas_destruct_devices+0x64/0xa0 [ 82.043102] [<ffff0000080e93bc>] process_one_work+0x1fc/0x4b0 [ 82.043104] [<ffff0000080e96c0>] worker_thread+0x50/0x490 [ 82.043105] [<ffff0000080f0364>] kthread+0xfc/0x128 [ 82.043107] [<ffff0000080836c0>] ret_from_fork+0x10/0x50Make probe and destruct a direct call in the disco and revalidate function, but put them outside the lock. The whole discovery or revalidate won't be interrupted by other events. And the
DISCE_PROBEandDISCE_DESTRUCTevent are deleted as a result of the direct call.Introduce a new list to destruct the
sas_portand put the port delete after the destruct. This makes sure the right order of destroying the sysfs kobject and fix the warning above.In
sas_ex_revalidate_domain()have a loop to find all broadcasted device, and sometimes we have a chance to find the same expander twice. Because thesas_portwill be deleted at the end of the whole revalidate process,sas_portwith the same name cannot be added before this. Otherwise the sysfs will complain of creating duplicate filename. Since the LLDD will send broadcast for every device change, we can only process one expander's revalidation.[mkp: kbuild test robot warning]
Signed-off-by Jason Yan <[email protected]>CC John Garry <[email protected]>CC Johannes Thumshirn <[email protected]>CC Ewan Milne <[email protected]>CC Christoph Hellwig <[email protected]>CC Tomas Henzl <[email protected]>CC Dan Williams <[email protected]>Reviewed-by Hannes Reinecke <[email protected]>Signed-off-by Martin K. Petersen <[email protected]>Signed-off-by Sasha Levin <[email protected]>---
Greg Kroah-Hartman
maintainerRe: [PATCH 4.14 01/51] scsi: libsas: direct call probe and destruct
Quoted 10 lines · John Garry
Quoted 4 lines · Greg Kroah-Hartman
From: Jason Yan <[email protected]>
[ Upstream commit
0558f33c06bb910e2879e355192227a8e8f0219d]Hi Greg,
This patch was one of a series from Jason to fix this WARN issue, below:
Quoted 7 lines
https://lore.kernel.org/linux-scsi/[email protected]/
I'm doubtful that it should be taken in isolation. Maybe 1 or 2 other patches are required.
The WARN was really annoying, so we could spend a bit of time to test a backport of what is strictly required. Let us know.
Ok, I'll drop this for now, if you want to submit the patch series fully backported, we will be glad to review it.
thanks,
greg k-h
Greg Kroah-Hartman
maintainerPATCH 2/51 net: phy: mdio-bcm-unimac: fix potential NULL dereference in unimac_mdio_probe()
In reply to Greg Kroah-HartmanFrom: Wei Yongjun <[email protected]>
[ Upstream commit 297a6961ffb8ff4dc66c9fbf53b924bd1dda05d5 ]
platform_get_resource() may fail and return NULL, so we should better check it's return value to avoid a NULL pointer dereference a bit later in the code.
This is detected by Coccinelle semantic patch.
@@
expression pdev, res, n, t, e, e1, e2;
@@
res = platform_get_resource(pdev, t, n);
+ if (!res)
+ return -EINVAL;
... when != res == NULL
e = devm_ioremap(e1, res->start, e2);
--- drivers/net/phy/mdio-bcm-unimac.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/phy/mdio-bcm-unimac.c +2 -0
@@ -237,6 +237,8 @@ static int unimac_mdio_probe(struct platform_device *pdev)return -ENOMEM ; r =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!r) +return -EINVAL ;/* Just ioremap, as this MDIO block is usually integrated into an * Ethernet MAC controller register range
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 3/51 crypto: ccp - Release all allocated memory if sha type is invalid
In reply to Greg Kroah-HartmanFrom: Navid Emamdoost <[email protected]>
[ Upstream commit 128c66429247add5128c03dc1e144ca56f05a4e2 ]
Release all allocated memory if sha type is invalid:
In ccp_run_sha_cmd, if the type of sha is invalid, the allocated hmac_buf should be released.
v2: fix the goto.
--- drivers/crypto/ccp/ccp-ops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/crypto/ccp/ccp-ops.c +2 -1
@@ -1783,8 +1783,9 @@ ccp_run_sha_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) LSB_ITEM_SIZE);break ;default : +kfree (hmac_buf); ret = -EINVAL ; - goto e_ctx; + goto e_data; }memset (&hmac_cmd,0 ,sizeof (hmac_cmd));
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 4/51 media: rc: prevent memory leak in cx23888_ir_probe
In reply to Greg Kroah-HartmanFrom: Navid Emamdoost <[email protected]>
[ Upstream commit a7b2df76b42bdd026e3106cf2ba97db41345a177 ]
In cx23888_ir_probe if kfifo_alloc fails the allocated memory for state should be released.
--- drivers/media/pci/cx23885/cx23888-ir.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/pci/cx23885/cx23888-ir.c +4 -1
@@ -1178,8 +1178,11 @@ int cx23888_ir_probe(struct cx23885_dev *dev)return -ENOMEM ;spin_lock_init (&state->rx_kfifo_lock); -if (kfifo_alloc (&state->rx_kfifo,CX23888_IR_RX_KFIFO_SIZE ,GFP_KERNEL )) +if (kfifo_alloc (&state->rx_kfifo,CX23888_IR_RX_KFIFO_SIZE , +GFP_KERNEL )) { +kfree (state);return -ENOMEM ; + } state->dev = dev; sd = &state->sd;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 5/51 iio: imu: adis16400: fix memory leak
In reply to Greg Kroah-Hartman[ Upstream commit 9c0530e898f384c5d279bfcebd8bb17af1105873 ]
In adis_update_scan_mode_burst, if adis->buffer allocation fails release the adis->xfer.
--- drivers/iio/imu/adis16400_buffer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/iio/imu/adis16400_buffer.c +4 -1
@@ -38,8 +38,11 @@ int adis16400_update_scan_mode(struct iio_dev *indio_dev,return -ENOMEM ; adis->buffer =kzalloc (burst_length +sizeof (u16),GFP_KERNEL ); -if (!adis->buffer) +if (!adis->buffer) { +kfree (adis->xfer); + adis->xfer =NULL ;return -ENOMEM ; + } tx = adis->buffer + burst_length; tx[0 ] =ADIS_READ_REG (ADIS16400_GLOB_CMD );
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 6/51 ath9k_htc: release allocated buffer if timed out
In reply to Greg Kroah-HartmanFrom: Navid Emamdoost <[email protected]>
[ Upstream commit 853acf7caf10b828102d92d05b5c101666a6142b ]
In htc_config_pipe_credits, htc_setup_complete, and htc_connect_service if time out happens, the allocated buffer needs to be released. Otherwise there will be memory leak.
--- drivers/net/wireless/ath/ath9k/htc_hst.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/ath/ath9k/htc_hst.c +3 -0
@@ -173,6 +173,7 @@ static int htc_config_pipe_credits(struct htc_target *target) time_left =wait_for_completion_timeout (&target->cmd_wait,HZ );if (!time_left) {dev_err (target->dev,"HTC credit config timeout\n" ); +kfree_skb (skb);return -ETIMEDOUT ; }
@@ -208,6 +209,7 @@ static int htc_setup_complete(struct htc_target *target) time_left =wait_for_completion_timeout (&target->cmd_wait,HZ );if (!time_left) {dev_err (target->dev,"HTC start timeout\n" ); +kfree_skb (skb);return -ETIMEDOUT ; }
@@ -280,6 +282,7 @@ int htc_connect_service(struct htc_target *target,if (!time_left) {dev_err (target->dev,"Service connection timeout for: %d\n" , service_connreq->service_id); +kfree_skb (skb);return -ETIMEDOUT ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 7/51 ath9k: release allocated buffer if timed out
In reply to Greg Kroah-HartmanFrom: Navid Emamdoost <[email protected]>
[ Upstream commit 728c1e2a05e4b5fc52fab3421dce772a806612a2 ]
In ath9k_wmi_cmd, the allocated network buffer needs to be released if timeout happens. Otherwise memory will be leaked.
--- drivers/net/wireless/ath/ath9k/wmi.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/ath/ath9k/wmi.c +1 -0
@@ -338,6 +338,7 @@ int ath9k_wmi_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id,ath_dbg (common,WMI ,"Timeout waiting for WMI command: %s\n" ,wmi_cmd_to_name (cmd_id));mutex_unlock (&wmi->op_mutex); +kfree_skb (skb);return -ETIMEDOUT ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 8/51 x86/kvm: Be careful not to clear KVM_VCPU_FLUSH_TLB bit
In reply to Greg Kroah-Hartman[ Upstream commit 8c6de56a42e0c657955e12b882a81ef07d1d073e ]
kvm_steal_time_set_preempted() may accidentally clear KVM_VCPU_FLUSH_TLB bit if it is called more than once while VCPU is preempted.
This is part of CVE-2019-3016.
(This bug was also independently discovered by Jim Mattson <[email protected]>)
--- arch/x86/kvm/x86.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kvm/x86.c +3 -0
@@ -3075,6 +3075,9 @@ static void kvm_steal_time_set_preempted(struct kvm_vcpu *vcpu)if (!(vcpu->arch.st.msr_val &KVM_MSR_ENABLED ))return ; +if (vcpu->arch.st.steal.preempted) +return ; + vcpu->arch.st.steal.preempted =1 ; kvm_write_guest_offset_cached(vcpu->kvm, &vcpu->arch.st.stime,
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 9/51 PCI/ASPM: Disable ASPM on ASMedia ASM1083/1085 PCIe-to-PCI bridge
In reply to Greg Kroah-HartmanFrom: Robert Hancock <[email protected]>
commit b361663c5a40c8bc758b7f7f2239f7a192180e7c upstream.
Recently ASPM handling was changed to allow ASPM on PCIe-to-PCI/PCI-X bridges. Unfortunately the ASMedia ASM1083/1085 PCIe to PCI bridge device doesn't seem to function properly with ASPM enabled. On an Asus PRIME H270-PRO motherboard, it causes errors like these:
pcieport 0000:00:1c.0: AER: PCIe Bus Error: severity=Corrected, type=Data Link Layer, (Transmitter ID)
pcieport 0000:00:1c.0: AER: device [8086:a292] error status/mask=00003000/00002000
pcieport 0000:00:1c.0: AER: [12] Timeout
pcieport 0000:00:1c.0: AER: Corrected error received: 0000:00:1c.0
pcieport 0000:00:1c.0: AER: can't find device of ID00e0
In addition to flooding the kernel log, this also causes the machine to wake up immediately after suspend is initiated.
The device advertises ASPM L0s and L1 support in the Link Capabilities register, but the ASMedia web page for ASM1083 [1] claims "No PCIe ASPM support".
Windows 10 (build 2004) enables L0s, but it also logs correctable PCIe errors.
Add a quirk to disable ASPM for this device.
[1] https://www.asmedia.com.tw/eng/e_show_products.php?cate_index=169&item=114
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=208667
--- drivers/pci/quirks.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/pci/quirks.c +13 -0
@@ -2086,6 +2086,19 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INDECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_INTEL ,0x10f4 , quirk_disable_aspm_l0s);DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_INTEL ,0x1508 , quirk_disable_aspm_l0s); +static void quirk_disable_aspm_l0s_l1 (struct pci_dev *dev) +{ +pci_info (dev,"Disabling ASPM L0s/L1\n" ); +pci_disable_link_state (dev,PCIE_LINK_STATE_L0S |PCIE_LINK_STATE_L1 ); +} + +/* +* ASM1083/1085 PCIe-PCI bridge devices cause AER timeout errors on the +* upstream PCIe root port when ASPM is enabled. At least L0s mode is affected; +* disable both L0s and L1 for now to be safe. +*/ +DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_ASMEDIA ,0x1080 , quirk_disable_aspm_l0s_l1); +/* * Some Pericom PCIe-to-PCI bridges in reverse mode need the PCIe Retrain * Link bit cleared after starting the link retrain process to allow this
Greg Kroah-Hartman
maintainerPATCH 10/51 wireless: Use offsetof instead of custom macro.
In reply to Greg Kroah-HartmanFrom: Pi-Hsun Shih <[email protected]>
commit 6989310f5d4327e8595664954edd40a7f99ddd0d upstream.
Use offsetof to calculate offset of a field to take advantage of compiler built-in version when possible, and avoid UBSAN warning when compiling with Clang:
==================================================================
UBSAN: Undefined behaviour in net/wireless/wext-core.c:525:14 member access within null pointer of type 'struct iw_point' CPU: 3 PID: 165 Comm: kworker/u16:3 Tainted: G S W 4.19.23 #43 Workqueue: cfg80211 __cfg80211_scan_done [cfg80211] Call trace: dump_backtrace+0x0/0x194 show_stack+0x20/0x2c __dump_stack+0x20/0x28 dump_stack+0x70/0x94 ubsan_epilogue+0x14/0x44 ubsan_type_mismatch_common+0xf4/0xfc __ubsan_handle_type_mismatch_v1+0x34/0x54 wireless_send_event+0x3cc/0x470 ___cfg80211_scan_done+0x13c/0x220 [cfg80211] __cfg80211_scan_done+0x28/0x34 [cfg80211] process_one_work+0x170/0x35c worker_thread+0x254/0x380 kthread+0x13c/0x158 ret_from_fork+0x10/0x18 ===================================================================
--- include/uapi/linux/wireless.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
include/uapi/linux/wireless.h +3 -2
@@ -74,6 +74,8 @@#include <linux/socket.h> /* for "struct sockaddr" et al */ #include <linux/if.h> /* for IFNAMSIZ and co... */ +#include <stddef.h> /* for offsetof */ +/***************************** VERSION *****************************/ /* * This constant is used to know the availability of the wireless
@@ -1090,8 +1092,7 @@ struct iw_event {/* iw_point events are special. First, the payload (extra data) come at * the end of the event, so they are bigger than IW_EV_POINT_LEN. Second, * we omit the pointer, so start at an offset. */ -#define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \ - (char *) NULL) +#define IW_EV_POINT_OFF offsetof(struct iw_point, length)#define IW_EV_POINT_LEN (IW_EV_LCP_LEN + sizeof(struct iw_point) - \ IW_EV_POINT_OFF)
Greg Kroah-Hartman
maintainerPATCH 11/51 ARM: 8986/1: hw_breakpoint: Dont invoke overflow handler on uaccess watchpoints
In reply to Greg Kroah-HartmanFrom: Will Deacon <[email protected]>
commit eec13b42d41b0f3339dcf0c4da43734427c68620 upstream.
Unprivileged memory accesses generated by the so-called "translated" instructions (e.g. LDRT) in kernel mode can cause user watchpoints to fire unexpectedly. In such cases, the hw_breakpoint logic will invoke the user overflow handler which will typically raise a SIGTRAP back to the current task. This is futile when returning back to the kernel because (a) the signal won't have been delivered and (b) userspace can't handle the thing anyway.
Avoid invoking the user overflow handler for watchpoints triggered by kernel uaccess routines, and instead single-step over the faulting instruction as we would if no overflow handler had been installed.
--- arch/arm/kernel/hw_breakpoint.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-)
arch/arm/kernel/hw_breakpoint.c +22 -5
@@ -688,6 +688,12 @@ static void disable_single_step(struct parch_install_hw_breakpoint (bp); } +static int watchpoint_fault_on_uaccess (struct pt_regs *regs, +struct arch_hw_breakpoint *info) +{ +return !user_mode (regs) && info->ctrl.privilege ==ARM_BREAKPOINT_USER ; +} +static void watchpoint_handler (unsigned long addr,unsigned int fsr,struct pt_regs *regs) {
@@ -747,16 +753,27 @@ static void watchpoint_handler(unsigned }pr_debug ("watchpoint fired: address = 0x%x\n" , info->trigger); + +/* +* If we triggered a user watchpoint from a uaccess routine, +* then handle the stepping ourselves since userspace really +* can't help us with this. +*/ +if (watchpoint_fault_on_uaccess (regs, info)) + goto step; +perf_bp_event (wp, regs);/* -* If no overflow handler is present, insert a temporary -* mismatch breakpoint so we can single-step over the -* watchpoint trigger. +* Defer stepping to the overflow handler if one is installed. +* Otherwise, insert a temporary mismatch breakpoint so that +* we can single-step over the watchpoint trigger. */ -if (is_default_overflow_handler (wp)) -enable_single_step (wp,instruction_pointer (regs)); +if (!is_default_overflow_handler (wp)) + goto unlock; +step: +enable_single_step (wp,instruction_pointer (regs)); unlock:rcu_read_unlock (); }
Greg Kroah-Hartman
maintainerPATCH 12/51 random32: update the net random state on interrupt and activity
In reply to Greg Kroah-HartmanFrom: Willy Tarreau <[email protected]>
commit f227e3ec3b5cad859ad15666874405e8c1bbc1d4 upstream.
This modifies the first 32 bits out of the 128 bits of a random CPU's net_rand_state on interrupt or CPU activity to complicate remote observations that could lead to guessing the network RNG's internal state.
Note that depending on some network devices' interrupt rate moderation or binding, this re-seeding might happen on every packet or even almost never.
In addition, with NOHZ some CPUs might not even get timer interrupts, leaving their local state rarely updated, while they are running networked processes making use of the random state. For this reason, we also perform this update in update_process_times() in order to at least update the state when there is user or system activity, since it's the only case we care about.
--- drivers/char/random.c | 1 + include/linux/random.h | 3 +++ kernel/time/timer.c | 8 ++++++++ lib/random32.c | 2 +- 4 files changed, 13 insertions(+), 1 deletion(-)
drivers/char/random.c +1 -0
@@ -1246,6 +1246,7 @@ void add_interrupt_randomness(int irq, ifast_mix (fast_pool);add_interrupt_bench (cycles); +this_cpu_add (net_rand_state.s1, fast_pool->pool[cycles &3 ]);if (unlikely (crng_init ==0 )) { if ((fast_pool->count >= 64) &&
include/linux/random.h +3 -0
@@ -9,6 +9,7 @@#include <linux/list.h> #include <linux/once.h> +#include <linux/percpu.h> #include <uapi/linux/random.h>
@@ -116,6 +117,8 @@ struct rnd_state {__u32 s1, s2, s3, s4; }; +DECLARE_PER_CPU(struct rnd_state, net_rand_state) __latent_entropy; +u32 prandom_u32_state (struct rnd_state *state);void prandom_bytes_state (struct rnd_state *state,void *buf,size_t nbytes);void prandom_seed_full_state (struct rnd_state __percpu *pcpu_state);
kernel/time/timer.c +8 -0
@@ -44,6 +44,7 @@#include <linux/sched/debug.h> #include <linux/slab.h> #include <linux/compat.h> +#include <linux/random.h> #include <linux/uaccess.h> #include <asm/unistd.h>
@@ -1595,6 +1596,13 @@ void update_process_times(int user_tick)scheduler_tick ();if (IS_ENABLED (CONFIG_POSIX_TIMERS ))run_posix_cpu_timers (p); + +/* The current CPU might make use of net randoms without receiving IRQs +* to renew them often enough. Let's update the net_rand_state from a +* non-constant value that's not affine to the number of calls to make +* sure it's updated when there's some activity (we don't care in idle). +*/ +this_cpu_add (net_rand_state.s1,rol32 (jiffies,24 ) + user_tick); }/**
lib/random32.c +1 -1
@@ -48,7 +48,7 @@ static inline void prandom_state_selftes }#endif -static DEFINE_PER_CPU(struct rnd_state, net_rand_state) __latent_entropy; +DEFINE_PER_CPU(struct rnd_state, net_rand_state) __latent_entropy;/** * prandom_u32_state - seeded pseudo-random number generator.
Greg Kroah-Hartman
maintainerPATCH 13/51 ARM: percpu.h: fix build error
In reply to Greg Kroah-HartmanFrom: Grygorii Strashko <[email protected]>
commit aa54ea903abb02303bf55855fb51e3fcee135d70 upstream.
Fix build error for the case:
defined(CONFIG_SMP) && !defined(CONFIG_CPU_V6)
config: keystone_defconfig
CC arch/arm/kernel/signal.o
In file included from ../include/linux/random.h:14,
from ../arch/arm/kernel/signal.c:8:
../arch/arm/include/asm/percpu.h: In function ‘__my_cpu_offset’:
../arch/arm/include/asm/percpu.h:29:34: error: ‘current_stack_pointer’ undeclared (first use in this function); did you mean ‘user_stack_pointer’?
: "Q" (*(const unsigned long *)current_stack_pointer));
^~~~~~~~~~~~~~~~~~~~~
user_stack_pointer--- arch/arm/include/asm/percpu.h | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/include/asm/percpu.h +2 -0
@@ -16,6 +16,8 @@#ifndef _ASM_ARM_PERCPU_H_#define _ASM_ARM_PERCPU_H_ +#include <asm/thread_info.h> +/* * Same as asm-generic/percpu.h, except that we store the per cpu offset * in the TPIDRPRW. TPIDRPRW only exists on V6K and V7
Greg Kroah-Hartman
maintainerPATCH 14/51 drm/amdgpu: Prevent kernel-infoleak in amdgpu_info_ioctl()
In reply to Greg Kroah-HartmanFrom: Peilin Ye <[email protected]>
commit 543e8669ed9bfb30545fd52bc0e047ca4df7fb31 upstream.
Compiler leaves a 4-byte hole near the end of dev_info, causing amdgpu_info_ioctl() to copy uninitialized kernel stack memory to userspace when size is greater than 356.
In 2015 we tried to fix this issue by doing = {}; on dev_info, which unfortunately does not initialize that 4-byte hole. Fix it by using memset() instead.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +2 -1
@@ -527,8 +527,9 @@ static int amdgpu_info_ioctl(struct drm_return n ? -EFAULT :0 ; }case AMDGPU_INFO_DEV_INFO : { -struct drm_amdgpu_info_device dev_info = {}; +struct drm_amdgpu_info_device dev_info; +memset (&dev_info,0 ,sizeof (dev_info)); dev_info.device_id = dev->pdev->device; dev_info.chip_rev = adev->rev_id; dev_info.external_rev = adev->external_rev_id;
Greg Kroah-Hartman
maintainerPATCH 15/51 drm: hold gem reference until object is no longer accessed
In reply to Greg Kroah-HartmanFrom: Steve Cohen <[email protected]>
commit 8490d6a7e0a0a6fab5c2d82d57a3937306660864 upstream.
A use-after-free in drm_gem_open_ioctl can happen if the GEM object handle is closed between the idr lookup and retrieving the size from said object since a local reference is not being held at that point. Hold the local reference while the object can still be accessed to fix this and plug the potential security hole.
--- drivers/gpu/drm/drm_gem.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/gpu/drm/drm_gem.c +4 -6
@@ -730,9 +730,6 @@ err:* @file_priv: drm file-private structure * * Open an object using the global name, returning a handle and the size. -* -* This handle (of course) holds a reference to the object, so the object -* will not go away until the handle is deleted. */ int drm_gem_open_ioctl(struct drm_device *dev, void *data,
@@ -757,14 +754,15 @@ drm_gem_open_ioctl(struct drm_device *de/* drm_gem_handle_create_tail unlocks dev->object_name_lock. */ ret =drm_gem_handle_create_tail (file_priv, obj, &handle); -drm_gem_object_put_unlocked (obj);if (ret) -return ret; + goto err; args->handle = handle; args->size = obj->size; -return 0 ; +err: +drm_gem_object_put_unlocked (obj); +return ret; }/**
Greg Kroah-Hartman
maintainerPATCH 16/51 f2fs: check memory boundary by insane namelen
In reply to Greg Kroah-HartmanFrom: Jaegeuk Kim <[email protected]>
[ Upstream commit 4e240d1bab1ead280ddf5eb05058dba6bbd57d10 ]
If namelen is corrupted to have very long value, fill_dentries can copy wrong memory area.
--- fs/f2fs/dir.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
fs/f2fs/dir.c +10 -1
@@ -817,6 +817,16 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d, de_name.name = d->filename[bit_pos]; de_name.len =le16_to_cpu (de->name_len); +/* check memory boundary before moving forward */ + bit_pos +=GET_DENTRY_SLOTS (le16_to_cpu (de->name_len)); +if (unlikely (bit_pos > d->max)) { +f2fs_msg (F2FS_I_SB (d->inode)->sb,KERN_WARNING , +"%s: corrupted namelen=%d, run fsck to fix." , + __func__,le16_to_cpu (de->name_len)); +set_sbi_flag (F2FS_I_SB (d->inode)->sb->s_fs_info,SBI_NEED_FSCK ); +return -EINVAL ; + } +if (f2fs_encrypted_inode (d->inode)) {int save_len = fstr->len;int err;
@@ -835,7 +845,6 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d, le32_to_cpu(de->ino), d_type))return 1 ; - bit_pos +=GET_DENTRY_SLOTS (le16_to_cpu (de->name_len)); ctx->pos = start_pos + bit_pos; }return 0 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 17/51 f2fs: check if file namelen exceeds max value
In reply to Greg Kroah-HartmanFrom: Sheng Yong <[email protected]>
[ Upstream commit 720db068634c91553a8e1d9a0fcd8c7050e06d2b ]
Dentry bitmap is not enough to detect incorrect dentries. So this patch also checks the namelen value of a dentry.
--- fs/f2fs/dir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/dir.c +2 -1
@@ -819,7 +819,8 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,/* check memory boundary before moving forward */ bit_pos +=GET_DENTRY_SLOTS (le16_to_cpu (de->name_len)); -if (unlikely (bit_pos > d->max)) { +if (unlikely (bit_pos > d->max || +le16_to_cpu (de->name_len) >F2FS_NAME_LEN )) {f2fs_msg (F2FS_I_SB (d->inode)->sb,KERN_WARNING ,"%s: corrupted namelen=%d, run fsck to fix." , __func__,le16_to_cpu (de->name_len));
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 18/51 random: fix circular include dependency on arm64 after addition of percpu.h
In reply to Greg Kroah-HartmanFrom: Willy Tarreau <[email protected]>
commit 1c9df907da83812e4f33b59d3d142c864d9da57f upstream.
Daniel Díaz and Kees Cook independently reported that commit f227e3ec3b5c ("random32: update the net random state on interrupt and activity") broke arm64 due to a circular dependency on include files since the addition of percpu.h in random.h.
The correct fix would definitely be to move all the prandom32 stuff out of random.h but for backporting, a smaller solution is preferred.
This one replaces linux/percpu.h with asm/percpu.h, and this fixes the problem on x86_64, arm64, arm, and mips. Note that moving percpu.h around didn't change anything and that removing it entirely broke differently. When backporting, such options might still be considered if this patch fails to help.
[ It turns out that an alternate fix seems to be to just remove the
troublesome <asm/pointer_auth.h> remove from the arm64 <asm/smp.h> that causes the circular dependency.
But we might as well do the whole belt-and-suspenders thing, and minimize inclusion in <linux/random.h> too. Either will fix the
problem, and both are good changes. - Linus ]
--- include/linux/random.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/random.h +1 -1
@@ -9,7 +9,7 @@#include <linux/list.h> #include <linux/once.h> -#include <linux/percpu.h> +#include <asm/percpu.h> #include <uapi/linux/random.h>
Greg Kroah-Hartman
maintainerPATCH 19/51 random32: remove net_rand_state from the latent entropy gcc plugin
In reply to Greg Kroah-HartmanFrom: Linus Torvalds <[email protected]>
commit 83bdc7275e6206f560d247be856bceba3e1ed8f2 upstream.
It turns out that the plugin right now ends up being really unhappy about the change from 'static' to 'extern' storage that happened in commit f227e3ec3b5c ("random32: update the net random state on interrupt and activity").
This is probably a trivial fix for the latent_entropy plugin, but for now, just remove net_rand_state from the list of things the plugin worries about.
--- include/linux/random.h | 2 +- lib/random32.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/linux/random.h +1 -1
@@ -117,7 +117,7 @@ struct rnd_state {__u32 s1, s2, s3, s4; }; -DECLARE_PER_CPU(struct rnd_state, net_rand_state) __latent_entropy; +DECLARE_PER_CPU(struct rnd_state, net_rand_state);u32 prandom_u32_state (struct rnd_state *state);void prandom_bytes_state (struct rnd_state *state,void *buf,size_t nbytes);
lib/random32.c +1 -1
@@ -48,7 +48,7 @@ static inline void prandom_state_selftes }#endif -DEFINE_PER_CPU(struct rnd_state, net_rand_state) __latent_entropy; +DEFINE_PER_CPU(struct rnd_state, net_rand_state);/** * prandom_u32_state - seeded pseudo-random number generator.
Greg Kroah-Hartman
maintainerPATCH 20/51 9p/trans_fd: abort p9_read_work if req status changed
In reply to Greg Kroah-HartmanFrom: Dominique Martinet <[email protected]>
[ Upstream commit e4ca13f7d075e551dc158df6af18fb412a1dba0a ]
p9_read_work would try to handle an errored req even if it got put to error state by another thread between the lookup (that worked) and the time it had been fully read.
The request itself is safe to use because we hold a ref to it from the lookup (for m->rreq, so it was safe to read into the request data buffer until this point), but the req_list has been deleted at the same time status changed, and client_cb already has been called as well, so we should not do either.
--- net/9p/trans_fd.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
net/9p/trans_fd.c +11 -6
@@ -301,7 +301,6 @@ static void p9_read_work(struct work_struct *work) {int n, err;struct p9_conn *m; -int status =REQ_STATUS_ERROR ; m = container_of(work, struct p9_conn, rq);
@@ -381,11 +380,17 @@ static void p9_read_work(struct work_struct *work)if ((m->req) && (m->rc.offset == m->rc.capacity)) {p9_debug (P9_DEBUG_TRANS ,"got new packet\n" );spin_lock (&m->client->lock); -if (m->req->status !=REQ_STATUS_ERROR ) - status =REQ_STATUS_RCVD ; -list_del (&m->req->req_list); -/* update req->status while holding client->lock */ -p9_client_cb (m->client, m->req, status); +if (m->req->status ==REQ_STATUS_SENT ) { +list_del (&m->req->req_list); +p9_client_cb (m->client, m->req,REQ_STATUS_RCVD ); + }else { +spin_unlock (&m->client->lock); +p9_debug (P9_DEBUG_ERROR , +"Request tag %d errored out while we were reading the reply\n" , + m->rc.tag); + err = -EIO ; + goto error; + }spin_unlock (&m->client->lock); m->rc.sdata =NULL ; m->rc.offset =0 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 21/51 9p/trans_fd: Fix concurrency del of req_list in p9_fd_cancelled/p9_read_work
In reply to Greg Kroah-HartmanFrom: Wang Hai <[email protected]>
[ Upstream commit 74d6a5d5662975aed7f25952f62efbb6f6dadd29 ]
p9_read_work and p9_fd_cancelled may be called concurrently. In some cases, req->req_list may be deleted by both p9_read_work and p9_fd_cancelled.
We can fix it by ignoring replies associated with a cancelled request and ignoring cancelled request if message has been received before lock.
--- net/9p/trans_fd.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
net/9p/trans_fd.c +14 -1
@@ -383,6 +383,10 @@ static void p9_read_work(struct work_struct *work)if (m->req->status ==REQ_STATUS_SENT ) {list_del (&m->req->req_list);p9_client_cb (m->client, m->req,REQ_STATUS_RCVD ); + }else if (m->req->status ==REQ_STATUS_FLSHD ) { +/* Ignore replies associated with a cancelled request. */ +p9_debug (P9_DEBUG_TRANS , +"Ignore replies associated with a cancelled request\n" ); }else {spin_unlock (&m->client->lock); p9_debug(P9_DEBUG_ERROR,
@@ -717,11 +721,20 @@ static int p9_fd_cancelled(struct p9_client *client, struct p9_req_t *req) {p9_debug (P9_DEBUG_TRANS ,"client %p req %p\n" , client, req); +spin_lock (&client->lock); +/* Ignore cancelled request if message has been received +* before lock. +*/ +if (req->status ==REQ_STATUS_RCVD ) { +spin_unlock (&client->lock); +return 0 ; + } +/* we haven't received a response for oldreq, * remove it from the list. */ -spin_lock (&client->lock);list_del (&req->req_list); + req->status =REQ_STATUS_FLSHD ;spin_unlock (&client->lock);return 0 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 22/51 x86/build/lto: Fix truncated .bss with -fdata-sections
In reply to Greg Kroah-HartmanFrom: Sami Tolvanen <[email protected]>
[ Upstream commit 6a03469a1edc94da52b65478f1e00837add869a3 ]
With CONFIG_LD_DEAD_CODE_DATA_ELIMINATION=y, we compile the kernel with -fdata-sections, which also splits the .bss section.
The new section, with a new .bss.* name, which pattern gets missed by the main x86 linker script which only expects the '.bss' name. This results in the discarding of the second part and a too small, truncated .bss section and an unhappy, non-working kernel.
Use the common BSS_MAIN macro in the linker script to properly capture and merge all the generated BSS sections.
--- arch/x86/kernel/vmlinux.lds.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/vmlinux.lds.S +1 -1
@@ -352,7 +352,7 @@ SECTIONS .bss : AT(ADDR(.bss) - LOAD_OFFSET) { __bss_start = .; *(.bss..page_aligned) - *(.bss) + *(BSS_MAIN) . = ALIGN(PAGE_SIZE); __bss_stop = .; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 23/51 x86, vmlinux.lds: Page-align end of ..page_aligned sections
In reply to Greg Kroah-HartmanFrom: Joerg Roedel <[email protected]>
[ Upstream commit de2b41be8fcccb2f5b6c480d35df590476344201 ]
On x86-32 the idt_table with 256 entries needs only 2048 bytes. It is page-aligned, but the end of the .bss..page_aligned section is not guaranteed to be page-aligned.
As a result, objects from other .bss sections may end up on the same 4k page as the idt_table, and will accidentially get mapped read-only during boot, causing unexpected page-faults when the kernel writes to them.
This could be worked around by making the objects in the page aligned sections page sized, but that's wrong.
Explicit sections which store only page aligned objects have an implicit guarantee that the object is alone in the page in which it is placed. That works for all objects except the last one. That's inconsistent.
Enforcing page sized objects for these sections would wreckage memory sanitizers, because the object becomes artificially larger than it should be and out of bound access becomes legit.
Align the end of the .bss..page_aligned and .data..page_aligned section on page-size so all objects places in these sections are guaranteed to have their own page.
[ tglx: Amended changelog ]
--- arch/x86/kernel/vmlinux.lds.S | 1 + include/asm-generic/vmlinux.lds.h | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-)
arch/x86/kernel/vmlinux.lds.S +1 -0
@@ -352,6 +352,7 @@ SECTIONS .bss : AT(ADDR(.bss) - LOAD_OFFSET) { __bss_start = .; *(.bss..page_aligned) + . = ALIGN(PAGE_SIZE); *(BSS_MAIN) . = ALIGN(PAGE_SIZE); __bss_stop = .;
include/asm-generic/vmlinux.lds.h +4 -1
@@ -251,7 +251,8 @@#define PAGE_ALIGNED_DATA (page_align) \ . = ALIGN(page_align); \ - *(.data..page_aligned) + *(.data..page_aligned) \ + . = ALIGN(page_align);#define READ_MOSTLY_DATA (align) \ . = ALIGN(align); \
@@ -619,7 +620,9 @@ . = ALIGN(bss_align); \ .bss : AT(ADDR(.bss) - LOAD_OFFSET) { \BSS_FIRST_SECTIONS \ + . = ALIGN(PAGE_SIZE); \ *(.bss..page_aligned) \ + . = ALIGN(PAGE_SIZE); \ *(.dynbss) \ *(BSS_MAIN ) \ *(COMMON ) \
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 24/51 rds: Prevent kernel-infoleak in rds_notify_queue_get()
In reply to Greg Kroah-HartmanFrom: Peilin Ye <[email protected]>
commit bbc8a99e952226c585ac17477a85ef1194501762 upstream.
rds_notify_queue_get() is potentially copying uninitialized kernel stack memory to userspace since the compiler may leave a 4-byte hole at the end of cmsg.
In 2016 we tried to fix this issue by doing = { 0 }; on cmsg, which unfortunately does not always initialize that 4-byte hole. Fix it by using memset() instead.
--- net/rds/recv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/rds/recv.c +2 -1
@@ -453,12 +453,13 @@ static int rds_still_queued(struct rds_sint rds_notify_queue_get (struct rds_sock *rs,struct msghdr *msghdr) {struct rds_notifier *notifier; -struct rds_rdma_notify cmsg = {0 };/* fill holes with zero */ +struct rds_rdma_notify cmsg;unsigned int count =0 , max_messages = ~0U ;unsigned long flags;LIST_HEAD (copy);int err =0 ; +memset (&cmsg,0 ,sizeof (cmsg));/* fill holes with zero */ /* put_cmsg copies to user space and thus may sleep. We can't do this * with rs_lock held, so first grab as many notifications as we can stuff
Greg Kroah-Hartman
maintainerPATCH 25/51 xfs: fix missed wakeup on l_flush_wait
In reply to Greg Kroah-HartmanFrom: Rik van Riel <[email protected]>
commit cdea5459ce263fbc963657a7736762ae897a8ae6 upstream.
The code in xlog_wait uses the spinlock to make adding the task to the wait queue, and setting the task state to UNINTERRUPTIBLE atomic with respect to the waker.
Doing the wakeup after releasing the spinlock opens up the following race condition:
Task 1 task 2
add task to wait queue
wake up task
set task state to UNINTERRUPTIBLE
This issue was found through code inspection as a result of kworkers being observed stuck in UNINTERRUPTIBLE state with an empty wait queue. It is rare and largely unreproducable.
Simply moving the spin_unlock to after the wake_up_all results in the waker not being able to see a task on the waitqueue before it has set its state to UNINTERRUPTIBLE.
This bug dates back to the conversion of this code to generic waitqueue infrastructure from a counting semaphore back in 2008 which didn't place the wakeups consistently w.r.t. to the relevant spin locks.
[dchinner: Also fix a similar issue in the shutdown path on xc_commit_wait. Update commit log with more details of the issue.]
--- fs/xfs/xfs_log.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
fs/xfs/xfs_log.c +4 -5
@@ -2684,7 +2684,6 @@ xlog_state_do_callback(int funcdidcallbacks;/* flag: function did callbacks */ int repeats;/* for issuing console warnings if * looping too many times */ -int wake =0 ;spin_lock (&log->l_icloglock); first_iclog = iclog = log->l_iclog;
@@ -2886,11 +2885,9 @@ xlog_state_do_callback(#endif if (log->l_iclog->ic_state & (XLOG_STATE_ACTIVE |XLOG_STATE_IOERROR )) - wake =1 ; -spin_unlock (&log->l_icloglock); - -if (wake)wake_up_all (&log->l_flush_wait); + +spin_unlock (&log->l_icloglock); }
@@ -4052,7 +4049,9 @@ xfs_log_force_umount(* item committed callback functions will do this again under lock to * avoid races. */ +spin_lock (&log->l_cilp->xc_push_lock);wake_up_all (&log->l_cilp->xc_commit_wait); +spin_unlock (&log->l_cilp->xc_push_lock);xlog_state_do_callback (log,XFS_LI_ABORTED ,NULL );#ifdef XFSERRORDEBUG
Greg Kroah-Hartman
maintainerPATCH 26/51 net/x25: Fix x25_neigh refcnt leak when x25 disconnect
In reply to Greg Kroah-HartmanFrom: Xiyu Yang <[email protected]>
commit 4becb7ee5b3d2829ed7b9261a245a77d5b7de902 upstream.
x25_connect() invokes x25_get_neigh(), which returns a reference of the specified x25_neigh object to "x25->neighbour" with increased refcnt.
When x25 connect success and returns, the reference still be hold by "x25->neighbour", so the refcount should be decreased in x25_disconnect() to keep refcount balanced.
The reference counting issue happens in x25_disconnect(), which forgets to decrease the refcnt increased by x25_get_neigh() in x25_connect(), causing a refcnt leak.
Fix this issue by calling x25_neigh_put() before x25_disconnect() returns.
--- net/x25/x25_subr.c | 4 ++++ 1 file changed, 4 insertions(+)
net/x25/x25_subr.c +4 -0
@@ -363,6 +363,10 @@ void x25_disconnect(struct sock *sk, int sk->sk_state_change (sk);sock_set_flag (sk,SOCK_DEAD ); } +read_lock_bh (&x25_list_lock); +x25_neigh_put (x25->neighbour); + x25->neighbour =NULL ; +read_unlock_bh (&x25_list_lock); }/*
Greg Kroah-Hartman
maintainerPATCH 27/51 net/x25: Fix null-ptr-deref in x25_disconnect
In reply to Greg Kroah-HartmanFrom: YueHaibing <[email protected]>
commit 8999dc89497ab1c80d0718828e838c7cd5f6bffe upstream.
We should check null before do x25_neigh_put in x25_disconnect, otherwise may cause null-ptr-deref like this:
#include <sys/socket.h>
#include <linux/x25.h>
int main() {
int sck_x25;
sck_x25 = socket(AF_X25, SOCK_SEQPACKET, 0);
close(sck_x25);
return 0;}
BUG: kernel NULL pointer dereference, address: 00000000000000d8 CPU: 0 PID: 4817 Comm: t2 Not tainted 5.7.0-rc3+ #159 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.9.3- RIP: 0010:x25_disconnect+0x91/0xe0 Call Trace: x25_release+0x18a/0x1b0 __sock_release+0x3d/0xc0 sock_close+0x13/0x20 __fput+0x107/0x270 ____fput+0x9/0x10 task_work_run+0x6d/0xb0 exit_to_usermode_loop+0x102/0x110 do_syscall_64+0x23c/0x260 entry_SYSCALL_64_after_hwframe+0x49/0xb3
--- net/x25/x25_subr.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
net/x25/x25_subr.c +6 -4
@@ -363,10 +363,12 @@ void x25_disconnect(struct sock *sk, int sk->sk_state_change (sk);sock_set_flag (sk,SOCK_DEAD ); } -read_lock_bh (&x25_list_lock); -x25_neigh_put (x25->neighbour); - x25->neighbour =NULL ; -read_unlock_bh (&x25_list_lock); +if (x25->neighbour) { +read_lock_bh (&x25_list_lock); +x25_neigh_put (x25->neighbour); + x25->neighbour =NULL ; +read_unlock_bh (&x25_list_lock); + } }/*
Greg Kroah-Hartman
maintainerPATCH 28/51 selftests/net: rxtimestamp: fix clang issues for target arch PowerPC
In reply to Greg Kroah-HartmanFrom: Tanner Love <[email protected]>
[ Upstream commit 955cbe91bcf782c09afe369c95a20f0a4b6dcc3c ]
The signedness of char is implementation-dependent. Some systems (including PowerPC and ARM) use unsigned char. Clang 9 threw:
warning: result of comparison of constant -1 with expression of type \
'char' is always true [-Wtautological-constant-out-of-range-compare]
&arg_index)) != -1) {Tested: make -C tools/testing/selftests TARGETS="net" run_tests
--- tools/testing/selftests/networking/timestamping/rxtimestamp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
tools/testing/selftests/networking/timestamping/rxtimestamp.c +1 -2
@@ -328,8 +328,7 @@ int main(int argc, char **argv)bool all_tests = true;int arg_index =0 ;int failures =0 ; -int s, t; -char opt; +int s, t, opt;while ((opt =getopt_long (argc, argv,"" , long_options, &arg_index)) !=-1 ) {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 29/51 sh: Fix validation of system call number
In reply to Greg Kroah-HartmanFrom: Michael Karcher <[email protected]>
[ Upstream commit 04a8a3d0a73f51c7c2da84f494db7ec1df230e69 ]
The slow path for traced system call entries accessed a wrong memory location to get the number of the maximum allowed system call number. Renumber the numbered "local" label for the correct location to avoid collisions with actual local labels.
--- arch/sh/kernel/entry-common.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/sh/kernel/entry-common.S +3 -3
@@ -203,7 +203,7 @@ syscall_trace_entry: mov.l @(OFF_R7,r15), r7 ! arg3 mov.l @(OFF_R3,r15), r3 ! syscall_nr ! - mov.l 2f, r10 ! Number of syscalls + mov.l 6f, r10 ! Number of syscalls cmp/hs r10, r3 bf syscall_call mov #-ENOSYS, r0
@@ -357,7 +357,7 @@ ENTRY(system_call) tst r9, r8 bf syscall_trace_entry ! - mov.l 2f, r8 ! Number of syscalls + mov.l 6f, r8 ! Number of syscalls cmp/hs r8, r3 bt syscall_badsys !
@@ -396,7 +396,7 @@ syscall_exit: #if !defined(CONFIG_CPU_SH2) 1: .long TRA #endif -2: .long NR_syscalls +6: .long NR_syscalls 3: .long sys_call_table 7: .long do_syscall_trace_enter 8: .long do_syscall_trace_leave
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 30/51 net: lan78xx: add missing endpoint sanity check
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit 8d8e95fd6d69d774013f51e5f2ee10c6e6d1fc14 ]
Add the missing endpoint sanity check to prevent a NULL-pointer dereference should a malicious device lack the expected endpoints.
Note that the driver has a broken endpoint-lookup helper, lan78xx_get_endpoints(), which can end up accepting interfaces in an altsetting without endpoints as long as *some* altsetting has a bulk-in and a bulk-out endpoint.
--- drivers/net/usb/lan78xx.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/usb/lan78xx.c +5 -0
@@ -3629,6 +3629,11 @@ static int lan78xx_probe(struct usb_interface *intf, netdev->max_mtu =MAX_SINGLE_PACKET_SIZE ;netif_set_gso_max_size (netdev,MAX_SINGLE_PACKET_SIZE -MAX_HEADER ); +if (intf->cur_altsetting->desc.bNumEndpoints <3 ) { + ret = -ENODEV ; + goto out3; + } + dev->ep_blkin = (intf->cur_altsetting)->endpoint +0 ; dev->ep_blkout = (intf->cur_altsetting)->endpoint +1 ; dev->ep_intr = (intf->cur_altsetting)->endpoint +2 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 31/51 net: lan78xx: fix transfer-buffer memory leak
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit 63634aa679ba8b5e306ad0727120309ae6ba8a8e ]
The interrupt URB transfer-buffer was never freed on disconnect or after probe errors.
--- drivers/net/usb/lan78xx.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/usb/lan78xx.c +1 -0
@@ -3658,6 +3658,7 @@ static int lan78xx_probe(struct usb_interface *intf,usb_fill_int_urb (dev->urb_intr, dev->udev, dev->pipe_intr, buf, maxp, intr_complete, dev, period); + dev->urb_intr->transfer_flags |=URB_FREE_BUFFER ; } }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 32/51 mlx4: disable device on shutdown
In reply to Greg Kroah-HartmanFrom: Jakub Kicinski <[email protected]>
[ Upstream commit 3cab8c65525920f00d8f4997b3e9bb73aecb3a8e ]
It appears that not disabling a PCI device on .shutdown may lead to a Hardware Error with particular (perhaps buggy) BIOS versions:
mlx4_en: eth0: Close port called
mlx4_en 0000:04:00.0: removed PHC
reboot: Restarting system
{1}[Hardware Error]: Hardware error from APEI Generic Hardware Error Source: 1
{1}[Hardware Error]: event severity: fatal
{1}[Hardware Error]: Error 0, type: fatal
{1}[Hardware Error]: section_type: PCIe error
{1}[Hardware Error]: port_type: 4, root port
{1}[Hardware Error]: version: 1.16
{1}[Hardware Error]: command: 0x4010, status: 0x0143
{1}[Hardware Error]: device_id: 0000:00:02.2
{1}[Hardware Error]: slot: 0
{1}[Hardware Error]: secondary_bus: 0x04
{1}[Hardware Error]: vendor_id: 0x8086, device_id: 0x2f06
{1}[Hardware Error]: class_code: 000604
{1}[Hardware Error]: bridge: secondary_status: 0x2000, control: 0x0003
{1}[Hardware Error]: aer_uncor_status: 0x00100000, aer_uncor_mask: 0x00000000
{1}[Hardware Error]: aer_uncor_severity: 0x00062030
{1}[Hardware Error]: TLP Header: 40000018 040000ff 791f4080 00000000
[hw error repeats]
Kernel panic - not syncing: Fatal hardware error!
CPU: 0 PID: 2189 Comm: reboot Kdump: loaded Not tainted 5.6.x-blabla #1
Hardware name: HP ProLiant DL380 Gen9/ProLiant DL380 Gen9, BIOS P89 05/05/2017Fix the mlx4 driver.
This is a very similar problem to what had been fixed in:
commit 0d98ba8d70b0 ("scsi: hpsa: disable device during shutdown") to address https://bugzilla.kernel.org/show_bug.cgi?id=199779.
--- drivers/net/ethernet/mellanox/mlx4/main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/mellanox/mlx4/main.c +2 -0
@@ -4190,12 +4190,14 @@ end:static void mlx4_shutdown (struct pci_dev *pdev) {struct mlx4_dev_persistent *persist =pci_get_drvdata (pdev); +struct mlx4_dev *dev = persist->dev;mlx4_info (persist->dev,"mlx4_shutdown was called\n" );mutex_lock (&persist->interface_state_mutex);if (persist->interface_state &MLX4_INTERFACE_STATE_UP )mlx4_unload_one (pdev);mutex_unlock (&persist->interface_state_mutex); +mlx4_pci_disable_device (dev); }static const struct pci_error_handlers mlx4_err_handler = {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 33/51 mlxsw: core: Increase scope of RCU read-side critical section
In reply to Greg Kroah-HartmanFrom: Ido Schimmel <[email protected]>
[ Upstream commit 7d8e8f3433dc8d1dc87c1aabe73a154978fb4c4d ]
The lifetime of the Rx listener item ('rxl_item') is managed using RCU, but is dereferenced outside of RCU read-side critical section, which can lead to a use-after-free.
Fix this by increasing the scope of the RCU read-side critical section.
--- drivers/net/ethernet/mellanox/mlxsw/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/core.c +4 -2
@@ -1574,11 +1574,13 @@ void mlxsw_core_skb_receive(struct mlxsw_core *mlxsw_core, struct sk_buff *skb,break ; } } -rcu_read_unlock (); -if (!found) +if (!found) { +rcu_read_unlock (); goto drop; + } rxl->func (skb, local_port, rxl_item->priv); +rcu_read_unlock ();return ; drop:
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 34/51 mlxsw: core: Free EMAD transactions using kfree_rcu()
In reply to Greg Kroah-HartmanFrom: Ido Schimmel <[email protected]>
[ Upstream commit 3c8ce24b037648a5a15b85888b259a74b05ff97d ]
The lifetime of EMAD transactions (i.e., 'struct mlxsw_reg_trans') is managed using RCU. They are freed using kfree_rcu() once the transaction ends.
However, in case the transaction failed it is freed immediately after being removed from the active transactions list. This is problematic because it is still possible for a different CPU to dereference the transaction from an RCU read-side critical section while traversing the active transaction list in mlxsw_emad_rx_listener_func(). In which case, a use-after-free is triggered [1].
Fix this by freeing the transaction after a grace period by calling kfree_rcu().
[1]
BUG: KASAN: use-after-free in mlxsw_emad_rx_listener_func+0x969/0xac0 drivers/net/ethernet/mellanox/mlxsw/core.c:671
Read of size 8 at addr ffff88800b7964e8 by task syz-executor.2/2881
CPU: 0 PID: 2881 Comm: syz-executor.2 Not tainted 5.8.0-rc4+ #44
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014
Call Trace:
<IRQ>
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0xf6/0x16e lib/dump_stack.c:118
print_address_description.constprop.0+0x1c/0x250 mm/kasan/report.c:383
__kasan_report mm/kasan/report.c:513 [inline]
kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530
mlxsw_emad_rx_listener_func+0x969/0xac0 drivers/net/ethernet/mellanox/mlxsw/core.c:671
mlxsw_core_skb_receive+0x571/0x700 drivers/net/ethernet/mellanox/mlxsw/core.c:2061
mlxsw_pci_cqe_rdq_handle drivers/net/ethernet/mellanox/mlxsw/pci.c:595 [inline]
mlxsw_pci_cq_tasklet+0x12a6/0x2520 drivers/net/ethernet/mellanox/mlxsw/pci.c:651
tasklet_action_common.isra.0+0x13f/0x3e0 kernel/softirq.c:550
__do_softirq+0x223/0x964 kernel/softirq.c:292
asm_call_on_stack+0x12/0x20 arch/x86/entry/entry_64.S:711
</IRQ>
__run_on_irqstack arch/x86/include/asm/irq_stack.h:22 [inline]
run_on_irqstack_cond arch/x86/include/asm/irq_stack.h:48 [inline]
do_softirq_own_stack+0x109/0x140 arch/x86/kernel/irq_64.c:77
invoke_softirq kernel/softirq.c:387 [inline]
__irq_exit_rcu kernel/softirq.c:417 [inline]
irq_exit_rcu+0x16f/0x1a0 kernel/softirq.c:429
sysvec_apic_timer_interrupt+0x4e/0xd0 arch/x86/kernel/apic/apic.c:1091
asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:587
RIP: 0010:arch_local_irq_restore arch/x86/include/asm/irqflags.h:85 [inline]
RIP: 0010:__raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:160 [inline]
RIP: 0010:_raw_spin_unlock_irqrestore+0x3b/0x40 kernel/locking/spinlock.c:191
Code: e8 2a c3 f4 fc 48 89 ef e8 12 96 f5 fc f6 c7 02 75 11 53 9d e8 d6 db 11 fd 65 ff 0d 1f 21 b3 56 5b 5d c3 e8 a7 d7 11 fd 53 9d <eb> ed 0f 1f 00 55 48 89 fd 65 ff 05 05 21 b3 56 ff 74 24 08 48 8d
RSP: 0018:ffff8880446ffd80 EFLAGS: 00000286
RAX: 0000000000000006 RBX: 0000000000000286 RCX: 0000000000000006
RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffffffa94ecea9
RBP: ffff888012934408 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000001 R11: fffffbfff57be301 R12: 1ffff110088dffc1
R13: ffff888037b817c0 R14: ffff88802442415a R15: ffff888024424000
__do_sys_perf_event_open+0x1b5d/0x2bd0 kernel/events/core.c:11874
do_syscall_64+0x56/0xa0 arch/x86/entry/common.c:384
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x473dbd
Code: Bad RIP value.
RSP: 002b:00007f21e5e9cc28 EFLAGS: 00000246 ORIG_RAX: 000000000000012a
RAX: ffffffffffffffda RBX: 000000000057bf00 RCX: 0000000000473dbd
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000020000040
RBP: 000000000057bf00 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000003 R11: 0000000000000246 R12: 000000000057bf0c
R13: 00007ffd0493503f R14: 00000000004d0f46 R15: 00007f21e5e9cd80
Allocated by task 871:
save_stack+0x1b/0x40 mm/kasan/common.c:48
set_track mm/kasan/common.c:56 [inline]
__kasan_kmalloc mm/kasan/common.c:494 [inline]
__kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:467
kmalloc include/linux/slab.h:555 [inline]
kzalloc include/linux/slab.h:669 [inline]
mlxsw_core_reg_access_emad+0x70/0x1410 drivers/net/ethernet/mellanox/mlxsw/core.c:1812
mlxsw_core_reg_access+0xeb/0x540 drivers/net/ethernet/mellanox/mlxsw/core.c:1991
mlxsw_sp_port_get_hw_xstats+0x335/0x7e0 drivers/net/ethernet/mellanox/mlxsw/spectrum.c:1130
update_stats_cache+0xf4/0x140 drivers/net/ethernet/mellanox/mlxsw/spectrum.c:1173
process_one_work+0xa3e/0x17a0 kernel/workqueue.c:2269
worker_thread+0x9e/0x1050 kernel/workqueue.c:2415
kthread+0x355/0x470 kernel/kthread.c:291
ret_from_fork+0x22/0x30 arch/x86/entry/entry_64.S:293
Freed by task 871:
save_stack+0x1b/0x40 mm/kasan/common.c:48
set_track mm/kasan/common.c:56 [inline]
kasan_set_free_info mm/kasan/common.c:316 [inline]
__kasan_slab_free+0x12c/0x170 mm/kasan/common.c:455
slab_free_hook mm/slub.c:1474 [inline]
slab_free_freelist_hook mm/slub.c:1507 [inline]
slab_free mm/slub.c:3072 [inline]
kfree+0xe6/0x320 mm/slub.c:4052
mlxsw_core_reg_access_emad+0xd45/0x1410 drivers/net/ethernet/mellanox/mlxsw/core.c:1819
mlxsw_core_reg_access+0xeb/0x540 drivers/net/ethernet/mellanox/mlxsw/core.c:1991
mlxsw_sp_port_get_hw_xstats+0x335/0x7e0 drivers/net/ethernet/mellanox/mlxsw/spectrum.c:1130
update_stats_cache+0xf4/0x140 drivers/net/ethernet/mellanox/mlxsw/spectrum.c:1173
process_one_work+0xa3e/0x17a0 kernel/workqueue.c:2269
worker_thread+0x9e/0x1050 kernel/workqueue.c:2415
kthread+0x355/0x470 kernel/kthread.c:291
ret_from_fork+0x22/0x30 arch/x86/entry/entry_64.S:293
The buggy address belongs to the object at ffff88800b796400
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 232 bytes inside of
512-byte region [ffff88800b796400, ffff88800b796600)
The buggy address belongs to the page:
page:ffffea00002de500 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 head:ffffea00002de500 order:2 compound_mapcount:0 compound_pincount:0
flags: 0x100000000010200(slab|head)
raw: 0100000000010200 dead000000000100 dead000000000122 ffff88806c402500
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88800b796380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88800b796400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88800b796480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88800b796500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88800b796580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb--- drivers/net/ethernet/mellanox/mlxsw/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/core.c +1 -1
@@ -1361,7 +1361,7 @@ static int mlxsw_core_reg_access_emad(struct mlxsw_core *mlxsw_core, err =mlxsw_emad_reg_access (mlxsw_core, reg, payload, type, trans, bulk_list, cb, cb_priv, tid);if (err) { -kfree (trans); +kfree_rcu (trans, rcu);return err; }return 0 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 35/51 ibmvnic: Fix IRQ mapping disposal in error path
In reply to Greg Kroah-HartmanFrom: Thomas Falcon <[email protected]>
[ Upstream commit 27a2145d6f826d1fad9de06ac541b1016ced3427 ]
RX queue IRQ mappings are disposed in both the TX IRQ and RX IRQ error paths. Fix this and dispose of TX IRQ mappings correctly in case of an error.
--- drivers/net/ethernet/ibm/ibmvnic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/ibm/ibmvnic.c +1 -1
@@ -2324,7 +2324,7 @@ req_rx_irq_failed: req_tx_irq_failed:for (j =0 ; j < i; j++) {free_irq (adapter->tx_scrq[j]->irq, adapter->tx_scrq[j]); -irq_dispose_mapping (adapter->rx_scrq[j]->irq); +irq_dispose_mapping (adapter->tx_scrq[j]->irq); }release_sub_crqs (adapter);return rc;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 36/51 bpf: Fix map leak in HASH_OF_MAPS map
In reply to Greg Kroah-HartmanFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit 1d4e1eab456e1ee92a94987499b211db05f900ea ]
Fix HASH_OF_MAPS bug of not putting inner map pointer on bpf_map_elem_update() operation. This is due to per-cpu extra_elems optimization, which bypassed free_htab_elem() logic doing proper clean ups. Make sure that inner map is put properly in optimized case as well.
--- kernel/bpf/hashtab.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
kernel/bpf/hashtab.c +9 -3
@@ -656,15 +656,20 @@ static void htab_elem_free_rcu(struct rcu_head *head)preempt_enable (); } -static void free_htab_elem (struct bpf_htab *htab,struct htab_elem *l) +static void htab_put_fd_value (struct bpf_htab *htab,struct htab_elem *l) {struct bpf_map *map = &htab->map; +void *ptr;if (map->ops->map_fd_put_ptr) { -void *ptr =fd_htab_map_get_ptr (map, l); - + ptr =fd_htab_map_get_ptr (map, l); map->ops->map_fd_put_ptr (ptr); } +} + +static void free_htab_elem (struct bpf_htab *htab,struct htab_elem *l) +{ +htab_put_fd_value (htab, l);if (htab_is_prealloc (htab)) {__pcpu_freelist_push (&htab->freelist, &l->fnode);
@@ -725,6 +730,7 @@ static struct htab_elem *alloc_htab_elem(struct bpf_htab *htab, void *key,*/ pl_new =this_cpu_ptr (htab->extra_elems); l_new = *pl_new; +htab_put_fd_value (htab, old_elem); *pl_new = old_elem; }else {struct pcpu_freelist_node *l;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 37/51 mac80211: mesh: Free ie data when leaving mesh
In reply to Greg Kroah-HartmanFrom: Remi Pommarel <[email protected]>
[ Upstream commit 6a01afcf8468d3ca2bd8bbb27503f60dcf643b20 ]
At ieee80211_join_mesh() some ie data could have been allocated (see copy_mesh_setup()) and need to be cleaned up when leaving the mesh.
This fixes the following kmemleak report:
unreferenced object 0xffff0000116bc600 (size 128):
comm "wpa_supplicant", pid 608, jiffies 4294898983 (age 293.484s) hex dump (first 32 bytes):
30 14 01 00 00 0f ac 04 01 00 00 0f ac 04 01 00 0...............
00 0f ac 08 00 00 00 00 c4 65 40 00 00 00 00 00 .........e@.....
backtrace:
[<00000000bebe439d>] __kmalloc_track_caller+0x1c0/0x330
[<00000000a349dbe1>] kmemdup+0x28/0x50
[<0000000075d69baa>] ieee80211_join_mesh+0x6c/0x3b8 [mac80211]
[<00000000683bb98b>] __cfg80211_join_mesh+0x1e8/0x4f0 [cfg80211]
[<0000000072cb507f>] nl80211_join_mesh+0x520/0x6b8 [cfg80211]
[<0000000077e9bcf9>] genl_family_rcv_msg+0x374/0x680
[<00000000b1bd936d>] genl_rcv_msg+0x78/0x108
[<0000000022c53788>] netlink_rcv_skb+0xb0/0x1c0
[<0000000011af8ec9>] genl_rcv+0x34/0x48
[<0000000069e41f53>] netlink_unicast+0x268/0x2e8
[<00000000a7517316>] netlink_sendmsg+0x320/0x4c0
[<0000000069cba205>] ____sys_sendmsg+0x354/0x3a0
[<00000000e06bab0f>] ___sys_sendmsg+0xd8/0x120
[<0000000037340728>] __sys_sendmsg+0xa4/0xf8
[<000000004fed9776>] __arm64_sys_sendmsg+0x44/0x58
[<000000001c1e5647>] el0_svc_handler+0xd0/0x1a0--- net/mac80211/cfg.c | 1 + 1 file changed, 1 insertion(+)
net/mac80211/cfg.c +1 -0
@@ -1997,6 +1997,7 @@ static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev)ieee80211_stop_mesh (sdata);mutex_lock (&sdata->local->mtx);ieee80211_vif_release_channel (sdata); +kfree (sdata->u.mesh.ie);mutex_unlock (&sdata->local->mtx);return 0 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 38/51 mac80211: mesh: Free pending skb when destroying a mpath
In reply to Greg Kroah-HartmanFrom: Remi Pommarel <[email protected]>
[ Upstream commit 5e43540c2af0a0c0a18e39579b1ad49541f87506 ]
A mpath object can hold reference on a list of skb that are waiting for mpath resolution to be sent. When destroying a mpath this skb list should be cleaned up in order to not leak memory.
Fixing that kind of leak:
unreferenced object 0xffff0000181c9300 (size 1088):
comm "openvpn", pid 1782, jiffies 4295071698 (age 80.416s) hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 f9 80 36 00 00 00 00 00 ..........6.....
02 00 07 40 00 00 00 00 00 00 00 00 00 00 00 00 ...@............
backtrace:
[<000000004bc6a443>] kmem_cache_alloc+0x1a4/0x2f0
[<000000002caaef13>] sk_prot_alloc.isra.39+0x34/0x178
[<00000000ceeaa916>] sk_alloc+0x34/0x228
[<00000000ca1f1d04>] inet_create+0x198/0x518
[<0000000035626b1c>] __sock_create+0x134/0x328
[<00000000a12b3a87>] __sys_socket+0xb0/0x158
[<00000000ff859f23>] __arm64_sys_socket+0x40/0x58
[<00000000263486ec>] el0_svc_handler+0xd0/0x1a0
[<0000000005b5157d>] el0_svc+0x8/0xc
unreferenced object 0xffff000012973a40 (size 216):
comm "openvpn", pid 1782, jiffies 4295082137 (age 38.660s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 c0 06 16 00 00 ff ff 00 93 1c 18 00 00 ff ff ................
backtrace:
[<000000004bc6a443>] kmem_cache_alloc+0x1a4/0x2f0
[<0000000023c8c8f9>] __alloc_skb+0xc0/0x2b8
[<000000007ad950bb>] alloc_skb_with_frags+0x60/0x320
[<00000000ef90023a>] sock_alloc_send_pskb+0x388/0x3c0
[<00000000104fb1a3>] sock_alloc_send_skb+0x1c/0x28
[<000000006919d2dd>] __ip_append_data+0xba4/0x11f0
[<0000000083477587>] ip_make_skb+0x14c/0x1a8
[<0000000024f3d592>] udp_sendmsg+0xaf0/0xcf0
[<000000005aabe255>] inet_sendmsg+0x5c/0x80
[<000000008651ea08>] __sys_sendto+0x15c/0x218
[<000000003505c99b>] __arm64_sys_sendto+0x74/0x90
[<00000000263486ec>] el0_svc_handler+0xd0/0x1a0
[<0000000005b5157d>] el0_svc+0x8/0xc--- net/mac80211/mesh_pathtbl.c | 1 + 1 file changed, 1 insertion(+)
net/mac80211/mesh_pathtbl.c +1 -0
@@ -554,6 +554,7 @@ static void mesh_path_free_rcu(struct mesh_table *tbl,del_timer_sync (&mpath->timer);atomic_dec (&sdata->u.mesh.mpaths);atomic_dec (&tbl->entries); +mesh_path_flush_pending (mpath);kfree_rcu (mpath, rcu); }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 39/51 arm64/alternatives: move length validation inside the subsection
In reply to Greg Kroah-HartmanFrom: Sami Tolvanen <[email protected]>
[ Upstream commit 966a0acce2fca776391823381dba95c40e03c339 ]
Commit f7b93d42945c ("arm64/alternatives: use subsections for replacement sequences") breaks LLVM's integrated assembler, because due to its one-pass design, it cannot compute instruction sequence lengths before the layout for the subsection has been finalized. This change fixes the build by moving the .org directives inside the subsection, so they are processed after the subsection layout is known.
--- arch/arm64/include/asm/alternative.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/include/asm/alternative.h +2 -2
@@ -72,9 +72,9 @@ void apply_alternatives(void *start, size_t length);"663:\n\t" \ newinstr"\n" \"664:\n\t" \ -".previous\n\t" \".org . - (664b-663b) + (662b-661b)\n\t" \ -".org . - (662b-661b) + (664b-663b)\n" \ +".org . - (662b-661b) + (664b-663b)\n\t" \ +".previous\n" \".endif\n" #define __ALTERNATIVE_CFG_CB(oldinstr, feature, cfg_enabled, cb) \
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 40/51 arm64: csum: Fix handling of bad packets
In reply to Greg Kroah-HartmanFrom: Robin Murphy <[email protected]>
[ Upstream commit 05fb3dbda187bbd9cc1cd0e97e5d6595af570ac6 ]
Although iph is expected to point to at least 20 bytes of valid memory, ihl may be bogus, for example on reception of a corrupt packet. If it happens to be less than 5, we really don't want to run away and dereference 16GB worth of memory until it wraps back to exactly zero...
--- arch/arm64/include/asm/checksum.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm64/include/asm/checksum.h +3 -2
@@ -30,16 +30,17 @@ static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl) {__uint128_t tmp;u64 sum; +int n = ihl;/* we want it signed */ tmp = *(const __uint128_t *)iph; iph +=16 ; - ihl -=4 ; + n -=4 ; tmp += ((tmp >>64 ) | (tmp <<64 )); sum = tmp >>64 ;do { sum += *(const u32 *)iph; iph +=4 ; - }while (--ihl); + }while (--n >0 ); sum += ((sum >>32 ) | (sum <<32 ));return csum_fold ((__force u32)(sum >>32 ));
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 41/51 usb: hso: Fix debug compile warning on sparc32
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit e0484010ec05191a8edf980413fc92f28050c1cc ]
On sparc32, tcflag_t is "unsigned long", unlike on all other architectures, where it is "unsigned int":
drivers/net/usb/hso.c: In function ‘hso_serial_set_termios’:
include/linux/kern_levels.h:5:18: warning: format ‘%d’ expects argument of type ‘unsigned int’, but argument 4 has type ‘tcflag_t {aka long unsigned int}’ [-Wformat=] drivers/net/usb/hso.c:1393:3: note: in expansion of macro ‘hso_dbg’
hso_dbg(0x16, "Termios called with: cflags new[%d] - old[%d]\n",
^~~~~~~
include/linux/kern_levels.h:5:18: warning: format ‘%d’ expects argument of type ‘unsigned int’, but argument 5 has type ‘tcflag_t {aka long unsigned int}’ [-Wformat=] drivers/net/usb/hso.c:1393:3: note: in expansion of macro ‘hso_dbg’
hso_dbg(0x16, "Termios called with: cflags new[%d] - old[%d]\n",
^~~~~~~
As "unsigned long" is 32-bit on sparc32, fix this by casting all tcflag_t parameters to "unsigned int".
While at it, use "%u" to format unsigned numbers.
--- drivers/net/usb/hso.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/usb/hso.c +3 -2
@@ -1402,8 +1402,9 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)unsigned long flags;if (old) -hso_dbg (0x16 ,"Termios called with: cflags new[%d] - old[%d]\n" , - tty->termios.c_cflag, old->c_cflag); +hso_dbg (0x16 ,"Termios called with: cflags new[%u] - old[%u]\n" , + (unsigned int )tty->termios.c_cflag, + (unsigned int )old->c_cflag);/* the actual setup */ spin_lock_irqsave (&serial->serial_lock, flags);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 42/51 qed: Disable "MFW indication via attention" SPAM every 5 minutes
In reply to Greg Kroah-HartmanFrom: Laurence Oberman <[email protected]>
[ Upstream commit 1d61e21852d3161f234b9656797669fe185c251b ]
This is likely firmware causing this but its starting to annoy customers. Change the message level to verbose to prevent the spam.
Note that this seems to only show up with ISCSI enabled on the HBA via the qedi driver.
--- drivers/net/ethernet/qlogic/qed/qed_int.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/qlogic/qed/qed_int.c +2 -1
@@ -1015,7 +1015,8 @@ static int qed_int_attentions(struct qed_hwfn *p_hwfn) index, attn_bits, attn_acks, asserted_bits, deasserted_bits, p_sb_attn_sw->known_attn); }else if (asserted_bits ==0x100 ) { -DP_INFO (p_hwfn,"MFW indication via attention\n" ); +DP_VERBOSE (p_hwfn,NETIF_MSG_INTR , +"MFW indication via attention\n" ); }else {DP_VERBOSE (p_hwfn,NETIF_MSG_INTR ,"MFW indication [deassertion]\n" );
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 43/51 nfc: s3fwrn5: add missing release on skb in s3fwrn5_recv_frame
In reply to Greg Kroah-HartmanFrom: Navid Emamdoost <[email protected]>
[ Upstream commit 1e8fd3a97f2d83a7197876ceb4f37b4c2b00a0f3 ]
The implementation of s3fwrn5_recv_frame() is supposed to consume skb on all execution paths. Release skb before returning -ENODEV.
--- drivers/nfc/s3fwrn5/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/nfc/s3fwrn5/core.c +1 -0
@@ -209,6 +209,7 @@ int s3fwrn5_recv_frame(struct nci_dev *ndev, struct sk_buff *skb,case S3FWRN5_MODE_FW :return s3fwrn5_fw_recv_frame (ndev, skb);default : +kfree_skb (skb);return -ENODEV ; } }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 44/51 parisc: add support for cmpxchg on u8 pointers
In reply to Greg Kroah-HartmanFrom: Liam Beguin <[email protected]>
[ Upstream commit b344d6a83d01c52fddbefa6b3b4764da5b1022a0 ]
The kernel test bot reported[1] that using set_mask_bits on a u8 causes the following issue on parisc:
hppa-linux-ld: drivers/phy/ti/phy-tusb1210.o: in function `tusb1210_probe': >> (.text+0x2f4): undefined reference to `__cmpxchg_called_with_bad_pointer' >> hppa-linux-ld: (.text+0x324): undefined reference to `__cmpxchg_called_with_bad_pointer' hppa-linux-ld: (.text+0x354): undefined reference to `__cmpxchg_called_with_bad_pointer'
Add support for cmpxchg on u8 pointers.
[1] https://lore.kernel.org/patchwork/patch/1272617/#1468946
--- arch/parisc/include/asm/cmpxchg.h | 2 ++ arch/parisc/lib/bitops.c | 12 ++++++++++++ 2 files changed, 14 insertions(+)
arch/parisc/include/asm/cmpxchg.h +2 -0
@@ -60,6 +60,7 @@ extern void __cmpxchg_called_with_bad_pointer(void);extern unsigned long __cmpxchg_u32 (volatile unsigned int *m,unsigned int old,unsigned int new_);extern u64 __cmpxchg_u64 (volatile u64 *ptr,u64 old,u64 new_); +extern u8 __cmpxchg_u8 (volatile u8 *ptr,u8 old,u8 new_);/* don't worry...optimizer will get rid of most of this */ static inline unsigned long
@@ -71,6 +72,7 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size)#endif case 4 :return __cmpxchg_u32 ((unsigned int *)ptr, (unsigned int )old, (unsigned int )new_); +case 1 :return __cmpxchg_u8 ((u8 *)ptr, (u8 )old, (u8 )new_); }__cmpxchg_called_with_bad_pointer ();return old;
arch/parisc/lib/bitops.c +12 -0
@@ -79,3 +79,15 @@ unsigned long __cmpxchg_u32(volatile unsigned int *ptr, unsigned int old, unsign_atomic_spin_unlock_irqrestore (ptr, flags);return (unsigned long )prev; } + +u8 __cmpxchg_u8 (volatile u8 *ptr,u8 old,u8 new) +{ +unsigned long flags; +u8 prev; + +_atomic_spin_lock_irqsave (ptr, flags); +if ((prev = *ptr) == old) + *ptr = new; +_atomic_spin_unlock_irqrestore (ptr, flags); +return prev; +}
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 45/51 net: ethernet: ravb: exit if re-initialization fails in tx timeout
In reply to Greg Kroah-HartmanFrom: Yoshihiro Shimoda <[email protected]>
[ Upstream commit 015c5d5e6aa3523c758a70eb87b291cece2dbbb4 ]
According to the report of [1], this driver is possible to cause the following error in ravb_tx_timeout_work().
ravb e6800000.ethernet ethernet: failed to switch device to config mode
This error means that the hardware could not change the state from "Operation" to "Configuration" while some tx and/or rx queue are operating. After that, ravb_config() in ravb_dmac_init() will fail, and then any descriptors will be not allocaled anymore so that NULL pointer dereference happens after that on ravb_start_xmit().
To fix the issue, the ravb_tx_timeout_work() should check the return values of ravb_stop_dma() and ravb_dmac_init(). If ravb_stop_dma() fails, ravb_tx_timeout_work() re-enables TX and RX and just exits. If ravb_dmac_init() fails, just exits.
[1]
https://lore.kernel.org/linux-renesas-soc/[email protected]/
--- drivers/net/ethernet/renesas/ravb_main.c | 26 ++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)
drivers/net/ethernet/renesas/ravb_main.c +24 -2
@@ -1482,6 +1482,7 @@ static void ravb_tx_timeout_work(struct work_struct *work) struct ravb_private *priv = container_of(work, struct ravb_private, work);struct net_device *ndev = priv->ndev; +int error;netif_tx_stop_all_queues (ndev);
@@ -1490,15 +1491,36 @@ static void ravb_tx_timeout_work(struct work_struct *work)ravb_ptp_stop (ndev);/* Wait for DMA stopping */ -ravb_stop_dma (ndev); +if (ravb_stop_dma (ndev)) { +/* If ravb_stop_dma() fails, the hardware is still operating +* for TX and/or RX. So, this should not call the following +* functions because ravb_dmac_init() is possible to fail too. +* Also, this should not retry ravb_stop_dma() again and again +* here because it's possible to wait forever. So, this just +* re-enables the TX and RX and skip the following +* re-initialization procedure. +*/ +ravb_rcv_snd_enable (ndev); + goto out; + }ravb_ring_free (ndev,RAVB_BE );ravb_ring_free (ndev,RAVB_NC );/* Device init */ -ravb_dmac_init (ndev); + error =ravb_dmac_init (ndev); +if (error) { +/* If ravb_dmac_init() fails, descriptors are freed. So, this +* should return here to avoid re-enabling the TX and RX in +* ravb_emac_init(). +*/ +netdev_err (ndev,"%s: ravb_dmac_init() failed, error %d\n" , + __func__, error); +return ; + }ravb_emac_init (ndev); +out:/* Initialise PTP Clock driver */ if (priv->chip_id ==RCAR_GEN2 )ravb_ptp_init (ndev, priv->pdev);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 46/51 Revert "i2c: cadence: Fix the hold bit setting"
In reply to Greg Kroah-HartmanFrom: Raviteja Narayanam <[email protected]>
[ Upstream commit 0db9254d6b896b587759e2c844c277fb1a6da5b9 ]
This reverts commit d358def706880defa4c9e87381c5bf086a97d5f9.
There are two issues with "i2c: cadence: Fix the hold bit setting" commit.
1. In case of combined message request from user space, when the HOLD bit is cleared in cdns_i2c_mrecv function, a STOP condition is sent on the bus even before the last message is started. This is because when the HOLD bit is cleared, the FIFOS are empty and there is no pending transfer. The STOP condition should occur only after the last message is completed.
2. The code added by the commit is redundant. Driver is handling the setting/clearing of HOLD bit in right way before the commit.
The setting of HOLD bit based on 'bus_hold_flag' is taken care in cdns_i2c_master_xfer function even before cdns_i2c_msend/cdns_i2c_recv functions.
The clearing of HOLD bit is taken care at the end of cdns_i2c_msend and cdns_i2c_recv functions based on bus_hold_flag and byte count. Since clearing of HOLD bit is done after the slave address is written to the register (writing to address register triggers the message transfer), it is ensured that STOP condition occurs at the right time after completion of the pending transfer (last message).
--- drivers/i2c/busses/i2c-cadence.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/i2c/busses/i2c-cadence.c +2 -7
@@ -382,10 +382,8 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id)* Check for the message size against FIFO depth and set the * 'hold bus' bit if it is greater than FIFO depth. */ -if ((id->recv_count >CDNS_I2C_FIFO_DEPTH ) || id->bus_hold_flag) +if (id->recv_count >CDNS_I2C_FIFO_DEPTH ) ctrl_reg |=CDNS_I2C_CR_HOLD ; -else - ctrl_reg = ctrl_reg & ~CDNS_I2C_CR_HOLD ;cdns_i2c_writereg (ctrl_reg,CDNS_I2C_CR_OFFSET );
@@ -442,11 +440,8 @@ static void cdns_i2c_msend(struct cdns_i2c *id)* Check for the message size against FIFO depth and set the * 'hold bus' bit if it is greater than FIFO depth. */ -if ((id->send_count >CDNS_I2C_FIFO_DEPTH ) || id->bus_hold_flag) +if (id->send_count >CDNS_I2C_FIFO_DEPTH ) ctrl_reg |=CDNS_I2C_CR_HOLD ; -else - ctrl_reg = ctrl_reg & ~CDNS_I2C_CR_HOLD ; -cdns_i2c_writereg (ctrl_reg,CDNS_I2C_CR_OFFSET );/* Clear the interrupts in interrupt status register. */
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 47/51 x86/unwind/orc: Fix ORC for newly forked tasks
In reply to Greg Kroah-HartmanFrom: Josh Poimboeuf <[email protected]>
[ Upstream commit 372a8eaa05998cd45b3417d0e0ffd3a70978211a ]
The ORC unwinder fails to unwind newly forked tasks which haven't yet run on the CPU. It correctly reads the 'ret_from_fork' instruction pointer from the stack, but it incorrectly interprets that value as a call stack address rather than a "signal" one, so the address gets incorrectly decremented in the call to orc_find(), resulting in bad ORC data.
Fix it by forcing 'ret_from_fork' frames to be signal frames.
--- arch/x86/kernel/unwind_orc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/x86/kernel/unwind_orc.c +6 -2
@@ -346,8 +346,11 @@ bool unwind_next_frame(struct unwind_state *state)/* * Find the orc_entry associated with the text address. * -* Decrement call return addresses by one so they work for sibling -* calls and calls to noreturn functions. +* For a call frame (as opposed to a signal frame), state->ip points to +* the instruction after the call. That instruction's stack layout +* could be different from the call instruction's layout, for example +* if the call was to a noreturn function. So get the ORC data for the +* call instruction itself. */ orc =orc_find (state->signal ? state->ip : state->ip -1 );if (!orc || orc->sp_reg ==ORC_REG_UNDEFINED )
@@ -550,6 +553,7 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task, state->sp = task->thread.sp; state->bp =READ_ONCE_NOCHECK (frame->bp); state->ip =READ_ONCE_NOCHECK (frame->ret_addr); + state->signal = (void *)state->ip == ret_from_fork; } if (get_stack_info((unsigned long *)state->sp, state->task,
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 48/51 cxgb4: add missing release on skb in uld_send()
In reply to Greg Kroah-HartmanFrom: Navid Emamdoost <[email protected]>
[ Upstream commit e6827d1abdc9b061a57d7b7d3019c4e99fabea2f ]
In the implementation of uld_send(), the skb is consumed on all execution paths except one. Release skb when returning NET_XMIT_DROP.
--- drivers/net/ethernet/chelsio/cxgb4/sge.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/chelsio/cxgb4/sge.c +1 -0
@@ -1812,6 +1812,7 @@ static inline int uld_send(struct adapter *adap, struct sk_buff *skb, txq_info = adap->sge.uld_txq_info[tx_uld_type];if (unlikely (!txq_info)) {WARN_ON (true); +kfree_skb (skb);return NET_XMIT_DROP ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 49/51 xen-netfront: fix potential deadlock in xennet_remove()
In reply to Greg Kroah-HartmanFrom: Andrea Righi <[email protected]>
[ Upstream commit c2c633106453611be07821f53dff9e93a9d1c3f0 ]
There's a potential race in xennet_remove(); this is what the driver is doing upon unregistering a network device:
1. state = read bus state
2. if state is not "Closed":
3. request to set state to "Closing" 4. wait for state to be set to "Closing" 5. request to set state to "Closed" 6. wait for state to be set to "Closed"
If the state changes to "Closed" immediately after step 1 we are stuck forever in step 4, because the state will never go back from "Closed" to "Closing".
Make sure to check also for state == "Closed" in step 4 to prevent the deadlock.
Also add a 5 sec timeout any time we wait for the bus state to change, to avoid getting stuck forever in wait_event().
--- drivers/net/xen-netfront.c | 64 +++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 22 deletions(-)
drivers/net/xen-netfront.c +42 -22
@@ -63,6 +63,8 @@ module_param_named(max_queues, xennet_max_queues, uint, 0644);MODULE_PARM_DESC (max_queues,"Maximum number of queues per virtual interface" ); +#define XENNET_TIMEOUT (5 * HZ) +static const struct ethtool_ops xennet_ethtool_ops;struct netfront_cb {
@@ -1336,12 +1338,15 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev)netif_carrier_off (netdev); -xenbus_switch_state (dev, XenbusStateInitialising); -wait_event (module_wq, -xenbus_read_driver_state (dev->otherend) != - XenbusStateClosed && -xenbus_read_driver_state (dev->otherend) != - XenbusStateUnknown); +do { +xenbus_switch_state (dev, XenbusStateInitialising); + err =wait_event_timeout (module_wq, +xenbus_read_driver_state (dev->otherend) != + XenbusStateClosed && +xenbus_read_driver_state (dev->otherend) != + XenbusStateUnknown,XENNET_TIMEOUT ); + }while (!err); +return netdev; exit:
@@ -2142,28 +2147,43 @@ static const struct attribute_group xennet_dev_group = { };#endif /* CONFIG_SYSFS */ -static int xennet_remove (struct xenbus_device *dev) +static void xennet_bus_close (struct xenbus_device *dev) { -struct netfront_info *info =dev_get_drvdata (&dev->dev); - -dev_dbg (&dev->dev,"%s\n" , dev->nodename); +int ret; -if (xenbus_read_driver_state (dev->otherend) != XenbusStateClosed) { +if (xenbus_read_driver_state (dev->otherend) == XenbusStateClosed) +return ; +do {xenbus_switch_state (dev, XenbusStateClosing); -wait_event (module_wq, -xenbus_read_driver_state (dev->otherend) == - XenbusStateClosing || -xenbus_read_driver_state (dev->otherend) == - XenbusStateUnknown); + ret =wait_event_timeout (module_wq, +xenbus_read_driver_state (dev->otherend) == + XenbusStateClosing || +xenbus_read_driver_state (dev->otherend) == + XenbusStateClosed || +xenbus_read_driver_state (dev->otherend) == + XenbusStateUnknown, +XENNET_TIMEOUT ); + }while (!ret); + +if (xenbus_read_driver_state (dev->otherend) == XenbusStateClosed) +return ; +do {xenbus_switch_state (dev, XenbusStateClosed); -wait_event (module_wq, -xenbus_read_driver_state (dev->otherend) == - XenbusStateClosed || -xenbus_read_driver_state (dev->otherend) == - XenbusStateUnknown); - } + ret =wait_event_timeout (module_wq, +xenbus_read_driver_state (dev->otherend) == + XenbusStateClosed || +xenbus_read_driver_state (dev->otherend) == + XenbusStateUnknown, +XENNET_TIMEOUT ); + }while (!ret); +} + +static int xennet_remove (struct xenbus_device *dev) +{ +struct netfront_info *info =dev_get_drvdata (&dev->dev); +xennet_bus_close (dev);xennet_disconnect_backend (info);if (info->netdev->reg_state ==NETREG_REGISTERED )
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 50/51 KVM: LAPIC: Prevent setting the tscdeadline timer if the lapic is hw disabled
In reply to Greg Kroah-HartmanFrom: Wanpeng Li <[email protected]>
commit d2286ba7d574ba3103a421a2f9ec17cb5b0d87a1 upstream.
Prevent setting the tscdeadline timer if the lapic is hw disabled.
Message-Id: <[email protected]>
--- arch/x86/kvm/lapic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/lapic.c +1 -1
@@ -1918,7 +1918,7 @@ void kvm_set_lapic_tscdeadline_msr(struc {struct kvm_lapic *apic = vcpu->arch.apic; -if (!lapic_in_kernel (vcpu) ||apic_lvtt_oneshot (apic) || +if (!kvm_apic_present (vcpu) ||apic_lvtt_oneshot (apic) ||apic_lvtt_period (apic))return ;
Greg Kroah-Hartman
maintainerPATCH 51/51 x86/i8259: Use printk_deferred() to prevent deadlock
In reply to Greg Kroah-HartmanFrom: Thomas Gleixner <[email protected]>
commit bdd65589593edd79b6a12ce86b3b7a7c6dae5208 upstream.
0day reported a possible circular locking dependency:
Chain exists of: &irq_desc_lock_class --> console_owner --> &port_lock_key Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&port_lock_key);
lock(console_owner);
lock(&port_lock_key); lock(&irq_desc_lock_class);
The reason for this is a printk() in the i8259 interrupt chip driver which is invoked with the irq descriptor lock held, which reverses the lock operations vs. printk() from arbitrary contexts.
Switch the printk() to printk_deferred() to avoid that.
--- arch/x86/kernel/i8259.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/i8259.c +1 -1
@@ -206,7 +206,7 @@ spurious_8259A_irq:* lets ACK and report it. [once per IRQ] */ if (!(spurious_irq_mask & irqmask)) { -printk (KERN_DEBUG +printk_deferred (KERN_DEBUG "spurious 8259A interrupt: IRQ%d.\n" , irq); spurious_irq_mask |= irqmask; }