autofs: fix a leak in autofs_expire_indirect()
Subsystems (8)
Sasha Levin
maintainerPATCH 4/13 audit_get_nd(): don't unlock parent too early
In reply to Sasha LevinFrom: Al Viro <[email protected]>
[ Upstream commit 69924b89687a2923e88cc42144aea27868913d0e ]
if the child has been negative and just went positive under us, we want coherent d_is_positive() and ->d_inode. Don't unlock the parent until we'd done that work...
--- kernel/audit_watch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/audit_watch.c +1 -1
@@ -365,12 +365,12 @@ static int audit_get_nd(struct audit_watch *watch, struct path *parent)struct dentry *d =kern_path_locked (watch->path, parent);if (IS_ERR (d))return PTR_ERR (d); -inode_unlock (d_backing_inode (parent->dentry));if (d_is_positive (d)) {/* update watch filter fields */ watch->dev = d->d_sb->s_dev; watch->ino =d_backing_inode (d)->i_ino; } +inode_unlock (d_backing_inode (parent->dentry));dput (d);return 0 ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 10/13 slcan: Fix memory leak in error path
In reply to Sasha LevinFrom: Jouni Hogander <[email protected]>
[ Upstream commit ed50e1600b4483c049ce76e6bd3b665a6a9300ed ]
This patch is fixing memory leak reported by Syzkaller:
BUG: memory leak unreferenced object 0xffff888067f65500 (size 4096):
comm "syz-executor043", pid 454, jiffies 4294759719 (age 11.930s)
hex dump (first 32 bytes):
73 6c 63 61 6e 30 00 00 00 00 00 00 00 00 00 00 slcan0..........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<00000000a06eec0d>] __kmalloc+0x18b/0x2c0
[<0000000083306e66>] kvmalloc_node+0x3a/0xc0
[<000000006ac27f87>] alloc_netdev_mqs+0x17a/0x1080
[<0000000061a996c9>] slcan_open+0x3ae/0x9a0
[<000000001226f0f9>] tty_ldisc_open.isra.1+0x76/0xc0
[<0000000019289631>] tty_set_ldisc+0x28c/0x5f0
[<000000004de5a617>] tty_ioctl+0x48d/0x1590
[<00000000daef496f>] do_vfs_ioctl+0x1c7/0x1510
[<0000000059068dbc>] ksys_ioctl+0x99/0xb0
[<000000009a6eb334>] __x64_sys_ioctl+0x78/0xb0
[<0000000053d0332e>] do_syscall_64+0x16f/0x580
[<0000000021b83b99>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[<000000008ea75434>] 0xffffffffffffffff--- drivers/net/can/slcan.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/can/slcan.c +1 -0
@@ -613,6 +613,7 @@ static int slcan_open(struct tty_struct *tty) sl->tty =NULL ; tty->disc_data =NULL ;clear_bit (SLF_INUSE , &sl->flags); +free_netdev (sl->dev); err_exit:rtnl_unlock ();
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 2/13 RDMA/hns: Correct the value of HNS_ROCE_HEM_CHUNK_LEN
In reply to Sasha LevinFrom: Sirong Wang <[email protected]>
[ Upstream commit 531eb45b3da4267fc2a64233ba256c8ffb02edd2 ]
Size of pointer to buf field of struct hns_roce_hem_chunk should be considered when calculating HNS_ROCE_HEM_CHUNK_LEN, or sg table size will be larger than expected when allocating hem.
--- drivers/infiniband/hw/hns/hns_roce_hem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/hns/hns_roce_hem.h +1 -1
@@ -52,7 +52,7 @@ enum {#define HNS_ROCE_HEM_CHUNK_LEN \ ((256 - sizeof(struct list_head) - 2 * sizeof(int)) / \ - (sizeof(struct scatterlist))) + (sizeof(struct scatterlist) + sizeof(void *)))enum {HNS_ROCE_HEM_PAGE_SHIFT =12 ,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 3/13 exportfs_decode_fh(): negative pinned may become positive without the parent locked
In reply to Sasha LevinFrom: Al Viro <[email protected]>
[ Upstream commit a2ece088882666e1dc7113744ac912eb161e3f87 ]
--- fs/exportfs/expfs.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-)
fs/exportfs/expfs.c +19 -12
@@ -506,26 +506,33 @@ struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid,* inode is actually connected to the parent. */ err =exportfs_get_name (mnt, target_dir, nbuf, result); -if (!err) { -inode_lock (target_dir->d_inode); - nresult =lookup_one_len (nbuf, target_dir, -strlen (nbuf)); -inode_unlock (target_dir->d_inode); -if (!IS_ERR (nresult)) { -if (nresult->d_inode) { -dput (result); - result = nresult; - }else -dput (nresult); - } +if (err) { +dput (target_dir); + goto err_result; } +inode_lock (target_dir->d_inode); + nresult =lookup_one_len (nbuf, target_dir,strlen (nbuf)); +if (!IS_ERR (nresult)) { +if (unlikely (nresult->d_inode != result->d_inode)) { +dput (nresult); + nresult =ERR_PTR (-ESTALE ); + } + } +inode_unlock (target_dir->d_inode);/* * At this point we are done with the parent, but it's pinned * by the child dentry anyway. */ dput (target_dir); +if (IS_ERR (nresult)) { + err =PTR_ERR (nresult); + goto err_result; + } +dput (result); + result = nresult; +/* * And finally make sure the dentry is actually acceptable * to NFSD.
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 6/13 Input: cyttsp4_core - fix use after free bug
In reply to Sasha LevinFrom: Pan Bian <[email protected]>
[ Upstream commit 79aae6acbef16f720a7949f8fc6ac69816c79d62 ]
The device md->input is used after it is released. Setting the device data to NULL is unnecessary as the device is never used again. Instead, md->input should be assigned NULL to avoid accessing the freed memory accidently. Besides, checking md->si against NULL is superfluous as it points to a variable address, which cannot be NULL.
--- drivers/input/touchscreen/cyttsp4_core.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/input/touchscreen/cyttsp4_core.c +0 -7
@@ -1972,11 +1972,6 @@ static int cyttsp4_mt_probe(struct cyttsp4 *cd)/* get sysinfo */ md->si = &cd->sysinfo; -if (!md->si) { -dev_err (dev,"%s: Fail get sysinfo pointer from core p=%p\n" , - __func__, md->si); - goto error_get_sysinfo; - } rc =cyttsp4_setup_input_device (cd);if (rc)
@@ -1986,8 +1981,6 @@ static int cyttsp4_mt_probe(struct cyttsp4 *cd) error_init_input:input_free_device (md->input); -error_get_sysinfo: -input_set_drvdata (md->input,NULL ); error_alloc_failed:dev_err (dev,"%s failed.\n" , __func__);return rc;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 11/13 rsxx: add missed destroy_workqueue calls in remove
In reply to Sasha LevinFrom: Chuhong Yuan <[email protected]>
[ Upstream commit dcb77e4b274b8f13ac6482dfb09160cd2fae9a40 ]
The driver misses calling destroy_workqueue in remove like what is done when probe fails.
Add the missed calls to fix it.
--- drivers/block/rsxx/core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/block/rsxx/core.c +2 -0
@@ -1025,8 +1025,10 @@ static void rsxx_pci_remove(struct pci_dev *dev)cancel_work_sync (&card->event_work); +destroy_workqueue (card->event_wq);rsxx_destroy_dev (card);rsxx_dma_destroy (card); +destroy_workqueue (card->creg_ctrl.creg_wq);spin_lock_irqsave (&card->irq_lock, flags);rsxx_disable_ier_and_isr (card,CR_INTR_ALL );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 13/13 net: ep93xx_eth: fix mismatch of request_mem_region in remove
In reply to Sasha LevinFrom: Chuhong Yuan <[email protected]>
[ Upstream commit 3df70afe8d33f4977d0e0891bdcfb639320b5257 ]
The driver calls release_resource in remove to match request_mem_region in probe, which is incorrect.
Fix it by using the right one, release_mem_region.
--- drivers/net/ethernet/cirrus/ep93xx_eth.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/cirrus/ep93xx_eth.c +3 -2
@@ -780,6 +780,7 @@ static int ep93xx_eth_remove(struct platform_device *pdev) {struct net_device *dev;struct ep93xx_priv *ep; +struct resource *mem; dev =platform_get_drvdata (pdev);if (dev ==NULL )
@@ -795,8 +796,8 @@ static int ep93xx_eth_remove(struct platform_device *pdev)iounmap (ep->base_addr);if (ep->res !=NULL ) { -release_resource (ep->res); -kfree (ep->res); + mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +release_mem_region (mem->start,resource_size (mem)); }free_netdev (dev);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 7/13 ALSA: pcm: Fix stream lock usage in snd_pcm_period_elapsed()
In reply to Sasha LevinFrom: paulhsia <[email protected]>
[ Upstream commit f5cdc9d4003a2f66ea57b3edd3e04acc2b1a4439 ]
If the nullity check for substream->runtime is outside of the lock region, it is possible to have a null runtime in the critical section if snd_pcm_detach_substream is called right before the lock.
--- sound/core/pcm_lib.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
sound/core/pcm_lib.c +6 -2
@@ -1877,11 +1877,14 @@ void snd_pcm_period_elapsed(struct snd_pcm_substream *substream)struct snd_pcm_runtime *runtime;unsigned long flags; -if (PCM_RUNTIME_CHECK (substream)) +if (snd_BUG_ON (!substream))return ; - runtime = substream->runtime;snd_pcm_stream_lock_irqsave (substream, flags); +if (PCM_RUNTIME_CHECK (substream)) + goto _unlock; + runtime = substream->runtime; +if (!snd_pcm_running (substream) ||snd_pcm_update_hw_ptr0 (substream,1 ) <0 ) goto _end;
@@ -1892,6 +1895,7 @@ void snd_pcm_period_elapsed(struct snd_pcm_substream *substream)#endif _end:kill_fasync (&runtime->fasync,SIGIO ,POLL_IN ); + _unlock:snd_pcm_stream_unlock_irqrestore (substream, flags); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 5/13 NFC: nxp-nci: Fix NULL pointer dereference after I2C communication error
In reply to Sasha LevinFrom: Stephan Gerhold <[email protected]>
[ Upstream commit a71a29f50de1ef97ab55c151a1598eb12dde379d ]
I2C communication errors (-EREMOTEIO) during the IRQ handler of nxp-nci result in a NULL pointer dereference at the moment:
BUG: kernel NULL pointer dereference, address: 0000000000000000
Oops: 0002 [#1] PREEMPT SMP NOPTI
CPU: 1 PID: 355 Comm: irq/137-nxp-nci Not tainted 5.4.0-rc6 #1
RIP: 0010:skb_queue_tail+0x25/0x50
Call Trace:
nci_recv_frame+0x36/0x90 [nci]
nxp_nci_i2c_irq_thread_fn+0xd1/0x285 [nxp_nci_i2c]
? preempt_count_add+0x68/0xa0
? irq_forced_thread_fn+0x80/0x80
irq_thread_fn+0x20/0x60
irq_thread+0xee/0x180
? wake_threads_waitq+0x30/0x30
kthread+0xfb/0x130
? irq_thread_check_affinity+0xd0/0xd0
? kthread_park+0x90/0x90
ret_from_fork+0x1f/0x40Afterward the kernel must be rebooted to work properly again.
This happens because it attempts to call nci_recv_frame() with skb == NULL. However, unlike nxp_nci_fw_recv_frame(), nci_recv_frame() does not have any NULL checks for skb, causing the NULL pointer dereference.
Change the code to call only nxp_nci_fw_recv_frame() in case of an error. Make sure to log it so it is obvious that a communication error occurred. The error above then becomes:
nxp-nci_i2c i2c-NXP1001:00: NFC: Read failed with error -121
nci: __nci_request: wait_for_completion_interruptible_timeout failed 0
nxp-nci_i2c i2c-NXP1001:00: NFC: Read failed with error -121--- drivers/nfc/nxp-nci/i2c.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/nfc/nxp-nci/i2c.c +4 -2
@@ -238,8 +238,10 @@ static irqreturn_t nxp_nci_i2c_irq_thread_fn(int irq, void *phy_id)if (r == -EREMOTEIO ) { phy->hard_fault = r; - skb =NULL ; - }else if (r <0 ) { +if (info->mode ==NXP_NCI_MODE_FW ) +nxp_nci_fw_recv_frame (phy->ndev,NULL ); + } +if (r <0 ) {nfc_err (&client->dev,"Read failed with error %d\n" , r); goto exit_irq_handled; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 12/13 ax88172a: fix information leak on short answers
In reply to Sasha LevinFrom: Oliver Neukum <[email protected]>
[ Upstream commit a9a51bd727d141a67b589f375fe69d0e54c4fe22 ]
If a malicious device gives a short MAC it can elicit up to 5 bytes of leaked memory out of the driver. We need to check for ETH_ALEN instead.
--- drivers/net/usb/ax88172a.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/ax88172a.c +1 -1
@@ -215,7 +215,7 @@ static int ax88172a_bind(struct usbnet *dev, struct usb_interface *intf)/* Get the MAC address */ ret =asix_read_cmd (dev,AX_CMD_READ_NODE_ID ,0 ,0 ,ETH_ALEN , buf,0 ); -if (ret <0 ) { +if (ret <ETH_ALEN ) {netdev_err (dev->net,"Failed to read MAC address: %d\n" , ret); goto free; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 9/13 net: cdc_ncm: Signedness bug in cdc_ncm_set_dgram_size()
In reply to Sasha LevinFrom: Dan Carpenter <[email protected]>
[ Upstream commit a56dcc6b455830776899ce3686735f1172e12243 ]
This code is supposed to test for negative error codes and partial reads, but because sizeof() is size_t (unsigned) type then negative error codes are type promoted to high positive values and the condition doesn't work as expected.
--- drivers/net/usb/cdc_ncm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/cdc_ncm.c +1 -1
@@ -577,7 +577,7 @@ static void cdc_ncm_set_dgram_size(struct usbnet *dev, int new_size) err =usbnet_read_cmd (dev,USB_CDC_GET_MAX_DATAGRAM_SIZE ,USB_TYPE_CLASS |USB_DIR_IN |USB_RECIP_INTERFACE ,0 , iface_no, &max_datagram_size,sizeof (max_datagram_size)); -if (err <sizeof (max_datagram_size)) { +if (err !=sizeof (max_datagram_size)) {dev_dbg (&dev->intf->dev,"GET_MAX_DATAGRAM_SIZE failed\n" ); goto out; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 8/13 slip: Fix memory leak in slip_open error path
In reply to Sasha LevinFrom: Jouni Hogander <[email protected]>
[ Upstream commit 3b5a39979dafea9d0cd69c7ae06088f7a84cdafa ]
Driver/net/can/slcan.c is derived from slip.c. Memory leak was detected by Syzkaller in slcan. Same issue exists in slip.c and this patch is addressing the leak in slip.c.
Here is the slcan memory leak trace reported by Syzkaller:
BUG: memory leak unreferenced object 0xffff888067f65500 (size 4096):
comm "syz-executor043", pid 454, jiffies 4294759719 (age 11.930s)
hex dump (first 32 bytes):
73 6c 63 61 6e 30 00 00 00 00 00 00 00 00 00 00 slcan0..........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<00000000a06eec0d>] __kmalloc+0x18b/0x2c0
[<0000000083306e66>] kvmalloc_node+0x3a/0xc0
[<000000006ac27f87>] alloc_netdev_mqs+0x17a/0x1080
[<0000000061a996c9>] slcan_open+0x3ae/0x9a0
[<000000001226f0f9>] tty_ldisc_open.isra.1+0x76/0xc0
[<0000000019289631>] tty_set_ldisc+0x28c/0x5f0
[<000000004de5a617>] tty_ioctl+0x48d/0x1590
[<00000000daef496f>] do_vfs_ioctl+0x1c7/0x1510
[<0000000059068dbc>] ksys_ioctl+0x99/0xb0
[<000000009a6eb334>] __x64_sys_ioctl+0x78/0xb0
[<0000000053d0332e>] do_syscall_64+0x16f/0x580
[<0000000021b83b99>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[<000000008ea75434>] 0xfffffffffffffff--- drivers/net/slip/slip.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/slip/slip.c +1 -0
@@ -860,6 +860,7 @@ static int slip_open(struct tty_struct *tty) sl->tty =NULL ; tty->disc_data =NULL ;clear_bit (SLF_INUSE , &sl->flags); +free_netdev (sl->dev); err_exit:rtnl_unlock ();
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 1/13 autofs: fix a leak in autofs_expire_indirect()
From: Al Viro <[email protected]>
[ Upstream commit 03ad0d703df75c43f78bd72e16124b5b94a95188 ]
if the second call of should_expire() in there ends up grabbing and returning a new reference to dentry, we need to drop it before continuing.
--- fs/autofs4/expire.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/autofs4/expire.c +3 -2
@@ -469,9 +469,10 @@ struct dentry *autofs4_expire_indirect(struct super_block *sb,*/ flags &= ~AUTOFS_EXP_LEAVES ; found =should_expire (expired, mnt, timeout, how); -if (!found || found != expired) -/* Something has changed, continue */ +if (found != expired) {// something has changed, continue +dput (found); goto next; + }if (expired != dentry)dput (dentry);
Signature · 1 line
2.20.1