5.4.189-rc1 review
Subsystems (8)
Greg Kroah-Hartman
maintainerPATCH 328/475 KVM: Prevent module exit until all VMs are freed
In reply to Greg Kroah-HartmanFrom: David Matlack <[email protected]>
commit 5f6de5cbebee925a612856fce6f9182bb3eee0db upstream.
Tie the lifetime the KVM module to the lifetime of each VM via kvm.users_count. This way anything that grabs a reference to the VM via kvm_get_kvm() cannot accidentally outlive the KVM module.
Prior to this commit, the lifetime of the KVM module was tied to the lifetime of /dev/kvm file descriptors, VM file descriptors, and vCPU file descriptors by their respective file_operations "owner" field. This approach is insufficient because references grabbed via kvm_get_kvm() do not prevent closing any of the aforementioned file descriptors.
This fixes a long standing theoretical bug in KVM that at least affects async page faults. kvm_setup_async_pf() grabs a reference via kvm_get_kvm(), and drops it in an asynchronous work callback. Nothing prevents the VM file descriptor from being closed and the KVM module from being unloaded before this callback runs.
Message-Id: <[email protected]>
--- virt/kvm/kvm_main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
virt/kvm/kvm_main.c +13 -0
@@ -115,6 +115,8 @@ EXPORT_SYMBOL_GPL(kvm_debugfs_dir);static int kvm_debugfs_num_entries;static const struct file_operations *stat_fops_per_vm[]; +static struct file_operations kvm_chardev_ops; +static long kvm_vcpu_ioctl (struct file *file,unsigned int ioctl,unsigned long arg);#ifdef CONFIG_KVM_COMPAT
@@ -766,6 +768,16 @@ static struct kvm *kvm_create_vm(unsignepreempt_notifier_inc (); +/* +* When the fd passed to this ioctl() is opened it pins the module, +* but try_module_get() also prevents getting a reference if the module +* is in MODULE_STATE_GOING (e.g. if someone ran "rmmod --wait"). +*/ +if (!try_module_get (kvm_chardev_ops.owner)) { + r = -ENODEV ; + goto out_err; + } +return kvm; out_err:
@@ -844,6 +856,7 @@ static void kvm_destroy_vm(struct kvm *kpreempt_notifier_dec ();hardware_disable_all ();mmdrop (mm); +module_put (kvm_chardev_ops.owner); }void kvm_get_kvm (struct kvm *kvm)
Greg Kroah-Hartman
maintainerPATCH 329/475 KVM: x86: fix sending PV IPI
In reply to Greg Kroah-HartmanFrom: Li RongQing <[email protected]>
commit c15e0ae42c8e5a61e9aca8aac920517cf7b3e94e upstream.
If apic_id is less than min, and (max - apic_id) is greater than KVM_IPI_CLUSTER_SIZE, then the third check condition is satisfied but the new apic_id does not fit the bitmask. In this case __send_ipi_mask should send the IPI.
This is mostly theoretical, but it can happen if the apic_ids on three iterations of the loop are for example 1, KVM_IPI_CLUSTER_SIZE, 0.
Message-Id: <[email protected]>
--- arch/x86/kernel/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/kvm.c +1 -1
@@ -487,7 +487,7 @@ static void __send_ipi_mask(const struct }else if (apic_id < min && max - apic_id <KVM_IPI_CLUSTER_SIZE ) { ipi_bitmap <<= min - apic_id; min = apic_id; - }else if (apic_id < min +KVM_IPI_CLUSTER_SIZE ) { + }else if (apic_id > min && apic_id < min +KVM_IPI_CLUSTER_SIZE ) { max = apic_id < max ? max : apic_id; }else { ret = kvm_hypercall4(KVM_HC_SEND_IPI, (unsigned long)ipi_bitmap,
Greg Kroah-Hartman
maintainerPATCH 330/475 ASoC: SOF: Intel: Fix NULL ptr dereference when ENOMEM
In reply to Greg Kroah-HartmanFrom: Ammar Faizi <[email protected]>
commit b7fb0ae09009d076964afe4c1a2bde1ee2bd88a9 upstream.
Do not call snd_dma_free_pages() when snd_dma_alloc_pages() returns -ENOMEM because it leads to a NULL pointer dereference bug.
The dmesg says:
[ T1387] sof-audio-pci-intel-tgl 0000:00:1f.3: error: memory alloc failed: -12
[ T1387] BUG: kernel NULL pointer dereference, address: 0000000000000000
[ T1387] #PF: supervisor read access in kernel mode
[ T1387] #PF: error_code(0x0000) - not-present page
[ T1387] PGD 0 P4D 0
[ T1387] Oops: 0000 [#1] PREEMPT SMP NOPTI
[ T1387] CPU: 6 PID: 1387 Comm: alsa-sink-HDA A Tainted: G W 5.17.0-rc4-superb-owl-00055-g80d47f5de5e3
[ T1387] Hardware name: HP HP Laptop 14s-dq2xxx/87FD, BIOS F.15 09/15/2021
[ T1387] RIP: 0010:dma_free_noncontiguous+0x37/0x80
[ T1387] Code: [... snip ...]
[ T1387] RSP: 0000:ffffc90002b87770 EFLAGS: 00010246
[ T1387] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
[ T1387] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff888101db30d0
[ T1387] RBP: 00000000fffffff4 R08: 0000000000000000 R09: 0000000000000000
[ T1387] R10: 0000000000000000 R11: ffffc90002b874d0 R12: 0000000000000001
[ T1387] R13: 0000000000058000 R14: ffff888105260c68 R15: ffff888105260828
[ T1387] FS: 00007f42e2ffd640(0000) GS:ffff888466b80000(0000) knlGS:0000000000000000
[ T1387] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ T1387] CR2: 0000000000000000 CR3: 000000014acf0003 CR4: 0000000000770ee0
[ T1387] PKRU: 55555554
[ T1387] Call Trace:
[ T1387] <TASK>
[ T1387] cl_stream_prepare+0x10a/0x120 [snd_sof_intel_hda_common 146addf995b9279ae7f509621078cccbe4f875e1] [... snip ...]
[ T1387] </TASK>
--- sound/soc/sof/intel/hda-loader.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
sound/soc/sof/intel/hda-loader.c +5 -4
@@ -50,7 +50,7 @@ static int cl_stream_prepare(struct snd_ ret =snd_dma_alloc_pages (SNDRV_DMA_TYPE_DEV_SG , &pci->dev, size, dmab);if (ret <0 ) {dev_err (sdev->dev,"error: memory alloc failed: %x\n" , ret); - goto error; + goto out_put; } hstream->period_bytes =0 ;/* initialize period_bytes */
@@ -60,16 +60,17 @@ static int cl_stream_prepare(struct snd_ ret =hda_dsp_stream_hw_params (sdev, dsp_stream, dmab,NULL );if (ret <0 ) {dev_err (sdev->dev,"error: hdac prepare failed: %x\n" , ret); - goto error; + goto out_free; }hda_dsp_stream_spib_config (sdev, dsp_stream,HDA_DSP_SPIB_ENABLE , size);return hstream->stream_tag; -error: -hda_dsp_stream_put (sdev, direction, hstream->stream_tag); +out_free:snd_dma_free_pages (dmab); +out_put: +hda_dsp_stream_put (sdev, direction, hstream->stream_tag);return ret; }
Greg Kroah-Hartman
maintainerPATCH 331/475 ubifs: rename_whiteout: Fix double free for whiteout_ui->data
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit 40a8f0d5e7b3999f096570edab71c345da812e3e upstream.
'whiteout_ui->data' will be freed twice if space budget fail for rename whiteout operation as following process:
rename_whiteout
dev = kmalloc
whiteout_ui->data = dev
kfree(whiteout_ui->data) // Free first time
iput(whiteout)
ubifs_free_inode
kfree(ui->data) // Double free!KASAN reports:
==================================================================
BUG: KASAN: double-free or invalid-free in ubifs_free_inode+0x4f/0x70 Call Trace: kfree+0x117/0x490 ubifs_free_inode+0x4f/0x70 [ubifs] i_callback+0x30/0x60 rcu_do_batch+0x366/0xac0 __do_softirq+0x133/0x57f Allocated by task 1506: kmem_cache_alloc_trace+0x3c2/0x7a0 do_rename+0x9b7/0x1150 [ubifs] ubifs_rename+0x106/0x1f0 [ubifs] do_syscall_64+0x35/0x80 Freed by task 1506: kfree+0x117/0x490 do_rename.cold+0x53/0x8a [ubifs] ubifs_rename+0x106/0x1f0 [ubifs] do_syscall_64+0x35/0x80 The buggy address belongs to the object at ffff88810238bed8 which
belongs to the cache kmalloc-8 of size 8
==================================================================
Let ubifs_free_inode() free 'whiteout_ui->data'. BTW, delete unused assignment 'whiteout_ui->data_len = 0', process 'ubifs_evict_inode() -> ubifs_jnl_delete_inode() -> ubifs_jnl_write_inode()' doesn't need it (because 'inc_nlink(whiteout)' won't be excuted by 'goto out_release',
and the nlink of whiteout inode is 0).
--- fs/ubifs/dir.c | 2 -- 1 file changed, 2 deletions(-)
fs/ubifs/dir.c +0 -2
@@ -1431,8 +1431,6 @@ static int do_rename(struct inode *old_d err =ubifs_budget_space (c, &wht_req);if (err) { -kfree (whiteout_ui->data); - whiteout_ui->data_len =0 ;iput (whiteout); goto out_release; }
Greg Kroah-Hartman
maintainerPATCH 332/475 ubifs: Fix deadlock in concurrent rename whiteout and inode writeback
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit afd427048047e8efdedab30e8888044e2be5aa9c upstream.
Following hung tasks:
[ 77.028764] task:kworker/u8:4 state:D stack: 0 pid: 132 [ 77.028820] Call Trace: [ 77.029027] schedule+0x8c/0x1b0 [ 77.029067] mutex_lock+0x50/0x60 [ 77.029074] ubifs_write_inode+0x68/0x1f0 [ubifs] [ 77.029117] __writeback_single_inode+0x43c/0x570 [ 77.029128] writeback_sb_inodes+0x259/0x740 [ 77.029148] wb_writeback+0x107/0x4d0 [ 77.029163] wb_workfn+0x162/0x7b0
[ 92.390442] task:aa state:D stack: 0 pid: 1506 [ 92.390448] Call Trace: [ 92.390458] schedule+0x8c/0x1b0 [ 92.390461] wb_wait_for_completion+0x82/0xd0 [ 92.390469] __writeback_inodes_sb_nr+0xb2/0x110 [ 92.390472] writeback_inodes_sb_nr+0x14/0x20 [ 92.390476] ubifs_budget_space+0x705/0xdd0 [ubifs] [ 92.390503] do_rename.cold+0x7f/0x187 [ubifs] [ 92.390549] ubifs_rename+0x8b/0x180 [ubifs] [ 92.390571] vfs_rename+0xdb2/0x1170 [ 92.390580] do_renameat2+0x554/0x770
, are caused by concurrent rename whiteout and inode writeback processes:
rename_whiteout(Thread 1) wb_workfn(Thread2)ubifs_rename
do_rename
lock_4_inodes (Hold ui_mutex)
ubifs_budget_space
make_free_space
shrink_liability
__writeback_inodes_sb_nr
bdi_split_work_to_wbs (Queue new wb work)
wb_do_writeback(wb work)
__writeback_single_inode
ubifs_write_inode
LOCK(ui_mutex)
↑
wb_wait_for_completion (Wait wb work) <-- deadlock!
Reproducer (Detail program in [Link]):
1. SYS_renameat2("/mp/dir/file", "/mp/dir/whiteout", RENAME_WHITEOUT)
2. Consume out of space before kernel(mdelay) doing budget for whiteout
Fix it by doing whiteout space budget before locking ubifs inodes. BTW, it also fixes wrong goto tag 'out_release' in whiteout budget error handling path(It should at least recover dir i_size and unlock 4 ubifs inodes).
--- fs/ubifs/dir.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
fs/ubifs/dir.c +15 -10
@@ -1330,6 +1330,7 @@ static int do_rename(struct inode *old_dif (flags &RENAME_WHITEOUT ) {union ubifs_dev_desc *dev =NULL ; +struct ubifs_budget_req wht_req; dev =kmalloc (sizeof (union ubifs_dev_desc ),GFP_NOFS );if (!dev) {
@@ -1351,6 +1352,20 @@ static int do_rename(struct inode *old_d whiteout_ui->data = dev; whiteout_ui->data_len =ubifs_encode_dev (dev,MKDEV (0 ,0 ));ubifs_assert (c, !whiteout_ui->dirty); + +memset (&wht_req,0 ,sizeof (struct ubifs_budget_req )); + wht_req.dirtied_ino =1 ; + wht_req.dirtied_ino_d =ALIGN (whiteout_ui->data_len,8 ); +/* +* To avoid deadlock between space budget (holds ui_mutex and +* waits wb work) and writeback work(waits ui_mutex), do space +* budget before ubifs inodes locked. +*/ + err =ubifs_budget_space (c, &wht_req); +if (err) { +iput (whiteout); + goto out_release; + } }lock_4_inodes (old_dir, new_dir, new_inode, whiteout);
@@ -1425,16 +1440,6 @@ static int do_rename(struct inode *old_d }if (whiteout) { -struct ubifs_budget_req wht_req = { .dirtied_ino =1 , - .dirtied_ino_d = \ -ALIGN (ubifs_inode (whiteout)->data_len,8 ) }; - - err =ubifs_budget_space (c, &wht_req); -if (err) { -iput (whiteout); - goto out_release; - } -inc_nlink (whiteout);mark_inode_dirty (whiteout);
Greg Kroah-Hartman
maintainerPATCH 333/475 ubifs: Add missing iput if do_tmpfile() failed in rename whiteout
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit 716b4573026bcbfa7b58ed19fe15554bac66b082 upstream.
whiteout inode should be put when do_tmpfile() failed if inode has been initialized. Otherwise we will get following warning during umount:
UBIFS error (ubi0:0 pid 1494): ubifs_assert_failed [ubifs]: UBIFS assert failed: c->bi.dd_growth == 0, in fs/ubifs/super.c:1930
VFS: Busy inodes after unmount of ubifs. Self-destruct in 5 seconds.
--- fs/ubifs/dir.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ubifs/dir.c +2 -0
@@ -439,6 +439,8 @@ out_inode:make_bad_inode (inode);if (!instantiated)iput (inode); +else if (whiteout) +iput (*whiteout); out_budg:ubifs_release_budget (c, &req);if (!instantiated)
Greg Kroah-Hartman
maintainerPATCH 334/475 ubifs: setflags: Make dirtied_ino_d 8 bytes aligned
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit 1b83ec057db16b4d0697dc21ef7a9743b6041f72 upstream.
Make 'ui->data_len' aligned with 8 bytes before it is assigned to dirtied_ino_d. Since 8871d84c8f8b0c6b("ubifs: convert to fileattr") applied, 'setflags()' only affects regular files and directories, only xattr inode, symlink inode and special inode(pipe/char_dev/block_dev) have none- zero 'ui->data_len' field, so assertion '!(req->dirtied_ino_d & 7)' cannot fail in ubifs_budget_space(). To avoid assertion fails in future evolution(eg. setflags can operate special inodes), it's better to make dirtied_ino_d 8 bytes aligned, after all aligned size is still zero for regular files.
--- fs/ubifs/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ubifs/ioctl.c +1 -1
@@ -101,7 +101,7 @@ static int setflags(struct inode *inode,struct ubifs_inode *ui =ubifs_inode (inode);struct ubifs_info *c = inode->i_sb->s_fs_info;struct ubifs_budget_req req = { .dirtied_ino =1 , - .dirtied_ino_d = ui->data_len }; + .dirtied_ino_d =ALIGN (ui->data_len,8 ) }; err =ubifs_budget_space (c, &req);if (err)
Greg Kroah-Hartman
maintainerPATCH 335/475 ubifs: Fix read out-of-bounds in ubifs_wbuf_write_nolock()
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit 4f2262a334641e05f645364d5ade1f565c85f20b upstream.
Function ubifs_wbuf_write_nolock() may access buf out of bounds in following process:
ubifs_wbuf_write_nolock():
aligned_len = ALIGN(len, 8); // Assume len = 4089, aligned_len = 4096
if (aligned_len <= wbuf->avail) ... // Not satisfy
if (wbuf->used) {
ubifs_leb_write() // Fill some data in avail wbuf
len -= wbuf->avail; // len is still not 8-bytes aligned
aligned_len -= wbuf->avail;
}
n = aligned_len >> c->max_write_shift;
if (n) {
n <<= c->max_write_shift;
err = ubifs_leb_write(c, wbuf->lnum, buf + written,
wbuf->offs, n);
// n > len, read out of bounds less than 8(n-len) bytes}
, which can be catched by KASAN:
=========================================================
BUG: KASAN: slab-out-of-bounds in ecc_sw_hamming_calculate+0x1dc/0x7d0
Read of size 4 at addr ffff888105594ff8 by task kworker/u8:4/128
Workqueue: writeback wb_workfn (flush-ubifs_0_0)
Call Trace:
kasan_report.cold+0x81/0x165
nand_write_page_swecc+0xa9/0x160
ubifs_leb_write+0xf2/0x1b0 [ubifs]
ubifs_wbuf_write_nolock+0x421/0x12c0 [ubifs]
write_head+0xdc/0x1c0 [ubifs]
ubifs_jnl_write_inode+0x627/0x960 [ubifs]
wb_workfn+0x8af/0xb80Function ubifs_wbuf_write_nolock() accepts that parameter 'len' is not 8 bytes aligned, the 'len' represents the true length of buf (which is allocated in 'ubifs_jnl_xxx', eg. ubifs_jnl_write_inode), so ubifs_wbuf_write_nolock() must handle the length read from 'buf' carefully to write leb safely.
Fetch a reproducer in [Link].
--- fs/ubifs/io.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-)
fs/ubifs/io.c +30 -4
@@ -846,16 +846,42 @@ int ubifs_wbuf_write_nolock(struct ubifs*/ n = aligned_len >> c->max_write_shift;if (n) { - n <<= c->max_write_shift; +int m = n -1 ; +dbg_io ("write %d bytes to LEB %d:%d" , n, wbuf->lnum, wbuf->offs); - err =ubifs_leb_write (c, wbuf->lnum, buf + written, - wbuf->offs, n); + +if (m) { +/* '(n-1)<<c->max_write_shift < len' is always true. */ + m <<= c->max_write_shift; + err =ubifs_leb_write (c, wbuf->lnum, buf + written, + wbuf->offs, m); +if (err) + goto out; + wbuf->offs += m; + aligned_len -= m; + len -= m; + written += m; + } + +/* +* The non-written len of buf may be less than 'n' because +* parameter 'len' is not 8 bytes aligned, so here we read +* min(len, n) bytes from buf. +*/ + n =1 << c->max_write_shift; +memcpy (wbuf->buf, buf + written,min (len, n)); +if (n > len) { +ubifs_assert (c, n - len <8 ); +ubifs_pad (c, wbuf->buf + len, n - len); + } + + err =ubifs_leb_write (c, wbuf->lnum, wbuf->buf, wbuf->offs, n);if (err) goto out; wbuf->offs += n; aligned_len -= n; - len -= n; + len -=min (len, n); written += n; }
Greg Kroah-Hartman
maintainerPATCH 336/475 ubifs: rename_whiteout: correct old_dir size computing
In reply to Greg Kroah-HartmanFrom: Baokun Li <[email protected]>
commit 705757274599e2e064dd3054aabc74e8af31a095 upstream.
When renaming the whiteout file, the old whiteout file is not deleted. Therefore, we add the old dentry size to the old dir like XFS. Otherwise, an error may be reported due to fscki->calc_sz != fscki->size in check_indes.
--- fs/ubifs/dir.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ubifs/dir.c +3 -0
@@ -1368,6 +1368,9 @@ static int do_rename(struct inode *old_diput (whiteout); goto out_release; } + +/* Add the old_dentry size to the old_dir size. */ + old_sz -=CALC_DENT_SIZE (fname_len (&old_nm)); }lock_4_inodes (old_dir, new_dir, new_inode, whiteout);
Greg Kroah-Hartman
maintainerPATCH 337/475 XArray: Fix xas_create_range() when multi-order entry present
In reply to Greg Kroah-HartmanFrom: Matthew Wilcox (Oracle) <[email protected]>
commit 3e3c658055c002900982513e289398a1aad4a488 upstream.
If there is already an entry present that is of order >= XA_CHUNK_SHIFT when we call xas_create_range(), xas_create_range() will misinterpret that entry as a node and dereference xa_node->parent, generally leading to a crash that looks something like this:
general protection fault, probably for non-canonical address 0xdffffc0000000001: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f] CPU: 0 PID: 32 Comm: khugepaged Not tainted 5.17.0-rc8-syzkaller-00003-g56e337f2cf13 #0 RIP: 0010:xa_parent_locked include/linux/xarray.h:1207 [inline] RIP: 0010:xas_create_range+0x2d9/0x6e0 lib/xarray.c:725
It's deterministically reproducable once you know what the problem is, but producing it in a live kernel requires khugepaged to hit a race. While the problem has been present since xas_create_range() was introduced, I'm not aware of a way to hit it before the page cache was converted to use multi-index entries.
--- lib/test_xarray.c | 22 ++++++++++++++++++++++ lib/xarray.c | 2 ++ 2 files changed, 24 insertions(+)
lib/test_xarray.c +22 -0
@@ -1438,6 +1438,25 @@ unlock:XA_BUG_ON (xa, !xa_empty (xa)); } +static noinline void check_create_range_5(struct xarray *xa, +unsigned long index,unsigned int order) +{ +XA_STATE_ORDER (xas, xa, index, order); +unsigned int i; + +xa_store_order (xa, index, order,xa_mk_index (index),GFP_KERNEL ); + +for (i =0 ; i < order +10 ; i++) { +do { +xas_lock (&xas); +xas_create_range (&xas); +xas_unlock (&xas); + }while (xas_nomem (&xas,GFP_KERNEL )); + } + +xa_destroy (xa); +} + static noinline void check_create_range(struct xarray *xa) {unsigned int order;
@@ -1465,6 +1484,9 @@ static noinline void check_create_range(check_create_range_4 (xa, (3U << order) +1 , order);check_create_range_4 (xa, (3U << order) -1 , order);check_create_range_4 (xa, (1U <<24 ) +1 , order); + +check_create_range_5 (xa,0 , order); +check_create_range_5 (xa, (1U << order), order); }check_create_range_3 ();
lib/xarray.c +2 -0
@@ -722,6 +722,8 @@ void xas_create_range(struct xa_state *xfor (;;) {struct xa_node *node = xas->xa_node; +if (node->shift >= shift) +break ; xas->xa_node =xa_parent_locked (xas->xa, node); xas->xa_offset = node->offset -1 ;if (node->offset !=0 )
Greg Kroah-Hartman
maintainerPATCH 338/475 can: mcba_usb: mcba_usb_start_xmit(): fix double dev_kfree_skb in error path
In reply to Greg Kroah-HartmanFrom: Hangyu Hua <[email protected]>
commit 04c9b00ba83594a29813d6b1fb8fdc93a3915174 upstream.
There is no need to call dev_kfree_skb() when usb_submit_urb() fails because can_put_echo_skb() deletes original skb and can_free_echo_skb() deletes the cloned skb.
--- drivers/net/can/usb/mcba_usb.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/can/usb/mcba_usb.c +0 -1
@@ -368,7 +368,6 @@ static netdev_tx_t mcba_usb_start_xmit(s xmit_failed:can_free_echo_skb (priv->netdev, ctx->ndx);mcba_usb_free_ctx (ctx); -dev_kfree_skb (skb); stats->tx_dropped++;return NETDEV_TX_OK ;
Greg Kroah-Hartman
maintainerPATCH 339/475 can: mcba_usb: properly check endpoint type
In reply to Greg Kroah-HartmanFrom: Pavel Skripkin <[email protected]>
commit 136bed0bfd3bc9c95c88aafff2d22ecb3a919f23 upstream.
Syzbot reported warning in usb_submit_urb() which is caused by wrong endpoint type. We should check that in endpoint is actually present to prevent this warning.
Found pipes are now saved to struct mcba_priv and code uses them directly instead of making pipes in place.
Fail log:
| usb 5-1: BOGUS urb xfer, pipe 3 != type 1 | WARNING: CPU: 1 PID: 49 at drivers/usb/core/urb.c:502 usb_submit_urb+0xed2/0x18a0 drivers/usb/core/urb.c:502 | Modules linked in: | CPU: 1 PID: 49 Comm: kworker/1:2 Not tainted 5.17.0-rc6-syzkaller-00184-g38f80f42147f #0 | Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014 | Workqueue: usb_hub_wq hub_event | RIP: 0010:usb_submit_urb+0xed2/0x18a0 drivers/usb/core/urb.c:502 | ... | Call Trace: | <TASK> | mcba_usb_start drivers/net/can/usb/mcba_usb.c:662 [inline] | mcba_usb_probe+0x8a3/0xc50 drivers/net/can/usb/mcba_usb.c:858 | usb_probe_interface+0x315/0x7f0 drivers/usb/core/driver.c:396 | call_driver_probe drivers/base/dd.c:517 [inline]
--- drivers/net/can/usb/mcba_usb.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
drivers/net/can/usb/mcba_usb.c +16 -10
@@ -33,10 +33,6 @@#define MCBA_USB_RX_BUFF_SIZE 64#define MCBA_USB_TX_BUFF_SIZE (sizeof(struct mcba_usb_msg)) -/* MCBA endpoint numbers */ -#define MCBA_USB_EP_IN 1 -#define MCBA_USB_EP_OUT 1 -/* Microchip command id */ #define MBCA_CMD_RECEIVE_MESSAGE 0xE3#define MBCA_CMD_I_AM_ALIVE_FROM_CAN 0xF5
@@ -84,6 +80,8 @@ struct mcba_priv {atomic_t free_ctx_cnt;void *rxbuf[MCBA_MAX_RX_URBS ];dma_addr_t rxbuf_dma[MCBA_MAX_RX_URBS ]; +int rx_pipe; +int tx_pipe; };/* CAN frame */
@@ -272,10 +270,8 @@ static netdev_tx_t mcba_usb_xmit(structmemcpy (buf, usb_msg,MCBA_USB_TX_BUFF_SIZE ); -usb_fill_bulk_urb (urb, priv->udev, -usb_sndbulkpipe (priv->udev,MCBA_USB_EP_OUT ), buf, -MCBA_USB_TX_BUFF_SIZE , mcba_usb_write_bulk_callback, - ctx); +usb_fill_bulk_urb (urb, priv->udev, priv->tx_pipe, buf,MCBA_USB_TX_BUFF_SIZE , + mcba_usb_write_bulk_callback, ctx); urb->transfer_flags |=URB_NO_TRANSFER_DMA_MAP ;usb_anchor_urb (urb, &priv->tx_submitted);
@@ -610,7 +606,7 @@ static void mcba_usb_read_bulk_callback( resubmit_urb:usb_fill_bulk_urb (urb, priv->udev, -usb_rcvbulkpipe (priv->udev,MCBA_USB_EP_OUT ), + priv->rx_pipe, urb->transfer_buffer,MCBA_USB_RX_BUFF_SIZE , mcba_usb_read_bulk_callback, priv);
@@ -655,7 +651,7 @@ static int mcba_usb_start(struct mcba_pr urb->transfer_dma = buf_dma;usb_fill_bulk_urb (urb, priv->udev, -usb_rcvbulkpipe (priv->udev,MCBA_USB_EP_IN ), + priv->rx_pipe, buf,MCBA_USB_RX_BUFF_SIZE , mcba_usb_read_bulk_callback, priv); urb->transfer_flags |=URB_NO_TRANSFER_DMA_MAP ;
@@ -809,6 +805,13 @@ static int mcba_usb_probe(struct usb_intstruct mcba_priv *priv;int err = -ENOMEM ;struct usb_device *usbdev =interface_to_usbdev (intf); +struct usb_endpoint_descriptor *in, *out; + + err =usb_find_common_endpoints (intf->cur_altsetting, &in, &out,NULL ,NULL ); +if (err) { +dev_err (&intf->dev,"Can't find endpoints\n" ); +return err; + } netdev =alloc_candev (sizeof (struct mcba_priv ),MCBA_MAX_TX_URBS );if (!netdev) {
@@ -854,6 +857,9 @@ static int mcba_usb_probe(struct usb_int goto cleanup_free_candev; } + priv->rx_pipe =usb_rcvbulkpipe (priv->udev, in->bEndpointAddress); + priv->tx_pipe =usb_sndbulkpipe (priv->udev, out->bEndpointAddress); +devm_can_led_init (netdev);/* Start USB dev only if we have successfully registered CAN device */
Greg Kroah-Hartman
maintainerPATCH 340/475 XArray: Update the LRU list in xas_split()
In reply to Greg Kroah-HartmanFrom: Matthew Wilcox (Oracle) <[email protected]>
commit 3ed4bb77156da0bc732847c8c9df92454c1fbeea upstream.
When splitting a value entry, we may need to add the new nodes to the LRU list and remove the parent node from the LRU list. The WARN_ON checks in shadow_lru_isolate() catch this oversight. This bug was latent until we stopped splitting folios in shrink_page_list() with commit 820c4e2e6f51 ("mm/vmscan: Free non-shmem folios without splitting them"). That allows the creation of large shadow entries, and subsequently when trying to page in a small page, we will split the large shadow entry in __filemap_add_folio().
--- lib/xarray.c | 2 ++ 1 file changed, 2 insertions(+)
lib/xarray.c +2 -0
@@ -1080,6 +1080,7 @@ void xas_split(struct xa_state *xas, voi xa_mk_node(child));if (xa_is_value (curr)) values--; +xas_update (xas, child); }else {unsigned int canon = offset - xas->xa_sibs;
@@ -1094,6 +1095,7 @@ void xas_split(struct xa_state *xas, voi } while (offset-- > xas->xa_offset); node->nr_values += values; +xas_update (xas, node); }EXPORT_SYMBOL_GPL (xas_split);#endif
Greg Kroah-Hartman
maintainerPATCH 341/475 rtc: check if __rtc_read_time was successful
In reply to Greg Kroah-HartmanFrom: Tom Rix <[email protected]>
commit 915593a7a663b2ad08b895a5f3ba8b19d89d4ebf upstream.
Clang static analysis reports this issue interface.c:810:8: warning: Passed-by-value struct
argument contains uninitialized data
now = rtc_tm_to_ktime(tm);
^~~~~~~~~~~~~~~~~~~tm is set by a successful call to __rtc_read_time() but its return status is not checked. Check if it was successful before setting the enabled flag. Move the decl of err to function scope.
--- drivers/rtc/interface.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/rtc/interface.c +5 -2
@@ -793,9 +793,13 @@ static int rtc_timer_enqueue(struct rtc_struct timerqueue_node *next =timerqueue_getnext (&rtc->timerqueue);struct rtc_time tm;ktime_t now; +int err; + + err =__rtc_read_time (rtc, &tm); +if (err) +return err; timer->enabled =1 ; -__rtc_read_time (rtc, &tm); now =rtc_tm_to_ktime (tm);/* Skip over expired timers */
@@ -809,7 +813,6 @@ static int rtc_timer_enqueue(struct rtc_trace_rtc_timer_enqueue (timer);if (!next ||ktime_before (timer->node.expires, next->expires)) {struct rtc_wkalrm alarm; -int err; alarm.time =rtc_ktime_to_tm (timer->node.expires); alarm.enabled =1 ;
Greg Kroah-Hartman
maintainerPATCH 342/475 gfs2: Make sure FITRIM minlen is rounded up to fs block size
In reply to Greg Kroah-HartmanFrom: Andrew Price <[email protected]>
commit 27ca8273fda398638ca994a207323a85b6d81190 upstream.
Per fstrim(8) we must round up the minlen argument to the fs block size. The current calculation doesn't take into account devices that have a discard granularity and requested minlen less than 1 fs block, so the value can get shifted away to zero in the translation to fs blocks.
The zero minlen passed to gfs2_rgrp_send_discards() then allows sb_issue_discard() to be called with nr_sects == 0 which returns -EINVAL and results in gfs2_rgrp_send_discards() returning -EIO.
Make sure minlen is never < 1 fs block by taking the max of the requested minlen and the fs block size before comparing to the device's discard granularity and shifting to fs blocks.
--- fs/gfs2/rgrp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/gfs2/rgrp.c +2 -1
@@ -1429,7 +1429,8 @@ int gfs2_fitrim(struct file *filp, void start = r.start >> bs_shift; end = start + (r.len >> bs_shift); - minlen =max_t (u64, r.minlen, + minlen =max_t (u64, r.minlen, sdp->sd_sb.sb_bsize); + minlen =max_t (u64, minlen, q->limits.discard_granularity) >> bs_shift;if (end <= start || minlen > sdp->sd_max_rg_data)
Greg Kroah-Hartman
maintainerPATCH 343/475 net: hns3: fix software vlan talbe of vlan 0 inconsistent with hardware
In reply to Greg Kroah-HartmanFrom: Guangbin Huang <[email protected]>
commit 7ed258f12ec5ce855f15cdfb5710361dc82fe899 upstream.
When user delete vlan 0, as driver will not delete vlan 0 for hardware in function hclge_set_vlan_filter_hw(), so vlan 0 in software vlan talbe should not be deleted.
--- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +3 -3
@@ -8344,11 +8344,11 @@ int hclge_set_vlan_filter(struct hnae3_h }if (!ret) { -if (is_kill) -hclge_rm_vport_vlan_table (vport, vlan_id, false); -else +if (!is_kill)hclge_add_vport_vlan_table (vport, vlan_id, writen_to_tbl); +else if (is_kill && vlan_id !=0 ) +hclge_rm_vport_vlan_table (vport, vlan_id, false); }else if (is_kill) {/* when remove hw vlan filter failed, record the vlan id, * and try to remove it from hw later, to be consistence
Greg Kroah-Hartman
maintainerPATCH 344/475 pinctrl: pinconf-generic: Print arguments for bias-pull-*
In reply to Greg Kroah-HartmanFrom: Chen-Yu Tsai <[email protected]>
commit 188e5834b930acd03ad3cf7c5e7aa24db9665a29 upstream.
The bias-pull-* properties, or PIN_CONFIG_BIAS_PULL_* pin config parameters, accept optional arguments in ohms denoting the strength of the pin bias.
Print these values out in debugfs as well.
--- drivers/pinctrl/pinconf-generic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pinctrl/pinconf-generic.c +3 -3
@@ -30,10 +30,10 @@ static const struct pin_config_item confPCONFDUMP (PIN_CONFIG_BIAS_BUS_HOLD ,"input bias bus hold" ,NULL , false),PCONFDUMP (PIN_CONFIG_BIAS_DISABLE ,"input bias disabled" ,NULL , false),PCONFDUMP (PIN_CONFIG_BIAS_HIGH_IMPEDANCE ,"input bias high impedance" ,NULL , false), -PCONFDUMP (PIN_CONFIG_BIAS_PULL_DOWN ,"input bias pull down" ,NULL , false), +PCONFDUMP (PIN_CONFIG_BIAS_PULL_DOWN ,"input bias pull down" ,"ohms" , true),PCONFDUMP (PIN_CONFIG_BIAS_PULL_PIN_DEFAULT , -"input bias pull to pin specific state" ,NULL , false), -PCONFDUMP (PIN_CONFIG_BIAS_PULL_UP ,"input bias pull up" ,NULL , false), +"input bias pull to pin specific state" ,"ohms" , true), +PCONFDUMP (PIN_CONFIG_BIAS_PULL_UP ,"input bias pull up" ,"ohms" , true),PCONFDUMP (PIN_CONFIG_DRIVE_OPEN_DRAIN ,"output drive open drain" ,NULL , false),PCONFDUMP (PIN_CONFIG_DRIVE_OPEN_SOURCE ,"output drive open source" ,NULL , false), PCONFDUMP(PIN_CONFIG_DRIVE_PUSH_PULL, "output drive push pull", NULL, false),
Greg Kroah-Hartman
maintainerPATCH 345/475 pinctrl: nuvoton: npcm7xx: Rename DS() macro to DSTR()
In reply to Greg Kroah-HartmanFrom: Jonathan Neuschäfer <[email protected]>
commit 603501c16431c56f74eaef1ee1390f60a30c2187 upstream.
The name "DS" is defined in arch/x86/um/shared/sysdep/ptrace_64.h, which results in a compiler warning when build-testing on ARCH=um. Rename this driver's "DS" macro to DSTR so avoid this collision.
--- drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c | 156 +++++++++++++++--------------- 1 file changed, 78 insertions(+), 78 deletions(-)
drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c +78 -78
@@ -904,7 +904,7 @@ static struct npcm7xx_func npcm7xx_funcs#define DRIVE_STRENGTH_HI_SHIFT 12#define DRIVE_STRENGTH_MASK 0x0000FF00 -#define DS (lo, hi) (((lo) << DRIVE_STRENGTH_LO_SHIFT) | \ +#define DSTR (lo, hi) (((lo) << DRIVE_STRENGTH_LO_SHIFT) | \ ((hi) << DRIVE_STRENGTH_HI_SHIFT))#define DSLO (x) (((x) >> DRIVE_STRENGTH_LO_SHIFT) & 0xF)#define DSHI (x) (((x) >> DRIVE_STRENGTH_HI_SHIFT) & 0xF)
@@ -924,31 +924,31 @@ struct npcm7xx_pincfg {static const struct npcm7xx_pincfg pincfg[] = {/* PIN FUNCTION 1 FUNCTION 2 FUNCTION 3 FLAGS */ NPCM7XX_PINCFG (0 , iox1,MFSEL1 ,30 , none,NONE ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (1 , iox1,MFSEL1 ,30 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (2 , iox1,MFSEL1 ,30 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), +NPCM7XX_PINCFG (1 , iox1,MFSEL1 ,30 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (2 , iox1,MFSEL1 ,30 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )),NPCM7XX_PINCFG (3 , iox1,MFSEL1 ,30 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (4 , iox2,MFSEL3 ,14 , smb1d,I2CSEGSEL ,7 , none,NONE ,0 ,SLEW ),NPCM7XX_PINCFG (5 , iox2,MFSEL3 ,14 , smb1d,I2CSEGSEL ,7 , none,NONE ,0 ,SLEW ),NPCM7XX_PINCFG (6 , iox2,MFSEL3 ,14 , smb2d,I2CSEGSEL ,10 , none,NONE ,0 ,SLEW ),NPCM7XX_PINCFG (7 , iox2,MFSEL3 ,14 , smb2d,I2CSEGSEL ,10 , none,NONE ,0 ,SLEW ), -NPCM7XX_PINCFG (8 , lkgpo1,FLOCKR1 ,4 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (9 , lkgpo2,FLOCKR1 ,8 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (10 , ioxh,MFSEL3 ,18 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (11 , ioxh,MFSEL3 ,18 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), +NPCM7XX_PINCFG (8 , lkgpo1,FLOCKR1 ,4 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (9 , lkgpo2,FLOCKR1 ,8 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (10 , ioxh,MFSEL3 ,18 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (11 , ioxh,MFSEL3 ,18 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )),NPCM7XX_PINCFG (12 , gspi,MFSEL1 ,24 , smb5b,I2CSEGSEL ,19 , none,NONE ,0 ,SLEW ),NPCM7XX_PINCFG (13 , gspi,MFSEL1 ,24 , smb5b,I2CSEGSEL ,19 , none,NONE ,0 ,SLEW ),NPCM7XX_PINCFG (14 , gspi,MFSEL1 ,24 , smb5c,I2CSEGSEL ,20 , none,NONE ,0 ,SLEW ),NPCM7XX_PINCFG (15 , gspi,MFSEL1 ,24 , smb5c,I2CSEGSEL ,20 , none,NONE ,0 ,SLEW ), -NPCM7XX_PINCFG (16 , lkgpo0,FLOCKR1 ,0 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (17 , pspi2,MFSEL3 ,13 , smb4den,I2CSEGSEL ,23 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (18 , pspi2,MFSEL3 ,13 , smb4b,I2CSEGSEL ,14 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (19 , pspi2,MFSEL3 ,13 , smb4b,I2CSEGSEL ,14 , none,NONE ,0 ,DS (8 ,12 )), +NPCM7XX_PINCFG (16 , lkgpo0,FLOCKR1 ,0 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (17 , pspi2,MFSEL3 ,13 , smb4den,I2CSEGSEL ,23 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (18 , pspi2,MFSEL3 ,13 , smb4b,I2CSEGSEL ,14 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (19 , pspi2,MFSEL3 ,13 , smb4b,I2CSEGSEL ,14 , none,NONE ,0 ,DSTR (8 ,12 )),NPCM7XX_PINCFG (20 , smb4c,I2CSEGSEL ,15 , smb15,MFSEL3 ,8 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (21 , smb4c,I2CSEGSEL ,15 , smb15,MFSEL3 ,8 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (22 , smb4d,I2CSEGSEL ,16 , smb14,MFSEL3 ,7 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (23 , smb4d,I2CSEGSEL ,16 , smb14,MFSEL3 ,7 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (24 , ioxh,MFSEL3 ,18 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (25 , ioxh,MFSEL3 ,18 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), +NPCM7XX_PINCFG (24 , ioxh,MFSEL3 ,18 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (25 , ioxh,MFSEL3 ,18 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )),NPCM7XX_PINCFG (26 , smb5,MFSEL1 ,2 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (27 , smb5,MFSEL1 ,2 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (28 , smb4,MFSEL1 ,1 , none,NONE ,0 , none,NONE ,0 ,0 ),
@@ -964,12 +964,12 @@ static const struct npcm7xx_pincfg pincfNPCM7XX_PINCFG (39 , smb3b,I2CSEGSEL ,11 , none,NONE ,0 , none,NONE ,0 ,SLEW ),NPCM7XX_PINCFG (40 , smb3b,I2CSEGSEL ,11 , none,NONE ,0 , none,NONE ,0 ,SLEW ),NPCM7XX_PINCFG (41 , bmcuart0a,MFSEL1 ,9 , none,NONE ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (42 , bmcuart0a,MFSEL1 ,9 , none,NONE ,0 , none,NONE ,0 ,DS (2 ,4 ) |GPO ), +NPCM7XX_PINCFG (42 , bmcuart0a,MFSEL1 ,9 , none,NONE ,0 , none,NONE ,0 ,DSTR (2 ,4 ) |GPO ),NPCM7XX_PINCFG (43 , uart1,MFSEL1 ,10 , jtag2,MFSEL4 ,0 , bmcuart1,MFSEL3 ,24 ,0 ),NPCM7XX_PINCFG (44 , uart1,MFSEL1 ,10 , jtag2,MFSEL4 ,0 , bmcuart1,MFSEL3 ,24 ,0 ),NPCM7XX_PINCFG (45 , uart1,MFSEL1 ,10 , jtag2,MFSEL4 ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (46 , uart1,MFSEL1 ,10 , jtag2,MFSEL4 ,0 , none,NONE ,0 ,DS (2 ,8 )), -NPCM7XX_PINCFG (47 , uart1,MFSEL1 ,10 , jtag2,MFSEL4 ,0 , none,NONE ,0 ,DS (2 ,8 )), +NPCM7XX_PINCFG (46 , uart1,MFSEL1 ,10 , jtag2,MFSEL4 ,0 , none,NONE ,0 ,DSTR (2 ,8 )), +NPCM7XX_PINCFG (47 , uart1,MFSEL1 ,10 , jtag2,MFSEL4 ,0 , none,NONE ,0 ,DSTR (2 ,8 )),NPCM7XX_PINCFG (48 , uart2,MFSEL1 ,11 , bmcuart0b,MFSEL4 ,1 , none,NONE ,0 ,GPO ),NPCM7XX_PINCFG (49 , uart2,MFSEL1 ,11 , bmcuart0b,MFSEL4 ,1 , none,NONE ,0 ,0 ), NPCM7XX_PINCFG(50, uart2, MFSEL1, 11, none, NONE, 0, none, NONE, 0, 0),
@@ -979,8 +979,8 @@ static const struct npcm7xx_pincfg pincfNPCM7XX_PINCFG (54 , uart2,MFSEL1 ,11 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (55 , uart2,MFSEL1 ,11 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (56 , r1err,MFSEL1 ,12 , none,NONE ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (57 , r1md,MFSEL1 ,13 , none,NONE ,0 , none,NONE ,0 ,DS (2 ,4 )), -NPCM7XX_PINCFG (58 , r1md,MFSEL1 ,13 , none,NONE ,0 , none,NONE ,0 ,DS (2 ,4 )), +NPCM7XX_PINCFG (57 , r1md,MFSEL1 ,13 , none,NONE ,0 , none,NONE ,0 ,DSTR (2 ,4 )), +NPCM7XX_PINCFG (58 , r1md,MFSEL1 ,13 , none,NONE ,0 , none,NONE ,0 ,DSTR (2 ,4 )),NPCM7XX_PINCFG (59 , smb3d,I2CSEGSEL ,13 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (60 , smb3d,I2CSEGSEL ,13 , none,NONE ,0 , none,NONE ,0 ,0 ), NPCM7XX_PINCFG(61, uart1, MFSEL1, 10, none, NONE, 0, none, NONE, 0, GPO),
@@ -1003,19 +1003,19 @@ static const struct npcm7xx_pincfg pincfNPCM7XX_PINCFG (77 , fanin13,MFSEL2 ,13 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (78 , fanin14,MFSEL2 ,14 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (79 , fanin15,MFSEL2 ,15 , none,NONE ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (80 , pwm0,MFSEL2 ,16 , none,NONE ,0 , none,NONE ,0 ,DS (4 ,8 )), -NPCM7XX_PINCFG (81 , pwm1,MFSEL2 ,17 , none,NONE ,0 , none,NONE ,0 ,DS (4 ,8 )), -NPCM7XX_PINCFG (82 , pwm2,MFSEL2 ,18 , none,NONE ,0 , none,NONE ,0 ,DS (4 ,8 )), -NPCM7XX_PINCFG (83 , pwm3,MFSEL2 ,19 , none,NONE ,0 , none,NONE ,0 ,DS (4 ,8 )), -NPCM7XX_PINCFG (84 , r2,MFSEL1 ,14 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (85 , r2,MFSEL1 ,14 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (86 , r2,MFSEL1 ,14 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (80 , pwm0,MFSEL2 ,16 , none,NONE ,0 , none,NONE ,0 ,DSTR (4 ,8 )), +NPCM7XX_PINCFG (81 , pwm1,MFSEL2 ,17 , none,NONE ,0 , none,NONE ,0 ,DSTR (4 ,8 )), +NPCM7XX_PINCFG (82 , pwm2,MFSEL2 ,18 , none,NONE ,0 , none,NONE ,0 ,DSTR (4 ,8 )), +NPCM7XX_PINCFG (83 , pwm3,MFSEL2 ,19 , none,NONE ,0 , none,NONE ,0 ,DSTR (4 ,8 )), +NPCM7XX_PINCFG (84 , r2,MFSEL1 ,14 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (85 , r2,MFSEL1 ,14 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (86 , r2,MFSEL1 ,14 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ),NPCM7XX_PINCFG (87 , r2,MFSEL1 ,14 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (88 , r2,MFSEL1 ,14 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (89 , r2,MFSEL1 ,14 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (90 , r2err,MFSEL1 ,15 , none,NONE ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (91 , r2md,MFSEL1 ,16 , none,NONE ,0 , none,NONE ,0 ,DS (2 ,4 )), -NPCM7XX_PINCFG (92 , r2md,MFSEL1 ,16 , none,NONE ,0 , none,NONE ,0 ,DS (2 ,4 )), +NPCM7XX_PINCFG (91 , r2md,MFSEL1 ,16 , none,NONE ,0 , none,NONE ,0 ,DSTR (2 ,4 )), +NPCM7XX_PINCFG (92 , r2md,MFSEL1 ,16 , none,NONE ,0 , none,NONE ,0 ,DSTR (2 ,4 )),NPCM7XX_PINCFG (93 , ga20kbc,MFSEL1 ,17 , smb5d,I2CSEGSEL ,21 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (94 , ga20kbc,MFSEL1 ,17 , smb5d,I2CSEGSEL ,21 , none,NONE ,0 ,0 ), NPCM7XX_PINCFG(95, lpc, NONE, 0, espi, MFSEL4, 8, gpio, MFSEL1, 26, 0),
@@ -1061,34 +1061,34 @@ static const struct npcm7xx_pincfg pincfNPCM7XX_PINCFG (133 , smb10,MFSEL4 ,13 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (134 , smb11,MFSEL4 ,14 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (135 , smb11,MFSEL4 ,14 , none,NONE ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (136 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (137 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (138 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (139 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (140 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (136 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (137 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (138 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (139 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (140 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ),NPCM7XX_PINCFG (141 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (142 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (142 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ),NPCM7XX_PINCFG (143 , sd1,MFSEL3 ,12 , sd1pwr,MFSEL4 ,5 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (144 , pwm4,MFSEL2 ,20 , none,NONE ,0 , none,NONE ,0 ,DS (4 ,8 )), -NPCM7XX_PINCFG (145 , pwm5,MFSEL2 ,21 , none,NONE ,0 , none,NONE ,0 ,DS (4 ,8 )), -NPCM7XX_PINCFG (146 , pwm6,MFSEL2 ,22 , none,NONE ,0 , none,NONE ,0 ,DS (4 ,8 )), -NPCM7XX_PINCFG (147 , pwm7,MFSEL2 ,23 , none,NONE ,0 , none,NONE ,0 ,DS (4 ,8 )), -NPCM7XX_PINCFG (148 , mmc8,MFSEL3 ,11 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (149 , mmc8,MFSEL3 ,11 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (150 , mmc8,MFSEL3 ,11 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (151 , mmc8,MFSEL3 ,11 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (152 , mmc,MFSEL3 ,10 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (144 , pwm4,MFSEL2 ,20 , none,NONE ,0 , none,NONE ,0 ,DSTR (4 ,8 )), +NPCM7XX_PINCFG (145 , pwm5,MFSEL2 ,21 , none,NONE ,0 , none,NONE ,0 ,DSTR (4 ,8 )), +NPCM7XX_PINCFG (146 , pwm6,MFSEL2 ,22 , none,NONE ,0 , none,NONE ,0 ,DSTR (4 ,8 )), +NPCM7XX_PINCFG (147 , pwm7,MFSEL2 ,23 , none,NONE ,0 , none,NONE ,0 ,DSTR (4 ,8 )), +NPCM7XX_PINCFG (148 , mmc8,MFSEL3 ,11 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (149 , mmc8,MFSEL3 ,11 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (150 , mmc8,MFSEL3 ,11 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (151 , mmc8,MFSEL3 ,11 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (152 , mmc,MFSEL3 ,10 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ),NPCM7XX_PINCFG (153 , mmcwp,FLOCKR1 ,24 , none,NONE ,0 , none,NONE ,0 ,0 ),/* Z1/A1 */ -NPCM7XX_PINCFG (154 , mmc,MFSEL3 ,10 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (154 , mmc,MFSEL3 ,10 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ),NPCM7XX_PINCFG (155 , mmccd,MFSEL3 ,25 , mmcrst,MFSEL4 ,6 , none,NONE ,0 ,0 ),/* Z1/A1 */ -NPCM7XX_PINCFG (156 , mmc,MFSEL3 ,10 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (157 , mmc,MFSEL3 ,10 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (158 , mmc,MFSEL3 ,10 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (159 , mmc,MFSEL3 ,10 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), - -NPCM7XX_PINCFG (160 , clkout,MFSEL1 ,21 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (161 , lpc,NONE ,0 , espi,MFSEL4 ,8 , gpio,MFSEL1 ,26 ,DS (8 ,12 )), -NPCM7XX_PINCFG (162 , serirq,NONE ,0 , gpio,MFSEL1 ,31 , none,NONE ,0 ,DS (8 ,12 )), +NPCM7XX_PINCFG (156 , mmc,MFSEL3 ,10 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (157 , mmc,MFSEL3 ,10 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (158 , mmc,MFSEL3 ,10 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (159 , mmc,MFSEL3 ,10 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), + +NPCM7XX_PINCFG (160 , clkout,MFSEL1 ,21 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (161 , lpc,NONE ,0 , espi,MFSEL4 ,8 , gpio,MFSEL1 ,26 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (162 , serirq,NONE ,0 , gpio,MFSEL1 ,31 , none,NONE ,0 ,DSTR (8 ,12 )),NPCM7XX_PINCFG (163 , lpc,NONE ,0 , espi,MFSEL4 ,8 , gpio,MFSEL1 ,26 ,0 ),NPCM7XX_PINCFG (164 , lpc,NONE ,0 , espi,MFSEL4 ,8 , gpio,MFSEL1 ,26 ,SLEWLPC ), NPCM7XX_PINCFG(165, lpc, NONE, 0, espi, MFSEL4, 8, gpio, MFSEL1, 26, SLEWLPC),
@@ -1101,25 +1101,25 @@ static const struct npcm7xx_pincfg pincfNPCM7XX_PINCFG (172 , smb6,MFSEL3 ,1 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (173 , smb7,MFSEL3 ,2 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (174 , smb7,MFSEL3 ,2 , none,NONE ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (175 , pspi1,MFSEL3 ,4 , faninx,MFSEL3 ,3 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (176 , pspi1,MFSEL3 ,4 , faninx,MFSEL3 ,3 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (177 , pspi1,MFSEL3 ,4 , faninx,MFSEL3 ,3 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (178 , r1,MFSEL3 ,9 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (179 , r1,MFSEL3 ,9 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (180 , r1,MFSEL3 ,9 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (175 , pspi1,MFSEL3 ,4 , faninx,MFSEL3 ,3 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (176 , pspi1,MFSEL3 ,4 , faninx,MFSEL3 ,3 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (177 , pspi1,MFSEL3 ,4 , faninx,MFSEL3 ,3 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (178 , r1,MFSEL3 ,9 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (179 , r1,MFSEL3 ,9 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (180 , r1,MFSEL3 ,9 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ),NPCM7XX_PINCFG (181 , r1,MFSEL3 ,9 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (182 , r1,MFSEL3 ,9 , none,NONE ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (183 , spi3,MFSEL4 ,16 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (184 , spi3,MFSEL4 ,16 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW |GPO ), -NPCM7XX_PINCFG (185 , spi3,MFSEL4 ,16 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW |GPO ), -NPCM7XX_PINCFG (186 , spi3,MFSEL4 ,16 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (187 , spi3cs1,MFSEL4 ,17 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (188 , spi3quad,MFSEL4 ,20 , spi3cs2,MFSEL4 ,18 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (189 , spi3quad,MFSEL4 ,20 , spi3cs3,MFSEL4 ,19 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (190 , gpio,FLOCKR1 ,20 , nprd_smi,NONE ,0 , none,NONE ,0 ,DS (2 ,4 )), -NPCM7XX_PINCFG (191 , none,NONE ,0 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )),/* XX */ +NPCM7XX_PINCFG (183 , spi3,MFSEL4 ,16 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (184 , spi3,MFSEL4 ,16 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW |GPO ), +NPCM7XX_PINCFG (185 , spi3,MFSEL4 ,16 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW |GPO ), +NPCM7XX_PINCFG (186 , spi3,MFSEL4 ,16 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (187 , spi3cs1,MFSEL4 ,17 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (188 , spi3quad,MFSEL4 ,20 , spi3cs2,MFSEL4 ,18 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (189 , spi3quad,MFSEL4 ,20 , spi3cs3,MFSEL4 ,19 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (190 , gpio,FLOCKR1 ,20 , nprd_smi,NONE ,0 , none,NONE ,0 ,DSTR (2 ,4 )), +NPCM7XX_PINCFG (191 , none,NONE ,0 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )),/* XX */ -NPCM7XX_PINCFG (192 , none,NONE ,0 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )),/* XX */ +NPCM7XX_PINCFG (192 , none,NONE ,0 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )),/* XX */ NPCM7XX_PINCFG (193 , r1,MFSEL3 ,9 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (194 , smb0b,I2CSEGSEL ,0 , none,NONE ,0 , none,NONE ,0 ,0 ), NPCM7XX_PINCFG(195, smb0b, I2CSEGSEL, 0, none, NONE, 0, none, NONE, 0, 0),
@@ -1130,11 +1130,11 @@ static const struct npcm7xx_pincfg pincfNPCM7XX_PINCFG (200 , r2,MFSEL1 ,14 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (201 , r1,MFSEL3 ,9 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (202 , smb0c,I2CSEGSEL ,1 , none,NONE ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (203 , faninx,MFSEL3 ,3 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), +NPCM7XX_PINCFG (203 , faninx,MFSEL3 ,3 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )),NPCM7XX_PINCFG (204 , ddc,NONE ,0 , gpio,MFSEL3 ,22 , none,NONE ,0 ,SLEW ),NPCM7XX_PINCFG (205 , ddc,NONE ,0 , gpio,MFSEL3 ,22 , none,NONE ,0 ,SLEW ), -NPCM7XX_PINCFG (206 , ddc,NONE ,0 , gpio,MFSEL3 ,22 , none,NONE ,0 ,DS (4 ,8 )), -NPCM7XX_PINCFG (207 , ddc,NONE ,0 , gpio,MFSEL3 ,22 , none,NONE ,0 ,DS (4 ,8 )), +NPCM7XX_PINCFG (206 , ddc,NONE ,0 , gpio,MFSEL3 ,22 , none,NONE ,0 ,DSTR (4 ,8 )), +NPCM7XX_PINCFG (207 , ddc,NONE ,0 , gpio,MFSEL3 ,22 , none,NONE ,0 ,DSTR (4 ,8 )),NPCM7XX_PINCFG (208 , rg2,MFSEL4 ,24 , ddr,MFSEL3 ,26 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (209 , rg2,MFSEL4 ,24 , ddr,MFSEL3 ,26 , none,NONE ,0 ,0 ), NPCM7XX_PINCFG(210, rg2, MFSEL4, 24, ddr, MFSEL3, 26, none, NONE, 0, 0),
@@ -1146,20 +1146,20 @@ static const struct npcm7xx_pincfg pincfNPCM7XX_PINCFG (216 , rg2mdio,MFSEL4 ,23 , ddr,MFSEL3 ,26 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (217 , rg2mdio,MFSEL4 ,23 , ddr,MFSEL3 ,26 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (218 , wdog1,MFSEL3 ,19 , none,NONE ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (219 , wdog2,MFSEL3 ,20 , none,NONE ,0 , none,NONE ,0 ,DS (4 ,8 )), +NPCM7XX_PINCFG (219 , wdog2,MFSEL3 ,20 , none,NONE ,0 , none,NONE ,0 ,DSTR (4 ,8 )),NPCM7XX_PINCFG (220 , smb12,MFSEL3 ,5 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (221 , smb12,MFSEL3 ,5 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (222 , smb13,MFSEL3 ,6 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (223 , smb13,MFSEL3 ,6 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (224 , spix,MFSEL4 ,27 , none,NONE ,0 , none,NONE ,0 ,SLEW ), -NPCM7XX_PINCFG (225 , spix,MFSEL4 ,27 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW |GPO ), -NPCM7XX_PINCFG (226 , spix,MFSEL4 ,27 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW |GPO ), -NPCM7XX_PINCFG (227 , spix,MFSEL4 ,27 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (228 , spixcs1,MFSEL4 ,28 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (229 , spix,MFSEL4 ,27 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (230 , spix,MFSEL4 ,27 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (231 , clkreq,MFSEL4 ,9 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), +NPCM7XX_PINCFG (225 , spix,MFSEL4 ,27 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW |GPO ), +NPCM7XX_PINCFG (226 , spix,MFSEL4 ,27 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW |GPO ), +NPCM7XX_PINCFG (227 , spix,MFSEL4 ,27 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (228 , spixcs1,MFSEL4 ,28 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (229 , spix,MFSEL4 ,27 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (230 , spix,MFSEL4 ,27 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (231 , clkreq,MFSEL4 ,9 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )),NPCM7XX_PINCFG (253 , none,NONE ,0 , none,NONE ,0 , none,NONE ,0 ,GPI ),/* SDHC1 power */ NPCM7XX_PINCFG (254 , none,NONE ,0 , none,NONE ,0 , none,NONE ,0 ,GPI ),/* SDHC2 power */ NPCM7XX_PINCFG(255, none, NONE, 0, none, NONE, 0, none, NONE, 0, GPI), /* DACOSEL */
Greg Kroah-Hartman
maintainerPATCH 346/475 pinctrl: nuvoton: npcm7xx: Use %zu printk format for ARRAY_SIZE()
In reply to Greg Kroah-HartmanFrom: Jonathan Neuschäfer <[email protected]>
commit 9d0f18bca3b557ae5d2128661ac06d33b3f45c0a upstream.
When compile-testing on 64-bit architectures, GCC complains about the mismatch of types between the %d format specifier and value returned by ARRAY_LENGTH(). Use %zu, which is correct everywhere.
--- drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c +1 -1
@@ -1560,7 +1560,7 @@ static int npcm7xx_get_groups_count(stru {struct npcm7xx_pinctrl *npcm =pinctrl_dev_get_drvdata (pctldev); -dev_dbg (npcm->dev,"group size: %d\n" ,ARRAY_SIZE (npcm7xx_groups)); +dev_dbg (npcm->dev,"group size: %zu\n" ,ARRAY_SIZE (npcm7xx_groups));return ARRAY_SIZE (npcm7xx_groups); }
Greg Kroah-Hartman
maintainerPATCH 347/475 ASoC: mediatek: mt6358: add missing EXPORT_SYMBOLs
In reply to Greg Kroah-HartmanFrom: Jiaxin Yu <[email protected]>
commit a7663c89f4193dbf717572e46e5a3251940dbdc8 upstream.
Fixes the following build errors when mt6358 is configured as module:
Quoted 4 lines
Quoted 4 lines
ERROR: modpost: "
mt6358_set_mtkaif_protocol" [sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.ko] undefined!
ERROR: modpost: "mt6358_set_mtkaif_protocol" [sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.ko] undefined!
--- sound/soc/codecs/mt6358.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/soc/codecs/mt6358.c +4 -0
@@ -103,6 +103,7 @@ int mt6358_set_mtkaif_protocol(struct sn priv->mtkaif_protocol = mtkaif_protocol;return 0 ; } +EXPORT_SYMBOL_GPL (mt6358_set_mtkaif_protocol);static void playback_gpio_set (struct mt6358_priv *priv) {
@@ -269,6 +270,7 @@ int mt6358_mtkaif_calibration_enable(str 1 << RG_AUD_PAD_TOP_DAT_MISO_LOOPBACK_SFT);return 0 ; } +EXPORT_SYMBOL_GPL (mt6358_mtkaif_calibration_enable);int mt6358_mtkaif_calibration_disable (struct snd_soc_component *cmpnt) {
@@ -292,6 +294,7 @@ int mt6358_mtkaif_calibration_disable(stcapture_gpio_reset (priv);return 0 ; } +EXPORT_SYMBOL_GPL (mt6358_mtkaif_calibration_disable);int mt6358_set_mtkaif_calibration_phase (struct snd_soc_component *cmpnt,int phase_1,int phase_2)
@@ -306,6 +309,7 @@ int mt6358_set_mtkaif_calibration_phase( phase_2 << RG_AUD_PAD_TOP_PHASE_MODE2_SFT);return 0 ; } +EXPORT_SYMBOL_GPL (mt6358_set_mtkaif_calibration_phase);/* dl pga gain */ enum {
Greg Kroah-Hartman
maintainerPATCH 348/475 ubi: Fix race condition between ctrl_cdev_ioctl and ubi_cdev_ioctl
In reply to Greg Kroah-HartmanFrom: Baokun Li <[email protected]>
commit 3cbf0e392f173ba0ce425968c8374a6aa3e90f2e upstream.
Hulk Robot reported a KASAN report about use-after-free:
==================================================================
BUG: KASAN: use-after-free in __list_del_entry_valid+0x13d/0x160 Read of size 8 at addr ffff888035e37d98 by task ubiattach/1385 [...] Call Trace: klist_dec_and_del+0xa7/0x4a0 klist_put+0xc7/0x1a0 device_del+0x4d4/0xed0 cdev_device_del+0x1a/0x80 ubi_attach_mtd_dev+0x2951/0x34b0 [ubi] ctrl_cdev_ioctl+0x286/0x2f0 [ubi] Allocated by task 1414: device_add+0x60a/0x18b0 cdev_device_add+0x103/0x170 ubi_create_volume+0x1118/0x1a10 [ubi] ubi_cdev_ioctl+0xb7f/0x1ba0 [ubi] Freed by task 1385: cdev_device_del+0x1a/0x80 ubi_remove_volume+0x438/0x6c0 [ubi] ubi_cdev_ioctl+0xbf4/0x1ba0 [ubi] [...] ==================================================================
The lock held by ctrl_cdev_ioctl is ubi_devices_mutex, but the lock held by ubi_cdev_ioctl is ubi->device_mutex. Therefore, the two locks can be concurrent.
ctrl_cdev_ioctl contains two operations: ubi_attach and ubi_detach. ubi_detach is bug-free because it uses reference counting to prevent concurrency. However, uif_init and uif_close in ubi_attach may race with ubi_cdev_ioctl.
uif_init will race with ubi_cdev_ioctl as in the following stack.
cpu1 cpu2 cpu3
_______________________|________________________|______________________ ctrl_cdev_ioctl
ubi_attach_mtd_dev
uif_init
ubi_cdev_ioctl
ubi_create_volume
cdev_device_add
ubi_add_volume
// sysfs exist
kill_volumes
ubi_cdev_ioctl
ubi_remove_volume
cdev_device_del
// first free
ubi_free_volume
cdev_del
// double free cdev_device_del
And uif_close will race with ubi_cdev_ioctl as in the following stack.
cpu1 cpu2 cpu3
_______________________|________________________|______________________ ctrl_cdev_ioctl
ubi_attach_mtd_dev
uif_init
ubi_cdev_ioctl
ubi_create_volume
cdev_device_add
ubi_debugfs_init_dev
//error goto out_uif;
uif_close
kill_volumes
ubi_cdev_ioctl
ubi_remove_volume
cdev_device_del
// first free
ubi_free_volume
// double freeThe cause of this problem is that commit 714fb87e8bc0 make device "available" before it becomes accessible via sysfs. Therefore, we roll back the modification. We will fix the race condition between ubi device creation and udev by removing ubi_get_device in vol_attribute_show and dev_attribute_show.This avoids accessing uninitialized ubi_devices[ubi_num].
ubi_get_device is used to prevent devices from being deleted during sysfs execution. However, now kernfs ensures that devices will not be deleted before all reference counting are released. The key process is shown in the following stack.
device_del
device_remove_attrs
device_remove_groups
sysfs_remove_groups
sysfs_remove_group
remove_files
kernfs_remove_by_name
kernfs_remove_by_name_ns
__kernfs_remove
kernfs_drain
--- drivers/mtd/ubi/build.c | 9 +-------- drivers/mtd/ubi/vmt.c | 8 +------- 2 files changed, 2 insertions(+), 15 deletions(-)
drivers/mtd/ubi/build.c +1 -8
@@ -350,9 +350,6 @@ static ssize_t dev_attribute_show(struct* we still can use 'ubi->ubi_num'. */ ubi = container_of(dev, struct ubi_device, dev); - ubi =ubi_get_device (ubi->ubi_num); -if (!ubi) -return -ENODEV ;if (attr == &dev_eraseblock_size) ret =sprintf (buf,"%d\n" , ubi->leb_size);
@@ -381,7 +378,6 @@ static ssize_t dev_attribute_show(structelse ret = -EINVAL ; -ubi_put_device (ubi);return ret; }
@@ -956,9 +952,6 @@ int ubi_attach_mtd_dev(struct mtd_info * goto out_detach; } -/* Make device "available" before it becomes accessible via sysfs */ - ubi_devices[ubi_num] = ubi; - err =uif_init (ubi);if (err) goto out_detach;
@@ -1003,6 +996,7 @@ int ubi_attach_mtd_dev(struct mtd_info *wake_up_process (ubi->bgt_thread);spin_unlock (&ubi->wl_lock); + ubi_devices[ubi_num] = ubi;ubi_notify_all (ubi,UBI_VOLUME_ADDED ,NULL );return ubi_num;
@@ -1011,7 +1005,6 @@ out_debugfs: out_uif:uif_close (ubi); out_detach: - ubi_devices[ubi_num] =NULL ;ubi_wl_close (ubi);ubi_free_internal_volumes (ubi);vfree (ubi->vtbl);
drivers/mtd/ubi/vmt.c +1 -7
@@ -56,16 +56,11 @@ static ssize_t vol_attribute_show(struct {int ret; struct ubi_volume *vol = container_of(dev, struct ubi_volume, dev); -struct ubi_device *ubi; - - ubi =ubi_get_device (vol->ubi->ubi_num); -if (!ubi) -return -ENODEV ; +struct ubi_device *ubi = vol->ubi;spin_lock (&ubi->volumes_lock);if (!ubi->volumes[vol->vol_id]) {spin_unlock (&ubi->volumes_lock); -ubi_put_device (ubi);return -ENODEV ; }/* Take a reference to prevent volume removal */
@@ -103,7 +98,6 @@ static ssize_t vol_attribute_show(struct vol->ref_count -=1 ;ubi_assert (vol->ref_count >=0 );spin_unlock (&ubi->volumes_lock); -ubi_put_device (ubi);return ret; }
Greg Kroah-Hartman
maintainerPATCH 349/475 ARM: iop32x: offset IRQ numbers by 1
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
commit 9d67412f24cc3a2c05f35f7c856addb07a2960ce upstream.
iop32x is one of the last platforms to use IRQ 0, and this has apparently stopped working in a 2014 cleanup without anyone noticing. This interrupt is used for the DMA engine, so most likely this has not actually worked in the past 7 years, but it's also not essential for using this board.
I'm splitting out this change from my GENERIC_IRQ_MULTI_HANDLER conversion so it can be backported if anyone cares.
--- arch/arm/mach-iop32x/include/mach/entry-macro.S | 2 arch/arm/mach-iop32x/include/mach/irqs.h | 2 arch/arm/mach-iop32x/irq.c | 6 +- arch/arm/mach-iop32x/irqs.h | 60 ++++++++++++------------ 4 files changed, 37 insertions(+), 33 deletions(-)
arch/arm/mach-iop32x/include/mach/entry-macro.S +1 -1
@@ -20,7 +20,7 @@ mrc p6, 0, \irqstat, c8, c0, 0 @ Read IINTSRC cmp \irqstat, #0 clzne \irqnr, \irqstat - rsbne \irqnr, \irqnr, #31 + rsbne \irqnr, \irqnr, #32 .endm .macro arch_ret_to_user, tmp1, tmp2
arch/arm/mach-iop32x/include/mach/irqs.h +1 -1
@@ -9,6 +9,6 @@#ifndef __IRQS_H#define __IRQS_H -#define NR_IRQS 32 +#define NR_IRQS 33#endif
arch/arm/mach-iop32x/irq.c +3 -3
@@ -32,14 +32,14 @@ static void intstr_write(u32 val)static void iop32x_irq_mask (struct irq_data *d) { - iop32x_mask &= ~(1 << d->irq); + iop32x_mask &= ~(1 << (d->irq -1 ));intctl_write (iop32x_mask); }static void iop32x_irq_unmask (struct irq_data *d) { - iop32x_mask |=1 << d->irq; + iop32x_mask |=1 << (d->irq -1 );intctl_write (iop32x_mask); }
@@ -65,7 +65,7 @@ void __init iop32x_init_irq(void) machine_is_em7210()) *IOP3XX_PCIIRSR =0x0f ; -for (i =0 ; i <NR_IRQS ; i++) { +for (i =1 ; i <NR_IRQS ; i++) {irq_set_chip_and_handler (i, &ext_chip, handle_level_irq);irq_clear_status_flags (i,IRQ_NOREQUEST |IRQ_NOPROBE ); }
arch/arm/mach-iop32x/irqs.h +32 -28
68 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 350/475 ACPI: CPPC: Avoid out of bounds access when parsing _CPC data
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
commit 40d8abf364bcab23bc715a9221a3c8623956257b upstream.
If the NumEntries field in the _CPC return package is less than 2, do not attempt to access the "Revision" element of that package, because it may not be present then.
--- drivers/acpi/cppc_acpi.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/acpi/cppc_acpi.c +5 -0
@@ -738,6 +738,11 @@ int acpi_cppc_processor_probe(struct acp cpc_obj = &out_obj->package.elements[0 ];if (cpc_obj->type ==ACPI_TYPE_INTEGER ) { num_ent = cpc_obj->integer.value; +if (num_ent <=1 ) { +pr_debug ("Unexpected _CPC NumEntries value (%d) for CPU:%d\n" , + num_ent, pr->id); + goto out_free; + } }else {pr_debug ("Unexpected entry type(%d) for NumEntries\n" , cpc_obj->type);
Greg Kroah-Hartman
maintainerPATCH 351/475 powerpc/kasan: Fix early region not updated correctly
In reply to Greg Kroah-HartmanFrom: Chen Jingwen <[email protected]>
commit dd75080aa8409ce10d50fb58981c6b59bf8707d3 upstream.
The shadow's page table is not updated when PTE_RPN_SHIFT is 24 and PAGE_SHIFT is 12. It not only causes false positives but also false negative as shown the following text.
Fix it by bringing the logic of kasan_early_shadow_page_entry here.
1. False Positive:
==================================================================
BUG: KASAN: vmalloc-out-of-bounds in pcpu_alloc+0x508/0xa50
Write of size 16 at addr f57f3be0 by task swapper/0/1
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.15.0-12267-gdebe436e77c7 #1
Call Trace:
[c80d1c20] [c07fe7b8] dump_stack_lvl+0x4c/0x6c (unreliable)
[c80d1c40] [c02ff668] print_address_description.constprop.0+0x88/0x300
[c80d1c70] [c02ff45c] kasan_report+0x1ec/0x200
[c80d1cb0] [c0300b20] kasan_check_range+0x160/0x2f0
[c80d1cc0] [c03018a4] memset+0x34/0x90
[c80d1ce0] [c0280108] pcpu_alloc+0x508/0xa50
[c80d1d40] [c02fd7bc] __kmem_cache_create+0xfc/0x570
[c80d1d70] [c0283d64] kmem_cache_create_usercopy+0x274/0x3e0
[c80d1db0] [c2036580] init_sd+0xc4/0x1d0
[c80d1de0] [c00044a0] do_one_initcall+0xc0/0x33c
[c80d1eb0] [c2001624] kernel_init_freeable+0x2c8/0x384
[c80d1ef0] [c0004b14] kernel_init+0x24/0x170
[c80d1f10] [c001b26c] ret_from_kernel_thread+0x5c/0x64
Memory state around the buggy address:
f57f3a80: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
f57f3b00: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
>f57f3b80: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
^
f57f3c00: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
f57f3c80: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
==================================================================2. False Negative (with KASAN tests):
==================================================================
Before fix:
ok 45 - kmalloc_double_kzfree
# vmalloc_oob: EXPECTATION FAILED at lib/test_kasan.c:1039 KASAN failure expected in "((volatile char *)area)[3100]", but none occurred not ok 46 - vmalloc_oob
not ok 1 - kasan
==================================================================
After fix:
ok 1 - kasan
--- arch/powerpc/mm/kasan/kasan_init_32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/mm/kasan/kasan_init_32.c +1 -1
@@ -121,7 +121,7 @@ static void __init kasan_remap_early_shapmd_t *pmd =pmd_offset (pud_offset (pgd_offset_k (k_cur), k_cur), k_cur);pte_t *ptep =pte_offset_kernel (pmd, k_cur); -if ((pte_val (*ptep) &PTE_RPN_MASK ) != pa) +if (pte_page (*ptep) !=virt_to_page (lm_alias (kasan_early_shadow_page)))continue ;__set_pte_at (&init_mm, k_cur, ptep,pfn_pte (PHYS_PFN (pa), prot),0 );
Greg Kroah-Hartman
maintainerPATCH 352/475 ASoC: soc-compress: Change the check for codec_dai
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
commit ccb4214f7f2a8b75acf493f31128e464ee1a3536 upstream.
It should be better to reverse the check on codec_dai and returned early in order to be easier to understand.
--- sound/soc/soc-compress.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
sound/soc/soc-compress.c +11 -8
@@ -871,16 +871,19 @@ int snd_soc_new_compress(struct snd_soc_return -EINVAL ; } -/* check client and interface hw capabilities */ -if (codec_dai) { -if (snd_soc_dai_stream_valid (codec_dai,SNDRV_PCM_STREAM_PLAYBACK ) && -snd_soc_dai_stream_valid (cpu_dai,SNDRV_PCM_STREAM_PLAYBACK )) - playback =1 ; -if (snd_soc_dai_stream_valid (codec_dai,SNDRV_PCM_STREAM_CAPTURE ) && -snd_soc_dai_stream_valid (cpu_dai,SNDRV_PCM_STREAM_CAPTURE )) - capture =1 ; +if (!codec_dai) { +dev_err (rtd->card->dev,"Missing codec\n" ); +return -EINVAL ; } +/* check client and interface hw capabilities */ +if (snd_soc_dai_stream_valid (codec_dai,SNDRV_PCM_STREAM_PLAYBACK ) && +snd_soc_dai_stream_valid (cpu_dai,SNDRV_PCM_STREAM_PLAYBACK )) + playback =1 ; +if (snd_soc_dai_stream_valid (codec_dai,SNDRV_PCM_STREAM_CAPTURE ) && +snd_soc_dai_stream_valid (cpu_dai,SNDRV_PCM_STREAM_CAPTURE )) + capture =1 ; +/* * Compress devices are unidirectional so only one of the directions * should be set, check for that (xor)
Greg Kroah-Hartman
maintainerPATCH 353/475 mm/mmap: return 1 from stack_guard_gap __setup() handler
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
commit e6d094936988910ce6e8197570f2753898830081 upstream.
__setup() handlers should return 1 if the command line option is handled and 0 if not (or maybe never return 0; it just pollutes init's environment). This prevents:
Unknown kernel command line parameters \ "BOOT_IMAGE=/boot/bzImage-517rc5 stack_guard_gap=100", will be \ passed to user space.
Run /sbin/init as init process
with arguments:
/sbin/init
with environment:
HOME=/
TERM=linux
BOOT_IMAGE=/boot/bzImage-517rc5
stack_guard_gap=100Return 1 to indicate that the boot option has been handled.
Note that there is no warning message if someone enters:
stack_guard_gap=anything_invalid
and 'val' and stack_guard_gap are both set to 0 due to the use of simple_strtoul(). This could be improved by using kstrtoxxx() and checking for an error.
It appears that having stack_guard_gap == 0 is valid (if unexpected) since using "stack_guard_gap=0" on the kernel command line does that.
--- mm/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/mmap.c +1 -1
@@ -2515,7 +2515,7 @@ static int __init cmdline_parse_stack_guif (!*endptr) stack_guard_gap = val <<PAGE_SHIFT ; -return 0 ; +return 1 ; }__setup ("stack_guard_gap=" , cmdline_parse_stack_guard_gap);
Greg Kroah-Hartman
maintainerPATCH 354/475 mm/memcontrol: return 1 from cgroup.memory __setup() handler
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
commit 460a79e18842caca6fa0c415de4a3ac1e671ac50 upstream.
__setup() handlers should return 1 if the command line option is handled and 0 if not (or maybe never return 0; it just pollutes init's environment).
The only reason that this particular __setup handler does not pollute init's environment is that the setup string contains a '.', as in "cgroup.memory". This causes init/main.c::unknown_boottoption() to consider it to be an "Unused module parameter" and ignore it. (This is for parsing of loadable module parameters any time after kernel init.) Otherwise the string "cgroup.memory=whatever" would be added to init's environment strings.
Instead of relying on this '.' quirk, just return 1 to indicate that the boot option has been handled.
Note that there is no warning message if someone enters:
cgroup.memory=anything_invalid
--- mm/memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memcontrol.c +1 -1
@@ -6973,7 +6973,7 @@ static int __init cgroup_memory(char *s)if (!strcmp (token,"nokmem" )) cgroup_memory_nokmem = true; } -return 0 ; +return 1 ; }__setup ("cgroup.memory=" , cgroup_memory);
Greg Kroah-Hartman
maintainerPATCH 355/475 mm/usercopy: return 1 from hardened_usercopy __setup() handler
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
commit 05fe3c103f7e6b8b4fca8a7001dfc9ed4628085b upstream.
__setup() handlers should return 1 if the command line option is handled and 0 if not (or maybe never return 0; it just pollutes init's environment). This prevents:
Unknown kernel command line parameters \ "BOOT_IMAGE=/boot/bzImage-517rc5 hardened_usercopy=off", will be \ passed to user space.
Run /sbin/init as init process
with arguments:
/sbin/init
with environment:
HOME=/
TERM=linux
BOOT_IMAGE=/boot/bzImage-517rc5
hardened_usercopy=offor
hardened_usercopy=on
but when "hardened_usercopy=foo" is used, there is no Unknown kernel command line parameter.
Return 1 to indicate that the boot option has been handled. Print a warning if strtobool() returns an error on the option string, but do not mark this as in unknown command line option and do not cause init's environment to be polluted with this string.
--- mm/usercopy.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
mm/usercopy.c +4 -1
@@ -294,7 +294,10 @@ static bool enable_checks __initdata = tstatic int __init parse_hardened_usercopy (char *str) { -return strtobool (str, &enable_checks); +if (strtobool (str, &enable_checks)) +pr_warn ("Invalid option string for hardened_usercopy: '%s'\n" , + str); +return 1 ; }__setup ("hardened_usercopy=" , parse_hardened_usercopy);
Greg Kroah-Hartman
maintainerPATCH 356/475 bpf: Fix comment for helper bpf_current_task_under_cgroup()
In reply to Greg Kroah-HartmanFrom: Hengqi Chen <[email protected]>
commit 58617014405ad5c9f94f464444f4972dabb71ca7 upstream.
Fix the descriptions of the return values of helper bpf_current_task_under_cgroup().
--- include/uapi/linux/bpf.h | 4 ++-- tools/include/uapi/linux/bpf.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
include/uapi/linux/bpf.h +2 -2
@@ -1294,8 +1294,8 @@ union bpf_attr {* Return * The return value depends on the result of the test, and can be: * -* * 0, if current task belongs to the cgroup2. -* * 1, if current task does not belong to the cgroup2. +* * 1, if current task belongs to the cgroup2. +* * 0, if current task does not belong to the cgroup2. * * A negative error code, if an error occurred. * * int bpf_skb_change_tail(struct sk_buff *skb, u32 len, u64 flags)
tools/include/uapi/linux/bpf.h +2 -2
@@ -1294,8 +1294,8 @@ union bpf_attr {* Return * The return value depends on the result of the test, and can be: * -* * 0, if current task belongs to the cgroup2. -* * 1, if current task does not belong to the cgroup2. +* * 1, if current task belongs to the cgroup2. +* * 0, if current task does not belong to the cgroup2. * * A negative error code, if an error occurred. * * int bpf_skb_change_tail(struct sk_buff *skb, u32 len, u64 flags)
Greg Kroah-Hartman
maintainerPATCH 357/475 dt-bindings: mtd: nand-controller: Fix the reg property description
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
commit 93f2ec9e401276fb4ea9903194a5bfcf175f9a2c upstream.
The reg property of a NAND device always references the chip-selects. The ready/busy lines are described in the nand-rb property. I believe this was a harmless copy/paste error during the conversion to yaml.
--- Documentation/devicetree/bindings/mtd/nand-controller.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/mtd/nand-controller.yaml +1 -1
@@ -44,7 +44,7 @@ patternProperties: properties: reg: description: - Contains the native Ready/Busy IDs. + Contains the chip-select IDs. nand-ecc-mode: allOf:
Greg Kroah-Hartman
maintainerPATCH 358/475 dt-bindings: mtd: nand-controller: Fix a comment in the examples
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
commit 0e7f1b557974ce297e5e4c9d4245720fbb489886 upstream.
The controller properties should be in the controller 'parent' node, while properties in the children nodes are specific to the NAND *chip*. This error was already present during the yaml conversion.
--- Documentation/devicetree/bindings/mtd/nand-controller.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/mtd/nand-controller.yaml +1 -1
@@ -139,6 +139,6 @@ examples: nand-ecc-mode = "soft"; nand-ecc-algo = "bch"; - /* controller specific properties */ + /* NAND chip specific properties */ }; };
Greg Kroah-Hartman
maintainerPATCH 359/475 dt-bindings: spi: mxic: The interrupt property is not mandatory
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
commit 90c204d3195a795f77f5bce767e311dd1c59ca17 upstream.
The interrupt property is not mandatory at all, this property should not be part of the required properties list, so move it into the optional properties list.
--- Documentation/devicetree/bindings/spi/spi-mxic.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/spi/spi-mxic.txt +3 -1
@@ -8,11 +8,13 @@ Required properties: - reg: should contain 2 entries, one for the registers and one for the direct mapping area - reg-names: should contain "regs" and "dirmap" -- interrupts: interrupt line connected to the SPI controller - clock-names: should contain "ps_clk", "send_clk" and "send_dly_clk" - clocks: should contain 3 entries for the "ps_clk", "send_clk" and "send_dly_clk" clocks +Optional properties: +- interrupts: interrupt line connected to the SPI controller + Example: spi@43c30000 {
Greg Kroah-Hartman
maintainerPATCH 360/475 ubi: fastmap: Return error code if memory allocation fails in add_aeb()
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit c3c07fc25f37c157fde041b3a0c3dfcb1590cbce upstream.
Abort fastmap scanning and return error code if memory allocation fails in add_aeb(). Otherwise ubi will get wrong peb statistics information after scanning.
--- drivers/mtd/ubi/fastmap.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-)
drivers/mtd/ubi/fastmap.c +19 -9
@@ -468,7 +468,9 @@ static int scan_pool(struct ubi_device *if (err ==UBI_IO_FF_BITFLIPS ) scrub =1 ; -add_aeb (ai, free, pnum, ec, scrub); + ret =add_aeb (ai, free, pnum, ec, scrub); +if (ret) + goto out;continue ; }else if (err ==0 || err ==UBI_IO_BITFLIPS ) {dbg_bld ("Found non empty PEB:%i in pool" , pnum);
@@ -638,8 +640,10 @@ static int ubi_attach_fastmap(struct ubiif (fm_pos >= fm_size) goto fail_bad; -add_aeb (ai, &ai->free,be32_to_cpu (fmec->pnum), -be32_to_cpu (fmec->ec),0 ); + ret =add_aeb (ai, &ai->free,be32_to_cpu (fmec->pnum), +be32_to_cpu (fmec->ec),0 ); +if (ret) + goto fail; }/* read EC values from used list */
@@ -649,8 +653,10 @@ static int ubi_attach_fastmap(struct ubiif (fm_pos >= fm_size) goto fail_bad; -add_aeb (ai, &used,be32_to_cpu (fmec->pnum), -be32_to_cpu (fmec->ec),0 ); + ret =add_aeb (ai, &used,be32_to_cpu (fmec->pnum), +be32_to_cpu (fmec->ec),0 ); +if (ret) + goto fail; }/* read EC values from scrub list */
@@ -660,8 +666,10 @@ static int ubi_attach_fastmap(struct ubiif (fm_pos >= fm_size) goto fail_bad; -add_aeb (ai, &used,be32_to_cpu (fmec->pnum), -be32_to_cpu (fmec->ec),1 ); + ret =add_aeb (ai, &used,be32_to_cpu (fmec->pnum), +be32_to_cpu (fmec->ec),1 ); +if (ret) + goto fail; }/* read EC values from erase list */
@@ -671,8 +679,10 @@ static int ubi_attach_fastmap(struct ubiif (fm_pos >= fm_size) goto fail_bad; -add_aeb (ai, &ai->erase,be32_to_cpu (fmec->pnum), -be32_to_cpu (fmec->ec),1 ); + ret =add_aeb (ai, &ai->erase,be32_to_cpu (fmec->pnum), +be32_to_cpu (fmec->ec),1 ); +if (ret) + goto fail; } ai->mean_ec =div_u64 (ai->ec_sum, ai->ec_count);
Greg Kroah-Hartman
maintainerPATCH 361/475 ASoC: topology: Allow TLV control to be either read or write
In reply to Greg Kroah-HartmanFrom: Amadeusz Sławiński <[email protected]>
commit feb00b736af64875560f371fe7f58b0b7f239046 upstream.
There is no reason to force readwrite access on TLV controls. It can be either read, write or both. This is further evidenced in code where it performs following checks:
if ((k->access & SNDRV_CTL_ELEM_ACCESS_TLV_READ) && !sbe->get)
return -EINVAL;
if ((k->access & SNDRV_CTL_ELEM_ACCESS_TLV_WRITE) && !sbe->put)
return -EINVAL;--- sound/soc/soc-topology.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/soc-topology.c +2 -1
@@ -587,7 +587,8 @@ static int soc_tplg_kcontrol_bind_io(strif (le32_to_cpu (hdr->ops.info) ==SND_SOC_TPLG_CTL_BYTES && k->iface &SNDRV_CTL_ELEM_IFACE_MIXER - && k->access &SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE + && (k->access &SNDRV_CTL_ELEM_ACCESS_TLV_READ + || k->access &SNDRV_CTL_ELEM_ACCESS_TLV_WRITE ) && k->access &SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK ) {struct soc_bytes_ext *sbe;struct snd_soc_tplg_bytes_control *be;
Greg Kroah-Hartman
maintainerPATCH 362/475 ARM: dts: spear1340: Update serial node properties
In reply to Greg Kroah-HartmanFrom: Kuldeep Singh <[email protected]>
commit 583d6b0062640def86f3265aa1042ecb6672516e upstream.
Reorder dma and dma-names property for serial node to make it compliant with bindings.
--- arch/arm/boot/dts/spear1340.dtsi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/boot/dts/spear1340.dtsi +3 -3
@@ -136,9 +136,9 @@ reg = <0xb4100000 0x1000>; interrupts = <0 105 0x4>; status = "disabled"; - dmas = <&dwdma0 12 0 1>, - <&dwdma0 13 1 0>; - dma-names = "tx", "rx"; + dmas = <&dwdma0 13 0 1>, + <&dwdma0 12 1 0>; + dma-names = "rx", "tx"; }; thermal@e07008c4 {
Greg Kroah-Hartman
maintainerPATCH 363/475 ARM: dts: spear13xx: Update SPI dma properties
In reply to Greg Kroah-HartmanFrom: Kuldeep Singh <[email protected]>
commit 31d3687d6017c7ce6061695361598d9cda70807a upstream.
Reorder dmas and dma-names property for spi controller node to make it compliant with bindings.
--- arch/arm/boot/dts/spear13xx.dtsi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/boot/dts/spear13xx.dtsi +3 -3
@@ -284,9 +284,9 @@ #size-cells = <0>; interrupts = <0 31 0x4>; status = "disabled"; - dmas = <&dwdma0 4 0 0>, - <&dwdma0 5 0 0>; - dma-names = "tx", "rx"; + dmas = <&dwdma0 5 0 0>, + <&dwdma0 4 0 0>; + dma-names = "rx", "tx"; }; rtc@e0580000 {
Greg Kroah-Hartman
maintainerPATCH 364/475 um: Fix uml_mconsole stop/go
In reply to Greg Kroah-HartmanFrom: Anton Ivanov <[email protected]>
commit 1a3a6a2a035bb6c3a7ef4c788d8fd69a7b2d6284 upstream.
Moving to an EPOLL based IRQ controller broke uml_mconsole stop/go commands. This fixes it and restores stop/go functionality.
--- arch/um/drivers/mconsole_kern.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/um/drivers/mconsole_kern.c +2 -1
@@ -217,7 +217,7 @@ void mconsole_go(struct mc_request *req)void mconsole_stop (struct mc_request *req) { -deactivate_fd (req->originating_fd,MCONSOLE_IRQ ); +block_signals ();os_set_fd_block (req->originating_fd,1 );mconsole_reply (req,"stopped" ,0 ,0 );for (;;) {
@@ -240,6 +240,7 @@ void mconsole_stop(struct mc_request *re }os_set_fd_block (req->originating_fd,0 );mconsole_reply (req,"" ,0 ,0 ); +unblock_signals (); }static DEFINE_SPINLOCK (mc_devices_lock);
Greg Kroah-Hartman
maintainerPATCH 365/475 openvswitch: Fixed nd target mask field in the flow dump.
In reply to Greg Kroah-HartmanFrom: Martin Varghese <[email protected]>
commit f19c44452b58a84d95e209b847f5495d91c9983a upstream.
IPv6 nd target mask was not getting populated in flow dump.
In the function __ovs_nla_put_key the icmp code mask field was checked instead of icmp code key field to classify the flow as neighbour discovery.
ufid:bdfbe3e5-60c2-43b0-a5ff-dfcac1c37328, recirc_id(0),dp_hash(0/0), skb_priority(0/0),in_port(ovs-nm1),skb_mark(0/0),ct_state(0/0), ct_zone(0/0),ct_mark(0/0),ct_label(0/0), eth(src=00:00:00:00:00:00/00:00:00:00:00:00, dst=00:00:00:00:00:00/00:00:00:00:00:00),eth_type(0x86dd), ipv6(src=::/::,dst=::/::,label=0/0,proto=58,tclass=0/0,hlimit=0/0,frag=no), icmpv6(type=135,code=0),
nd(target=2001::2/::,
sll=00:00:00:00:00:00/00:00:00:00:00:00, tll=00:00:00:00:00:00/00:00:00:00:00:00),
packets:10, bytes:860, used:0.504s, dp:ovs, actions:ovs-nm2
--- net/openvswitch/flow_netlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/openvswitch/flow_netlink.c +2 -2
@@ -2179,8 +2179,8 @@ static int __ovs_nla_put_key(const struc icmpv6_key->icmpv6_type =ntohs (output->tp.src); icmpv6_key->icmpv6_code =ntohs (output->tp.dst); -if (icmpv6_key->icmpv6_type ==NDISC_NEIGHBOUR_SOLICITATION || - icmpv6_key->icmpv6_type ==NDISC_NEIGHBOUR_ADVERTISEMENT ) { +if (swkey->tp.src ==htons (NDISC_NEIGHBOUR_SOLICITATION ) || + swkey->tp.src ==htons (NDISC_NEIGHBOUR_ADVERTISEMENT )) {struct ovs_key_nd *nd_key; nla =nla_reserve (skb,OVS_KEY_ATTR_ND ,sizeof (*nd_key));
Greg Kroah-Hartman
maintainerPATCH 366/475 KVM: x86/mmu: do compare-and-exchange of gPTE via the user address
In reply to Greg Kroah-HartmanFrom: Paolo Bonzini <[email protected]>
commit 2a8859f373b0a86f0ece8ec8312607eacf12485d upstream.
FNAME(cmpxchg_gpte) is an inefficient mess. It is at least decent if it can go through get_user_pages_fast(), but if it cannot then it tries to use memremap(); that is not just terribly slow, it is also wrong because it assumes that the VM_PFNMAP VMA is contiguous.
The right way to do it would be to do the same thing as hva_to_pfn_remapped() does since commit add6a0cd1c5b ("KVM: MMU: try to fix up page faults before giving up", 2016-07-05), using follow_pte() and fixup_user_fault() to determine the correct address to use for memremap(). To do this, one could for example extract hva_to_pfn() for use outside virt/kvm/kvm_main.c. But really there is no reason to do that either, because there is already a perfectly valid address to do the cmpxchg() on, only it is a userspace address. That means doing user_access_begin()/user_access_end() and writing the code in assembly to handle exceptions correctly. Worse, the guest PTE can be 8-byte even on i686 so there is the extra complication of using cmpxchg8b to account for. But at least it is an efficient mess.
(Thanks to Linus for suggesting improvement on the inline assembly).
--- arch/x86/kvm/paging_tmpl.h | 77 +++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 40 deletions(-)
arch/x86/kvm/paging_tmpl.h +37 -40
@@ -34,9 +34,8 @@#define PT_HAVE_ACCESSED_DIRTY (mmu) true#ifdef CONFIG_X86_64 #define PT_MAX_FULL_LEVELS PT64_ROOT_MAX_LEVEL -#define CMPXCHG cmpxchg +#define CMPXCHG "cmpxchgq"#else -#define CMPXCHG cmpxchg64#define PT_MAX_FULL_LEVELS 2#endif #elif PTTYPE ==32
@@ -52,7 +51,7 @@#define PT_GUEST_DIRTY_SHIFT PT_DIRTY_SHIFT#define PT_GUEST_ACCESSED_SHIFT PT_ACCESSED_SHIFT#define PT_HAVE_ACCESSED_DIRTY (mmu) true -#define CMPXCHG cmpxchg +#define CMPXCHG "cmpxchgl"#elif PTTYPE ==PTTYPE_EPT #define pt_element_t u64#define guest_walker guest_walkerEPT
@@ -65,8 +64,10 @@#define PT_GUEST_DIRTY_SHIFT 9#define PT_GUEST_ACCESSED_SHIFT 8#define PT_HAVE_ACCESSED_DIRTY (mmu) ((mmu)->ept_ad) -#define CMPXCHG cmpxchg64#define PT_MAX_FULL_LEVELS 4 +#ifdef CONFIG_X86_64 +#define CMPXCHG "cmpxchgq" +#endif #else #error Invalid PTTYPE value#endif
@@ -132,43 +133,39 @@ static int FNAME(cmpxchg_gpte)(struct kv pt_element_t __user *ptep_user, unsigned index, pt_element_t orig_pte, pt_element_t new_pte) { - int npages; -pt_element_t ret; -pt_element_t *table; -struct page *page; - - npages =get_user_pages_fast ((unsigned long )ptep_user,1 ,FOLL_WRITE , &page); -if (likely (npages ==1 )) { - table =kmap_atomic (page); - ret =CMPXCHG (&table[index], orig_pte, new_pte); -kunmap_atomic (table); - -kvm_release_page_dirty (page); - }else { -struct vm_area_struct *vma; -unsigned long vaddr = (unsigned long )ptep_user &PAGE_MASK ; -unsigned long pfn; -unsigned long paddr; - -down_read (¤t->mm->mmap_sem); - vma =find_vma_intersection (current->mm, vaddr, vaddr +PAGE_SIZE ); -if (!vma || !(vma->vm_flags &VM_PFNMAP )) { -up_read (¤t->mm->mmap_sem); -return -EFAULT ; - } - pfn = ((vaddr - vma->vm_start) >>PAGE_SHIFT ) + vma->vm_pgoff; - paddr = pfn <<PAGE_SHIFT ; - table =memremap (paddr,PAGE_SIZE ,MEMREMAP_WB ); -if (!table) { -up_read (¤t->mm->mmap_sem); -return -EFAULT ; - } - ret =CMPXCHG (&table[index], orig_pte, new_pte); -memunmap (table); -up_read (¤t->mm->mmap_sem); - } + int r = -EFAULT; + +if (!user_access_begin (ptep_user,sizeof (pt_element_t))) +return -EFAULT ; + +#ifdef CMPXCHG + asmvolatile ("1:" LOCK_PREFIX CMPXCHG " %[new], %[ptr]\n" +"mov $0, %[r]\n" +"setnz %b[r]\n" +"2:" + _ASM_EXTABLE_UA(1b, 2b) + : [ptr] "+m" (*ptep_user), + [old] "+a" (orig_pte), + [r] "+q" (r) + : [new] "r" (new_pte) + : "memory"); +#else + asmvolatile ("1:" LOCK_PREFIX "cmpxchg8b %[ptr]\n" +"movl $0, %[r]\n" +"jz 2f\n" +"incl %[r]\n" +"2:" + _ASM_EXTABLE_UA(1b, 2b) + : [ptr] "+m" (*ptep_user), + [old] "+A" (orig_pte), + [r] "+rm" (r) + : [new_lo] "b" ((u32)new_pte), + [new_hi] "c" ((u32)(new_pte >> 32)) + : "memory"); +#endif -return (ret != orig_pte); +user_access_end (); +return r; } static bool FNAME(prefetch_invalid_gpte)(struct kvm_vcpu *vcpu,
Greg Kroah-Hartman
maintainerPATCH 367/475 KVM: x86: Forbid VMM to set SYNIC/STIMER MSRs when SynIC wasnt activated
In reply to Greg Kroah-HartmanFrom: Vitaly Kuznetsov <[email protected]>
commit b1e34d325397a33d97d845e312d7cf2a8b646b44 upstream.
Setting non-zero values to SYNIC/STIMER MSRs activates certain features, this should not happen when KVM_CAP_HYPERV_SYNIC{,2} was not activated.
Note, it would've been better to forbid writing anything to SYNIC/STIMER MSRs, including zeroes, however, at least QEMU tries clearing HV_X64_MSR_STIMER0_CONFIG without SynIC. HV_X64_MSR_EOM MSR is somewhat 'special' as writing zero there triggers an action, this also should not happen when SynIC wasn't activated.
Message-Id: <[email protected]>
--- arch/x86/kvm/hyperv.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
arch/x86/kvm/hyperv.c +15 -1
@@ -205,7 +205,7 @@ static int synic_set_msr(struct kvm_vcpustruct kvm_vcpu *vcpu =synic_to_vcpu (synic);int ret; -if (!synic->active && !host) +if (!synic->active && (!host || data))return 1 ;trace_kvm_hv_synic_set_msr (vcpu->vcpu_id, msr, data, host);
@@ -251,6 +251,9 @@ static int synic_set_msr(struct kvm_vcpucase HV_X64_MSR_EOM : {int i; +if (!synic->active) +break ; +for (i =0 ; i <ARRAY_SIZE (synic->sint); i++)kvm_hv_notify_acked_sint (vcpu, i);break ;
@@ -514,6 +517,11 @@ static int stimer_set_config(struct kvm_ {union hv_stimer_config new_config = {.as_uint64 = config}, old_config = {.as_uint64 = stimer->config.as_uint64}; +struct kvm_vcpu *vcpu =stimer_to_vcpu (stimer); +struct kvm_vcpu_hv_synic *synic =vcpu_to_synic (vcpu); + +if (!synic->active && (!host || config)) +return 1 ;trace_kvm_hv_stimer_set_config (stimer_to_vcpu (stimer)->vcpu_id, stimer->index, config, host);
@@ -533,6 +541,12 @@ static int stimer_set_config(struct kvm_static int stimer_set_count (struct kvm_vcpu_hv_stimer *stimer,u64 count,bool host) { +struct kvm_vcpu *vcpu =stimer_to_vcpu (stimer); +struct kvm_vcpu_hv_synic *synic =vcpu_to_synic (vcpu); + +if (!synic->active && (!host || count)) +return 1 ; +trace_kvm_hv_stimer_set_count (stimer_to_vcpu (stimer)->vcpu_id, stimer->index, count, host);
Greg Kroah-Hartman
maintainerPATCH 368/475 ubifs: Rectify space amount budget for mkdir/tmpfile operations
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
[ Upstream commit a6dab6607d4681d227905d5198710b575dbdb519 ]
UBIFS should make sure the flash has enough space to store dirty (Data that is newer than disk) data (in memory), space budget is exactly designed to do that. If space budget calculates less data than we need, 'make_reservation()' will do more work(return -ENOSPC if no free space lelf, sometimes we can see "cannot reserve xxx bytes in jhead xxx, error -28" in ubifs error messages) with ubifs inodes locked, which may effect other syscalls.
A simple way to decide how much space do we need when make a budget:
See how much space is needed by 'make_reservation()' in ubifs_jnl_xxx() function according to corresponding operation.
It's better to report ENOSPC in ubifs_budget_space(), as early as we can.
--- fs/ubifs/dir.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
fs/ubifs/dir.c +8 -4
@@ -361,15 +361,18 @@ static int do_tmpfile(struct inode *dir, struct dentry *dentry, {struct inode *inode;struct ubifs_info *c = dir->i_sb->s_fs_info; -struct ubifs_budget_req req = { .new_ino =1 , .new_dent =1 }; +struct ubifs_budget_req req = { .new_ino =1 , .new_dent =1 , + .dirtied_ino =1 };struct ubifs_budget_req ino_req = { .dirtied_ino =1 };struct ubifs_inode *ui, *dir_ui =ubifs_inode (dir);int err, instantiated =0 ;struct fscrypt_name nm;/* -* Budget request settings: new dirty inode, new direntry, -* budget for dirtied inode will be released via writeback. +* Budget request settings: new inode, new direntry, changing the +* parent directory inode. +* Allocate budget separately for new dirtied inode, the budget will +* be released via writeback. */ dbg_gen("dent '%pd', mode %#hx in dir ino %lu",
@@ -957,7 +960,8 @@ static int ubifs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)struct ubifs_inode *dir_ui =ubifs_inode (dir);struct ubifs_info *c = dir->i_sb->s_fs_info;int err, sz_change; -struct ubifs_budget_req req = { .new_ino =1 , .new_dent =1 }; +struct ubifs_budget_req req = { .new_ino =1 , .new_dent =1 , + .dirtied_ino =1 };struct fscrypt_name nm;/*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 369/475 rtc: wm8350: Handle error for wm8350_register_irq
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit 43f0269b6b89c1eec4ef83c48035608f4dcdd886 ]
As the potential failure of the wm8350_register_irq(), it should be better to check it and return error if fails. Also, it need not free 'wm_rtc->rtc' since it will be freed automatically.
--- drivers/rtc/rtc-wm8350.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/rtc/rtc-wm8350.c +9 -2
@@ -432,14 +432,21 @@ static int wm8350_rtc_probe(struct platform_device *pdev)return ret; } -wm8350_register_irq (wm8350,WM8350_IRQ_RTC_SEC , + ret =wm8350_register_irq (wm8350,WM8350_IRQ_RTC_SEC , wm8350_rtc_update_handler,0 ,"RTC Seconds" , wm8350); +if (ret) +return ret; +wm8350_mask_irq (wm8350,WM8350_IRQ_RTC_SEC ); -wm8350_register_irq (wm8350,WM8350_IRQ_RTC_ALM , + ret =wm8350_register_irq (wm8350,WM8350_IRQ_RTC_ALM , wm8350_rtc_alarm_handler,0 ,"RTC Alarm" , wm8350); +if (ret) { +wm8350_free_irq (wm8350,WM8350_IRQ_RTC_SEC , wm8350); +return ret; + }return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 370/475 riscv module: remove (NOLOAD)
In reply to Greg Kroah-HartmanFrom: Fangrui Song <[email protected]>
[ Upstream commit 60210a3d86dc57ce4a76a366e7841dda746a33f7 ]
On ELF, (NOLOAD) sets the section type to SHT_NOBITS[1]. It is conceptually inappropriate for .plt, .got, and .got.plt sections which are always SHT_PROGBITS.
In GNU ld, if PLT entries are needed, .plt will be SHT_PROGBITS anyway and (NOLOAD) will be essentially ignored. In ld.lld, since
https://reviews.llvm.org/D118840 ("[ELF] Support (TYPE=<value>) to customize the output section type"), ld.lld will report a section type mismatch error (later changed to a warning). Just remove (NOLOAD) to fix the warning.
[1] https://lld.llvm.org/ELF/linker_script.html As of today, "The section should be marked as not loadable" on
https://sourceware.org/binutils/docs/ld/Output-Section-Type.html is outdated for ELF.
--- arch/riscv/kernel/module.lds | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/riscv/kernel/module.lds +3 -3
@@ -2,7 +2,7 @@ /* Copyright (C) 2017 Andes Technology Corporation */ SECTIONS { - .plt (NOLOAD) : { BYTE(0) } - .got (NOLOAD) : { BYTE(0) } - .got.plt (NOLOAD) : { BYTE(0) } + .plt : { BYTE(0) } + .got : { BYTE(0) } + .got.plt : { BYTE(0) } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 371/475 ARM: 9187/1: JIVE: fix return value of __setup handler
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 8b2360c7157b462c4870d447d1e65d30ef31f9aa ]
__setup() handlers should return 1 to obsolete_checksetup() in init/main.c to indicate that the boot option has been handled. A return of 0 causes the boot option/value to be listed as an Unknown kernel parameter and added to init's (limited) argument or environment strings. Also, error return codes don't mean anything to obsolete_checksetup() -- only non-zero (usually 1) or zero. So return 1 from jive_mtdset().
--- arch/arm/mach-s3c24xx/mach-jive.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/mach-s3c24xx/mach-jive.c +3 -3
@@ -237,11 +237,11 @@ static int __init jive_mtdset(char *options)unsigned long set;if (options ==NULL || options[0 ] =='\0' ) -return 0 ; +return 1 ;if (kstrtoul (options,10 , &set)) {printk (KERN_ERR "failed to parse mtdset=%s\n" , options); -return 0 ; +return 1 ; }switch (set) {
@@ -256,7 +256,7 @@ static int __init jive_mtdset(char *options) "using default.", set); } -return 0 ; +return 1 ; }/* parse the mtdset= option given to the kernel command line */
Signature · 9 lines
2.35.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Greg Kroah-Hartman
maintainerPATCH 372/475 KVM: x86/svm: Clear reserved bits written to PerfEvtSeln MSRs
In reply to Greg Kroah-HartmanFrom: Jim Mattson <[email protected]>
[ Upstream commit 9b026073db2f1ad0e4d8b61c83316c8497981037 ]
AMD EPYC CPUs never raise a #GP for a WRMSR to a PerfEvtSeln MSR. Some reserved bits are cleared, and some are not. Specifically, on Zen3/Milan, bits 19 and 42 are not cleared.
When emulating such a WRMSR, KVM should not synthesize a #GP, regardless of which bits are set. However, undocumented bits should not be passed through to the hardware MSR. So, rather than checking for reserved bits and synthesizing a #GP, just clear the reserved bits.
This may seem pedantic, but since KVM currently does not support the "Host/Guest Only" bits (41:40), it is necessary to clear these bits rather than synthesizing #GP, because some popular guests (e.g Linux) will set the "Host Only" bit even on CPUs that don't support EFER.SVME, and they don't expect a #GP.
For example,
root@Ubuntu1804:~# perf stat -e r26 -a sleep 1
Performance counter stats for 'system wide':
0 r26
1.001070977 seconds time elapsedFeb 23 03:59:58 Ubuntu1804 kernel: [ 405.379957] unchecked MSR access error: WRMSR to 0xc0010200 (tried to write 0x0000020000130026) at rIP: 0xffffffff9b276a28 (native_write_msr+0x8/0x30) Feb 23 03:59:58 Ubuntu1804 kernel: [ 405.379958] Call Trace: Feb 23 03:59:58 Ubuntu1804 kernel: [ 405.379963] amd_pmu_disable_event+0x27/0x90
Message-Id: <[email protected]>
--- arch/x86/kvm/pmu_amd.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
arch/x86/kvm/pmu_amd.c +3 -5
@@ -245,12 +245,10 @@ static int amd_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)/* MSR_EVNTSELn */ pmc =get_gp_pmc_amd (pmu, msr,PMU_TYPE_EVNTSEL );if (pmc) { -if (data == pmc->eventsel) -return 0 ; -if (!(data & pmu->reserved_bits)) { + data &= ~pmu->reserved_bits; +if (data != pmc->eventsel)reprogram_gp_counter (pmc, data); -return 0 ; - } +return 0 ; }return 1 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 373/475 drm: Add orientation quirk for GPD Win Max
In reply to Greg Kroah-HartmanFrom: Anisse Astier <[email protected]>
[ Upstream commit 0b464ca3e0dd3cec65f28bc6d396d82f19080f69 ]
Panel is 800x1280, but mounted on a laptop form factor, sideways.
--- drivers/gpu/drm/drm_panel_orientation_quirks.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/drm_panel_orientation_quirks.c +6 -0
@@ -166,6 +166,12 @@ static const struct dmi_system_id orientation_data[] = { DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "MicroPC"), }, .driver_data = (void *)&lcd720x1280_rightside_up, + }, { /* GPD Win Max */ + .matches = { +DMI_EXACT_MATCH (DMI_SYS_VENDOR ,"GPD" ), + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "G1619-01"), + }, + .driver_data = (void *)&lcd800x1280_rightside_up, }, { /** GPD Pocket, note that the the DMI data is less generic then * it seems, devices with a board-vendor of "AMI Corporation"
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 374/475 ath5k: fix OOB in ath5k_eeprom_read_pcal_info_5111
In reply to Greg Kroah-HartmanFrom: Zekun Shen <[email protected]>
[ Upstream commit 564d4eceb97eaf381dd6ef6470b06377bb50c95a ]
The bug was found during fuzzing. Stacktrace locates it in ath5k_eeprom_convert_pcal_info_5111.
When none of the curve is selected in the loop, idx can go up to AR5K_EEPROM_N_PD_CURVES. The line makes pd out of bound. pd = &chinfo[pier].pd_curves[idx];
There are many OOB writes using pd later in the code. So I added a sanity check for idx. Checks for other loops involving AR5K_EEPROM_N_PD_CURVES are not needed as the loop index is not used outside the loops.
The patch is NOT tested with real device.
The following is the fuzzing report
BUG: KASAN: slab-out-of-bounds in ath5k_eeprom_read_pcal_info_5111+0x126a/0x1390 [ath5k] Write of size 1 at addr ffff8880174a4d60 by task modprobe/214 CPU: 0 PID: 214 Comm: modprobe Not tainted 5.6.0 #1 Call Trace: dump_stack+0x76/0xa0 print_address_description.constprop.0+0x16/0x200 ? ath5k_eeprom_read_pcal_info_5111+0x126a/0x1390 [ath5k] ? ath5k_eeprom_read_pcal_info_5111+0x126a/0x1390 [ath5k] __kasan_report.cold+0x37/0x7c ? ath5k_eeprom_read_pcal_info_5111+0x126a/0x1390 [ath5k] kasan_report+0xe/0x20 ath5k_eeprom_read_pcal_info_5111+0x126a/0x1390 [ath5k] ? apic_timer_interrupt+0xa/0x20 ? ath5k_eeprom_init_11a_pcal_freq+0xbc0/0xbc0 [ath5k] ? ath5k_pci_eeprom_read+0x228/0x3c0 [ath5k] ath5k_eeprom_init+0x2513/0x6290 [ath5k] ? ath5k_eeprom_init_11a_pcal_freq+0xbc0/0xbc0 [ath5k] ? usleep_range+0xb8/0x100 ? apic_timer_interrupt+0xa/0x20 ? ath5k_eeprom_read_pcal_info_2413+0x2f20/0x2f20 [ath5k] ath5k_hw_init+0xb60/0x1970 [ath5k] ath5k_init_ah+0x6fe/0x2530 [ath5k] ? kasprintf+0xa6/0xe0 ? ath5k_stop+0x140/0x140 [ath5k] ? _dev_notice+0xf6/0xf6 ? apic_timer_interrupt+0xa/0x20 ath5k_pci_probe.cold+0x29a/0x3d6 [ath5k] ? ath5k_pci_eeprom_read+0x3c0/0x3c0 [ath5k] ? mutex_lock+0x89/0xd0 ? ath5k_pci_eeprom_read+0x3c0/0x3c0 [ath5k] local_pci_probe+0xd3/0x160 pci_device_probe+0x23f/0x3e0 ? pci_device_remove+0x280/0x280 ? pci_device_remove+0x280/0x280 really_probe+0x209/0x5d0
--- drivers/net/wireless/ath/ath5k/eeprom.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/ath/ath5k/eeprom.c +3 -0
@@ -746,6 +746,9 @@ ath5k_eeprom_convert_pcal_info_5111(struct ath5k_hw *ah, int mode, } } +if (idx ==AR5K_EEPROM_N_PD_CURVES ) + goto err_out; + ee->ee_pd_gains[mode] =1 ; pd = &chinfo[pier].pd_curves[idx];
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 375/475 drm/amd/amdgpu/amdgpu_cs: fix refcount leak of a dma_fence obj
In reply to Greg Kroah-HartmanFrom: Xin Xiong <[email protected]>
[ Upstream commit dfced44f122c500004a48ecc8db516bb6a295a1b ]
This issue takes place in an error path in amdgpu_cs_fence_to_handle_ioctl(). When info->in.what falls into default case, the function simply returns -EINVAL, forgetting to decrement the reference count of a dma_fence obj, which is bumped earlier by amdgpu_cs_get_fence(). This may result in reference count leaks.
Fix it by decreasing the refcount of specific object before returning the error code.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -0
@@ -1542,6 +1542,7 @@ int amdgpu_cs_fence_to_handle_ioctl(struct drm_device *dev, void *data,return 0 ;default : +dma_fence_put (fence);return -EINVAL ; } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 376/475 ptp: replace snprintf with sysfs_emit
In reply to Greg Kroah-HartmanFrom: Yang Guang <[email protected]>
[ Upstream commit e2cf07654efb0fd7bbcb475c6f74be7b5755a8fd ]
coccinelle report:
./drivers/ptp/ptp_sysfs.c:17:8-16:
WARNING: use scnprintf or sprintf
./drivers/ptp/ptp_sysfs.c:390:8-16:
WARNING: use scnprintf or sprintf
Use sysfs_emit instead of scnprintf or sprintf makes more sense.
--- drivers/ptp/ptp_sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ptp/ptp_sysfs.c +2 -2
@@ -13,7 +13,7 @@ static ssize_t clock_name_show(struct device *dev, struct device_attribute *attr, char *page) { struct ptp_clock *ptp = dev_get_drvdata(dev); -return snprintf (page,PAGE_SIZE -1 ,"%s\n" , ptp->info->name); +return sysfs_emit (page,"%s\n" , ptp->info->name); }static DEVICE_ATTR_RO (clock_name);
@@ -227,7 +227,7 @@ static ssize_t ptp_pin_show(struct device *dev, struct device_attribute *attr,mutex_unlock (&ptp->pincfg_mux); -return snprintf (page,PAGE_SIZE ,"%u %u\n" , func, chan); +return sysfs_emit (page,"%u %u\n" , func, chan); } static ssize_t ptp_pin_store(struct device *dev, struct device_attribute *attr,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 377/475 powerpc: dts: t104xrdb: fix phy type for FMAN 4/5
In reply to Greg Kroah-HartmanFrom: Maxim Kiselev <[email protected]>
[ Upstream commit 17846485dff91acce1ad47b508b633dffc32e838 ]
T1040RDB has two RTL8211E-VB phys which requires setting of internal delays for correct work.
Changing the phy-connection-type property to rgmii-id will fix this issue.
--- arch/powerpc/boot/dts/fsl/t104xrdb.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/boot/dts/fsl/t104xrdb.dtsi +2 -2
@@ -139,12 +139,12 @@ fman@400000 { ethernet@e6000 { phy-handle = <&phy_rgmii_0>; - phy-connection-type = "rgmii"; + phy-connection-type = "rgmii-id"; }; ethernet@e8000 { phy-handle = <&phy_rgmii_1>; - phy-connection-type = "rgmii"; + phy-connection-type = "rgmii-id"; }; mdio0: mdio@fc000 {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 378/475 bpf: Make dst_port field in struct bpf_sock 16-bit wide
In reply to Greg Kroah-HartmanFrom: Jakub Sitnicki <[email protected]>
[ Upstream commit 4421a582718ab81608d8486734c18083b822390d ]
Menglong Dong reports that the documentation for the dst_port field in struct bpf_sock is inaccurate and confusing. From the BPF program PoV, the field is a zero-padded 16-bit integer in network byte order. The value appears to the BPF user as if laid out in memory as so:
offsetof(struct bpf_sock, dst_port) + 0 <port MSB>
+ 8 <port LSB>
+16 0x00
+24 0x0032-, 16-, and 8-bit wide loads from the field are all allowed, but only if the offset into the field is 0.
32-bit wide loads from dst_port are especially confusing. The loaded value, after converting to host byte order with bpf_ntohl(dst_port), contains the port number in the upper 16-bits.
Remove the confusion by splitting the field into two 16-bit fields. For backward compatibility, allow 32-bit wide loads from offsetof(struct bpf_sock, dst_port).
While at it, allow loads 8-bit loads at offset [0] and [1] from dst_port.
--- include/uapi/linux/bpf.h | 3 ++- net/core/filter.c | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-)
include/uapi/linux/bpf.h +2 -1
@@ -3068,7 +3068,8 @@ struct bpf_sock {__u32 src_ip4;__u32 src_ip6[4 ];__u32 src_port;/* host byte order */ -__u32 dst_port;/* network byte order */ +__be16 dst_port;/* network byte order */ + __u16 :16 ;/* zero padding */ __u32 dst_ip4;__u32 dst_ip6[4 ];__u32 state;
net/core/filter.c +9 -1
@@ -6708,6 +6708,7 @@ bool bpf_sock_is_valid_access(int off, int size, enum bpf_access_type type, struct bpf_insn_access_aux *info) {const int size_default =sizeof (__u32); +int field_size;if (off <0 || off >=sizeof (struct bpf_sock ))return false;
@@ -6719,7 +6720,6 @@ bool bpf_sock_is_valid_access(int off, int size, enum bpf_access_type type,case offsetof(struct bpf_sock , family):case offsetof(struct bpf_sock , type):case offsetof(struct bpf_sock , protocol): -case offsetof(struct bpf_sock , dst_port):case offsetof(struct bpf_sock , src_port): case bpf_ctx_range(struct bpf_sock, src_ip4): case bpf_ctx_range_till(struct bpf_sock, src_ip6[0], src_ip6[3]):
@@ -6727,6 +6727,14 @@ bool bpf_sock_is_valid_access(int off, int size, enum bpf_access_type type, case bpf_ctx_range_till(struct bpf_sock, dst_ip6[0], dst_ip6[3]):bpf_ctx_record_field_size (info, size_default);return bpf_ctx_narrow_access_ok (off, size, size_default); + case bpf_ctx_range(struct bpf_sock, dst_port): + field_size = size == size_default ? + size_default : sizeof_field(struct bpf_sock, dst_port); +bpf_ctx_record_field_size (info, field_size); +return bpf_ctx_narrow_access_ok (off, size, field_size); + case offsetofend(struct bpf_sock, dst_port) ... + offsetof(struct bpf_sock, dst_ip4) - 1: +return false; }return size == size_default;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 379/475 scsi: mvsas: Replace snprintf() with sysfs_emit()
In reply to Greg Kroah-HartmanFrom: Yang Guang <[email protected]>
[ Upstream commit 0ad3867b0f13e45cfee5a1298bfd40eef096116c ]
coccinelle report:
./drivers/scsi/mvsas/mv_init.c:699:8-16:
WARNING: use scnprintf or sprintf
./drivers/scsi/mvsas/mv_init.c:747:8-16:
WARNING: use scnprintf or sprintf
Use sysfs_emit() instead of scnprintf() or sprintf().
--- drivers/scsi/mvsas/mv_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/mvsas/mv_init.c +2 -2
@@ -697,7 +697,7 @@ static ssize_t mvs_show_driver_version(struct device *cdev, struct device_attribute *attr, char *buffer) { - return snprintf(buffer, PAGE_SIZE, "%s\n", DRV_VERSION); + return sysfs_emit(buffer, "%s\n", DRV_VERSION); } static DEVICE_ATTR(driver_version,
@@ -749,7 +749,7 @@ mvs_store_interrupt_coalescing(struct device *cdev,static ssize_t mvs_show_interrupt_coalescing (struct device *cdev,struct device_attribute *attr,char *buffer) { -return snprintf (buffer,PAGE_SIZE ,"%d\n" , interrupt_coalescing); +return sysfs_emit (buffer,"%d\n" , interrupt_coalescing); } static DEVICE_ATTR(interrupt_coalescing,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 380/475 scsi: bfa: Replace snprintf() with sysfs_emit()
In reply to Greg Kroah-HartmanFrom: Yang Guang <[email protected]>
[ Upstream commit 2245ea91fd3a04cafbe2f54911432a8657528c3b ]
coccinelle report:
./drivers/scsi/bfa/bfad_attr.c:908:8-16:
WARNING: use scnprintf or sprintf
./drivers/scsi/bfa/bfad_attr.c:860:8-16:
WARNING: use scnprintf or sprintf
./drivers/scsi/bfa/bfad_attr.c:888:8-16:
WARNING: use scnprintf or sprintf
./drivers/scsi/bfa/bfad_attr.c:853:8-16:
WARNING: use scnprintf or sprintf
./drivers/scsi/bfa/bfad_attr.c:808:8-16:
WARNING: use scnprintf or sprintf
./drivers/scsi/bfa/bfad_attr.c:728:8-16:
WARNING: use scnprintf or sprintf
./drivers/scsi/bfa/bfad_attr.c:822:8-16:
WARNING: use scnprintf or sprintf
./drivers/scsi/bfa/bfad_attr.c:927:9-17:
WARNING: use scnprintf or sprintf
./drivers/scsi/bfa/bfad_attr.c:900:8-16:
WARNING: use scnprintf or sprintf
./drivers/scsi/bfa/bfad_attr.c:874:8-16:
WARNING: use scnprintf or sprintf
./drivers/scsi/bfa/bfad_attr.c:714:8-16:
WARNING: use scnprintf or sprintf
./drivers/scsi/bfa/bfad_attr.c:839:8-16:
WARNING: use scnprintf or sprintf
Use sysfs_emit() instead of scnprintf() or sprintf().
--- drivers/scsi/bfa/bfad_attr.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/scsi/bfa/bfad_attr.c +13 -13
@@ -711,7 +711,7 @@ bfad_im_serial_num_show(struct device *dev, struct device_attribute *attr,char serial_num[BFA_ADAPTER_SERIAL_NUM_LEN ];bfa_get_adapter_serial_num (&bfad->bfa, serial_num); -return snprintf (buf,PAGE_SIZE ,"%s\n" , serial_num); +return sysfs_emit (buf,"%s\n" , serial_num); } static ssize_t
@@ -725,7 +725,7 @@ bfad_im_model_show(struct device *dev, struct device_attribute *attr,char model[BFA_ADAPTER_MODEL_NAME_LEN ];bfa_get_adapter_model (&bfad->bfa, model); -return snprintf (buf,PAGE_SIZE ,"%s\n" , model); +return sysfs_emit (buf,"%s\n" , model); } static ssize_t
@@ -805,7 +805,7 @@ bfad_im_model_desc_show(struct device *dev, struct device_attribute *attr,snprintf (model_descr,BFA_ADAPTER_MODEL_DESCR_LEN ,"Invalid Model" ); -return snprintf (buf,PAGE_SIZE ,"%s\n" , model_descr); +return sysfs_emit (buf,"%s\n" , model_descr); } static ssize_t
@@ -819,7 +819,7 @@ bfad_im_node_name_show(struct device *dev, struct device_attribute *attr,u64 nwwn; nwwn =bfa_fcs_lport_get_nwwn (port->fcs_port); -return snprintf (buf,PAGE_SIZE ,"0x%llx\n" ,cpu_to_be64 (nwwn)); +return sysfs_emit (buf,"0x%llx\n" ,cpu_to_be64 (nwwn)); } static ssize_t
@@ -836,7 +836,7 @@ bfad_im_symbolic_name_show(struct device *dev, struct device_attribute *attr,bfa_fcs_lport_get_attr (&bfad->bfa_fcs.fabric.bport, &port_attr);strlcpy (symname, port_attr.port_cfg.sym_name.symname,BFA_SYMNAME_MAXLEN ); -return snprintf (buf,PAGE_SIZE ,"%s\n" , symname); +return sysfs_emit (buf,"%s\n" , symname); } static ssize_t
@@ -850,14 +850,14 @@ bfad_im_hw_version_show(struct device *dev, struct device_attribute *attr,char hw_ver[BFA_VERSION_LEN ];bfa_get_pci_chip_rev (&bfad->bfa, hw_ver); -return snprintf (buf,PAGE_SIZE ,"%s\n" , hw_ver); +return sysfs_emit (buf,"%s\n" , hw_ver); }static ssize_t bfad_im_drv_version_show (struct device *dev,struct device_attribute *attr,char *buf) { -return snprintf (buf,PAGE_SIZE ,"%s\n" ,BFAD_DRIVER_VERSION ); +return sysfs_emit (buf,"%s\n" ,BFAD_DRIVER_VERSION ); } static ssize_t
@@ -871,7 +871,7 @@ bfad_im_optionrom_version_show(struct device *dev,char optrom_ver[BFA_VERSION_LEN ];bfa_get_adapter_optrom_ver (&bfad->bfa, optrom_ver); -return snprintf (buf,PAGE_SIZE ,"%s\n" , optrom_ver); +return sysfs_emit (buf,"%s\n" , optrom_ver); } static ssize_t
@@ -885,7 +885,7 @@ bfad_im_fw_version_show(struct device *dev, struct device_attribute *attr,char fw_ver[BFA_VERSION_LEN ];bfa_get_adapter_fw_ver (&bfad->bfa, fw_ver); -return snprintf (buf,PAGE_SIZE ,"%s\n" , fw_ver); +return sysfs_emit (buf,"%s\n" , fw_ver); } static ssize_t
@@ -897,7 +897,7 @@ bfad_im_num_of_ports_show(struct device *dev, struct device_attribute *attr, (struct bfad_im_port_s *) shost->hostdata[0 ];struct bfad_s *bfad = im_port->bfad; -return snprintf (buf,PAGE_SIZE ,"%d\n" , +return sysfs_emit (buf,"%d\n" ,bfa_get_nports (&bfad->bfa)); }
@@ -905,7 +905,7 @@ static ssize_t bfad_im_drv_name_show(struct device *dev, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, "%s\n", BFAD_DRIVER_NAME); + return sysfs_emit(buf, "%s\n", BFAD_DRIVER_NAME); } static ssize_t
@@ -924,14 +924,14 @@ bfad_im_num_of_discovered_ports_show(struct device *dev, rports =kcalloc (nrports,sizeof (struct bfa_rport_qualifier_s ),GFP_ATOMIC );if (rports ==NULL ) -return snprintf (buf,PAGE_SIZE ,"Failed\n" ); +return sysfs_emit (buf,"Failed\n" );spin_lock_irqsave (&bfad->bfad_lock, flags);bfa_fcs_lport_get_rport_quals (port->fcs_port, rports, &nrports);spin_unlock_irqrestore (&bfad->bfad_lock, flags);kfree (rports); -return snprintf (buf,PAGE_SIZE ,"%d\n" , nrports); +return sysfs_emit (buf,"%d\n" , nrports); } static DEVICE_ATTR(serial_number, S_IRUGO,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 381/475 power: supply: axp20x_battery: properly report current when discharging
In reply to Greg Kroah-HartmanFrom: Evgeny Boger <[email protected]>
[ Upstream commit d4f408cdcd26921c1268cb8dcbe8ffb6faf837f3 ]
As stated in [1], negative current values are used for discharging batteries.
AXP PMICs internally have two different ADC channels for shunt current
measurement: one used during charging and one during discharging. The values reported by these ADCs are unsigned.
While the driver properly selects ADC channel to get the data from, it doesn't apply negative sign when reporting discharging current.
[1] Documentation/ABI/testing/sysfs-class-power
--- drivers/power/supply/axp20x_battery.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/power/supply/axp20x_battery.c +6 -7
@@ -185,7 +185,6 @@ static int axp20x_battery_get_prop(struct power_supply *psy, union power_supply_propval *val) {struct axp20x_batt_ps *axp20x_batt =power_supply_get_drvdata (psy); -struct iio_channel *chan;int ret =0 , reg, val1;switch (psp) {
@@ -265,12 +264,12 @@ static int axp20x_battery_get_prop(struct power_supply *psy,if (ret)return ret; -if (reg &AXP20X_PWR_STATUS_BAT_CHARGING ) - chan = axp20x_batt->batt_chrg_i; -else - chan = axp20x_batt->batt_dischrg_i; - - ret =iio_read_channel_processed (chan, &val->intval); +if (reg &AXP20X_PWR_STATUS_BAT_CHARGING ) { + ret =iio_read_channel_processed (axp20x_batt->batt_chrg_i, &val->intval); + }else { + ret =iio_read_channel_processed (axp20x_batt->batt_dischrg_i, &val1); + val->intval = -val1; + }if (ret)return ret;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 382/475 ipv6: make mc_forwarding atomic
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 145c7a793838add5e004e7d49a67654dc7eba147 ]
This fixes minor data-races in ip6_mc_input() andbatadv_mcast_mla_rtr_flags_softif_get_ipv6()
--- include/linux/ipv6.h | 2 +- net/batman-adv/multicast.c | 2 +- net/ipv6/addrconf.c | 4 ++-- net/ipv6/ip6_input.c | 2 +- net/ipv6/ip6mr.c | 8 ++++---- 5 files changed, 9 insertions(+), 9 deletions(-)
include/linux/ipv6.h +1 -1
@@ -50,7 +50,7 @@ struct ipv6_devconf {__s32 use_optimistic;#endif #ifdef CONFIG_IPV6_MROUTE -__s32 mc_forwarding; +atomic_t mc_forwarding;#endif __s32 disable_ipv6;__s32 drop_unicast_in_l2_multicast;
net/batman-adv/multicast.c +1 -1
@@ -136,7 +136,7 @@ static u8 batadv_mcast_mla_rtr_flags_softif_get_ipv6(struct net_device *dev) {struct inet6_dev *in6_dev =__in6_dev_get (dev); -if (in6_dev && in6_dev->cnf.mc_forwarding) +if (in6_dev &&atomic_read (&in6_dev->cnf.mc_forwarding))return BATADV_NO_FLAGS ;else return BATADV_MCAST_WANT_NO_RTR6 ;
net/ipv6/addrconf.c +2 -2
@@ -542,7 +542,7 @@ static int inet6_netconf_fill_devconf(struct sk_buff *skb, int ifindex,#ifdef CONFIG_IPV6_MROUTE if ((all || type ==NETCONFA_MC_FORWARDING ) &&nla_put_s32 (skb,NETCONFA_MC_FORWARDING , - devconf->mc_forwarding) <0 ) +atomic_read (&devconf->mc_forwarding)) <0 ) goto nla_put_failure;#endif if ((all || type == NETCONFA_PROXY_NEIGH) &&
@@ -5460,7 +5460,7 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf, array[DEVCONF_USE_OPTIMISTIC ] = cnf->use_optimistic;#endif #ifdef CONFIG_IPV6_MROUTE - array[DEVCONF_MC_FORWARDING ] = cnf->mc_forwarding; + array[DEVCONF_MC_FORWARDING ] =atomic_read (&cnf->mc_forwarding);#endif array[DEVCONF_DISABLE_IPV6 ] = cnf->disable_ipv6; array[DEVCONF_ACCEPT_DAD ] = cnf->accept_dad;
net/ipv6/ip6_input.c +1 -1
@@ -485,7 +485,7 @@ int ip6_mc_input(struct sk_buff *skb)/* * IPv6 multicast router mode is now supported ;) */ -if (dev_net (skb->dev)->ipv6.devconf_all->mc_forwarding && +if (atomic_read (&dev_net (skb->dev)->ipv6.devconf_all->mc_forwarding) && !(ipv6_addr_type (&hdr->daddr) & (IPV6_ADDR_LOOPBACK |IPV6_ADDR_LINKLOCAL )) &&likely (!(IP6CB (skb)->flags &IP6SKB_FORWARDED ))) {
net/ipv6/ip6mr.c +4 -4
@@ -736,7 +736,7 @@ static int mif6_delete(struct mr_table *mrt, int vifi, int notify, in6_dev =__in6_dev_get (dev);if (in6_dev) { - in6_dev->cnf.mc_forwarding--; +atomic_dec (&in6_dev->cnf.mc_forwarding);inet6_netconf_notify_devconf (dev_net (dev),RTM_NEWNETCONF ,NETCONFA_MC_FORWARDING , dev->ifindex, &in6_dev->cnf);
@@ -904,7 +904,7 @@ static int mif6_add(struct net *net, struct mr_table *mrt, in6_dev =__in6_dev_get (dev);if (in6_dev) { - in6_dev->cnf.mc_forwarding++; +atomic_inc (&in6_dev->cnf.mc_forwarding);inet6_netconf_notify_devconf (dev_net (dev),RTM_NEWNETCONF ,NETCONFA_MC_FORWARDING , dev->ifindex, &in6_dev->cnf);
@@ -1553,7 +1553,7 @@ static int ip6mr_sk_init(struct mr_table *mrt, struct sock *sk) }else {rcu_assign_pointer (mrt->mroute_sk, sk);sock_set_flag (sk,SOCK_RCU_FREE ); - net->ipv6.devconf_all->mc_forwarding++; +atomic_inc (&net->ipv6.devconf_all->mc_forwarding); }write_unlock_bh (&mrt_lock);
@@ -1586,7 +1586,7 @@ int ip6mr_sk_done(struct sock *sk)* so the RCU grace period before sk freeing * is guaranteed by sk_destruct() */ - net->ipv6.devconf_all->mc_forwarding--; +atomic_dec (&net->ipv6.devconf_all->mc_forwarding);write_unlock_bh (&mrt_lock); inet6_netconf_notify_devconf(net, RTM_NEWNETCONF, NETCONFA_MC_FORWARDING,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 383/475 powerpc: Set crashkernel offset to mid of RMA region
In reply to Greg Kroah-HartmanFrom: Sourabh Jain <[email protected]>
[ Upstream commit 7c5ed82b800d8615cdda00729e7b62e5899f0b13 ]
On large config LPARs (having 192 and more cores), Linux fails to boot due to insufficient memory in the first memblock. It is due to the memory reservation for the crash kernel which starts at 128MB offset of the first memblock. This memory reservation for the crash kernel doesn't leave enough space in the first memblock to accommodate other essential system resources.
The crash kernel start address was set to 128MB offset by default to ensure that the crash kernel get some memory below the RMA region which is used to be of size 256MB. But given that the RMA region size can be 512MB or more, setting the crash kernel offset to mid of RMA size will leave enough space for the kernel to allocate memory for other system resources.
Since the above crash kernel offset change is only applicable to the LPAR platform, the LPAR feature detection is pushed before the crash kernel reservation. The rest of LPAR specific initialization will still be done during pseries_probe_fw_features as usual.
This patch is dependent on changes to paca allocation for boot CPU. It expect boot CPU to discover 1T segment support which is introduced by the patch posted here:
https://lists.ozlabs.org/pipermail/linuxppc-dev/2022-January/239175.html
--- arch/powerpc/kernel/machine_kexec.c | 15 +++++++++++---- arch/powerpc/kernel/rtas.c | 6 ++++++ 2 files changed, 17 insertions(+), 4 deletions(-)
arch/powerpc/kernel/machine_kexec.c +11 -4
@@ -146,11 +146,18 @@ void __init reserve_crashkernel(void)if (!crashk_res.start) {#ifdef CONFIG_PPC64 /* -* On 64bit we split the RMO in half but cap it at half of -* a small SLB (128MB) since the crash kernel needs to place -* itself and some stacks to be in the first segment. +* On the LPAR platform place the crash kernel to mid of +* RMA size (512MB or more) to ensure the crash kernel +* gets enough space to place itself and some stack to be +* in the first segment. At the same time normal kernel +* also get enough space to allocate memory for essential +* system resource in the first segment. Keep the crash +* kernel starts at 128MB offset on other platforms. */ - crashk_res.start =min (0x8000000ULL , (ppc64_rma_size /2 )); +if (firmware_has_feature (FW_FEATURE_LPAR )) + crashk_res.start = ppc64_rma_size /2 ; +else + crashk_res.start =min (0x8000000ULL , (ppc64_rma_size /2 ));#else crashk_res.start =KDUMP_KERNELBASE ;#endif
arch/powerpc/kernel/rtas.c +6 -0
@@ -1244,6 +1244,12 @@ int __init early_init_dt_scan_rtas(unsigned long node, entryp =of_get_flat_dt_prop (node,"linux,rtas-entry" ,NULL ); sizep =of_get_flat_dt_prop (node,"rtas-size" ,NULL ); +#ifdef CONFIG_PPC64 +/* need this feature to decide the crashkernel offset */ +if (of_get_flat_dt_prop (node,"ibm,hypertas-functions" ,NULL )) + powerpc_firmware_features |=FW_FEATURE_LPAR ; +#endif +if (basep && entryp && sizep) { rtas.base = *basep; rtas.entry = *entryp;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 384/475 drm/amdgpu: Fix recursive locking warning
In reply to Greg Kroah-HartmanFrom: Rajneesh Bhardwaj <[email protected]>
[ Upstream commit 447c7997b62a5115ba4da846dcdee4fc12298a6a ]
Noticed the below warning while running a pytorch workload on vega10 GPUs. Change to trylock to avoid conflicts with already held reservation locks.
[ +0.000003] WARNING: possible recursive locking detected
[ +0.000003] 5.13.0-kfd-rajneesh #1030 Not tainted
[ +0.000004] --------------------------------------------
[ +0.000002] python/4822 is trying to acquire lock:
[ +0.000004] ffff932cd9a259f8 (reservation_ww_class_mutex){+.+.}-{3:3},at: amdgpu_bo_release_notify+0xc4/0x160 [amdgpu]
[ +0.000203]
but task is already holding lock:
[ +0.000003] ffff932cbb7181f8 (reservation_ww_class_mutex){+.+.}-{3:3},
at: ttm_eu_reserve_buffers+0x270/0x470 [ttm]
[ +0.000017]
other info that might help us debug this:
[ +0.000002] Possible unsafe locking scenario:
[ +0.000003] CPU0
[ +0.000002] ----
[ +0.000002] lock(reservation_ww_class_mutex);
[ +0.000004] lock(reservation_ww_class_mutex);
[ +0.000003]
*** DEADLOCK ***[ +0.000002] May be due to missing lock nesting notation
[ +0.000003] 7 locks held by python/4822:
[ +0.000003] #0: ffff932c4ac028d0 (&process->mutex){+.+.}-{3:3}, at:kfd_ioctl_map_memory_to_gpu+0x10b/0x320 [amdgpu]
[ +0.000232] #1: ffff932c55e830a8 (&info->lock#2){+.+.}-{3:3}, at:amdgpu_amdkfd_gpuvm_map_memory_to_gpu+0x64/0xf60 [amdgpu]
[ +0.000241] #2: ffff932cc45b5e68 (&(*mem)->lock){+.+.}-{3:3}, at:amdgpu_amdkfd_gpuvm_map_memory_to_gpu+0xdf/0xf60 [amdgpu]
[ +0.000236] #3: ffffb2b35606fd28 (reservation_ww_class_acquire){+.+.}-{0:0}, at:amdgpu_amdkfd_gpuvm_map_memory_to_gpu+0x232/0xf60 [amdgpu] [ +0.000235] #4: ffff932cbb7181f8 (reservation_ww_class_mutex){+.+.}-{3:3}, at:ttm_eu_reserve_buffers+0x270/0x470 [ttm]
[ +0.000015] #5: ffffffffc045f700 (*(sspp++)){....}-{0:0}, at:drm_dev_enter+0x5/0xa0 [drm]
[ +0.000038] #6: ffff932c52da7078 (&vm->eviction_lock){+.+.}-{3:3},
at: amdgpu_vm_bo_update_mapping+0xd5/0x4f0 [amdgpu]
[ +0.000195]
stack backtrace:
[ +0.000003] CPU: 11 PID: 4822 Comm: python Not tainted 5.13.0-kfd-rajneesh #1030
[ +0.000005] Hardware name: GIGABYTE MZ01-CE0-00/MZ01-CE0-00, BIOS F02 08/29/2018
[ +0.000003] Call Trace: [ +0.000003] dump_stack+0x6d/0x89 [ +0.000010] __lock_acquire+0xb93/0x1a90 [ +0.000009] lock_acquire+0x25d/0x2d0 [ +0.000005] ? amdgpu_bo_release_notify+0xc4/0x160 [amdgpu] [ +0.000184] ? lock_is_held_type+0xa2/0x110 [ +0.000006] ? amdgpu_bo_release_notify+0xc4/0x160 [amdgpu] [ +0.000184] __ww_mutex_lock.constprop.17+0xca/0x1060 [ +0.000007] ? amdgpu_bo_release_notify+0xc4/0x160 [amdgpu] [ +0.000183] ? lock_release+0x13f/0x270 [ +0.000005] ? lock_is_held_type+0xa2/0x110 [ +0.000006] ? amdgpu_bo_release_notify+0xc4/0x160 [amdgpu] [ +0.000183] amdgpu_bo_release_notify+0xc4/0x160 [amdgpu] [ +0.000185] ttm_bo_release+0x4c6/0x580 [ttm] [ +0.000010] amdgpu_bo_unref+0x1a/0x30 [amdgpu] [ +0.000183] amdgpu_vm_free_table+0x76/0xa0 [amdgpu] [ +0.000189] amdgpu_vm_free_pts+0xb8/0xf0 [amdgpu] [ +0.000189] amdgpu_vm_update_ptes+0x411/0x770 [amdgpu] [ +0.000191] amdgpu_vm_bo_update_mapping+0x324/0x4f0 [amdgpu] [ +0.000191] amdgpu_vm_bo_update+0x251/0x610 [amdgpu] [ +0.000191] update_gpuvm_pte+0xcc/0x290 [amdgpu] [ +0.000229] ? amdgpu_vm_bo_map+0xd7/0x130 [amdgpu] [ +0.000190] amdgpu_amdkfd_gpuvm_map_memory_to_gpu+0x912/0xf60 [amdgpu] [ +0.000234] kfd_ioctl_map_memory_to_gpu+0x182/0x320 [amdgpu] [ +0.000218] kfd_ioctl+0x2b9/0x600 [amdgpu] [ +0.000216] ? kfd_ioctl_unmap_memory_from_gpu+0x270/0x270 [amdgpu] [ +0.000216] ? lock_release+0x13f/0x270 [ +0.000006] ? __fget_files+0x107/0x1e0 [ +0.000007] __x64_sys_ioctl+0x8b/0xd0 [ +0.000007] do_syscall_64+0x36/0x70 [ +0.000004] entry_SYSCALL_64_after_hwframe+0x44/0xae [ +0.000007] RIP: 0033:0x7fbff90a7317 [ +0.000004] Code: b3 66 90 48 8b 05 71 4b 2d 00 64 c7 00 26 00 00 00
48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 41 4b 2d 00 f7 d8 64 89 01 48 [ +0.000005] RSP: 002b:00007fbe301fe648 EFLAGS: 00000246 ORIG_RAX:
0000000000000010
[ +0.000006] RAX: ffffffffffffffda RBX: 00007fbcc402d820 RCX:00007fbff90a7317
[ +0.000003] RDX: 00007fbe301fe690 RSI: 00000000c0184b18 RDI:
0000000000000004
[ +0.000003] RBP: 00007fbe301fe690 R08: 0000000000000000 R09:00007fbcc402d880
[ +0.000003] R10: 0000000002001000 R11: 0000000000000246 R12:00000000c0184b18
[ +0.000003] R13: 0000000000000004 R14: 00007fbf689593a0 R15:00007fbcc402d820
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2 -1
@@ -1305,7 +1305,8 @@ void amdgpu_bo_release_notify(struct ttm_buffer_object *bo) !(abo->flags & AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE)) return; -dma_resv_lock (bo->base.resv,NULL ); +if (WARN_ON_ONCE (!dma_resv_trylock (bo->base.resv))) +return ; r =amdgpu_fill_buffer (abo,AMDGPU_POISON , bo->base.resv, &fence);if (!WARN_ON (r)) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 385/475 PCI: aardvark: Fix support for MSI interrupts
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
[ Upstream commit b0b0b8b897f8e12b2368e868bd7cdc5742d5c5a9 ]
Aardvark hardware supports Multi-MSI and MSI_FLAG_MULTI_PCI_MSI is already set for the MSI chip. But when allocating MSI interrupt numbers for Multi-MSI, the numbers need to be properly aligned, otherwise endpoint devices send MSI interrupt with incorrect numbers.
Fix this issue by using function bitmap_find_free_region() instead of bitmap_find_next_zero_area().
To ensure that aligned MSI interrupt numbers are used by endpoint devices, we cannot use Linux virtual irq numbers (as they are random and not properly aligned). Instead we need to use the aligned hwirq numbers.
This change fixes receiving MSI interrupts on Armada 3720 boards and allows using NVMe disks which use Multi-MSI feature with 3 interrupts.
Without this NVMe disks freeze booting as linux nvme-core.c is waiting 60s for an interrupt.
--- drivers/pci/controller/pci-aardvark.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
drivers/pci/controller/pci-aardvark.c +6 -10
@@ -1170,7 +1170,7 @@ static void advk_msi_irq_compose_msi_msg(struct irq_data *data, msg->address_lo =lower_32_bits (msi_msg); msg->address_hi =upper_32_bits (msi_msg); - msg->data = data->irq; + msg->data = data->hwirq; } static int advk_msi_set_affinity(struct irq_data *irq_data,
@@ -1187,15 +1187,11 @@ static int advk_msi_irq_domain_alloc(struct irq_domain *domain,int hwirq, i;mutex_lock (&pcie->msi_used_lock); - hwirq =bitmap_find_next_zero_area (pcie->msi_used,MSI_IRQ_NUM , -0 , nr_irqs,0 ); -if (hwirq >=MSI_IRQ_NUM ) { -mutex_unlock (&pcie->msi_used_lock); -return -ENOSPC ; - } - -bitmap_set (pcie->msi_used, hwirq, nr_irqs); + hwirq =bitmap_find_free_region (pcie->msi_used,MSI_IRQ_NUM , +order_base_2 (nr_irqs));mutex_unlock (&pcie->msi_used_lock); +if (hwirq <0 ) +return -ENOSPC ;for (i =0 ; i < nr_irqs; i++) irq_domain_set_info(domain, virq + i, hwirq + i,
@@ -1213,7 +1209,7 @@ static void advk_msi_irq_domain_free(struct irq_domain *domain,struct advk_pcie *pcie = domain->host_data;mutex_lock (&pcie->msi_used_lock); -bitmap_clear (pcie->msi_used, d->hwirq, nr_irqs); +bitmap_release_region (pcie->msi_used, d->hwirq,order_base_2 (nr_irqs));mutex_unlock (&pcie->msi_used_lock); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 386/475 iommu/arm-smmu-v3: fix event handling soft lockup
In reply to Greg Kroah-HartmanFrom: Zhou Guanghui <[email protected]>
[ Upstream commit 30de2b541af98179780054836b48825fcfba4408 ]
During event processing, events are read from the event queue one by one until the queue is empty.If the master device continuously requests address access at the same time and the SMMU generates events, the cyclic processing of the event takes a long time and softlockup warnings may be reported.
arm-smmu-v3 arm-smmu-v3.34.auto: event 0x0a received:
arm-smmu-v3 arm-smmu-v3.34.auto: 0x00007f220000280a
arm-smmu-v3 arm-smmu-v3.34.auto: 0x000010000000007e
arm-smmu-v3 arm-smmu-v3.34.auto: 0x00000000034e8670
watchdog: BUG: soft lockup - CPU#0 stuck for 22s! [irq/268-arm-smm:247] Call trace: _dev_info+0x7c/0xa0 arm_smmu_evtq_thread+0x1c0/0x230 irq_thread_fn+0x30/0x80 irq_thread+0x128/0x210 kthread+0x134/0x138 ret_from_fork+0x10/0x1c Kernel panic - not syncing: softlockup: hung tasks
Fix this by calling cond_resched() after the event information is printed.
--- drivers/iommu/arm-smmu-v3.c | 1 + 1 file changed, 1 insertion(+)
drivers/iommu/arm-smmu-v3.c +1 -0
@@ -1708,6 +1708,7 @@ static irqreturn_t arm_smmu_evtq_thread(int irq, void *dev)dev_info (smmu->dev,"\t0x%016llx\n" , (unsigned long long )evt[i]); +cond_resched (); }/*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 387/475 usb: ehci: add pci device support for Aspeed platforms
In reply to Greg Kroah-HartmanFrom: Neal Liu <[email protected]>
[ Upstream commit c3c9cee592828528fd228b01d312c7526c584a42 ]
Enable Aspeed quirks in commit 7f2d73788d90 ("usb: ehci:
handshake CMD_RUN instead of STS_HALT") to support Aspeed ehci-pci device.
--- drivers/usb/host/ehci-pci.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/usb/host/ehci-pci.c +9 -0
@@ -21,6 +21,9 @@ static const char hcd_name[] = "ehci-pci";/* defined here to avoid adding to pci_ids.h for single instance use */ #define PCI_DEVICE_ID_INTEL_CE4100_USB 0x2e70 +#define PCI_VENDOR_ID_ASPEED 0x1a03 +#define PCI_DEVICE_ID_ASPEED_EHCI 0x2603 +/*-------------------------------------------------------------------------*/ #define PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC 0x0939static inline bool is_intel_quark_x1000 (struct pci_dev *pdev)
@@ -223,6 +226,12 @@ static int ehci_pci_setup(struct usb_hcd *hcd) ehci->has_synopsys_hc_bug =1 ; }break ; +case PCI_VENDOR_ID_ASPEED : +if (pdev->device ==PCI_DEVICE_ID_ASPEED_EHCI ) { +ehci_info (ehci,"applying Aspeed HC workaround\n" ); + ehci->is_aspeed =1 ; + } +break ; }/* optional debug port, normally in the first BAR */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 388/475 PCI: pciehp: Add Qualcomm quirk for Command Completed erratum
In reply to Greg Kroah-HartmanFrom: Manivannan Sadhasivam <[email protected]>
[ Upstream commit 9f72d4757cbe4d1ed669192f6d23817c9e437c4b ]
The Qualcomm PCI bridge device (Device ID 0x0110) found in chipsets such as SM8450 does not set the Command Completed bit unless writes to the Slot Command register change "Control" bits.
This results in timeouts like below:
pcieport 0001:00:00.0: pciehp: Timeout on hotplug command 0x03c0 (issued 2020 msec ago)
Add the device to the Command Completed quirk to mark commands "completed" immediately unless they change the "Control" bits.
--- drivers/pci/hotplug/pciehp_hpc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pci/hotplug/pciehp_hpc.c +2 -0
@@ -959,6 +959,8 @@ static void quirk_cmd_compl(struct pci_dev *pdev) }DECLARE_PCI_FIXUP_CLASS_EARLY (PCI_VENDOR_ID_INTEL ,PCI_ANY_ID ,PCI_CLASS_BRIDGE_PCI ,8 , quirk_cmd_compl); +DECLARE_PCI_FIXUP_CLASS_EARLY (PCI_VENDOR_ID_QCOM ,0x0110 , +PCI_CLASS_BRIDGE_PCI ,8 , quirk_cmd_compl);DECLARE_PCI_FIXUP_CLASS_EARLY (PCI_VENDOR_ID_QCOM ,0x0400 ,PCI_CLASS_BRIDGE_PCI ,8 , quirk_cmd_compl); DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_QCOM, 0x0401,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 389/475 power: supply: axp288-charger: Set Vhold to 4.4V
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit 5ac121b81b4051e7fc83d5b3456a5e499d5bd147 ]
The AXP288's recommended and factory default Vhold value (minimum input voltage below which the input current draw will be reduced) is 4.4V. This lines up with other charger IC's such as the TI bq2419x/bq2429x series which use 4.36V or 4.44V.
For some reason some BIOS-es initialize Vhold to 4.6V or even 4.7V which combined with the typical voltage drop over typically low wire gauge micro-USB cables leads to the input-current getting capped below 1A (with a 2A capable dedicated charger) based on Vhold.
This leads to slow charging, or even to the device slowly discharging if the device is in heavy use.
As the Linux AXP288 drivers use the builtin BC1.2 charger detection and send the input-current-limit according to the detected charger there really is no reason not to use the recommended 4.4V Vhold.
Set Vhold to 4.4V to fix the slow charging issue on various devices.
There is one exception, the special-case of the HP X2 2-in-1s which combine this BC1.2 capable PMIC with a Type-C port and a 5V/3A factory provided charger with a Type-C plug which does not do BC1.2. These have their input-current-limit hardcoded to 3A (like under Windows) and use a higher Vhold on purpose to limit the current when used with other chargers. To avoid touching Vhold on these HP X2 laptops the code setting Vhold is added to an else branch of the if checking for these models.
Note this also fixes the sofar unused VBUS_ISPOUT_VHOLD_SET_MASK define, which was wrong.
--- drivers/power/supply/axp288_charger.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/power/supply/axp288_charger.c +12 -2
@@ -41,11 +41,11 @@#define VBUS_ISPOUT_CUR_LIM_1500MA 0x1/* 1500mA */ #define VBUS_ISPOUT_CUR_LIM_2000MA 0x2/* 2000mA */ #define VBUS_ISPOUT_CUR_NO_LIM 0x3/* 2500mA */ -#define VBUS_ISPOUT_VHOLD_SET_MASK 0x31 +#define VBUS_ISPOUT_VHOLD_SET_MASK 0x38#define VBUS_ISPOUT_VHOLD_SET_BIT_POS 0x3#define VBUS_ISPOUT_VHOLD_SET_OFFSET 4000/* 4000mV */ #define VBUS_ISPOUT_VHOLD_SET_LSB_RES 100/* 100mV */ -#define VBUS_ISPOUT_VHOLD_SET_4300MV 0x3/* 4300mV */ +#define VBUS_ISPOUT_VHOLD_SET_4400MV 0x4/* 4400mV */ #define VBUS_ISPOUT_VBUS_PATH_DIS BIT(7)#define CHRG_CCCV_CC_MASK 0xf/* 4 bits */
@@ -744,6 +744,16 @@ static int charger_init_hw_regs(struct axp288_chrg_info *info) ret =axp288_charger_vbus_path_select (info, true);if (ret <0 )return ret; + }else { +/* Set Vhold to the factory default / recommended 4.4V */ + val =VBUS_ISPOUT_VHOLD_SET_4400MV <<VBUS_ISPOUT_VHOLD_SET_BIT_POS ; + ret =regmap_update_bits (info->regmap,AXP20X_VBUS_IPSOUT_MGMT , +VBUS_ISPOUT_VHOLD_SET_MASK , val); +if (ret <0 ) { +dev_err (&info->pdev->dev,"register(%x) write error(%d)\n" , +AXP20X_VBUS_IPSOUT_MGMT , ret); +return ret; + } }/* Read current charge voltage and current limit */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 390/475 ipv4: Invalidate neighbour for broadcast address upon address addition
In reply to Greg Kroah-HartmanFrom: Ido Schimmel <[email protected]>
[ Upstream commit 0c51e12e218f20b7d976158fdc18019627326f7a ]
In case user space sends a packet destined to a broadcast address when a matching broadcast route is not configured, the kernel will create a unicast neighbour entry that will never be resolved [1].
When the broadcast route is configured, the unicast neighbour entry will not be invalidated and continue to linger, resulting in packets being dropped.
Solve this by invalidating unresolved neighbour entries for broadcast addresses after routes for these addresses are internally configured by the kernel. This allows the kernel to create a broadcast neighbour entry following the next route lookup.
Another possible solution that is more generic but also more complex is to have the ARP code register a listener to the FIB notification chain and invalidate matching neighbour entries upon the addition of broadcast routes.
It is also possible to wave off the issue as a user space problem, but it seems a bit excessive to expect user space to be that intimately familiar with the inner workings of the FIB/neighbour kernel code.
[1] https://lore.kernel.org/netdev/[email protected]/
--- include/net/arp.h | 1 + net/ipv4/arp.c | 9 +++++++-- net/ipv4/fib_frontend.c | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-)
include/net/arp.h +1 -0
@@ -71,6 +71,7 @@ void arp_send(int type, int ptype, __be32 dest_ip, const unsigned char *src_hw, const unsigned char *th);int arp_mc_map (__be32 addr,u8 *haddr,struct net_device *dev,int dir);void arp_ifdown (struct net_device *dev); +int arp_invalidate (struct net_device *dev,__be32 ip,bool force); struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip, struct net_device *dev, __be32 src_ip,
net/ipv4/arp.c +7 -2
@@ -1116,13 +1116,18 @@ static int arp_req_get(struct arpreq *r, struct net_device *dev)return err; } -static int arp_invalidate (struct net_device *dev,__be32 ip) +int arp_invalidate (struct net_device *dev,__be32 ip,bool force) {struct neighbour *neigh =neigh_lookup (&arp_tbl, &ip, dev);int err = -ENXIO ;struct neigh_table *tbl = &arp_tbl;if (neigh) { +if ((neigh->nud_state &NUD_VALID ) && !force) { +neigh_release (neigh); +return 0 ; + } +if (neigh->nud_state & ~NUD_NOARP ) err = neigh_update(neigh, NULL, NUD_FAILED, NEIGH_UPDATE_F_OVERRIDE|
@@ -1169,7 +1174,7 @@ static int arp_req_delete(struct net *net, struct arpreq *r,if (!dev)return -EINVAL ; } -return arp_invalidate (dev, ip); +return arp_invalidate (dev, ip, true); }/*
net/ipv4/fib_frontend.c +4 -1
@@ -1122,9 +1122,11 @@ void fib_add_ifaddr(struct in_ifaddr *ifa)return ;/* Add broadcast address, if it is explicitly assigned. */ -if (ifa->ifa_broadcast && ifa->ifa_broadcast !=htonl (0xFFFFFFFF )) +if (ifa->ifa_broadcast && ifa->ifa_broadcast !=htonl (0xFFFFFFFF )) {fib_magic (RTM_NEWROUTE ,RTN_BROADCAST , ifa->ifa_broadcast,32 , prim,0 ); +arp_invalidate (dev, ifa->ifa_broadcast, false); + }if (!ipv4_is_zeronet (prefix) && !(ifa->ifa_flags &IFA_F_SECONDARY ) && (prefix != addr || ifa->ifa_prefixlen <32 )) {
@@ -1140,6 +1142,7 @@ void fib_add_ifaddr(struct in_ifaddr *ifa) prim, 0);fib_magic (RTM_NEWROUTE ,RTN_BROADCAST , prefix | ~mask,32 , prim,0 ); +arp_invalidate (dev, prefix | ~mask, false); } } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 391/475 dm ioctl: prevent potential spectre v1 gadget
In reply to Greg Kroah-HartmanFrom: Jordy Zomer <[email protected]>
[ Upstream commit cd9c88da171a62c4b0f1c70e50c75845969fbc18 ]
It appears like cmd could be a Spectre v1 gadget as it's supplied by a user and used as an array index. Prevent the contents of kernel memory from being leaked to userspace via speculative execution by using array_index_nospec.
--- drivers/md/dm-ioctl.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/md/dm-ioctl.c +2 -0
@@ -17,6 +17,7 @@#include <linux/dm-ioctl.h> #include <linux/hdreg.h> #include <linux/compat.h> +#include <linux/nospec.h> #include <linux/uaccess.h>
@@ -1696,6 +1697,7 @@ static ioctl_fn lookup_ioctl(unsigned int cmd, int *ioctl_flags)if (unlikely (cmd >=ARRAY_SIZE (_ioctls)))return NULL ; + cmd =array_index_nospec (cmd,ARRAY_SIZE (_ioctls)); *ioctl_flags = _ioctls[cmd].flags;return _ioctls[cmd].fn; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 392/475 drm/amdkfd: make CRAT table missing message informational only
In reply to Greg Kroah-HartmanFrom: Alex Deucher <[email protected]>
[ Upstream commit 9dff13f9edf755a15f6507874185a3290c1ae8bb ]
The driver has a fallback so make the message informational rather than a warning. The driver has a fallback if the Component Resource Association Table (CRAT) is missing, so make this informational now.
--- drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_crat.c +1 -1
@@ -758,7 +758,7 @@ int kfd_create_crat_image_acpi(void **crat_image, size_t *size)/* Fetch the CRAT table from ACPI */ status =acpi_get_table (CRAT_SIGNATURE ,0 , &crat_table);if (status ==AE_NOT_FOUND ) { -pr_warn ("CRAT table not found\n" ); +pr_info ("CRAT table not found\n" );return -ENODATA ; }else if (ACPI_FAILURE (status)) {const char *err =acpi_format_exception (status);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 393/475 scsi: pm8001: Fix pm8001_mpi_task_abort_resp()
In reply to Greg Kroah-HartmanFrom: Damien Le Moal <[email protected]>
[ Upstream commit 7e6b7e740addcea450041b5be8e42f0a4ceece0f ]
The call to pm8001_ccb_task_free() at the end of pm8001_mpi_task_abort_resp() already frees the ccb tag. So when the device NCQ_ABORT_ALL_FLAG is set, the tag should not be freed again. Also change the hardcoded 0xBFFFFFFF value to ~NCQ_ABORT_ALL_FLAG as it ought to be.
--- drivers/scsi/pm8001/pm8001_hwi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/scsi/pm8001/pm8001_hwi.c +3 -4
@@ -3775,12 +3775,11 @@ int pm8001_mpi_task_abort_resp(struct pm8001_hba_info *pm8001_ha, void *piomb)mb ();if (pm8001_dev->id &NCQ_ABORT_ALL_FLAG ) { -pm8001_tag_free (pm8001_ha, tag);sas_free_task (t); -/* clear the flag */ - pm8001_dev->id &=0xBFFFFFFF ; - }else + pm8001_dev->id &= ~NCQ_ABORT_ALL_FLAG ; + }else { t->task_done (t); + }return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 394/475 scsi: aha152x: Fix aha152x_setup() __setup handler return value
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit cc8294ec4738d25e2bb2d71f7d82a9bf7f4a157b ]
__setup() handlers should return 1 if the command line option is handled and 0 if not (or maybe never return 0; doing so just pollutes init's environment with strings that are not init arguments/parameters).
Return 1 from aha152x_setup() to indicate that the boot option has been handled.
--- drivers/scsi/aha152x.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/scsi/aha152x.c +2 -4
@@ -3368,13 +3368,11 @@ static int __init aha152x_setup(char *str) setup[setup_count].synchronous = ints[0 ] >=6 ? ints[6 ] :1 ; setup[setup_count].delay = ints[0 ] >=7 ? ints[7 ] :DELAY_DEFAULT ; setup[setup_count].ext_trans = ints[0 ] >=8 ? ints[8 ] :0 ; -if (ints[0 ] >8 ) {/*}*/ +if (ints[0 ] >8 )printk (KERN_NOTICE "aha152x: usage: aha152x=<IOBASE>[,<IRQ>[,<SCSI ID>" "[,<RECONNECT>[,<PARITY>[,<SYNCHRONOUS>[,<DELAY>[,<EXT_TRANS>]]]]]]]\n" ); - }else { +else setup_count++; -return 0 ; - }return 1 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 395/475 net/smc: correct settings of RMB window update limit
In reply to Greg Kroah-HartmanFrom: Dust Li <[email protected]>
[ Upstream commit 6bf536eb5c8ca011d1ff57b5c5f7c57ceac06a37 ]
rmbe_update_limit is used to limit announcing receive window updating too frequently. RFC7609 request a minimal increase in the window size of 10% of the receive buffer space. But current implementation used:
min_t(int, rmbe_size / 10, SOCK_MIN_SNDBUF / 2)
and SOCK_MIN_SNDBUF / 2 == 2304 Bytes, which is almost always less then 10% of the receive buffer space.
This causes the receiver always sending CDC message to update its consumer cursor when it consumes more then 2K of data. And as a result, we may encounter something like "TCP silly window syndrome" when sending 2.5~8K message.
This patch fixes this using max(rmbe_size / 10, SOCK_MIN_SNDBUF / 2).
With this patch and SMC autocorking enabled, qperf 2K/4K/8K tcp_bw test shows 45%/75%/40% increase in throughput respectively.
--- net/smc/smc_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/smc/smc_core.c +1 -1
@@ -734,7 +734,7 @@ static struct smc_buf_desc *smc_buf_get_slot(int compressed_bufsize,*/ static inline int smc_rmb_wnd_update_limit (int rmbe_size) { -return min_t (int, rmbe_size /10 ,SOCK_MIN_SNDBUF /2 ); +return max_t (int, rmbe_size /10 ,SOCK_MIN_SNDBUF /2 ); } static struct smc_buf_desc *smcr_new_buf_create(struct smc_link_group *lgr,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 396/475 mips: ralink: fix a refcount leak in ill_acc_of_setup()
In reply to Greg Kroah-HartmanFrom: Hangyu Hua <[email protected]>
[ Upstream commit 4a0a1436053b17e50b7c88858fb0824326641793 ]
of_node_put(np) needs to be called when pdev == NULL.
--- arch/mips/ralink/ill_acc.c | 1 + 1 file changed, 1 insertion(+)
arch/mips/ralink/ill_acc.c +1 -0
@@ -61,6 +61,7 @@ static int __init ill_acc_of_setup(void) pdev =of_find_device_by_node (np);if (!pdev) {pr_err ("%pOFn: failed to lookup pdev\n" , np); +of_node_put (np);return -EINVAL ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 397/475 macvtap: advertise link netns via netlink
In reply to Greg Kroah-HartmanFrom: Sven Eckelmann <[email protected]>
[ Upstream commit a02192151b7dbf855084c38dca380d77c7658353 ]
Assign rtnl_link_ops->get_link_net() callback so that IFLA_LINK_NETNSID is added to rtnetlink messages. This fixes iproute2 which otherwise resolved the link interface to an interface in the wrong namespace.
Test commands:
ip netns add nst
ip link add dummy0 type dummy
ip link add link macvtap0 link dummy0 type macvtap ip link set macvtap0 netns nst
ip -netns nst link show macvtap0
Before:
10: macvtap0@gre0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 500
link/ether 5e:8f:ae:1d:60:50 brd ff:ff:ff:ff:ff:ff
After:
10: macvtap0@if2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 500
link/ether 5e:8f:ae:1d:60:50 brd ff:ff:ff:ff:ff:ff link-netnsid 0
--- drivers/net/macvtap.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/macvtap.c +6 -0
@@ -133,11 +133,17 @@ static void macvtap_setup(struct net_device *dev) dev->tx_queue_len =TUN_READQ_SIZE ; } +static struct net *macvtap_link_net (const struct net_device *dev) +{ +return dev_net (macvlan_dev_real_dev (dev)); +} +static struct rtnl_link_ops macvtap_link_ops__read_mostly = { .kind ="macvtap" , .setup = macvtap_setup, .newlink = macvtap_newlink, .dellink = macvtap_dellink, + .get_link_net = macvtap_link_net, .priv_size =sizeof (struct macvtap_dev ), };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 398/475 tuntap: add sanity checks about msg_controllen in sendmsg
In reply to Greg Kroah-HartmanFrom: Harold Huang <[email protected]>
[ Upstream commit 74a335a07a17d131b9263bfdbdcb5e40673ca9ca ]
In patch [1], tun_msg_ctl was added to allow pass batched xdp buffers to tun_sendmsg. Although we donot use msg_controllen in this path, we should check msg_controllen to make sure the caller pass a valid msg_ctl.
--- drivers/net/tap.c | 3 ++- drivers/net/tun.c | 3 ++- drivers/vhost/net.c | 1 + 3 files changed, 5 insertions(+), 2 deletions(-)
drivers/net/tap.c +2 -1
@@ -1214,7 +1214,8 @@ static int tap_sendmsg(struct socket *sock, struct msghdr *m,struct xdp_buff *xdp;int i; -if (ctl && (ctl->type ==TUN_MSG_PTR )) { +if (m->msg_controllen ==sizeof (struct tun_msg_ctl ) && + ctl && ctl->type ==TUN_MSG_PTR ) {for (i =0 ; i < ctl->num; i++) { xdp = &((struct xdp_buff *)ctl->ptr)[i];tap_get_user_xdp (q, xdp);
drivers/net/tun.c +2 -1
@@ -2561,7 +2561,8 @@ static int tun_sendmsg(struct socket *sock, struct msghdr *m, size_t total_len)if (!tun)return -EBADFD ; -if (ctl && (ctl->type ==TUN_MSG_PTR )) { +if (m->msg_controllen ==sizeof (struct tun_msg_ctl ) && + ctl && ctl->type ==TUN_MSG_PTR ) {struct tun_page tpage;int n = ctl->num;int flush =0 ;
drivers/vhost/net.c +1 -0
@@ -472,6 +472,7 @@ static void vhost_tx_batch(struct vhost_net *net, goto signal_used; msghdr->msg_control = &ctl; + msghdr->msg_controllen =sizeof (ctl); err = sock->ops->sendmsg (sock, msghdr,0 );if (unlikely (err <0 )) {vq_err (&nvq->vq,"Fail to batch sending packets\n" );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 399/475 bnxt_en: Eliminate unintended link toggle during FW reset
In reply to Greg Kroah-HartmanFrom: Michael Chan <[email protected]>
[ Upstream commit 7c492a2530c1f05441da541307c2534230dfd59b ]
If the flow control settings have been changed, a subsequent FW reset may cause the ethernet link to toggle unnecessarily. This link toggle will increase the down time by a few seconds.
The problem is caused by bnxt_update_phy_setting() detecting a false mismatch in the flow control settings between the stored software settings and the current FW settings after the FW reset. This mismatch is caused by the AUTONEG bit added to link_info->req_flow_ctrl in an inconsistent way in bnxt_set_pauseparam() in autoneg mode. The AUTONEG bit should not be added to link_info->req_flow_ctrl.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +1 -3
@@ -1673,9 +1673,7 @@ static int bnxt_set_pauseparam(struct net_device *dev, } link_info->autoneg |=BNXT_AUTONEG_FLOW_CTRL ; -if (bp->hwrm_spec_code >=0x10201 ) - link_info->req_flow_ctrl = -PORT_PHY_CFG_REQ_AUTO_PAUSE_AUTONEG_PAUSE ; + link_info->req_flow_ctrl =0 ; }else {/* when transition from auto pause to force pause, * force a link change
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 400/475 MIPS: fix fortify panic when copying asm exception handlers
In reply to Greg Kroah-HartmanFrom: Alexander Lobakin <[email protected]>
[ Upstream commit d17b66417308996e7e64b270a3c7f3c1fbd4cfc8 ]
With KCFLAGS="-O3", I was able to trigger a fortify-source memcpy() overflow panic on set_vi_srs_handler(). Although O3 level is not supported in the mainline, under some conditions that may've happened with any optimization settings, it's just a matter of inlining luck. The panic itself is correct, more precisely, 50/50 false-positive and not at the same time.
Quoted 1 line
From the one side, no real overflow happens. Exception handler
defined in asm just gets copied to some reserved places in the memory.
But the reason behind is that C code refers to that exception handler declares it as char, i.e. something of 1 byte length. It's obvious that the asm function itself is way more than 1 byte, so fortify logics thought we are going to past the symbol declared. The standard way to refer to asm symbols from C code which is not supposed to be called from C is to declare them as extern const u8[]. This is fully correct from any point of view, as any code itself is just a bunch of bytes (including 0 as it is for syms like _stext/_etext/etc.), and the exact size is not known at the moment of compilation.
Adjust the type of the except_vec_vi_*() and related variables. Make set_handler() take const as a second argument to avoid cast-away warnings and give a little more room for optimization.
--- arch/mips/include/asm/setup.h | 2 +- arch/mips/kernel/traps.c | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-)
arch/mips/include/asm/setup.h +1 -1
@@ -16,7 +16,7 @@ static inline void setup_8250_early_printk_port(unsigned long base, unsigned int reg_shift, unsigned int timeout) {}#endif -extern void set_handler (unsigned long offset,void *addr,unsigned long len); +void set_handler (unsigned long offset,const void *addr,unsigned long len);extern void set_uncached_handler (unsigned long offset,void *addr,unsigned long len);typedef void (*vi_handler_t )(void );
arch/mips/kernel/traps.c +11 -11
@@ -2020,19 +2020,19 @@ static void *set_vi_srs_handler(int n, vi_handler_t addr, int srs)* If no shadow set is selected then use the default handler * that does normal register saving and standard interrupt exit */ -extern char except_vec_vi, except_vec_vi_lui; -extern char except_vec_vi_ori, except_vec_vi_end; -extern char rollback_except_vec_vi; -char *vec_start =using_rollback_handler () ? - &rollback_except_vec_vi : &except_vec_vi; +extern const u8 except_vec_vi[], except_vec_vi_lui[]; +extern const u8 except_vec_vi_ori[], except_vec_vi_end[]; +extern const u8 rollback_except_vec_vi[]; +const u8 *vec_start =using_rollback_handler () ? + rollback_except_vec_vi : except_vec_vi;#if defined(CONFIG_CPU_MICROMIPS ) || defined(CONFIG_CPU_BIG_ENDIAN ) -const int lui_offset = &except_vec_vi_lui - vec_start +2 ; -const int ori_offset = &except_vec_vi_ori - vec_start +2 ; +const int lui_offset = except_vec_vi_lui - vec_start +2 ; +const int ori_offset = except_vec_vi_ori - vec_start +2 ;#else -const int lui_offset = &except_vec_vi_lui - vec_start; -const int ori_offset = &except_vec_vi_ori - vec_start; +const int lui_offset = except_vec_vi_lui - vec_start; +const int ori_offset = except_vec_vi_ori - vec_start;#endif -const int handler_len = &except_vec_vi_end - vec_start; +const int handler_len = except_vec_vi_end - vec_start;if (handler_len >VECTORSPACING ) {/*
@@ -2240,7 +2240,7 @@ void per_cpu_trap_init(bool is_boot_cpu) }/* Install CPU exception handler */ -void set_handler (unsigned long offset,void *addr,unsigned long size) +void set_handler (unsigned long offset,const void *addr,unsigned long size) {#ifdef CONFIG_CPU_MICROMIPS memcpy ((void *)(ebase + offset), ((unsigned char *)addr -1 ), size);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 401/475 scsi: libfc: Fix use after free in fc_exch_abts_resp()
In reply to Greg Kroah-HartmanFrom: Jianglei Nie <[email protected]>
[ Upstream commit 271add11994ba1a334859069367e04d2be2ebdd4 ]
fc_exch_release(ep) will decrease the ep's reference count. When the reference count reaches zero, it is freed. But ep is still used in the following code, which will lead to a use after free.
Return after the fc_exch_release() call to avoid use after free.
--- drivers/scsi/libfc/fc_exch.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/libfc/fc_exch.c +1 -0
@@ -1697,6 +1697,7 @@ static void fc_exch_abts_resp(struct fc_exch *ep, struct fc_frame *fp)if (cancel_delayed_work_sync (&ep->timeout_work)) {FC_EXCH_DBG (ep,"Exchange timer canceled due to ABTS response\n" );fc_exch_release (ep);/* release from pending timer hold */ +return ; }spin_lock_bh (&ep->ex_lock);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 402/475 usb: dwc3: omap: fix "unbalanced disables for smps10_out1" on omap5evm
In reply to Greg Kroah-HartmanFrom: H. Nikolaus Schaller <[email protected]>
[ Upstream commit ac01df343e5a6c6bcead2ed421af1fde30f73e7e ]
Usually, the vbus_regulator (smps10 on omap5evm) boots up disabled.
Hence calling regulator_disable() indirectly through dwc3_omap_set_mailbox() during probe leads to:
[ 10.332764] WARNING: CPU: 0 PID: 1628 at drivers/regulator/core.c:2853 _regulator_disable+0x40/0x164 [ 10.351919] unbalanced disables for smps10_out1 [ 10.361298] Modules linked in: dwc3_omap(+) clk_twl6040 at24 gpio_twl6040 palmas_gpadc palmas_pwrbutton industrialio snd_soc_omap_mcbsp(+) snd_soc_ti_sdma display_connector ti_tpd12s015 drm leds_gpio drm_panel_orientation_quirks ip_tables x_tables ipv6 autofs4 [ 10.387818] CPU: 0 PID: 1628 Comm: systemd-udevd Not tainted 5.17.0-rc1-letux-lpae+ #8139 [ 10.405129] Hardware name: Generic OMAP5 (Flattened Device Tree) [ 10.411455] unwind_backtrace from show_stack+0x10/0x14 [ 10.416970] show_stack from dump_stack_lvl+0x40/0x4c [ 10.422313] dump_stack_lvl from __warn+0xb8/0x170 [ 10.427377] __warn from warn_slowpath_fmt+0x70/0x9c [ 10.432595] warn_slowpath_fmt from _regulator_disable+0x40/0x164 [ 10.439037] _regulator_disable from regulator_disable+0x30/0x64 [ 10.445382] regulator_disable from dwc3_omap_set_mailbox+0x8c/0xf0 [dwc3_omap] [ 10.453116] dwc3_omap_set_mailbox [dwc3_omap] from dwc3_omap_probe+0x2b8/0x394 [dwc3_omap] [ 10.467021] dwc3_omap_probe [dwc3_omap] from platform_probe+0x58/0xa8 [ 10.481762] platform_probe from really_probe+0x168/0x2fc [ 10.481782] really_probe from __driver_probe_device+0xc4/0xd8 [ 10.481782] __driver_probe_device from driver_probe_device+0x24/0xa4 [ 10.503762] driver_probe_device from __driver_attach+0xc4/0xd8 [ 10.510018] __driver_attach from bus_for_each_dev+0x64/0xa0 [ 10.516001] bus_for_each_dev from bus_add_driver+0x148/0x1a4 [ 10.524880] bus_add_driver from driver_register+0xb4/0xf8 [ 10.530678] driver_register from do_one_initcall+0x90/0x1c4 [ 10.536661] do_one_initcall from do_init_module+0x4c/0x200 [ 10.536683] do_init_module from load_module+0x13dc/0x1910 [ 10.551159] load_module from sys_finit_module+0xc8/0xd8 [ 10.561319] sys_finit_module from __sys_trace_return+0x0/0x18 [ 10.561336] Exception stack(0xc344bfa8 to 0xc344bff0) [ 10.561341] bfa0: b6fb5778 b6fab8d8 00000007 b6ecfbb8 00000000 b6ed0398 [ 10.561341] bfc0: b6fb5778 b6fab8d8 855c0500 0000017b 00020000 b6f9a3cc 00000000 b6fb5778 [ 10.595500] bfe0: bede18f8 bede18e8 b6ec9aeb b6dda1c2 [ 10.601345] ---[ end trace 0000000000000000 ]---
Fix this unnecessary warning by checking if the regulator is enabled.
--- drivers/usb/dwc3/dwc3-omap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-omap.c +1 -1
@@ -242,7 +242,7 @@ static void dwc3_omap_set_mailbox(struct dwc3_omap *omap,break ;case OMAP_DWC3_ID_FLOAT : -if (omap->vbus_reg) +if (omap->vbus_reg &®ulator_is_enabled (omap->vbus_reg))regulator_disable (omap->vbus_reg); val =dwc3_omap_read_utmi_ctrl (omap); val |=USBOTGSS_UTMI_OTG_CTRL_IDDIG ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 403/475 xtensa: fix DTC warning unit_address_format
In reply to Greg Kroah-HartmanFrom: Max Filippov <[email protected]>
[ Upstream commit e85d29ba4b24f68e7a78cb85c55e754362eeb2de ]
DTC issues the following warnings when building xtfpga device trees:
/soc/flash@00000000/partition@0x0: unit name should not have leading "0x" /soc/flash@00000000/partition@0x6000000: unit name should not have leading "0x" /soc/flash@00000000/partition@0x6800000: unit name should not have leading "0x" /soc/flash@00000000/partition@0x7fe0000: unit name should not have leading "0x"
Drop leading 0x from flash partition unit names.
--- arch/xtensa/boot/dts/xtfpga-flash-128m.dtsi | 8 ++++---- arch/xtensa/boot/dts/xtfpga-flash-16m.dtsi | 8 ++++---- arch/xtensa/boot/dts/xtfpga-flash-4m.dtsi | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-)
arch/xtensa/boot/dts/xtfpga-flash-128m.dtsi +4 -4
@@ -8,19 +8,19 @@ reg = <0x00000000 0x08000000>; bank-width = <2>; device-width = <2>; - partition@0x0 { + partition@0 { label = "data"; reg = <0x00000000 0x06000000>; }; - partition@0x6000000 { + partition@6000000 { label = "boot loader area"; reg = <0x06000000 0x00800000>; }; - partition@0x6800000 { + partition@6800000 { label = "kernel image"; reg = <0x06800000 0x017e0000>; }; - partition@0x7fe0000 { + partition@7fe0000 { label = "boot environment"; reg = <0x07fe0000 0x00020000>; };
arch/xtensa/boot/dts/xtfpga-flash-16m.dtsi +4 -4
@@ -8,19 +8,19 @@ reg = <0x08000000 0x01000000>; bank-width = <2>; device-width = <2>; - partition@0x0 { + partition@0 { label = "boot loader area"; reg = <0x00000000 0x00400000>; }; - partition@0x400000 { + partition@400000 { label = "kernel image"; reg = <0x00400000 0x00600000>; }; - partition@0xa00000 { + partition@a00000 { label = "data"; reg = <0x00a00000 0x005e0000>; }; - partition@0xfe0000 { + partition@fe0000 { label = "boot environment"; reg = <0x00fe0000 0x00020000>; };
arch/xtensa/boot/dts/xtfpga-flash-4m.dtsi +2 -2
@@ -8,11 +8,11 @@ reg = <0x08000000 0x00400000>; bank-width = <2>; device-width = <2>; - partition@0x0 { + partition@0 { label = "boot loader area"; reg = <0x00000000 0x003f0000>; }; - partition@0x3f0000 { + partition@3f0000 { label = "boot environment"; reg = <0x003f0000 0x00010000>; };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 404/475 Bluetooth: Fix use after free in hci_send_acl
In reply to Greg Kroah-HartmanFrom: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit f63d24baff787e13b723d86fe036f84bdbc35045 ]
This fixes the following trace caused by receiving HCI_EV_DISCONN_PHY_LINK_COMPLETE which does call hci_conn_del without first checking if conn->type is in fact AMP_LINK and in case it is do properly cleanup upper layers with hci_disconn_cfm:
==================================================================
BUG: KASAN: use-after-free in hci_send_acl+0xaba/0xc50
Read of size 8 at addr ffff88800e404818 by task bluetoothd/142
CPU: 0 PID: 142 Comm: bluetoothd Not tainted
5.17.0-rc5-00006-gda4022eeac1a #7
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
Call Trace:
<TASK>
dump_stack_lvl+0x45/0x59
print_address_description.constprop.0+0x1f/0x150
kasan_report.cold+0x7f/0x11b
hci_send_acl+0xaba/0xc50
l2cap_do_send+0x23f/0x3d0
l2cap_chan_send+0xc06/0x2cc0
l2cap_sock_sendmsg+0x201/0x2b0
sock_sendmsg+0xdc/0x110
sock_write_iter+0x20f/0x370
do_iter_readv_writev+0x343/0x690
do_iter_write+0x132/0x640
vfs_writev+0x198/0x570
do_writev+0x202/0x280
do_syscall_64+0x38/0x90
entry_SYSCALL_64_after_hwframe+0x44/0xae
RSP: 002b:00007ffce8a099b8 EFLAGS: 00000246 ORIG_RAX: 0000000000000014
Code: 0f 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b8 0f 1f 00 f3
0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 14 00 00 00 0f 05
<48> 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 89 54 24 1c 48 89 74 24 10
RDX: 0000000000000001 RSI: 00007ffce8a099e0 RDI: 0000000000000015
RAX: ffffffffffffffda RBX: 00007ffce8a099e0 RCX: 00007f788fc3cf77
R10: 00007ffce8af7080 R11: 0000000000000246 R12: 000055e4ccf75580
RBP: 0000000000000015 R08: 0000000000000002 R09: 0000000000000001
</TASK>
R13: 000055e4ccf754a0 R14: 000055e4ccf75cd0 R15: 000055e4ccf4a6b0
Allocated by task 45:
kasan_save_stack+0x1e/0x40
__kasan_kmalloc+0x81/0xa0
hci_chan_create+0x9a/0x2f0
l2cap_conn_add.part.0+0x1a/0xdc0
l2cap_connect_cfm+0x236/0x1000
le_conn_complete_evt+0x15a7/0x1db0
hci_le_conn_complete_evt+0x226/0x2c0
hci_le_meta_evt+0x247/0x450
hci_event_packet+0x61b/0xe90
hci_rx_work+0x4d5/0xc50
process_one_work+0x8fb/0x15a0
worker_thread+0x576/0x1240
kthread+0x29d/0x340
ret_from_fork+0x1f/0x30
Freed by task 45:
kasan_save_stack+0x1e/0x40
kasan_set_track+0x21/0x30
kasan_set_free_info+0x20/0x30
__kasan_slab_free+0xfb/0x130
kfree+0xac/0x350
hci_conn_cleanup+0x101/0x6a0
hci_conn_del+0x27e/0x6c0
hci_disconn_phylink_complete_evt+0xe0/0x120
hci_event_packet+0x812/0xe90
hci_rx_work+0x4d5/0xc50
process_one_work+0x8fb/0x15a0
worker_thread+0x576/0x1240
kthread+0x29d/0x340
ret_from_fork+0x1f/0x30
The buggy address belongs to the object at ffff88800c0f0500
The buggy address is located 24 bytes inside of
which belongs to the cache kmalloc-128 of size 128
The buggy address belongs to the page:
128-byte region [ffff88800c0f0500, ffff88800c0f0580)
flags: 0x100000000000200(slab|node=0|zone=1)
page:00000000fe45cd86 refcount:1 mapcount:0
mapping:0000000000000000 index:0x0 pfn:0xc0f0
raw: 0000000000000000 0000000080100010 00000001ffffffff
0000000000000000
raw: 0100000000000200 ffffea00003a2c80 dead000000000004
ffff8880078418c0
page dumped because: kasan: bad access detected
ffff88800c0f0400: 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc
Memory state around the buggy address:
>ffff88800c0f0500: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88800c0f0480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88800c0f0580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
^
==================================================================
ffff88800c0f0600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb--- net/bluetooth/hci_event.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/bluetooth/hci_event.c +2 -1
@@ -4911,8 +4911,9 @@ static void hci_disconn_phylink_complete_evt(struct hci_dev *hdev,hci_dev_lock (hdev); hcon =hci_conn_hash_lookup_handle (hdev, ev->phy_handle); -if (hcon) { +if (hcon && hcon->type ==AMP_LINK ) { hcon->state =BT_CLOSED ; +hci_disconn_cfm (hcon, ev->reason);hci_conn_del (hcon); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 405/475 netlabel: fix out-of-bounds memory accesses
In reply to Greg Kroah-HartmanFrom: Wang Yufen <[email protected]>
[ Upstream commit f22881de730ebd472e15bcc2c0d1d46e36a87b9c ]
In calipso_map_cat_ntoh(), in the for loop, if the return value of netlbl_bitmap_walk() is equal to (net_clen_bits - 1), when netlbl_bitmap_walk() is called next time, out-of-bounds memory accesses of bitmap[byte_offset] occurs.
The bug was found during fuzzing. The following is the fuzzing report
BUG: KASAN: slab-out-of-bounds in netlbl_bitmap_walk+0x3c/0xd0 Read of size 1 at addr ffffff8107bf6f70 by task err_OH/252 CPU: 7 PID: 252 Comm: err_OH Not tainted 5.17.0-rc7+ #17 Hardware name: linux,dummy-virt (DT) Call trace: dump_backtrace+0x21c/0x230 show_stack+0x1c/0x60 dump_stack_lvl+0x64/0x7c print_address_description.constprop.0+0x70/0x2d0 __kasan_report+0x158/0x16c kasan_report+0x74/0x120 __asan_load1+0x80/0xa0 netlbl_bitmap_walk+0x3c/0xd0 calipso_opt_getattr+0x1a8/0x230 calipso_sock_getattr+0x218/0x340 calipso_sock_getattr+0x44/0x60 netlbl_sock_getattr+0x44/0x80 selinux_netlbl_socket_setsockopt+0x138/0x170 selinux_socket_setsockopt+0x4c/0x60 security_socket_setsockopt+0x4c/0x90 __sys_setsockopt+0xbc/0x2b0 __arm64_sys_setsockopt+0x6c/0x84 invoke_syscall+0x64/0x190 el0_svc_common.constprop.0+0x88/0x200 do_el0_svc+0x88/0xa0 el0_svc+0x128/0x1b0 el0t_64_sync_handler+0x9c/0x120 el0t_64_sync+0x16c/0x170
--- net/netlabel/netlabel_kapi.c | 2 ++ 1 file changed, 2 insertions(+)
net/netlabel/netlabel_kapi.c +2 -0
@@ -885,6 +885,8 @@ int netlbl_bitmap_walk(const unsigned char *bitmap, u32 bitmap_len,unsigned char bitmask;unsigned char byte; +if (offset >= bitmap_len) +return -1 ; byte_offset = offset /8 ; byte = bitmap[byte_offset]; bit_spot = offset;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 406/475 init/main.c: return 1 from handled __setup() functions
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit f9a40b0890658330c83c95511f9d6b396610defc ]
initcall_blacklist() should return 1 to indicate that it handled its cmdline arguments.
set_debug_rodata() should return 1 to indicate that it handled its cmdline arguments. Print a warning if the option string is invalid.
This prevents these strings from being added to the 'init' program's environment as they are not init arguments/parameters.
--- init/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
init/main.c +4 -2
@@ -831,7 +831,7 @@ static int __init initcall_blacklist(char *str) } }while (str_entry); -return 0 ; +return 1 ; } static bool __init_or_module initcall_blacklisted(initcall_t fn)
@@ -1072,7 +1072,9 @@ static noinline void __init kernel_init_freeable(void);bool rodata_enabled__ro_after_init = true;static int __init set_debug_rodata (char *str) { -return strtobool (str, &rodata_enabled); +if (strtobool (str, &rodata_enabled)) +pr_warn ("Invalid option string for rodata: '%s'\n" , str); +return 1 ; }__setup ("rodata=" , set_debug_rodata);#endif
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 407/475 minix: fix bug when opening a file with O_DIRECT
In reply to Greg Kroah-HartmanFrom: Qinghua Jin <[email protected]>
[ Upstream commit 9ce3c0d26c42d279b6c378a03cd6a61d828f19ca ]
Testcase:
1. create a minix file system and mount it
2. open a file on the file system with O_RDWR|O_CREAT|O_TRUNC|O_DIRECT
3. open fails with -EINVAL but leaves an empty file behind. All other open() failures don't leave the failed open files behind.
It is hard to check the direct_IO op before creating the inode. Just as ext4 and btrfs do, this patch will resolve the issue by allowing to create the file with O_DIRECT but returning error when writing the file.
--- fs/minix/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/minix/inode.c +2 -1
@@ -447,7 +447,8 @@ static const struct address_space_operations minix_aops = { .writepage = minix_writepage, .write_begin = minix_write_begin, .write_end = generic_write_end, - .bmap = minix_bmap + .bmap = minix_bmap, + .direct_IO = noop_direct_IO };static const struct inode_operations minix_symlink_inode_operations = {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 408/475 clk: si5341: fix reported clk_rate when output divider is 2
In reply to Greg Kroah-HartmanFrom: Adam Wujek <[email protected]>
[ Upstream commit 2a8b539433e111c4de364237627ef219d2f6350a ]
SI5341_OUT_CFG_RDIV_FORCE2 shall be checked first to distinguish whether a divider for a given output is set to 2 (SI5341_OUT_CFG_RDIV_FORCE2 is set) or the output is disabled (SI5341_OUT_CFG_RDIV_FORCE2 not set, SI5341_OUT_R_REG is set 0).
Before the change, divider set to 2 (SI5341_OUT_R_REG set to 0) was interpreted as output is disabled.
--- drivers/clk/clk-si5341.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/clk/clk-si5341.c +9 -7
@@ -638,6 +638,15 @@ static unsigned long si5341_output_clk_recalc_rate(struct clk_hw *hw,u32 r_divider;u8 r[3 ]; + err =regmap_read (output->data->regmap, +SI5341_OUT_CONFIG (output), &val); +if (err <0 ) +return err; + +/* If SI5341_OUT_CFG_RDIV_FORCE2 is set, r_divider is 2 */ +if (val &SI5341_OUT_CFG_RDIV_FORCE2 ) +return parent_rate /2 ; + err =regmap_bulk_read (output->data->regmap,SI5341_OUT_R_REG (output), r,3 );if (err <0 )
@@ -654,13 +663,6 @@ static unsigned long si5341_output_clk_recalc_rate(struct clk_hw *hw, r_divider +=1 ; r_divider <<=1 ; - err =regmap_read (output->data->regmap, -SI5341_OUT_CONFIG (output), &val); -if (err <0 ) -return err; - -if (val &SI5341_OUT_CFG_RDIV_FORCE2 ) - r_divider =2 ;return parent_rate / r_divider; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 409/475 w1: w1_therm: fixes w1_seq for ds28ea00 sensors
In reply to Greg Kroah-HartmanFrom: Lucas Denefle <[email protected]>
[ Upstream commit 41a92a89eee819298f805c40187ad8b02bb53426 ]
w1_seq was failing due to several devices responding to the CHAIN_DONE at the same time. Now properly selects the current device in the chain with MATCH_ROM. Also acknowledgment was read twice.
--- drivers/w1/slaves/w1_therm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/w1/slaves/w1_therm.c +6 -2
@@ -679,16 +679,20 @@ static ssize_t w1_seq_show(struct device *device,if (sl->reg_num.id == reg_num->id) seq = i; +if (w1_reset_bus (sl->master)) + goto error; + +/* Put the device into chain DONE state */ +w1_write_8 (sl->master,W1_MATCH_ROM ); +w1_write_block (sl->master, (u8 *)&rn,8 );w1_write_8 (sl->master,W1_42_CHAIN );w1_write_8 (sl->master,W1_42_CHAIN_DONE );w1_write_8 (sl->master,W1_42_CHAIN_DONE_INV ); -w1_read_block (sl->master, &ack,sizeof (ack));/* check for acknowledgment */ ack =w1_read_8 (sl->master);if (ack !=W1_42_SUCCESS_CONFIRM_BYTE ) goto error; - }/* Exit from CHAIN state */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 410/475 NFSv4: Protect the state recovery thread against direct reclaim
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit 3e17898aca293a24dae757a440a50aa63ca29671 ]
If memory allocation triggers a direct reclaim from the state recovery thread, then we can deadlock. Use memalloc_nofs_save/restore to ensure that doesn't happen.
--- fs/nfs/nfs4state.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
fs/nfs/nfs4state.c +12 -0
@@ -49,6 +49,7 @@#include <linux/workqueue.h> #include <linux/bitops.h> #include <linux/jiffies.h> +#include <linux/sched/mm.h> #include <linux/sunrpc/clnt.h>
@@ -2504,9 +2505,17 @@ static int nfs4_bind_conn_to_session(struct nfs_client *clp)static void nfs4_state_manager (struct nfs_client *clp) { +unsigned int memflags;int status =0 ;const char *section ="" , *section_sep ="" ; +/* +* State recovery can deadlock if the direct reclaim code tries +* start NFS writeback. So ensure memory allocations are all +* GFP_NOFS. +*/ + memflags =memalloc_nofs_save (); +/* Ensure exclusive access to NFSv4 state */ do { clear_bit(NFS4CLNT_RUN_MANAGER, &clp->cl_state);
@@ -2600,6 +2609,7 @@ static void nfs4_state_manager(struct nfs_client *clp)clear_bit (NFS4CLNT_RECLAIM_NOGRACE , &clp->cl_state); } +memalloc_nofs_restore (memflags);nfs4_end_drain_session (clp);nfs4_clear_state_manager_bit (clp);
@@ -2616,6 +2626,7 @@ static void nfs4_state_manager(struct nfs_client *clp)return ;if (test_and_set_bit (NFS4CLNT_MANAGER_RUNNING , &clp->cl_state) !=0 )return ; + memflags =memalloc_nofs_save (); }while (refcount_read (&clp->cl_count) >1 && !signalled ()); goto out_drain;
@@ -2627,6 +2638,7 @@ static void nfs4_state_manager(struct nfs_client *clp) clp->cl_hostname, -status);ssleep (1 ); out_drain: +memalloc_nofs_restore (memflags);nfs4_end_drain_session (clp);nfs4_clear_state_manager_bit (clp); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 411/475 xen: delay xen_hvm_init_time_ops() if kdump is boot on vcpu>=32
In reply to Greg Kroah-HartmanFrom: Dongli Zhang <[email protected]>
[ Upstream commit eed05744322da07dd7e419432dcedf3c2e017179 ]
The sched_clock() can be used very early since commit 857baa87b642 ("sched/clock: Enable sched clock early"). In addition, with commit 38669ba205d1 ("x86/xen/time: Output xen sched_clock time from 0"), kdump kernel in Xen HVM guest may panic at very early stage when accessing &__this_cpu_read(xen_vcpu)->time as in below:
setup_arch()
-> init_hypervisor_platform()
-> x86_init.hyper.init_platform = xen_hvm_guest_init()
-> xen_hvm_init_time_ops()
-> xen_clocksource_read()
-> src = &__this_cpu_read(xen_vcpu)->time;This is because Xen HVM supports at most MAX_VIRT_CPUS=32 'vcpu_info' embedded inside 'shared_info' during early stage until xen_vcpu_setup() is used to allocate/relocate 'vcpu_info' for boot cpu at arbitrary address.
However, when Xen HVM guest panic on vcpu >= 32, since xen_vcpu_info_reset(0) would set per_cpu(xen_vcpu, cpu) = NULL when vcpu >= 32, xen_clocksource_read() on vcpu >= 32 would panic.
This patch calls xen_hvm_init_time_ops() again later in xen_hvm_smp_prepare_boot_cpu() after the 'vcpu_info' for boot vcpu is registered when the boot vcpu is >= 32.
This issue can be reproduced on purpose via below command at the guest side when kdump/kexec is enabled:
"taskset -c 33 echo c > /proc/sysrq-trigger"
The bugfix for PVM is not implemented due to the lack of testing environment.
[boris: xen_hvm_init_time_ops() returns on errors instead of jumping to end]
--- arch/x86/xen/smp_hvm.c | 6 ++++++ arch/x86/xen/time.c | 24 +++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-)
arch/x86/xen/smp_hvm.c +6 -0
@@ -18,6 +18,12 @@ static void __init xen_hvm_smp_prepare_boot_cpu(void)*/ xen_vcpu_setup (0 ); +/* +* Called again in case the kernel boots on vcpu >= MAX_VIRT_CPUS. +* Refer to comments in xen_hvm_init_time_ops(). +*/ +xen_hvm_init_time_ops (); +/* * The alternative logic (which patches the unlock/lock) runs before * the smp bootup up code is activated. Hence we need to set this up
arch/x86/xen/time.c +23 -1
@@ -547,6 +547,11 @@ static void xen_hvm_setup_cpu_clockevents(void)void __init xen_hvm_init_time_ops (void ) { +static bool hvm_time_initialized; + +if (hvm_time_initialized) +return ; +/* * vector callback is needed otherwise we cannot receive interrupts * on cpu > 0 and at this point we don't know how many cpus are
@@ -556,7 +561,22 @@ void __init xen_hvm_init_time_ops(void)return ;if (!xen_feature (XENFEAT_hvm_safe_pvclock)) { -pr_info ("Xen doesn't support pvclock on HVM, disable pv timer" ); +pr_info_once ("Xen doesn't support pvclock on HVM, disable pv timer" ); +return ; + } + +/* +* Only MAX_VIRT_CPUS 'vcpu_info' are embedded inside 'shared_info'. +* The __this_cpu_read(xen_vcpu) is still NULL when Xen HVM guest +* boots on vcpu >= MAX_VIRT_CPUS (e.g., kexec), To access +* __this_cpu_read(xen_vcpu) via xen_clocksource_read() will panic. +* +* The xen_hvm_init_time_ops() should be called again later after +* __this_cpu_read(xen_vcpu) is available. +*/ +if (!__this_cpu_read (xen_vcpu)) { +pr_info ("Delay xen_init_time_common() as kernel is running on vcpu=%d\n" , +xen_vcpu_nr (0 ));return ; }
@@ -568,6 +588,8 @@ void __init xen_hvm_init_time_ops(void) x86_platform.calibrate_tsc = xen_tsc_khz; x86_platform.get_wallclock = xen_get_wallclock; x86_platform.set_wallclock = xen_set_wallclock; + + hvm_time_initialized = true; }#endif
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 412/475 clk: Enforce that disjoints limits are invalid
In reply to Greg Kroah-HartmanFrom: Maxime Ripard <[email protected]>
[ Upstream commit 10c46f2ea914202482d19cf80dcc9c321c9ff59b ]
If we were to have two users of the same clock, doing something like:
clk_set_rate_range(user1, 1000, 2000);clk_set_rate_range(user2, 3000, 4000);
The second call would fail with -EINVAL, preventing from getting in a situation where we end up with impossible limits.
However, this is never explicitly checked against and enforced, and works by relying on an undocumented behaviour of clk_set_rate().
Indeed, on the first clk_set_rate_range will make sure the current clock rate is within the new range, so it will be between 1000 and 2000Hz. On the second clk_set_rate_range(), it will consider (rightfully), that our current clock is outside of the 3000-4000Hz range, and will call clk_core_set_rate_nolock() to set it to 3000Hz.
clk_core_set_rate_nolock() will then call clk_calc_new_rates() that will eventually check that our rate 3000Hz rate is outside the min 3000Hz max 2000Hz range, will bail out, the error will propagate and we'll eventually return -EINVAL.
This solely relies on the fact that clk_calc_new_rates(), and in particular clk_core_determine_round_nolock(), won't modify the new rate allowing the error to be reported. That assumption won't be true for all drivers, and most importantly we'll break that assumption in a later patch.
It can also be argued that we shouldn't even reach the point where we're calling clk_core_set_rate_nolock().
Let's make an explicit check for disjoints range before we're doing anything.
--- drivers/clk/clk.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/clk/clk.c +24 -0
@@ -637,6 +637,24 @@ static void clk_core_get_boundaries(struct clk_core *core, *max_rate =min (*max_rate, clk_user->max_rate); } +static bool clk_core_check_boundaries (struct clk_core *core, +unsigned long min_rate, +unsigned long max_rate) +{ +struct clk *user; + +lockdep_assert_held (&prepare_lock); + +if (min_rate > core->max_rate || max_rate < core->min_rate) +return false; + +hlist_for_each_entry (user, &core->clks, clks_node) +if (min_rate > user->max_rate || max_rate < user->min_rate) +return false; + +return true; +} +void clk_hw_set_rate_range (struct clk_hw *hw,unsigned long min_rate,unsigned long max_rate) {
@@ -2306,6 +2324,11 @@ int clk_set_rate_range(struct clk *clk, unsigned long min, unsigned long max) clk->min_rate = min; clk->max_rate = max; +if (!clk_core_check_boundaries (clk->core, min, max)) { + ret = -EINVAL ; + goto out; + } + rate =clk_core_get_rate_nolock (clk->core);if (rate < min || rate > max) {/*
@@ -2334,6 +2357,7 @@ int clk_set_rate_range(struct clk *clk, unsigned long min, unsigned long max) } } +out:if (clk->exclusive_count)clk_core_rate_protect (clk->core);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 413/475 SUNRPC/call_alloc: async tasks mustnt block waiting for memory
In reply to Greg Kroah-HartmanFrom: NeilBrown <[email protected]>
[ Upstream commit c487216bec83b0c5a8803e5c61433d33ad7b104d ]
When memory is short, new worker threads cannot be created and we depend on the minimum one rpciod thread to be able to handle everything. So it must not block waiting for memory.
mempools are particularly a problem as memory can only be released back to the mempool by an async rpc task running. If all available workqueue threads are waiting on the mempool, no thread is available to return anything.
rpc_malloc() can block, and this might cause deadlocks.
So check RPC_IS_ASYNC(), rather than RPC_IS_SWAPPER() to determine if blocking is acceptable.
--- net/sunrpc/sched.c | 4 +++- net/sunrpc/xprtrdma/transport.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-)
net/sunrpc/sched.c +3 -1
@@ -1039,8 +1039,10 @@ int rpc_malloc(struct rpc_task *task)struct rpc_buffer *buf;gfp_t gfp =GFP_NOFS ; +if (RPC_IS_ASYNC (task)) + gfp =GFP_NOWAIT | __GFP_NOWARN;if (RPC_IS_SWAPPER (task)) - gfp = __GFP_MEMALLOC |GFP_NOWAIT | __GFP_NOWARN; + gfp |= __GFP_MEMALLOC; size +=sizeof (struct rpc_buffer );if (size <=RPC_BUFFER_MAXSIZE )
net/sunrpc/xprtrdma/transport.c +3 -1
@@ -626,8 +626,10 @@ xprt_rdma_allocate(struct rpc_task *task)gfp_t flags; flags =RPCRDMA_DEF_GFP ; +if (RPC_IS_ASYNC (task)) + flags =GFP_NOWAIT | __GFP_NOWARN;if (RPC_IS_SWAPPER (task)) - flags = __GFP_MEMALLOC |GFP_NOWAIT | __GFP_NOWARN; + flags |= __GFP_MEMALLOC;if (!rpcrdma_check_regbuf (r_xprt, req->rl_sendbuf, rqst->rq_callsize, flags))
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 414/475 NFS: swap IO handling is slightly different for O_DIRECT IO
In reply to Greg Kroah-HartmanFrom: NeilBrown <[email protected]>
[ Upstream commit 64158668ac8b31626a8ce48db4cad08496eb8340 ]
1/ Taking the i_rwsem for swap IO triggers lockdep warnings regarding
possible deadlocks with "fs_reclaim". These deadlocks could, I believe, eventuate if a buffered read on the swapfile was attempted.
We don't need coherence with the page cache for a swap file, and buffered writes are forbidden anyway. There is no other need for i_rwsem during direct IO. So never take it for swap_rw()
2/ generic_write_checks() explicitly forbids writes to swap, and
performs checks that are not needed for swap. So bypass it for swap_rw().
--- fs/nfs/direct.c | 42 ++++++++++++++++++++++++++++-------------- fs/nfs/file.c | 4 ++-- include/linux/nfs_fs.h | 8 ++++---- 3 files changed, 34 insertions(+), 20 deletions(-)
fs/nfs/direct.c +28 -14
@@ -272,8 +272,8 @@ ssize_t nfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)VM_BUG_ON (iov_iter_count (iter) !=PAGE_SIZE );if (iov_iter_rw (iter) ==READ ) -return nfs_file_direct_read (iocb, iter); -return nfs_file_direct_write (iocb, iter); +return nfs_file_direct_read (iocb, iter, true); +return nfs_file_direct_write (iocb, iter, true); }static void nfs_direct_release_pages (struct page **pages,unsigned int npages)
@@ -524,6 +524,7 @@ static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq,* nfs_file_direct_read - file direct read operation for NFS files * @iocb: target I/O control block * @iter: vector of user buffers into which to read data +* @swap: flag indicating this is swap IO, not O_DIRECT IO * * We use this function for direct reads instead of calling * generic_file_aio_read() in order to avoid gfar's check to see if
@@ -539,7 +540,8 @@ static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq,* client must read the updated atime from the server back into its * cache. */ -ssize_t nfs_file_direct_read (struct kiocb *iocb,struct iov_iter *iter) +ssize_t nfs_file_direct_read (struct kiocb *iocb,struct iov_iter *iter, +bool swap) {struct file *file = iocb->ki_filp;struct address_space *mapping = file->f_mapping;
@@ -581,12 +583,14 @@ ssize_t nfs_file_direct_read(struct kiocb *iocb, struct iov_iter *iter)if (iter_is_iovec (iter)) dreq->flags =NFS_ODIRECT_SHOULD_DIRTY ; -nfs_start_io_direct (inode); +if (!swap) +nfs_start_io_direct (inode);NFS_I (inode)->read_io += count; requested =nfs_direct_read_schedule_iovec (dreq, iter, iocb->ki_pos); -nfs_end_io_direct (inode); +if (!swap) +nfs_end_io_direct (inode);if (requested >0 ) { result =nfs_direct_wait (dreq);
@@ -937,6 +941,7 @@ static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq,* nfs_file_direct_write - file direct write operation for NFS files * @iocb: target I/O control block * @iter: vector of user buffers from which to write data +* @swap: flag indicating this is swap IO, not O_DIRECT IO * * We use this function for direct writes instead of calling * generic_file_aio_write() in order to avoid taking the inode
@@ -953,7 +958,8 @@ static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq,* Note that O_APPEND is not supported for NFS direct writes, as there * is no atomic O_APPEND write facility in the NFS protocol. */ -ssize_t nfs_file_direct_write (struct kiocb *iocb,struct iov_iter *iter) +ssize_t nfs_file_direct_write (struct kiocb *iocb,struct iov_iter *iter, +bool swap) {ssize_t result = -EINVAL , requested;size_t count;
@@ -967,7 +973,11 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter)dfprintk (FILE ,"NFS: direct write(%pD2, %zd@%Ld)\n" , file,iov_iter_count (iter), (long long ) iocb->ki_pos); - result =generic_write_checks (iocb, iter); +if (swap) +/* bypass generic checks */ + result =iov_iter_count (iter); +else + result =generic_write_checks (iocb, iter);if (result <=0 )return result; count = result;
@@ -997,16 +1007,20 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter)if (!is_sync_kiocb (iocb)) dreq->iocb = iocb; -nfs_start_io_direct (inode); +if (swap) { + requested =nfs_direct_write_schedule_iovec (dreq, iter, pos); + }else { +nfs_start_io_direct (inode); - requested =nfs_direct_write_schedule_iovec (dreq, iter, pos); + requested =nfs_direct_write_schedule_iovec (dreq, iter, pos); -if (mapping->nrpages) { -invalidate_inode_pages2_range (mapping, - pos >>PAGE_SHIFT , end); - } +if (mapping->nrpages) { +invalidate_inode_pages2_range (mapping, + pos >>PAGE_SHIFT , end); + } -nfs_end_io_direct (inode); +nfs_end_io_direct (inode); + }if (requested >0 ) { result =nfs_direct_wait (dreq);
fs/nfs/file.c +2 -2
@@ -161,7 +161,7 @@ nfs_file_read(struct kiocb *iocb, struct iov_iter *to)ssize_t result;if (iocb->ki_flags &IOCB_DIRECT ) -return nfs_file_direct_read (iocb, to); +return nfs_file_direct_read (iocb, to, false); dprintk("NFS: read(%pD2, %zu@%lu)\n", iocb->ki_filp,
@@ -609,7 +609,7 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from)return result;if (iocb->ki_flags &IOCB_DIRECT ) -return nfs_file_direct_write (iocb, from); +return nfs_file_direct_write (iocb, from, false);dprintk ("NFS: write(%pD2, %zu@%Ld)\n" , file,iov_iter_count (from), (long long ) iocb->ki_pos);
include/linux/nfs_fs.h +4 -4
@@ -480,10 +480,10 @@ static inline const struct cred *nfs_file_cred(struct file *file)* linux/fs/nfs/direct.c */ extern ssize_t nfs_direct_IO (struct kiocb *,struct iov_iter *); -extern ssize_t nfs_file_direct_read (struct kiocb *iocb, -struct iov_iter *iter); -extern ssize_t nfs_file_direct_write (struct kiocb *iocb, -struct iov_iter *iter); +ssize_t nfs_file_direct_read (struct kiocb *iocb, +struct iov_iter *iter,bool swap); +ssize_t nfs_file_direct_write (struct kiocb *iocb, +struct iov_iter *iter,bool swap);/* * linux/fs/nfs/dir.c
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 415/475 NFS: swap-out must always use STABLE writes.
In reply to Greg Kroah-HartmanFrom: NeilBrown <[email protected]>
[ Upstream commit c265de257f558a05c1859ee9e3fed04883b9ec0e ]
The commit handling code is not safe against memory-pressure deadlocks when writing to swap. In particular, nfs_commitdata_alloc() blocks indefinitely waiting for memory, and this can consume all available workqueue threads.
swap-out most likely uses STABLE writes anyway as COND_STABLE indicates that a stable write should be used if the write fits in a single request, and it normally does. However if we ever swap with a small wsize, or gather unusually large numbers of pages for a single write, this might change.
For safety, make it explicit in the code that direct writes used for swap must always use FLUSH_STABLE.
--- fs/nfs/direct.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
fs/nfs/direct.c +6 -4
@@ -855,7 +855,7 @@ static const struct nfs_pgio_completion_ops nfs_direct_write_completion_ops = {*/ static ssize_t nfs_direct_write_schedule_iovec (struct nfs_direct_req *dreq,struct iov_iter *iter, -loff_t pos) +loff_t pos,int ioflags) {struct nfs_pageio_descriptor desc;struct inode *inode = dreq->inode;
@@ -863,7 +863,7 @@ static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq,size_t requested_bytes =0 ;size_t wsize =max_t (size_t,NFS_SERVER (inode)->wsize,PAGE_SIZE ); -nfs_pageio_init_write (&desc, inode,FLUSH_COND_STABLE , false, +nfs_pageio_init_write (&desc, inode, ioflags, false, &nfs_direct_write_completion_ops); desc.pg_dreq = dreq;get_dreq (dreq);
@@ -1008,11 +1008,13 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter, dreq->iocb = iocb;if (swap) { - requested =nfs_direct_write_schedule_iovec (dreq, iter, pos); + requested =nfs_direct_write_schedule_iovec (dreq, iter, pos, +FLUSH_STABLE ); }else {nfs_start_io_direct (inode); - requested =nfs_direct_write_schedule_iovec (dreq, iter, pos); + requested =nfs_direct_write_schedule_iovec (dreq, iter, pos, +FLUSH_COND_STABLE );if (mapping->nrpages) { invalidate_inode_pages2_range(mapping,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 416/475 serial: samsung_tty: do not unlock port->lock for uart_write_wakeup()
In reply to Greg Kroah-HartmanFrom: Jiri Slaby <[email protected]>
[ Upstream commit 988c7c00691008ea1daaa1235680a0da49dab4e8 ]
The commit c15c3747ee32 (serial: samsung: fix potential soft lockup during uart write) added an unlock of port->lock before uart_write_wakeup() and a lock after it. It was always problematic to write data from tty_ldisc_ops::write_wakeup and it was even documented that way. We fixed the line disciplines to conform to this recently. So if there is still a missed one, we should fix them instead of this workaround.
On the top of that, s3c24xx_serial_tx_dma_complete() in this driver still holds the port->lock while calling uart_write_wakeup().
So revert the wrap added by the commit above.
--- drivers/tty/serial/samsung.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/samsung.c +1 -4
@@ -761,11 +761,8 @@ static irqreturn_t s3c24xx_serial_tx_chars(int irq, void *id) goto out; } -if (uart_circ_chars_pending (xmit) <WAKEUP_CHARS ) { -spin_unlock (&port->lock); +if (uart_circ_chars_pending (xmit) <WAKEUP_CHARS )uart_write_wakeup (port); -spin_lock (&port->lock); - }if (uart_circ_empty (xmit))s3c24xx_serial_stop_tx (port);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 417/475 virtio_console: eliminate anonymous module_init & module_exit
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit fefb8a2a941338d871e2d83fbd65fbfa068857bd ]
Eliminate anonymous module_init() and module_exit(), which can lead to confusion or ambiguity when reading System.map, crashes/oops/bugs, or an initcall_debug log.
Give each of these init and exit functions unique driver-specific names to eliminate the anonymous names.
Example 1: (System.map)
ffffffff832fc78c t init
ffffffff832fc79e t init
ffffffff832fc8f8 t init
Example 2: (initcall_debug log)
calling init+0x0/0x12 @ 1
initcall init+0x0/0x12 returned 0 after 15 usecs
calling init+0x0/0x60 @ 1
initcall init+0x0/0x60 returned 0 after 2 usecs
calling init+0x0/0x9a @ 1
initcall init+0x0/0x9a returned 0 after 74 usecs
--- drivers/char/virtio_console.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/char/virtio_console.c +4 -4
@@ -2241,7 +2241,7 @@ static struct virtio_driver virtio_rproc_serial = { .remove = virtcons_remove, }; -static int __init init (void ) +static int __init virtio_console_init (void ) {int err;
@@ -2278,7 +2278,7 @@ static int __init init(void)return err; } -static void __exit fini(void) +static void __exit virtio_console_fini(void) {reclaim_dma_bufs ();
@@ -2288,8 +2288,8 @@ static void __exit fini(void)class_destroy (pdrvdata.class);debugfs_remove_recursive (pdrvdata.debugfs_dir); } -module_init (init); -module_exit (fini); +module_init (virtio_console_init); +module_exit (virtio_console_fini);MODULE_DESCRIPTION ("Virtio console driver" );MODULE_LICENSE ("GPL" );
Signature · 8 lines
2.35.1 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Greg Kroah-Hartman
maintainerPATCH 418/475 jfs: prevent NULL deref in diFree
In reply to Greg Kroah-HartmanFrom: Haimin Zhang <[email protected]>
[ Upstream commit a53046291020ec41e09181396c1e829287b48d47 ]
Add validation check for JFS_IP(ipimap)->i_imap to prevent a NULL deref in diFree since diFree uses it without do any validations. When function jfs_mount calls diMount to initialize fileset inode allocation map, it can fail and JFS_IP(ipimap)->i_imap won't be initialized. Then it calls diFreeSpecial to close fileset inode allocation map inode and it will flow into jfs_evict_inode. Function jfs_evict_inode just validates JFS_SBI(inode->i_sb)->ipimap, then calls diFree. diFree use JFS_IP(ipimap)->i_imap directly, then it will cause a NULL deref.
--- fs/jfs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/jfs/inode.c +2 -1
@@ -146,12 +146,13 @@ void jfs_evict_inode(struct inode *inode)dquot_initialize (inode);if (JFS_IP (inode)->fileset ==FILESYSTEM_I ) { +struct inode *ipimap =JFS_SBI (inode->i_sb)->ipimap;truncate_inode_pages_final (&inode->i_data);if (test_cflag (COMMIT_Freewmap, inode))jfs_free_zero_link (inode); -if (JFS_SBI (inode->i_sb)->ipimap) +if (ipimap &&JFS_IP (ipimap)->i_imap)diFree (inode);/*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 419/475 SUNRPC: Fix socket waits for write buffer space
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit 7496b59f588dd52886fdbac7633608097543a0a5 ]
The socket layer requires that we use the socket lock to protect changes to the sock->sk_write_pending field and others.
--- net/sunrpc/xprtsock.c | 54 +++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 15 deletions(-)
net/sunrpc/xprtsock.c +39 -15
@@ -872,12 +872,12 @@ static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen,/** * xs_nospace - handle transmit was incomplete * @req: pointer to RPC request +* @transport: pointer to struct sock_xprt * */ -static int xs_nospace (struct rpc_rqst *req) +static int xs_nospace (struct rpc_rqst *req,struct sock_xprt *transport) { -struct rpc_xprt *xprt = req->rq_xprt; - struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); +struct rpc_xprt *xprt = &transport->xprt;struct sock *sk = transport->inet;int ret = -EAGAIN ;
@@ -891,25 +891,49 @@ static int xs_nospace(struct rpc_rqst *req)/* Don't race with disconnect */ if (xprt_connected (xprt)) { +struct socket_wq *wq; + +rcu_read_lock (); + wq =rcu_dereference (sk->sk_wq); +set_bit (SOCKWQ_ASYNC_NOSPACE , &wq->flags); +rcu_read_unlock (); +/* wait for more buffer space */ +set_bit (SOCK_NOSPACE , &sk->sk_socket->flags); sk->sk_write_pending++;xprt_wait_for_buffer_space (xprt); }else ret = -ENOTCONN ;spin_unlock (&xprt->transport_lock); +return ret; +} -/* Race breaker in case memory is freed before above code is called */ -if (ret == -EAGAIN ) { -struct socket_wq *wq; +static int xs_sock_nospace (struct rpc_rqst *req) +{ +struct sock_xprt *transport = + container_of(req->rq_xprt, struct sock_xprt, xprt); +struct sock *sk = transport->inet; +int ret = -EAGAIN ; -rcu_read_lock (); - wq =rcu_dereference (sk->sk_wq); -set_bit (SOCKWQ_ASYNC_NOSPACE , &wq->flags); -rcu_read_unlock (); +lock_sock (sk); +if (!sock_writeable (sk)) + ret =xs_nospace (req, transport); +release_sock (sk); +return ret; +} - sk->sk_write_space (sk); - } +static int xs_stream_nospace (struct rpc_rqst *req) +{ +struct sock_xprt *transport = + container_of(req->rq_xprt, struct sock_xprt, xprt); +struct sock *sk = transport->inet; +int ret = -EAGAIN ; + +lock_sock (sk); +if (!sk_stream_memory_free (sk)) + ret =xs_nospace (req, transport); +release_sock (sk);return ret; }
@@ -996,7 +1020,7 @@ static int xs_local_send_request(struct rpc_rqst *req)case -ENOBUFS :break ;case -EAGAIN : - status =xs_nospace (req); + status =xs_stream_nospace (req);break ;default : dprintk("RPC: sendmsg returned unrecognized error %d\n",
@@ -1068,7 +1092,7 @@ static int xs_udp_send_request(struct rpc_rqst *req)/* Should we call xs_close() here? */ break ;case -EAGAIN : - status =xs_nospace (req); + status =xs_sock_nospace (req);break ;case -ENETUNREACH :case -ENOBUFS :
@@ -1181,7 +1205,7 @@ static int xs_tcp_send_request(struct rpc_rqst *req)/* Should we call xs_close() here? */ break ;case -EAGAIN : - status =xs_nospace (req); + status =xs_stream_nospace (req);break ;case -ECONNRESET :case -ECONNREFUSED :
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 420/475 parisc: Fix CPU affinity for Lasi, WAX and Dino chips
In reply to Greg Kroah-HartmanFrom: Helge Deller <[email protected]>
[ Upstream commit 939fc856676c266c3bc347c1c1661872a3725c0f ]
Add the missing logic to allow Lasi, WAX and Dino to set the CPU affinity. This fixes IRQ migration to other CPUs when a CPU is shutdown which currently holds the IRQs for one of those chips.
--- drivers/parisc/dino.c | 41 +++++++++++++++++++++++++++++++++-------- drivers/parisc/gsc.c | 31 +++++++++++++++++++++++++++++++ drivers/parisc/gsc.h | 1 + drivers/parisc/lasi.c | 7 +++---- drivers/parisc/wax.c | 7 +++---- 5 files changed, 71 insertions(+), 16 deletions(-)
drivers/parisc/dino.c +33 -8
@@ -142,9 +142,8 @@ struct dino_device {struct pci_hba_data hba;/* 'C' inheritance - must be first */ spinlock_t dinosaur_pen; -unsigned long txn_addr;/* EIR addr to generate interrupt */ -u32 txn_data;/* EIR data assign to each dino */ u32 imr;/* IRQ's which are enabled */ +struct gsc_irq gsc_irq;int global_irq[DINO_LOCAL_IRQS ];/* map IMR bit to global irq */ #ifdef DINO_DEBUG unsigned int dino_irr0;/* save most recent IRQ line stat */
@@ -339,14 +338,43 @@ static void dino_unmask_irq(struct irq_data *d)if (tmp &DINO_MASK_IRQ (local_irq)) {DBG (KERN_WARNING "%s(): IRQ asserted! (ILR 0x%x)\n" , __func__, tmp); -gsc_writel (dino_dev->txn_data, dino_dev->txn_addr); +gsc_writel (dino_dev->gsc_irq.txn_data, dino_dev->gsc_irq.txn_addr); } } +#ifdef CONFIG_SMP +static int dino_set_affinity_irq (struct irq_data *d,const struct cpumask *dest, +bool force) +{ +struct dino_device *dino_dev =irq_data_get_irq_chip_data (d); +struct cpumask tmask; +int cpu_irq; +u32 eim; + +if (!cpumask_and (&tmask, dest, cpu_online_mask)) +return -EINVAL ; + + cpu_irq =cpu_check_affinity (d, &tmask); +if (cpu_irq <0 ) +return cpu_irq; + + dino_dev->gsc_irq.txn_addr =txn_affinity_addr (d->irq, cpu_irq); + eim = ((u32 ) dino_dev->gsc_irq.txn_addr) | dino_dev->gsc_irq.txn_data; +__raw_writel (eim, dino_dev->hba.base_addr+DINO_IAR0 ); + +irq_data_update_effective_affinity (d, &tmask); + +return IRQ_SET_MASK_OK ; +} +#endif +static struct irq_chip dino_interrupt_type = { .name ="GSC-PCI" , .irq_unmask = dino_unmask_irq, .irq_mask = dino_mask_irq, +#ifdef CONFIG_SMP + .irq_set_affinity = dino_set_affinity_irq, +#endif };
@@ -806,7 +834,6 @@ static int __init dino_common_init(struct parisc_device *dev, {int status;u32 eim; -struct gsc_irq gsc_irq;struct resource *res;pcibios_register_hba (&dino_dev->hba);
@@ -821,10 +848,8 @@ static int __init dino_common_init(struct parisc_device *dev,** still only has 11 IRQ input lines - just map some of them ** to a different processor. */ - dev->irq =gsc_alloc_irq (&gsc_irq); - dino_dev->txn_addr = gsc_irq.txn_addr; - dino_dev->txn_data = gsc_irq.txn_data; - eim = ((u32 ) gsc_irq.txn_addr) | gsc_irq.txn_data; + dev->irq =gsc_alloc_irq (&dino_dev->gsc_irq); + eim = ((u32 ) dino_dev->gsc_irq.txn_addr) | dino_dev->gsc_irq.txn_data;/* ** Dino needs a PA "IRQ" to get a processor's attention.
drivers/parisc/gsc.c +31 -0
@@ -135,10 +135,41 @@ static void gsc_asic_unmask_irq(struct irq_data *d)*/ } +#ifdef CONFIG_SMP +static int gsc_set_affinity_irq (struct irq_data *d,const struct cpumask *dest, +bool force) +{ +struct gsc_asic *gsc_dev =irq_data_get_irq_chip_data (d); +struct cpumask tmask; +int cpu_irq; + +if (!cpumask_and (&tmask, dest, cpu_online_mask)) +return -EINVAL ; + + cpu_irq =cpu_check_affinity (d, &tmask); +if (cpu_irq <0 ) +return cpu_irq; + + gsc_dev->gsc_irq.txn_addr =txn_affinity_addr (d->irq, cpu_irq); + gsc_dev->eim = ((u32 ) gsc_dev->gsc_irq.txn_addr) | gsc_dev->gsc_irq.txn_data; + +/* switch IRQ's for devices below LASI/WAX to other CPU */ +gsc_writel (gsc_dev->eim, gsc_dev->hpa +OFFSET_IAR ); + +irq_data_update_effective_affinity (d, &tmask); + +return IRQ_SET_MASK_OK ; +} +#endif + +static struct irq_chip gsc_asic_interrupt_type = { .name ="GSC-ASIC" , .irq_unmask = gsc_asic_unmask_irq, .irq_mask = gsc_asic_mask_irq, +#ifdef CONFIG_SMP + .irq_set_affinity = gsc_set_affinity_irq, +#endif };int gsc_assign_irq (struct irq_chip *type,void *data)
drivers/parisc/gsc.h +1 -0
@@ -31,6 +31,7 @@ struct gsc_asic {int version;int type;int eim; +struct gsc_irq gsc_irq;int global_irq[32 ]; };
drivers/parisc/lasi.c +3 -4
@@ -163,7 +163,6 @@ static int __init lasi_init_chip(struct parisc_device *dev) {extern void (*chassis_power_off)(void );struct gsc_asic *lasi; -struct gsc_irq gsc_irq;int ret; lasi =kzalloc (sizeof (*lasi),GFP_KERNEL );
@@ -185,7 +184,7 @@ static int __init lasi_init_chip(struct parisc_device *dev)lasi_init_irq (lasi);/* the IRQ lasi should use */ - dev->irq =gsc_alloc_irq (&gsc_irq); + dev->irq =gsc_alloc_irq (&lasi->gsc_irq);if (dev->irq <0 ) {printk (KERN_ERR "%s(): cannot get GSC irq\n" , __func__);
@@ -193,9 +192,9 @@ static int __init lasi_init_chip(struct parisc_device *dev)return -EBUSY ; } - lasi->eim = ((u32 ) gsc_irq.txn_addr) | gsc_irq.txn_data; + lasi->eim = ((u32 ) lasi->gsc_irq.txn_addr) | lasi->gsc_irq.txn_data; - ret =request_irq (gsc_irq.irq, gsc_asic_intr,0 ,"lasi" , lasi); + ret =request_irq (lasi->gsc_irq.irq, gsc_asic_intr,0 ,"lasi" , lasi);if (ret <0 ) {kfree (lasi);return ret;
drivers/parisc/wax.c +3 -4
@@ -68,7 +68,6 @@ static int __init wax_init_chip(struct parisc_device *dev) {struct gsc_asic *wax;struct parisc_device *parent; -struct gsc_irq gsc_irq;int ret; wax =kzalloc (sizeof (*wax),GFP_KERNEL );
@@ -85,7 +84,7 @@ static int __init wax_init_chip(struct parisc_device *dev)wax_init_irq (wax);/* the IRQ wax should use */ - dev->irq =gsc_claim_irq (&gsc_irq,WAX_GSC_IRQ ); + dev->irq =gsc_claim_irq (&wax->gsc_irq,WAX_GSC_IRQ );if (dev->irq <0 ) {printk (KERN_ERR "%s(): cannot get GSC irq\n" , __func__);
@@ -93,9 +92,9 @@ static int __init wax_init_chip(struct parisc_device *dev)return -EBUSY ; } - wax->eim = ((u32 ) gsc_irq.txn_addr) | gsc_irq.txn_data; + wax->eim = ((u32 ) wax->gsc_irq.txn_addr) | wax->gsc_irq.txn_data; - ret =request_irq (gsc_irq.irq, gsc_asic_intr,0 ,"wax" , wax); + ret =request_irq (wax->gsc_irq.irq, gsc_asic_intr,0 ,"wax" , wax);if (ret <0 ) {kfree (wax);return ret;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 421/475 parisc: Fix patch code locking and flushing
In reply to Greg Kroah-HartmanFrom: John David Anglin <[email protected]>
[ Upstream commit a9fe7fa7d874a536e0540469f314772c054a0323 ]
This change fixes the following:
1) The flags variable is not initialized. Always use raw_spin_lock_irqsave and raw_spin_unlock_irqrestore to serialize patching.
2) flush_kernel_vmap_range is primarily intended for DMA flushes. Since __patch_text_multiple is often called with interrupts disabled, it is better to directly call flush_kernel_dcache_range_asm and flush_kernel_icache_range_asm. This avoids an extra call.
3) The final call to flush_icache_range is unnecessary.
--- arch/parisc/kernel/patch.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
arch/parisc/kernel/patch.c +11 -14
@@ -40,10 +40,7 @@ static void __kprobes *patch_map(void *addr, int fixmap, unsigned long *flags, *need_unmap =1 ;set_fixmap (fixmap,page_to_phys (page)); -if (flags) -raw_spin_lock_irqsave (&patch_lock, *flags); -else -__acquire (&patch_lock); +raw_spin_lock_irqsave (&patch_lock, *flags);return (void *) (__fix_to_virt (fixmap) + (uintaddr & ~PAGE_MASK )); }
@@ -52,10 +49,7 @@ static void __kprobes patch_unmap(int fixmap, unsigned long *flags) {clear_fixmap (fixmap); -if (flags) -raw_spin_unlock_irqrestore (&patch_lock, *flags); -else -__release (&patch_lock); +raw_spin_unlock_irqrestore (&patch_lock, *flags); }void __kprobes __patch_text_multiple (void *addr,u32 *insn,unsigned int len)
@@ -67,8 +61,9 @@ void __kprobes __patch_text_multiple(void *addr, u32 *insn, unsigned int len)int mapped;/* Make sure we don't have any aliases in cache */ -flush_kernel_vmap_range (addr, len); -flush_icache_range (start, end); +flush_kernel_dcache_range_asm (start, end); +flush_kernel_icache_range_asm (start, end); +flush_tlb_kernel_range (start, end); p = fixmap =patch_map (addr,FIX_TEXT_POKE0 , &flags, &mapped);
@@ -81,8 +76,10 @@ void __kprobes __patch_text_multiple(void *addr, u32 *insn, unsigned int len)* We're crossing a page boundary, so * need to remap */ -flush_kernel_vmap_range ((void *)fixmap, - (p-fixmap) *sizeof (*p)); +flush_kernel_dcache_range_asm ((unsigned long )fixmap, + (unsigned long )p); +flush_tlb_kernel_range ((unsigned long )fixmap, + (unsigned long )p);if (mapped)patch_unmap (FIX_TEXT_POKE0 , &flags); p = fixmap = patch_map(addr, FIX_TEXT_POKE0, &flags,
@@ -90,10 +87,10 @@ void __kprobes __patch_text_multiple(void *addr, u32 *insn, unsigned int len) } } -flush_kernel_vmap_range ((void *)fixmap, (p-fixmap) *sizeof (*p)); +flush_kernel_dcache_range_asm ((unsigned long )fixmap, (unsigned long )p); +flush_tlb_kernel_range ((unsigned long )fixmap, (unsigned long )p);if (mapped)patch_unmap (FIX_TEXT_POKE0 , &flags); -flush_icache_range (start, end); }void __kprobes __patch_text (void *addr,u32 insn)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 422/475 mm: fix race between MADV_FREE reclaim and blkdev direct IO read
In reply to Greg Kroah-HartmanFrom: Mauricio Faria de Oliveira <[email protected]>
commit 6c8e2a256915a223f6289f651d6b926cd7135c9e upstream.
Problem:
=======
Userspace might read the zero-page instead of actual data from a direct IO read on a block device if the buffers have been called madvise(MADV_FREE) on earlier (this is discussed below) due to a race between page reclaim on MADV_FREE and blkdev direct IO read.
- Race condition:
==============
During page reclaim, the MADV_FREE page check in try_to_unmap_one() checks if the page is not dirty, then discards its rmap PTE(s) (vs. remap back if the page is dirty).
However, after try_to_unmap_one() returns to shrink_page_list(), it might keep the page _anyway_ if page_ref_freeze() fails (it expects exactly _one_ page reference, from the isolation for page reclaim).
Well, blkdev_direct_IO() gets references for all pages, and on READ operations it only sets them dirty _later_.
So, if MADV_FREE'd pages (i.e., not dirty) are used as buffers for direct IO read from block devices, and page reclaim happens during __blkdev_direct_IO[_simple]() exactly AFTER bio_iov_iter_get_pages() returns, but BEFORE the pages are set dirty, the situation happens.
The direct IO read eventually completes. Now, when userspace reads the buffers, the PTE is no longer there and the page fault handler do_anonymous_page() services that with the zero-page, NOT the data!
A synthetic reproducer is provided.
- Page faults:
===========
If page reclaim happens BEFORE bio_iov_iter_get_pages() the issue doesn't happen, because that faults-in all pages as writeable, so do_anonymous_page() sets up a new page/rmap/PTE, and that is used by direct IO. The userspace reads don't fault as the PTE is there (thus zero-page is not used/setup).
But if page reclaim happens AFTER it / BEFORE setting pages dirty, the PTE is no longer there; the subsequent page faults can't help:
The data-read from the block device probably won't generate faults due to DMA (no MMU) but even in the case it wouldn't use DMA, that happens on different virtual addresses (not user-mapped addresses) because struct bio_vec stores struct page to figure addresses out (which are different from user-mapped addresses) for the read.
Thus userspace reads (to user-mapped addresses) still fault, then do_anonymous_page() gets another struct page that would address/ map to other memory than the struct page used by struct bio_vec for the read. (The original struct page is not available, since it wasn't freed, as page_ref_freeze() failed due to more page refs. And even if it were available, its data cannot be trusted anymore.)
Solution:
========
One solution is to check for the expected page reference count in try_to_unmap_one().
There should be one reference from the isolation (that is also checked in shrink_page_list() with page_ref_freeze()) plus one or more references from page mapping(s) (put in discard: label). Further references mean that rmap/PTE cannot be unmapped/nuked.
(Note: there might be more than one reference from mapping due to fork()/clone() without CLONE_VM, which use the same struct page for references, until the copy-on-write page gets copied.)
So, additional page references (e.g., from direct IO read) now prevent the rmap/PTE from being unmapped/dropped; similarly to the page is not freed per shrink_page_list()/page_ref_freeze()).
- Races and Barriers:
==================
The new check in try_to_unmap_one() should be safe in races with bio_iov_iter_get_pages() in get_user_pages() fast and slow paths, as it's done under the PTE lock.
The fast path doesn't take the lock, but it checks if the PTE has changed and if so, it drops the reference and leaves the page for the slow path (which does take that lock).
The fast path requires synchronization w/ full memory barrier: it writes the page reference count first then it reads the PTE later, while try_to_unmap() writes PTE first then it reads page refcount.
And a second barrier is needed, as the page dirty flag should not be read before the page reference count (as in __remove_mapping()). (This can be a load memory barrier only; no writes are involved.)
Call stack/comments:
- try_to_unmap_one()
- page_vma_mapped_walk()
- map_pte() # see pte_offset_map_lock():
pte_offset_map()
spin_lock()
- ptep_get_and_clear() # write PTE
- smp_mb() # (new barrier) GUP fast path
- page_ref_count() # (new check) read refcount
- page_vma_mapped_walk_done() # see pte_unmap_unlock():
pte_unmap()
spin_unlock()- bio_iov_iter_get_pages()
- __bio_iov_iter_get_pages()
- iov_iter_get_pages()
- get_user_pages_fast()
- internal_get_user_pages_fast()
# fast path
- lockless_pages_from_mm()
- gup_{pgd,p4d,pud,pmd,pte}_range()
ptep = pte_offset_map() # not _lock()
pte = ptep_get_lockless(ptep)
page = pte_page(pte)
try_grab_compound_head(page) # inc refcount
# (RMW/barrier # on success)
if (pte_val(pte) != pte_val(*ptep)) # read PTE
put_compound_head(page) # dec refcount
# go slow path
# slow path
- __gup_longterm_unlocked()
- get_user_pages_unlocked()
- __get_user_pages_locked()
- __get_user_pages()
- follow_{page,p4d,pud,pmd}_mask()
- follow_page_pte()
ptep = pte_offset_map_lock() pte = *ptep
page = vm_normal_page(pte)
try_grab_page(page) # inc refcount
pte_unmap_unlock()
- Huge Pages:
==========
Regarding transparent hugepages, that logic shouldn't change, as MADV_FREE (aka lazyfree) pages are PageAnon() && !PageSwapBacked() (madvise_free_pte_range() -> mark_page_lazyfree() -> lru_lazyfree_fn()) thus should reach shrink_page_list() -> split_huge_page_to_list() before try_to_unmap[_one](), so it deals with normal pages only.
(And in case unlikely/TTU_SPLIT_HUGE_PMD/split_huge_pmd_address() happens, which should not or be rare, the page refcount should be greater than
mapcount: the head page is referenced by tail pages. That also prevents checking the head page then incorrectly call page_remove_rmap(subpage) for a tail page, that isn't even in the shrink_page_list()'s page_list (an effect of split huge pmd/pmvw), as it might happen today in this unlikely scenario.)
MADV_FREE'd buffers:
===================
So, back to the "if MADV_FREE pages are used as buffers" note. The case is arguable, and subject to multiple interpretations.
The madvise(2) manual page on the MADV_FREE advice value says:
1) 'After a successful MADV_FREE ... data will be lost when the kernel frees the pages.'
2) 'the free operation will be canceled if the caller writes into the page' / 'subsequent writes ... will succeed and then [the] kernel cannot free those dirtied pages'
3) 'If there is no subsequent write, the kernel can free the pages at any time.'
Thoughts, questions, considerations... respectively:
1) Since the kernel didn't actually free the page (page_ref_freeze() failed), should the data not have been lost? (on userspace read.)
2) Should writes performed by the direct IO read be able to cancel the free operation?
- Should the direct IO read be considered as 'the caller' too, as it's been requested by 'the caller'?
- Should the bio technique to dirty pages on return to userspace (bio_check_pages_dirty() is called/used by __blkdev_direct_IO()) be considered in another/special way here?
3) Should an upcoming write from a previously requested direct IO read be considered as a subsequent write, so the kernel should not free the pages? (as it's known at the time of page reclaim.)
And lastly:
Technically, the last point would seem a reasonable consideration and balance, as the madvise(2) manual page apparently (and fairly) seem to assume that 'writes' are memory access from the userspace process (not explicitly considering writes from the kernel or its corner cases; again, fairly).. plus the kernel fix implementation for the corner case of the largely 'non-atomic write' encompassed by a direct IO read operation, is relatively simple; and it helps.
Reproducer:
==========
@ test.c (simplified, but works)
#define _GNU_SOURCE
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
int main() {
int fd, i;
char *buf;
fd = open(DEV, O_RDONLY | O_DIRECT);
buf = mmap(NULL, BUF_SIZE, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
for (i = 0; i < BUF_SIZE; i += PAGE_SIZE)
buf[i] = 1; // init to non-zero
madvise(buf, BUF_SIZE, MADV_FREE);
read(fd, buf, BUF_SIZE);
for (i = 0; i < BUF_SIZE; i += PAGE_SIZE)
printf("%p: 0x%x\n", &buf[i], buf[i]);
return 0;
}@ block/fops.c (formerly fs/block_dev.c)
+#include <linux/swap.h>
...
... __blkdev_direct_IO[_simple](...)
{
...
+ if (!strcmp(current->comm, "good"))
+ shrink_all_memory(ULONG_MAX);
+
ret = bio_iov_iter_get_pages(...);
+
+ if (!strcmp(current->comm, "bad"))
+ shrink_all_memory(ULONG_MAX);
...
}@ shell
# NUM_PAGES=4
# PAGE_SIZE=$(getconf PAGE_SIZE)
# yes | dd of=test.img bs=${PAGE_SIZE} count=${NUM_PAGES}
# DEV=$(losetup -f --show test.img)
# gcc -DDEV=\"$DEV\" \
-DBUF_SIZE=$((PAGE_SIZE * NUM_PAGES)) \
-DPAGE_SIZE=${PAGE_SIZE} \
test.c -o test
# od -tx1 $DEV
0000000 79 0a 79 0a 79 0a 79 0a 79 0a 79 0a 79 0a 79 0a
*
0040000
# mv test good
# ./good
0x7f7c10418000: 0x79
0x7f7c10419000: 0x79
0x7f7c1041a000: 0x79
0x7f7c1041b000: 0x79
# mv good bad
# ./bad
0x7fa1b8050000: 0x0
0x7fa1b8051000: 0x0
0x7fa1b8052000: 0x0
0x7fa1b8053000: 0x0Note: the issue is consistent on v5.17-rc3, but it's intermittent with the support of MADV_FREE on v4.5 (60%-70% error; needs swap). [wrap do_direct_IO() in do_blockdev_direct_IO() @ fs/direct-io.c].
- v5.17-rc3:
# for i in {1..1000}; do ./good; done \
| cut -d: -f2 | sort | uniq -c
4000 0x79 # mv good bad
# for i in {1..1000}; do ./bad; done \
| cut -d: -f2 | sort | uniq -c
4000 0x0 # free | grep Swap
Swap: 0 0 0- v4.5:
# for i in {1..1000}; do ./good; done \
| cut -d: -f2 | sort | uniq -c
4000 0x79 # mv good bad
# for i in {1..1000}; do ./bad; done \
| cut -d: -f2 | sort | uniq -c
2702 0x0
1298 0x79 # swapoff -av
swapoff /swap # for i in {1..1000}; do ./bad; done \
| cut -d: -f2 | sort | uniq -c
4000 0x79Ceph/TCMalloc:
=============
For documentation purposes, the use case driving the analysis/fix is Ceph on Ubuntu 18.04, as the TCMalloc library there still uses MADV_FREE to release unused memory to the system from the mmap'ed page heap (might be committed back/used again; it's not munmap'ed.) - PageHeap::DecommitSpan() -> TCMalloc_SystemRelease() -> madvise() - PageHeap::CommitSpan() -> TCMalloc_SystemCommit() -> do nothing.
Note: TCMalloc switched back to MADV_DONTNEED a few commits after the release in Ubuntu 18.04 (google-perftools/gperftools 2.5), so the issue just 'disappeared' on Ceph on later Ubuntu releases but is still present in the kernel, and can be hit by other use cases.
The observed issue seems to be the old Ceph bug #22464 [1], where checksum mismatches are observed (and instrumentation with buffer dumps shows zero-pages read from mmap'ed/MADV_FREE'd page ranges).
The issue in Ceph was reasonably deemed a kernel bug (comment #50) and mostly worked around with a retry mechanism, but other parts of Ceph could still hit that (rocksdb). Anyway, it's less likely to be hit again as TCMalloc switched out of MADV_FREE by default.
(Some kernel versions/reports from the Ceph bug, and relation with the MADV_FREE introduction/changes; TCMalloc versions not checked.)
- 4.4 good
- 4.5 (madv_free: introduction)
- 4.9 bad
- 4.10 good? maybe a swapless system
- 4.12 (madv_free: no longer free instantly on swapless systems)
- 4.13 bad
[1] https://tracker.ceph.com/issues/22464
Thanks:
======
Several people contributed to analysis/discussions/tests/reproducers in the first stages when drilling down on ceph/tcmalloc/linux kernel:
- Dan Hill
- Dan Streetman
- Dongdong Tao
- Gavin Guo
- Gerald Yang
- Heitor Alves de Siqueira
- Ioanna Alifieraki
- Jay Vosburgh
- Matthew Ruffell
- Ponnuvel Palaniyappan
Reviews, suggestions, corrections, comments:
- Minchan Kim
- Yu Zhao
- Huang, Ying
- John Hubbard
- Christoph Hellwig
[mfo: backport: replace folio/test_flag with page/flag equivalents;
real Fixes: 854e9ed09ded ("mm: support madvise(MADV_FREE)") in v4.]
--- mm/rmap.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
mm/rmap.c +24 -1
@@ -1602,7 +1602,30 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,/* MADV_FREE page check */ if (!PageSwapBacked (page)) { -if (!PageDirty (page)) { +int ref_count, map_count; + +/* +* Synchronize with gup_pte_range(): +* - clear PTE; barrier; read refcount +* - inc refcount; barrier; read PTE +*/ +smp_mb (); + + ref_count =page_ref_count (page); + map_count =page_mapcount (page); + +/* +* Order reads for page refcount and dirty flag +* (see comments in __remove_mapping()). +*/ +smp_rmb (); + +/* +* The only page refs must be one from isolation +* plus the rmap(s) (dropped by discard:). +*/ +if (ref_count ==1 + map_count && + !PageDirty (page)) {/* Invalidate as we cleared the pte */ mmu_notifier_invalidate_range (mm, address, address +PAGE_SIZE );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 423/475 KVM: arm64: Check arm64_get_bp_hardening_data() didnt return NULL
In reply to Greg Kroah-HartmanFrom: James Morse <[email protected]>
Will reports that with CONFIG_EXPERT=y and CONFIG_HARDEN_BRANCH_PREDICTOR=n, the kernel dereferences a NULL pointer during boot:
[ 2.384444] Internal error: Oops: 96000004 [#1] PREEMPT SMP [ 2.384461] pstate: 20400085 (nzCv daIf +PAN -UAO) [ 2.384472] pc : cpu_hyp_reinit+0x114/0x30c [ 2.384476] lr : cpu_hyp_reinit+0x80/0x30c
[ 2.384529] Call trace: [ 2.384533] cpu_hyp_reinit+0x114/0x30c [ 2.384537] _kvm_arch_hardware_enable+0x30/0x54 [ 2.384541] flush_smp_call_function_queue+0xe4/0x154 [ 2.384544] generic_smp_call_function_single_interrupt+0x10/0x18 [ 2.384549] ipi_handler+0x170/0x2b0 [ 2.384555] handle_percpu_devid_fasteoi_ipi+0x120/0x1cc [ 2.384560] __handle_domain_irq+0x9c/0xf4 [ 2.384563] gic_handle_irq+0x6c/0xe4 [ 2.384566] el1_irq+0xf0/0x1c0 [ 2.384570] arch_cpu_idle+0x28/0x44 [ 2.384574] do_idle+0x100/0x2a8 [ 2.384577] cpu_startup_entry+0x20/0x24 [ 2.384581] secondary_start_kernel+0x1b0/0x1cc [ 2.384589] Code: b9469d08 7100011f 540003ad 52800208 (f9400108) [ 2.384600] ---[ end trace 266d08dbf96ff143 ]--- [ 2.385171] Kernel panic - not syncing: Fatal exception in interrupt
In this configuration arm64_get_bp_hardening_data() returns NULL. Add a check in kvm_get_hyp_vector().
--- arch/arm64/include/asm/kvm_mmu.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/include/asm/kvm_mmu.h +2 -1
@@ -479,7 +479,8 @@ static inline void *kvm_get_hyp_vector(void)int slot =-1 ;if ((cpus_have_const_cap (ARM64_HARDEN_BRANCH_PREDICTOR ) || -cpus_have_const_cap (ARM64_SPECTRE_BHB )) && data->template_start) { +cpus_have_const_cap (ARM64_SPECTRE_BHB )) && + data && data->template_start) { vect =kern_hyp_va (kvm_ksym_ref (__bp_harden_hyp_vecs_start)); slot = data->hyp_vectors_slot; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 424/475 drm/amdgpu: fix off by one in amdgpu_gfx_kiq_acquire()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 1647b54ed55d4d48c7199d439f8834626576cbe9 ]
This post-op should be a pre-op so that we do not pass -1 as the bit number to test_bit(). The current code will loop downwards from 63 to -1. After changing to a pre-op, it loops from 63 to 0.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1 -1
@@ -263,7 +263,7 @@ static int amdgpu_gfx_kiq_acquire(struct amdgpu_device *adev,* adev->gfx.mec.num_pipe_per_mec * adev->gfx.mec.num_queue_per_pipe; -while (queue_bit-- >= 0) { +while (--queue_bit >= 0) { if (test_bit(queue_bit, adev->gfx.mec.queue_bitmap)) continue;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 425/475 Drivers: hv: vmbus: Fix potential crash on module unload
In reply to Greg Kroah-HartmanFrom: Guilherme G. Piccoli <[email protected]>
[ Upstream commit 792f232d57ff28bbd5f9c4abe0466b23d5879dc8 ]
The vmbus driver relies on the panic notifier infrastructure to perform some operations when a panic event is detected. Since vmbus can be built as module, it is required that the driver handles both registering and unregistering such panic notifier callback.
After commit 74347a99e73a ("x86/Hyper-V: Unload vmbus channel in hv panic callback") though, the panic notifier registration is done unconditionally in the module initialization routine whereas the unregistering procedure is conditionally guarded and executes only if HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE capability is set.
This patch fixes that by unconditionally unregistering the panic notifier in the module's exit routine as well.
--- drivers/hv/vmbus_drv.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/hv/vmbus_drv.c +7 -2
@@ -2493,10 +2493,15 @@ static void __exit vmbus_exit(void)if (ms_hyperv.misc_features &HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE ) {kmsg_dump_unregister (&hv_kmsg_dumper);unregister_die_notifier (&hyperv_die_block); -atomic_notifier_chain_unregister (&panic_notifier_list, - &hyperv_panic_block); } +/* +* The panic notifier is always registered, hence we should +* also unconditionally unregister it here as well. +*/ +atomic_notifier_chain_unregister (&panic_notifier_list, + &hyperv_panic_block); +free_page ((unsigned long )hv_panic_page);unregister_sysctl_table (hv_ctl_table_hdr); hv_ctl_table_hdr =NULL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 426/475 scsi: zorro7xx: Fix a resource leak in zorro7xx_remove_one()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 16ed828b872d12ccba8f07bcc446ae89ba662f9c ]
The error handling path of the probe releases a resource that is not freed in the remove function. In some cases, a ioremap() must be undone.
Add the missing iounmap() call in the remove function.
--- drivers/scsi/zorro7xx.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/zorro7xx.c +2 -0
@@ -159,6 +159,8 @@ static void zorro7xx_remove_one(struct zorro_dev *z)scsi_remove_host (host);NCR_700_release (host); +if (host->base >0x01000000 ) +iounmap (hostdata->base);kfree (hostdata);free_irq (host->irq, host);zorro_release_device (z);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 427/475 net/tls: fix slab-out-of-bounds bug in decrypt_internal
In reply to Greg Kroah-HartmanFrom: Ziyang Xuan <[email protected]>
[ Upstream commit 9381fe8c849cfbe50245ac01fc077554f6eaa0e2 ]
The memory size of tls_ctx->rx.iv for AES128-CCM is 12 setting in tls_set_sw_offload(). The return value of crypto_aead_ivsize() for "ccm(aes)" is 16. So memcpy() require 16 bytes from 12 bytes memory space will trigger slab-out-of-bounds bug as following:
==================================================================
BUG: KASAN: slab-out-of-bounds in decrypt_internal+0x385/0xc40 [tls] Read of size 16 at addr ffff888114e84e60 by task tls/10911 Call Trace: <TASK> dump_stack_lvl+0x34/0x44 print_report.cold+0x5e/0x5db ? decrypt_internal+0x385/0xc40 [tls] kasan_report+0xab/0x120 ? decrypt_internal+0x385/0xc40 [tls] kasan_check_range+0xf9/0x1e0 memcpy+0x20/0x60 decrypt_internal+0x385/0xc40 [tls] ? tls_get_rec+0x2e0/0x2e0 [tls] ? process_rx_list+0x1a5/0x420 [tls] ? tls_setup_from_iter.constprop.0+0x2e0/0x2e0 [tls] decrypt_skb_update+0x9d/0x400 [tls] tls_sw_recvmsg+0x3c8/0xb50 [tls] Allocated by task 10911: kasan_save_stack+0x1e/0x40 __kasan_kmalloc+0x81/0xa0 tls_set_sw_offload+0x2eb/0xa20 [tls] tls_setsockopt+0x68c/0x700 [tls] __sys_setsockopt+0xfe/0x1b0
Replace the crypto_aead_ivsize() with prot->iv_size + prot->salt_size when memcpy() iv value in TLS_1_3_VERSION scenario.
--- net/tls/tls_sw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/tls/tls_sw.c +1 -1
@@ -1479,7 +1479,7 @@ static int decrypt_internal(struct sock *sk, struct sk_buff *skb, }if (prot->version ==TLS_1_3_VERSION )memcpy (iv + iv_offset, tls_ctx->rx.iv, -crypto_aead_ivsize (ctx->aead_recv)); + prot->iv_size + prot->salt_size);else memcpy (iv + iv_offset, tls_ctx->rx.iv, prot->salt_size);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 428/475 net: ipv4: fix route with nexthop object delete warning
In reply to Greg Kroah-HartmanFrom: Nikolay Aleksandrov <[email protected]>
[ Upstream commit 6bf92d70e690b7ff12b24f4bfff5e5434d019b82 ]
FRR folks have hit a kernel warning[1] while deleting routes[2] which is caused by trying to delete a route pointing to a nexthop id without specifying nhid but matching on an interface. That is, a route is found but we hit a warning while matching it. The warning is from fib_info_nh() in include/net/nexthop.h because we run it on a fib_info with nexthop object. The call chain is:
inet_rtm_delroute -> fib_table_delete -> fib_nh_match (called with a
nexthop fib_info and also with fc_oif set thus calling fib_info_nh on the fib_info and triggering the warning). The fix is to not do any matching in that branch if the fi has a nexthop object because those are managed separately. I.e. we should match when deleting without nh spec and should fail when deleting a nexthop route with old-style nh spec because nexthop objects are managed separately, e.g.:
$ ip r show 1.2.3.4/32 1.2.3.4 nhid 12 via 192.168.11.2 dev dummy0
$ ip r del 1.2.3.4/32 $ ip r del 1.2.3.4/32 nhid 12 <both should work>
$ ip r del 1.2.3.4/32 dev dummy0 <should fail with ESRCH>
[1]
[ 523.462226] ------------[ cut here ]------------ [ 523.462230] WARNING: CPU: 14 PID: 22893 at include/net/nexthop.h:468 fib_nh_match+0x210/0x460 [ 523.462236] Modules linked in: dummy rpcsec_gss_krb5 xt_socket nf_socket_ipv4 nf_socket_ipv6 ip6table_raw iptable_raw bpf_preload xt_statistic ip_set ip_vs_sh ip_vs_wrr ip_vs_rr ip_vs xt_mark nf_tables xt_nat veth nf_conntrack_netlink nfnetlink xt_addrtype br_netfilter overlay dm_crypt nfsv3 nfs fscache netfs vhost_net vhost vhost_iotlb tap tun xt_CHECKSUM xt_MASQUERADE xt_conntrack 8021q garp mrp ipt_REJECT nf_reject_ipv4 ip6table_mangle ip6table_nat iptable_mangle iptable_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 iptable_filter bridge stp llc rfcomm snd_seq_dummy snd_hrtimer rpcrdma rdma_cm iw_cm ib_cm ib_core ip6table_filter xt_comment ip6_tables vboxnetadp(OE) vboxnetflt(OE) vboxdrv(OE) qrtr bnep binfmt_misc xfs vfat fat squashfs loop nvidia_drm(POE) nvidia_modeset(POE) nvidia_uvm(POE) nvidia(POE) intel_rapl_msr intel_rapl_common snd_hda_codec_realtek snd_hda_codec_generic ledtrig_audio snd_hda_codec_hdmi btusb btrtl iwlmvm uvcvideo btbcm snd_hda_intel edac_mce_amd [ 523.462274] videobuf2_vmalloc videobuf2_memops btintel snd_intel_dspcfg videobuf2_v4l2 snd_intel_sdw_acpi bluetooth snd_usb_audio snd_hda_codec mac80211 snd_usbmidi_lib joydev snd_hda_core videobuf2_common kvm_amd snd_rawmidi snd_hwdep snd_seq videodev ccp snd_seq_device libarc4 ecdh_generic mc snd_pcm kvm iwlwifi snd_timer drm_kms_helper snd cfg80211 cec soundcore irqbypass rapl wmi_bmof i2c_piix4 rfkill k10temp pcspkr acpi_cpufreq nfsd auth_rpcgss nfs_acl lockd grace sunrpc drm zram ip_tables crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel nvme sp5100_tco r8169 nvme_core wmi ipmi_devintf ipmi_msghandler fuse [ 523.462300] CPU: 14 PID: 22893 Comm: ip Tainted: P OE 5.16.18-200.fc35.x86_64 #1 [ 523.462302] Hardware name: Micro-Star International Co., Ltd. MS-7C37/MPG X570 GAMING EDGE WIFI (MS-7C37), BIOS 1.C0 10/29/2020 [ 523.462303] RIP: 0010:fib_nh_match+0x210/0x460 [ 523.462304] Code: 7c 24 20 48 8b b5 90 00 00 00 e8 bb ee f4 ff 48 8b 7c 24 20 41 89 c4 e8 ee eb f4 ff 45 85 e4 0f 85 2e fe ff ff e9 4c ff ff ff <0f> 0b e9 17 ff ff ff 3c 0a 0f 85 61 fe ff ff 48 8b b5 98 00 00 00 [ 523.462306] RSP: 0018:ffffaa53d4d87928 EFLAGS: 00010286 [ 523.462307] RAX: 0000000000000000 RBX: ffffaa53d4d87a90 RCX: ffffaa53d4d87bb0 [ 523.462308] RDX: ffff9e3d2ee6be80 RSI: ffffaa53d4d87a90 RDI: ffffffff920ed380 [ 523.462309] RBP: ffff9e3d2ee6be80 R08: 0000000000000064 R09: 0000000000000000 [ 523.462310] R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000031 [ 523.462310] R13: 0000000000000020 R14: 0000000000000000 R15: ffff9e3d331054e0 [ 523.462311] FS: 00007f245517c1c0(0000) GS:ffff9e492ed80000(0000) knlGS:0000000000000000 [ 523.462313] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 523.462313] CR2: 000055e5dfdd8268 CR3: 00000003ef488000 CR4: 0000000000350ee0 [ 523.462315] Call Trace: [ 523.462316] <TASK> [ 523.462320] fib_table_delete+0x1a9/0x310 [ 523.462323] inet_rtm_delroute+0x93/0x110 [ 523.462325] rtnetlink_rcv_msg+0x133/0x370 [ 523.462327] ? _copy_to_iter+0xb5/0x6f0 [ 523.462330] ? rtnl_calcit.isra.0+0x110/0x110 [ 523.462331] netlink_rcv_skb+0x50/0xf0 [ 523.462334] netlink_unicast+0x211/0x330 [ 523.462336] netlink_sendmsg+0x23f/0x480 [ 523.462338] sock_sendmsg+0x5e/0x60 [ 523.462340] ____sys_sendmsg+0x22c/0x270 [ 523.462341] ? import_iovec+0x17/0x20 [ 523.462343] ? sendmsg_copy_msghdr+0x59/0x90 [ 523.462344] ? __mod_lruvec_page_state+0x85/0x110 [ 523.462348] ___sys_sendmsg+0x81/0xc0 [ 523.462350] ? netlink_seq_start+0x70/0x70 [ 523.462352] ? __dentry_kill+0x13a/0x180 [ 523.462354] ? __fput+0xff/0x250 [ 523.462356] __sys_sendmsg+0x49/0x80 [ 523.462358] do_syscall_64+0x3b/0x90 [ 523.462361] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 523.462364] RIP: 0033:0x7f24552aa337 [ 523.462365] Code: 0e 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b9 0f 1f 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 2e 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 89 54 24 1c 48 89 74 24 10 [ 523.462366] RSP: 002b:00007fff7f05a838 EFLAGS: 00000246 ORIG_RAX: 000000000000002e [ 523.462368] RAX: ffffffffffffffda RBX: 000000006245bf91 RCX: 00007f24552aa337 [ 523.462368] RDX: 0000000000000000 RSI: 00007fff7f05a8a0 RDI: 0000000000000003 [ 523.462369] RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000000 [ 523.462370] R10: 0000000000000008 R11: 0000000000000246 R12: 0000000000000001 [ 523.462370] R13: 00007fff7f05ce08 R14: 0000000000000000 R15: 000055e5dfdd1040 [ 523.462373] </TASK> [ 523.462374] ---[ end trace ba537bc16f6bf4ed ]---
[2] https://github.com/FRRouting/frr/issues/6412
--- net/ipv4/fib_semantics.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/ipv4/fib_semantics.c +6 -1
@@ -876,8 +876,13 @@ int fib_nh_match(struct fib_config *cfg, struct fib_info *fi, }if (cfg->fc_oif || cfg->fc_gw_family) { -struct fib_nh *nh =fib_info_nh (fi,0 ); +struct fib_nh *nh; + +/* cannot match on nexthop object attributes */ +if (fi->nh) +return 1 ; + nh =fib_info_nh (fi,0 );if (cfg->fc_encap) {if (fib_encap_match (cfg->fc_encap_type, cfg->fc_encap, nh, cfg, extack))
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 429/475 net: stmmac: Fix unset max_speed difference between DT and non-DT platforms
In reply to Greg Kroah-HartmanFrom: Chen-Yu Tsai <[email protected]>
[ Upstream commit c21cabb0fd0b54b8b54235fc1ecfe1195a23bcb2 ]
In commit 9cbadf094d9d ("net: stmmac: support max-speed device tree property"), when DT platforms don't set "max-speed", max_speed is set to -1; for non-DT platforms, it stays the default 0.
Prior to commit eeef2f6b9f6e ("net: stmmac: Start adding phylink support"), the check for a valid max_speed setting was to check if it was greater than zero. This commit got it right, but subsequent patches just checked for non-zero, which is incorrect for DT platforms.
In commit 92c3807b9ac3 ("net: stmmac: convert to phylink_get_linkmodes()") the conversion switched completely to checking for non-zero value as a valid value, which caused 1000base-T to stop getting advertised by default.
Instead of trying to fix all the checks, simply leave max_speed alone if DT property parsing fails.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +1 -2
@@ -428,8 +428,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) plat->phylink_node = np;/* Get max speed of operation from device tree */ -if (of_property_read_u32 (np,"max-speed" , &plat->max_speed)) - plat->max_speed =-1 ; +of_property_read_u32 (np,"max-speed" , &plat->max_speed); plat->bus_id =of_alias_get_id (np,"ethernet" );if (plat->bus_id <0 )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 430/475 drm/imx: Fix memory leak in imx_pd_connector_get_modes
In reply to Greg Kroah-HartmanFrom: José Expósito <[email protected]>
[ Upstream commit bce81feb03a20fca7bbdd1c4af16b4e9d5c0e1d3 ]
Avoid leaking the display mode variable if of_get_drm_display_mode fails.
Addresses-Coverity-ID: 1443943 ("Resource leak")
--- drivers/gpu/drm/imx/parallel-display.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/imx/parallel-display.c +3 -1
@@ -68,8 +68,10 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector) ret =of_get_drm_display_mode (np, &imxpd->mode, &imxpd->bus_flags,OF_USE_NATIVE_MODE ); -if (ret) +if (ret) { +drm_mode_destroy (connector->dev, mode);return ret; + }drm_mode_copy (mode, &imxpd->mode); mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 431/475 bnxt_en: reserve space inside receive page for skb_shared_info
In reply to Greg Kroah-HartmanFrom: Andy Gospodarek <[email protected]>
[ Upstream commit facc173cf700e55b2ad249ecbd3a7537f7315691 ]
Insufficient space was being reserved in the page used for packet reception, so the interface MTU could be set too large to still have room for the contents of the packet when doing XDP redirect. This resulted in the following message when redirecting a packet between 3520 and 3822 bytes with an MTU of 3822:
[311815.561880] XDP_WARN: xdp_update_frame_from_buff(line:200): Driver BUG: missing reserved tailroom
--- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.h +2 -1
@@ -559,7 +559,8 @@ struct nqe_cn {#define BNXT_MAX_MTU 9500#define BNXT_MAX_PAGE_MODE_MTU \ ((unsigned int)PAGE_SIZE - VLAN_ETH_HLEN - NET_IP_ALIGN - \ - XDP_PACKET_HEADROOM) + XDP_PACKET_HEADROOM - \ + SKB_DATA_ALIGN((unsigned int)sizeof(struct skb_shared_info)))#define BNXT_MIN_PKT_SIZE 52
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 432/475 IB/rdmavt: add lock to call to rvt_error_qp to prevent a race condition
In reply to Greg Kroah-HartmanFrom: Niels Dossche <[email protected]>
[ Upstream commit 4d809f69695d4e7d1378b3a072fa9aef23123018 ]
The documentation of the function rvt_error_qp says both r_lock and s_lock need to be held when calling that function. It also asserts using lockdep that both of those locks are held. However, the commit I referenced in Fixes accidentally makes the call to rvt_error_qp in rvt_ruc_loopback no longer covered by r_lock. This results in the lockdep assertion failing and also possibly in a race condition.
--- drivers/infiniband/sw/rdmavt/qp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/infiniband/sw/rdmavt/qp.c +5 -1
@@ -3227,7 +3227,11 @@ void rvt_ruc_loopback(struct rvt_qp *sqp)spin_lock_irqsave (&sqp->s_lock, flags);rvt_send_complete (sqp, wqe, send_status);if (sqp->ibqp.qp_type ==IB_QPT_RC ) { -int lastwqe =rvt_error_qp (sqp,IB_WC_WR_FLUSH_ERR ); +int lastwqe; + +spin_lock (&sqp->r_lock); + lastwqe =rvt_error_qp (sqp,IB_WC_WR_FLUSH_ERR ); +spin_unlock (&sqp->r_lock); sqp->s_flags &= ~RVT_S_BUSY ;spin_unlock_irqrestore (&sqp->s_lock, flags);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 433/475 dpaa2-ptp: Fix refcount leak in dpaa2_ptp_probe
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 2b04bd4f03bba021959ca339314f6739710f0954 ]
This node pointer is returned by of_find_compatible_node() with refcount incremented. Calling of_node_put() to aovid the refcount leak.
--- drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c +3 -1
@@ -148,7 +148,7 @@ static int dpaa2_ptp_probe(struct fsl_mc_device *mc_dev) base =of_iomap (node,0 );if (!base) { err = -ENOMEM ; - goto err_close; + goto err_put; } err =fsl_mc_allocate_irqs (mc_dev);
@@ -191,6 +191,8 @@ static int dpaa2_ptp_probe(struct fsl_mc_device *mc_dev)fsl_mc_free_irqs (mc_dev); err_unmap:iounmap (base); +err_put: +of_node_put (node); err_close:dprtc_close (mc_dev->mc_io,0 , mc_dev->mc_handle); err_free_mcp:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 434/475 ipv6: Fix stats accounting in ip6_pkt_drop
In reply to Greg Kroah-HartmanFrom: David Ahern <[email protected]>
[ Upstream commit 1158f79f82d437093aeed87d57df0548bdd68146 ]
VRF devices are the loopbacks for VRFs, and a loopback can not be assigned to a VRF. Accordingly, the condition in ip6_pkt_drop should be '||' not '&&'.
--- net/ipv6/route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/route.c +1 -1
@@ -4403,7 +4403,7 @@ static int ip6_pkt_drop(struct sk_buff *skb, u8 code, int ipstats_mib_noroutes)struct inet6_dev *idev;int type; -if (netif_is_l3_master (skb->dev) && +if (netif_is_l3_master (skb->dev) || dst->dev == net->loopback_dev) idev =__in6_dev_get_safely (dev_get_by_index_rcu (net,IP6CB (skb)->iif));else
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 435/475 net: openvswitch: dont send internal clone attribute to the userspace.
In reply to Greg Kroah-HartmanFrom: Ilya Maximets <[email protected]>
[ Upstream commit 3f2a3050b4a3e7f32fc0ea3c9b0183090ae00522 ]
'OVS_CLONE_ATTR_EXEC' is an internal attribute that is used for performance optimization inside the kernel. It's added by the kernel while parsing user-provided actions and should not be sent during the flow dump as it's not part of the uAPI.
The issue doesn't cause any significant problems to the ovs-vswitchd process, because reported actions are not really used in the application lifecycle and only supposed to be shown to a human via ovs-dpctl flow dump. However, the action list is still incorrect and causes the following error if the user wants to look at the datapath flows:
# ovs-dpctl add-dp system@ovs-system
# ovs-dpctl add-flow "<flow match>" "clone(ct(commit),0)"
# ovs-dpctl dump-flows
<flow match>, packets:0, bytes:0, used:never,
actions:clone(bad length 4, expected -1 for: action0(01 00 00 00),
ct(commit),0)With the fix:
# ovs-dpctl dump-flows
<flow match>, packets:0, bytes:0, used:never,
actions:clone(ct(commit),0)Additionally fixed an incorrect attribute name in the comment.
--- net/openvswitch/actions.c | 2 +- net/openvswitch/flow_netlink.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-)
net/openvswitch/actions.c +1 -1
@@ -1037,7 +1037,7 @@ static int clone(struct datapath *dp, struct sk_buff *skb,int rem =nla_len (attr);bool dont_clone_flow_key; -/* The first action is always 'OVS_CLONE_ATTR_ARG'. */ +/* The first action is always 'OVS_CLONE_ATTR_EXEC'. */ clone_arg =nla_data (attr); dont_clone_flow_key =nla_get_u32 (clone_arg); actions =nla_next (clone_arg, &rem);
net/openvswitch/flow_netlink.c +3 -1
@@ -3284,7 +3284,9 @@ static int clone_action_to_attr(const struct nlattr *attr,if (!start)return -EMSGSIZE ; - err =ovs_nla_put_actions (nla_data (attr), rem, skb); +/* Skipping the OVS_CLONE_ATTR_EXEC that is always the first attribute. */ + attr =nla_next (nla_data (attr), &rem); + err =ovs_nla_put_actions (attr, rem, skb);if (err)nla_nest_cancel (skb, start);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 436/475 rxrpc: fix a race in rxrpc_exit_net()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 1946014ca3b19be9e485e780e862c375c6f98bad ]
Current code can lead to the following race:
CPU0 CPU1
rxrpc_exit_net()
rxrpc_peer_keepalive_worker()
if (rxnet->live)rxnet->live = false; del_timer_sync(&rxnet->peer_keepalive_timer);
timer_reduce(&rxnet->peer_keepalive_timer, jiffies + delay);
cancel_work_sync(&rxnet->peer_keepalive_work);
rxrpc_exit_net() exits while peer_keepalive_timer is still armed, leading to use-after-free.
syzbot report was:
ODEBUG: free active (active state 0) object type: timer_list hint: rxrpc_peer_keepalive_timeout+0x0/0xb0
WARNING: CPU: 0 PID: 3660 at lib/debugobjects.c:505 debug_print_object+0x16e/0x250 lib/debugobjects.c:505 Modules linked in: CPU: 0 PID: 3660 Comm: kworker/u4:6 Not tainted 5.17.0-syzkaller-13993-g88e6c0207623 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: netns cleanup_net RIP: 0010:debug_print_object+0x16e/0x250 lib/debugobjects.c:505 Code: ff df 48 89 fa 48 c1 ea 03 80 3c 02 00 0f 85 af 00 00 00 48 8b 14 dd 00 1c 26 8a 4c 89 ee 48 c7 c7 00 10 26 8a e8 b1 e7 28 05 <0f> 0b 83 05 15 eb c5 09 01 48 83 c4 18 5b 5d 41 5c 41 5d 41 5e c3 RSP: 0018:ffffc9000353fb00 EFLAGS: 00010082 RAX: 0000000000000000 RBX: 0000000000000003 RCX: 0000000000000000 RDX: ffff888029196140 RSI: ffffffff815efad8 RDI: fffff520006a7f52 RBP: 0000000000000001 R08: 0000000000000000 R09: 0000000000000000 R10: ffffffff815ea4ae R11: 0000000000000000 R12: ffffffff89ce23e0 R13: ffffffff8a2614e0 R14: ffffffff816628c0 R15: dffffc0000000000 FS: 0000000000000000(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fe1f2908924 CR3: 0000000043720000 CR4: 00000000003506f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> __debug_check_no_obj_freed lib/debugobjects.c:992 [inline] debug_check_no_obj_freed+0x301/0x420 lib/debugobjects.c:1023 kfree+0xd6/0x310 mm/slab.c:3809 ops_free_list.part.0+0x119/0x370 net/core/net_namespace.c:176 ops_free_list net/core/net_namespace.c:174 [inline] cleanup_net+0x591/0xb00 net/core/net_namespace.c:598 process_one_work+0x996/0x1610 kernel/workqueue.c:2289 worker_thread+0x665/0x1080 kernel/workqueue.c:2436 kthread+0x2e9/0x3a0 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298 </TASK>
--- net/rxrpc/net_ns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/rxrpc/net_ns.c +1 -1
@@ -116,8 +116,8 @@ static __net_exit void rxrpc_exit_net(struct net *net)struct rxrpc_net *rxnet =rxrpc_net (net); rxnet->live = false; -del_timer_sync (&rxnet->peer_keepalive_timer);cancel_work_sync (&rxnet->peer_keepalive_work); +del_timer_sync (&rxnet->peer_keepalive_timer);rxrpc_destroy_all_calls (rxnet);rxrpc_destroy_all_connections (rxnet);rxrpc_destroy_all_peers (rxnet);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 437/475 qede: confirm skb is allocated before using
In reply to Greg Kroah-HartmanFrom: Jamie Bainbridge <[email protected]>
[ Upstream commit 4e910dbe36508654a896d5735b318c0b88172570 ]
qede_build_skb() assumes build_skb() always works and goes straight to skb_reserve(). However, build_skb() can fail under memory pressure. This results in a kernel panic because the skb to reserve is NULL.
Add a check in case build_skb() failed to allocate and return NULL.
The NULL return is handled correctly in callers to qede_build_skb().
--- drivers/net/ethernet/qlogic/qede/qede_fp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/qlogic/qede/qede_fp.c +3 -0
@@ -723,6 +723,9 @@ qede_build_skb(struct qede_rx_queue *rxq, buf =page_address (bd->data) + bd->page_offset; skb =build_skb (buf, rxq->rx_buf_seg_size); +if (unlikely (!skb)) +return NULL ; +skb_reserve (skb, pad);skb_put (skb, len);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 438/475 spi: bcm-qspi: fix MSPI only access with bcm_qspi_exec_mem_op()
In reply to Greg Kroah-HartmanFrom: Kamal Dasu <[email protected]>
[ Upstream commit 2c7d1b281286c46049cd22b43435cecba560edde ]
This fixes case where MSPI controller is used to access spi-nor flash and BSPI block is not present.
--- drivers/spi/spi-bcm-qspi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/spi-bcm-qspi.c +2 -2
@@ -960,7 +960,7 @@ static int bcm_qspi_exec_mem_op(struct spi_mem *mem, addr = op->addr.val; len = op->data.nbytes; -if (bcm_qspi_bspi_ver_three (qspi) == true) { +if (has_bspi (qspi) &&bcm_qspi_bspi_ver_three (qspi) == true) {/* * The address coming into this function is a raw flash offset. * But for BSPI <= V3, we need to convert it to a remapped BSPI
@@ -979,7 +979,7 @@ static int bcm_qspi_exec_mem_op(struct spi_mem *mem, len < 4) mspi_read = true; -if (mspi_read) +if (!has_bspi (qspi) || mspi_read)return bcm_qspi_mspi_exec_mem_op (spi, op); ret =bcm_qspi_bspi_set_mode (qspi, op,0 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 439/475 bpf: Support dual-stack sockets in bpf_tcp_check_syncookie
In reply to Greg Kroah-HartmanFrom: Maxim Mikityanskiy <[email protected]>
[ Upstream commit 2e8702cc0cfa1080f29fd64003c00a3e24ac38de ]
bpf_tcp_gen_syncookie looks at the IP version in the IP header and validates the address family of the socket. It supports IPv4 packets in AF_INET6 dual-stack sockets.
On the other hand, bpf_tcp_check_syncookie looks only at the address family of the socket, ignoring the real IP version in headers, and validates only the packet size. This implementation has some drawbacks:
1. Packets are not validated properly, allowing a BPF program to trick bpf_tcp_check_syncookie into handling an IPv6 packet on an IPv4 socket.
2. Dual-stack sockets fail the checks on IPv4 packets. IPv4 clients end up receiving a SYNACK with the cookie, but the following ACK gets dropped.
This patch fixes these issues by changing the checks in bpf_tcp_check_syncookie to match the ones in bpf_tcp_gen_syncookie. IP version from the header is taken into account, and it is validated properly with address family.
--- net/core/filter.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
net/core/filter.c +13 -4
@@ -5824,24 +5824,33 @@ BPF_CALL_5(bpf_tcp_check_syncookie, struct sock *, sk, void *, iph, u32, iph_lenif (!th->ack || th->rst || th->syn)return -ENOENT ; +if (unlikely (iph_len <sizeof (struct iphdr ))) +return -EINVAL ; +if (tcp_synq_no_recent_overflow (sk))return -ENOENT ; cookie =ntohl (th->ack_seq) -1 ; -switch (sk->sk_family) { -case AF_INET : -if (unlikely (iph_len <sizeof (struct iphdr ))) +/* Both struct iphdr and struct ipv6hdr have the version field at the +* same offset so we can cast to the shorter header (struct iphdr). +*/ +switch (((struct iphdr *)iph)->version) { +case 4 : +if (sk->sk_family ==AF_INET6 &&ipv6_only_sock (sk))return -EINVAL ; ret =__cookie_v4_check ((struct iphdr *)iph, th, cookie);break ;#if IS_BUILTIN (CONFIG_IPV6 ) -case AF_INET6 : +case 6 :if (unlikely (iph_len <sizeof (struct ipv6hdr )))return -EINVAL ; +if (sk->sk_family !=AF_INET6 ) +return -EINVAL ; + ret =__cookie_v6_check ((struct ipv6hdr *)iph, th, cookie);break ;#endif /* CONFIG_IPV6 */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 440/475 drbd: Fix five use after free bugs in get_initial_state
In reply to Greg Kroah-HartmanFrom: Lv Yunlong <[email protected]>
[ Upstream commit aadb22ba2f656581b2f733deb3a467c48cc618f6 ]
In get_initial_state, it calls notify_initial_state_done(skb,..) if cb->args[5]==1. If genlmsg_put() failed in notify_initial_state_done(), the skb will be freed by nlmsg_free(skb).
Then get_initial_state will goto out and the freed skb will be used by return value skb->len, which is a uaf bug.
What's worse, the same problem goes even further: skb can also be freed in the notify_*_state_change -> notify_*_state calls below. Thus 4 additional uaf bugs happened.
My patch lets the problem callee functions: notify_initial_state_done and notify_*_state_change return an error code if errors happen. So that the error codes could be propagated and the uaf bugs can be avoid.
v2 reports a compilation warning. This v3 fixed this warning and built successfully in my local environment with no additional warnings.
v2: https://lore.kernel.org/patchwork/patch/1435218/
--- drivers/block/drbd/drbd_int.h | 8 ++--- drivers/block/drbd/drbd_nl.c | 41 ++++++++++++++++---------- drivers/block/drbd/drbd_state.c | 18 +++++------ drivers/block/drbd/drbd_state_change.h | 8 ++--- 4 files changed, 42 insertions(+), 33 deletions(-)
drivers/block/drbd/drbd_int.h +4 -4
@@ -1673,22 +1673,22 @@ struct sib_info { };void drbd_bcast_event (struct drbd_device *device,const struct sib_info *sib); -extern void notify_resource_state (struct sk_buff *, +extern int notify_resource_state (struct sk_buff *,unsigned int ,struct drbd_resource *,struct resource_info *,enum drbd_notification_type ); -extern void notify_device_state (struct sk_buff *, +extern int notify_device_state (struct sk_buff *,unsigned int ,struct drbd_device *,struct device_info *,enum drbd_notification_type ); -extern void notify_connection_state (struct sk_buff *, +extern int notify_connection_state (struct sk_buff *,unsigned int ,struct drbd_connection *,struct connection_info *,enum drbd_notification_type ); -extern void notify_peer_device_state(struct sk_buff *, +extern int notify_peer_device_state(struct sk_buff *, unsigned int, struct drbd_peer_device *, struct peer_device_info *,
drivers/block/drbd/drbd_nl.c +25 -16
156 lines not on this page · raw message
drivers/block/drbd/drbd_state.c +9 -9
@@ -1537,7 +1537,7 @@ int drbd_bitmap_io_from_worker(struct drbd_device *device,return rv; } -void notify_resource_state_change (struct sk_buff *skb, +int notify_resource_state_change (struct sk_buff *skb,unsigned int seq,struct drbd_resource_state_change *resource_state_change,enum drbd_notification_type type)
@@ -1550,10 +1550,10 @@ void notify_resource_state_change(struct sk_buff *skb, .res_susp_fen = resource_state_change->susp_fen[NEW], }; -notify_resource_state (skb, seq, resource, &resource_info, type); +return notify_resource_state (skb, seq, resource, &resource_info, type); } -void notify_connection_state_change (struct sk_buff *skb, +int notify_connection_state_change (struct sk_buff *skb,unsigned int seq,struct drbd_connection_state_change *connection_state_change,enum drbd_notification_type type)
@@ -1564,10 +1564,10 @@ void notify_connection_state_change(struct sk_buff *skb, .conn_role = connection_state_change->peer_role[NEW], }; -notify_connection_state (skb, seq, connection, &connection_info, type); +return notify_connection_state (skb, seq, connection, &connection_info, type); } -void notify_device_state_change (struct sk_buff *skb, +int notify_device_state_change (struct sk_buff *skb,unsigned int seq,struct drbd_device_state_change *device_state_change,enum drbd_notification_type type)
@@ -1577,10 +1577,10 @@ void notify_device_state_change(struct sk_buff *skb, .dev_disk_state = device_state_change->disk_state[NEW], }; -notify_device_state (skb, seq, device, &device_info, type); +return notify_device_state (skb, seq, device, &device_info, type); } -void notify_peer_device_state_change (struct sk_buff *skb, +int notify_peer_device_state_change (struct sk_buff *skb,unsigned int seq,struct drbd_peer_device_state_change *p,enum drbd_notification_type type)
@@ -1594,7 +1594,7 @@ void notify_peer_device_state_change(struct sk_buff *skb, .peer_resync_susp_dependency = p->resync_susp_dependency[NEW], }; -notify_peer_device_state (skb, seq, peer_device, &peer_device_info, type); +return notify_peer_device_state (skb, seq, peer_device, &peer_device_info, type); }static void broadcast_state_change (struct drbd_state_change *state_change)
@@ -1602,7 +1602,7 @@ static void broadcast_state_change(struct drbd_state_change *state_change)struct drbd_resource_state_change *resource_state_change = &state_change->resource[0 ];bool resource_state_has_changed;unsigned int n_device, n_connection, n_peer_device, n_peer_devices; -void (*last_func)(struct sk_buff *,unsigned int ,void *, +int (*last_func)(struct sk_buff *,unsigned int ,void *,enum drbd_notification_type ) =NULL ;void *uninitialized_var (last_arg );
drivers/block/drbd/drbd_state_change.h +4 -4
@@ -44,19 +44,19 @@ extern struct drbd_state_change *remember_old_state(struct drbd_resource *, gfp_extern void copy_old_to_new_state_change (struct drbd_state_change *);extern void forget_state_change (struct drbd_state_change *); -extern void notify_resource_state_change (struct sk_buff *, +extern int notify_resource_state_change (struct sk_buff *,unsigned int ,struct drbd_resource_state_change *,enum drbd_notification_type type); -extern void notify_connection_state_change (struct sk_buff *, +extern int notify_connection_state_change (struct sk_buff *,unsigned int ,struct drbd_connection_state_change *,enum drbd_notification_type type); -extern void notify_device_state_change (struct sk_buff *, +extern int notify_device_state_change (struct sk_buff *,unsigned int ,struct drbd_device_state_change *,enum drbd_notification_type type); -extern void notify_peer_device_state_change (struct sk_buff *, +extern int notify_peer_device_state_change (struct sk_buff *,unsigned int ,struct drbd_peer_device_state_change *,enum drbd_notification_type type);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 441/475 SUNRPC: Handle ENOMEM in call_transmit_status()
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit d3c15033b240767d0287f1c4a529cbbe2d5ded8a ]
Both call_transmit() and call_bc_transmit() can now return ENOMEM, so let's make sure that we handle the errors gracefully.
--- net/sunrpc/clnt.c | 2 ++ 1 file changed, 2 insertions(+)
net/sunrpc/clnt.c +2 -0
@@ -2223,6 +2223,7 @@ call_transmit_status(struct rpc_task *task)* socket just returned a connection error, * then hold onto the transport lock. */ +case -ENOMEM :case -ENOBUFS :rpc_delay (task,HZ >>2 );/* fall through */
@@ -2308,6 +2309,7 @@ call_bc_transmit_status(struct rpc_task *task)case -ENOTCONN :case -EPIPE :break ; +case -ENOMEM :case -ENOBUFS :rpc_delay (task,HZ >>2 );/* fall through */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 442/475 SUNRPC: Handle low memory situations in call_status()
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit 9d82819d5b065348ce623f196bf601028e22ed00 ]
We need to handle ENFILE, ENOBUFS, and ENOMEM, because xprt_wake_pending_tasks() can be called with any one of these due to socket creation failures.
--- net/sunrpc/clnt.c | 5 +++++ 1 file changed, 5 insertions(+)
net/sunrpc/clnt.c +5 -0
@@ -2394,6 +2394,11 @@ call_status(struct rpc_task *task)case -EPIPE :case -EAGAIN :break ; +case -ENFILE : +case -ENOBUFS : +case -ENOMEM : +rpc_delay (task,HZ >>2 ); +break ;case -EIO :/* shutdown or soft timeout */ goto out_exit;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 443/475 perf tools: Fix perfs libperf_print callback
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
[ Upstream commit aeee9dc53ce405d2161f9915f553114e94e5b677 ]
eprintf() does not expect va_list as the type of the 4th parameter.
Use veprintf() because it does.
--- tools/perf/perf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/perf.c +1 -1
@@ -433,7 +433,7 @@ void pthread__unblock_sigwinch(void)static int libperf_print (enum libperf_print_level level,const char *fmt,va_list ap) { -return eprintf (level, verbose, fmt, ap); +return veprintf (level, verbose, fmt, ap); }int main (int argc,const char **argv)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 444/475 perf session: Remap buf if there is no space for event
In reply to Greg Kroah-HartmanFrom: Denis Nikitin <[email protected]>
[ Upstream commit bc21e74d4775f883ae1f542c1f1dc7205b15d925 ]
If a perf event doesn't fit into remaining buffer space return NULL to remap buf and fetch the event again.
Keep the logic to error out on inadequate input from fuzzing.
This fixes perf failing on ChromeOS (with 32b userspace):
$ perf report -v -i perf.data ... prefetch_event: head=0x1fffff8 event->header_size=0x30, mmap_size=0x2000000: fuzzed or compressed perf.data? Error: failed to process sample
--- tools/perf/util/session.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
tools/perf/util/session.c +12 -3
@@ -1960,6 +1960,7 @@ prefetch_event(char *buf, u64 head, size_t mmap_size, bool needs_swap, union perf_event *error) { union perf_event *event; +u16 event_size;/* * Ensure we have enough space remaining to read
@@ -1972,15 +1973,23 @@ prefetch_event(char *buf, u64 head, size_t mmap_size,if (needs_swap)perf_event_header__bswap (&event->header); -if (head + event->header.size <= mmap_size) + event_size = event->header.size; +if (head + event_size <= mmap_size)return event;/* We're not fetching the event so swap back again */ if (needs_swap)perf_event_header__bswap (&event->header); -pr_debug ("%s: head=%#" PRIx64" event->header_size=%#x, mmap_size=%#zx:" -" fuzzed or compressed perf.data?\n" ,__func__, head, event->header.size, mmap_size); +/* Check if the event fits into the next mmapped buf. */ +if (event_size <= mmap_size - head % page_size) { +/* Remap buf and fetch again. */ +return NULL ; + } + +/* Invalid input. Event size should never exceed mmap_size. */ +pr_debug ("%s: head=%#" PRIx64" event->header.size=%#x, mmap_size=%#zx:" +" fuzzed or compressed perf.data?\n" , __func__, head, event_size, mmap_size);return error; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 445/475 Revert "mmc: sdhci-xenon: fix annoying 1.8V regulator warning"
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
commit 7e2646ed47542123168d43916b84b954532e5386 upstream.
This reverts commit bb32e1987bc55ce1db400faf47d85891da3c9b9f.
Commit 1a3ed0dc3594 ("mmc: sdhci-xenon: fix 1.8v regulator stabilization") contains proper fix for the issue described in commit bb32e1987bc5 ("mmc:
sdhci-xenon: fix annoying 1.8V regulator warning").
--- drivers/mmc/host/sdhci-xenon.c | 10 ---------- 1 file changed, 10 deletions(-)
drivers/mmc/host/sdhci-xenon.c +0 -10
@@ -240,16 +240,6 @@ static void xenon_voltage_switch(struct {/* Wait for 5ms after set 1.8V signal enable bit */ usleep_range (5000 ,5500 ); - -/* -* For some reason the controller's Host Control2 register reports -* the bit representing 1.8V signaling as 0 when read after it was -* written as 1. Subsequent read reports 1. -* -* Since this may cause some issues, do an empty read of the Host -* Control2 register here to circumvent this. -*/ -sdhci_readw (host,SDHCI_HOST_CONTROL2 ); }static const struct sdhci_ops sdhci_xenon_ops = {
Greg Kroah-Hartman
maintainerPATCH 446/475 mmc: renesas_sdhi: dont overwrite TAP settings when HS400 tuning is complete
In reply to Greg Kroah-HartmanFrom: Wolfram Sang <[email protected]>
commit 03e59b1e2f56245163b14c69e0a830c24b1a3a47 upstream.
When HS400 tuning is complete and HS400 is going to be activated, we have to keep the current number of TAPs and should not overwrite them with a hardcoded value. This was probably a copy&paste mistake when upporting HS400 support from the BSP.
--- drivers/mmc/host/renesas_sdhi_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/renesas_sdhi_core.c +2 -2
@@ -349,10 +349,10 @@ static void renesas_sdhi_hs400_complete( SH_MOBILE_SDHI_SCC_TMPPORT2_HS400OSEL) | sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_TMPPORT2)); -/* Set the sampling clock selection range of HS400 mode */ sd_scc_write32 (host, priv,SH_MOBILE_SDHI_SCC_DTCNTL ,SH_MOBILE_SDHI_SCC_DTCNTL_TAPEN | -0x4 <<SH_MOBILE_SDHI_SCC_DTCNTL_TAPNUM_SHIFT ); +sd_scc_read32 (host, priv, +SH_MOBILE_SDHI_SCC_DTCNTL ));if (host->pdata->flags &TMIO_MMC_HAVE_4TAP_HS400 )
Greg Kroah-Hartman
maintainerPATCH 447/475 lz4: fix LZ4_decompress_safe_partial read out of bound
In reply to Greg Kroah-HartmanFrom: Guo Xuenan <[email protected]>
commit eafc0a02391b7b36617b36c97c4b5d6832cf5e24 upstream.
When partialDecoding, it is EOF if we've either filled the output buffer or can't proceed with reading an offset for following match.
In some extreme corner cases when compressed data is suitably corrupted, UAF will occur. As reported by KASAN [1], LZ4_decompress_safe_partial may lead to read out of bound problem during decoding. lz4 upstream has fixed it [2] and this issue has been disscussed here [3] before.
current decompression routine was ported from lz4 v1.8.3, bumping lib/lz4 to v1.9.+ is certainly a huge work to be done later, so, we'd better fix it first.
[1] https://lore.kernel.org/all/[email protected]/
[2] https://github.com/lz4/lz4/commit/c5d6f8a8be3927c0bec91bcc58667a6cfad244ad#
[3] https://lore.kernel.org/all/[email protected]/
--- lib/lz4/lz4_decompress.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
lib/lz4/lz4_decompress.c +6 -2
@@ -268,8 +268,12 @@ static FORCE_INLINE int LZ4_decompress_g ip += length; op += length; -/* Necessarily EOF, due to parsing restrictions */ -if (!partialDecoding || (cpy == oend)) +/* Necessarily EOF when !partialDecoding. +* When partialDecoding, it is EOF if we've either +* filled the output buffer or +* can't proceed with reading an offset for following match. +*/ +if (!partialDecoding || (cpy == oend) || (ip >= (iend -2 )))break ; }else {/* may overwrite up to WILDCOPYLENGTH beyond cpy */
Greg Kroah-Hartman
maintainerPATCH 448/475 mmmremap.c: avoid pointless invalidate_range_start/end on mremap(old_size=0)
In reply to Greg Kroah-HartmanFrom: Paolo Bonzini <[email protected]>
commit 01e67e04c28170c47700c2c226d732bbfedb1ad0 upstream.
If an mremap() syscall with old_size=0 ends up in move_page_tables(), it will call invalidate_range_start()/invalidate_range_end() unnecessarily, i.e. with an empty range.
This causes a WARN in KVM's mmu_notifier. In the past, empty ranges have been diagnosed to be off-by-one bugs, hence the WARNing. Given the low (so far) number of unique reports, the benefits of detecting more buggy callers seem to outweigh the cost of having to fix cases such as this one, where userspace is doing something silly. In this particular case, an early return from move_page_tables() is enough to fix the issue.
--- mm/mremap.c | 3 +++ 1 file changed, 3 insertions(+)
mm/mremap.c +3 -0
@@ -246,6 +246,9 @@ unsigned long move_page_tables(struct vmstruct mmu_notifier_range range;pmd_t *old_pmd, *new_pmd; +if (!len) +return 0 ; + old_end = old_addr + len;flush_cache_range (vma, old_addr, old_end);
Greg Kroah-Hartman
maintainerPATCH 449/475 mm/mempolicy: fix mpol_new leak in shared_policy_replace
In reply to Greg Kroah-HartmanFrom: Miaohe Lin <[email protected]>
commit 4ad099559b00ac01c3726e5c95dc3108ef47d03e upstream.
If mpol_new is allocated but not used in restart loop, mpol_new will be freed via mpol_put before returning to the caller. But refcnt is not initialized yet, so mpol_put could not do the right things and might leak the unused mpol_new. This would happen if mempolicy was updated on the shared shmem file while the sp->lock has been dropped during the memory allocation.
This issue could be triggered easily with the below code snippet if there are many processes doing the below work at the same time:
shmid = shmget((key_t)5566, 1024 * PAGE_SIZE, 0666|IPC_CREAT);
shm = shmat(shmid, 0, 0);
loop many times {
mbind(shm, 1024 * PAGE_SIZE, MPOL_LOCAL, mask, maxnode, 0);
mbind(shm + 128 * PAGE_SIZE, 128 * PAGE_SIZE, MPOL_DEFAULT, mask,
maxnode, 0);
}--- mm/mempolicy.c | 1 + 1 file changed, 1 insertion(+)
mm/mempolicy.c +1 -0
@@ -2559,6 +2559,7 @@ alloc_new: mpol_new =kmem_cache_alloc (policy_cache,GFP_KERNEL );if (!mpol_new) goto err_out; +atomic_set (&mpol_new->refcnt,1 ); goto restart; }
Greg Kroah-Hartman
maintainerPATCH 450/475 x86/pm: Save the MSR validity status at context setup
In reply to Greg Kroah-HartmanFrom: Pawan Gupta <[email protected]>
commit 73924ec4d560257004d5b5116b22a3647661e364 upstream.
The mechanism to save/restore MSRs during S3 suspend/resume checks for the MSR validity during suspend, and only restores the MSR if its a valid MSR. This is not optimal, as an invalid MSR will unnecessarily throw an exception for every suspend cycle. The more invalid MSRs, higher the impact will be.
Check and save the MSR validity at setup. This ensures that only valid MSRs that are guaranteed to not throw an exception will be attempted during suspend.
--- arch/x86/power/cpu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/x86/power/cpu.c +5 -2
@@ -40,7 +40,8 @@ static void msr_save_context(struct savestruct saved_msr *end = msr + ctxt->saved_msrs.num;while (msr < end) { - msr->valid = !rdmsrl_safe (msr->info.msr_no, &msr->info.reg.q); +if (msr->valid) +rdmsrl (msr->info.msr_no, msr->info.reg.q); msr++; } }
@@ -421,8 +422,10 @@ static int msr_build_context(const u32 * }for (i = saved_msrs->num, j =0 ; i < total_num; i++, j++) { +u64 dummy; + msr_array[i].info.msr_no = msr_id[j]; - msr_array[i].valid = false; + msr_array[i].valid = !rdmsrl_safe (msr_id[j], &dummy); msr_array[i].info.reg.q =0 ; } saved_msrs->num = total_num;
Greg Kroah-Hartman
maintainerPATCH 451/475 x86/speculation: Restore speculation related MSRs during S3 resume
In reply to Greg Kroah-HartmanFrom: Pawan Gupta <[email protected]>
commit e2a1256b17b16f9b9adf1b6fea56819e7b68e463 upstream.
After resuming from suspend-to-RAM, the MSRs that control CPU's speculative execution behavior are not being restored on the boot CPU.
These MSRs are used to mitigate speculative execution vulnerabilities. Not restoring them correctly may leave the CPU vulnerable. Secondary CPU's MSRs are correctly being restored at S3 resume by identify_secondary_cpu().
During S3 resume, restore these MSRs for boot CPU when restoring its processor state.
--- arch/x86/power/cpu.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/x86/power/cpu.c +14 -0
@@ -512,10 +512,24 @@ static int pm_cpu_check(const struct x86return ret; } +static void pm_save_spec_msr (void ) +{ +u32 spec_msr_id[] = { +MSR_IA32_SPEC_CTRL , +MSR_IA32_TSX_CTRL , +MSR_TSX_FORCE_ABORT , +MSR_IA32_MCU_OPT_CTRL , +MSR_AMD64_LS_CFG , + }; + +msr_build_context (spec_msr_id,ARRAY_SIZE (spec_msr_id)); +} +static int pm_check_save_msr (void ) {dmi_check_system (msr_save_dmi_table);pm_cpu_check (msr_save_cpu_table); +pm_save_spec_msr ();return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 452/475 btrfs: fix qgroup reserve overflow the qgroup limit
In reply to Greg Kroah-HartmanFrom: Ethan Lien <[email protected]>
commit b642b52d0b50f4d398cb4293f64992d0eed2e2ce upstream.
We use extent_changeset->bytes_changed in qgroup_reserve_data() to record how many bytes we set for EXTENT_QGROUP_RESERVED state. Currently the bytes_changed is set as "unsigned int", and it will overflow if we try to fallocate a range larger than 4GiB. The result is we reserve less bytes and eventually break the qgroup limit.
Unlike regular buffered/direct write, which we use one changeset for each ordered extent, which can never be larger than 256M. For fallocate, we use one changeset for the whole range, thus it no longer respects the 256M per extent limit, and caused the problem.
The following example test script reproduces the problem:
$ cat qgroup-overflow.sh #!/bin/bash
DEV=/dev/sdj
MNT=/mnt/sdj
mkfs.btrfs -f $DEV
mount $DEV $MNT
# Set qgroup limit to 2GiB.
btrfs quota enable $MNT
btrfs qgroup limit 2G $MNT
# Try to fallocate a 3GiB file. This should fail. echo
echo "Try to fallocate a 3GiB file..." fallocate -l 3G $MNT/3G.file
# Try to fallocate a 5GiB file.
echo
echo "Try to fallocate a 5GiB file..."
fallocate -l 5G $MNT/5G.file
# See we break the qgroup limit.
echo
sync
btrfs qgroup show -r $MNT
umount $MNT
When running the test:
$ ./qgroup-overflow.sh (...)
Try to fallocate a 3GiB file...
fallocate: fallocate failed: Disk quota exceeded
Try to fallocate a 5GiB file...
qgroupid rfer excl max_rfer
-------- ---- ---- --------
0/5 5.00GiB 5.00GiB 2.00GiB
Since we have no control of how bytes_changed is used, it's better to set it to u64.
--- fs/btrfs/extent_io.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/extent_io.h +1 -1
@@ -202,7 +202,7 @@ struct extent_buffer {*/ struct extent_changeset {/* How many bytes are set/cleared in this operation */ -unsigned int bytes_changed; +u64 bytes_changed;/* Changed ranges */ struct ulist range_changed;
Greg Kroah-Hartman
maintainerPATCH 453/475 arm64: patch_text: Fixup last cpu should be master
In reply to Greg Kroah-HartmanFrom: Guo Ren <[email protected]>
commit 31a099dbd91e69fcab55eef4be15ed7a8c984918 upstream.
These patch_text implementations are using stop_machine_cpuslocked infrastructure with atomic cpu_count. The original idea: When the master CPU patch_text, the others should wait for it. But current implementation is using the first CPU as master, which couldn't guarantee the remaining CPUs are waiting. This patch changes the last CPU as the master to solve the potential risk.
--- arch/arm64/kernel/insn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kernel/insn.c +2 -2
@@ -207,8 +207,8 @@ static int __kprobes aarch64_insn_patch_int i, ret =0 ;struct aarch64_insn_patch *pp = arg; -/* The first CPU becomes master */ -if (atomic_inc_return (&pp->cpu_count) ==1 ) { +/* The last CPU becomes master */ +if (atomic_inc_return (&pp->cpu_count) ==num_online_cpus ()) {for (i =0 ; ret ==0 && i < pp->insn_cnt; i++) ret =aarch64_insn_patch_text_nosync (pp->text_addrs[i], pp->new_insns[i]);
Greg Kroah-Hartman
maintainerPATCH 454/475 ata: sata_dwc_460ex: Fix crash due to OOB write
In reply to Greg Kroah-HartmanFrom: Christian Lamparter <[email protected]>
commit 7aa8104a554713b685db729e66511b93d989dd6a upstream.
the driver uses libata's "tag" values from in various arrays. Since the mentioned patch bumped the ATA_TAG_INTERNAL to 32, the value of the SATA_DWC_QCMD_MAX needs to account for that.
Otherwise ATA_TAG_INTERNAL usage cause similar crashes like this as reported by Tice Rex on the OpenWrt Forum and reproduced (with symbols) here:
| BUG: Kernel NULL pointer dereference at 0x00000000 | Faulting instruction address: 0xc03ed4b8 | Oops: Kernel access of bad area, sig: 11 [#1] | BE PAGE_SIZE=4K PowerPC 44x Platform | CPU: 0 PID: 362 Comm: scsi_eh_1 Not tainted 5.4.163 #0 | NIP: c03ed4b8 LR: c03d27e8 CTR: c03ed36c | REGS: cfa59950 TRAP: 0300 Not tainted (5.4.163) | MSR: 00021000 <CE,ME> CR: 42000222 XER: 00000000 | DEAR: 00000000 ESR: 00000000 | GPR00: c03d27e8 cfa59a08 cfa55fe0 00000000 0fa46bc0 [...] | [..] | NIP [c03ed4b8] sata_dwc_qc_issue+0x14c/0x254 | LR [c03d27e8] ata_qc_issue+0x1c8/0x2dc | Call Trace: | [cfa59a08] [c003f4e0] __cancel_work_timer+0x124/0x194 (unreliable) | [cfa59a78] [c03d27e8] ata_qc_issue+0x1c8/0x2dc | [cfa59a98] [c03d2b3c] ata_exec_internal_sg+0x240/0x524 | [cfa59b08] [c03d2e98] ata_exec_internal+0x78/0xe0 | [cfa59b58] [c03d30fc] ata_read_log_page.part.38+0x1dc/0x204 | [cfa59bc8] [c03d324c] ata_identify_page_supported+0x68/0x130 | [...]
This is because sata_dwc_dma_xfer_complete() NULLs the dma_pending's next neighbour "chan" (a *dma_chan struct) in this '32' case right here (line ~735):
Quoted 1 line
hsdevp->dma_pending[tag] =
SATA_DWC_DMA_PENDING_NONE;
Then the next time, a dma gets issued; dma_dwc_xfer_setup() passes the NULL'd hsdevp->chan to the dmaengine_slave_config() which then causes the crash.
With this patch, SATA_DWC_QCMD_MAX is now set to ATA_MAX_QUEUE + 1. This avoids the OOB. But please note, there was a worthwhile discussion on what ATA_TAG_INTERNAL and ATA_MAX_QUEUE is. And why there should not be a "fake" 33 command-long queue size.
Ideally, the dw driver should account for the ATA_TAG_INTERNAL. In Damien Le Moal's words: "... having looked at the driver, it is a bigger change than just faking a 33rd "tag" that is in fact not a command tag at all."
--- drivers/ata/sata_dwc_460ex.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/ata/sata_dwc_460ex.c +5 -1
@@ -145,7 +145,11 @@ struct sata_dwc_device {#endif }; -#define SATA_DWC_QCMD_MAX 32 +/* +* Allow one extra special slot for commands and DMA management +* to account for libata internal commands. +*/ +#define SATA_DWC_QCMD_MAX (ATA_MAX_QUEUE + 1)struct sata_dwc_device_port {struct sata_dwc_device *hsdev;
Greg Kroah-Hartman
maintainerPATCH 455/475 perf: qcom_l2_pmu: fix an incorrect NULL check on list iterator
In reply to Greg Kroah-HartmanFrom: Xiaomeng Tong <[email protected]>
commit 2012a9e279013933885983cbe0a5fe828052563b upstream.
The bug is here:
return cluster;
The list iterator value 'cluster' will *always* be set and non-NULL by list_for_each_entry(), so it is incorrect to assume that the iterator value will be NULL if the list is empty or no element is found.
To fix the bug, return 'cluster' when found, otherwise return NULL.
--- drivers/perf/qcom_l2_pmu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/perf/qcom_l2_pmu.c +3 -3
@@ -781,7 +781,7 @@ static struct cluster_pmu *l2_cache_asso {u64 mpidr;int cpu_cluster_id; -struct cluster_pmu *cluster =NULL ; +struct cluster_pmu *cluster;/* * This assumes that the cluster_id is in MPIDR[aff1] for
@@ -803,10 +803,10 @@ static struct cluster_pmu *l2_cache_asso cluster->cluster_id);cpumask_set_cpu (cpu, &cluster->cluster_cpus); *per_cpu_ptr (l2cache_pmu->pmu_cluster, cpu) = cluster; -break ; +return cluster; } -return cluster; +return NULL ; }static int l2cache_pmu_online_cpu (unsigned int cpu,struct hlist_node *node)
Greg Kroah-Hartman
maintainerPATCH 456/475 irqchip/gic-v3: Fix GICR_CTLR.RWP polling
In reply to Greg Kroah-HartmanFrom: Marc Zyngier <[email protected]>
commit 0df6664531a12cdd8fc873f0cac0dcb40243d3e9 upstream.
It turns out that our polling of RWP is totally wrong when checking for it in the redistributors, as we test the *distributor* bit index, whereas it is a different bit number in the RDs... Oopsie boo.
This is embarassing. Not only because it is wrong, but also because it took *8 years* to notice the blunder...
Just fix the damn thing.
--- drivers/irqchip/irq-gic-v3.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/irqchip/irq-gic-v3.c +4 -4
@@ -162,11 +162,11 @@ static inline void __iomem *gic_dist_bas } } -static void gic_do_wait_for_rwp (void __iomem *base) +static void gic_do_wait_for_rwp (void __iomem *base,u32 bit) {u32 count =1000000 ;/* 1s! */ -while (readl_relaxed (base +GICD_CTLR ) &GICD_CTLR_RWP ) { +while (readl_relaxed (base +GICD_CTLR ) & bit) { count--;if (!count) {pr_err_ratelimited ("RWP timeout, gone fishing\n" );
@@ -180,13 +180,13 @@ static void gic_do_wait_for_rwp(void __i/* Wait for completion of a distributor change */ static void gic_dist_wait_for_rwp (void ) { -gic_do_wait_for_rwp (gic_data.dist_base); +gic_do_wait_for_rwp (gic_data.dist_base,GICD_CTLR_RWP ); }/* Wait for completion of a redistributor change */ static void gic_redist_wait_for_rwp (void ) { -gic_do_wait_for_rwp (gic_data_rdist_rd_base ()); +gic_do_wait_for_rwp (gic_data_rdist_rd_base (),GICR_CTLR_RWP ); }#ifdef CONFIG_ARM64
Greg Kroah-Hartman
maintainerPATCH 457/475 tools build: Filter out options and warnings not supported by clang
In reply to Greg Kroah-HartmanFrom: Arnaldo Carvalho de Melo <[email protected]>
commit 41caff459a5b956b3e23ba9ca759dd0629ad3dda upstream.
These make the feature check fail when using clang, so remove them just like is done in tools/perf/Makefile.config to build perf itself.
Adding -Wno-compound-token-split-by-macro to tools/perf/Makefile.config when building with clang is also necessary to avoid these warnings turned into errors (-Werror):
CC /tmp/build/perf/util/scripting-engines/trace-event-perl.o
In file included from util/scripting-engines/trace-event-perl.c:35:
In file included from /usr/lib64/perl5/CORE/perl.h:4085:
In file included from /usr/lib64/perl5/CORE/hv.h:659:
In file included from /usr/lib64/perl5/CORE/hv_func.h:34:
In file included from /usr/lib64/perl5/CORE/sbox32_hash.h:4:
/usr/lib64/perl5/CORE/zaphod32_hash.h:150:5: error: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
ZAPHOD32_SCRAMBLE32(state[0],0x9fade23b);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib64/perl5/CORE/zaphod32_hash.h:80:38: note: expanded from macro 'ZAPHOD32_SCRAMBLE32'
#define ZAPHOD32_SCRAMBLE32(v,prime) STMT_START { \
^~~~~~~~~~
/usr/lib64/perl5/CORE/perl.h:737:29: note: expanded from macro 'STMT_START'
# define STMT_START (void)( /* gcc supports "({ STATEMENTS; })" */
^
/usr/lib64/perl5/CORE/zaphod32_hash.h:150:5: note: '{' token is here
ZAPHOD32_SCRAMBLE32(state[0],0x9fade23b);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib64/perl5/CORE/zaphod32_hash.h:80:49: note: expanded from macro 'ZAPHOD32_SCRAMBLE32'
#define ZAPHOD32_SCRAMBLE32(v,prime) STMT_START { \
^
/usr/lib64/perl5/CORE/zaphod32_hash.h:150:5: error: '}' and ')' tokens terminating statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
ZAPHOD32_SCRAMBLE32(state[0],0x9fade23b);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib64/perl5/CORE/zaphod32_hash.h:87:41: note: expanded from macro 'ZAPHOD32_SCRAMBLE32'
v ^= (v>>23); \
^
/usr/lib64/perl5/CORE/zaphod32_hash.h:150:5: note: ')' token is here
ZAPHOD32_SCRAMBLE32(state[0],0x9fade23b);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib64/perl5/CORE/zaphod32_hash.h:88:3: note: expanded from macro 'ZAPHOD32_SCRAMBLE32'
} STMT_END
^~~~~~~~
/usr/lib64/perl5/CORE/perl.h:738:21: note: expanded from macro 'STMT_END'
# define STMT_END )
^Please refer to the discussion on the Link: tag below, where Nathan clarifies the situation:
<quote>
acme> And then get to the problems at the end of this message, which seem acme> similar to the problem described here:
acme>
acme> From Nathan Chancellor <>
acme> Subject [PATCH] mwifiex: Remove unnecessary braces from HostCmd_SET_SEQ_NO_BSS_INFO
acme>
acme> https://lkml.org/lkml/2020/9/1/135
acme>
acme> So perhaps in this case its better to disable that acme> -Werror,-Wcompound-token-split-by-macro when building with clang?
Yes, I think that is probably the best solution. As far as I can tell, at least in this file and context, the warning appears harmless, as the "create a GNU C statement expression from two different macros" is very much intentional, based on the presence of PERL_USE_GCC_BRACE_GROUPS. The warning is fixed in upstream Perl by just avoiding creating GNU C statement expressions using STMT_START and STMT_END:
https://github.com/Perl/perl5/issues/18780
https://github.com/Perl/perl5/pull/18984
If I am reading the source code correctly, an alternative to disabling the warning would be specifying -DPERL_GCC_BRACE_GROUPS_FORBIDDEN but it seems like that might end up impacting more than just this site, according to the issue discussion above.
</quote>
--- tools/build/feature/Makefile | 7 +++++++ tools/perf/Makefile.config | 3 +++ 2 files changed, 10 insertions(+)
tools/build/feature/Makefile +7 -0
@@ -207,6 +207,13 @@ PERL_EMBED_LIBADD = $(call grep-libs,$(P PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null` FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) +ifeq ($(CC_NO_CLANG), 0) + PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS)) + PERL_EMBED_CCOPTS := $(filter-out -flto=auto -ffat-lto-objects, $(PERL_EMBED_CCOPTS)) + PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS)) + FLAGS_PERL_EMBED += -Wno-compound-token-split-by-macro +endif + $(OUTPUT)test-libperl.bin: $(BUILD) $(FLAGS_PERL_EMBED)
tools/perf/Makefile.config +3 -0
@@ -706,6 +706,9 @@ else LDFLAGS += $(PERL_EMBED_LDFLAGS) EXTLIBS += $(PERL_EMBED_LIBADD) CFLAGS += -DHAVE_LIBPERL_SUPPORT + ifeq ($(CC_NO_CLANG), 0) + CFLAGS += -Wno-compound-token-split-by-macro + endif $(call detected,CONFIG_LIBPERL) endif endif
Greg Kroah-Hartman
maintainerPATCH 458/475 tools build: Use $(shell ) instead of `` to get embedded libperls ccopts
In reply to Greg Kroah-HartmanFrom: Arnaldo Carvalho de Melo <[email protected]>
commit 541f695cbcb6932c22638b06e0cbe1d56177e2e9 upstream.
Just like its done for ldopts and for both in tools/perf/Makefile.config.
Using `` to initialize PERL_EMBED_CCOPTS somehow precludes using:
$(filter-out SOMETHING_TO_FILTER,$(PERL_EMBED_CCOPTS))
And we need to do it to allow for building with versions of clang where some gcc options selected by distros are not available.
--- tools/build/feature/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/build/feature/Makefile +1 -1
@@ -204,7 +204,7 @@ strip-libs = $(filter-out -l%,$(1)) PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null) PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) -PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null` +PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null) FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) ifeq ($(CC_NO_CLANG), 0)
Greg Kroah-Hartman
maintainerPATCH 459/475 dmaengine: Revert "dmaengine: shdma: Fix runtime PM imbalance on error"
In reply to Greg Kroah-HartmanFrom: Vinod Koul <[email protected]>
commit d143f939a95696d38ff800ada14402fa50ebbd6c upstream.
This reverts commit 455896c53d5b ("dmaengine: shdma: Fix runtime PM imbalance on error") as the patch wrongly reduced the count on error and did not bail out. So drop the count by reverting the patch .
--- drivers/dma/sh/shdma-base.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/dma/sh/shdma-base.c +1 -3
@@ -115,10 +115,8 @@ static dma_cookie_t shdma_tx_submit(stru ret =pm_runtime_get (schan->dev);spin_unlock_irq (&schan->chan_lock); -if (ret <0 ) { +if (ret <0 )dev_err (schan->dev,"%s(): GET = %d\n" , __func__, ret); -pm_runtime_put (schan->dev); - }pm_runtime_barrier (schan->dev);
Greg Kroah-Hartman
maintainerPATCH 460/475 mmc: mmci_sdmmc: Replace sg_dma_xxx macros
In reply to Greg Kroah-HartmanFrom: Ludovic Barre <[email protected]>
commit 127e6e98ca9b8ac4f87698ebce1508e3449bb791 upstream.
sg_dma_xxx should be used after a dma_map_sg call has been done to get bus addresses of each of the SG entries and their lengths. But mmci_host_ops validate_data can be called before dma_map_sg. This patch replaces theses macros by sg->offset and sg->length which are always defined.
--- drivers/mmc/host/mmci_stm32_sdmmc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mmc/host/mmci_stm32_sdmmc.c +3 -3
@@ -36,8 +36,8 @@ int sdmmc_idma_validate_data(struct mmci* excepted the last element which has no constraint on idmasize */ for_each_sg (data->sg, sg, data->sg_len -1 , i) { -if (!IS_ALIGNED (sg_dma_address (data->sg),sizeof (u32)) || - !IS_ALIGNED (sg_dma_len (data->sg),SDMMC_IDMA_BURST )) { +if (!IS_ALIGNED (data->sg->offset,sizeof (u32)) || + !IS_ALIGNED (data->sg->length,SDMMC_IDMA_BURST )) {dev_err (mmc_dev (host->mmc),"unaligned scatterlist: ofst:%x length:%d\n" , data->sg->offset, data->sg->length);
@@ -45,7 +45,7 @@ int sdmmc_idma_validate_data(struct mmci } } -if (!IS_ALIGNED (sg_dma_address (data->sg),sizeof (u32))) { +if (!IS_ALIGNED (data->sg->offset,sizeof (u32))) {dev_err (mmc_dev (host->mmc),"unaligned last scatterlist: ofst:%x length:%d\n" , data->sg->offset, data->sg->length);
Greg Kroah-Hartman
maintainerPATCH 461/475 mmc: mmci: stm32: correctly check all elements of sg list
In reply to Greg Kroah-HartmanFrom: Yann Gautier <[email protected]>
commit 0d319dd5a27183b75d984e3dc495248e59f99334 upstream.
Use sg and not data->sg when checking sg list elements. Else only the first element alignment is checked.
The last element should be checked the same way, for_each_sg already set sg to sg_next(sg).
--- drivers/mmc/host/mmci_stm32_sdmmc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mmc/host/mmci_stm32_sdmmc.c +3 -3
@@ -36,8 +36,8 @@ int sdmmc_idma_validate_data(struct mmci* excepted the last element which has no constraint on idmasize */ for_each_sg (data->sg, sg, data->sg_len -1 , i) { -if (!IS_ALIGNED (data->sg->offset,sizeof (u32)) || - !IS_ALIGNED (data->sg->length,SDMMC_IDMA_BURST )) { +if (!IS_ALIGNED (sg->offset,sizeof (u32)) || + !IS_ALIGNED (sg->length,SDMMC_IDMA_BURST )) {dev_err (mmc_dev (host->mmc),"unaligned scatterlist: ofst:%x length:%d\n" , data->sg->offset, data->sg->length);
@@ -45,7 +45,7 @@ int sdmmc_idma_validate_data(struct mmci } } -if (!IS_ALIGNED (data->sg->offset,sizeof (u32))) { +if (!IS_ALIGNED (sg->offset,sizeof (u32))) {dev_err (mmc_dev (host->mmc),"unaligned last scatterlist: ofst:%x length:%d\n" , data->sg->offset, data->sg->length);
Greg Kroah-Hartman
maintainerPATCH 462/475 mm: dont skip swap entry even if zap_details specified
In reply to Greg Kroah-HartmanFrom: Peter Xu <[email protected]>
commit 5abfd71d936a8aefd9f9ccd299dea7a164a5d455 upstream.
Patch series "mm: Rework zap ptes on swap entries", v5.
Patch 1 should fix a long standing bug for zap_pte_range() on zap_details usage. The risk is we could have some swap entries skipped while we should have zapped them.
Migration entries are not the major concern because file backed memory always zap in the pattern that "first time without page lock, then re-zap with page lock" hence the 2nd zap will always make sure all migration entries are already recovered.
However there can be issues with real swap entries got skipped errornoously. There's a reproducer provided in commit message of patch 1 for that.
Patch 2-4 are cleanups that are based on patch 1. After the whole patchset applied, we should have a very clean view of zap_pte_range().
Only patch 1 needs to be backported to stable if necessary.
This patch (of 4):
The "details" pointer shouldn't be the token to decide whether we should skip swap entries.
For example, when the callers specified details->zap_mapping==NULL, it means the user wants to zap all the pages (including COWed pages), then we need to look into swap entries because there can be private COWed pages that was swapped out.
Skipping some swap entries when details is non-NULL may lead to wrongly leaving some of the swap entries while we should have zapped them.
A reproducer of the problem:
===8<===
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <stdio.h>
#include <assert.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
int page_size;
int shmem_fd;
char *buffer;
void main(void)
{
int ret;
char val;
page_size = getpagesize();
shmem_fd = memfd_create("test", 0);
assert(shmem_fd >= 0);
ret = ftruncate(shmem_fd, page_size * 2);
assert(ret == 0);
buffer = mmap(NULL, page_size * 2, PROT_READ | PROT_WRITE,
MAP_PRIVATE, shmem_fd, 0);
assert(buffer != MAP_FAILED);
/* Write private page, swap it out */
buffer[page_size] = 1;
madvise(buffer, page_size * 2, MADV_PAGEOUT);
/* This should drop private buffer[page_size] already */
ret = ftruncate(shmem_fd, page_size);
assert(ret == 0);
/* Recover the size */
ret = ftruncate(shmem_fd, page_size * 2);
assert(ret == 0);
/* Re-read the data, it should be all zero */
val = buffer[page_size];
if (val == 0)
printf("Good\n");
else
printf("BUG\n");
}===8<===
We don't need to touch up the pmd path, because pmd never had a issue with swap entries. For example, shmem pmd migration will always be split into pte level, and same to swapping on anonymous.
Add another helper should_zap_cows() so that we can also check whether we should zap private mappings when there's no page pointer specified.
This patch drops that trick, so we handle swap ptes coherently. Meanwhile we should do the same check upon migration entry, hwpoison entry and genuine swap entries too.
To be explicit, we should still remember to keep the private entries if even_cows==false, and always zap them when even_cows==true.
The issue seems to exist starting from the initial commit of git.
--- mm/memory.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)
mm/memory.c +19 -6
@@ -1013,6 +1013,17 @@ int copy_page_range(struct mm_struct *dsreturn ret; } +/* Whether we should zap all COWed (private) pages too */ +static inline bool should_zap_cows (struct zap_details *details) +{ +/* By default, zap all pages */ +if (!details) +return true; + +/* Or, we zap COWed pages only if the caller wants to */ +return !details->check_mapping; +} + static unsigned long zap_pte_range(struct mmu_gather *tlb, struct vm_area_struct *vma, pmd_t *pmd, unsigned long addr, unsigned long end,
@@ -1104,16 +1115,18 @@ again:continue ; } -/* If details->check_mapping, we leave swap entries. */ -if (unlikely (details)) -continue ; - -if (!non_swap_entry (entry)) +if (!non_swap_entry (entry)) { +/* Genuine swap entry, hence a private anon page */ +if (!should_zap_cows (details)) +continue ; rss[MM_SWAPENTS ]--; -else if (is_migration_entry (entry)) { + }else if (is_migration_entry (entry)) {struct page *page; page =migration_entry_to_page (entry); +if (details && details->check_mapping && + details->check_mapping !=page_rmapping (page)) +continue ; rss[mm_counter (page)]--; }if (unlikely (!free_swap_and_cache (entry)))
Greg Kroah-Hartman
maintainerPATCH 463/475 arm64: module: remove (NOLOAD) from linker script
In reply to Greg Kroah-HartmanFrom: Fangrui Song <[email protected]>
commit 4013e26670c590944abdab56c4fa797527b74325 upstream.
On ELF, (NOLOAD) sets the section type to SHT_NOBITS[1]. It is conceptually inappropriate for .plt and .text.* sections which are always SHT_PROGBITS.
In GNU ld, if PLT entries are needed, .plt will be SHT_PROGBITS anyway and (NOLOAD) will be essentially ignored. In ld.lld, since
https://reviews.llvm.org/D118840 ("[ELF] Support (TYPE=<value>) to customize the output section type"), ld.lld will report a section type mismatch error. Just remove (NOLOAD) to fix the error.
[1] https://lld.llvm.org/ELF/linker_script.html As of today, "The section should be marked as not loadable" on
https://sourceware.org/binutils/docs/ld/Output-Section-Type.html is outdated for ELF.
--- arch/arm64/kernel/module.lds | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/kernel/module.lds +3 -3
@@ -1,5 +1,5 @@ SECTIONS { - .plt 0 (NOLOAD) : { BYTE(0) } - .init.plt 0 (NOLOAD) : { BYTE(0) } - .text.ftrace_trampoline 0 (NOLOAD) : { BYTE(0) } + .plt 0 : { BYTE(0) } + .init.plt 0 : { BYTE(0) } + .text.ftrace_trampoline 0 : { BYTE(0) } }
Greg Kroah-Hartman
maintainerPATCH 464/475 mm/sparsemem: fix mem_section will never be NULL gcc 12 warning
In reply to Greg Kroah-HartmanFrom: Waiman Long <[email protected]>
commit a431dbbc540532b7465eae4fc8b56a85a9fc7d17 upstream.
The gcc 12 compiler reports a "'mem_section' will never be NULL" warning on the following code:
static inline struct mem_section *__nr_to_section(unsigned long nr)
{
#ifdef CONFIG_SPARSEMEM_EXTREME
if (!mem_section)
return NULL;
#endif
if (!mem_section[SECTION_NR_TO_ROOT(nr)])
return NULL;
:It happens with CONFIG_SPARSEMEM_EXTREME off. The mem_section definition is
#ifdef CONFIG_SPARSEMEM_EXTREME
extern struct mem_section **mem_section;
#else
extern struct mem_section mem_section[NR_SECTION_ROOTS][SECTIONS_PER_ROOT];
#endifIn the !CONFIG_SPARSEMEM_EXTREME case, mem_section is a static 2-dimensional array and so the check "!mem_section[SECTION_NR_TO_ROOT(nr)]" doesn't make sense.
Fix this warning by moving the "!mem_section[SECTION_NR_TO_ROOT(nr)]" check up inside the CONFIG_SPARSEMEM_EXTREME block and adding an explicit NR_SECTION_ROOTS check to make sure that there is no out-of-bound array access.
--- include/linux/mmzone.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
include/linux/mmzone.h +7 -4
@@ -1250,13 +1250,16 @@ static inline unsigned long *section_to_static inline struct mem_section *__nr_to_section (unsigned long nr) { +unsigned long root =SECTION_NR_TO_ROOT (nr); + +if (unlikely (root >=NR_SECTION_ROOTS )) +return NULL ; +#ifdef CONFIG_SPARSEMEM_EXTREME -if (!mem_section) +if (!mem_section || !mem_section[root])return NULL ;#endif -if (!mem_section[SECTION_NR_TO_ROOT (nr)]) -return NULL ; -return &mem_section[SECTION_NR_TO_ROOT (nr)][nr &SECTION_ROOT_MASK ]; +return &mem_section[root][nr &SECTION_ROOT_MASK ]; }extern unsigned long __section_nr (struct mem_section *ms);extern size_t mem_section_usage_size (void );
Greg Kroah-Hartman
maintainerPATCH 465/475 drm/amdkfd: add missing void argument to function kgd2kfd_init
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
From: Colin Ian King <[email protected]>
commit 63617d8b125ed9f674133dd000b6df58d6b2965a upstream.
Function kgd2kfd_init is missing a void argument, add it to clean up the non-ANSI function declaration.
--- drivers/gpu/drm/amd/amdkfd/kfd_module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_module.c +1 -1
@@ -82,7 +82,7 @@ static void kfd_exit(void)kfd_chardev_exit (); } -int kgd2kfd_init () +int kgd2kfd_init (void ) {return kfd_init (); }
Greg Kroah-Hartman
maintainerPATCH 466/475 drm/amdkfd: Fix -Wstrict-prototypes from amdgpu_amdkfd_gfx_10_0_get_functions()
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
This patch is for linux-5.4.y only, it has no equivalent change upstream.
When building x86_64 allmodconfig with tip of tree clang, there is an instance of -Wstrict-prototypes:
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c:168:59: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes] struct kfd2kgd_calls *amdgpu_amdkfd_gfx_10_0_get_functions()
^
void1 error generated.
amdgpu_amdkfd_gfx_10_0_get_functions() is prototyped properly in drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h but its definition in amdgpu_amdkfd_gfx_v10.c does not have the argument types specified, which causes the warning. GCC does not warn because it permits an old-style definition if the prototype has the argument types.
This code was eliminated by commit e392c887df97 ("drm/amdkfd: Use array to probe kfd2kgd_calls"), which was a part of a larger series that does not look very suitable for stable. Just fix this one location, as it was the only instance of this new warning across a variety of builds.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c +1 -1
@@ -165,7 +165,7 @@ static const struct kfd2kgd_calls kfd2kg .get_tile_config = amdgpu_amdkfd_get_tile_config, }; -struct kfd2kgd_calls *amdgpu_amdkfd_gfx_10_0_get_functions () +struct kfd2kgd_calls *amdgpu_amdkfd_gfx_10_0_get_functions (void ) {return (struct kfd2kgd_calls *)&kfd2kgd; }
Greg Kroah-Hartman
maintainerPATCH 467/475 io_uring: fix fs->users overflow
In reply to Greg Kroah-HartmanFrom: Pavel Begunkov <[email protected]>
There is a bunch of cases where we can grab req->fs but not put it, this can be used to cause a controllable overflow with further implications. Release req->fs in the request free path and make sure we zero the field to be sure we don't do it twice.
--- fs/io_uring.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-)
fs/io_uring.c +18 -10
@@ -438,6 +438,22 @@ static struct io_ring_ctx *io_ring_ctx_areturn ctx; } +static void io_req_put_fs (struct io_kiocb *req) +{ +struct fs_struct *fs = req->fs; + +if (!fs) +return ; + +spin_lock (&req->fs->lock); +if (--fs->users) + fs =NULL ; +spin_unlock (&req->fs->lock); +if (fs) +free_fs_struct (fs); + req->fs =NULL ; +} +static inline bool __io_sequence_defer (struct io_ring_ctx *ctx,struct io_kiocb *req) {
@@ -695,6 +711,7 @@ static void io_free_req_many(struct io_rstatic void __io_free_req (struct io_kiocb *req) { +io_req_put_fs (req);if (req->file && !(req->flags &REQ_F_FIXED_FILE ))fput (req->file);percpu_ref_put (&req->ctx->refs);
@@ -1701,16 +1718,7 @@ static int io_send_recvmsg(struct io_kio ret = -EINTR ; } -if (req->fs) { -struct fs_struct *fs = req->fs; - -spin_lock (&req->fs->lock); -if (--fs->users) - fs =NULL ; -spin_unlock (&req->fs->lock); -if (fs) -free_fs_struct (fs); - } +io_req_put_fs (req);io_cqring_add_event (req->ctx, sqe->user_data, ret);io_put_req (req);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 468/475 cgroup: Use open-time credentials for process migraton perm checks
In reply to Greg Kroah-HartmanFrom: Tejun Heo <[email protected]>
commit 1756d7994ad85c2479af6ae5a9750b92324685af upstream.
cgroup process migration permission checks are performed at write time as whether a given operation is allowed or not is dependent on the content of the write - the PID. This currently uses current's credentials which is a potential security weakness as it may allow scenarios where a less privileged process tricks a more privileged one into writing into a fd that it created.
This patch makes both cgroup2 and cgroup1 process migration interfaces to use the credentials saved at the time of open (file->f_cred) instead of current's.
[OP: backport to 5.4: apply original __cgroup_procs_write() changes to cgroup_threads_write() and cgroup_procs_write()]
--- kernel/cgroup/cgroup-v1.c | 7 ++++--- kernel/cgroup/cgroup.c | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-)
kernel/cgroup/cgroup-v1.c +4 -3
@@ -507,10 +507,11 @@ static ssize_t __cgroup1_procs_write(str goto out_unlock;/* -* Even if we're attaching all tasks in the thread group, we only -* need to check permissions on one of them. +* Even if we're attaching all tasks in the thread group, we only need +* to check permissions on one of them. Check permissions using the +* credentials from file open to protect against inherited fd attacks. */ - cred =current_cred (); + cred = of->file->f_cred; tcred =get_task_cred (task); if (!uid_eq(cred->euid, GLOBAL_ROOT_UID) && !uid_eq(cred->euid, tcred->uid) &&
kernel/cgroup/cgroup.c +16 -1
@@ -4798,6 +4798,7 @@ static ssize_t cgroup_procs_write(struct {struct cgroup *src_cgrp, *dst_cgrp;struct task_struct *task; +const struct cred *saved_cred;ssize_t ret; dst_cgrp =cgroup_kn_lock_live (of->kn, false);
@@ -4814,8 +4815,15 @@ static ssize_t cgroup_procs_write(struct src_cgrp =task_cgroup_from_root (task, &cgrp_dfl_root);spin_unlock_irq (&css_set_lock); +/* +* Process and thread migrations follow same delegation rule. Check +* permissions using the credentials from file open to protect against +* inherited fd attacks. +*/ + saved_cred =override_creds (of->file->f_cred); ret =cgroup_procs_write_permission (src_cgrp, dst_cgrp, of->file->f_path.dentry->d_sb); +revert_creds (saved_cred);if (ret) goto out_finish;
@@ -4839,6 +4847,7 @@ static ssize_t cgroup_threads_write(stru {struct cgroup *src_cgrp, *dst_cgrp;struct task_struct *task; +const struct cred *saved_cred;ssize_t ret; buf =strstrip (buf);
@@ -4857,9 +4866,15 @@ static ssize_t cgroup_threads_write(stru src_cgrp =task_cgroup_from_root (task, &cgrp_dfl_root);spin_unlock_irq (&css_set_lock); -/* thread migrations follow the cgroup.procs delegation rule */ +/* +* Process and thread migrations follow same delegation rule. Check +* permissions using the credentials from file open to protect against +* inherited fd attacks. +*/ + saved_cred =override_creds (of->file->f_cred); ret =cgroup_procs_write_permission (src_cgrp, dst_cgrp, of->file->f_path.dentry->d_sb); +revert_creds (saved_cred);if (ret) goto out_finish;
Greg Kroah-Hartman
maintainerPATCH 469/475 cgroup: Allocate cgroup_file_ctx for kernfs_open_file->priv
In reply to Greg Kroah-HartmanFrom: Tejun Heo <[email protected]>
commit 0d2b5955b36250a9428c832664f2079cbf723bec upstream.
of->priv is currently used by each interface file implementation to store private information. This patch collects the current two private data usages into struct cgroup_file_ctx which is allocated and freed by the common path. This allows generic private data which applies to multiple files, which will be used to in the following patch.
Note that cgroup_procs iterator is now embedded as procs.iter in the new cgroup_file_ctx so that it doesn't need to be allocated and freed separately.
v2: union dropped from cgroup_file_ctx and the procs iterator is embedded in
cgroup_file_ctx as suggested by Linus.
v3: Michal pointed out that cgroup1's procs pidlist uses of->priv too.
Converted. Didn't change to embedded allocation as cgroup1 pidlists get stored for caching.
--- kernel/cgroup/cgroup-internal.h | 17 ++++++++++++ kernel/cgroup/cgroup-v1.c | 26 ++++++++++--------- kernel/cgroup/cgroup.c | 54 +++++++++++++++++++++++++--------------- 3 files changed, 65 insertions(+), 32 deletions(-)
kernel/cgroup/cgroup-internal.h +17 -0
@@ -65,6 +65,23 @@ static inline struct cgroup_fs_context * return container_of(kfc, struct cgroup_fs_context, kfc); } +struct cgroup_pidlist ; + +struct cgroup_file_ctx { +struct { +void *trigger; + } psi; + +struct { +bool started; +struct css_task_iter iter; + } procs; + +struct { +struct cgroup_pidlist *pidlist; + } procs1; +}; +/* * A cgroup can be associated with multiple css_sets as different tasks may * belong to different cgroups on different hierarchies. In the other
kernel/cgroup/cgroup-v1.c +14 -12
@@ -398,6 +398,7 @@ static void *cgroup_pidlist_start(struct* next pid to display, if any */ struct kernfs_open_file *of = s->private; +struct cgroup_file_ctx *ctx = of->priv;struct cgroup *cgrp =seq_css (s)->cgroup;struct cgroup_pidlist *l;enum cgroup_filetype type =seq_cft (s)->private;
@@ -407,25 +408,24 @@ static void *cgroup_pidlist_start(structmutex_lock (&cgrp->pidlist_mutex);/* -* !NULL @of->priv indicates that this isn't the first start() -* after open. If the matching pidlist is around, we can use that. -* Look for it. Note that @of->priv can't be used directly. It -* could already have been destroyed. +* !NULL @ctx->procs1.pidlist indicates that this isn't the first +* start() after open. If the matching pidlist is around, we can use +* that. Look for it. Note that @ctx->procs1.pidlist can't be used +* directly. It could already have been destroyed. */ -if (of->priv) - of->priv =cgroup_pidlist_find (cgrp, type); +if (ctx->procs1.pidlist) + ctx->procs1.pidlist =cgroup_pidlist_find (cgrp, type);/* * Either this is the first start() after open or the matching * pidlist has been destroyed inbetween. Create a new one. */ -if (!of->priv) { - ret =pidlist_array_load (cgrp, type, - (struct cgroup_pidlist **)&of->priv); +if (!ctx->procs1.pidlist) { + ret =pidlist_array_load (cgrp, type, &ctx->procs1.pidlist);if (ret)return ERR_PTR (ret); } - l = of->priv; + l = ctx->procs1.pidlist;if (pid) {int end = l->length;
@@ -453,7 +453,8 @@ static void *cgroup_pidlist_start(structstatic void cgroup_pidlist_stop (struct seq_file *s,void *v) {struct kernfs_open_file *of = s->private; -struct cgroup_pidlist *l = of->priv; +struct cgroup_file_ctx *ctx = of->priv; +struct cgroup_pidlist *l = ctx->procs1.pidlist;if (l) mod_delayed_work(cgroup_pidlist_destroy_wq, &l->destroy_dwork,
@@ -464,7 +465,8 @@ static void cgroup_pidlist_stop(struct sstatic void *cgroup_pidlist_next (struct seq_file *s,void *v,loff_t *pos) {struct kernfs_open_file *of = s->private; -struct cgroup_pidlist *l = of->priv; +struct cgroup_file_ctx *ctx = of->priv; +struct cgroup_pidlist *l = ctx->procs1.pidlist;pid_t *p = v;pid_t *end = l->list + l->length;/*
kernel/cgroup/cgroup.c +34 -20
126 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 470/475 cgroup: Use open-time cgroup namespace for process migration perm checks
In reply to Greg Kroah-HartmanFrom: Tejun Heo <[email protected]>
commit e57457641613fef0d147ede8bd6a3047df588b95 upstream.
cgroup process migration permission checks are performed at write time as whether a given operation is allowed or not is dependent on the content of the write - the PID. This currently uses current's cgroup namespace which is a potential security weakness as it may allow scenarios where a less privileged process tricks a more privileged one into writing into a fd that it created.
This patch makes cgroup remember the cgroup namespace at the time of open and uses it for migration permission checks instad of current's. Note that this only applies to cgroup2 as cgroup1 doesn't have namespace support.
This also fixes a use-after-free bug on cgroupns reported in
https://lore.kernel.org/r/[email protected]
Note that backporting this fix also requires the preceding patch.
[OP: backport to v5.4: drop changes to cgroup_attach_permissions() and cgroup_css_set_fork(), adjust cgroup_procs_write_permission() calls]
--- kernel/cgroup/cgroup-internal.h | 2 ++ kernel/cgroup/cgroup.c | 24 +++++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-)
kernel/cgroup/cgroup-internal.h +2 -0
@@ -68,6 +68,8 @@ static inline struct cgroup_fs_context *struct cgroup_pidlist ;struct cgroup_file_ctx { +struct cgroup_namespace *ns; +struct {void *trigger; } psi;
kernel/cgroup/cgroup.c +17 -7
@@ -3758,14 +3758,19 @@ static int cgroup_file_open(struct kernf ctx =kzalloc (sizeof (*ctx),GFP_KERNEL );if (!ctx)return -ENOMEM ; + + ctx->ns = current->nsproxy->cgroup_ns; +get_cgroup_ns (ctx->ns); of->priv = ctx;if (!cft->open)return 0 ; ret = cft->open (of); -if (ret) +if (ret) { +put_cgroup_ns (ctx->ns);kfree (ctx); + }return ret; }
@@ -3776,13 +3781,14 @@ static void cgroup_file_release(struct kif (cft->release) cft->release (of); +put_cgroup_ns (ctx->ns);kfree (ctx); }static ssize_t cgroup_file_write (struct kernfs_open_file *of,char *buf,size_t nbytes,loff_t off) { -struct cgroup_namespace *ns = current->nsproxy->cgroup_ns; +struct cgroup_file_ctx *ctx = of->priv;struct cgroup *cgrp = of->kn->parent->priv;struct cftype *cft = of->kn->priv;struct cgroup_subsys_state *css;
@@ -3796,7 +3802,7 @@ static ssize_t cgroup_file_write(struct*/ if ((cgrp->root->flags &CGRP_ROOT_NS_DELEGATE ) && !(cft->flags &CFTYPE_NS_DELEGATABLE ) && - ns != &init_cgroup_ns && ns->root_cset->dfl_cgrp == cgrp) + ctx->ns != &init_cgroup_ns && ctx->ns->root_cset->dfl_cgrp == cgrp)return -EPERM ;if (cft->write)
@@ -4772,9 +4778,9 @@ static int cgroup_procs_show(struct seq_static int cgroup_procs_write_permission (struct cgroup *src_cgrp,struct cgroup *dst_cgrp, -struct super_block *sb) +struct super_block *sb, +struct cgroup_namespace *ns) { -struct cgroup_namespace *ns = current->nsproxy->cgroup_ns;struct cgroup *com_cgrp = src_cgrp;struct inode *inode;int ret;
@@ -4810,6 +4816,7 @@ static int cgroup_procs_write_permissionstatic ssize_t cgroup_procs_write (struct kernfs_open_file *of,char *buf,size_t nbytes,loff_t off) { +struct cgroup_file_ctx *ctx = of->priv;struct cgroup *src_cgrp, *dst_cgrp;struct task_struct *task;const struct cred *saved_cred;
@@ -4836,7 +4843,8 @@ static ssize_t cgroup_procs_write(struct*/ saved_cred =override_creds (of->file->f_cred); ret =cgroup_procs_write_permission (src_cgrp, dst_cgrp, - of->file->f_path.dentry->d_sb); + of->file->f_path.dentry->d_sb, + ctx->ns);revert_creds (saved_cred);if (ret) goto out_finish;
@@ -4859,6 +4867,7 @@ static void *cgroup_threads_start(structstatic ssize_t cgroup_threads_write (struct kernfs_open_file *of,char *buf,size_t nbytes,loff_t off) { +struct cgroup_file_ctx *ctx = of->priv;struct cgroup *src_cgrp, *dst_cgrp;struct task_struct *task;const struct cred *saved_cred;
@@ -4887,7 +4896,8 @@ static ssize_t cgroup_threads_write(stru*/ saved_cred =override_creds (of->file->f_cred); ret =cgroup_procs_write_permission (src_cgrp, dst_cgrp, - of->file->f_path.dentry->d_sb); + of->file->f_path.dentry->d_sb, + ctx->ns);revert_creds (saved_cred);if (ret) goto out_finish;
Greg Kroah-Hartman
maintainerPATCH 471/475 selftests: cgroup: Make cg_create() use 0755 for permission instead of 0644
In reply to Greg Kroah-HartmanFrom: Tejun Heo <[email protected]>
commit b09c2baa56347ae65795350dfcc633dedb1c2970 upstream.
0644 is an odd perm to create a cgroup which is a directory. Use the regular 0755 instead. This is necessary for euid switching test case.
--- tools/testing/selftests/cgroup/cgroup_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/cgroup/cgroup_util.c +1 -1
@@ -202,7 +202,7 @@ int cg_find_unified_root(char *root, sizint cg_create (const char *cgroup) { -return mkdir (cgroup,0644 ); +return mkdir (cgroup,0755 ); }int cg_wait_for_proc_count (const char *cgroup,int count)
Greg Kroah-Hartman
maintainerPATCH 472/475 selftests: cgroup: Test open-time credential usage for migration checks
In reply to Greg Kroah-HartmanFrom: Tejun Heo <[email protected]>
commit 613e040e4dc285367bff0f8f75ea59839bc10947 upstream.
When a task is writing to an fd opened by a different task, the perm check should use the credentials of the latter task. Add a test for it.
--- tools/testing/selftests/cgroup/test_core.c | 68 +++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+)
tools/testing/selftests/cgroup/test_core.c +68 -0
@@ -354,6 +354,73 @@ cleanup:return ret; } +/* +* cgroup migration permission check should be performed based on the +* credentials at the time of open instead of write. +*/ +static int test_cgcore_lesser_euid_open (const char *root) +{ +const uid_t test_euid =65534 ;/* usually nobody, any !root is fine */ +int ret =KSFT_FAIL ; +char *cg_test_a =NULL , *cg_test_b =NULL ; +char *cg_test_a_procs =NULL , *cg_test_b_procs =NULL ; +int cg_test_b_procs_fd =-1 ; +uid_t saved_uid; + + cg_test_a =cg_name (root,"cg_test_a" ); + cg_test_b =cg_name (root,"cg_test_b" ); + +if (!cg_test_a || !cg_test_b) + goto cleanup; + + cg_test_a_procs =cg_name (cg_test_a,"cgroup.procs" ); + cg_test_b_procs =cg_name (cg_test_b,"cgroup.procs" ); + +if (!cg_test_a_procs || !cg_test_b_procs) + goto cleanup; + +if (cg_create (cg_test_a) ||cg_create (cg_test_b)) + goto cleanup; + +if (cg_enter_current (cg_test_a)) + goto cleanup; + +if (chown (cg_test_a_procs, test_euid,-1 ) || +chown (cg_test_b_procs, test_euid,-1 )) + goto cleanup; + + saved_uid =geteuid (); +if (seteuid (test_euid)) + goto cleanup; + + cg_test_b_procs_fd =open (cg_test_b_procs,O_RDWR ); + +if (seteuid (saved_uid)) + goto cleanup; + +if (cg_test_b_procs_fd <0 ) + goto cleanup; + +if (write (cg_test_b_procs_fd,"0" ,1 ) >=0 || errno !=EACCES ) + goto cleanup; + + ret =KSFT_PASS ; + +cleanup: +cg_enter_current (root); +if (cg_test_b_procs_fd >=0 ) +close (cg_test_b_procs_fd); +if (cg_test_b) +cg_destroy (cg_test_b); +if (cg_test_a) +cg_destroy (cg_test_a); +free (cg_test_b_procs); +free (cg_test_a_procs); +free (cg_test_b); +free (cg_test_a); +return ret; +} +#define T (x) { x, #x }struct corecg_test {int (*fn)(const char *root);
@@ -366,6 +433,7 @@ struct corecg_test {T (test_cgcore_parent_becomes_threaded),T (test_cgcore_invalid_domain),T (test_cgcore_populated), + T(test_cgcore_lesser_euid_open), };#undef T
Greg Kroah-Hartman
maintainerPATCH 473/475 selftests: cgroup: Test open-time cgroup namespace usage for migration checks
In reply to Greg Kroah-HartmanFrom: Tejun Heo <[email protected]>
commit bf35a7879f1dfb0d050fe779168bcf25c7de66f5 upstream.
When a task is writing to an fd opened by a different task, the perm check should use the cgroup namespace of the latter task. Add a test for it.
--- tools/testing/selftests/cgroup/test_core.c | 99 +++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+)
tools/testing/selftests/cgroup/test_core.c +99 -0
@@ -1,8 +1,13 @@/* SPDX-License-Identifier: GPL-2.0 */ +#define _GNU_SOURCE#include <linux/limits.h> +#include <linux/sched.h> #include <sys/types.h> +#include <sys/wait.h> #include <unistd.h> +#include <fcntl.h> +#include <sched.h> #include <stdio.h> #include <errno.h>
@@ -421,6 +426,99 @@ cleanup:return ret; } +struct lesser_ns_open_thread_arg { +const char *path; +int fd; +int err; +}; + +static int lesser_ns_open_thread_fn (void *arg) +{ +struct lesser_ns_open_thread_arg *targ = arg; + + targ->fd =open (targ->path,O_RDWR ); + targ->err = errno; +return 0 ; +} + +/* +* cgroup migration permission check should be performed based on the cgroup +* namespace at the time of open instead of write. +*/ +static int test_cgcore_lesser_ns_open (const char *root) +{ +static char stack[65536 ]; +const uid_t test_euid =65534 ;/* usually nobody, any !root is fine */ +int ret =KSFT_FAIL ; +char *cg_test_a =NULL , *cg_test_b =NULL ; +char *cg_test_a_procs =NULL , *cg_test_b_procs =NULL ; +int cg_test_b_procs_fd =-1 ; +struct lesser_ns_open_thread_arg targ = { .fd =-1 }; +pid_t pid; +int status; + + cg_test_a =cg_name (root,"cg_test_a" ); + cg_test_b =cg_name (root,"cg_test_b" ); + +if (!cg_test_a || !cg_test_b) + goto cleanup; + + cg_test_a_procs =cg_name (cg_test_a,"cgroup.procs" ); + cg_test_b_procs =cg_name (cg_test_b,"cgroup.procs" ); + +if (!cg_test_a_procs || !cg_test_b_procs) + goto cleanup; + +if (cg_create (cg_test_a) ||cg_create (cg_test_b)) + goto cleanup; + +if (cg_enter_current (cg_test_b)) + goto cleanup; + +if (chown (cg_test_a_procs, test_euid,-1 ) || +chown (cg_test_b_procs, test_euid,-1 )) + goto cleanup; + + targ.path = cg_test_b_procs; + pid =clone (lesser_ns_open_thread_fn, stack +sizeof (stack), +CLONE_NEWCGROUP |CLONE_FILES |CLONE_VM |SIGCHLD , + &targ); +if (pid <0 ) + goto cleanup; + +if (waitpid (pid, &status,0 ) <0 ) + goto cleanup; + +if (!WIFEXITED (status)) + goto cleanup; + + cg_test_b_procs_fd = targ.fd; +if (cg_test_b_procs_fd <0 ) + goto cleanup; + +if (cg_enter_current (cg_test_a)) + goto cleanup; + +if ((status =write (cg_test_b_procs_fd,"0" ,1 )) >=0 || errno !=ENOENT ) + goto cleanup; + + ret =KSFT_PASS ; + +cleanup: +cg_enter_current (root); +if (cg_test_b_procs_fd >=0 ) +close (cg_test_b_procs_fd); +if (cg_test_b) +cg_destroy (cg_test_b); +if (cg_test_a) +cg_destroy (cg_test_a); +free (cg_test_b_procs); +free (cg_test_a_procs); +free (cg_test_b); +free (cg_test_a); +return ret; +} +#define T (x) { x, #x }struct corecg_test {int (*fn)(const char *root);
@@ -434,6 +532,7 @@ struct corecg_test {T (test_cgcore_invalid_domain),T (test_cgcore_populated),T (test_cgcore_lesser_euid_open), + T(test_cgcore_lesser_ns_open), };#undef T
Greg Kroah-Hartman
maintainerPATCH 474/475 cpuidle: PSCI: Move the `has_lpi` check to the beginning of the function
In reply to Greg Kroah-HartmanFrom: Mario Limonciello <[email protected]>
commit 01f6c7338ce267959975da65d86ba34f44d54220 upstream.
Currently the first thing checked is whether the PCSI cpu_suspend function has been initialized.
Another change will be overloading acpi_processor_ffh_lpi_probe and calling it sooner. So make the has_lpi check the first thing checked to prepare for that change.
--- arch/arm64/kernel/cpuidle.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/kernel/cpuidle.c +3 -3
@@ -53,6 +53,9 @@ static int psci_acpi_cpu_init_idle(unsigstruct acpi_lpi_state *lpi;struct acpi_processor *pr =per_cpu (processors, cpu); +if (unlikely (!pr || !pr->flags.has_lpi)) +return -EINVAL ; +/* * If the PSCI cpu_suspend function hook has not been initialized * idle states must not be enabled, so bail out
@@ -60,9 +63,6 @@ static int psci_acpi_cpu_init_idle(unsigif (!psci_ops.cpu_suspend)return -EOPNOTSUPP ; -if (unlikely (!pr || !pr->flags.has_lpi)) -return -EINVAL ; - count = pr->power.count -1 ;if (count <=0 )return -ENODEV ;
Greg Kroah-Hartman
maintainerPATCH 475/475 ACPI: processor idle: Check for architectural support for LPI
In reply to Greg Kroah-HartmanFrom: Mario Limonciello <[email protected]>
commit eb087f305919ee8169ad65665610313e74260463 upstream.
When osc_pc_lpi_support_confirmed is set through _OSC and _LPI is populated then the cpuidle driver assumes that LPI is fully functional.
However currently the kernel only provides architectural support for LPI on ARM. This leads to high power consumption on X86 platforms that otherwise try to enable LPI.
So probe whether or not LPI support is implemented before enabling LPI in the kernel. This is done by overloading acpi_processor_ffh_lpi_probe to check whether it returns -EOPNOTSUPP. It also means that all future implementations of acpi_processor_ffh_lpi_probe will need to follow these semantics as well.
--- drivers/acpi/processor_idle.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/acpi/processor_idle.c +10 -5
@@ -1201,6 +1201,11 @@ static int flatten_lpi_states(struct acpreturn 0 ; } +int __weak acpi_processor_ffh_lpi_probe (unsigned int cpu) +{ +return -EOPNOTSUPP ; +} +static int acpi_processor_get_lpi_info (struct acpi_processor *pr) {int ret, i;
@@ -1209,6 +1214,11 @@ static int acpi_processor_get_lpi_info(sstruct acpi_device *d =NULL ;struct acpi_lpi_states_array info[2 ], *tmp, *prev, *curr; +/* make sure our architecture has support */ + ret =acpi_processor_ffh_lpi_probe (pr->id); +if (ret == -EOPNOTSUPP ) +return ret; +if (!osc_pc_lpi_support_confirmed)return -EOPNOTSUPP ;
@@ -1260,11 +1270,6 @@ static int acpi_processor_get_lpi_info(sreturn 0 ; } -int __weak acpi_processor_ffh_lpi_probe (unsigned int cpu) -{ -return -ENODEV ; -} -int __weak acpi_processor_ffh_lpi_enter (struct acpi_lpi_state *lpi) {return -ENODEV ;
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.189 release. There are 475 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 Sat, 16 Apr 2022 11:07:54 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.189-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.4.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.189 release. There are 475 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 Sat, 16 Apr 2022 11:07:54 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.189-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.4.y
and the diffstat can be found below.thanks,
greg k-h
Tested on arm64 and x86 for 5.4.189-rc1,
Kernel repo:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
Branch: linux-5.4.y
Version: 5.4.189-rc1
Commit: 60d6fdc40ea0a2f8726ba5c02bc8f343287b0539
Compiler: gcc version 7.3.0 (GCC)
arm64:
--------------------------------------------------------------------
Testcase Result Summary:
total: 9027
passed: 9027
failed: 0
timeout: 0
--------------------------------------------------------------------
x86:
--------------------------------------------------------------------
Testcase Result Summary:
total: 9027
passed: 9027
failed: 0
timeout: 0
--------------------------------------------------------------------
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.189 release. There are 475 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 Sat, 16 Apr 2022 11:07:54 +0000. Anything received after that time might be too late.
Build results:
total: 159 pass: 159 fail: 0 Qemu test results: total: 449 pass: 449 fail: 0
Guenter
Hello!
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.189 release. There are 475 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 Sat, 16 Apr 2022 11:07:54 +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/v5.x/stable-review/patch-5.4.189-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.4.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.
## Build
* kernel: 5.4.189-rc1
* git: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
* git branch: linux-5.4.y
* git commit: 894dcf9d89fbc5bbc2c65827aaf7febc12fe19ca
* git describe: v5.4.188-476-g894dcf9d89fb
* test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-5.4.y/build/v5.4.188-476-g894dcf9d89fb
## No Test Regressions (compared to v5.4.188)
## No Metric Regressions (compared to v5.4.188)
## No Test Fixes (compared to v5.4.188)
## No Metric Fixes (compared to v5.4.188)
## Test result summary
total: 90063, pass: 74104, fail: 1138, skip: 13360, xfail: 1461
## Build Summary
* arc: 10 total, 10 passed, 0 failed
* arm: 290 total, 290 passed, 0 failed
* arm64: 40 total, 34 passed, 6 failed
* dragonboard-410c: 1 total, 1 passed, 0 failed
* hi6220-hikey: 1 total, 1 passed, 0 failed
* i386: 20 total, 20 passed, 0 failed
* juno-r2: 1 total, 1 passed, 0 failed
* mips: 37 total, 37 passed, 0 failed
* parisc: 12 total, 12 passed, 0 failed
* powerpc: 60 total, 54 passed, 6 failed
* riscv: 27 total, 27 passed, 0 failed
* s390: 12 total, 12 passed, 0 failed
* sh: 24 total, 24 passed, 0 failed
* sparc: 12 total, 12 passed, 0 failed
* x15: 1 total, 1 passed, 0 failed
* x86: 1 total, 1 passed, 0 failed
* x86_64: 40 total, 40 passed, 0 failed
## Test suites summary
* fwts
* igt-gpu-tools
* kselftest-android
* kselftest-arm64
* kselftest-bpf
* kselftest-breakpoints
* kselftest-capabilities
* kselftest-cgroup
* kselftest-clone3
* kselftest-core
* kselftest-cpu-hotplug
* kselftest-cpufreq
* kselftest-drivers
* kselftest-efivarfs
* kselftest-filesystems
* kselftest-firmware
* kselftest-fpu
* kselftest-futex
* kselftest-gpio
* kselftest-intel_pstate
* kselftest-ipc
* kselftest-ir
* kselftest-kcmp
* kselftest-kexec
* kselftest-kvm
* kselftest-lib
* kselftest-livepatch
* kselftest-membarrier
* kselftest-memfd
* kselftest-memory-hotplug
* kselftest-mincore
* kselftest-mount
* kselftest-mqueue
* kselftest-net
* kselftest-netfilter
* kselftest-nsfs
* kselftest-openat2
* kselftest-pid_namespace
* kselftest-pidfd
* kselftest-proc
* kselftest-pstore
* kselftest-ptrace
* 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-vm
* kselftest-x86
* kselftest-zram
* kvm-unit-tests
* libgpiod
* libhugetlbfs
* linux-log-parser
* ltp-cap_bounds-tests
* ltp-commands-tests
* ltp-containers-tests
* ltp-controllers-tests
* ltp-cpuhotplug-tests
* ltp-crypto-tests
* ltp-cve-tests
* ltp-dio-tests
* ltp-fcntl-locktests-tests
* ltp-filecaps-tests
* ltp-fs-tests
* ltp-fs_bind-tests
* ltp-fs_perms_simple-tests
* ltp-fsx-tests
* ltp-hugetlb-tests
* ltp-io-tests
* ltp-ipc-tests
* ltp-math-tests
* ltp-mm-tests
* ltp-nptl-tests
* ltp-open-posix-tests
* ltp-pty-tests
* ltp-sched-tests
* ltp-securebits-tests
* ltp-syscalls-tests
* ltp-tracing-tests
* network-basic-tests
* packetdrill
* perf
* perf/Zstd-perf.data-compression
* rcutorture
* ssuite
* v4l2-compliance
* vdso
Greetings!
Daniel Díaz
[email protected]
Signature · 2 lines
Linaro LKFT https://lkft.linaro.org
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.189 release. There are 475 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 Sat, 16 Apr 2022 11:07:54 +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/v5.x/stable-review/patch-5.4.189-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.4.y
and the diffstat can be found below.thanks,
greg k-h
On ARCH_BRCMSTB using 32-bit and 64-bit ARM kernels:
Signature · 1 line
Florian