media: budget-core: Improve exception handling in budget_register()
Subsystems (7)
Sasha Levin
maintainerPATCH 10/10 alpha: fix annotation of io{read,write}{16,32}be()
In reply to Sasha LevinFrom: Luc Van Oostenryck <[email protected]>
[ Upstream commit bd72866b8da499e60633ff28f8a4f6e09ca78efe ]
These accessors must be used to read/write a big-endian bus. The value returned or written is native-endian.
However, these accessors are defined using be{16,32}_to_cpu() or cpu_to_be{16,32}() to make the endian conversion but these expect a __be{16,32} when none is present. Keeping them would need a force cast that would solve nothing at all.
So, do the conversion using swab{16,32}, like done in asm-generic for similar situations.
--- arch/alpha/include/asm/io.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/alpha/include/asm/io.h +4 -4
@@ -491,10 +491,10 @@ extern inline void writeq(u64 b, volatile void __iomem *addr) }#endif -#define ioread16be (p) be16_to_cpu(ioread16(p)) -#define ioread32be (p) be32_to_cpu(ioread32(p)) -#define iowrite16be (v,p) iowrite16(cpu_to_be16(v), (p)) -#define iowrite32be (v,p) iowrite32(cpu_to_be32(v), (p)) +#define ioread16be (p) swab16(ioread16(p)) +#define ioread32be (p) swab32(ioread32(p)) +#define iowrite16be (v,p) iowrite16(swab16(v), (p)) +#define iowrite32be (v,p) iowrite32(swab32(v), (p))#define inb_p inb#define inw_p inw
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 7/10 scsi: libfc: Free skb in fc_disc_gpn_id_resp() for valid cases
In reply to Sasha LevinFrom: Javed Hasan <[email protected]>
[ Upstream commit ec007ef40abb6a164d148b0dc19789a7a2de2cc8 ]
In fc_disc_gpn_id_resp(), skb is supposed to get freed in all cases except for PTR_ERR. However, in some cases it didn't.
This fix is to call fc_frame_free(fp) before function returns.
--- drivers/scsi/libfc/fc_disc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/scsi/libfc/fc_disc.c +9 -3
@@ -595,8 +595,12 @@ static void fc_disc_gpn_id_resp(struct fc_seq *sp, struct fc_frame *fp,mutex_lock (&disc->disc_mutex);if (PTR_ERR (fp) == -FC_EX_CLOSED ) goto out; -if (IS_ERR (fp)) - goto redisc; +if (IS_ERR (fp)) { +mutex_lock (&disc->disc_mutex); +fc_disc_restart (disc); +mutex_unlock (&disc->disc_mutex); + goto out; + } cp =fc_frame_payload_get (fp,sizeof (*cp));if (!cp)
@@ -621,7 +625,7 @@ static void fc_disc_gpn_id_resp(struct fc_seq *sp, struct fc_frame *fp, new_rdata->disc_id = disc->disc_id; lport->tt.rport_login (new_rdata); } - goto out; + goto free_fp; } rdata->disc_id = disc->disc_id; lport->tt.rport_login (rdata);
@@ -635,6 +639,8 @@ static void fc_disc_gpn_id_resp(struct fc_seq *sp, struct fc_frame *fp, redisc:fc_disc_restart (disc); } +free_fp: +fc_frame_free (fp); out:mutex_unlock (&disc->disc_mutex);kref_put (&rdata->kref, lport->tt.rport_destroy);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 4/10 m68knommu: fix overwriting of bits in ColdFire V3 cache control
In reply to Sasha LevinFrom: Greg Ungerer <[email protected]>
[ Upstream commit bdee0e793cea10c516ff48bf3ebb4ef1820a116b ]
The Cache Control Register (CACR) of the ColdFire V3 has bits that control high level caching functions, and also enable/disable the use of the alternate stack pointer register (the EUSP bit) to provide separate supervisor and user stack pointer registers. The code as it is today will blindly clear the EUSP bit on cache actions like invalidation. So it is broken for this case - and that will result in failed booting (interrupt entry and exit processing will be completely hosed).
This only affects ColdFire V3 parts that support the alternate stack register (like the 5329 for example) - generally speaking new parts do, older parts don't. It has no impact on ColdFire V3 parts with the single stack pointer, like the 5307 for example.
Fix the cache bit defines used, so they maintain the EUSP bit when carrying out cache actions through the CACR register.
--- arch/m68k/include/asm/m53xxacr.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/m68k/include/asm/m53xxacr.h +3 -3
@@ -88,9 +88,9 @@* coherency though in all cases. And for copyback caches we will need * to push cached data as well. */ -#define CACHE_INIT CACR_CINVA -#define CACHE_INVALIDATE CACR_CINVA -#define CACHE_INVALIDATED CACR_CINVA +#define CACHE_INIT (CACHE_MODE + CACR_CINVA - CACR_EC) +#define CACHE_INVALIDATE (CACHE_MODE + CACR_CINVA) +#define CACHE_INVALIDATED (CACHE_MODE + CACR_CINVA)#define ACR0_MODE ((CONFIG_RAMBASE & 0xff000000) + \ (0x000f0000) + \
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 8/10 virtio_ring: Avoid loop when vq is broken in virtqueue_poll
In reply to Sasha LevinFrom: Mao Wenan <[email protected]>
[ Upstream commit 481a0d7422db26fb63e2d64f0652667a5c6d0f3e ]
The loop may exist if vq->broken is true, virtqueue_get_buf_ctx_packed or virtqueue_get_buf_ctx_split will return NULL, so virtnet_poll will reschedule napi to receive packet, it will lead cpu usage(si) to 100%.
call trace as below:virtnet_poll
virtnet_receive
virtqueue_get_buf_ctx
virtqueue_get_buf_ctx_packed virtqueue_get_buf_ctx_split
virtqueue_napi_complete
virtqueue_poll //return true
virtqueue_napi_schedule //it will reschedule napi
to fix this, return false if vq is broken in virtqueue_poll.
--- drivers/virtio/virtio_ring.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/virtio/virtio_ring.c +3 -0
@@ -603,6 +603,9 @@ bool virtqueue_poll(struct virtqueue *_vq, unsigned last_used_idx) {struct vring_virtqueue *vq =to_vvq (_vq); +if (unlikely (vq->broken)) +return false; +virtio_mb (vq->weak_barriers);return (u16 )last_used_idx !=virtio16_to_cpu (_vq->vdev, vq->vring.used->idx); }
Signature · 6 lines
2.25.1 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Sasha Levin
maintainerPATCH 9/10 xfs: Fix UBSAN null-ptr-deref in xfs_sysfs_init
In reply to Sasha LevinFrom: Eiichi Tsukata <[email protected]>
[ Upstream commit 96cf2a2c75567ff56195fe3126d497a2e7e4379f ]
If xfs_sysfs_init is called with parent_kobj == NULL, UBSAN shows the following warning:
UBSAN: null-ptr-deref in ./fs/xfs/xfs_sysfs.h:37:23 member access within null pointer of type 'struct xfs_kobj' Call Trace: dump_stack+0x10e/0x195 ubsan_type_mismatch_common+0x241/0x280 __ubsan_handle_type_mismatch_v1+0x32/0x40 init_xfs_fs+0x12b/0x28f do_one_initcall+0xdd/0x1d0 do_initcall_level+0x151/0x1b6 do_initcalls+0x50/0x8f do_basic_setup+0x29/0x2b kernel_init_freeable+0x19f/0x20b kernel_init+0x11/0x1e0 ret_from_fork+0x22/0x30
Fix it by checking parent_kobj before the code accesses its member.
--- fs/xfs/xfs_sysfs.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/xfs/xfs_sysfs.h +4 -2
@@ -44,9 +44,11 @@ xfs_sysfs_init(struct xfs_kobj *parent_kobj, const char *name) { + struct kobject *parent; + + parent = parent_kobj ? &parent_kobj->kobject :NULL ;init_completion (&kobj->complete); -return kobject_init_and_add (&kobj->kobject, ktype, - &parent_kobj->kobject,"%s" , name); +return kobject_init_and_add (&kobj->kobject, ktype, parent,"%s" , name); } static inline void
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 5/10 xfs: fix inode quota reservation checks
In reply to Sasha LevinFrom: "Darrick J. Wong" <[email protected]>
[ Upstream commit f959b5d037e71a4d69b5bf71faffa065d9269b4a ]
xfs_trans_dqresv is the function that we use to make reservations against resource quotas. Each resource contains two counters: the q_core counter, which tracks resources allocated on disk; and the dquot reservation counter, which tracks how much of that resource has either been allocated or reserved by threads that are working on metadata updates.
For disk blocks, we compare the proposed reservation counter against the hard and soft limits to decide if we're going to fail the operation. However, for inodes we inexplicably compare against the q_core counter, not the incore reservation count.
Since the q_core counter is always lower than the reservation count and we unlock the dquot between reservation and transaction commit, this means that multiple threads can reserve the last inode count before we hit the hard limit, and when they commit, we'll be well over the hard limit.
Fix this by checking against the incore inode reservation counter, since we would appear to maintain that correctly (and that's what we report in GETQUOTA).
--- fs/xfs/xfs_trans_dquot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_trans_dquot.c +1 -1
@@ -662,7 +662,7 @@ xfs_trans_dqresv( } }if (ninos >0 ) { - total_count =be64_to_cpu (dqp->q_core.d_icount) + ninos; + total_count = dqp->q_res_icount + ninos; timer =be32_to_cpu (dqp->q_core.d_itimer); warns =be16_to_cpu (dqp->q_core.d_iwarns); warnlimit = dqp->q_mount->m_quotainfo->qi_iwarnlimit;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 3/10 Input: psmouse - add a newline when printing 'proto' by sysfs
In reply to Sasha LevinFrom: Xiongfeng Wang <[email protected]>
[ Upstream commit 4aec14de3a15cf9789a0e19c847f164776f49473 ]
When I cat parameter 'proto' by sysfs, it displays as follows. It's better to add a newline for easy reading.
root@syzkaller:~# cat /sys/module/psmouse/parameters/proto autoroot@syzkaller:~#
--- drivers/input/mouse/psmouse-base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/mouse/psmouse-base.c +1 -1
@@ -1911,7 +1911,7 @@ static int psmouse_get_maxproto(char *buffer, const struct kernel_param *kp) {int type = *((unsigned int *)kp->arg); -return sprintf (buffer,"%s" ,psmouse_protocol_by_type (type)->name); +return sprintf (buffer,"%s\n" ,psmouse_protocol_by_type (type)->name); }static int __init psmouse_init (void )
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 6/10 jffs2: fix UAF problem
In reply to Sasha LevinFrom: Zhe Li <[email protected]>
[ Upstream commit 798b7347e4f29553db4b996393caf12f5b233daf ]
The log of UAF problem is listed below.
BUG: KASAN: use-after-free in jffs2_rmdir+0xa4/0x1cc [jffs2] at addr c1f165fc Read of size 4 by task rm/8283 =============================================================================
BUG kmalloc-32 (Tainted: P B O ): kasan: bad access detected
-----------------------------------------------------------------------------
INFO: Allocated in 0xbbbbbbbb age=3054364 cpu=0 pid=0
0xb0bba6ef
jffs2_write_dirent+0x11c/0x9c8 [jffs2]
__slab_alloc.isra.21.constprop.25+0x2c/0x44
__kmalloc+0x1dc/0x370
jffs2_write_dirent+0x11c/0x9c8 [jffs2]
jffs2_do_unlink+0x328/0x5fc [jffs2]
jffs2_rmdir+0x110/0x1cc [jffs2]
vfs_rmdir+0x180/0x268
do_rmdir+0x2cc/0x300
ret_from_syscall+0x0/0x3c
INFO: Freed in 0x205b age=3054364 cpu=0 pid=0
0x2e9173
jffs2_add_fd_to_list+0x138/0x1dc [jffs2]
jffs2_add_fd_to_list+0x138/0x1dc [jffs2]
jffs2_garbage_collect_dirent.isra.3+0x21c/0x288 [jffs2]
jffs2_garbage_collect_live+0x16bc/0x1800 [jffs2]
jffs2_garbage_collect_pass+0x678/0x11d4 [jffs2]
jffs2_garbage_collect_thread+0x1e8/0x3b0 [jffs2]
kthread+0x1a8/0x1b0
ret_from_kernel_thread+0x5c/0x64
Call Trace:
[c17ddd20] [c02452d4] kasan_report.part.0+0x298/0x72c (unreliable)
[c17ddda0] [d2509680] jffs2_rmdir+0xa4/0x1cc [jffs2]
[c17dddd0] [c026da04] vfs_rmdir+0x180/0x268
[c17dde00] [c026f4e4] do_rmdir+0x2cc/0x300
[c17ddf40] [c001a658] ret_from_syscall+0x0/0x3cThe root cause is that we don't get "jffs2_inode_info.sem" before we scan list "jffs2_inode_info.dents" in function jffs2_rmdir. This patch add codes to get "jffs2_inode_info.sem" before we scan "jffs2_inode_info.dents" to slove the UAF problem.
--- fs/jffs2/dir.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/jffs2/dir.c +5 -1
@@ -588,10 +588,14 @@ static int jffs2_rmdir (struct inode *dir_i, struct dentry *dentry)int ret;uint32_t now =get_seconds (); +mutex_lock (&f->sem);for (fd = f->dents ; fd; fd = fd->next) { -if (fd->ino) +if (fd->ino) { +mutex_unlock (&f->sem);return -ENOTEMPTY ; + } } +mutex_unlock (&f->sem); ret =jffs2_do_unlink (c, dir_f, dentry->d_name.name, dentry->d_name.len, f, now);
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Sasha Levin
maintainerPATCH 2/10 media: vpss: clean up resources in init
In reply to Sasha LevinFrom: Evgeny Novikov <[email protected]>
[ Upstream commit 9c487b0b0ea7ff22127fe99a7f67657d8730ff94 ]
If platform_driver_register() fails within vpss_init() resources are not cleaned up. The patch fixes this issue by introducing the corresponding error handling.
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/media/platform/davinci/vpss.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/media/platform/davinci/vpss.c +16 -4
@@ -519,19 +519,31 @@ static void vpss_exit(void)static int __init vpss_init (void ) { +int ret; +if (!request_mem_region (VPSS_CLK_CTRL ,4 ,"vpss_clock_control" ))return -EBUSY ; oper_cfg.vpss_regs_base2 =ioremap (VPSS_CLK_CTRL ,4 );if (unlikely (!oper_cfg.vpss_regs_base2)) { -release_mem_region (VPSS_CLK_CTRL ,4 ); -return -ENOMEM ; + ret = -ENOMEM ; + goto err_ioremap; }writel (VPSS_CLK_CTRL_VENCCLKEN | -VPSS_CLK_CTRL_DACCLKEN , oper_cfg.vpss_regs_base2); +VPSS_CLK_CTRL_DACCLKEN , oper_cfg.vpss_regs_base2); + + ret =platform_driver_register (&vpss_driver); +if (ret) + goto err_pd_register; + +return 0 ; -return platform_driver_register (&vpss_driver); +err_pd_register: +iounmap (oper_cfg.vpss_regs_base2); +err_ioremap: +release_mem_region (VPSS_CLK_CTRL ,4 ); +return ret; }subsys_initcall (vpss_init);module_exit (vpss_exit);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 1/10 media: budget-core: Improve exception handling in budget_register()
From: Chuhong Yuan <[email protected]>
[ Upstream commit fc0456458df8b3421dba2a5508cd817fbc20ea71 ]
budget_register() has no error handling after its failure. Add the missed undo functions for error handling to fix it.
--- drivers/media/pci/ttpci/budget-core.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/media/pci/ttpci/budget-core.c +8 -3
@@ -386,20 +386,25 @@ static int budget_register(struct budget *budget) ret = dvbdemux->dmx.add_frontend (&dvbdemux->dmx, &budget->hw_frontend);if (ret <0 ) -return ret; + goto err_release_dmx; budget->mem_frontend.source =DMX_MEMORY_FE ; ret = dvbdemux->dmx.add_frontend (&dvbdemux->dmx, &budget->mem_frontend);if (ret <0 ) -return ret; + goto err_release_dmx; ret = dvbdemux->dmx.connect_frontend (&dvbdemux->dmx, &budget->hw_frontend);if (ret <0 ) -return ret; + goto err_release_dmx;dvb_net_init (&budget->dvb_adapter, &budget->dvb_net, &dvbdemux->dmx);return 0 ; + +err_release_dmx: +dvb_dmxdev_release (&budget->dmxdev); +dvb_dmx_release (&budget->demux); +return ret; }static void budget_unregister (struct budget *budget)
Signature · 1 line
2.25.1