4.14.326-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 157/186 tpm_tis: Resend command to recover from data transfer errors
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Steffen <[email protected]>
[ Upstream commit 280db21e153d8810ce3b93640c63ae922bcb9e8e ]
Similar to the transmission of TPM responses, also the transmission of TPM commands may become corrupted. Instead of aborting when detecting such issues, try resending the command again.
--- drivers/char/tpm/tpm_tis_core.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/char/tpm/tpm_tis_core.c +11 -4
@@ -364,10 +364,17 @@ static int tpm_tis_send_main(struct tpm_chip *chip, const u8 *buf, size_t len)int rc;u32 ordinal;unsigned long dur; - - rc =tpm_tis_send_data (chip, buf, len); -if (rc <0 ) -return rc; +unsigned int try; + +for (try =0 ; try <TPM_RETRY ; try++) { + rc =tpm_tis_send_data (chip, buf, len); +if (rc >=0 ) +/* Data transfer done successfully */ +break ; +else if (rc != -EIO ) +/* Data transfer failed, not recoverable */ +return rc; + }/* go and do it */ rc =tpm_tis_write8 (priv,TPM_STS (priv->locality),TPM_STS_GO );
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 158/186 alx: fix OOB-read compiler warning
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: GONG, Ruiqi <[email protected]>
[ Upstream commit 3a198c95c95da10ad844cbeade2fe40bdf14c411 ]
The following message shows up when compiling with W=1:
In function ‘fortify_memcpy_chk’,
inlined from ‘alx_get_ethtool_stats’ at drivers/net/ethernet/atheros/alx/ethtool.c:297:2:./include/linux/fortify-string.h:592:4: error: call to ‘__read_overflow2_field’ declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Werror=attribute-warning]
592 | __read_overflow2_field(q_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~In order to get alx stats altogether, alx_get_ethtool_stats() reads beyond hw->stats.rx_ok. Fix this warning by directly copying hw->stats, and refactor the unnecessarily complicated BUILD_BUG_ON btw.
--- drivers/net/ethernet/atheros/alx/ethtool.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/ethernet/atheros/alx/ethtool.c +2 -3
@@ -281,9 +281,8 @@ static void alx_get_ethtool_stats(struct net_device *netdev,spin_lock (&alx->stats_lock);alx_update_hw_stats (hw); -BUILD_BUG_ON (sizeof (hw->stats) - offsetof(struct alx_hw_stats , rx_ok) < -ALX_NUM_STATS *sizeof (u64)); -memcpy (data, &hw->stats.rx_ok,ALX_NUM_STATS *sizeof (u64)); +BUILD_BUG_ON (sizeof (hw->stats) !=ALX_NUM_STATS *sizeof (u64)); +memcpy (data, &hw->stats,sizeof (hw->stats));spin_unlock (&alx->stats_lock); }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 159/186 drm/exynos: fix a possible null-pointer dereference due to data race in exynos_drm_crtc_atomic_disable()
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tuo Li <[email protected]>
[ Upstream commit 2e63972a2de14482d0eae1a03a73e379f1c3f44c ]
The variable crtc->state->event is often protected by the lock crtc->dev->event_lock when is accessed. However, it is accessed as a condition of an if statement in exynos_drm_crtc_atomic_disable() without holding the lock:
if (crtc->state->event && !crtc->state->active)
However, if crtc->state->event is changed to NULL by another thread right after the conditions of the if statement is checked to be true, a null-pointer dereference can occur in drm_crtc_send_vblank_event():
e->pipe = pipe;
To fix this possible null-pointer dereference caused by data race, the spin lock coverage is extended to protect the if statement as well as the function call to drm_crtc_send_vblank_event().
Added relevant link.
--- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_crtc.c +2 -3
@@ -43,13 +43,12 @@ static void exynos_drm_crtc_atomic_disable(struct drm_crtc *crtc,if (exynos_crtc->ops->disable) exynos_crtc->ops->disable (exynos_crtc); +spin_lock_irq (&crtc->dev->event_lock);if (crtc->state->event && !crtc->state->active) { -spin_lock_irq (&crtc->dev->event_lock);drm_crtc_send_vblank_event (crtc, crtc->state->event); -spin_unlock_irq (&crtc->dev->event_lock); - crtc->state->event =NULL ; } +spin_unlock_irq (&crtc->dev->event_lock); } static int exynos_crtc_atomic_check(struct drm_crtc *crtc,
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 160/186 md: raid1: fix potential OOB in raid1_remove_disk()
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Shurong <[email protected]>
[ Upstream commit 8b0472b50bcf0f19a5119b00a53b63579c8e1e4d ]
If rddev->raid_disk is greater than mddev->raid_disks, there will be an out-of-bounds in raid1_remove_disk(). We have already found similar reports as follows:
1) commit d17f744e883b ("md-raid10: fix KASAN warning")
2) commit 1ebc2cec0b7d ("dm raid: fix KASAN warning in raid5_remove_disk")
Fix this bug by checking whether the "number" variable is valid.
--- drivers/md/raid1.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/md/raid1.c +4 -0
@@ -1775,6 +1775,10 @@ static int raid1_remove_disk(struct mddev *mddev, struct md_rdev *rdev)struct r1conf *conf = mddev->private;int err =0 ;int number = rdev->raid_disk; + +if (unlikely (number >= conf->raid_disks)) + goto abort; +struct raid1_info *p = conf->mirrors + number;if (rdev != p->rdev)
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 161/186 ext2: fix datatype of block number in ext2_xattr_set2()
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Georg Ottinger <[email protected]>
[ Upstream commit e88076348425b7d0491c8c98d8732a7df8de7aa3 ]
I run a small server that uses external hard drives for backups. The backup software I use uses ext2 filesystems with 4KiB block size and the server is running SELinux and therefore relies on xattr. I recently upgraded the hard drives from 4TB to 12TB models. I noticed that after transferring some TBs I got a filesystem error "Freeing blocks not in datazone - block = 18446744071529317386, count = 1" and the backup process stopped. Trying to fix the fs with e2fsck resulted in a completely corrupted fs. The error probably came from ext2_free_blocks(), and because of the large number 18e19 this problem immediately looked like some kind of integer overflow. Whereas the 4TB fs was about 1e9 blocks, the new 12TB is about 3e9 blocks. So, searching the ext2 code, I came across the line in fs/ext2/xattr.c:745 where ext2_new_block() is called and the resulting block number is stored in the variable block as an int datatype. If a block with a block number greater than INT32_MAX is returned, this variable overflows and the call to sb_getblk() at line fs/ext2/xattr.c:750 fails, then the call to ext2_free_blocks() produces the error.
Message-Id: <[email protected]>
--- fs/ext2/xattr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ext2/xattr.c +2 -2
@@ -664,10 +664,10 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,/* We need to allocate a new block */ ext2_fsblk_t goal =ext2_group_first_block_no (sb,EXT2_I (inode)->i_block_group); -int block =ext2_new_block (inode, goal, &error); +ext2_fsblk_t block =ext2_new_block (inode, goal, &error);if (error) goto cleanup; -ea_idebug (inode,"creating block %d" , block); +ea_idebug (inode,"creating block %lu" , block); new_bh =sb_getblk (sb, block);if (unlikely (!new_bh)) {
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 162/186 fs/jfs: prevent double-free in dbUnmount() after failed jfs_remount()
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Kanner <[email protected]>
[ Upstream commit cade5397e5461295f3cb87880534b6a07cafa427 ]
Syzkaller reported the following issue:
==================================================================
BUG: KASAN: double-free in slab_free mm/slub.c:3787 [inline] BUG: KASAN: double-free in __kmem_cache_free+0x71/0x110 mm/slub.c:3800 Free of addr ffff888086408000 by task syz-executor.4/12750 [...] Call Trace: <TASK> [...] kasan_report_invalid_free+0xac/0xd0 mm/kasan/report.c:482 ____kasan_slab_free+0xfb/0x120 kasan_slab_free include/linux/kasan.h:177 [inline] slab_free_hook mm/slub.c:1781 [inline] slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1807 slab_free mm/slub.c:3787 [inline] __kmem_cache_free+0x71/0x110 mm/slub.c:3800 dbUnmount+0xf4/0x110 fs/jfs/jfs_dmap.c:264 jfs_umount+0x248/0x3b0 fs/jfs/jfs_umount.c:87 jfs_put_super+0x86/0x190 fs/jfs/super.c:194 generic_shutdown_super+0x130/0x310 fs/super.c:492 kill_block_super+0x79/0xd0 fs/super.c:1386 deactivate_locked_super+0xa7/0xf0 fs/super.c:332 cleanup_mnt+0x494/0x520 fs/namespace.c:1291 task_work_run+0x243/0x300 kernel/task_work.c:179 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop+0x124/0x150 kernel/entry/common.c:171 exit_to_user_mode_prepare+0xb2/0x140 kernel/entry/common.c:203 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline] syscall_exit_to_user_mode+0x26/0x60 kernel/entry/common.c:296 do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd [...] </TASK> Allocated by task 13352: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x3d/0x60 mm/kasan/common.c:52 ____kasan_kmalloc mm/kasan/common.c:371 [inline] __kasan_kmalloc+0x97/0xb0 mm/kasan/common.c:380 kmalloc include/linux/slab.h:580 [inline] dbMount+0x54/0x980 fs/jfs/jfs_dmap.c:164 jfs_mount+0x1dd/0x830 fs/jfs/jfs_mount.c:121 jfs_fill_super+0x590/0xc50 fs/jfs/super.c:556 mount_bdev+0x26c/0x3a0 fs/super.c:1359 legacy_get_tree+0xea/0x180 fs/fs_context.c:610 vfs_get_tree+0x88/0x270 fs/super.c:1489 do_new_mount+0x289/0xad0 fs/namespace.c:3145 do_mount fs/namespace.c:3488 [inline] __do_sys_mount fs/namespace.c:3697 [inline] __se_sys_mount+0x2d3/0x3c0 fs/namespace.c:3674 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 13352: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x3d/0x60 mm/kasan/common.c:52 kasan_save_free_info+0x27/0x40 mm/kasan/generic.c:518 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236 kasan_slab_free include/linux/kasan.h:177 [inline] slab_free_hook mm/slub.c:1781 [inline] slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1807 slab_free mm/slub.c:3787 [inline] __kmem_cache_free+0x71/0x110 mm/slub.c:3800 dbUnmount+0xf4/0x110 fs/jfs/jfs_dmap.c:264 jfs_mount_rw+0x545/0x740 fs/jfs/jfs_mount.c:247 jfs_remount+0x3db/0x710 fs/jfs/super.c:454 reconfigure_super+0x3bc/0x7b0 fs/super.c:935 vfs_fsconfig_locked fs/fsopen.c:254 [inline] __do_sys_fsconfig fs/fsopen.c:439 [inline] __se_sys_fsconfig+0xad5/0x1060 fs/fsopen.c:314 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd
[...]
JFS_SBI(ipbmap->i_sb)->bmap wasn't set to NULL after kfree() in dbUnmount().
Syzkaller uses faultinject to reproduce this KASAN double-free warning. The issue is triggered if either diMount() or dbMount() fail in jfs_remount(), since diUnmount() or dbUnmount() already happened in such a case - they will do double-free on next execution: jfs_umount or jfs_remount.
Tested on both upstream and jfs-next by syzkaller.
--- fs/jfs/jfs_dmap.c | 1 + 1 file changed, 1 insertion(+)
fs/jfs/jfs_dmap.c +1 -0
@@ -282,6 +282,7 @@ int dbUnmount(struct inode *ipbmap, int mounterror)/* free the memory for the in-memory bmap. */ kfree (bmp); +JFS_SBI (ipbmap->i_sb)->bmap =NULL ;return (0 ); }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 163/186 jfs: fix invalid free of JFS_IP(ipimap)->i_imap in diUnmount
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liu Shixin via Jfs-discussion <[email protected]>
[ Upstream commit 6e2bda2c192d0244b5a78b787ef20aa10cb319b7 ]
syzbot found an invalid-free in diUnmount:
BUG: KASAN: double-free in slab_free mm/slub.c:3661 [inline] BUG: KASAN: double-free in __kmem_cache_free+0x71/0x110 mm/slub.c:3674
Free of addr ffff88806f410000 by task syz-executor131/3632
CPU: 0 PID: 3632 Comm: syz-executor131 Not tainted 6.1.0-rc7-syzkaller-00012-gca57f02295f1 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022 Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1b1/0x28e lib/dump_stack.c:106 print_address_description+0x74/0x340 mm/kasan/report.c:284 print_report+0x107/0x1f0 mm/kasan/report.c:395 kasan_report_invalid_free+0xac/0xd0 mm/kasan/report.c:460 ____kasan_slab_free+0xfb/0x120 kasan_slab_free include/linux/kasan.h:177 [inline] slab_free_hook mm/slub.c:1724 [inline] slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1750 slab_free mm/slub.c:3661 [inline] __kmem_cache_free+0x71/0x110 mm/slub.c:3674 diUnmount+0xef/0x100 fs/jfs/jfs_imap.c:195 jfs_umount+0x108/0x370 fs/jfs/jfs_umount.c:63 jfs_put_super+0x86/0x190 fs/jfs/super.c:194 generic_shutdown_super+0x130/0x310 fs/super.c:492 kill_block_super+0x79/0xd0 fs/super.c:1428 deactivate_locked_super+0xa7/0xf0 fs/super.c:332 cleanup_mnt+0x494/0x520 fs/namespace.c:1186 task_work_run+0x243/0x300 kernel/task_work.c:179 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0x664/0x2070 kernel/exit.c:820 do_group_exit+0x1fd/0x2b0 kernel/exit.c:950 __do_sys_exit_group kernel/exit.c:961 [inline] __se_sys_exit_group kernel/exit.c:959 [inline] __x64_sys_exit_group+0x3b/0x40 kernel/exit.c:959 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd
[...]
JFS_IP(ipimap)->i_imap is not setting to NULL after free in diUnmount. If jfs_remount() free JFS_IP(ipimap)->i_imap but then failed at diMount(). JFS_IP(ipimap)->i_imap will be freed once again.
Fix this problem by setting JFS_IP(ipimap)->i_imap to NULL after free.
--- fs/jfs/jfs_imap.c | 1 + 1 file changed, 1 insertion(+)
fs/jfs/jfs_imap.c +1 -0
@@ -208,6 +208,7 @@ int diUnmount(struct inode *ipimap, int mounterror)* free in-memory control structure */ kfree (imap); +JFS_IP (ipimap)->i_imap =NULL ;return (0 ); }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 164/186 powerpc/pseries: fix possible memory leak in ibmebus_bus_init()
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: ruanjinjie <[email protected]>
[ Upstream commit afda85b963c12947e298ad85d757e333aa40fd74 ]
If device_register() returns error in ibmebus_bus_init(), name of kobject which is allocated in dev_set_name() called in device_add() is leaked.
As comment of device_add() says, it should call put_device() to drop the reference count that was set in device_initialize() when it fails, so the name can be freed in kobject_cleanup().
--- arch/powerpc/platforms/pseries/ibmebus.c | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/platforms/pseries/ibmebus.c +1 -0
@@ -452,6 +452,7 @@ static int __init ibmebus_bus_init(void)if (err) {printk (KERN_WARNING "%s: device_register returned %i\n" , __func__, err); +put_device (&ibmebus_bus_device);bus_unregister (&ibmebus_bus_type);return err;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 165/186 media: dvb-usb-v2: af9035: Fix null-ptr-deref in af9035_i2c_master_xfer
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Shurong <[email protected]>
[ Upstream commit 7bf744f2de0a848fb1d717f5831b03db96feae89 ]
In af9035_i2c_master_xfer, msg is controlled by user. When msg[i].buf is null and msg[i].len is zero, former checks on msg[i].buf would be passed. Malicious data finally reach af9035_i2c_master_xfer. If accessing msg[i].buf[0] without sanity check, null ptr deref would happen. We add check on msg[i].len to prevent crash.
Similar commit:
commit 0ed554fd769a
("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")
--- drivers/media/usb/dvb-usb-v2/af9035.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/media/usb/dvb-usb-v2/af9035.c +8 -6
@@ -284,6 +284,7 @@ static int af9035_i2c_master_xfer(structstruct dvb_usb_device *d =i2c_get_adapdata (adap);struct state *state =d_to_priv (d);int ret; +u32 reg;if (mutex_lock_interruptible (&d->i2c_mutex) <0 )return -EAGAIN ;
@@ -336,8 +337,10 @@ static int af9035_i2c_master_xfer(struct ret = -EOPNOTSUPP ; }else if ((msg[0 ].addr == state->af9033_i2c_addr[0 ]) || (msg[0 ].addr == state->af9033_i2c_addr[1 ])) { +if (msg[0 ].len <3 || msg[1 ].len <1 ) +return -EOPNOTSUPP ;/* demod access via firmware interface */ -u32 reg = msg[0 ].buf[0 ] <<16 | msg[0 ].buf[1 ] <<8 | + reg = msg[0 ].buf[0 ] <<16 | msg[0 ].buf[1 ] <<8 | msg[0 ].buf[2 ];if (msg[0 ].addr == state->af9033_i2c_addr[1 ])
@@ -395,17 +398,16 @@ static int af9035_i2c_master_xfer(struct ret = -EOPNOTSUPP ; }else if ((msg[0 ].addr == state->af9033_i2c_addr[0 ]) || (msg[0 ].addr == state->af9033_i2c_addr[1 ])) { +if (msg[0 ].len <3 ) +return -EOPNOTSUPP ;/* demod access via firmware interface */ -u32 reg = msg[0 ].buf[0 ] <<16 | msg[0 ].buf[1 ] <<8 | + reg = msg[0 ].buf[0 ] <<16 | msg[0 ].buf[1 ] <<8 | msg[0 ].buf[2 ];if (msg[0 ].addr == state->af9033_i2c_addr[1 ]) reg |=0x100000 ; - ret = (msg[0 ].len >=3 ) ?af9035_wr_regs (d, reg, - &msg[0 ].buf[3 ], - msg[0 ].len -3 ) - : -EOPNOTSUPP ; + ret =af9035_wr_regs (d, reg, &msg[0 ].buf[3 ], msg[0 ].len -3 ); }else {/* I2C write */ u8 buf[MAX_XFER_SIZE ];
Greg Kroah-Hartman
maintainerPATCH 166/186 media: dw2102: Fix null-ptr-deref in dw2102_i2c_transfer()
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Shurong <[email protected]>
[ Upstream commit 5ae544d94abc8ff77b1b9bf8774def3fa5689b5b ]
In dw2102_i2c_transfer, msg is controlled by user. When msg[i].buf is null and msg[i].len is zero, former checks on msg[i].buf would be passed. Malicious data finally reach dw2102_i2c_transfer. If accessing msg[i].buf[0] without sanity check, null ptr deref would happen. We add check on msg[i].len to prevent crash.
Similar commit:
commit 950e252cb469
("[media] dw2102: limit messages to buffer size")
--- drivers/media/usb/dvb-usb/dw2102.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/media/usb/dvb-usb/dw2102.c +24 -0
@@ -133,6 +133,10 @@ static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],switch (num) {case 2 : +if (msg[0 ].len <1 ) { + num = -EOPNOTSUPP ; +break ; + }/* read stv0299 register */ value = msg[0 ].buf[0 ];/* register */ for (i =0 ; i < msg[1 ].len; i++) {
@@ -144,6 +148,10 @@ static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],case 1 :switch (msg[0 ].addr) {case 0x68 : +if (msg[0 ].len <2 ) { + num = -EOPNOTSUPP ; +break ; + }/* write to stv0299 register */ buf6[0 ] =0x2a ; buf6[1 ] = msg[0 ].buf[0 ];
@@ -153,6 +161,10 @@ static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],break ;case 0x60 :if (msg[0 ].flags ==0 ) { +if (msg[0 ].len <4 ) { + num = -EOPNOTSUPP ; +break ; + }/* write to tuner pll */ buf6[0 ] =0x2c ; buf6[1 ] =5 ;
@@ -164,6 +176,10 @@ static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],dw210x_op_rw (d->udev,0xb2 ,0 ,0 , buf6,7 ,DW210X_WRITE_MSG ); }else { +if (msg[0 ].len <1 ) { + num = -EOPNOTSUPP ; +break ; + }/* read from tuner */ dw210x_op_rw (d->udev,0xb5 ,0 ,0 , buf6,1 ,DW210X_READ_MSG );
@@ -171,12 +187,20 @@ static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], }break ;case (DW2102_RC_QUERY ): +if (msg[0 ].len <2 ) { + num = -EOPNOTSUPP ; +break ; + }dw210x_op_rw (d->udev,0xb8 ,0 ,0 , buf6,2 ,DW210X_READ_MSG ); msg[0 ].buf[0 ] = buf6[0 ]; msg[0 ].buf[1 ] = buf6[1 ];break ;case (DW2102_VOLTAGE_CTRL ): +if (msg[0 ].len <1 ) { + num = -EOPNOTSUPP ; +break ; + } buf6[0 ] =0x30 ; buf6[1 ] = msg[0 ].buf[0 ]; dw210x_op_rw(d->udev, 0xb2, 0, 0,
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 167/186 media: af9005: Fix null-ptr-deref in af9005_i2c_xfer
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Shurong <[email protected]>
[ Upstream commit f4ee84f27625ce1fdf41e8483fa0561a1b837d10 ]
In af9005_i2c_xfer, msg is controlled by user. When msg[i].buf is null and msg[i].len is zero, former checks on msg[i].buf would be passed. Malicious data finally reach af9005_i2c_xfer. If accessing msg[i].buf[0] without sanity check, null ptr deref would happen. We add check on msg[i].len to prevent crash.
Similar commit:
commit 0ed554fd769a
("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")
--- drivers/media/usb/dvb-usb/af9005.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/media/usb/dvb-usb/af9005.c +5 -0
@@ -431,6 +431,10 @@ static int af9005_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],if (ret ==0 ) ret =2 ; }else { +if (msg[0 ].len <2 ) { + ret = -EOPNOTSUPP ; + goto unlock; + }/* write one or more registers */ reg = msg[0 ].buf[0 ]; addr = msg[0 ].addr;
@@ -440,6 +444,7 @@ static int af9005_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], ret =1 ; } +unlock:mutex_unlock (&d->i2c_mutex);return ret; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 168/186 media: anysee: fix null-ptr-deref in anysee_master_xfer
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Shurong <[email protected]>
[ Upstream commit c30411266fd67ea3c02a05c157231654d5a3bdc9 ]
In anysee_master_xfer, msg is controlled by user. When msg[i].buf is null and msg[i].len is zero, former checks on msg[i].buf would be passed. Malicious data finally reach anysee_master_xfer. If accessing msg[i].buf[0] without sanity check, null ptr deref would happen. We add check on msg[i].len to prevent crash.
Similar commit:
commit 0ed554fd769a
("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")
--- drivers/media/usb/dvb-usb-v2/anysee.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/dvb-usb-v2/anysee.c +1 -1
@@ -211,7 +211,7 @@ static int anysee_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msg,while (i < num) {if (num > i +1 && (msg[i+1 ].flags &I2C_M_RD )) { -if (msg[i].len >2 || msg[i+1 ].len >60 ) { +if (msg[i].len !=2 || msg[i +1 ].len >60 ) { ret = -EOPNOTSUPP ;break ; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 169/186 media: az6007: Fix null-ptr-deref in az6007_i2c_xfer()
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Shurong <[email protected]>
[ Upstream commit 1047f9343011f2cedc73c64829686206a7e9fc3f ]
In az6007_i2c_xfer, msg is controlled by user. When msg[i].buf is null and msg[i].len is zero, former checks on msg[i].buf would be passed. Malicious data finally reach az6007_i2c_xfer. If accessing msg[i].buf[0] without sanity check, null ptr deref would happen. We add check on msg[i].len to prevent crash.
Similar commit:
commit 0ed554fd769a
("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")
--- drivers/media/usb/dvb-usb-v2/az6007.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/media/usb/dvb-usb-v2/az6007.c +8 -0
@@ -796,6 +796,10 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],if (az6007_xfer_debug)printk (KERN_DEBUG "az6007: I2C W addr=0x%x len=%d\n" , addr, msgs[i].len); +if (msgs[i].len <1 ) { + ret = -EIO ; + goto err; + } req =AZ6007_I2C_WR ; index = msgs[i].buf[0 ]; value = addr | (1 <<8 );
@@ -810,6 +814,10 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],if (az6007_xfer_debug)printk (KERN_DEBUG "az6007: I2C R addr=0x%x len=%d\n" , addr, msgs[i].len); +if (msgs[i].len <1 ) { + ret = -EIO ; + goto err; + } req =AZ6007_I2C_RD ; index = msgs[i].buf[0 ]; value = addr;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 170/186 iio: core: Use min() instead of min_t() to make code more robust
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit cb1d17535061ca295903f97f5cb0af9db719c02c ]
min() has strict type checking and preferred over min_t() for unsigned types to avoid overflow. Here it's unclear why min_t() was chosen since both variables are of the same type. In any case update to use min().
--- drivers/iio/industrialio-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/industrialio-core.c +1 -1
@@ -328,7 +328,7 @@ static ssize_t iio_debugfs_write_reg(struct file *file,char buf[80 ];int ret; - count =min_t (size_t, count, (sizeof (buf)-1 )); + count =min (count,sizeof (buf) -1 );if (copy_from_user (buf, userbuf, count))return -EFAULT ;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 171/186 media: tuners: qt1010: replace BUG_ON with a regular error
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
[ Upstream commit ee630b29ea44d1851bb6c903f400956604834463 ]
BUG_ON is unnecessary here, and in addition it confuses smatch. Replacing this with an error return help resolve this smatch warning:
drivers/media/tuners/qt1010.c:350 qt1010_init() error: buffer overflow 'i2c_data' 34 <= 34
--- drivers/media/tuners/qt1010.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/media/tuners/qt1010.c +6 -5
@@ -351,11 +351,12 @@ static int qt1010_init(struct dvb_frontend *fe)else valptr = &tmpval; -BUG_ON (i >=ARRAY_SIZE (i2c_data) -1 ); - - err =qt1010_init_meas1 (priv, i2c_data[i+1 ].reg, - i2c_data[i].reg, - i2c_data[i].val, valptr); +if (i >=ARRAY_SIZE (i2c_data) -1 ) + err = -EIO ; +else + err =qt1010_init_meas1 (priv, i2c_data[i +1 ].reg, + i2c_data[i].reg, + i2c_data[i].val, valptr); i++;break ; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 172/186 media: pci: cx23885: replace BUG with error return
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
[ Upstream commit 2e1796fd4904fdd6062a8e4589778ea899ea0c8d ]
It was completely unnecessary to use BUG in buffer_prepare(). Just replace it with an error return. This also fixes a smatch warning:
drivers/media/pci/cx23885/cx23885-video.c:422 buffer_prepare() error: uninitialized symbol 'ret'.
--- drivers/media/pci/cx23885/cx23885-video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/cx23885/cx23885-video.c +1 -1
@@ -418,7 +418,7 @@ static int buffer_prepare(struct vb2_buffer *vb) dev->height >> 1);break ;default : -BUG (); +return -EINVAL ;/* should not happen */ } dprintk(2, "[%p/%d] buffer_init - %dx%d %dbpp \"%s\" - dma=0x%08lx\n", buf, buf->vb.vb2_buf.index,
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 173/186 usb: gadget: fsl_qe_udc: validate endpoint index for ch9 udc
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
[ Upstream commit ce9daa2efc0872a9a68ea51dc8000df05893ef2e ]
We should verify the bound of the array to assure that host may not manipulate the index to point past endpoint array.
--- drivers/usb/gadget/udc/fsl_qe_udc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/gadget/udc/fsl_qe_udc.c +2 -0
@@ -1954,6 +1954,8 @@ static void ch9getstatus(struct qe_udc *udc, u8 request_type, u16 value, }else if ((request_type &USB_RECIP_MASK ) ==USB_RECIP_ENDPOINT ) {/* Get endpoint status */ int pipe = index &USB_ENDPOINT_NUMBER_MASK ; +if (pipe >=USB_MAX_ENDPOINTS ) + goto stall;struct qe_ep *target_ep = &udc->eps[pipe];u16 usep;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 174/186 scsi: target: iscsi: Fix buffer overflow in lio_target_nacl_info_show()
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konstantin Shelekhin <[email protected]>
[ Upstream commit 801f287c93ff95582b0a2d2163f12870a2f076d4 ]
The function lio_target_nacl_info_show() uses sprintf() in a loop to print details for every iSCSI connection in a session without checking for the buffer length. With enough iSCSI connections it's possible to overflow the buffer provided by configfs and corrupt the memory.
This patch replaces sprintf() with sysfs_emit_at() that checks for buffer boundries.
--- drivers/target/iscsi/iscsi_target_configfs.c | 54 ++++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-)
drivers/target/iscsi/iscsi_target_configfs.c +27 -27
@@ -516,102 +516,102 @@ static ssize_t lio_target_nacl_info_show(struct config_item *item, char *page)spin_lock_bh (&se_nacl->nacl_sess_lock); se_sess = se_nacl->nacl_sess;if (!se_sess) { - rb +=sprintf (page+rb,"No active iSCSI Session for Initiator" + rb +=sysfs_emit_at (page, rb,"No active iSCSI Session for Initiator" " Endpoint: %s\n" , se_nacl->initiatorname); }else { sess = se_sess->fabric_sess_ptr; - rb +=sprintf (page+rb,"InitiatorName: %s\n" , + rb +=sysfs_emit_at (page, rb,"InitiatorName: %s\n" , sess->sess_ops->InitiatorName); - rb +=sprintf (page+rb,"InitiatorAlias: %s\n" , + rb +=sysfs_emit_at (page, rb,"InitiatorAlias: %s\n" , sess->sess_ops->InitiatorAlias); - rb +=sprintf (page+rb, + rb +=sysfs_emit_at (page, rb,"LIO Session ID: %u ISID: 0x%6ph TSIH: %hu " , sess->sid, sess->isid, sess->tsih); - rb +=sprintf (page+rb,"SessionType: %s\n" , + rb +=sysfs_emit_at (page, rb,"SessionType: %s\n" , (sess->sess_ops->SessionType) ?"Discovery" :"Normal" ); - rb +=sprintf (page+rb,"Session State: " ); + rb +=sysfs_emit_at (page, rb,"Session State: " );switch (sess->session_state) {case TARG_SESS_STATE_FREE : - rb +=sprintf (page+rb,"TARG_SESS_FREE\n" ); + rb +=sysfs_emit_at (page, rb,"TARG_SESS_FREE\n" );break ;case TARG_SESS_STATE_ACTIVE : - rb +=sprintf (page+rb,"TARG_SESS_STATE_ACTIVE\n" ); + rb +=sysfs_emit_at (page, rb,"TARG_SESS_STATE_ACTIVE\n" );break ;case TARG_SESS_STATE_LOGGED_IN : - rb +=sprintf (page+rb,"TARG_SESS_STATE_LOGGED_IN\n" ); + rb +=sysfs_emit_at (page, rb,"TARG_SESS_STATE_LOGGED_IN\n" );break ;case TARG_SESS_STATE_FAILED : - rb +=sprintf (page+rb,"TARG_SESS_STATE_FAILED\n" ); + rb +=sysfs_emit_at (page, rb,"TARG_SESS_STATE_FAILED\n" );break ;case TARG_SESS_STATE_IN_CONTINUE : - rb +=sprintf (page+rb,"TARG_SESS_STATE_IN_CONTINUE\n" ); + rb +=sysfs_emit_at (page, rb,"TARG_SESS_STATE_IN_CONTINUE\n" );break ;default : - rb +=sprintf (page+rb,"ERROR: Unknown Session" + rb +=sysfs_emit_at (page, rb,"ERROR: Unknown Session" " State!\n" );break ; } - rb +=sprintf (page+rb,"---------------------[iSCSI Session" + rb +=sysfs_emit_at (page, rb,"---------------------[iSCSI Session" " Values]-----------------------\n" ); - rb +=sprintf (page+rb," CmdSN/WR : CmdSN/WC : ExpCmdSN" + rb +=sysfs_emit_at (page, rb," CmdSN/WR : CmdSN/WC : ExpCmdSN" " : MaxCmdSN : ITT : TTT\n" ); max_cmd_sn = (u32 )atomic_read (&sess->max_cmd_sn); - rb +=sprintf (page+rb," 0x%08x 0x%08x 0x%08x 0x%08x" + rb +=sysfs_emit_at (page, rb," 0x%08x 0x%08x 0x%08x 0x%08x" " 0x%08x 0x%08x\n" , sess->cmdsn_window, (max_cmd_sn - sess->exp_cmd_sn) +1 , sess->exp_cmd_sn, max_cmd_sn, sess->init_task_tag, sess->targ_xfer_tag); - rb +=sprintf (page+rb,"----------------------[iSCSI" + rb +=sysfs_emit_at (page, rb,"----------------------[iSCSI" " Connections]-------------------------\n" );spin_lock (&sess->conn_lock);list_for_each_entry (conn, &sess->sess_conn_list, conn_list) { - rb +=sprintf (page+rb,"CID: %hu Connection" + rb +=sysfs_emit_at (page, rb,"CID: %hu Connection" " State: " , conn->cid);switch (conn->conn_state) {case TARG_CONN_STATE_FREE : - rb +=sprintf (page+rb, + rb +=sysfs_emit_at (page, rb,"TARG_CONN_STATE_FREE\n" );break ;case TARG_CONN_STATE_XPT_UP : - rb +=sprintf (page+rb, + rb +=sysfs_emit_at (page, rb,"TARG_CONN_STATE_XPT_UP\n" );break ;case TARG_CONN_STATE_IN_LOGIN : - rb +=sprintf (page+rb, + rb +=sysfs_emit_at (page, rb,"TARG_CONN_STATE_IN_LOGIN\n" );break ;case TARG_CONN_STATE_LOGGED_IN : - rb +=sprintf (page+rb, + rb +=sysfs_emit_at (page, rb,"TARG_CONN_STATE_LOGGED_IN\n" );break ;case TARG_CONN_STATE_IN_LOGOUT : - rb +=sprintf (page+rb, + rb +=sysfs_emit_at (page, rb,"TARG_CONN_STATE_IN_LOGOUT\n" );break ;case TARG_CONN_STATE_LOGOUT_REQUESTED : - rb +=sprintf (page+rb, + rb +=sysfs_emit_at (page, rb,"TARG_CONN_STATE_LOGOUT_REQUESTED\n" );break ;case TARG_CONN_STATE_CLEANUP_WAIT : - rb +=sprintf (page+rb, + rb +=sysfs_emit_at (page, rb,"TARG_CONN_STATE_CLEANUP_WAIT\n" );break ;default : - rb +=sprintf (page+rb, + rb +=sysfs_emit_at (page, rb,"ERROR: Unknown Connection State!\n" );break ; } - rb +=sprintf (page+rb," Address %pISc %s" , &conn->login_sockaddr, + rb +=sysfs_emit_at (page, rb," Address %pISc %s" , &conn->login_sockaddr, (conn->network_transport ==ISCSI_TCP ) ?"TCP" :"SCTP" ); - rb +=sprintf (page+rb," StatSN: 0x%08x\n" , + rb +=sysfs_emit_at (page, rb," StatSN: 0x%08x\n" , conn->stat_sn); }spin_unlock (&sess->conn_lock);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 175/186 serial: cpm_uart: Avoid suspicious locking
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Leroy <[email protected]>
[ Upstream commit 36ef11d311f405e55ad8e848c19b212ff71ef536 ]
CHECK drivers/tty/serial/cpm_uart/cpm_uart_core.cdrivers/tty/serial/cpm_uart/cpm_uart_core.c:1271:39: warning: context imbalance in 'cpm_uart_console_write' - unexpected unlock
Allthough 'nolock' is not expected to change, sparse find the following form suspicious:
if (unlikely(nolock)) {
local_irq_save(flags);
} else {
spin_lock_irqsave(&pinfo->port.lock, flags);
}
cpm_uart_early_write(pinfo, s, count, true);
if (unlikely(nolock)) {
local_irq_restore(flags);
} else {
spin_unlock_irqrestore(&pinfo->port.lock, flags);
}Rewrite it a more obvious form:
if (unlikely(oops_in_progress)) {
local_irq_save(flags);
cpm_uart_early_write(pinfo, s, count, true);
local_irq_restore(flags);
} else {
spin_lock_irqsave(&pinfo->port.lock, flags);
cpm_uart_early_write(pinfo, s, count, true);
spin_unlock_irqrestore(&pinfo->port.lock, flags);
}--- drivers/tty/serial/cpm_uart/cpm_uart_core.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/tty/serial/cpm_uart/cpm_uart_core.c +4 -9
@@ -1283,19 +1283,14 @@ static void cpm_uart_console_write(struct console *co, const char *s, {struct uart_cpm_port *pinfo = &cpm_uart_ports[co->index];unsigned long flags; -int nolock = oops_in_progress; -if (unlikely (nolock)) { +if (unlikely (oops_in_progress)) {local_irq_save (flags); - }else { -spin_lock_irqsave (&pinfo->port.lock, flags); - } - -cpm_uart_early_write (pinfo, s, count, true); - -if (unlikely (nolock)) { +cpm_uart_early_write (pinfo, s, count, true);local_irq_restore (flags); }else { +spin_lock_irqsave (&pinfo->port.lock, flags); +cpm_uart_early_write (pinfo, s, count, true);spin_unlock_irqrestore (&pinfo->port.lock, flags); } }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 176/186 kobject: Add sanity check for kset->kobj.ktype in kset_register()
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhen Lei <[email protected]>
[ Upstream commit 4d0fe8c52bb3029d83e323c961221156ab98680b ]
When I register a kset in the following way:
static struct kset my_kset;
kobject_set_name(&my_kset.kobj, "my_kset");
ret = kset_register(&my_kset);A null pointer dereference exception is occurred:
[ 4453.568337] Unable to handle kernel NULL pointer dereference at \ virtual address 0000000000000028 ... ... [ 4453.810361] Call trace: [ 4453.813062] kobject_get_ownership+0xc/0x34 [ 4453.817493] kobject_add_internal+0x98/0x274 [ 4453.822005] kset_register+0x5c/0xb4 [ 4453.825820] my_kobj_init+0x44/0x1000 [my_kset]
... ...
Because I didn't initialize my_kset.kobj.ktype.
According to the description in Documentation/core-api/kobject.rst:
- A ktype is the type of object that embeds a kobject. Every structure that embeds a kobject needs a corresponding ktype.
So add sanity check to make sure kset->kobj.ktype is not NULL.
--- lib/kobject.c | 5 +++++ 1 file changed, 5 insertions(+)
lib/kobject.c +5 -0
@@ -814,6 +814,11 @@ int kset_register(struct kset *k)if (!k)return -EINVAL ; +if (!k->kobj.ktype) { +pr_err ("must have a ktype to be initialized properly!\n" ); +return -EINVAL ; + } +kset_init (k); err =kobject_add_internal (&k->kobj);if (err)
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 177/186 md/raid1: fix error: ISO C90 forbids mixed declarations
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nigel Croxon <[email protected]>
[ Upstream commit df203da47f4428bc286fc99318936416253a321c ]
There is a compile error when this commit is added:
md: raid1: fix potential OOB in raid1_remove_disk()
drivers/md/raid1.c: In function 'raid1_remove_disk':drivers/md/raid1.c:1844:9: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
1844 | struct raid1_info *p = conf->mirrors + number;
| ^~~~~~
That's because the new code was inserted before the struct. The change is move the struct command above this commit.
--- drivers/md/raid1.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/md/raid1.c +1 -2
@@ -1775,12 +1775,11 @@ static int raid1_remove_disk(struct mddev *mddev, struct md_rdev *rdev)struct r1conf *conf = mddev->private;int err =0 ;int number = rdev->raid_disk; +struct raid1_info *p = conf->mirrors + number;if (unlikely (number >= conf->raid_disks)) goto abort; -struct raid1_info *p = conf->mirrors + number; -if (rdev != p->rdev) p = conf->mirrors + conf->raid_disks + number;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 178/186 attr: block mode changes of symlinks
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
commit 5d1f903f75a80daa4dfb3d84e114ec8ecbf29956 upstream.
Changing the mode of symlinks is meaningless as the vfs doesn't take the mode of a symlink into account during path lookup permission checking.
However, the vfs doesn't block mode changes on symlinks. This however, has lead to an untenable mess roughly classifiable into the following two categories:
(1) Filesystems that don't implement a i_op->setattr() for symlinks.
Such filesystems may or may not know that without i_op->setattr() defined, notify_change() falls back to simple_setattr() causing the inode's mode in the inode cache to be changed.
That's a generic issue as this will affect all non-size changing inode attributes including ownership changes.
Example: afs
(2) Filesystems that fail with EOPNOTSUPP but change the mode of the symlink nonetheless.
Some filesystems will happily update the mode of a symlink but still return EOPNOTSUPP. This is the biggest source of confusion for userspace.
The EOPNOTSUPP in this case comes from POSIX ACLs. Specifically it comes from filesystems that call posix_acl_chmod(), e.g., btrfs via
if (!err && attr->ia_valid & ATTR_MODE)
err = posix_acl_chmod(idmap, dentry, inode->i_mode);
Filesystems including btrfs don't implement i_op->set_acl() so posix_acl_chmod() will report EOPNOTSUPP.
When posix_acl_chmod() is called, most filesystems will have finished updating the inode.
Perversely, this has the consequences that this behavior may depend on two kconfig options and mount options:
* CONFIG_POSIX_ACL={y,n}
* CONFIG_${FSTYPE}_POSIX_ACL={y,n}
* Opt_acl, Opt_noacl
Example: btrfs, ext4, xfs
The only way to change the mode on a symlink currently involves abusing an O_PATH file descriptor in the following manner:
fd = openat(-1, "/path/to/link", O_CLOEXEC | O_PATH | O_NOFOLLOW);
char path[PATH_MAX];
snprintf(path, sizeof(path), "/proc/self/fd/%d", fd);
chmod(path, 0000);But for most major filesystems with POSIX ACL support such as btrfs, ext4, ceph, tmpfs, xfs and others this will fail with EOPNOTSUPP with the mode still updated due to the aforementioned posix_acl_chmod() nonsense.
So, given that for all major filesystems this would fail with EOPNOTSUPP and that both glibc (cf. [1]) and musl (cf. [2]) outright block mode changes on symlinks we should just try and block mode changes on symlinks directly in the vfs and have a clean break with this nonsense.
If this causes any regressions, we do the next best thing and fix up all filesystems that do return EOPNOTSUPP with the mode updated to not call posix_acl_chmod() on symlinks.
But as usual, let's try the clean cut solution first. It's a simple patch that can be easily reverted. Not marking this for backport as I'll do that manually if we're reasonably sure that this works and there are no strong objections.
We could block this in chmod_common() but it's more appropriate to do it notify_change() as it will also mean that we catch filesystems that change symlink permissions explicitly or accidently.
Similar proposals were floated in the past as in [3] and [4] and again recently in [5]. There's also a couple of bugs about this inconsistency as in [6] and [7].
Message-Id: <[email protected]>
--- fs/attr.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
fs/attr.c +18 -2
@@ -235,9 +235,25 @@ int notify_change(struct dentry * dentry }if ((ia_valid &ATTR_MODE )) { -umode_t amode = attr->ia_mode; +/* +* Don't allow changing the mode of symlinks: +* +* (1) The vfs doesn't take the mode of symlinks into account +* during permission checking. +* (2) This has never worked correctly. Most major filesystems +* did return EOPNOTSUPP due to interactions with POSIX ACLs +* but did still updated the mode of the symlink. +* This inconsistency led system call wrapper providers such +* as libc to block changing the mode of symlinks with +* EOPNOTSUPP already. +* (3) To even do this in the first place one would have to use +* specific file descriptors and quite some effort. +*/ +if (S_ISLNK (inode->i_mode)) +return -EOPNOTSUPP ; +/* Flag setting protected by i_mutex */ -if (is_sxid (amode)) +if (is_sxid (attr->ia_mode)) inode->i_flags &= ~S_NOSEC ; }
Greg Kroah-Hartman
maintainerPATCH 179/186 btrfs: fix lockdep splat and potential deadlock after failure running delayed items
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit e110f8911ddb93e6f55da14ccbbe705397b30d0b upstream.
When running delayed items we are holding a delayed node's mutex and then we will attempt to modify a subvolume btree to insert/update/delete the delayed items. However if have an error during the insertions for example, btrfs_insert_delayed_items() may return with a path that has locked extent buffers (a leaf at the very least), and then we attempt to release the delayed node at __btrfs_run_delayed_items(), which requires taking the delayed node's mutex, causing an ABBA type of deadlock. This was reported by syzbot and the lockdep splat is the following:
WARNING: possible circular locking dependency detected
6.5.0-rc7-syzkaller-00024-g93f5de5f648d #0 Not tainted
------------------------------------------------------
syz-executor.2/13257 is trying to acquire lock:
ffff88801835c0c0 (&delayed_node->mutex){+.+.}-{3:3}, at: __btrfs_release_delayed_node+0x9a/0xaa0 fs/btrfs/delayed-inode.c:256
but task is already holding lock:
ffff88802a5ab8e8 (btrfs-tree-00){++++}-{3:3}, at: __btrfs_tree_lock+0x3c/0x2a0 fs/btrfs/locking.c:198
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #1 (btrfs-tree-00){++++}-{3:3}:
__lock_release kernel/locking/lockdep.c:5475 [inline]
lock_release+0x36f/0x9d0 kernel/locking/lockdep.c:5781
up_write+0x79/0x580 kernel/locking/rwsem.c:1625
btrfs_tree_unlock_rw fs/btrfs/locking.h:189 [inline]
btrfs_unlock_up_safe+0x179/0x3b0 fs/btrfs/locking.c:239
search_leaf fs/btrfs/ctree.c:1986 [inline]
btrfs_search_slot+0x2511/0x2f80 fs/btrfs/ctree.c:2230
btrfs_insert_empty_items+0x9c/0x180 fs/btrfs/ctree.c:4376
btrfs_insert_delayed_item fs/btrfs/delayed-inode.c:746 [inline]
btrfs_insert_delayed_items fs/btrfs/delayed-inode.c:824 [inline]
__btrfs_commit_inode_delayed_items+0xd24/0x2410 fs/btrfs/delayed-inode.c:1111
__btrfs_run_delayed_items+0x1db/0x430 fs/btrfs/delayed-inode.c:1153
flush_space+0x269/0xe70 fs/btrfs/space-info.c:723
btrfs_async_reclaim_metadata_space+0x106/0x350 fs/btrfs/space-info.c:1078
process_one_work+0x92c/0x12c0 kernel/workqueue.c:2600
worker_thread+0xa63/0x1210 kernel/workqueue.c:2751
kthread+0x2b8/0x350 kernel/kthread.c:389
ret_from_fork+0x2e/0x60 arch/x86/kernel/process.c:145
ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304-> #0 (&delayed_node->mutex){+.+.}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3142 [inline]
check_prevs_add kernel/locking/lockdep.c:3261 [inline]
validate_chain kernel/locking/lockdep.c:3876 [inline]
__lock_acquire+0x39ff/0x7f70 kernel/locking/lockdep.c:5144
lock_acquire+0x1e3/0x520 kernel/locking/lockdep.c:5761
__mutex_lock_common+0x1d8/0x2530 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x1b/0x20 kernel/locking/mutex.c:799
__btrfs_release_delayed_node+0x9a/0xaa0 fs/btrfs/delayed-inode.c:256
btrfs_release_delayed_node fs/btrfs/delayed-inode.c:281 [inline]
__btrfs_run_delayed_items+0x2b5/0x430 fs/btrfs/delayed-inode.c:1156
btrfs_commit_transaction+0x859/0x2ff0 fs/btrfs/transaction.c:2276
btrfs_sync_file+0xf56/0x1330 fs/btrfs/file.c:1988
vfs_fsync_range fs/sync.c:188 [inline]
vfs_fsync fs/sync.c:202 [inline]
do_fsync fs/sync.c:212 [inline]
__do_sys_fsync fs/sync.c:220 [inline]
__se_sys_fsync fs/sync.c:218 [inline]
__x64_sys_fsync+0x196/0x1e0 fs/sync.c:218
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcdother info that might help us debug this:
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(btrfs-tree-00);
lock(&delayed_node->mutex);
lock(btrfs-tree-00);
lock(&delayed_node->mutex);*** DEADLOCK ***
3 locks held by syz-executor.2/13257:
#0: ffff88802c1ee370 (btrfs_trans_num_writers){++++}-{0:0}, at: spin_unlock include/linux/spinlock.h:391 [inline] #0: ffff88802c1ee370 (btrfs_trans_num_writers){++++}-{0:0}, at: join_transaction+0xb87/0xe00 fs/btrfs/transaction.c:287 #1: ffff88802c1ee398 (btrfs_trans_num_extwriters){++++}-{0:0}, at: join_transaction+0xbb2/0xe00 fs/btrfs/transaction.c:288 #2: ffff88802a5ab8e8 (btrfs-tree-00){++++}-{3:3}, at: __btrfs_tree_lock+0x3c/0x2a0 fs/btrfs/locking.c:198
stack backtrace: CPU: 0 PID: 13257 Comm: syz-executor.2 Not tainted 6.5.0-rc7-syzkaller-00024-g93f5de5f648d #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/26/2023 Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106 check_noncircular+0x375/0x4a0 kernel/locking/lockdep.c:2195 check_prev_add kernel/locking/lockdep.c:3142 [inline] check_prevs_add kernel/locking/lockdep.c:3261 [inline] validate_chain kernel/locking/lockdep.c:3876 [inline] __lock_acquire+0x39ff/0x7f70 kernel/locking/lockdep.c:5144 lock_acquire+0x1e3/0x520 kernel/locking/lockdep.c:5761 __mutex_lock_common+0x1d8/0x2530 kernel/locking/mutex.c:603 __mutex_lock kernel/locking/mutex.c:747 [inline] mutex_lock_nested+0x1b/0x20 kernel/locking/mutex.c:799 __btrfs_release_delayed_node+0x9a/0xaa0 fs/btrfs/delayed-inode.c:256 btrfs_release_delayed_node fs/btrfs/delayed-inode.c:281 [inline] __btrfs_run_delayed_items+0x2b5/0x430 fs/btrfs/delayed-inode.c:1156 btrfs_commit_transaction+0x859/0x2ff0 fs/btrfs/transaction.c:2276 btrfs_sync_file+0xf56/0x1330 fs/btrfs/file.c:1988 vfs_fsync_range fs/sync.c:188 [inline] vfs_fsync fs/sync.c:202 [inline] do_fsync fs/sync.c:212 [inline] __do_sys_fsync fs/sync.c:220 [inline] __se_sys_fsync fs/sync.c:218 [inline] __x64_sys_fsync+0x196/0x1e0 fs/sync.c:218 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f3ad047cae9 Code: 28 00 00 00 75 (...) RSP: 002b:00007f3ad12510c8 EFLAGS: 00000246 ORIG_RAX: 000000000000004a RAX: ffffffffffffffda RBX: 00007f3ad059bf80 RCX: 00007f3ad047cae9 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000005 RBP: 00007f3ad04c847a R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 000000000000000b R14: 00007f3ad059bf80 R15: 00007ffe56af92f8 </TASK> ------------[ cut here ]------------
Fix this by releasing the path before releasing the delayed node in the error path at __btrfs_run_delayed_items().
--- fs/btrfs/delayed-inode.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
fs/btrfs/delayed-inode.c +16 -3
@@ -1205,20 +1205,33 @@ static int __btrfs_run_delayed_items(str ret =__btrfs_commit_inode_delayed_items (trans, path, curr_node);if (ret) { -btrfs_release_delayed_node (curr_node); - curr_node =NULL ;btrfs_abort_transaction (trans, ret);break ; } prev_node = curr_node; curr_node =btrfs_next_delayed_node (curr_node); +/* +* See the comment below about releasing path before releasing +* node. If the commit of delayed items was successful the path +* should always be released, but in case of an error, it may +* point to locked extent buffers (a leaf at the very least). +*/ +ASSERT (path->nodes[0 ] ==NULL );btrfs_release_delayed_node (prev_node); } +/* +* Release the path to avoid a potential deadlock and lockdep splat when +* releasing the delayed node, as that requires taking the delayed node's +* mutex. If another task starts running delayed items before we take +* the mutex, it will first lock the mutex and then it may try to lock +* the same btree path (leaf). +*/ +btrfs_free_path (path); +if (curr_node)btrfs_release_delayed_node (curr_node); -btrfs_free_path (path); trans->block_rsv = block_rsv;return ret;
Greg Kroah-Hartman
maintainerPATCH 180/186 nfsd: fix change_info in NFSv4 RENAME replies
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Layton <[email protected]>
commit fdd2630a7398191e84822612e589062063bd4f3d upstream.
nfsd sends the transposed directory change info in the RENAME reply. The source directory is in save_fh and the target is in current_fh.
--- fs/nfsd/nfs4proc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfsd/nfs4proc.c +2 -2
@@ -870,8 +870,8 @@ nfsd4_rename(struct svc_rqst *rqstp, str rename->rn_tname, rename->rn_tnamelen);if (status)return status; -set_change_info (&rename->rn_sinfo, &cstate->current_fh); -set_change_info (&rename->rn_tinfo, &cstate->save_fh); +set_change_info (&rename->rn_sinfo, &cstate->save_fh); +set_change_info (&rename->rn_tinfo, &cstate->current_fh);return nfs_ok; }
Greg Kroah-Hartman
maintainerPATCH 181/186 mtd: rawnand: brcmnand: Fix crash during the panic_write
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: William Zhang <[email protected]>
commit e66dd317194daae0475fe9e5577c80aa97f16cb9 upstream.
When executing a NAND command within the panic write path, wait for any pending command instead of calling BUG_ON to avoid crashing while already crashing.
--- drivers/mtd/nand/brcmnand/brcmnand.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/mtd/nand/brcmnand/brcmnand.c +11 -1
@@ -1271,7 +1271,17 @@ static void brcmnand_send_cmd(struct brcdev_dbg (ctrl->dev,"send native cmd %d addr 0x%llx\n" , cmd, cmd_addr); -BUG_ON (ctrl->cmd_pending !=0 ); +/* +* If we came here through _panic_write and there is a pending +* command, try to wait for it. If it times out, rather than +* hitting BUG_ON, just return so we don't crash while crashing. +*/ +if (oops_in_progress) { +if (ctrl->cmd_pending && +bcmnand_ctrl_poll_status (ctrl,NAND_CTRL_RDY ,NAND_CTRL_RDY ,0 )) +return ; + }else +BUG_ON (ctrl->cmd_pending !=0 ); ctrl->cmd_pending = cmd; ret =bcmnand_ctrl_poll_status (ctrl,NAND_CTRL_RDY ,NAND_CTRL_RDY ,0 );
Greg Kroah-Hartman
maintainerPATCH 182/186 mtd: rawnand: brcmnand: Fix potential false time out warning
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: William Zhang <[email protected]>
commit 9cc0a598b944816f2968baf2631757f22721b996 upstream.
If system is busy during the command status polling function, the driver may not get the chance to poll the status register till the end of time out and return the premature status. Do a final check after time out happens to ensure reading the correct status.
--- drivers/mtd/nand/brcmnand/brcmnand.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/mtd/nand/brcmnand/brcmnand.c +8 -0
@@ -836,6 +836,14 @@ static int bcmnand_ctrl_poll_status(strucpu_relax (); }while (time_after (limit, jiffies)); +/* +* do a final check after time out in case the CPU was busy and the driver +* did not get enough time to perform the polling to avoid false alarms +*/ + val =brcmnand_read_reg (ctrl,BRCMNAND_INTFC_STATUS ); +if ((val & mask) == expected_val) +return 0 ; +dev_warn (ctrl->dev,"timeout on status poll (expected %x got %x)\n" , expected_val, val & mask);
Greg Kroah-Hartman
maintainerPATCH 183/186 mtd: rawnand: brcmnand: Fix ECC level field setting for v7.2 controller
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: William Zhang <[email protected]>
commit 2ec2839a9062db8a592525a3fdabd42dcd9a3a9b upstream.
v7.2 controller has different ECC level field size and shift in the acc control register than its predecessor and successor controller. It needs to be set specifically.
--- drivers/mtd/nand/brcmnand/brcmnand.c | 74 +++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 33 deletions(-)
drivers/mtd/nand/brcmnand/brcmnand.c +41 -33
@@ -152,6 +152,7 @@ struct brcmnand_controller {unsigned int max_page_size;const unsigned int *page_sizes;unsigned int max_oob; +u32 ecc_level_shift;u32 features;/* for low-power standby/resume only */
@@ -441,6 +442,34 @@ enum { INTFC_CTLR_READY = BIT(31), }; +/*********************************************************************** +* NAND ACC CONTROL bitfield +* +* Some bits have remained constant throughout hardware revision, while +* others have shifted around. +***********************************************************************/ + +/* Constant for all versions (where supported) */ +enum { +/* See BRCMNAND_HAS_CACHE_MODE */ +ACC_CONTROL_CACHE_MODE =BIT (22 ), + +/* See BRCMNAND_HAS_PREFETCH */ +ACC_CONTROL_PREFETCH =BIT (23 ), + +ACC_CONTROL_PAGE_HIT =BIT (24 ), +ACC_CONTROL_WR_PREEMPT =BIT (25 ), +ACC_CONTROL_PARTIAL_PAGE =BIT (26 ), +ACC_CONTROL_RD_ERASED =BIT (27 ), +ACC_CONTROL_FAST_PGM_RDIN =BIT (28 ), +ACC_CONTROL_WR_ECC =BIT (30 ), +ACC_CONTROL_RD_ECC =BIT (31 ), +}; + +#define ACC_CONTROL_ECC_SHIFT 16 +/* Only for v7.2 */ +#define ACC_CONTROL_ECC_EXT_SHIFT 13 +static inline u32 nand_readreg (struct brcmnand_controller *ctrl,u32 offs) {return brcmnand_readl (ctrl->nand_base + offs);
@@ -544,6 +573,12 @@ static int brcmnand_revision_init(structelse if (of_property_read_bool (ctrl->dev->of_node,"brcm,nand-has-wp" )) ctrl->features |=BRCMNAND_HAS_WP ; +/* v7.2 has different ecc level shift in the acc register */ +if (ctrl->nand_version ==0x0702 ) + ctrl->ecc_level_shift =ACC_CONTROL_ECC_EXT_SHIFT ; +else + ctrl->ecc_level_shift =ACC_CONTROL_ECC_SHIFT ; +return 0 ; }
@@ -697,30 +732,6 @@ static inline int brcmnand_cmd_shift(strreturn 0 ; } -/*********************************************************************** -* NAND ACC CONTROL bitfield -* -* Some bits have remained constant throughout hardware revision, while -* others have shifted around. -***********************************************************************/ - -/* Constant for all versions (where supported) */ -enum { -/* See BRCMNAND_HAS_CACHE_MODE */ -ACC_CONTROL_CACHE_MODE =BIT (22 ), - -/* See BRCMNAND_HAS_PREFETCH */ -ACC_CONTROL_PREFETCH =BIT (23 ), - -ACC_CONTROL_PAGE_HIT =BIT (24 ), -ACC_CONTROL_WR_PREEMPT =BIT (25 ), -ACC_CONTROL_PARTIAL_PAGE =BIT (26 ), -ACC_CONTROL_RD_ERASED =BIT (27 ), -ACC_CONTROL_FAST_PGM_RDIN =BIT (28 ), -ACC_CONTROL_WR_ECC =BIT (30 ), -ACC_CONTROL_RD_ECC =BIT (31 ), -}; -static inline u32 brcmnand_spare_area_mask (struct brcmnand_controller *ctrl) {if (ctrl->nand_version >=0x0702 )
@@ -731,18 +742,15 @@ static inline u32 brcmnand_spare_area_mareturn GENMASK (5 ,0 ); } -#define NAND_ACC_CONTROL_ECC_SHIFT 16 -#define NAND_ACC_CONTROL_ECC_EXT_SHIFT 13 -static inline u32 brcmnand_ecc_level_mask (struct brcmnand_controller *ctrl) {u32 mask = (ctrl->nand_version >=0x0600 ) ?0x1f :0x0f ; - mask <<=NAND_ACC_CONTROL_ECC_SHIFT ; + mask <<=ACC_CONTROL_ECC_SHIFT ;/* v7.2 includes additional ECC levels */ -if (ctrl->nand_version >=0x0702 ) - mask |=0x7 <<NAND_ACC_CONTROL_ECC_EXT_SHIFT ; +if (ctrl->nand_version ==0x0702 ) + mask |=0x7 <<ACC_CONTROL_ECC_EXT_SHIFT ;return mask; }
@@ -756,8 +764,8 @@ static void brcmnand_set_ecc_enabled(strif (en) { acc_control |= ecc_flags;/* enable RD/WR ECC */ - acc_control |= host->hwcfg.ecc_level - <<NAND_ACC_CONTROL_ECC_SHIFT ; + acc_control &= ~brcmnand_ecc_level_mask (ctrl); + acc_control |= host->hwcfg.ecc_level << ctrl->ecc_level_shift; }else { acc_control &= ~ecc_flags;/* disable RD/WR ECC */ acc_control &= ~brcmnand_ecc_level_mask (ctrl);
@@ -2082,7 +2090,7 @@ static int brcmnand_set_cfg(struct brcmn tmp =nand_readreg (ctrl, acc_control_offs); tmp &= ~brcmnand_ecc_level_mask (ctrl); - tmp |= cfg->ecc_level <<NAND_ACC_CONTROL_ECC_SHIFT ; + tmp |= cfg->ecc_level << ctrl->ecc_level_shift; tmp &= ~brcmnand_spare_area_mask (ctrl); tmp |= cfg->spare_area_size;nand_writereg (ctrl, acc_control_offs, tmp);
Greg Kroah-Hartman
maintainerPATCH 184/186 mtd: rawnand: brcmnand: Fix potential out-of-bounds access in oob write
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: William Zhang <[email protected]>
commit 5d53244186c9ac58cb88d76a0958ca55b83a15cd upstream.
When the oob buffer length is not in multiple of words, the oob write function does out-of-bounds read on the oob source buffer at the last iteration. Fix that by always checking length limit on the oob buffer read and fill with 0xff when reaching the end of the buffer to the oob registers.
--- drivers/mtd/nand/brcmnand/brcmnand.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/mtd/nand/brcmnand/brcmnand.c +16 -2
@@ -1229,19 +1229,33 @@ static int write_oob_to_regs(struct brcm const u8 *oob, int sas, int sector_1k) { int tbytes = sas << sector_1k; -int j; +int j, k =0 ; +u32 last =0xffffffff ; +u8 *plast = (u8 *)&last;/* Adjust OOB values for 1K sector size */ if (sector_1k && (i &0x01 )) tbytes =max (0 , tbytes - (int )ctrl->max_oob); tbytes =min_t (int, tbytes, ctrl->max_oob); -for (j =0 ; j < tbytes; j +=4 ) +/* +* tbytes may not be multiple of words. Make sure we don't read out of +* the boundary and stop at last word. +*/ +for (j =0 ; (j +3 ) < tbytes; j +=4 )oob_reg_write (ctrl, j, (oob[j +0 ] <<24 ) | (oob[j +1 ] <<16 ) | (oob[j +2 ] <<8 ) | (oob[j +3 ] <<0 )); + +/* handle the remaing bytes */ +while (j < tbytes) + plast[k++] = oob[j++]; + +if (tbytes &0x3 ) +oob_reg_write (ctrl, (tbytes & ~0x3 ), (__force u32 )cpu_to_be32 (last)); +return tbytes; }
Greg Kroah-Hartman
maintainerPATCH 185/186 net/sched: cls_fw: No longer copy tcf_result on update to avoid use-after-free
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: valis <[email protected]>
commit 76e42ae831991c828cffa8c37736ebfb831ad5ec upstream.
When fw_change() is called on an existing filter, the whole tcf_result struct is always copied into the new instance of the filter.
This causes a problem when updating a filter bound to a class, as tcf_unbind_filter() is always called on the old instance in the success path, decreasing filter_cnt of the still referenced class and allowing it to be deleted, leading to a use-after-free.
Fix this by no longer copying the tcf_result struct from the old filter.
[ Fixed small conflict as 'fnew->ifindex' assignment is not protected by
CONFIG_NET_CLS_IND on upstream since a51486266c3 ]
--- net/sched/cls_fw.c | 1 - 1 file changed, 1 deletion(-)
net/sched/cls_fw.c +0 -1
@@ -281,7 +281,6 @@ static int fw_change(struct net *net, streturn -ENOBUFS ; fnew->id = f->id; - fnew->res = f->res;#ifdef CONFIG_NET_CLS_IND fnew->ifindex = f->ifindex;#endif /* CONFIG_NET_CLS_IND */
Greg Kroah-Hartman
maintainerPATCH 186/186 net/sched: Retire rsvp classifier
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
commit 265b4da82dbf5df04bee5a5d46b7474b1aaf326a upstream.
The rsvp classifier has served us well for about a quarter of a century but has has not been getting much maintenance attention due to lack of known users.
--- net/sched/Kconfig | 28 - net/sched/Makefile | 2 net/sched/cls_rsvp.c | 28 - net/sched/cls_rsvp.h | 779 -------------------------------------------------- net/sched/cls_rsvp6.c | 28 - 5 files changed, 865 deletions(-) delete mode 100644 net/sched/cls_rsvp.c delete mode 100644 net/sched/cls_rsvp.h delete mode 100644 net/sched/cls_rsvp6.c
net/sched/Kconfig +0 -28
@@ -457,34 +457,6 @@ config CLS_U32_MARK ---help--- Say Y here to be able to use netfilter marks as u32 key. -config NET_CLS_RSVP - tristate "IPv4 Resource Reservation Protocol (RSVP)" - select NET_CLS - ---help--- - The Resource Reservation Protocol (RSVP) permits end systems to - request a minimum and maximum data flow rate for a connection; this - is important for real time data such as streaming sound or video. - - Say Y here if you want to be able to classify outgoing packets based - on their RSVP requests. - - To compile this code as a module, choose M here: the - module will be called cls_rsvp. - -config NET_CLS_RSVP6 - tristate "IPv6 Resource Reservation Protocol (RSVP6)" - select NET_CLS - ---help--- - The Resource Reservation Protocol (RSVP) permits end systems to - request a minimum and maximum data flow rate for a connection; this - is important for real time data such as streaming sound or video. - - Say Y here if you want to be able to classify outgoing packets based - on their RSVP requests and you are using the IPv6 protocol. - - To compile this code as a module, choose M here: the - module will be called cls_rsvp6. - config NET_CLS_FLOW tristate "Flow classifier" select NET_CLS
net/sched/Makefile +0 -2
@@ -57,8 +57,6 @@ obj-$(CONFIG_NET_SCH_PIE) += sch_pie.o obj-$(CONFIG_NET_CLS_U32) += cls_u32.o obj-$(CONFIG_NET_CLS_ROUTE4) += cls_route.o obj-$(CONFIG_NET_CLS_FW) += cls_fw.o -obj-$(CONFIG_NET_CLS_RSVP) += cls_rsvp.o -obj-$(CONFIG_NET_CLS_RSVP6) += cls_rsvp6.o obj-$(CONFIG_NET_CLS_BASIC) += cls_basic.o obj-$(CONFIG_NET_CLS_FLOW) += cls_flow.o obj-$(CONFIG_NET_CLS_CGROUP) += cls_cgroup.o
net/sched/cls_rsvp.c deleted +0 -28
@@ -1,28 +0,0 @@ -/* -* net/sched/cls_rsvp.c Special RSVP packet classifier for IPv4. -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version -* 2 of the License, or (at your option) any later version. -* -* Authors: Alexey Kuznetsov, <[email protected]> -*/ - -#include <linux/module.h> -#include <linux/types.h> -#include <linux/kernel.h> -#include <linux/string.h> -#include <linux/errno.h> -#include <linux/skbuff.h> -#include <net/ip.h> -#include <net/netlink.h> -#include <net/act_api.h> -#include <net/pkt_cls.h> - -#define RSVP_DST_LEN 1 -#define RSVP_ID "rsvp" -#define RSVP_OPS cls_rsvp_ops - -#include "cls_rsvp.h" -MODULE_LICENSE ("GPL" );
net/sched/cls_rsvp.h deleted +0 -779
779 lines not on this page · raw message
net/sched/cls_rsvp6.c deleted +0 -28
@@ -1,28 +0,0 @@ -/* -* net/sched/cls_rsvp6.c Special RSVP packet classifier for IPv6. -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version -* 2 of the License, or (at your option) any later version. -* -* Authors: Alexey Kuznetsov, <[email protected]> -*/ - -#include <linux/module.h> -#include <linux/types.h> -#include <linux/kernel.h> -#include <linux/string.h> -#include <linux/errno.h> -#include <linux/ipv6.h> -#include <linux/skbuff.h> -#include <net/act_api.h> -#include <net/pkt_cls.h> -#include <net/netlink.h> - -#define RSVP_DST_LEN 4 -#define RSVP_ID "rsvp6" -#define RSVP_OPS cls_rsvp6_ops - -#include "cls_rsvp.h" -MODULE_LICENSE ("GPL" );
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.326 release. There are 186 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 Fri, 22 Sep 2023 11:28:09 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.326-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.14.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.
NOTE:
The latest version of selftests ftrace test fails here on 4.14.326-rc1. This is not a kernel regression.
## Build
* kernel: 4.14.326-rc1
* git: https://gitlab.com/Linaro/lkft/mirrors/stable/linux-stable-rc
* git branch: linux-4.14.y
* git commit: db587d473a47d83c9329f769e7df2c07df6b77a5
* git describe: v4.14.325-187-gdb587d473a47
* test details:
https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-4.14.y/build/v4.14.325-187-gdb587d473a47
## Test Regressions (compared to v4.14.325)
## Metric Regressions (compared to v4.14.325)
## Test Fixes (compared to v4.14.325)
## Metric Fixes (compared to v4.14.325)
## Test result summary
total: 51393, pass: 43787, fail: 1208, skip: 6354, xfail: 44
## Build Summary
* arc: 10 total, 10 passed, 0 failed
* arm: 107 total, 102 passed, 5 failed
* arm64: 33 total, 29 passed, 4 failed
* i386: 21 total, 18 passed, 3 failed
* mips: 21 total, 21 passed, 0 failed
* parisc: 3 total, 0 passed, 3 failed
* powerpc: 8 total, 7 passed, 1 failed
* s390: 6 total, 5 passed, 1 failed
* sh: 12 total, 12 passed, 0 failed
* sparc: 6 total, 6 passed, 0 failed
* x86_64: 27 total, 23 passed, 4 failed
## Test suites summary
* boot
* kselftest-android
* kselftest-arm64
* kselftest-breakpoints
* kselftest-capabilities
* kselftest-cgroup
* kselftest-clone3
* kselftest-core
* kselftest-cpu-hotplug
* kselftest-cpufreq
* kselftest-drivers-dma-buf
* kselftest-efivarfs
* kselftest-filesystems
* kselftest-filesystems-binderfs
* kselftest-filesystems-epoll
* kselftest-firmware
* kselftest-fpu
* kselftest-ftrace
* kselftest-futex
* kselftest-gpio
* kselftest-ipc
* kselftest-ir
* kselftest-kcmp
* kselftest-kexec
* kselftest-lib
* kselftest-membarrier
* kselftest-memfd
* kselftest-memory-hotplug
* kselftest-mincore
* kselftest-mount
* kselftest-mqueue
* kselftest-net
* kselftest-net-forwarding
* kselftest-net-mptcp
* kselftest-netfilter
* kselftest-nsfs
* kselftest-openat2
* kselftest-pid_namespace
* kselftest-pidfd
* kselftest-proc
* kselftest-pstore
* kselftest-rseq
* kselftest-rtc
* kselftest-seccomp
* kselftest-sigaltstack
* kselftest-size
* kselftest-splice
* kselftest-static_keys
* kselftest-sync
* kselftest-sysctl
* kselftest-tc-testing
* kselftest-timens
* kselftest-timers
* kselftest-tmpfs
* kselftest-tpm2
* kselftest-user
* kselftest-user_events
* kselftest-vDSO
* kselftest-vm
* kselftest-watchdog
* kselftest-zram
* kunit
* log-parser-boot
* log-parser-test
* ltp-cap_bounds
* ltp-commands
* ltp-containers
* ltp-controllers
* ltp-crypto
* ltp-cve
* ltp-fcntl-locktests
* ltp-filecaps
* ltp-fs
* ltp-fs_bind
* ltp-fs_perms_simple
* ltp-fsx
* ltp-hugetlb
* ltp-io
* ltp-ipc
* ltp-math
* ltp-mm
* ltp-nptl
* ltp-pty
* ltp-sched
* ltp-securebits
* ltp-smoke
* ltp-syscalls
* ltp-tracing
* rcutorture
--
Linaro LKFT
https://lkft.linaro.org
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.326 release. There are 186 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 Fri, 22 Sep 2023 11:28:09 +0000. Anything received after that time might be too late.
Build results:
total: 139 pass: 139 fail: 0 Qemu test results: total: 440 pass: 440 fail: 0
Guenter
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.326 release. There are 186 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 Fri, 22 Sep 2023 11:28:09 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.326-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.14.y
and the diffstat can be found below.thanks,
greg k-h
All tests passing for Tegra ...
Test results for stable-v4.14:
11 builds: 11 pass, 0 fail
16 boots: 16 pass, 0 fail
32 tests: 32 pass, 0 failLinux version: 4.14.326-rc1-gdb587d473a47
Boards tested: tegra124-jetson-tk1, tegra20-ventana,
tegra210-p2371-2180, tegra30-cardhu-a04
Jon