5.15.222-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 268/752 btrfs: consolidate device_list_mutex in prepare_sprout to its parent
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anand Jain <[email protected]>
[ Upstream commit 849eae5e57a703105aa6cdce0d860ab95f44d81c ]
btrfs_prepare_sprout() splices seed devices into its own struct fs_devices, so that its parent function btrfs_init_new_device() can add the new sprout device to fs_info->fs_devices.
Both btrfs_prepare_sprout() and btrfs_init_new_device() need device_list_mutex. But they are holding it separately, thus create a small race window. Close it and hold device_list_mutex across both functions btrfs_init_new_device() and btrfs_prepare_sprout().
Split btrfs_prepare_sprout() into btrfs_init_sprout() and btrfs_setup_sprout(). This split is essential because device_list_mutex must not be held for allocations in btrfs_init_sprout() but must be held for btrfs_setup_sprout(). So now a common device_list_mutex can be used between btrfs_init_new_device() and btrfs_setup_sprout().
Stable-dep-of: e0b54613aabe ("btrfs: restore active device pointers after failed sprout")
--- fs/btrfs/volumes.c | 69 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 18 deletions(-)
fs/btrfs/volumes.c +51 -18
@@ -2525,21 +2525,15 @@ struct btrfs_device *btrfs_find_device_by_devspec(return device; } -/* -* does all the dirty work required for changing file system's UUID. -*/ -static int btrfs_prepare_sprout (struct btrfs_fs_info *fs_info) +static struct btrfs_fs_devices *btrfs_init_sprout (struct btrfs_fs_info *fs_info) {struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;struct btrfs_fs_devices *old_devices;struct btrfs_fs_devices *seed_devices; -struct btrfs_super_block *disk_super = fs_info->super_copy; -struct btrfs_device *device; -u64 super_flags;lockdep_assert_held (&uuid_mutex);if (!fs_devices->seeding) -return -EINVAL ; +return ERR_PTR (-EINVAL );/* * Private copy of the seed devices, anchored at
@@ -2547,7 +2541,7 @@ static int btrfs_prepare_sprout(struct btrfs_fs_info *fs_info)*/ seed_devices =alloc_fs_devices (NULL ,NULL );if (IS_ERR (seed_devices)) -return PTR_ERR (seed_devices); +return seed_devices;/* * It's necessary to retain a copy of the original seed fs_devices in
@@ -2558,7 +2552,7 @@ static int btrfs_prepare_sprout(struct btrfs_fs_info *fs_info) old_devices =clone_fs_devices (fs_devices);if (IS_ERR (old_devices)) {kfree (seed_devices); -return PTR_ERR (old_devices); +return old_devices; }list_add (&old_devices->fs_list, &fs_uuids);
@@ -2569,7 +2563,41 @@ static int btrfs_prepare_sprout(struct btrfs_fs_info *fs_info)INIT_LIST_HEAD (&seed_devices->alloc_list);mutex_init (&seed_devices->device_list_mutex); -mutex_lock (&fs_devices->device_list_mutex); +return seed_devices; +} + +/* +* Splice seed devices into the sprout fs_devices. +* Generate a new fsid for the sprouted read-write filesystem. +*/ +static void btrfs_setup_sprout (struct btrfs_fs_info *fs_info, +struct btrfs_fs_devices *seed_devices) +{ +struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; +struct btrfs_super_block *disk_super = fs_info->super_copy; +struct btrfs_device *device; +u64 super_flags; + +/* +* We are updating the fsid, the thread leading to device_list_add() +* could race, so uuid_mutex is needed. +*/ +lockdep_assert_held (&uuid_mutex); + +/* +* The threads listed below may traverse dev_list but can do that without +* device_list_mutex: +* - All device ops and balance - as we are in btrfs_exclop_start. +* - Various dev_list readers - are using RCU. +* - btrfs_ioctl_fitrim() - is using RCU. +* +* For-read threads as below are using device_list_mutex: +* - Readonly scrub btrfs_scrub_dev() +* - Readonly scrub btrfs_scrub_progress() +* - btrfs_get_dev_stats() +*/ +lockdep_assert_held (&fs_devices->device_list_mutex); +list_splice_init_rcu (&fs_devices->devices, &seed_devices->devices, synchronize_rcu);list_for_each_entry (device, &seed_devices->devices, dev_list)
@@ -2585,13 +2613,10 @@ static int btrfs_prepare_sprout(struct btrfs_fs_info *fs_info)generate_random_uuid (fs_devices->fsid);memcpy (fs_devices->metadata_uuid, fs_devices->fsid,BTRFS_FSID_SIZE );memcpy (disk_super->fsid, fs_devices->fsid,BTRFS_FSID_SIZE ); -mutex_unlock (&fs_devices->device_list_mutex); super_flags =btrfs_super_flags (disk_super) & ~BTRFS_SUPER_FLAG_SEEDING ;btrfs_set_super_flags (disk_super, super_flags); - -return 0 ; }/*
@@ -2682,6 +2707,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_pathstruct super_block *sb = fs_info->sb;struct rcu_string *name;struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; +struct btrfs_fs_devices *seed_devices;u64 orig_super_total_bytes;u64 orig_super_num_devices;int seeding_dev =0 ;
@@ -2765,18 +2791,25 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_pathif (seeding_dev) {btrfs_clear_sb_rdonly (sb); - ret =btrfs_prepare_sprout (fs_info); -if (ret) { + +/* GFP_KERNEL allocation must not be under device_list_mutex */ + seed_devices =btrfs_init_sprout (fs_info); +if (IS_ERR (seed_devices)) { + ret =PTR_ERR (seed_devices);btrfs_abort_transaction (trans, ret); goto error_trans; } + } + +mutex_lock (&fs_devices->device_list_mutex); +if (seeding_dev) { +btrfs_setup_sprout (fs_info, seed_devices);btrfs_assign_next_active_device (fs_info->fs_devices->latest_dev, device); } device->fs_devices = fs_devices; -mutex_lock (&fs_devices->device_list_mutex);mutex_lock (&fs_info->chunk_mutex);list_add_rcu (&device->dev_list, &fs_devices->devices);list_add (&device->dev_alloc_list, &fs_devices->alloc_list);
@@ -2838,7 +2871,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path/* * fs_devices now represents the newly sprouted filesystem and -* its fsid has been changed by btrfs_prepare_sprout +* its fsid has been changed by btrfs_sprout_splice(). */ btrfs_sysfs_update_sprout_fsid (fs_devices); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 269/752 btrfs: restore active device pointers after failed sprout
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guanghui Yang <[email protected]>
[ Upstream commit e0b54613aabeb8e9da597f23b90c6a03d0981986 ]
btrfs_init_new_device() switches latest_dev and possibly s_bdev from the seed device to the new sprout device before creating the first writable chunks.
If chunk creation or the subsequent sprout setup fails, the error path releases the new device without switching those pointers back. btrfs_show_devname() can then dereference the freed latest_dev and crash.
Restore the active device pointers to the latest seed device before removing and releasing the failed sprout device.
--- fs/btrfs/volumes.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/volumes.c +2 -0
@@ -2918,6 +2918,8 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path error_sysfs:btrfs_sysfs_remove_device (device);mutex_lock (&fs_info->fs_devices->device_list_mutex); +if (seeding_dev) +btrfs_assign_next_active_device (device, seed_devices->latest_dev);mutex_lock (&fs_info->chunk_mutex);if (!list_empty (&device->post_commit_list))list_del_init (&device->post_commit_list);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 270/752 scsi: mpt3sas: Use irq_set_affinity_and_hint()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nitesh Narayan Lal <[email protected]>
[ Upstream commit fdb8ed13a77270c8e6e05b3ff9f4cb2f57e16d6a ]
The driver uses irq_set_affinity_hint() specifically for the high IOPS queue interrupts for two purposes:
- To set the affinity_hint which is consumed by the userspace for distributing the interrupts
- To apply an affinity that it provides
The driver enforces its own affinity to bind the high IOPS queue interrupts to the local NUMA node. However, irq_set_affinity_hint() applying the provided cpumask as an affinity (if not NULL) for the interrupt is an undocumented side effect.
To remove this side effect irq_set_affinity_hint() has been marked as deprecated and new interfaces have been introduced. Hence, replace the irq_set_affinity_hint() with the new interface irq_set_affinity_and_hint() where the provided mask needs to be applied as the affinity and affinity_hint pointer needs to be set and replace with irq_update_affinity_hint() where only affinity_hint needs to be updated.
Stable-dep-of: e0d26fe176a8 ("scsi: mpt3sas: Avoid out-of-bounds cpumask_of_node() call in _base_assign_reply_queues()")
--- drivers/scsi/mpt3sas/mpt3sas_base.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_base.c +10 -11
@@ -3114,6 +3114,7 @@ _base_check_enable_msix(struct MPT3SAS_ADAPTER *ioc)void mpt3sas_base_free_irq (struct MPT3SAS_ADAPTER *ioc) { +unsigned int irq;struct adapter_reply_queue *reply_q, *next;if (list_empty (&ioc->reply_queue_list))
@@ -3126,9 +3127,10 @@ mpt3sas_base_free_irq(struct MPT3SAS_ADAPTER *ioc)continue ; } -if (ioc->smp_affinity_enable) -irq_set_affinity_hint (pci_irq_vector (ioc->pdev, - reply_q->msix_index),NULL ); +if (ioc->smp_affinity_enable) { + irq =pci_irq_vector (ioc->pdev, reply_q->msix_index); +irq_update_affinity_hint (irq,NULL ); + }free_irq (pci_irq_vector (ioc->pdev, reply_q->msix_index), reply_q);kfree (reply_q);
@@ -3195,18 +3197,15 @@ _base_request_irq(struct MPT3SAS_ADAPTER *ioc, u8 index)* @ioc: per adapter object * * The enduser would need to set the affinity via /proc/irq/#/smp_affinity -* -* It would nice if we could call irq_set_affinity, however it is not -* an exported symbol */ static void _base_assign_reply_queues (struct MPT3SAS_ADAPTER *ioc) { -unsigned int cpu, nr_cpus, nr_msix, index =0 ; +unsigned int cpu, nr_cpus, nr_msix, index =0 , irq;struct adapter_reply_queue *reply_q; -int local_numa_node;int iopoll_q_count = ioc->reply_queue_count - ioc->iopoll_q_start_index; +const struct cpumask *mask;if (!_base_is_controller_msix_enabled (ioc))return ;
@@ -3229,11 +3228,11 @@ _base_assign_reply_queues(struct MPT3SAS_ADAPTER *ioc)* corresponding to high iops queues. */ if (ioc->high_iops_queues) { - local_numa_node =dev_to_node (&ioc->pdev->dev); + mask =cpumask_of_node (dev_to_node (&ioc->pdev->dev));for (index =0 ; index < ioc->high_iops_queues; index++) { -irq_set_affinity_hint (pci_irq_vector (ioc->pdev, - index),cpumask_of_node (local_numa_node)); + irq =pci_irq_vector (ioc->pdev, index); +irq_set_affinity_and_hint (irq, mask); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 271/752 scsi: mpt3sas: Avoid out-of-bounds cpumask_of_node() call in _base_assign_reply_queues()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ivy Lopez <[email protected]>
[ Upstream commit e0d26fe176a8db6ccad4ab38c5bab29391c1946b ]
dev_to_node() can return NUMA_NO_NODE (-1) on systems without NUMA topology information for the PCI device, such as single-socket boards that don't expose device-to-node affinity. Passing -1 directly into cpumask_of_node() indexes node_to_cpumask_map[-1], an out-of-bounds array read caught by UBSAN:
UBSAN: array-index-out-of-bounds in arch/x86/include/asm/topology.h:72:28 index -1 is out of range for type 'cpumask *[1024]'
Fall back to cpu_online_mask when no NUMA node is available, rather than assuming dev_to_node() always returns a valid node index.
--- drivers/scsi/mpt3sas/mpt3sas_base.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/scsi/mpt3sas/mpt3sas_base.c +4 -1
@@ -3228,7 +3228,10 @@ _base_assign_reply_queues(struct MPT3SAS_ADAPTER *ioc)* corresponding to high iops queues. */ if (ioc->high_iops_queues) { - mask =cpumask_of_node (dev_to_node (&ioc->pdev->dev)); +int node =dev_to_node (&ioc->pdev->dev); + + mask = (node ==NUMA_NO_NODE ) ? + cpu_online_mask :cpumask_of_node (node);for (index =0 ; index < ioc->high_iops_queues; index++) { irq =pci_irq_vector (ioc->pdev, index);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 272/752 perf/core: Skip empty AUX records with only format flags
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Yan <[email protected]>
[ Upstream commit 8a7f5b5e860b5c113ca99acd5b1e9074f5c5af3c ]
perf_aux_output_end() emits a PERF_RECORD_AUX when the recorded size is nonzero or when any flag other than PERF_AUX_FLAG_OVERWRITE is set.
PMU format flags describe how an AUX payload is encoded. TRBE driver sets PERF_AUX_FLAG_CORESIGHT_FORMAT_RAW for raw trace buffers, causing an AUX record to be emitted even when no trace data.
This is noticeable when tracing a task with strace. Ptrace stops repeatedly end empty AUX transactions, producing many zero-sized PERF_RECORD_AUX records. For example:
perf record -e cs_etm//u -m,128M -- strace ls
perf script -D 2>&1 |
awk '/PERF_RECORD_AUX offset/ {
for (i = 1; i <= NF; i++)
if ($i == "size:" && $(i + 1) == "0")
count++
}
END { print count }'
165This recording contains 165 zero-sized AUX records which provide no useful information to userspace.
Ignore PERF_AUX_FLAG_PMU_FORMAT_TYPE_MASK, together with PERF_AUX_FLAG_OVERWRITE, when deciding whether an empty AUX record is useful. Zero-sized records carrying TRUNCATED, PARTIAL or COLLISION are still emitted.
--- kernel/events/ring_buffer.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
kernel/events/ring_buffer.c +7 -2
@@ -501,7 +501,10 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size)/* * Only send RECORD_AUX if we have something useful to communicate * -* Note: the OVERWRITE records by themselves are not considered +* PMU_FORMAT bits identify the PMU type rather than an AUX event +* has occurred, so ignore them for zero-sized records. +* +* The OVERWRITE records by themselves are not considered * useful, as they don't communicate any *new* information, * aside from the short-lived offset, that becomes history at * the next event sched-in and therefore isn't useful.
@@ -510,7 +513,9 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size)* offset. So, from now on we don't output AUX records that * have *only* OVERWRITE flag set. */ -if (size || (handle->aux_flags & ~(u64 )PERF_AUX_FLAG_OVERWRITE )) +if (size || + (handle->aux_flags & ~(u64)(PERF_AUX_FLAG_PMU_FORMAT_TYPE_MASK | +PERF_AUX_FLAG_OVERWRITE )))perf_event_aux_event (handle->event, aux_head, size, handle->aux_flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 273/752 locking/lockdep: Introduce lock_sync()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boqun Feng <[email protected]>
[ Upstream commit 2f1f043e7bea3fbf4c1869df2f7a0312bc8ca2bf ]
Currently, functions like synchronize_srcu() do not have lockdep annotations resembling those of other write-side locking primitives. Such annotations might look as follows:
lock_acquire(); lock_release();
Such annotations would tell lockdep that synchronize_srcu() acts like an empty critical section that waits for other (read-side) critical sections to finish. This would definitely catch some deadlock, but as pointed out by Paul Mckenney [1], this could also introduce false positives because of irq-safe/unsafe detection. Of course, there are tricks could help with this:
might_sleep(); // Existing statement in __synchronize_srcu().
if (IS_ENABLED(CONFIG_PROVE_LOCKING)) {
local_irq_disable();
lock_acquire();
lock_release();
local_irq_enable();
}But it would be better for lockdep to provide a separate annonation for functions like synchronize_srcu(), so that people won't need to repeat the ugly tricks above.
Therefore introduce lock_sync(), which is simply an lock+unlock pair with no irq safe/unsafe deadlock check. This works because the to-be-annontated functions do not create real critical sections, and there is therefore no way that irq can create extra dependencies.
[1]: https://lore.kernel.org/lkml/20180412021233.ewncg5jjuzjw3x62@tardis/
Stable-dep-of: 02c6be7d675b ("locking/lockdep: Invalidate stale class_cache entries for zapped classes")
--- include/linux/lockdep.h | 5 +++++ kernel/locking/lockdep.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+)
include/linux/lockdep.h +5 -0
@@ -272,6 +272,10 @@ extern void lock_acquire(struct lockdep_map *lock, unsigned int subclass,extern void lock_release (struct lockdep_map *lock,unsigned long ip); +extern void lock_sync (struct lockdep_map *lock,unsigned int subclass, +int read,int check,struct lockdep_map *nest_lock, +unsigned long ip); +/* lock_is_held_type() returns */ #define LOCK_STATE_UNKNOWN -1#define LOCK_STATE_NOT_HELD 0
@@ -572,6 +576,7 @@ do { \#define lock_map_acquire_read (l) lock_acquire_shared_recursive(l, 0, 0, NULL, _THIS_IP_)#define lock_map_acquire_tryread (l) lock_acquire_shared_recursive(l, 0, 1, NULL, _THIS_IP_)#define lock_map_release (l) lock_release(l, _THIS_IP_) +#define lock_map_sync (l) lock_sync(l, 0, 0, 1, NULL, _THIS_IP_)#ifdef CONFIG_PROVE_LOCKING # define might_lock (lock) \
kernel/locking/lockdep.c +34 -0
@@ -5649,6 +5649,40 @@ void lock_release(struct lockdep_map *lock, unsigned long ip) }EXPORT_SYMBOL_GPL (lock_release); +/* +* lock_sync() - A special annotation for synchronize_{s,}rcu()-like API. +* +* No actual critical section is created by the APIs annotated with this: these +* APIs are used to wait for one or multiple critical sections (on other CPUs +* or threads), and it means that calling these APIs inside these critical +* sections is potential deadlock. +* +* This annotation acts as an acquire+release annotation pair with hardirqoff +* being 1. Since there's no critical section, no interrupt can create extra +* dependencies "inside" the annotation, hardirqoff == 1 allows us to avoid +* false positives. +*/ +void lock_sync (struct lockdep_map *lock,unsigned subclass,int read, +int check,struct lockdep_map *nest_lock,unsigned long ip) +{ +unsigned long flags; + +if (unlikely (!lockdep_enabled ())) +return ; + +raw_local_irq_save (flags); +check_flags (flags); + +lockdep_recursion_inc (); +__lock_acquire (lock, subclass,0 , read, check,1 , nest_lock, ip,0 ,0 ); + +if (__lock_release (lock, ip)) +check_chain_key (current); +lockdep_recursion_finish (); +raw_local_irq_restore (flags); +} +EXPORT_SYMBOL_GPL (lock_sync); + noinstr int lock_is_held_type(const struct lockdep_map *lock, int read) {unsigned long flags;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 274/752 locking/lockdep: Improve the deadlock scenario print for sync and read lock
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boqun Feng <[email protected]>
[ Upstream commit 0471db447cb7de56bbe2fedd9256b4d2b8ef642a ]
Lock scenario print is always a weak spot of lockdep splats. Improvement can be made if we rework the dependency search and the error printing.
However without touching the graph search, we can improve a little for the circular deadlock case, since we have the to-be-added lock dependency, and know whether these two locks are read/write/sync.
In order to know whether a held_lock is sync or not, a bit was "stolen" from ->references, which reduce our limit for the same lock class nesting from 2^12 to 2^11, and it should still be good enough.
Besides, since we now have bit in held_lock for sync, we don't need the "hardirqoffs being 1" trick, and also we can avoid the __lock_release() if we jump out of __lock_acquire() before the held_lock stored.
With these changes, a deadlock case evolved with read lock and sync gets a better print-out from:
[...] Possible unsafe locking scenario: [...] [...] CPU0 CPU1 [...] ---- ---- [...] lock(srcuA); [...] lock(srcuB); [...] lock(srcuA); [...] lock(srcuB);
to
[...] Possible unsafe locking scenario: [...] [...] CPU0 CPU1 [...] ---- ---- [...] rlock(srcuA); [...] lock(srcuB); [...] lock(srcuA); [...] sync(srcuB);
Stable-dep-of: 02c6be7d675b ("locking/lockdep: Invalidate stale class_cache entries for zapped classes")
--- include/linux/lockdep.h | 3 ++- kernel/locking/lockdep.c | 48 ++++++++++++++++++++++++++-------------- 2 files changed, 34 insertions(+), 17 deletions(-)
include/linux/lockdep.h +2 -1
@@ -138,7 +138,8 @@ struct held_lock { unsigned int read:2; /* see lock_acquire() comment */ unsigned int check:1; /* see lock_acquire() comment */ unsigned int hardirqs_off:1; - unsigned int references:12; /* 32 bits */ + unsigned int sync:1; + unsigned int references:11; /* 32 bits */unsigned int pin_count; };
kernel/locking/lockdep.c +32 -16
120 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 275/752 lockdep: Add lock_set_cmp_fn() annotation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kent Overstreet <[email protected]>
[ Upstream commit eb1cfd09f788e39948a82be8063e54e40dd018d9 ]
This implements a new interface to lockdep, lock_set_cmp_fn(), for defining a custom ordering when taking multiple locks of the same class.
This is an alternative to subclasses, but can not fully replace them since subclasses allow lock hierarchies with other clasees inter-twined, while this relies on pure class nesting.
Specifically, if A is our nesting class then:
A/0 <- B <- A/1
Would be a valid lock order with subclasses (each subclass really is a full class from the validation PoV) but not with this annotation, which requires all nesting to be consecutive.
Example output:
| ============================================
| WARNING: possible recursive locking detected
| 6.2.0-rc8-00003-g7d81e591ca6a-dirty #15 Not tainted
| --------------------------------------------
| kworker/14:3/938 is trying to acquire lock:
| ffff8880143218c8 (&b->lock l=0 0:2803368){++++}-{3:3}, at: bch_btree_node_get.part.0+0x81/0x2b0
|
| but task is already holding lock:
| ffff8880143de8c8 (&b->lock l=1 1048575:9223372036854775807){++++}-{3:3}, at: __bch_btree_map_nodes+0xea/0x1e0
| and the lock comparison function returns 1:
|
| other info that might help us debug this:
| Possible unsafe locking scenario:
|
| CPU0
| ----
| lock(&b->lock l=1 1048575:9223372036854775807);
| lock(&b->lock l=0 0:2803368);
|
| *** DEADLOCK ***
|
| May be due to missing lock nesting notation
|
| 3 locks held by kworker/14:3/938:
| #0: ffff888005ea9d38 ((wq_completion)bcache){+.+.}-{0:0}, at: process_one_work+0x1ec/0x530
| #1: ffff8880098c3e70 ((work_completion)(&cl->work)#3){+.+.}-{0:0}, at: process_one_work+0x1ec/0x530
| #2: ffff8880143de8c8 (&b->lock l=1 1048575:9223372036854775807){++++}-{3:3}, at: __bch_btree_map_nodes+0xea/0x1e0Stable-dep-of: 02c6be7d675b ("locking/lockdep: Invalidate stale class_cache entries for zapped classes")
--- include/linux/lockdep.h | 8 +++ include/linux/lockdep_types.h | 8 +++ kernel/locking/lockdep.c | 118 +++++++++++++++++++++++++--------- 3 files changed, 103 insertions(+), 31 deletions(-)
include/linux/lockdep.h +8 -0
@@ -434,6 +434,14 @@ extern int lockdep_is_held(const void *);#endif /* !LOCKDEP */ +#ifdef CONFIG_PROVE_LOCKING +void lockdep_set_lock_cmp_fn (struct lockdep_map *,lock_cmp_fn ,lock_print_fn ); + +#define lock_set_cmp_fn (lock, ...) lockdep_set_lock_cmp_fn(&(lock)->dep_map, __VA_ARGS__) +#else +#define lock_set_cmp_fn (lock, ...) do { } while (0) +#endif +enum xhlock_context_t {XHLOCK_HARD ,XHLOCK_SOFT ,
include/linux/lockdep_types.h +8 -0
@@ -84,6 +84,11 @@ struct lock_trace;#define LOCKSTAT_POINTS 4 +struct lockdep_map ; +typedef int (*lock_cmp_fn )(const struct lockdep_map *a, +const struct lockdep_map *b); +typedef void (*lock_print_fn )(const struct lockdep_map *map); +/* * The lock-class itself. The order of the structure members matters. * reinit_class() zeroes the key member and all subsequent members.
@@ -109,6 +114,9 @@ struct lock_class {struct list_head locks_after, locks_before;const struct lockdep_subclass_key *key; +lock_cmp_fn cmp_fn; +lock_print_fn print_fn; +unsigned int subclass;unsigned int dep_gen_id;
kernel/locking/lockdep.c +87 -31
296 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 276/752 locking/lockdep: Invalidate stale class_cache entries for zapped classes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 02c6be7d675b21d81f0ba3a524346850a8c0e3bf ]
syzbot reported a lockdep splat hitting DEBUG_LOCKS_WARN_ON(1) in hlock_class() due to an invalid class_idx:
WARNING: kernel/locking/lockdep.c:238 at __lock_acquire+0x382/0x2cf0 kernel/locking/lockdep.c:5203 Workqueue: wg-crypt-wg0 wg_packet_tx_worker RIP: 0010:hlock_class kernel/locking/lockdep.c:238 [inline] RIP: 0010:check_wait_context kernel/locking/lockdep.c:4870 [inline] RIP: 0010:__lock_acquire+0x389/0x2cf0 kernel/locking/lockdep.c:5203 Call Trace: <IRQ> lock_acquire+0x106/0x350 kernel/locking/lockdep.c:5886 _raw_spin_lock+0x2e/0x40 kernel/locking/spinlock.c:173 tcp_tsq_handler+0x29/0x200 net/ipv4/tcp_output.c:1291 tcp_tsq_workfn+0x384/0x410 net/ipv4/tcp_output.c:1325 ...
When a lock class is zapped (e.g. during module unload or key unregistration), zap_class() clears the class's bit in lock_classes_in_use and removes it from the class hash table. However, existing lockdep_map instances embedded in data structures may still retain a pointer to the zapped class in their class_cache[] array.
When __lock_acquire() subsequently runs on such a lock, it finds lock->class_cache[subclass] != NULL, skipping register_lock_class() and assigning hlock->class_idx to the index of the zapped class. When check_wait_context() or hlock_class() inspects the held_lock, it finds !test_bit(class_idx, lock_classes_in_use) and warns. Furthermore, if the zapped slot is subsequently re-allocated to an unrelated lock key, the stale class_cache entry would erroneously match the unrelated class (ABA issue).
Add lock_class_cache_is_valid() to validate that the cached class is within lock_classes bounds, still allocated in lock_classes_in_use (using uninstrumented arch_test_bit() in __always_inline context so it is safe in noinstr contexts like match_held_lock()), and that class->key matches the expected subkey (taking lockdep_set_subclass() overrides into account). Also use READ_ONCE()/WRITE_ONCE() when accessing class_cache[]. If the entry is invalid or stale, fall back to register_lock_class() / look_up_lock_class().
--- kernel/locking/lockdep.c | 50 +++++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 8 deletions(-)
kernel/locking/lockdep.c +42 -8
@@ -903,6 +903,34 @@ look_up_lock_class(const struct lockdep_map *lock, unsigned int subclass)return NULL ; } +static __always_inline bool lock_class_cache_is_valid(const struct lockdep_map *lock, +const struct lock_class *class, +unsigned int subclass) +{ +unsigned int class_subclass; + +if (!class) +return false; + +if (unlikely (class < lock_classes || class >= lock_classes +MAX_LOCKDEP_KEYS )) +return false; + +if (unlikely (!arch_test_bit (class - lock_classes, lock_classes_in_use))) +return false; + +if (unlikely (!lock->key)) +return false; + + class_subclass = subclass ? subclass : class->subclass; +if (unlikely (class_subclass >=MAX_LOCKDEP_SUBCLASSES )) +return false; + +if (unlikely (READ_ONCE (class->key) != lock->key->subkeys + class_subclass)) +return false; + +return true; +} +/* * Static locks do not have their class-keys yet - for them the key is * the lock object itself. If the lock is in the per cpu area, the
@@ -1328,9 +1356,9 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force) out_set_class_cache:if (!subclass || force) - lock->class_cache[0 ] = class; +WRITE_ONCE (lock->class_cache[0 ], class);else if (subclass <NR_LOCKDEP_CACHING_CLASSES ) - lock->class_cache[subclass] = class; +WRITE_ONCE (lock->class_cache[subclass], class);/* * Hash collision, did we smoke some? We found a class with a matching
@@ -4809,7 +4837,7 @@ void lockdep_init_map_type(struct lockdep_map *lock, const char *name,int i;for (i =0 ; i <NR_LOCKDEP_CACHING_CLASSES ; i++) - lock->class_cache[i] =NULL ; +WRITE_ONCE (lock->class_cache[i],NULL );#ifdef CONFIG_LOCK_STAT lock->cpu =raw_smp_processor_id ();
@@ -4871,12 +4899,15 @@ EXPORT_SYMBOL_GPL(__lockdep_no_validate__);void lockdep_set_lock_cmp_fn (struct lockdep_map *lock,lock_cmp_fn cmp_fn,lock_print_fn print_fn) { -struct lock_class *class = lock->class_cache[0 ]; +struct lock_class *class =READ_ONCE (lock->class_cache[0 ]);unsigned long flags;raw_local_irq_save (flags);lockdep_recursion_inc (); +if (!lock_class_cache_is_valid (lock, class,0 )) + class =NULL ; +if (!class) class =register_lock_class (lock,0 ,0 );
@@ -4954,8 +4985,11 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,if (!prove_locking || lock->key == &__lockdep_no_validate__) check =0 ; -if (subclass <NR_LOCKDEP_CACHING_CLASSES ) - class = lock->class_cache[subclass]; +if (subclass <NR_LOCKDEP_CACHING_CLASSES ) { + class =READ_ONCE (lock->class_cache[subclass]); +if (!lock_class_cache_is_valid (lock, class, subclass)) + class =NULL ; + }/* * Not cached? */
@@ -5150,9 +5184,9 @@ static noinstr int match_held_lock(const struct held_lock *hlock,return 1 ;if (hlock->references) { -const struct lock_class *class = lock->class_cache[0 ]; +const struct lock_class *class =READ_ONCE (lock->class_cache[0 ]); -if (!class) +if (!lock_class_cache_is_valid (lock, class,0 )) class =look_up_lock_class (lock,0 );/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 277/752 ASoC: ux500: Fix MSP stream lifecycle handling
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit c37ba8fe00f264eee2fd18b0bff7c5f188136c51 ]
The trigger stop path drops the direction busy flag even though ALSA still owns the stream until shutdown. A later trigger cannot reliably restart it, shutdown may leave the block configured, and a second stream may overwrite shared duplex configuration.
Keep configured and running directions as separate state. Program shared settings only for the first direction, require a compatible configuration for the other half of a duplex stream, and enable the frame generator only while a provider stream is running. Also fix the RX-disable direction test and preserve the other direction multichannel setup.
--- sound/soc/ux500/ux500_msp_dai.c | 8 +- sound/soc/ux500/ux500_msp_i2s.c | 183 ++++++++++++++++++++++++-------- sound/soc/ux500/ux500_msp_i2s.h | 4 + 3 files changed, 149 insertions(+), 46 deletions(-)
sound/soc/ux500/ux500_msp_dai.c +6 -2
@@ -37,8 +37,10 @@ static int setup_pcm_multichan(struct snd_soc_dai *dai,if (drvdata->slots >1 ) { msp_config->multichannel_configured =1 ; - multi->tx_multichannel_enable = true; - multi->rx_multichannel_enable = true; + multi->tx_multichannel_enable = + msp_config->direction &MSP_DIR_TX ; + multi->rx_multichannel_enable = + msp_config->direction &MSP_DIR_RX ; multi->rx_comparison_enable_mode =MSP_COMPARISON_DISABLED ; multi->tx_channel_0_enable = drvdata->tx_mask;
@@ -195,6 +197,7 @@ static int setup_clocking(struct snd_soc_dai *dai,case SND_SOC_DAIFMT_CBM_CFM :dev_dbg (dai->dev,"%s: Codec is master.\n" , __func__); + msp_config->clock_provider = false; msp_config->iodelay =0x20 ; msp_config->rx_fsync_sel =0 ; msp_config->tx_fsync_sel =1 <<TFSSEL_SHIFT ;
@@ -207,6 +210,7 @@ static int setup_clocking(struct snd_soc_dai *dai,case SND_SOC_DAIFMT_CBS_CFS :dev_dbg (dai->dev,"%s: Codec is slave.\n" , __func__); + msp_config->clock_provider = true; msp_config->tx_clk_sel =TX_CLK_SEL_SRG ; msp_config->tx_fsync_sel =TX_SYNC_SRG_PROG ; msp_config->rx_clk_sel =RX_CLK_SEL_SRG ;
sound/soc/ux500/ux500_msp_i2s.c +139 -44
284 lines not on this page · raw message
sound/soc/ux500/ux500_msp_i2s.h +4 -0
@@ -463,6 +463,7 @@ struct ux500_msp_config {enum msp_data_size data_size;unsigned int def_elem_len;unsigned int iodelay; +bool clock_provider; };struct ux500_msp_dma_params {
@@ -480,8 +481,11 @@ struct ux500_msp {enum msp_state msp_state;int def_elem_len;unsigned int dir_busy; +unsigned int dir_running;int loopback_enable;unsigned int f_bitclk; +bool clock_provider; +struct ux500_msp_config config; };struct msp_i2s_platform_data ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 278/752 ASoC: ux500: remove platform_data support
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit 1766ac5248063c25d1fe46e04bb936c46313ed89 ]
The platform data definition for ux500 sound devices was removed six years ago after the DT conversion was completed, see commit 4b483ed0be8b ("ARM: ux500: cut some platform data").
Remove some leftover bits in the ASoC driver and just assume that it always gets probed using DT.
Stable-dep-of: 3415421a2b0b ("ASoC: ux500: Propagate MSP setup errors")
--- include/linux/platform_data/asoc-ux500-msp.h | 20 ---------- sound/soc/ux500/mop500.c | 8 ++-- sound/soc/ux500/ux500_msp_dai.c | 33 +-------------- sound/soc/ux500/ux500_msp_i2s.c | 33 +++------------ sound/soc/ux500/ux500_msp_i2s.h | 5 +-- sound/soc/ux500/ux500_pcm.c | 42 ++------------------ 6 files changed, 15 insertions(+), 126 deletions(-) delete mode 100644 include/linux/platform_data/asoc-ux500-msp.h
include/linux/platform_data/asoc-ux500-msp.h deleted +0 -20
@@ -1,20 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* -* Copyright (C) ST-Ericsson SA 2010 -* -* Author: Rabin Vincent <[email protected]> for ST-Ericsson -*/ - -#ifndef __MSP_H -#define __MSP_H - -#include <linux/platform_data/dma-ste-dma40.h> - -/* Platform data structure for a MSP I2S-device */ -struct msp_i2s_platform_data { -int id; -struct stedma40_chan_cfg *msp_i2s_dma_rx; -struct stedma40_chan_cfg *msp_i2s_dma_tx; -}; - -#endif
sound/soc/ux500/mop500.c +3 -5
@@ -111,11 +111,9 @@ static int mop500_probe(struct platform_device *pdev) mop500_card.dev = &pdev->dev; -if (np) { - ret =mop500_of_probe (pdev, np); -if (ret) -return ret; - } + ret =mop500_of_probe (pdev, np); +if (ret) +return ret;dev_dbg (&pdev->dev,"%s: Card %s: Set platform drvdata.\n" , __func__, mop500_card.name);
sound/soc/ux500/ux500_msp_dai.c +2 -31
@@ -17,7 +17,6 @@#include <linux/of.h> #include <linux/regulator/consumer.h> #include <linux/mfd/dbx500-prcmu.h> -#include <linux/platform_data/asoc-ux500-msp.h> #include <sound/soc.h> #include <sound/soc-dai.h>
@@ -688,26 +687,6 @@ static int ux500_msp_dai_of_probe(struct snd_soc_dai *dai)return 0 ; } -static int ux500_msp_dai_probe (struct snd_soc_dai *dai) -{ -struct ux500_msp_i2s_drvdata *drvdata =dev_get_drvdata (dai->dev); -struct msp_i2s_platform_data *pdata = dai->dev->platform_data; -int ret; - -if (!pdata) { - ret =ux500_msp_dai_of_probe (dai); -return ret; - } - - drvdata->msp->playback_dma_data.data_size = drvdata->slot_width; - drvdata->msp->capture_dma_data.data_size = drvdata->slot_width; - -snd_soc_dai_init_dma_data (dai, - &drvdata->msp->playback_dma_data, - &drvdata->msp->capture_dma_data); -return 0 ; -} -static const struct snd_soc_dai_ops ux500_msp_dai_ops[] = { { .set_sysclk = ux500_msp_dai_set_dai_sysclk,
@@ -722,7 +701,7 @@ static const struct snd_soc_dai_ops ux500_msp_dai_ops[] = { };static struct snd_soc_dai_driver ux500_msp_dai_drv = { - .probe = ux500_msp_dai_probe, + .probe = ux500_msp_dai_of_probe, .playback.channels_min =UX500_MSP_MIN_CHANNELS , .playback.channels_max =UX500_MSP_MAX_CHANNELS , .playback.rates =UX500_I2S_RATES ,
@@ -742,15 +721,8 @@ static const struct snd_soc_component_driver ux500_msp_component = {static int ux500_msp_drv_probe (struct platform_device *pdev) {struct ux500_msp_i2s_drvdata *drvdata; -struct msp_i2s_platform_data *pdata = pdev->dev.platform_data; -struct device_node *np = pdev->dev.of_node;int ret =0 ; -if (!pdata && !np) { -dev_err (&pdev->dev,"No platform data or Device Tree found\n" ); -return -ENODEV ; - } - drvdata =devm_kzalloc (&pdev->dev,sizeof (struct ux500_msp_i2s_drvdata ),GFP_KERNEL );
@@ -792,8 +764,7 @@ static int ux500_msp_drv_probe(struct platform_device *pdev)return ret; } - ret =ux500_msp_i2s_init_msp (pdev, &drvdata->msp, - pdev->dev.platform_data); + ret =ux500_msp_i2s_init_msp (pdev, &drvdata->msp);if (!drvdata->msp) { dev_err(&pdev->dev, "%s: ERROR: Failed to init MSP-struct (%d)!",
sound/soc/ux500/ux500_msp_i2s.c +5 -28
@@ -16,7 +16,6 @@#include <linux/slab.h> #include <linux/io.h> #include <linux/of.h> -#include <linux/platform_data/asoc-ux500-msp.h> #include <sound/soc.h>
@@ -737,18 +736,8 @@ int ux500_msp_i2s_close(struct ux500_msp *msp, unsigned int dir) }static int ux500_msp_i2s_of_init_msp (struct platform_device *pdev, -struct ux500_msp *msp, -struct msp_i2s_platform_data **platform_data) +struct ux500_msp *msp); { -struct msp_i2s_platform_data *pdata; - - *platform_data =devm_kzalloc (&pdev->dev, -sizeof (struct msp_i2s_platform_data ), -GFP_KERNEL ); - pdata = *platform_data; -if (!pdata) -return -ENOMEM ; - msp->playback_dma_data.dma_cfg =devm_kzalloc (&pdev->dev,sizeof (struct stedma40_chan_cfg ),GFP_KERNEL );
@@ -765,11 +754,9 @@ static int ux500_msp_i2s_of_init_msp(struct platform_device *pdev, }int ux500_msp_i2s_init_msp (struct platform_device *pdev, -struct ux500_msp **msp_p, -struct msp_i2s_platform_data *platform_data) +struct ux500_msp **msp_p) {struct resource *res =NULL ; -struct device_node *np = pdev->dev.of_node;struct ux500_msp *msp;int ret;
@@ -778,19 +765,9 @@ int ux500_msp_i2s_init_msp(struct platform_device *pdev,if (!msp)return -ENOMEM ; -if (!platform_data) { -if (np) { - ret =ux500_msp_i2s_of_init_msp (pdev, msp, - &platform_data); -if (ret) -return ret; - }else -return -EINVAL ; - }else { - msp->playback_dma_data.dma_cfg = platform_data->msp_i2s_dma_tx; - msp->capture_dma_data.dma_cfg = platform_data->msp_i2s_dma_rx; - msp->id = platform_data->id; - } + ret =ux500_msp_i2s_of_init_msp (pdev, msp); +if (ret) +return ret; msp->dev = &pdev->dev;
sound/soc/ux500/ux500_msp_i2s.h +1 -4
@@ -13,7 +13,6 @@#define UX500_MSP_I2S_H #include <linux/platform_device.h> -#include <linux/platform_data/asoc-ux500-msp.h> #define MSP_INPUT_FREQ_APB 48000000
@@ -488,10 +487,8 @@ struct ux500_msp {struct ux500_msp_config config; }; -struct msp_i2s_platform_data ;int ux500_msp_i2s_init_msp (struct platform_device *pdev, -struct ux500_msp **msp_p, -struct msp_i2s_platform_data *platform_data); +struct ux500_msp **msp_p);void ux500_msp_i2s_cleanup_msp (struct platform_device *pdev,struct ux500_msp *msp);int ux500_msp_i2s_open (struct ux500_msp *msp,struct ux500_msp_config *config);
sound/soc/ux500/ux500_pcm.c +4 -38
72 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 279/752 ASoC: ux500: Propagate MSP setup errors
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 3415421a2b0bc4e32bb5a9df24ed7863512d47a7 ]
The prepare callback continues with a partly initialized configuration when format setup fails. Probe likewise tests the allocated pointer instead of the return value, so an MMIO resource or mapping failure can be ignored after allocation succeeds.
Return configuration failures from prepare and test the MSP initialization result directly.
--- sound/soc/ux500/ux500_msp_dai.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
sound/soc/ux500/ux500_msp_dai.c +4 -2
@@ -470,7 +470,9 @@ static int ux500_msp_dai_prepare(struct snd_pcm_substream *substream,dev_dbg (dai->dev,"%s: MSP %d (%s): Enter (rate = %d).\n" , __func__, dai->id,snd_pcm_stream_str (substream), runtime->rate); -setup_msp_config (substream, dai, &msp_config); + ret =setup_msp_config (substream, dai, &msp_config); +if (ret) +return ret; ret =ux500_msp_i2s_open (drvdata->msp, &msp_config);if (ret <0 ) {
@@ -765,7 +767,7 @@ static int ux500_msp_drv_probe(struct platform_device *pdev) } ret =ux500_msp_i2s_init_msp (pdev, &drvdata->msp); -if (!drvdata->msp) { +if (ret) {dev_err (&pdev->dev,"%s: ERROR: Failed to init MSP-struct (%d)!" , __func__, ret);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 280/752 ASoC: ux500: Correct MSP frame and bit clock setup
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 94c18cea657c48680e4ee20b635b6c01f3eb352e ]
FRPER plus one is the number of bit clocks in a frame. It must follow the configured slot count and width. The legacy rate-dependent constants produce malformed frames; notably, a 16-slot, 16-bit frame is programmed as 278 rather than 256 clocks.
Derive the frame period from the TDM geometry and use the real functional clock rate. Validate that the requested bit clock has an exact, representable divider, program SCKDIV as divider minus one, and report the resulting bit clock using that same divisor.
--- sound/soc/ux500/ux500_msp_dai.c | 75 +++++++-------------------------- sound/soc/ux500/ux500_msp_dai.h | 11 ----- sound/soc/ux500/ux500_msp_i2s.c | 54 ++++++++++++++---------- sound/soc/ux500/ux500_msp_i2s.h | 2 - 4 files changed, 46 insertions(+), 96 deletions(-)
sound/soc/ux500/ux500_msp_dai.c +15 -60
@@ -61,72 +61,21 @@ static int setup_pcm_multichan(struct snd_soc_dai *dai,return 0 ; } -static int setup_frameper (struct snd_soc_dai *dai,unsigned int rate, -struct msp_protdesc *prot_desc) +static void setup_frameper (struct snd_soc_dai *dai, +struct msp_protdesc *prot_desc) {struct ux500_msp_i2s_drvdata *drvdata =dev_get_drvdata (dai->dev); -switch (drvdata->slots) { -case 1 : -switch (rate) { -case 8000 : - prot_desc->frame_period = -FRAME_PER_SINGLE_SLOT_8_KHZ ; -break ; - -case 16000 : - prot_desc->frame_period = -FRAME_PER_SINGLE_SLOT_16_KHZ ; -break ; - -case 44100 : - prot_desc->frame_period = -FRAME_PER_SINGLE_SLOT_44_1_KHZ ; -break ; - -case 48000 : - prot_desc->frame_period = -FRAME_PER_SINGLE_SLOT_48_KHZ ; -break ; - -default : -dev_err (dai->dev, -"%s: Error: Unsupported sample-rate (freq = %d)!\n" , - __func__, rate); -return -EINVAL ; - } -break ; - -case 2 : - prot_desc->frame_period =FRAME_PER_2_SLOTS ; -break ; - -case 8 : - prot_desc->frame_period =FRAME_PER_8_SLOTS ; -break ; - -case 16 : - prot_desc->frame_period =FRAME_PER_16_SLOTS ; -break ; -default : -dev_err (dai->dev, -"%s: Error: Unsupported slot-count (slots = %d)!\n" , - __func__, drvdata->slots); -return -EINVAL ; - } - - prot_desc->clocks_per_frame = - prot_desc->frame_period+1 ; + prot_desc->clocks_per_frame = drvdata->slots * drvdata->slot_width; + prot_desc->frame_period = prot_desc->clocks_per_frame -1 ;dev_dbg (dai->dev,"%s: Clocks per frame: %u\n" , __func__, prot_desc->clocks_per_frame); - -return 0 ; } -static int setup_pcm_framing (struct snd_soc_dai *dai,unsigned int rate, -struct msp_protdesc *prot_desc) +static int setup_pcm_framing (struct snd_soc_dai *dai, +struct msp_protdesc *prot_desc) {struct ux500_msp_i2s_drvdata *drvdata =dev_get_drvdata (dai->dev);
@@ -167,7 +116,9 @@ static int setup_pcm_framing(struct snd_soc_dai *dai, unsigned int rate, prot_desc->tx_elem_len_2 =MSP_ELEM_LEN_16 ; prot_desc->rx_elem_len_2 =MSP_ELEM_LEN_16 ; -return setup_frameper (dai, rate, prot_desc); +setup_frameper (dai, prot_desc); + +return 0 ; } static int setup_clocking(struct snd_soc_dai *dai,
@@ -368,7 +319,7 @@ static int setup_msp_config(struct snd_pcm_substream *substream,if (ret <0 )return ret; - ret =setup_pcm_framing (dai, runtime->rate, prot_desc); + ret =setup_pcm_framing (dai, prot_desc);if (ret <0 )return ret;
@@ -736,7 +687,6 @@ static int ux500_msp_drv_probe(struct platform_device *pdev) drvdata->tx_mask =0x01 ; drvdata->rx_mask =0x01 ; drvdata->slot_width =16 ; - drvdata->master_clk =MSP_INPUT_FREQ_APB ; drvdata->reg_vape =devm_regulator_get (&pdev->dev,"v-ape" );if (IS_ERR (drvdata->reg_vape)) {
@@ -765,6 +715,11 @@ static int ux500_msp_drv_probe(struct platform_device *pdev) __func__, ret);return ret; } + drvdata->master_clk =clk_get_rate (drvdata->clk); +if (!drvdata->master_clk) { +dev_err (&pdev->dev,"MSP clock has no rate\n" ); +return -EINVAL ; + } ret =ux500_msp_i2s_init_msp (pdev, &drvdata->msp);if (ret) {
sound/soc/ux500/ux500_msp_dai.h +0 -11
@@ -24,17 +24,6 @@#define UX500_I2S_FORMATS (SNDRV_PCM_FMTBIT_S16_LE) -#define FRAME_PER_SINGLE_SLOT_8_KHZ 31 -#define FRAME_PER_SINGLE_SLOT_16_KHZ 124 -#define FRAME_PER_SINGLE_SLOT_44_1_KHZ 63 -#define FRAME_PER_SINGLE_SLOT_48_KHZ 49 -#define FRAME_PER_2_SLOTS 31 -#define FRAME_PER_8_SLOTS 138 -#define FRAME_PER_16_SLOTS 277 - -#define UX500_MSP_INTERNAL_CLOCK_FREQ 40000000 -#define UX500_MSP1_INTERNAL_CLOCK_FREQ UX500_MSP_INTERNAL_CLOCK_FREQ -#define UX500_MSP_MIN_CHANNELS 1#define UX500_MSP_MAX_CHANNELS 8
sound/soc/ux500/ux500_msp_i2s.c +31 -23
78 lines not on this page · raw message
sound/soc/ux500/ux500_msp_i2s.h +0 -2
@@ -14,8 +14,6 @@#include <linux/platform_device.h> -#define MSP_INPUT_FREQ_APB 48000000 -/*** Stereo mode. Used for APB data accesses as 16 bits accesses (mono), * 32 bits accesses (stereo). ***/
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 281/752 ASoC: ux500: Validate MSP DAI configuration
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 9ccbacf5a0120964fc1ffacb8151e3347bee9287 ]
Installing channel constraints from hw_params is too late to affect the parameters being committed. The driver consequently accepts channel counts which disagree with the I2S or TDM setup. It also silently truncates out-of-range slot masks and accepts inverted bit clock formats which prepare then rejects.
Validate the selected channel count directly, reject invalid masks before changing cached TDM state, and implement all four standard clock and frame inversion combinations. Use the requested format in validation diagnostics.
--- sound/soc/ux500/ux500_msp_dai.c | 41 ++++++++++++++++++++++----------- sound/soc/ux500/ux500_msp_i2s.c | 7 ++++-- sound/soc/ux500/ux500_msp_i2s.h | 1 + 3 files changed, 33 insertions(+), 16 deletions(-)
sound/soc/ux500/ux500_msp_dai.c +27 -14
@@ -132,7 +132,16 @@ static int setup_clocking(struct snd_soc_dai *dai,case SND_SOC_DAIFMT_NB_IF : msp_config->tx_fsync_pol ^=1 <<TFSPOL_SHIFT ; msp_config->rx_fsync_pol ^=1 <<RFSPOL_SHIFT ; +break ; + +case SND_SOC_DAIFMT_IB_NF : + msp_config->bclk_inverted = true; +break ; +case SND_SOC_DAIFMT_IB_IF : + msp_config->bclk_inverted = true; + msp_config->tx_fsync_pol ^=1 <<TFSPOL_SHIFT ; + msp_config->rx_fsync_pol ^=1 <<RFSPOL_SHIFT ;break ;default :
@@ -455,7 +464,6 @@ static int ux500_msp_dai_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) {unsigned int mask, slots_active; -struct snd_pcm_runtime *runtime = substream->runtime;struct ux500_msp_i2s_drvdata *drvdata =dev_get_drvdata (dai->dev); dev_dbg(dai->dev, "%s: MSP %d (%s): Enter.\n",
@@ -463,9 +471,8 @@ static int ux500_msp_dai_hw_params(struct snd_pcm_substream *substream,switch (drvdata->fmt &SND_SOC_DAIFMT_FORMAT_MASK ) {case SND_SOC_DAIFMT_I2S : -snd_pcm_hw_constraint_minmax (runtime, -SNDRV_PCM_HW_PARAM_CHANNELS , -1 ,2 ); +if (params_channels (params) <1 ||params_channels (params) >2 ) +return -EINVAL ;break ;case SND_SOC_DAIFMT_DSP_B :
@@ -477,9 +484,8 @@ static int ux500_msp_dai_hw_params(struct snd_pcm_substream *substream, slots_active =hweight32 (mask);dev_dbg (dai->dev,"TDM-slots active: %d" , slots_active); -snd_pcm_hw_constraint_single (runtime, -SNDRV_PCM_HW_PARAM_CHANNELS , - slots_active); +if (!slots_active ||params_channels (params) != slots_active) +return -EINVAL ;break ;default :
@@ -512,20 +518,21 @@ static int ux500_msp_dai_set_dai_fmt(struct snd_soc_dai *dai,default :dev_err (dai->dev,"%s: Error: Unsupported protocol/master (fmt = 0x%x)!\n" , - __func__, drvdata->fmt); + __func__, fmt);return -EINVAL ; }switch (fmt &SND_SOC_DAIFMT_INV_MASK ) {case SND_SOC_DAIFMT_NB_NF :case SND_SOC_DAIFMT_NB_IF : +case SND_SOC_DAIFMT_IB_NF :case SND_SOC_DAIFMT_IB_IF :break ;default :dev_err (dai->dev,"%s: Error: Unsupported inversion (fmt = 0x%x)!\n" , - __func__, drvdata->fmt); + __func__, fmt);return -EINVAL ; }
@@ -559,17 +566,23 @@ static int ux500_msp_dai_set_tdm_slot(struct snd_soc_dai *dai, __func__, slots);return -EINVAL ; } - drvdata->slots = slots; -if (!(slot_width ==16 )) { +if (slot_width !=16 ) {dev_err (dai->dev,"%s: Error: Unsupported slot-width (%d)!\n" , __func__, slot_width);return -EINVAL ; } - drvdata->slot_width = slot_width; - drvdata->tx_mask = tx_mask & cap; - drvdata->rx_mask = rx_mask & cap; +if ((tx_mask | rx_mask) & ~cap) { +dev_err (dai->dev,"%s: Slot mask exceeds %d slots\n" , + __func__, slots); +return -EINVAL ; + } + + drvdata->slots = slots; + drvdata->slot_width = slot_width; + drvdata->tx_mask = tx_mask; + drvdata->rx_mask = rx_mask;return 0 ; }
sound/soc/ux500/ux500_msp_i2s.c +5 -2
@@ -203,10 +203,12 @@ static int configure_protocol(struct ux500_msp *msp,/* The code below should not be separated. */ temp_reg =readl (msp->registers +MSP_GCR ) & ~TX_CLK_POL_RISING ; - temp_reg |=MSP_TX_CLKPOL_BIT (~protdesc->tx_clk_pol); + temp_reg |=MSP_TX_CLKPOL_BIT (!protdesc->tx_clk_pol ^ + config->bclk_inverted);writel (temp_reg, msp->registers +MSP_GCR ); temp_reg =readl (msp->registers +MSP_GCR ) & ~RX_CLK_POL_RISING ; - temp_reg |=MSP_RX_CLKPOL_BIT (protdesc->rx_clk_pol); + temp_reg |=MSP_RX_CLKPOL_BIT (protdesc->rx_clk_pol ^ + config->bclk_inverted);writel (temp_reg, msp->registers +MSP_GCR );return 0 ;
@@ -457,6 +459,7 @@ static bool ux500_msp_config_compatible(struct ux500_msp *msp, active->data_size == config->data_size && active->def_elem_len == config->def_elem_len && active->clock_provider == config->clock_provider && + active->bclk_inverted == config->bclk_inverted && !memcmp (&active->protdesc, &config->protdesc,sizeof (active->protdesc)); }
sound/soc/ux500/ux500_msp_i2s.h +1 -0
@@ -461,6 +461,7 @@ struct ux500_msp_config {unsigned int def_elem_len;unsigned int iodelay;bool clock_provider; +bool bclk_inverted; };struct ux500_msp_dma_params {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 282/752 ASoC: ux500: remove stedma40 references
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit aafe9375b386010e28614f58499d199250a16874 ]
ux500_pcm_request_chan() is never called because the dma channels are already set up from DT. Remove this, along with the ux500_msp_dma_params structure.
Stable-dep-of: 4fb67925f33a ("ASoC: ux500: Request the MSP MMIO resource")
--- sound/soc/ux500/ux500_msp_dai.c | 4 +-- sound/soc/ux500/ux500_msp_i2s.c | 41 +------------------------------ sound/soc/ux500/ux500_msp_i2s.h | 9 +------ sound/soc/ux500/ux500_pcm.c | 43 +-------------------------------- 4 files changed, 5 insertions(+), 92 deletions(-)
sound/soc/ux500/ux500_msp_dai.c +2 -2
@@ -642,8 +642,8 @@ static int ux500_msp_dai_of_probe(struct snd_soc_dai *dai)if (!capture_dma_data)return -ENOMEM ; - playback_dma_data->addr = drvdata->msp->playback_dma_data.tx_rx_addr; - capture_dma_data->addr = drvdata->msp->capture_dma_data.tx_rx_addr; + playback_dma_data->addr = drvdata->msp->tx_rx_addr; + capture_dma_data->addr = drvdata->msp->tx_rx_addr; playback_dma_data->maxburst =4 ; capture_dma_data->maxburst =4 ;
sound/soc/ux500/ux500_msp_i2s.c +1 -40
70 lines not on this page · raw message
sound/soc/ux500/ux500_msp_i2s.h +1 -8
@@ -464,18 +464,11 @@ struct ux500_msp_config {bool bclk_inverted; }; -struct ux500_msp_dma_params { -unsigned int data_size; -dma_addr_t tx_rx_addr; -struct stedma40_chan_cfg *dma_cfg; -}; -struct ux500_msp {int id;void __iomem *registers;struct device *dev; -struct ux500_msp_dma_params playback_dma_data; -struct ux500_msp_dma_params capture_dma_data; +dma_addr_t tx_rx_addr;enum msp_state msp_state;int def_elem_len;unsigned int dir_busy;
sound/soc/ux500/ux500_pcm.c +1 -42
67 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 283/752 ASoC: ux500: Request the MSP MMIO resource
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 4fb67925f33ad789e9e00903a73306ed40f7ae32 ]
A bare devm_ioremap() neither reserves the register range nor preserves the platform resource error. This permits another driver to claim the same range and reports every mapping failure as an allocation failure.
Use the managed platform resource helper, retaining the resolved resource only to derive the DMA register address.
--- sound/soc/ux500/ux500_msp_i2s.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
sound/soc/ux500/ux500_msp_i2s.c +4 -14
@@ -735,7 +735,7 @@ int ux500_msp_i2s_close(struct ux500_msp *msp, unsigned int dir)int ux500_msp_i2s_init_msp (struct platform_device *pdev,struct ux500_msp **msp_p) { -struct resource *res =NULL ; +struct resource *res;struct ux500_msp *msp; *msp_p =devm_kzalloc (&pdev->dev,sizeof (struct ux500_msp ),GFP_KERNEL );
@@ -745,20 +745,10 @@ int ux500_msp_i2s_init_msp(struct platform_device *pdev, msp->dev = &pdev->dev; - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (res ==NULL ) { -dev_err (&pdev->dev,"%s: ERROR: Unable to get resource!\n" , - __func__); -return -ENOMEM ; - } - + msp->registers =devm_platform_get_and_ioremap_resource (pdev,0 , &res); +if (IS_ERR (msp->registers)) +return PTR_ERR (msp->registers); msp->tx_rx_addr = res->start +MSP_DR ; - msp->registers =devm_ioremap (&pdev->dev, res->start, -resource_size (res)); -if (msp->registers ==NULL ) { -dev_err (&pdev->dev,"%s: ERROR: ioremap failed!\n" , __func__); -return -ENOMEM ; - } msp->msp_state =MSP_STATE_IDLE ; msp->loopback_enable =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 284/752 ASoC: ux500: Program the MSP FIFO watermarks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 2519439b4b5f6ee95879b1a44fc373127291b1e4 ]
The DMA engine is configured for four-element bursts, but the MSP driver never programs the FIFO watermark register and instead depends on its previous or reset value. The DB8500 DMA request protocol requires the peripheral watermark to match the DMA packet size.
Program four-element receive and transmit watermarks when configuring the first direction, before enabling MSP DMA requests.
--- sound/soc/ux500/ux500_msp_i2s.c | 2 ++ sound/soc/ux500/ux500_msp_i2s.h | 5 +++++ 2 files changed, 7 insertions(+)
sound/soc/ux500/ux500_msp_i2s.c +2 -0
@@ -509,6 +509,8 @@ int ux500_msp_i2s_open(struct ux500_msp *msp, old_reg &= ~mask; new_reg |= old_reg;writel (new_reg, msp->registers +MSP_GCR ); +writel (MSP_WMRK_TX_4_ELEMENTS |MSP_WMRK_RX_4_ELEMENTS , + msp->registers +MSP_WMRK ); } res =enable_msp (msp, config, first);
sound/soc/ux500/ux500_msp_i2s.h +5 -0
@@ -64,6 +64,7 @@ enum msp_direction {#define MSP_SRG 0x10#define MSP_FLR 0x14#define MSP_DMACR 0x18 +#define MSP_WMRK 0x1c#define MSP_IMSC 0x20#define MSP_RIS 0x24
@@ -230,6 +231,10 @@ enum msp_direction {#define RDMAE_SHIFT 0#define TDMAE_SHIFT 1 +/* FIFO watermark register */ +#define MSP_WMRK_RX_4_ELEMENTS BIT(0) +#define MSP_WMRK_TX_4_ELEMENTS BIT(3) +/* Interrupt Register */ #define RX_SERVICE_INT BIT(0)#define RX_OVERRUN_ERROR_INT BIT(1)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 285/752 btrfs: do not force reloc root creation during qgroup_account_snapshot()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit cacf35832292997018837e484283f95a9301ebf5 ]
[BUG]
When running btrfs/252 with quota enabled through MKFS_OPTIONS="-O quota", it has a high chance to trigger the following kernel warning and flips the fs RO:
BTRFS info (device dm-2): relocating block group 30408704 flags metadata|dup
------------[ cut here ]------------
WARNING: fs/btrfs/extent-tree.c:879 at lookup_inline_extent_backref+0x74b/0x960 [btrfs], CPU#4: btrfs/2173
CPU: 4 UID: 0 PID: 2173 Comm: btrfs Not tainted 7.2.0-rc6-custom+ #457 PREEMPT(full) 3adc6528fb66f7a55fe1095385818e742f200aab
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS unknown 02/02/2022
RIP: 0010:lookup_inline_extent_backref+0x74b/0x960 [btrfs]
Call Trace:
<TASK>
insert_inline_extent_backref+0x7c/0x160 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
__btrfs_inc_extent_ref+0xa9/0x270 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
__btrfs_run_delayed_refs+0x4af/0x11c0 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
btrfs_run_delayed_refs+0x9d/0xf0 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
create_pending_snapshot+0x39d/0xf00 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
create_pending_snapshots+0x9b/0xc0 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
btrfs_commit_transaction+0x280/0xeb0 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
prepare_to_relocate+0x147/0x200 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
relocate_block_group+0x6b/0x5e0 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
btrfs_relocate_block_group+0x92c/0x2380 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
btrfs_relocate_chunk+0x3f/0x1a0 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
btrfs_balance+0xa2c/0x19c0 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
btrfs_ioctl+0x2839/0x2d30 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
__x64_sys_ioctl+0x416/0x9a0
do_syscall_64+0xe1/0x790
entry_SYSCALL_64_after_hwframe+0x4b/0x53
</TASK>
---[ end trace 0000000000000000 ]---
BTRFS info (device dm-2): leaf 4593991680 gen 233 total ptrs 175 free space 5953 owner 2
BTRFS info (device dm-2): refs 3 lock_owner 2173 current 2173
item 0 key (166772736 METADATA_ITEM 1) itemoff 16250 itemsize 33
extent refs 1 gen 222 flags 2
ref#0: tree block backref root 266
[ Skip the tree dump ]
item 174 key (263225344 METADATA_ITEM 0) itemoff 10328 itemsize 33
extent refs 1 gen 162 flags 258
ref#0: tree block backref root 267
BTRFS error (device dm-2): extent item not found for insert, bytenr 179847168 num_bytes 16384 parent 4594335744 root_objectid 273 owner 0 offset 0
BTRFS error (device dm-2): failed to run delayed ref for logical 179847168 num_bytes 16384 type 182 action 1 ref_mod 1: -117[CAUSE]
The above error is showing that there is a tree reference to a metadata extent that is no longer there.
With "ref_verify" mount option (requires CONFIG_BTRFS_DEBUG), there is some extra debug output:
BTRFS error (device dm-2): dumping block entry [180961280 16384], num_refs 0, metadata 1, from disk 0
BTRFS error (device dm-2): root entry 256, num_refs 18446744073709551615
BTRFS error (device dm-2): root entry 273, num_refs 18446744073709551615
BTRFS error (device dm-2): Ref action 3, root 273, ref_root 273, parent 0, owner 0, offset 0, num_refs 1
btrfs_force_cow_block+0x129/0x7d0 [btrfs]
btrfs_cow_block+0x10a/0x250 [btrfs]
btrfs_search_slot+0x5eb/0xf40 [btrfs]
btrfs_insert_empty_items+0x3a/0x70 [btrfs]
insert_with_overflow+0x53/0x130 [btrfs]
btrfs_insert_dir_item+0x125/0x290 [btrfs]
btrfs_add_link+0xaa/0x410 [btrfs]
btrfs_rename+0x5ea/0xcd0 [btrfs]
btrfs_rename2+0x28/0x60 [btrfs]
vfs_rename+0x5b2/0xe10
filename_renameat2+0x244/0x430
__x64_sys_rename+0x48/0x70
do_syscall_64+0xe1/0x790
entry_SYSCALL_64_after_hwframe+0x4b/0x53
BTRFS error (device dm-2): Ref action 2, root 273, ref_root 273, parent 0, owner 0, offset 0, num_refs 18446744073709551615
btrfs_force_cow_block+0x327/0x7d0 [btrfs]
btrfs_cow_block+0x10a/0x250 [btrfs]
btrfs_search_slot+0x5eb/0xf40 [btrfs]
btrfs_lookup_file_extent+0x4d/0x70 [btrfs]
btrfs_drop_extents+0x151/0xf00 [btrfs]
insert_reserved_file_extent+0xfe/0x3e0 [btrfs]
btrfs_finish_one_ordered+0x549/0xc40 [btrfs]
btrfs_work_helper+0xde/0x350 [btrfs]
process_one_work+0x198/0x380
worker_thread+0x1c8/0x330
kthread+0xee/0x120
ret_from_fork+0x28f/0x310
ret_from_fork_asm+0x11/0x20
BTRFS error (device dm-2): Ref action 1, root 273, ref_root 0, parent 4594335744, owner 0, offset 0, num_refs 1
__btrfs_mod_ref+0x1c5/0x2d0 [btrfs]
btrfs_copy_root+0x262/0x390 [btrfs]
create_reloc_root+0xb9/0x370 [btrfs]
btrfs_init_reloc_root+0xb0/0x1b0 [btrfs]
record_root_in_trans+0xa6/0xd0 [btrfs]
create_pending_snapshot+0x383/0xf00 [btrfs]
create_pending_snapshots+0x9b/0xc0 [btrfs]
btrfs_commit_transaction+0x280/0xeb0 [btrfs]
prepare_to_relocate+0x147/0x200 [btrfs]
relocate_block_group+0x6b/0x5e0 [btrfs]
btrfs_relocate_block_group+0x92c/0x2380 [btrfs]
btrfs_relocate_chunk+0x3f/0x1a0 [btrfs]
btrfs_balance+0xa2c/0x19c0 [btrfs]
btrfs_ioctl+0x2839/0x2d30 [btrfs]
__x64_sys_ioctl+0x416/0x9a0
do_syscall_64+0xe1/0x790The above shows the direct cause, Ref action 3 is the oldest operation, which shows the tree block is created by COW. Then ref action 2 shows it's COWed away, by a metadata update, meaning the tree block is already released, should not be referred any more.
Then the final one, is trying to create a reloc tree for subvolume 273, and that reloc root creation is referring to the already dropped tree block.
The root cause is that, during qgroup_account_snapshot(), we are calling record_root_in_trans() with "force = true".
So if the root has no reloc root, we will create one, but at that timing it's already too late.
Normally reloc root should be created before the commit and current roots diverge, to avoid the same problem we are hitting.
But during relocation initialization, we are committing the current running transaction, with a new reloc_control attached halfway.
And if qgroup is enabled, the record_root_in_trans() with "force = true" calls will force reloc root creation even if we do not and should not create reloc root at that timing.
[FIX]
Do not force reloc root creation during record_root_in_trans() with "force = true" cases, which is only called by qgroup_account_snapshot().
If we're really under relocation, the reloc root should be created way early, before the commit and current root diverge. If the root has no reloc tree yet, it means we're still initializing the reloc, and do not need a reloc root.
So skipping the reloc tree creation in qgroup_account_snapshot() should be safe.
--- fs/btrfs/transaction.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
fs/btrfs/transaction.c +12 -1
@@ -464,8 +464,19 @@ static int record_root_in_trans(struct btrfs_trans_handle *trans,* through btrfs_record_root_in_trans without having to take the * lock. smp_wmb() makes sure that all the writes above are * done before we pop in the zero below +* +* If @force is true, it means the call is from +* qgroup_account_snapshot(), which only requires radix tree +* tracking. +* We should not force reloc root creation here, as the root +* may have already been modified, and in that case +* root->commit_root has already been dropped. +* +* Using that commit root will cause the reloc root to refer +* to a deleted extent, causing extent tree corruption. */ - ret =btrfs_init_reloc_root (trans, root); +if (!force) + ret =btrfs_init_reloc_root (trans, root);smp_mb__before_atomic ();clear_bit (BTRFS_ROOT_IN_TRANS_SETUP , &root->state); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 286/752 ipvs: fix reversed sequence option serialization
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <[email protected]>
[ Upstream commit b04578b74f2d3755548fe9e829e3b2a6c6f966a1 ]
hton_seq() expects the host-order source first and the unaligned network-order destination second. The version 1 sync sender passes these arguments in reverse for both sequence blocks. This leaves 24 bytes of the kmalloc-backed message unwritten. It may disclose stale heap data and replace the live connection sequence state with values read from the buffer.
Pass the connection sequence state as the source and the message payload as the destination for both blocks.
--- net/netfilter/ipvs/ip_vs_sync.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/ipvs/ip_vs_sync.c +2 -2
@@ -748,9 +748,9 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts)if (cp->flags &IP_VS_CONN_F_SEQ_MASK ) { *(p++) =IPVS_OPT_SEQ_DATA ; *(p++) =sizeof (struct ip_vs_sync_conn_options ); -hton_seq ((struct ip_vs_seq *)p, &cp->in_seq); +hton_seq (&cp->in_seq, (struct ip_vs_seq *)p); p +=sizeof (struct ip_vs_seq ); -hton_seq ((struct ip_vs_seq *)p, &cp->out_seq); +hton_seq (&cp->out_seq, (struct ip_vs_seq *)p); p +=sizeof (struct ip_vs_seq ); }/* Handle pe data */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 287/752 netfilter: nf_conntrack_sip: fix OOB read in sip_skip_whitespace()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joas Antonio dos Santos <[email protected]>
[ Upstream commit e8f8231824b5815f57ce62cba116e511b10196de ]
sip_skip_whitespace() returns dptr unchanged when its own loop exhausts the buffer (dptr == limit), instead of NULL like its sibling sip_follow_continuation() returns on its own "no more data" path.
ct_sip_get_header() only checks for NULL after calling it:
dptr = sip_skip_whitespace(dptr, limit);
if (dptr == NULL)
break;
if (*dptr != ':' || ++dptr >= limit)
break;so a recognized header name followed only by spaces/tabs running to the exact end of the SIP payload, with no colon, makes the very next statement read one byte past the buffer.
Make both "no more data" outcomes return NULL, matching the convention sip_follow_continuation() already uses and that both existing callers already check for.
--- net/netfilter/nf_conntrack_sip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_conntrack_sip.c +1 -1
@@ -429,7 +429,7 @@ static const char *sip_skip_whitespace(const char *dptr, const char *limit) dptr =sip_follow_continuation (dptr, limit);break ; } -return dptr; +return dptr < limit ? dptr :NULL ; }/* Search within a SIP header value, dealing with continuation lines */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 288/752 tracing/probes: Fix use-after-free on field name/type of events with multiple probes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Martin <[email protected]>
[ Upstream commit 86b7a239ec6b14a7544200ede85474c6f5526049 ]
The fields of a probe-based dynamic event (kprobe, uprobe, eprobe and fprobe events) are created in traceprobe_define_arg_fields() by handing the probe_arg name/type strings to trace_define_field(), which only stores the pointers without copying. Those strings are owned by the trace_probe and are freed when that probe is removed.
An event can have several probes attached. The field list is defined only once, by the first probe that registers the event, but it is kept alive by any surviving sibling probe. Deleting just that first probe by symbol -
# primary A: fields are defined from A's args echo 'p:kprobes/ev vfs_read a1=$arg1' > kprobe_events # append B: shares A's event call echo 'p:kprobes/ev vfs_write a1=$arg1' >> kprobe_events # delete only A (matched by symbol), B survives echo '-:kprobes/ev vfs_read' >> kprobe_events
frees A's args (trace_probe_cleanup() -> traceprobe_free_probe_arg()), but trace_probe_unlink() keeps the trace_probe_event because the probe list is not empty. The event call stays registered via B while its fields now reference freed memory. Any field lookup then reads it, e.g.
echo 'a1 == 1' > events/kprobes/ev/filter
BUG: KASAN: slab-use-after-free in strcmp+0xa7/0xb0 Call Trace: strcmp trace_find_event_field parse_pred process_preds create_filter apply_event_filter event_filter_write
field->name references parg->name (kstrdup'd, freed with the probe) and, for array arguments, field->type references parg->fmt (kmalloc'd, freed with the probe) - the scalar type otherwise points at the static fmttype rodata, which is safe.
Have traceprobe_define_arg_fields() duplicate the name and type strings and anchor the copies on the trace_probe_event, which embeds the event call and outlives every individual probe; trace_probe_event_free() releases them.
The reproducer above triggers reliably; the field lookup and the delete both run under event_mutex, so this is a dangling reference after removal rather than a race.
The issue was found by the autokbug dynamic kernel fuzzer at Tencent Yunding Lab.
--- kernel/trace/trace_probe.c | 48 +++++++++++++++++++++++++++++++++++++- kernel/trace/trace_probe.h | 2 ++ 2 files changed, 49 insertions(+), 1 deletion(-)
kernel/trace/trace_probe.c +47 -1
@@ -989,19 +989,60 @@ int traceprobe_set_print_fmt(struct trace_probe *tp, enum probe_print_type ptypeint traceprobe_define_arg_fields (struct trace_event_call *event_call,size_t offset,struct trace_probe *tp) { +struct trace_probe_event *tpe =trace_probe_event_from_call (event_call);int ret, i; +/* +* A field created by trace_define_field() only stores the name and +* type pointers, it does not copy the strings. Here they point into +* the probe_arg of @tp, which is freed when @tp is removed. For an +* event with multiple probes attached, the field list is defined +* once by the first probe but kept alive by the surviving siblings, +* so removing that first probe would leave the fields referencing +* freed memory. Duplicate the strings and anchor the copies on the +* trace_probe_event, which lives as long as the field list itself. +* +* event_define_fields() ignores the return value of this hook, so +* if a previous attempt failed before creating any field, it may +* call here again. Release duplicates left behind by such an +* attempt before starting over. +*/ +for (i =0 ; i < tpe->nr_field_strings; i++) +kfree (tpe->field_strings[i]); +kfree (tpe->field_strings); + tpe->field_strings =NULL ; + tpe->nr_field_strings =0 ; + +if (tp->nr_args) { + tpe->field_strings =kcalloc (tp->nr_args *2 ,sizeof (char *), +GFP_KERNEL ); +if (!tpe->field_strings) +return -ENOMEM ; + } +/* Set argument names as fields */ for (i =0 ; i < tp->nr_args; i++) {struct probe_arg *parg = &tp->args[i];const char *fmt = parg->type->fmttype;int size = parg->type->size; +char *name, *type;if (parg->fmt) fmt = parg->fmt;if (parg->count) size *= parg->count; - ret =trace_define_field (event_call, fmt, parg->name, + + name =kstrdup (parg->name,GFP_KERNEL ); + type =kstrdup (fmt,GFP_KERNEL ); +if (!name || !type) { +kfree (name); +kfree (type); +return -ENOMEM ; + } + tpe->field_strings[tpe->nr_field_strings++] = name; + tpe->field_strings[tpe->nr_field_strings++] = type; + + ret =trace_define_field (event_call, type, name, offset + parg->offset, size, parg->type->is_signed,FILTER_OTHER );
@@ -1013,6 +1054,11 @@ int traceprobe_define_arg_fields(struct trace_event_call *event_call,static void trace_probe_event_free (struct trace_probe_event *tpe) { +int i; + +for (i =0 ; i < tpe->nr_field_strings; i++) +kfree (tpe->field_strings[i]); +kfree (tpe->field_strings);kfree (tpe->class.system);kfree (tpe->call.name);kfree (tpe->call.print_fmt);
kernel/trace/trace_probe.h +2 -0
@@ -243,6 +243,8 @@ struct trace_probe_event {struct trace_event_call call;struct list_head files;struct list_head probes; +char **field_strings; +int nr_field_strings;struct trace_uprobe_filter filter[]; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 289/752 bpf: reject BPF_PSEUDO_FUNC reference to the main program
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eduard Zingerman <[email protected]>
[ Upstream commit 374b2c5561db80fcdd7cdce44af37a49416f61c7 ]
fixups.c:jit_subprogs() rewrites BPF_PSEUDO_FUNC loads to contain real function addresses. This function is invoked from bpf_jit_subprogs() only when env->subprog_cnt > 1. Meaning that for any program like below:
int main(void *ctx) {
void *ptr = main;
...
bpf_timer_set_callback(..., ptr);
...
}The 'ptr' won't be ever converted to contain an address.
In combination with e.g. bpf_timer_set_callback() this would lead to a function call at a bogus address.
Instead of complicating the implementation, just assume that no useful program needs main to be a sync or async callback and reject BPF_PSEUDO_FUNC loads for the main subprogram.
--- kernel/bpf/verifier.c | 9 +++++++++ 1 file changed, 9 insertions(+)
kernel/bpf/verifier.c +9 -0
@@ -9518,6 +9518,15 @@ static int check_ld_imm(struct bpf_verifier_env *env, struct bpf_insn *insn)verbose (env,"callback function not static\n" );return -EINVAL ; } +/* +* When env->subprog_cnt == 1 this instruction won't be rewritten +* to hold a real function address. Assume that no usable program +* combines e.g. main and timer callback and just reject here. +*/ +if (subprogno ==0 ) { +verbose (env,"callback function cannot be the main program\n" ); +return -EINVAL ; + } dst_reg->type =PTR_TO_FUNC ; dst_reg->subprogno = subprogno;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 290/752 bonding: do not clear curr_active_slave prematurely when releasing all slaves
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit af602c7aa5fedc9be3043244017aef4f26c96b70 ]
When releasing all slaves during bond destruction (all == true), __bond_release_one() unconditionally clears bond->curr_active_slave to NULL in every iteration.
If a backup slave is released before the active slave, bond_alb_deinit_slave() triggers rlb_teach_disabled_mac_on_primary(), which increments the active slave dev promiscuity counter and sets bond_info->primary_is_promisc = 1.
Because bond->curr_active_slave was prematurely cleared to NULL when releasing the backup slave, the subsequent iteration releasing the active slave evaluates oldcurrent as NULL, so bond_change_active_slave(bond, NULL) is skipped. Consequently, bond_alb_handle_active_change() is never called to decrement the promiscuity counter, permanently leaking promiscuous mode on the physical device after bond teardown.
When oldcurrent == slave, bond_change_active_slave(bond, NULL) already sets bond->curr_active_slave to NULL. We only need to avoid selecting a new active slave when all == true. Replace the if (all) branch with if (!all && oldcurrent == slave).
--- drivers/net/bonding/bond_main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/bonding/bond_main.c +1 -3
@@ -2393,9 +2393,7 @@ static int __bond_release_one(struct net_device *bond_dev,bond_alb_deinit_slave (bond, slave); } -if (all) { -RCU_INIT_POINTER (bond->curr_active_slave,NULL ); - }else if (oldcurrent == slave) { +if (!all && oldcurrent == slave) {/* Note that we hold RTNL over this sequence, so there * is no concern that another slave add/remove event * will interfere.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 291/752 net/rds: use wq_has_sleeper() in release_in_xmit()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Allison Henderson <[email protected]>
[ Upstream commit 6d0c8b7073913011459cf968cbbadd341e166bc3 ]
release_in_xmit() clears RDS_IN_XMIT with clear_bit_unlock() and then checks waitqueue_active() to decide whether anyone needs waking. clear_bit_unlock() is only a release operation: it orders the critical section before the bit clear, but does not order the subsequent plain load of the wait queue head after it. The waiter side does the mirror image - it adds itself to the wait queue and then tests the bit. That is the classic store-buffering pattern: the releasing CPU can read the wait queue as empty while the waiting CPU still reads the bit as set, so the sleeper is never woken.
The waiters are rds_conn_shutdown() and rds_tcp_reset_callbacks(), both in uninterruptible wait_event() with no timeout. A lost wake-up strands the shutdown worker on its single-threaded workqueue until some other sender releases the bit again - and on a connection that is being torn down precisely because it failed, there may never be another sender.
The barrier used to be there: release_in_xmit() did clear_bit() followed by smp_mb__after_atomic() until commit 1422f28826d2 ("rds:
introduce acquire/release ordering in acquire/release_in_xmit()") folded both into clear_bit_unlock(), which strengthened the lock hand-off but silently dropped the full barrier the wake-up check depends on. The refill counterpart, release_refill() in net/rds/ib_recv.c, still carries its smp_mb__after_atomic() for exactly this reason.
Use wq_has_sleeper(), which is waitqueue_active() preceded by the required full barrier.
--- net/rds/send.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/rds/send.c +6 -1
@@ -114,8 +114,13 @@ static void release_in_xmit(struct rds_conn_path *cp)* hot path and finding waiters is very rare. We don't want to walk * the system-wide hashed waitqueue buckets in the fast path only to * almost never find waiters. +* +* wq_has_sleeper() supplies the full barrier that orders the wait +* queue read after the bit clear; clear_bit_unlock() alone is only +* a release and would let this check read a stale empty queue, +* losing the wake-up. */ -if (waitqueue_active (&cp->cp_waitq)) +if (wq_has_sleeper (&cp->cp_waitq))wake_up_all (&cp->cp_waitq); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 292/752 net/rds: use clear_bit_unlock() in release_refill()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Allison Henderson <[email protected]>
[ Upstream commit 17c4476dbb9c3bfd34193a6c22f2c3da8747134a ]
release_refill() drops the RDS_RECV_REFILL bit with a plain clear_bit(). clear_bit() has no ordering semantics, and the smp_mb__after_atomic() that follows it sits on the wrong side for a lock release: it orders the clear against the waitqueue_active() load below it, but does nothing to order the refill critical section's ring and descriptor stores before the clear itself.
That matters once connection teardown owns RDS_RECV_REFILL as a lock across the transport shutdown and path reset, rather than sampling it clear, which "net/rds: acquire the fastpath locks in rds_conn_shutdown()" later in this series arranges: on a weakly ordered architecture the teardown can win the bit and start the shutdown and reset while some of the refill's stores are not yet visible to it. The same gap existed under the sample-based scheme - a waiter that saw the bit clear had no guarantee it also observed the refill's stores - but taking the bit as a lock makes the missing release pairing load-bearing.
Switch to clear_bit_unlock(), which orders the critical section before the release, and replace the open-coded barrier-plus-waitqueue_active() with wq_has_sleeper(), whose internal full barrier keeps the store-buffering guarantee between clearing the bit and checking for sleepers. This mirrors what "net/rds: use wq_has_sleeper() in release_in_xmit()" does for RDS_IN_XMIT.
The fast-path acquire side, acquire_refill(), uses test_and_set_bit(), a full-barrier RMW that pairs with this release. The teardown at this point in the series still samples the bit, so on its own this change is release-side hardening; the shutdown-conversion patch named above makes the teardown acquire the bit with the same RMW, completing the pairing at the end of the series.
--- net/rds/ib_recv.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/rds/ib_recv.c +2 -3
@@ -362,15 +362,14 @@ static int acquire_refill(struct rds_connection *conn)static void release_refill (struct rds_connection *conn) { -clear_bit (RDS_RECV_REFILL , &conn->c_flags); -smp_mb__after_atomic (); +clear_bit_unlock (RDS_RECV_REFILL , &conn->c_flags);/* We don't use wait_on_bit()/wake_up_bit() because our waking is in a * hot path and finding waiters is very rare. We don't want to walk * the system-wide hashed waitqueue buckets in the fast path only to * almost never find waiters. */ -if (waitqueue_active (&conn->c_waitq)) +if (wq_has_sleeper (&conn->c_waitq))wake_up_all (&conn->c_waitq); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 293/752 net/rds: clear cp_flags bits individually in rds_conn_path_reset()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Allison Henderson <[email protected]>
[ Upstream commit 103c4b13c4f50322910078d1c02f29334a574122 ]
rds_conn_path_reset() wipes the whole flag word with a plain cp->cp_flags = 0 store. Every other accessor of that word uses atomic bitops, and some of them can run concurrently with the reset:RDS_LL_SEND_FULL is set from rds_send_xmit() and cleared from the transport completion paths, neither of which holds anything that excludes the shutdown worker. A plain store racing an atomic read-modify-write on the same word is a data race, and whichever side loses has its update silently discarded.
Clear the two bits the reset is actually responsible for instead. RDS_IN_XMIT and RDS_RECV_REFILL need no store at all here: they belong to the caller, rds_conn_shutdown(), which waits for both to be clear before calling the transport shutdown and this reset.
This also gives every bit in cp_flags a single well-defined writer discipline, which the following patches rely on when they turn RDS_IN_XMIT and RDS_RECV_REFILL into bit locks held across the
teardown: a blanket store mid-teardown would destroy lock ownership that an atomic clear preserves.
Oracle UEK carries the same conversion ("net/rds: Preserve essential connection state flags"), motivated by its asynchronous shutdown state machine, whose progress and destroy flags must survive the reset. UEK's variant also clears RDS_IN_XMIT and RDS_RECV_REFILL because there the reset runs as the final step of a teardown that owns both bits, making those clears its unlock. Upstream that release belongs in rds_conn_shutdown(): once a later patch in this series turns the two bits into locks held across the teardown, ending ownership needs release semantics and a wake-up that a plain clear inside the reset would not provide.
Based on Oracle UEK commit "net/rds: Preserve essential connection state flags" by Gerd Rausch.
--- net/rds/connection.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
net/rds/connection.c +9 -1
@@ -119,7 +119,15 @@ static void rds_conn_path_reset(struct rds_conn_path *cp)rds_stats_inc (s_conn_reset);rds_send_path_reset (cp); - cp->cp_flags =0 ; + +/* Clear the bits the reset is responsible for individually: a +* blanket cp_flags = 0 is a plain store that can clobber a +* concurrent atomic read-modify-write on the same word. +* RDS_IN_XMIT and RDS_RECV_REFILL belong to the caller, +* rds_conn_shutdown(), and are left alone here. +*/ +clear_bit (RDS_LL_SEND_FULL , &cp->cp_flags); +clear_bit (RDS_RECONNECT_PENDING , &cp->cp_flags);/* Do not clear next_rx_seq here, else we cannot distinguish * retransmitted packets from new packets, and will hand all
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 294/752 net/rds: tcp: dont force RDS_CONN_RESETTING over a concurrent shutdown
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gerd Rausch <[email protected]>
[ Upstream commit e8e60d74fec49ccae2aea9b04a6eb162feb8d9af ]
rds_tcp_reset_callbacks() resolves a duelling SYN by storing RDS_CONN_RESETTING into cp_state unconditionally. Nothing serializes that store against the shutdown path: rds_tcp_accept_one() checks for RDS_CONN_CONNECTING or RDS_CONN_ERROR under t_conn_path_lock, but neither rds_conn_path_drop(), which forces RDS_CONN_ERROR, nor rds_conn_shutdown(), which moves the path to RDS_CONN_DISCONNECTING under cp_cm_lock, takes that lock. The store can therefore land on top of a shutdown that is already in progress, or that gets queued right after the accept-side check.
When it does, the shutdown worker's final DISCONNECTING -> DOWN transition fails and the path goes through rds_conn_path_error() and a second drop/shutdown cycle instead of a clean reconnect, tearing down the socket the accept path has just installed. Before commit ad22d24be635 ("net/rds: No shortcut out of RDS_CONN_ERROR") a path found in RDS_CONN_RESETTING even made rds_conn_shutdown() bail out altogether.
Make the transition conditional: move CONNECTING -> RESETTING (or stay in RESETTING from an earlier duel), and drop the path in any other state. The drop has side effects of its own: it replaces the shutdown's RDS_CONN_DISCONNECTING (or RDS_CONN_ERROR) with RDS_CONN_ERROR and queues one more cp_down_w run. The difference is that rds_conn_shutdown() accepts RDS_CONN_ERROR in its final transition to RDS_CONN_DOWN, so the shutdown in flight completes normally instead of through rds_conn_path_error(); the extra down-work pass then finds the path already down and falls through to the reconnect check, or catches a reconnect that has already started and restarts it. The accept path still installs the new socket, rds_connect_path_complete() then fails its RESETTING -> UP transition and drops it: the raced socket ends up torn down as it does today. The comment at that call site, which promised that rds_connect_path_complete() marks the path RDS_CONN_UP, is updated to name this outcome as well.
The state can change again between the failed transitions and the drop. That is inherent to rds_conn_path_drop(), which the socket state-change callbacks also call unconditionally, and costs at most one extra drop/reconnect cycle.
Based on Oracle UEK commit "net/rds: Don't force state RDS_CONN_RESETTING" by Gerd Rausch.
[achender: port to net-next: use the two-argument
rds_conn_path_transition()/rds_conn_path_drop() and rewrite the changelog for the upstream shutdown path]
--- net/rds/tcp.c | 17 +++++++++++++++-- net/rds/tcp_listen.c | 6 +++++- 2 files changed, 20 insertions(+), 3 deletions(-)
net/rds/tcp.c +15 -2
@@ -149,9 +149,22 @@ void rds_tcp_reset_callbacks(struct socket *sock,* end up deadlocking with tcp_sendmsg(), and the RDS_IN_XMIT * would not get set. As a result, we set c_state to * RDS_CONN_RESETTTING, to ensure that rds_tcp_state_change -* cannot mark rds_conn_path_up() in the window before lock_sock() +* cannot mark rds_conn_path_up() in the window before lock_sock(). +* +* Only make that transition if the path is still connecting +* (or already resetting from an earlier duel). A path in any +* other state - typically RDS_CONN_DISCONNECTING or +* RDS_CONN_ERROR with a shutdown in flight - is dropped +* instead. That still replaces its state, with RDS_CONN_ERROR, +* and queues one more shutdown pass, but rds_conn_shutdown() +* accepts RDS_CONN_ERROR in its final transition to +* RDS_CONN_DOWN, so the shutdown in flight completes normally. */ -atomic_set (&cp->cp_state,RDS_CONN_RESETTING ); +if (!rds_conn_path_transition (cp,RDS_CONN_CONNECTING , +RDS_CONN_RESETTING ) && + !rds_conn_path_transition (cp,RDS_CONN_RESETTING , +RDS_CONN_RESETTING )) +rds_conn_path_drop (cp,0 );wait_event (cp->cp_waitq, !test_bit (RDS_IN_XMIT , &cp->cp_flags));/* reset receive side state for rds_tcp_data_recv() for osock */ cancel_delayed_work_sync (&cp->cp_send_w);
net/rds/tcp_listen.c +5 -1
@@ -193,7 +193,11 @@ int rds_tcp_accept_one(struct socket *sock)if (rs_tcp->t_sock) {/* Duelling SYN has been handled in rds_tcp_accept_one() */ rds_tcp_reset_callbacks (new_sock, cp); -/* rds_connect_path_complete() marks RDS_CONN_UP */ +/* rds_connect_path_complete() marks RDS_CONN_UP, or, +* if a concurrent shutdown won the duel, drops the +* path again and the pass that drop queues reaps the +* socket installed above. +*/ rds_connect_path_complete (cp,RDS_CONN_RESETTING ); }else {rds_tcp_set_callbacks (new_sock, cp);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 295/752 net/rds: acquire RDS_IN_XMIT in rds_tcp_reset_callbacks()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Allison Henderson <[email protected]>
[ Upstream commit 02c5f9dc2efd823e061954d564ce00bacd1bebeb ]
rds_tcp_reset_callbacks() quiesces the transmit path by setting the path state to RDS_CONN_RESETTING and then waiting for RDS_IN_XMIT to be sampled clear before swapping the underlying socket and calling rds_send_path_reset().
Sampling the bit clear is not the same as owning it: rds_send_xmit() can re-acquire RDS_IN_XMIT right after the wait_event() returns. Its state recheck after taking the lock is a store-buffering pattern (the resetter writes the state and reads the bit, the sender writes the bit and reads the state) and acquire_in_xmit() is only an acquire operation, so on weakly ordered architectures both sides can miss each other's write and the transmit path then runs concurrently with rds_send_path_reset() rewriting cp_xmit_* state - which is exactly what the comment above rds_send_path_reset() tells its callers to prevent.
Take the lock instead, hold it across the socket swap and rds_send_path_reset(), and release it with a wake-up at the end. The lock-ordering constraint documented above the wait still holds: the lock is acquired before lock_sock(), so a sender inside tcp_sendmsg() can never be waited on while we hold the socket lock.
Two details of the old code go away with the same change:
- t_sock is now read only after the lock is acquired. The old code cached it before waiting; the teardown in rds_conn_shutdown() releases that socket and clears t_sock, so a pointer cached before the wait can be stale by the time the accept path resumes. Reading it under RDS_IN_XMIT is what makes the exclusion complete once the teardown owns the same lock, which the next patch arranges; until then the teardown still only samples the bit, and the two paths remain as exposed to each other as they are today.
- The old !osock early path called rds_send_path_reset() with no serialization at all. It now runs under the lock like the normal path. The conditional RDS_CONN_RESETTING transition of the previous patch happens before the socket check either way: a path found without a socket is either still connecting (its reconnect worker blocked on t_conn_path_lock) and legitimately goes RESETTING -> UP on the new socket, or it has been torn down meanwhile and is dropped.
The in-function comment describing the old wait-based quiesce is rewritten to describe the lock-based one, and the stale block comment above the function (which still described a return value and an incomplete list of t_sock writers) is refreshed to name all four writers - the connect, accept, teardown and swap paths - and what serializes each of them.
--- net/rds/tcp.c | 70 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 25 deletions(-)
net/rds/tcp.c +45 -25
@@ -114,42 +114,48 @@ void rds_tcp_restore_callbacks(struct socket *sock, }/* -* rds_tcp_reset_callbacks() switches the to the new sock and -* returns the existing tc->t_sock. +* rds_tcp_reset_callbacks() switches a path to a new socket and +* releases the old one it finds in tc->t_sock, resolving a duelling +* SYN. * -* The only functions that set tc->t_sock are rds_tcp_set_callbacks -* and rds_tcp_reset_callbacks. Send and receive trust that -* it is set. The absence of RDS_CONN_UP bit protects those paths -* from being called while it isn't set. +* tc->t_sock is set by rds_tcp_set_callbacks() and cleared by +* rds_tcp_restore_callbacks(). Four paths write it: the active +* connect in rds_tcp_conn_path_connect(), which sets it and clears it +* again on failure; the accept path in rds_tcp_accept_one(), which +* sets it for a path with no socket yet; the teardown in +* rds_tcp_conn_path_shutdown(), which clears it; and the swap done +* here, which does both. The connect and accept paths are serialized +* against each other by t_conn_path_lock. Send and receive trust +* that it is set: the absence of RDS_CONN_UP protects those paths +* from being called while it isn't, and the swap done here runs under +* RDS_IN_XMIT so that it cannot interleave with a sender already +* inside rds_send_xmit(). */ void rds_tcp_reset_callbacks (struct socket *sock,struct rds_conn_path *cp) {struct rds_tcp_connection *tc = cp->cp_transport_data; -struct socket *osock = tc->t_sock; - -if (!osock) - goto newsock; +struct socket *osock;/* Need to resolve a duelling SYN between peers. * We have an outstanding SYN to this peer, which may * potentially have transitioned to the RDS_CONN_UP state, * so we must quiesce any send threads before resetting -* cp_transport_data. We quiesce these threads by setting -* cp_state to something other than RDS_CONN_UP, and then -* waiting for any existing threads in rds_send_xmit to -* complete release_in_xmit(). (Subsequent threads entering -* rds_send_xmit() will bail on !rds_conn_up(). +* cp_transport_data. Setting cp_state to something other +* than RDS_CONN_UP stops new senders, and owning RDS_IN_XMIT +* excludes any thread already inside rds_send_xmit() for the +* whole socket swap and the rds_send_path_reset() below. * -* However an incoming syn-ack at this point would end up -* marking the conn as RDS_CONN_UP, and would again permit -* rds_send_xmi() threads through, so ideally we would -* synchronize on RDS_CONN_UP after lock_sock(), but cannot -* do that: waiting on !RDS_IN_XMIT after lock_sock() may -* end up deadlocking with tcp_sendmsg(), and the RDS_IN_XMIT -* would not get set. As a result, we set c_state to -* RDS_CONN_RESETTTING, to ensure that rds_tcp_state_change -* cannot mark rds_conn_path_up() in the window before lock_sock(). +* An incoming syn-ack at this point would end up marking the +* conn as RDS_CONN_UP, and would again permit rds_send_xmit() +* threads through, so ideally we would synchronize on +* RDS_CONN_UP after lock_sock(), but cannot do that: acquiring +* RDS_IN_XMIT after lock_sock() may end up deadlocking with +* tcp_sendmsg(), which takes the socket lock while holding +* RDS_IN_XMIT. As a result, we set c_state to +* RDS_CONN_RESETTING, to ensure that rds_tcp_state_change +* cannot mark rds_conn_path_up() in the window before +* lock_sock(). * * Only make that transition if the path is still connecting * (or already resetting from an earlier duel). A path in any
@@ -165,7 +171,18 @@ void rds_tcp_reset_callbacks(struct socket *sock, !rds_conn_path_transition(cp, RDS_CONN_RESETTING, RDS_CONN_RESETTING))rds_conn_path_drop (cp,0 ); -wait_event (cp->cp_waitq, !test_bit (RDS_IN_XMIT , &cp->cp_flags)); +wait_event (cp->cp_waitq, + !test_and_set_bit_lock (RDS_IN_XMIT , &cp->cp_flags)); + +/* Read t_sock only while owning RDS_IN_XMIT, never before the +* wait: the teardown in rds_conn_shutdown() releases the old +* socket and clears t_sock, so a pointer sampled earlier can +* be stale by the time we wake up. +*/ + osock = tc->t_sock; +if (!osock) + goto newsock; +/* reset receive side state for rds_tcp_data_recv() for osock */ cancel_delayed_work_sync (&cp->cp_send_w);cancel_delayed_work_sync (&cp->cp_recv_w);
@@ -184,6 +201,9 @@ void rds_tcp_reset_callbacks(struct socket *sock,lock_sock (sock->sk);rds_tcp_set_callbacks (sock, cp);release_sock (sock->sk); + +clear_bit_unlock (RDS_IN_XMIT , &cp->cp_flags); +wake_up_all (&cp->cp_waitq); }/* Add tc to rds_tcp_tc_list and set tc->t_sock. See comments
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 296/752 net/rds: acquire the fastpath locks in rds_conn_shutdown()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Håkon Bugge <[email protected]>
[ Upstream commit 813f3582ac7ae9f60f917937d54660e0952d5f2d ]
rds_conn_shutdown() quiesces the transmit and receive-refill paths by waiting for RDS_IN_XMIT and RDS_RECV_REFILL to be sampled clear, and then runs the transport shutdown and rds_conn_path_reset(). Sampling the bits clear is not the same as owning them: the moment after the wait_event() returns, rds_send_xmit() can re-acquire RDS_IN_XMIT (or rds_ib_recv_refill() can re-acquire RDS_RECV_REFILL) and run concurrently with the teardown.
The sender does recheck the connection state after taking the lock, but that recheck is a classic store-buffering pattern: teardown writes the state and reads the bit while the sender writes the bit and reads the state. acquire_in_xmit() is only an acquire operation, so on weakly ordered architectures both sides can miss each other's write, and the transmit path then runs while the transport zeroes its rings (e.g. rds_ib_ring_init()) and rds_send_path_reset() rewrites the transmit state under it.
Oracle UEK fixed the same class of crashes - a 14-year tail of BUG_ON()s in rds_ib_sub_signaled(), unexpected op-codes and NULL dereferences in rds_ib_send_cqe_handler() during failover testing - by making the teardown path *acquire* the fastpath bit locks instead of testing them ("rds: Make sure transmit path and connection tear-down does not run concurrently"). Ownership of a single word is decided by RMW atomicity, so no cross-variable ordering is needed.
Do the same here: take both locks before calling the transport shutdown, hold them across rds_conn_path_reset(), and release them explicitly with a wake-up afterwards. Both are released with clear_bit_unlock(), so that the ring re-initialization done by the transport shutdown and the transmit state rewritten by rds_send_path_reset() are ordered before either bit is seen clear by the next acquire_in_xmit() or acquire_refill().
The fastpath users of these bits - rds_send_xmit() and rds_ib_recv_refill() - are trylock style and back off while teardown owns the locks, so no new lock dependency is introduced for them. rds_tcp_reset_callbacks() is different: since the previous patch it acquires RDS_IN_XMIT as well, and it blocks doing so, so its wait now spans the teardown instead of at most one send batch. That waiter runs from rds_tcp_accept_one() on the single-threaded krdsd workqueue and holds rds_tcp_accept_lock and t_conn_path_lock while it waits, so a duelling SYN accepted while its path is being torn down parks accept processing for the duration of the teardown - for TCP bounded by the (up to 5 s) drain loop in rds_tcp_conn_path_shutdown(). An IB path's drain in rds_ib_conn_path_shutdown() has no round cap, but no blocking waiter either: rds_tcp_reset_callbacks() is the only blocking acquirer of these bits and waits only on its own TCP path, and the fastpaths are trylock-and-back-off on both transports, so a long IB drain lengthens only that path's own quiesce. The
window is narrow: the accept-side state check has to pass before the teardown moves the path to RDS_CONN_DISCONNECTING.
Because krdsd is a single global workqueue, everything else queued there - accept processing for other connections and network namespaces, and the flush_workqueue(rds_wq) in rds_tcp_listen_stop() during namespace teardown - waits behind the parked accept worker for that time. It cannot deadlock, although the waits do point at each
other: the teardown blocks until the bit's holder releases it, and the holder may be that krdsd accept worker. The holder finishes without needing anything the teardown owns: the sync cancels rds_tcp_reset_callbacks() issues target cp_send_w and cp_recv_w on the path's ordered cp_wq, whose only execution slot is occupied by the blocked cp_down_w itself, so they are pending at most and cancel without flushing - a reliance on cp_wq being ordered that is now noted next to those cancels (on the allocation-failure fallback where a path shares rds_wq, the work items simply serialize). Nor is the blocking wait itself new: rds_tcp_reset_callbacks() has waited on RDS_IN_XMIT from the krdsd work item since commit 335b48d980f6 ("RDS: TCP: Add/use rds_tcp_reset_callbacks to reset tcp socket safely"); this patch stretches its worst case from a sender's batch to the teardown's drain. The alternative to parking is the accept path racing the teardown, which is what these patches close; making the teardown itself non-blocking is a separate item.
One observable side effect: the SENDING flag reported by rds-info has always mirrored RDS_IN_XMIT, so it now also covers the window where teardown owns the bit.
The comments that describe the old sample-based handshake or name rds_send_xmit() as the only other holder of these bits - in rds_send_xmit(), above rds_conn_path_reset(), in rds_ib_recv_refill() and in rds_tcp_reset_callbacks() - are updated to match.
For anyone backporting this patch standalone: it depends on "net/rds: clear cp_flags bits individually in rds_conn_path_reset()" and "net/rds: acquire RDS_IN_XMIT in rds_tcp_reset_callbacks()" earlier in this series. Without the former, the blanket cp_flags clear in rds_conn_path_reset() would drop both held bits in the middle of the teardown; without the latter, rds_tcp_reset_callbacks() would still sample t_sock without owning RDS_IN_XMIT. "net/rds: use clear_bit_unlock() in release_refill()" is needed for the refill side's release to pair with the acquire added here, and the follow-up "net/rds: don't let rds_conn_shutdown() consume a concurrent drop" completes the teardown-state handling for the waiter this patch parks; a backport should carry all four.
[achender: reimplement for net-next shutdown path: acquire the existing
RDS_IN_XMIT/RDS_RECV_REFILL bit locks in rds_conn_shutdown() and release after teardown; update comments and commit message]
--- net/rds/connection.c | 40 ++++++++++++++++++++++++++++++++-------- net/rds/ib_recv.c | 4 +++- net/rds/send.c | 7 +++++-- net/rds/tcp.c | 19 +++++++++++++++---- 4 files changed, 55 insertions(+), 15 deletions(-)
net/rds/connection.c +32 -8
@@ -105,10 +105,12 @@ static struct rds_connection *rds_conn_lookup(struct net *net, }/* -* This is called by transports as they're bringing down a connection. -* It clears partial message state so that the transport can start sending -* and receiving over this connection again in the future. It is up to -* the transport to have serialized this call with its send and recv. +* This is called by rds_conn_shutdown() once the transport has brought +* a path down. It clears partial message state so that the transport +* can start sending and receiving over this path again in the future. +* The caller owns RDS_IN_XMIT and RDS_RECV_REFILL across this call, +* which is what serializes it against the send and receive-refill +* paths. */ static void rds_conn_path_reset (struct rds_conn_path *cp) {
@@ -123,8 +125,9 @@ static void rds_conn_path_reset(struct rds_conn_path *cp)/* Clear the bits the reset is responsible for individually: a * blanket cp_flags = 0 is a plain store that can clobber a * concurrent atomic read-modify-write on the same word. -* RDS_IN_XMIT and RDS_RECV_REFILL belong to the caller, -* rds_conn_shutdown(), and are left alone here. +* RDS_IN_XMIT and RDS_RECV_REFILL are held as locks by the +* caller, rds_conn_shutdown(), which releases them once the +* teardown is complete. */ clear_bit (RDS_LL_SEND_FULL , &cp->cp_flags);clear_bit (RDS_RECONNECT_PENDING , &cp->cp_flags);
@@ -400,14 +403,35 @@ void rds_conn_shutdown(struct rds_conn_path *cp) }mutex_unlock (&cp->cp_cm_lock); +/* Quiesce the transmit and receive-refill paths by +* acquiring their bit locks, not merely waiting for +* them to be released: with a plain wait, either path +* can re-take its lock the instant after we sample it +* clear and then run concurrently with the transport +* shutdown and the path reset below. Holding both +* locks across the teardown makes that structurally +* impossible. +*/ wait_event (cp->cp_waitq, - !test_bit (RDS_IN_XMIT , &cp->cp_flags)); + !test_and_set_bit_lock (RDS_IN_XMIT , &cp->cp_flags));wait_event (cp->cp_waitq, - !test_bit (RDS_RECV_REFILL , &cp->cp_flags)); + !test_and_set_bit (RDS_RECV_REFILL , &cp->cp_flags)); conn->c_trans->conn_path_shutdown (cp);rds_conn_path_reset (cp); +/* Release the two locks and wake any waiter (e.g. +* rds_tcp_reset_callbacks()) that blocked on them while +* we held them. The unlock orders the transport's ring +* re-initialization and the path reset above before +* either bit is seen clear. rds_conn_path_reset() leaves +* both bits alone: ownership ends here, not inside the +* reset. +*/ +clear_bit_unlock (RDS_IN_XMIT , &cp->cp_flags); +clear_bit_unlock (RDS_RECV_REFILL , &cp->cp_flags); +wake_up_all (&cp->cp_waitq); +if (!rds_conn_path_transition (cp,RDS_CONN_DISCONNECTING ,RDS_CONN_DOWN ) && !rds_conn_path_transition(cp, RDS_CONN_ERROR,
net/rds/ib_recv.c +3 -1
@@ -390,7 +390,9 @@ void rds_ib_recv_refill(struct rds_connection *conn, int prefill, gfp_t gfp)/* the goal here is to just make sure that someone, somewhere * is posting buffers. If we can't get the refill lock, -* let them do their thing +* let them do their thing. The holder may also be +* rds_conn_shutdown() tearing the path down, in which case +* there is nothing to post. */ if (!acquire_refill (conn))return ;
net/rds/send.c +5 -2
@@ -185,8 +185,11 @@ int rds_send_xmit(struct rds_conn_path *cp)WRITE_ONCE (cp->cp_send_gen, send_gen);/* -* rds_conn_shutdown() sets the conn state and then tests RDS_IN_XMIT, -* we do the opposite to avoid races. +* rds_conn_shutdown() sets the conn state and then acquires +* RDS_IN_XMIT; we take the lock first and then check the state. +* Ownership is decided by the atomic RMW on the cp_flags word: +* if the teardown won the bit we back off here, and if we won +* it the teardown waits until we release it. */ if (!rds_conn_path_up (cp)) {release_in_xmit (cp);
net/rds/tcp.c +15 -4
@@ -143,8 +143,10 @@ void rds_tcp_reset_callbacks(struct socket *sock,* so we must quiesce any send threads before resetting * cp_transport_data. Setting cp_state to something other * than RDS_CONN_UP stops new senders, and owning RDS_IN_XMIT -* excludes any thread already inside rds_send_xmit() for the -* whole socket swap and the rds_send_path_reset() below. +* excludes any thread already inside rds_send_xmit() - or a +* teardown in rds_conn_shutdown(), which holds the same lock +* for the duration of the transport shutdown - for the whole +* socket swap and the rds_send_path_reset() below. * * An incoming syn-ack at this point would end up marking the * conn as RDS_CONN_UP, and would again permit rds_send_xmit()
@@ -177,13 +179,22 @@ void rds_tcp_reset_callbacks(struct socket *sock,/* Read t_sock only while owning RDS_IN_XMIT, never before the * wait: the teardown in rds_conn_shutdown() releases the old * socket and clears t_sock, so a pointer sampled earlier can -* be stale by the time we wake up. +* be stale by the time we wake up. The teardown holds the +* same lock while it does so, so what we read here cannot +* change under us until we release it. */ osock = tc->t_sock;if (!osock) goto newsock; -/* reset receive side state for rds_tcp_data_recv() for osock */ +/* reset receive side state for rds_tcp_data_recv() for osock. +* +* The sync cancels while owning RDS_IN_XMIT rely on cp_wq +* being ordered: a teardown blocked on the bit occupies +* cp_wq's only execution slot, so cp_send_w and cp_recv_w are +* pending at most and the cancels never flush. Nothing here +* may flush or wait on cp_wq itself. +*/ cancel_delayed_work_sync (&cp->cp_send_w);cancel_delayed_work_sync (&cp->cp_recv_w);lock_sock (osock->sk);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 297/752 net/rds: dont let rds_conn_shutdown() consume a concurrent drop
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Allison Henderson <[email protected]>
[ Upstream commit 260c6308fe2e19ad519389d44d582e292aecc3af ]
rds_conn_shutdown() finishes by moving the path from RDS_CONN_DISCONNECTING to RDS_CONN_DOWN, and also accepts RDS_CONN_ERROR as the starting state of that final transition, so that a FIN processed in softirq context during the teardown does not derail the shutdown into a noisy error path.
But consuming that RDS_CONN_ERROR also consumes the shutdown pass that came with it: rds_conn_path_drop() sets RDS_CONN_ERROR and then queues cp_down_w, and a pass that starts on a path already in RDS_CONN_DOWN is a no-op. For the FIN case that is harmless - the socket the FIN arrived on is the very socket the teardown just released. It is not harmless for a dropper that attached something to the path first.
rds_tcp_accept_one() is such a dropper. Its path claim in rds_tcp_accept_one_path() transitions RDS_CONN_DOWN -> RDS_CONN_CONNECTING, and a concurrent drop - a FIN on a previous socket in softirq context, an administrative reset - can put the path into RDS_CONN_ERROR between that claim and the state check that follows, which accepts RDS_CONN_ERROR. The accept then installs the freshly accepted socket with rds_tcp_set_callbacks() while the queued teardown - which sampled tc->t_sock before this socket existed - is still running. rds_connect_path_complete() fails its transition to RDS_CONN_UP and drops the path again, queueing the pass that should reap the socket it just installed. If the in-flight shutdown's final transition consumes that drop's RDS_CONN_ERROR, the queued pass finds the path in RDS_CONN_DOWN and does nothing. The installed socket is never torn down: it sits established with its callbacks armed and its rds_tcp_connection on rds_tcp_tc_list, the peer sees a connection that nothing ever reads, and the path is wedged in RDS_CONN_DOWN until some later event drops it again. Reproduced with widened race windows as an ever-growing receive queue on a socket owned by a path stuck in RDS_CONN_DOWN, with the peer's send path wedged behind it.
Make the final transition only DISCONNECTING -> DOWN. If it fails because the path is in RDS_CONN_ERROR, a drop raced the teardown:
cancel the reconnect timer and clear RDS_RECONNECT_PENDING - the one piece of the skipped tail that must not be left behind - and return, letting the pass the drop queued finish the job: it tears down whatever attached to the path in the meantime, completes the transition to RDS_CONN_DOWN, and re-arms the reconnect from its own tail.
The timer quiesce in that branch matters because the racing drop does not always queue that pass: rds_conn_path_drop() returns without queueing when a destroy is pending - exactly the situation during a netns teardown or module unload, when a FIN on the dying socket is processed while rds_conn_path_destroy() flushes cp_down_w. If the flushed pass is the one that takes this return, no later pass exists, and rds_conn_path_destroy() would find cp_conn_w still armed (WARN_ON) and then free a path whose reconnect timer can still fire. With the cancel in the branch, every exit of a shutdown pass leaves the timer quiesced no matter which pass completes the transition.
The FIN case keeps making progress, one pass later and still without noisy logging. Any other state keeps today's rds_conn_path_error() handling; no current cp_state writer can leave a DISCONNECTING path in anything but RDS_CONN_ERROR (every other writer is a cmpxchg from a non-DISCONNECTING state), so that branch is defensive.
On kernels without the preceding patches the same hazard exists with the sample-based quiesce; the fix applies there equally.
--- net/rds/connection.c | 43 ++++++++++++++++++++++++++++++++----------- net/rds/tcp.c | 9 ++++++--- 2 files changed, 38 insertions(+), 14 deletions(-)
net/rds/connection.c +32 -11
@@ -433,19 +433,40 @@ void rds_conn_shutdown(struct rds_conn_path *cp)wake_up_all (&cp->cp_waitq);if (!rds_conn_path_transition (cp,RDS_CONN_DISCONNECTING , -RDS_CONN_DOWN ) && - !rds_conn_path_transition (cp,RDS_CONN_ERROR ,RDS_CONN_DOWN )) { -/* This can happen - eg when we're in the middle of tearing -* down the connection, and someone unloads the rds module. -* Quite reproducible with loopback connections. -* Mostly harmless. +/* The path was dropped again while we tore it +* down: by a socket state-change callback in +* irq context on receipt of a FIN, or by an +* accept that claimed the path just before a +* drop put it back to RDS_CONN_ERROR and then +* installed a fresh socket on it. Unless a +* pending destroy suppressed it, the drop also +* queued another shutdown pass, and that pass +* must run, because it is what tears down +* whatever attached to the path after the +* transport shutdown above sampled its state. +* Consuming the RDS_CONN_ERROR here would turn +* that pass into a no-op: leave the state +* alone, and let the pass finish the job. * -* Note that this also happens with rds-tcp because -* we could have triggered rds_conn_path_drop in irq -* mode from rds_tcp_state change on the receipt of -* a FIN, thus we need to recheck for RDS_CONN_ERROR -* here. +* Quiesce the reconnect timer before bailing +* out, though. When a pending destroy did +* suppress the queue, no later pass runs, and +* rds_conn_path_destroy() is about to flush +* cp_down_w and free the path: it must not +* find cp_conn_w still armed. A successor +* pass, when there is one, re-arms the +* reconnect from its own tail. +*/ +cancel_delayed_work_sync (&cp->cp_conn_w); +clear_bit (RDS_RECONNECT_PENDING , &cp->cp_flags); + +if (rds_conn_path_state (cp) ==RDS_CONN_ERROR ) +return ; +/* No current cp_state writer leaves a +* DISCONNECTING path in any state but +* RDS_CONN_ERROR; report loudly if one ever +* does. */ rds_conn_path_error (cp,"%s: failed to transition " "to state DOWN, current state "
net/rds/tcp.c +6 -3
@@ -164,9 +164,12 @@ void rds_tcp_reset_callbacks(struct socket *sock,* other state - typically RDS_CONN_DISCONNECTING or * RDS_CONN_ERROR with a shutdown in flight - is dropped * instead. That still replaces its state, with RDS_CONN_ERROR, -* and queues one more shutdown pass, but rds_conn_shutdown() -* accepts RDS_CONN_ERROR in its final transition to -* RDS_CONN_DOWN, so the shutdown in flight completes normally. +* and, unless a pending destroy is about to reap the whole +* connection anyway, queues one more shutdown pass. A shutdown +* already in flight leaves that RDS_CONN_ERROR alone when it +* finishes; the queued pass then completes the transition to +* RDS_CONN_DOWN and tears down anything that attached to the +* path in the meantime. */ if (!rds_conn_path_transition(cp, RDS_CONN_CONNECTING, RDS_CONN_RESETTING) &&
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 298/752 net: stmmac: reconfigure RX packet parser table in stmmac_hw_setup() after reset
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit 6b8fed2675fb75d23e6cf2b7e49c94926e884b34 ]
The core software reset issued in stmmac_init_dma_engine() during ndo_open() callback clears the MTL RX packet parser registers, but stmmac_rxp_config() is only invoked from the cls_u32 add/delete paths. After an ifdown/ifup cycle the hardware therefore runs with the default all-pass table while priv->tc_entries still reports the filters as installed. Re-apply the RX packet parser table from priv->tc_entries in stmmac_hw_setup(), right after the software reset, so the filters are restored when the interface is brought up again.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +8 -0
@@ -3317,6 +3317,14 @@ static int stmmac_hw_setup(struct net_device *dev, bool ptp_register)/* Initialize MTL*/ stmmac_mtl_configuration (priv); +/* Apply the RX packet parser table */ +if (priv->tc_entries) { + ret =stmmac_rxp_config (priv, priv->hw->pcsr, priv->tc_entries, + priv->tc_entries_max); +if (ret) +return ret; + } +/* Initialize Safety Features */ stmmac_safety_feat_configuration (priv);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 299/752 ALSA: caiaq: Fix potential double-free at error path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 3b26ceef88c110f4d188387cffa0df78657be904 ]
The fix for caiaq driver's resource management to handle the errors tries to release the resources in a common destructor call, but as a sashiko review for another patch suggested, some of the audio resources such as URBs have been already freed, and this may lead to a double-free.
For addressing the double-free, call the common destructor function from each place, and assure that the resource pointers get cleared.
--- sound/usb/caiaq/audio.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
sound/usb/caiaq/audio.c +5 -5
@@ -853,16 +853,13 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev) cdev->data_urbs_in =alloc_urbs (cdev,SNDRV_PCM_STREAM_CAPTURE , &ret);if (ret <0 ) { -kfree (cdev->data_cb_info); -free_urbs (cdev->data_urbs_in); +snd_usb_caiaq_audio_free (cdev);return ret; } cdev->data_urbs_out =alloc_urbs (cdev,SNDRV_PCM_STREAM_PLAYBACK , &ret);if (ret <0 ) { -kfree (cdev->data_cb_info); -free_urbs (cdev->data_urbs_in); -free_urbs (cdev->data_urbs_out); +snd_usb_caiaq_audio_free (cdev);return ret; }
@@ -883,6 +880,9 @@ void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *cdev)dev_dbg (dev,"%s(%p)\n" , __func__, cdev);free_urbs (cdev->data_urbs_in); + cdev->data_urbs_in =NULL ;free_urbs (cdev->data_urbs_out); + cdev->data_urbs_out =NULL ;kfree (cdev->data_cb_info); + cdev->data_cb_info =NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 300/752 bpf: Fix NULL-ptr-deref when showing a void BTF type
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit 4ea508b9ebd78bce7f212166d2e2cba66b875f08 ]
btf_modifier_show() resolves the modifier and then calls btf_type_ops(t)->show() unconditionally. For the void type (type_id 0, BTF_KIND_UNKN) kind_ops[] has no entry, so ->show is NULL.
A "const void" (a modifier resolving to void) cannot be a map key or value - map_check_btf() rejects it because void has no size - so the map dump path does not reach it. But bpf_snprintf_btf() takes a type_id straight from the BPF program, and passing such a "const void" from the vmlinux BTF NULL-derefs:
KASAN: null-ptr-deref in range [0x0000000000000028-0x000000000000002f] RIP: 0010:btf_modifier_show (kernel/bpf/btf.c:2914) Call Trace: <TASK> btf_type_show (kernel/bpf/btf.c:8251) btf_type_snprintf_show (kernel/bpf/btf.c:8321) bpf_snprintf_btf (kernel/trace/bpf_trace.c:1047) bpf_prog_test_run_raw_tp (net/bpf/test_run.c:829) __sys_bpf (kernel/bpf/syscall.c:4804) do_syscall_64 (arch/x86/entry/syscall_64.c:94) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) </TASK>
Fall back to btf_df_show() when the resolved type has no show op; it emits the "<unsupported kind:N>" placeholder already used for kinds like FWD and FUNC. bpf_snprintf_btf() then returns the length as usual.
--- kernel/bpf/btf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
kernel/bpf/btf.c +8 -1
@@ -2522,7 +2522,14 @@ static void btf_modifier_show(const struct btf *btf,else t =btf_type_skip_modifiers (btf, type_id,NULL ); -btf_type_ops (t)->show (btf, t, type_id, data, bits_offset, show); +/* +* A modifier can resolve to void, which has no show op; print a +* placeholder rather than dereferencing NULL. +*/ +if (!btf_type_ops (t)) +btf_df_show (btf, t, type_id, data, bits_offset, show); +else +btf_type_ops (t)->show (btf, t, type_id, data, bits_offset, show); } static void btf_var_show(const struct btf *btf, const struct btf_type *t,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 301/752 bpf: Fix NULL-ptr-deref in btf_var_show()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit 5403a383f52fc0905703b488f7c3db4b2447dc58 ]
btf_var_show() calls btf_type_id_resolve() unconditionally, which dereferences btf->resolved_ids. That is NULL for a base BTF - e.g. the vmlinux BTF that bpf_snprintf_btf() renders against - since base BTF is not resolved during parsing. btf_modifier_show() guards this with 'if (btf->resolved_ids)', but btf_var_show() does not.
A BPF program that passes the type_id of a BTF_KIND_VAR from the vmlinux BTF to bpf_snprintf_btf() thus NULL-derefs:
KASAN: probably user-memory-access in range [0x46638-0x4663f] RIP: 0010:btf_var_show (kernel/bpf/btf.c:2929) Call Trace: <TASK> btf_type_show (kernel/bpf/btf.c:8259) btf_type_snprintf_show (kernel/bpf/btf.c:8329) bpf_snprintf_btf (kernel/trace/bpf_trace.c:1047) bpf_prog_test_run_raw_tp (net/bpf/test_run.c:829) __sys_bpf (kernel/bpf/syscall.c:4804) do_syscall_64 (arch/x86/entry/syscall_64.c:84) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) </TASK>
Resolve the var's type directly with btf_type_skip_modifiers() when resolved_ids is NULL, mirroring btf_modifier_show().
--- kernel/bpf/btf.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
kernel/bpf/btf.c +9 -1
@@ -2536,7 +2536,15 @@ static void btf_var_show(const struct btf *btf, const struct btf_type *t, u32 type_id, void *data, u8 bits_offset, struct btf_show *show) { - t =btf_type_id_resolve (btf, &type_id); + /* + * btf_type_id_resolve() dereferences btf->resolved_ids, which is NULL + * for a base BTF (e.g. the vmlinux BTF that bpf_snprintf_btf() uses). + * Resolve the var's type directly in that case. + */ + if (btf->resolved_ids) + t =btf_type_id_resolve (btf, &type_id); + else + t =btf_type_skip_modifiers (btf, t->type, &type_id);btf_type_ops (t)->show (btf, t, type_id, data, bits_offset, show); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 302/752 nexthop: Initialize extack in remove_nh_grp_entry()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
[ Upstream commit 5bd9e4e7cdaa03879e9b73b12ab52cceb1edd55b ]
remove_nh_grp_entry() prints the extack message when a listener fails to replace the reduced nexthop group. However, extack is not initialized and listeners are not required to set a message when returning an error. Neither netdevsim nor mlxsw do so when an allocation fails, resulting in the dereference of an uninitialized stack pointer.
Fix by zero-initializing extack, as was done in commit 6347c5314cee ("nexthop: initialize extack in nh_res_bucket_migrate()").
--- net/ipv4/nexthop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/nexthop.c +1 -1
@@ -1735,7 +1735,7 @@ static void remove_nh_grp_entry(struct net *net, struct nh_grp_entry *nhge, {struct nh_grp_entry *nhges, *new_nhges;struct nexthop *nhp = nhge->nh_parent; -struct netlink_ext_ack extack; +struct netlink_ext_ack extack = {};struct nexthop *nh = nhge->nh;struct nh_group *nhg, *newg;int i, j, err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 303/752 bonding: use skb_cow_head() in bond_do_alb_xmit() and rlb_arp_xmit()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 1746ef2e2df2ad71c66eca56364d56bde284523b ]
In bond_do_alb_xmit() and rlb_arp_xmit(), make sure to unclone skb head via skb_cow_head() before modifying the source MAC address (Ethernet header and ARP payload) to avoid silent corruption if the skb is shared or cloned. Avoid caching the header pointers across skb_cow_head().
In rlb_arp_xmit(), only modify arp->mac_src if it differs from tx_slave->dev->dev_addr to avoid an unnecessary copy and head reallocation.
Also, we should not assume mac header is set in output path.
Use skb_eth_hdr() instead of eth_hdr() to fix the issue, and remove now redundant skb_reset_mac_header() calls.
--- drivers/net/bonding/bond_alb.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/net/bonding/bond_alb.c +12 -7
@@ -666,9 +666,15 @@ static struct slave *rlb_arp_xmit(struct sk_buff *skb, struct bonding *bond)if (arp->op_code ==htons (ARPOP_REPLY )) {/* the arp must be sent on the selected rx channel */ tx_slave =rlb_choose_channel (skb, bond, arp); -if (tx_slave) +if (tx_slave && + !ether_addr_equal_64bits (arp->mac_src, + tx_slave->dev->dev_addr)) { +if (unlikely (skb_cow_head (skb,0 ))) +return NULL ; + arp = (struct arp_pkt *)skb_network_header (skb);bond_hw_addr_copy (arp->mac_src, tx_slave->dev->dev_addr, tx_slave->dev->addr_len); + }netdev_dbg (bond->dev,"(slave %s): Server sent ARP Reply packet\n" , tx_slave ? tx_slave->dev->name :"NULL" ); }else if (arp->op_code ==htons (ARPOP_REQUEST )) {
@@ -1309,7 +1315,6 @@ static netdev_tx_t bond_do_alb_xmit(struct sk_buff *skb, struct bonding *bond, struct slave *tx_slave) {struct alb_bond_info *bond_info = &(BOND_ALB_INFO (bond)); -struct ethhdr *eth_data =eth_hdr (skb);if (!tx_slave) {/* unbalanced or unassigned, send through primary */
@@ -1320,7 +1325,9 @@ static netdev_tx_t bond_do_alb_xmit(struct sk_buff *skb, struct bonding *bond,if (tx_slave &&bond_slave_can_tx (tx_slave)) {if (tx_slave !=rcu_access_pointer (bond->curr_active_slave)) { -ether_addr_copy (eth_data->h_source, +if (unlikely (skb_cow_head (skb,0 ))) +return bond_tx_drop (bond->dev, skb); +ether_addr_copy (skb_eth_hdr (skb)->h_source, tx_slave->dev->dev_addr); }
@@ -1344,8 +1351,7 @@ struct slave *bond_xmit_tlb_slave_get(struct bonding *bond,struct ethhdr *eth_data;u32 hash_index; -skb_reset_mac_header (skb); - eth_data =eth_hdr (skb); + eth_data =skb_eth_hdr (skb);/* Do not TX balance any multicast or broadcast */ if (!is_multicast_ether_addr (eth_data->h_dest)) {
@@ -1394,8 +1400,7 @@ struct slave *bond_xmit_alb_slave_get(struct bonding *bond,u32 hash_index =0 ;int hash_size =0 ; -skb_reset_mac_header (skb); - eth_data =eth_hdr (skb); + eth_data =skb_eth_hdr (skb);switch (ntohs (skb->protocol)) {case ETH_P_IP : {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 304/752 net: dsa: bcm_sf2: bound the CFP rule dump by the callers buffer size
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit cdb719f4b8596d9ccee2d56d204c2c4dce982f46 ]
bcm_sf2_cfp_rule_get_all() walks the whole cfp.unique bitmap into rule_locs[] without consulting nfc->rule_cnt, which is how many entries the caller had room for. ETHTOOL_GRXCLSRLALL requires no CAP_NET_ADMIN and the ioctl sizes the buffer from the rule_cnt userspace passes in, so once an admin has installed CFP rules any user can ask for fewer slots than there are rules and run off the end of the allocation. A rule_cnt of 0 leaves the buffer pointer NULL and the walk dereferences it.
--- drivers/net/dsa/bcm_sf2_cfp.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/dsa/bcm_sf2_cfp.c +2 -0
@@ -1088,6 +1088,8 @@ static int bcm_sf2_cfp_rule_get_all(struct bcm_sf2_priv *priv,unsigned int index =1 , rules_cnt =0 ;for_each_set_bit_from (index, priv->cfp.unique, priv->num_cfp_rules) { +if (rules_cnt == nfc->rule_cnt) +return -EMSGSIZE ; rule_locs[rules_cnt] = index; rules_cnt++; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 305/752 net: dsa: mv88e6xxx: bound the policy rule dump by the callers buffer size
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit b1fffc273112e7284c5b705e186b43b5770cd3d5 ]
mv88e6xxx_get_rxnfc() uses rxnfc->rule_cnt as the write index while dumping the policy IDR, clobbering the input value before it has been looked at. That input is the number of entries the caller had room for. ETHTOOL_GRXCLSRLALL requires no CAP_NET_ADMIN and the ioctl sizes the buffer from the rule_cnt userspace passes in, so once an admin has installed policy rules any user can ask for fewer slots than there are rules and run off the end of the allocation. A rule_cnt of 0 leaves the buffer pointer NULL and the walk dereferences it.
Count into a local so the caller's limit survives the walk, and stop with -EMSGSIZE once it is reached.
--- drivers/net/dsa/mv88e6xxx/chip.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.c +12 -4
@@ -1995,6 +1995,7 @@ static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,struct ethtool_rx_flow_spec *fs = &rxnfc->fs;struct mv88e6xxx_chip *chip = ds->priv;struct mv88e6xxx_policy *policy; +u32 cnt =0 ;int err;int id;
@@ -2020,11 +2021,18 @@ static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,break ;case ETHTOOL_GRXCLSRLALL : rxnfc->data =0 ; - rxnfc->rule_cnt =0 ; -idr_for_each_entry (&chip->policies, policy, id) -if (policy->port == port) - rule_locs[rxnfc->rule_cnt++] = id; err =0 ; +idr_for_each_entry (&chip->policies, policy, id) { +if (policy->port != port) +continue ; +if (cnt == rxnfc->rule_cnt) { + err = -EMSGSIZE ; +break ; + } + rule_locs[cnt++] = id; + } +if (!err) + rxnfc->rule_cnt = cnt;break ;default : err = -EOPNOTSUPP ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 306/752 net: usb: cx82310_eth: drop URB after 0xffff reboot sentinel to prevent partial_data heap overflow
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Winter <[email protected]>
[ Upstream commit 5d50e90add8b4a978395e893e81954d19d58a7c5 ]
The 0xffff length sentinel detects a router reboot and schedules re-enabling of ethernet mode, but then falls through to the rest of the loop body. The next check is
} else if (len > CX82310_MTU) {which is the else of the just-matched if -- it never fires for len == 0xffff. The MTU bound that normally caps the incomplete-packet save path is silently bypassed.
With 0xffff > skb->len always true (rx_urb_size is 4096), the incomplete-packet branch saves dev->partial_len = skb->len bytes into dev->partial_data. partial_data is kmalloc(hard_mtu) = kmalloc(CX82310_MTU + 2) = 1516 bytes, but skb->len after the 2-byte header pull can be up to 4094. A device that sends a 4096-byte URB starting with [0xff 0xff] therefore copies 4094 device-provided bytes into a buffer allocated for 1516 bytes, exceeding its requested size by 2578 bytes.
The next URB then reads dev->partial_len (4094) back from the same 1516-byte buffer and dev->partial_rem (65535 - 4094 = 61441) from the new URB's ~4KB skb, both well past their allocations, and delivers the spliced result as a 64KB "frame" to the network stack.
Bail out of rx_fixup after scheduling the re-enable work; the remainder of a reboot-marker URB is not meaningful packet data. This restores the invariant that partial_len < CX82310_MTU + 2 on the save path, since every other route there has already passed the MTU check.
--- drivers/net/usb/cx82310_eth.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/usb/cx82310_eth.c +1 -0
@@ -282,6 +282,7 @@ static int cx82310_rx_fixup(struct usbnet *dev, struct sk_buff *skb)if (len ==0xffff ) {netdev_info (dev->net,"router was rebooted, re-enabling ethernet mode" );schedule_work (&priv->reenable_work); +return 0 ; }else if (len >CX82310_MTU ) {netdev_err (dev->net,"RX packet too long: %d B\n" , len);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 307/752 vxlan: reject dynamic fdb entries that reference a nexthop id
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Seungwon Bae <[email protected]>
[ Upstream commit 98fc57d167446b95b4e719815fe79edef93f8e7a ]
The commit cited in the Fixes tag allowed VXLAN FDB entries to point to FDB nexthops so that overlay traffic could be load balanced across multiple VTEPs. Such entries can only be configured from user space, cannot be learned and cannot roam. They only make sense with a user space control plane such as E-VPN where data plane learning is disabled.
Despite that, the VXLAN driver does not currently prevent such entries from being configured with the "dynamic" flag. The per-nexthop FDB list is only protected by the per-device hash lock, which is not sufficient when two VXLAN devices point to the same FDB nexthop and therefore share the list. Aging runs in softirq context without RTNL, so an entry deleted by one device can race with an addition or deletion from the other, leading to list corruption:
list_del corruption. next->prev should be ffff8881069d9548, but was dead000000000122. (next=ffff8881069d9448)
WARNING: CPU: 0 PID: 90 at lib/list_debug.c:65 __list_del_entry_valid_or_report+0x1aa/0x210 ... vxlan_fdb_destroy+0x5b8/0xad0 vxlan_cleanup+0x328/0x450 call_timer_fn+0x2a/0x1c0 run_timer_softirq+0x18c/0x210 BUG: KASAN: slab-use-after-free in vxlan_fdb_destroy
Fix this by rejecting the bogus configuration of dynamic FDB entries that point to FDB nexthops, both when created and when an existing entry is updated. As such, the per-nexthop FDB list is only ever mutated under the RTNL lock. Add test cases to make sure that this does not regress in the future.
--- drivers/net/vxlan/vxlan_core.c | 11 ++++++++ tools/testing/selftests/net/fib_nexthops.sh | 28 +++++++++++++++++++++ 2 files changed, 39 insertions(+)
drivers/net/vxlan/vxlan_core.c +11 -0
@@ -1066,6 +1066,12 @@ static int vxlan_fdb_update_existing(struct vxlan_dev *vxlan,return -EOPNOTSUPP ; } +if (rcu_access_pointer (f->nh) && + !(state & (NUD_PERMANENT |NUD_NOARP ))) { +NL_SET_ERR_MSG (extack,"Cannot make a nexthop fdb dynamic" ); +return -EOPNOTSUPP ; + } +/* Do not allow an externally learned entry to take over an entry added * by the user. */
@@ -1318,6 +1324,11 @@ static int vxlan_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],if (err)return err; +if (nhid && !(ndm->ndm_state & (NUD_PERMANENT |NUD_NOARP ))) { +NL_SET_ERR_MSG (extack,"A nexthop fdb cannot be dynamic" ); +return -EINVAL ; + } +if (vxlan->default_dst.remote_ip.sa.sa_family != ip.sa.sa_family)return -EAFNOSUPPORT ;
tools/testing/selftests/net/fib_nexthops.sh +28 -0
@@ -475,6 +475,20 @@ ipv6_fdb_grp_fcnal() run_cmd "$BRIDGE fdb add 02:02:00:00:00:14 dev vx10 nhid 61 self" log_test $? 255 "Fdb mac add with nexthop" + # fdb entries with a nexthop group cannot be aged out + run_cmd "$BRIDGE fdb add 02:02:00:00:00:15 dev vx10 nhid 102 self static" + log_test $? 0 "Fdb mac add with nexthop group and static state" + + run_cmd "$BRIDGE fdb add 02:02:00:00:00:16 dev vx10 nhid 102 self dynamic" + log_test $? 255 "Fdb mac add with nexthop group and dynamic state" + + run_cmd "$BRIDGE fdb add 02:02:00:00:00:17 dev vx10 nhid 102 self" + run_cmd "$BRIDGE fdb replace 02:02:00:00:00:17 dev vx10 dst 2001:db8:91::11 self dynamic" + log_test $? 255 "Fdb mac replace with nexthop group and dynamic state" + + run_cmd "$BRIDGE fdb append 02:02:00:00:00:17 dev vx10 dst 2001:db8:91::11 self dynamic" + log_test $? 255 "Fdb mac append with nexthop group and dynamic state" + run_cmd "$IP -6 ro add 2001:db8:101::1/128 nhid 66" log_test $? 2 "Route add with fdb nexthop"
@@ -555,6 +569,20 @@ ipv4_fdb_grp_fcnal() run_cmd "$BRIDGE fdb add 02:02:00:00:00:14 dev vx10 nhid 12 self" log_test $? 255 "Fdb mac add with nexthop" + # fdb entries with a nexthop group cannot be aged out + run_cmd "$BRIDGE fdb add 02:02:00:00:00:15 dev vx10 nhid 102 self static" + log_test $? 0 "Fdb mac add with nexthop group and static state" + + run_cmd "$BRIDGE fdb add 02:02:00:00:00:16 dev vx10 nhid 102 self dynamic" + log_test $? 255 "Fdb mac add with nexthop group and dynamic state" + + run_cmd "$BRIDGE fdb add 02:02:00:00:00:17 dev vx10 nhid 102 self" + run_cmd "$BRIDGE fdb replace 02:02:00:00:00:17 dev vx10 dst 10.0.0.3 self dynamic" + log_test $? 255 "Fdb mac replace with nexthop group and dynamic state" + + run_cmd "$BRIDGE fdb append 02:02:00:00:00:17 dev vx10 dst 10.0.0.3 self dynamic" + log_test $? 255 "Fdb mac append with nexthop group and dynamic state" + run_cmd "$IP ro add 172.16.0.0/22 nhid 16" log_test $? 2 "Route add with fdb nexthop"
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 308/752 net: cap tx_queue_len at S16_MAX to prevent oversized ring allocations
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 66ab4c59b74db7ab53a1c9083feaaede393a96a0 ]
Several subsystems allocate ring buffers sized by dev->tx_queue_len with no upper bound. An unprivileged user (via unshare -Urn) can set a huge tx_queue_len and exhaust global memory with ring allocations:
- pfifo_fast: pfifo_fast_init() and pfifo_fast_change_tx_queue_len() allocate 3 skb_array rings of tx_queue_len entries each.
- tun: tun_queue_resize() and the queue-attach path resize ptr_rings to tx_queue_len on the NETDEV_CHANGE_TX_QUEUE_LEN notifier.
- tap (macvtap/ipvtap): tap_queue_resize() and tap_init() resize/init ptr_rings to tx_queue_len on the same notifier.
netif_change_tx_queue_len() is the single entry point for IFLA_TXQLEN, sysfs, and the SIOCSIFTXQLEN ioctl. Cap new_len at S16_MAX (32767) there so the oversized value is rejected at set time. This takes effect whether the device is up or down, before dev->tx_queue_len is written, before any notifier fires, and before any ring is allocated. The "> S16_MAX" check also subsumes the previous unsigned-long truncation test, and a negative ifr_qlen from the ioctl lands far above the cap after conversion, so both old failure modes are covered by the one comparison.
tx_queue_len is ambigious: both a per-ring sizing multiplier and a default queue-length/limit knob for consumers that allocate nothing at set time (pfifo/bfifo/gred/plug/sfb limits, htb direct_qlen, qfq max_classes, teql). 32767 is chosen as the largest value NLA_POLICY_FULL_RANGE can express for the u32 IFLA_TXQLEN policy in patch 2/3 while staying a legitimate queue length on high-BDP paths; the ring-memory trade-off of a shared knob is disclosed below.
Conditions to recreate the bug:
- CONFIG_NET_SCHED=y, CONFIG_VETH=y, CONFIG_USER_NS=y, CONFIG_NET_NS=y.
- Unprivileged user in a fresh user+net namespace (unshare -Urn).
- pfifo_fast: create veth pairs, set tx_queue_len to 500000, attach mq+pfifo_fast. ~28 iterations OOMs a 2GB guest.
- tun: create 50 tun devices with IFF_MULTI_QUEUE, set tx_queue_len to 500000, open 8 queues each. ~1.6GB of ptr_ring allocations OOMs a 512MB guest.
- tap: same as tun with IFF_TAP. ~960MB OOMs a 512MB guest.
- On the fixed kernel the oversized tx_queue_len is rejected with -ERANGE at set time (all four paths: RTM_SETLINK, RTM_NEWLINK create, sysfs, ioctl - the latter two via this check, the former two via this check and the 2/3 parse policy respectively).
--- net/core/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/dev.c +1 -1
@@ -9056,7 +9056,7 @@ int dev_change_tx_queue_len(struct net_device *dev, unsigned long new_len)unsigned int orig_len = dev->tx_queue_len;int res; -if (new_len != (unsigned int )new_len) +if (new_len >S16_MAX )return -ERANGE ;if (new_len != orig_len) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 309/752 powerpc/kexec_file: Use inclusive range checks in add_usable_mem()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit c6755be4838d6ccd641effbcdc3d917b82631ff9 ]
add_usable_mem() adds usable memory ranges for the kdump kernel.
The ranges are inclusive, but the partial overlap check uses exclusive comparisons. This skips ranges with base == loc_end or end == loc_base. Use inclusive comparisons instead.
--- arch/powerpc/kexec/file_load_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kexec/file_load_64.c +1 -1
@@ -478,7 +478,7 @@ static int add_usable_mem(struct umem_info *um_info, u64 base, u64 end) loc_end = um_info->ranges[i].end;if (loc_base >= base && loc_end <= end) add = true; -else if (base < loc_end && end > loc_base) { +else if (base <= loc_end && end >= loc_base) {if (loc_base < base) loc_base = base;if (loc_end > end)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 310/752 net/mlx5e: Fix setting RS FEC after remapping
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shahar Shitrit <[email protected]>
[ Upstream commit b9d755c5a37519fb1354034db1dfeb30e1ba6856 ]
When a user sets a FEC mode via ethtool, the driver maps the ethtool FEC type to the lowest mlx5 bit of that type. For RS FEC, this is MLX5E_FEC_RS_528_514 (bit 2). The driver then checks whether this bit is supported by at least one link mode by inspecting the fec_override_cap fields via mlx5e_fec_in_caps(), and returns -EOPNOTSUPP if not.
This check is incorrect. RS FEC has three supported hardware variants:RS_528_514 (bit 2), RS_544_514_INTERLEAVED_QUAD (bit 4), and RS_544_514 (bit 7). mlx5e_remap_fec_conf_mode() already remaps bit 2 to the appropriate RS variant per link mode when writing the admin fields, but the early capability check is done against the raw unmapped bit. As a result, a device that supports RS_544_514 or RS_544_514_INTERLEAVED_QUAD but not RS_528_514 will incorrectly reject the user's RS FEC request.
Remove the early support check from mlx5e_set_fec_mode() and fold it into the existing write loop, checking caps against the remapped policy per link mode. Return -EOPNOTSUPP before the final register write if no link mode accepted the policy.
--- drivers/net/ethernet/mellanox/mlx5/core/en/port.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/port.c +9 -6
@@ -542,6 +542,7 @@ int mlx5e_set_fec_mode(struct mlx5_core_dev *dev, u16 fec_policy)u32 in[MLX5_ST_SZ_DW (pplm_reg)] = {};int sz =MLX5_ST_SZ_BYTES (pplm_reg);u16 fec_policy_auto =0 ; +bool fec_set = false;int err;int i;
@@ -554,9 +555,6 @@ int mlx5e_set_fec_mode(struct mlx5_core_dev *dev, u16 fec_policy)if (fec_policy >= (1 <<MLX5E_FEC_LLRS_272_257_1 ) && !fec_50g_per_lane)return -EOPNOTSUPP ; -if (fec_policy && !mlx5e_fec_in_caps (dev, fec_policy)) -return -EOPNOTSUPP ; -MLX5_SET (pplm_reg, in, local_port,1 ); err =mlx5_core_access_reg (dev, in, sz, out, sz,MLX5_REG_PPLM ,0 ,0 );if (err)
@@ -583,12 +581,17 @@ int mlx5e_set_fec_mode(struct mlx5_core_dev *dev, u16 fec_policy)mlx5e_get_fec_cap_field (out, &fec_caps, i);/* policy supported for link speed */ -if (fec_caps & conf_fec) +if (fec_caps & conf_fec) {mlx5e_fec_admin_field (out, &conf_fec,1 , i); -else -/* set FEC to auto*/ + fec_set = true; + }else { +/* set FEC to auto */ mlx5e_fec_admin_field (out, &fec_policy_auto,1 , i); + } } +if (fec_policy && !fec_set) +return -EOPNOTSUPP ; +return mlx5_core_access_reg (dev, out, sz, out, sz,MLX5_REG_PPLM ,0 ,1 ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 311/752 net/mlx5e: Fix ETS zero BW reporting when one TC holds 100%
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carolina Jubran <[email protected]>
[ Upstream commit e7ee89740800a1cf253713e9249c3ee9203ebe91 ]
When ETS TCs with zero bandwidth are configured, the driver programs the firmware using an alternate representation. On get, it needs to recognize that representation so those TCs can be translated back and reported as 0% bandwidth.
The existing detection relied on the programmed bandwidth because it was enough to identify this representation. However, when a single ETS TC owns 100% of the bandwidth, its firmware representation becomes the same as a strict-priority TC, causing zero-bandwidth ETS TCs to be reported with non-zero bandwidth values.
Use the cached TSA instead to distinguish the ETS and strict-priority cases.
--- drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c +1 -1
@@ -133,7 +133,7 @@ static int mlx5e_dcbnl_ieee_getets(struct net_device *netdev,if (err)return err; -if (ets->tc_tx_bw[i] <MLX5E_MAX_BW_ALLOC && +if (priv->dcbx.tc_tsa[i] ==IEEE_8021QAZ_TSA_ETS && tc_group[i] == (MLX5E_LOWEST_PRIO_GROUP +1 )) is_zero_bw_ets_tc = true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 312/752 net/mlx5e: Fix use-after-free race in sample_restore_put()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carolina Jubran <[email protected]>
[ Upstream commit af3aef0245abbab5e9f6302e7a7d6407187afb71 ]
Concurrent teardown of TC sample rules sharing the same restore context may re-read restore->count after dropping restore_lock. At that point another thread may already have completed cleanup and freed the restore object.
Use the result of the refcount decrement while holding restore_lock to determine whether cleanup is needed.
--- drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c +5 -2
@@ -335,12 +335,15 @@ sample_restore_get(struct mlx5e_tc_psample *tc_psample, u32 obj_id,static void sample_restore_put (struct mlx5e_tc_psample *tc_psample,struct mlx5e_sample_restore *restore) { +bool last; +mutex_lock (&tc_psample->restore_lock); -if (--restore->count ==0 ) + last = --restore->count ==0 ; +if (last)hash_del (&restore->hlist);mutex_unlock (&tc_psample->restore_lock); -if (!restore->count) { +if (last) {mlx5_del_flow_rules (restore->rule);mlx5_modify_header_dealloc (tc_psample->esw->dev, restore->modify_hdr);kfree (restore);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 313/752 net/mlx5: E-Switch: fix use-after-free in mlx5_eswitch_termtbl_put
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yael Chemla <[email protected]>
[ Upstream commit 7ee07f601f8f507c9faf25c68a49396ab8950596 ]
In mlx5_eswitch_termtbl_put(), the zero-ref cleanup check reads tt->ref_count after termtbl_mutex has been released. Two concurrent callers on the same mlx5_termtbl_handle race: one decrements ref_count to zero, removes the hash entry, and calls kfree(tt) while the other has already dropped the mutex and is about to evaluate
if (!tt->ref_count), producing a use-after-free.
Fix this by capturing the result of the decrement into a stack-local last variable before dropping the mutex. The cleanup decision is now made entirely under termtbl_mutex, and tt is not touched after kfree.
--- .../ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c +5 -2
@@ -163,12 +163,15 @@ void mlx5_eswitch_termtbl_put(struct mlx5_eswitch *esw, struct mlx5_termtbl_handle *tt) { + bool last; +mutex_lock (&esw->offloads.termtbl_mutex); -if (--tt->ref_count ==0 ) + last = (--tt->ref_count ==0 ); +if (last)hash_del (&tt->termtbl_hlist);mutex_unlock (&esw->offloads.termtbl_mutex); -if (!tt->ref_count) { +if (last) {mlx5_del_flow_rules (tt->rule);mlx5_destroy_flow_table (tt->termtbl);kfree (tt);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 314/752 net/mlx5: E-Switch, prevent mc_list repopulation during vport disable
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lama Kayal <[email protected]>
[ Upstream commit c0c6f4ba8a37688f7b4d4044898d88f0450d44c2 ]
In mlx5_esw_vport_disable(), move esw_apply_vport_rx_mode() ahead of esw_vport_change_handle_locked() so vport->allmulti_rule is NULL before the change handler observes it.
During FW-fatal recovery the disable runs while dev->state == INTERNAL_ERROR. The promisc query inside esw_update_vport_rx_mode() fails and returns early, leaving vport->allmulti_rule intact, so esw_update_vport_mc_promisc() runs and adds MLX5_ACTION_ADD entries to vport->mc_list whose flow rules are then installed in the FDB by esw_add_mc_addr(). esw_destroy_legacy_table() tears down the FDB with those refs still held, corrupting the sub-tree and leaving dangling flow_rule pointers in vport->mc_list.
Two-stage failure on echo 1 > /sys/bus/pci/devices/<bdf>/reset:
refcount_t: underflow; use-after-free.
tree_put_node+0xef/0x110 [mlx5_core] clean_tree+0x44/0xd0 [mlx5_core] (x5) mlx5_fs_core_cleanup+0x57/0x1c0 [mlx5_core] mlx5_unload+0x65/0xd0 [mlx5_core] ... mlx5_health_try_recover BUG: unable to handle page fault for address: 0000000003000055 down_write+0x1c/0x60 mlx5_del_flow_rules+0x33/0x1f0 [mlx5_core] esw_del_mc_addr+0x7b/0x170 [mlx5_core] esw_apply_vport_addr_list+0x56/0xf0 [mlx5_core] esw_vport_change_handle_locked+0x28b/0x310 [mlx5_core] mlx5_esw_vport_enable+0x270/0x4a0 [mlx5_core] ... mlx5_load ... mlx5_health_try_recover
esw_apply_vport_rx_mode(false, false) clears vport->allmulti_rule via its local state machine even when the FW del fails. With the rule NULL the !IS_ERR_OR_NULL(allmulti_rule) gate in the change handler closes, no rules are installed during disable, and the reload starts with a clean mc_list.
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +7 -1
@@ -912,13 +912,19 @@ void mlx5_esw_vport_disable(struct mlx5_eswitch *esw, u16 vport_num) MLX5_CAP_GEN(esw->dev, vhca_resource_manager))mlx5_esw_vport_vhca_id_clear (esw, vport_num); +/* Clear rx-mode before esw_vport_change_handle_locked(): on +* MLX5_VPORT_PROMISC_CHANGE it calls esw_update_vport_mc_promisc() +* when vport->allmulti_rule is set, repopulating mc_list with FDB +* rules that dangle once the FDB is destroyed. NULL allmulti_rule +* here skips that path. +*/ +esw_apply_vport_rx_mode (esw, vport, false, false);/* We don't assume VFs will cleanup after themselves. * Calling vport change handler while vport is disabled will cleanup * the vport resources. */ esw_vport_change_handle_locked (vport); vport->enabled_events =0 ; -esw_apply_vport_rx_mode (esw, vport, false, false);esw_vport_cleanup (esw, vport); esw->enabled_vports--;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 315/752 net_sched: sch_fq_pie: implement lockless fq_pie_dump()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 13a9965de32457d59aa3162d657aa4c5e512c146 ]
Instead of relying on RTNL, fq_pie_dump() can use READ_ONCE() annotations, paired with WRITE_ONCE() ones in fq_pie_change().
Stable-dep-of: 4864f58c53eb ("net/sched: fq_pie: clamp quantum in change path")
--- net/sched/sch_fq_pie.c | 61 +++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 27 deletions(-)
net/sched/sch_fq_pie.c +34 -27
@@ -301,8 +301,8 @@ static int fq_pie_change(struct Qdisc *sch, struct nlattr *opt,if (tb[TCA_FQ_PIE_LIMIT ]) {u32 limit =nla_get_u32 (tb[TCA_FQ_PIE_LIMIT ]); - q->p_params.limit = limit; - sch->limit = limit; +WRITE_ONCE (q->p_params.limit, limit); +WRITE_ONCE (sch->limit, limit); }if (tb[TCA_FQ_PIE_FLOWS ]) {if (q->flows) {
@@ -324,39 +324,45 @@ static int fq_pie_change(struct Qdisc *sch, struct nlattr *opt,u32 target =nla_get_u32 (tb[TCA_FQ_PIE_TARGET ]);/* convert to pschedtime */ - q->p_params.target = -PSCHED_NS2TICKS ((u64 )target *NSEC_PER_USEC ); +WRITE_ONCE (q->p_params.target, +PSCHED_NS2TICKS ((u64 )target *NSEC_PER_USEC )); }/* tupdate is in jiffies */ if (tb[TCA_FQ_PIE_TUPDATE ]) - q->p_params.tupdate = -usecs_to_jiffies (nla_get_u32 (tb[TCA_FQ_PIE_TUPDATE ])); +WRITE_ONCE (q->p_params.tupdate, +usecs_to_jiffies (nla_get_u32 (tb[TCA_FQ_PIE_TUPDATE ])));if (tb[TCA_FQ_PIE_ALPHA ]) - q->p_params.alpha =nla_get_u32 (tb[TCA_FQ_PIE_ALPHA ]); +WRITE_ONCE (q->p_params.alpha, +nla_get_u32 (tb[TCA_FQ_PIE_ALPHA ]));if (tb[TCA_FQ_PIE_BETA ]) - q->p_params.beta =nla_get_u32 (tb[TCA_FQ_PIE_BETA ]); +WRITE_ONCE (q->p_params.beta, +nla_get_u32 (tb[TCA_FQ_PIE_BETA ]));if (tb[TCA_FQ_PIE_QUANTUM ]) - q->quantum =nla_get_u32 (tb[TCA_FQ_PIE_QUANTUM ]); +WRITE_ONCE (q->quantum,nla_get_u32 (tb[TCA_FQ_PIE_QUANTUM ]));if (tb[TCA_FQ_PIE_MEMORY_LIMIT ]) - q->memory_limit =nla_get_u32 (tb[TCA_FQ_PIE_MEMORY_LIMIT ]); +WRITE_ONCE (q->memory_limit, +nla_get_u32 (tb[TCA_FQ_PIE_MEMORY_LIMIT ]));if (tb[TCA_FQ_PIE_ECN_PROB ]) - q->ecn_prob =nla_get_u32 (tb[TCA_FQ_PIE_ECN_PROB ]); +WRITE_ONCE (q->ecn_prob, +nla_get_u32 (tb[TCA_FQ_PIE_ECN_PROB ]));if (tb[TCA_FQ_PIE_ECN ]) - q->p_params.ecn =nla_get_u32 (tb[TCA_FQ_PIE_ECN ]); +WRITE_ONCE (q->p_params.ecn, +nla_get_u32 (tb[TCA_FQ_PIE_ECN ]));if (tb[TCA_FQ_PIE_BYTEMODE ]) - q->p_params.bytemode =nla_get_u32 (tb[TCA_FQ_PIE_BYTEMODE ]); +WRITE_ONCE (q->p_params.bytemode, +nla_get_u32 (tb[TCA_FQ_PIE_BYTEMODE ]));if (tb[TCA_FQ_PIE_DQ_RATE_ESTIMATOR ]) - q->p_params.dq_rate_estimator = -nla_get_u32 (tb[TCA_FQ_PIE_DQ_RATE_ESTIMATOR ]); +WRITE_ONCE (q->p_params.dq_rate_estimator, +nla_get_u32 (tb[TCA_FQ_PIE_DQ_RATE_ESTIMATOR ]));/* Drop excess packets if new limit is lower */ while (sch->q.qlen > sch->limit) {
@@ -472,22 +478,23 @@ static int fq_pie_dump(struct Qdisc *sch, struct sk_buff *skb)return -EMSGSIZE ;/* convert target from pschedtime to us */ -if (nla_put_u32 (skb,TCA_FQ_PIE_LIMIT , sch->limit) || -nla_put_u32 (skb,TCA_FQ_PIE_FLOWS , q->flows_cnt) || +if (nla_put_u32 (skb,TCA_FQ_PIE_LIMIT ,READ_ONCE (sch->limit)) || +nla_put_u32 (skb,TCA_FQ_PIE_FLOWS ,READ_ONCE (q->flows_cnt)) ||nla_put_u32 (skb,TCA_FQ_PIE_TARGET , - ((u32 )PSCHED_TICKS2NS (q->p_params.target)) / + ((u32 )PSCHED_TICKS2NS (READ_ONCE (q->p_params.target))) /NSEC_PER_USEC ) ||nla_put_u32 (skb,TCA_FQ_PIE_TUPDATE , -jiffies_to_usecs (q->p_params.tupdate)) || -nla_put_u32 (skb,TCA_FQ_PIE_ALPHA , q->p_params.alpha) || -nla_put_u32 (skb,TCA_FQ_PIE_BETA , q->p_params.beta) || -nla_put_u32 (skb,TCA_FQ_PIE_QUANTUM , q->quantum) || -nla_put_u32 (skb,TCA_FQ_PIE_MEMORY_LIMIT , q->memory_limit) || -nla_put_u32 (skb,TCA_FQ_PIE_ECN_PROB , q->ecn_prob) || -nla_put_u32 (skb,TCA_FQ_PIE_ECN , q->p_params.ecn) || -nla_put_u32 (skb,TCA_FQ_PIE_BYTEMODE , q->p_params.bytemode) || +jiffies_to_usecs (READ_ONCE (q->p_params.tupdate))) || +nla_put_u32 (skb,TCA_FQ_PIE_ALPHA ,READ_ONCE (q->p_params.alpha)) || +nla_put_u32 (skb,TCA_FQ_PIE_BETA ,READ_ONCE (q->p_params.beta)) || +nla_put_u32 (skb,TCA_FQ_PIE_QUANTUM ,READ_ONCE (q->quantum)) || +nla_put_u32 (skb,TCA_FQ_PIE_MEMORY_LIMIT , +READ_ONCE (q->memory_limit)) || +nla_put_u32 (skb,TCA_FQ_PIE_ECN_PROB ,READ_ONCE (q->ecn_prob)) || +nla_put_u32 (skb,TCA_FQ_PIE_ECN ,READ_ONCE (q->p_params.ecn)) || +nla_put_u32 (skb,TCA_FQ_PIE_BYTEMODE ,READ_ONCE (q->p_params.bytemode)) ||nla_put_u32 (skb,TCA_FQ_PIE_DQ_RATE_ESTIMATOR , - q->p_params.dq_rate_estimator)) +READ_ONCE (q->p_params.dq_rate_estimator))) goto nla_put_failure;return nla_nest_end (skb, opts);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 316/752 net/sched: fq_pie: clamp quantum in change path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 4864f58c53eb47257d55e01f47d4a9f355f7f970 ]
fq_pie_change() accepts any quantum value from userspace, including 1. With a crafted size table qdisc_pkt_len reaches ~2 GiB, so quantum=1 makes the deficit-refill loop spin ~2^31 times under the qdisc lock (a soft lockup / denial of service).
Add max(256U, ...) matching fq_codel_change().
Conditions to recreate the bug:
CONFIG_NET_SCH_FQ_PIE=y. Requires CAP_NET_ADMIN (namespace-local via unshare -Urn suffices).
tc qdisc add dev dummy0 root fq_pie
tc qdisc change dev dummy0 root fq_pie quantum 1 stab data 32768 size_log 15 cell_log 0
--- net/sched/sch_fq_pie.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/sched/sch_fq_pie.c +2 -1
@@ -342,7 +342,8 @@ static int fq_pie_change(struct Qdisc *sch, struct nlattr *opt, nla_get_u32(tb[TCA_FQ_PIE_BETA]));if (tb[TCA_FQ_PIE_QUANTUM ]) -WRITE_ONCE (q->quantum,nla_get_u32 (tb[TCA_FQ_PIE_QUANTUM ])); +WRITE_ONCE (q->quantum, +max (256U ,nla_get_u32 (tb[TCA_FQ_PIE_QUANTUM ])));if (tb[TCA_FQ_PIE_MEMORY_LIMIT ]) WRITE_ONCE(q->memory_limit,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 317/752 net/sched: sfq: clamp quantum in change path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit fb9f88a33c516ea5c0bcd9a22ca288b246b34567 ]
sfq_change() accepts any non-negative quantum (only rejects (int)ctl->quantum < 0). With a crafted size table qdisc_pkt_len reaches ~2 GiB, so quantum=1 makes the deficit-refill loop spin ~2^31 times under the qdisc lock (a soft lockup / denial of service).
Add max(256U, ...) matching fq_codel_change(). Reject quantum > 1<<20 with -EINVAL, matching fq_codel_change() and the init clamp.
Conditions to recreate the bug:
CONFIG_NET_SCH_SFQ=y. Requires CAP_NET_ADMIN (namespace-local via unshare -Urn suffices).
tc qdisc add dev dummy0 root sfq
tc qdisc change dev dummy0 root sfq quantum 1 stab data 32768 size_log 15 cell_log 0
--- net/sched/sch_sfq.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/sched/sch_sfq.c +6 -1
@@ -654,6 +654,11 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt,return -EINVAL ; } +if (ctl->quantum >1 <<20 ) { +NL_SET_ERR_MSG_MOD (extack,"quantum too large" ); +return -EINVAL ; + } +if (ctl->perturb_period <0 || ctl->perturb_period >INT_MAX /HZ ) {NL_SET_ERR_MSG_MOD (extack,"invalid perturb period" );
@@ -682,7 +687,7 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt,/* update and validate configuration */ if (ctl->quantum) - quantum = ctl->quantum; + quantum =max (256U , ctl->quantum);if (ctl->flows) maxflows =min_t (u32, ctl->flows,SFQ_MAX_FLOWS );if (ctl->divisor) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 318/752 net/sched: hhf: clamp quantum in change and init paths
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit eb56a495f59baf6cad5ed80e3ffb9078098b1346 ]
hhf_change() accepts any quantum from userspace, including 1. With a crafted size table qdisc_pkt_len reaches ~2 GiB, so quantum=1 makes the deficit-refill loop spin ~2^31 times under the qdisc lock (a soft lockup / denial of service).
Add max(256U, ...) in hhf_change() matching fq_codel_change(). Clamp hhf_init() to [256, 1<<20] matching the siblings, and remove the old fallback that only set quantum=256 on overflow.
Conditions to recreate the bug:
CONFIG_NET_SCH_HHF=y. Requires CAP_NET_ADMIN (namespace-local via unshare -Urn suffices).
tc qdisc add dev dummy0 root hhf
tc qdisc change dev dummy0 root hhf quantum 1 stab data 32768 size_log 15 cell_log 0
--- net/sched/sch_hhf.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
net/sched/sch_hhf.c +2 -6
@@ -553,7 +553,7 @@ static int hhf_change(struct Qdisc *sch, struct nlattr *opt,return err;if (tb[TCA_HHF_QUANTUM ]) - new_quantum =nla_get_u32 (tb[TCA_HHF_QUANTUM ]); + new_quantum =max (256U ,nla_get_u32 (tb[TCA_HHF_QUANTUM ]));if (tb[TCA_HHF_NON_HH_WEIGHT ]) new_hhf_non_hh_weight =nla_get_u32 (tb[TCA_HHF_NON_HH_WEIGHT ]);
@@ -609,7 +609,7 @@ static int hhf_init(struct Qdisc *sch, struct nlattr *opt,int i; sch->limit =1000 ; - q->quantum =psched_mtu (qdisc_dev (sch)); + q->quantum =clamp_t (u32,psched_mtu (qdisc_dev (sch)),256 ,1 <<20 );get_random_bytes (&q->perturbation,sizeof (q->perturbation));INIT_LIST_HEAD (&q->new_buckets);INIT_LIST_HEAD (&q->old_buckets);
@@ -620,10 +620,6 @@ static int hhf_init(struct Qdisc *sch, struct nlattr *opt, q->hhf_evict_timeout =HZ ;/* 1 sec */ q->hhf_non_hh_weight =2 ; -if ((int )q->quantum <=0 || - (u64 )q->quantum * q->hhf_non_hh_weight >INT_MAX ) - q->quantum =256 ; -if (opt) {int err =hhf_change (sch, opt, extack);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 319/752 net/sched: pie: clamp psched_mtu in pie_drop_early
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 54370e44c002770ae61fc889f28f699e91616ffc ]
pie_drop_early() calls psched_mtu() with no clamp. With mtu=0x80000000 the bytemode divide silently zeroes the drop probability, disabling AQM. Clamp to [1, 1<<20].
Conditions to recreate the bug:
CONFIG_NET_SCH_PIE=y. Requires CAP_NET_ADMIN (namespace-local via unshare -Urn suffices).
tc qdisc add dev dummy0 root pie
tc qdisc change dev dummy0 root pie stab data 32768 size_log 15 cell_log 0
--- net/sched/sch_pie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_pie.c +1 -1
@@ -35,7 +35,7 @@ bool pie_drop_early(struct Qdisc *sch, struct pie_params *params, {u64 rnd;u64 local_prob = vars->prob; -u32 mtu =psched_mtu (qdisc_dev (sch)); +u32 mtu =clamp_t (u32,psched_mtu (qdisc_dev (sch)),1 ,1 <<20 );/* If there is still burst allowance left skip random early drop */ if (vars->burst_time >0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 320/752 net/sched: drr: clamp quantum in change class
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 8382abec0f1568d0a5590d75a3df92f23fcf5196 ]
drr_change_class() rejects explicit quantum==0 but falls back to psched_mtu() with no floor. With a crafted size table qdisc_pkt_len reaches ~2 GiB, so quantum=1 (or a zero psched_mtu on a headerless device) makes the deficit-refill loop spin under the qdisc lock.
Add clamp_t(u32, quantum, 256, 1<<20) after the zero reject and on the fallback path. The explicit-zero reject is preserved.
Conditions to recreate the bug:
CONFIG_NET_SCH_DRR=y. Requires CAP_NET_ADMIN (namespace-local via unshare -Urn suffices).
tc qdisc add dev dummy0 root drr
tc class add dev dummy0 parent 1: classid 1:1 drr quantum 1
--- net/sched/sch_drr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/sched/sch_drr.c +2 -1
@@ -83,8 +83,9 @@ static int drr_change_class(struct Qdisc *sch, u32 classid, u32 parentid,NL_SET_ERR_MSG (extack,"Specified DRR quantum cannot be zero" );return -EINVAL ; } + quantum =clamp_t (u32, quantum,256 ,1 <<20 ); }else - quantum =psched_mtu (qdisc_dev (sch)); + quantum =clamp_t (u32, (u32 )psched_mtu (qdisc_dev (sch)),256 ,1 <<20 );if (cl !=NULL ) {if (tca[TCA_RATE ]) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 321/752 net/sched: ets: clamp quantum in parse and fallback paths
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 1c38487f46b243bfeefec0c0c86023a3904f2214 ]
ets_qdisc_change() falls back to psched_mtu() with no floor for bands without an explicit quantum. With a crafted size table qdisc_pkt_len reaches ~2 GiB, so a zero psched_mtu on a headerless device makes the deficit-refill loop spin under the qdisc lock.
Move the floor into ets_quantum_parse() so explicitly configured quanta are also clamped to [256, 1<<20], not just the fallback path.
Conditions to recreate the bug:
CONFIG_NET_SCH_ETS=y. Requires CAP_NET_ADMIN (namespace-local via unshare -Urn suffices).
tc qdisc add dev dummy0 root ets bands 3 strict 2 quanta 1 1
--- net/sched/sch_ets.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
net/sched/sch_ets.c +5 -7
@@ -83,11 +83,7 @@ static int ets_quantum_parse(struct Qdisc *sch, const struct nlattr *attr,unsigned int *quantum, struct netlink_ext_ack *extack) { - *quantum =nla_get_u32 (attr); -if (!*quantum) { -NL_SET_ERR_MSG (extack,"ETS quantum cannot be zero" ); -return -EINVAL ; - } + *quantum =clamp_t (u32,nla_get_u32 (attr),256 ,1 <<20 );return 0 ; }
@@ -647,11 +643,13 @@ static int ets_qdisc_change(struct Qdisc *sch, struct nlattr *opt,return err; }/* If there are more bands than strict + quanta provided, the remaining -* ones are ETS with quantum of MTU. Initialize the missing values here. +* ones are ETS with quantum of max(MTU, 256). Initialize the missing +* values here. */ for (i = nstrict; i < nbands; i++) {if (!quanta[i]) - quanta[i] =psched_mtu (qdisc_dev (sch)); + quanta[i] =clamp_t (u32, (u32 )psched_mtu (qdisc_dev (sch)), +256 ,1 <<20 ); }/* Before commit, make sure we can allocate all new qdiscs */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 322/752 ALSA: caiaq: Decoupling ep1_in_urb in caiaq dev
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edward Adam Davis <[email protected]>
[ Upstream commit 402a9d6aab7ac787ab075adeb562c3db8b8f564b ]
The epq_in_urb object belonging to the caiaq device is coupled within the struct snd_usb_caiaqdev. After usb_submit_urb(epq_in_urb, GFP_KERNEL) executes successfully, epq_in_urb is successfully added to the urbp_list queue of the dummy HCD driver (userspace specifies dummy_hcd as the HCD layer driver for the caiaq USB device).
When init_card() calls snd_usb_caiaq_send_command() which subsequently fails due to a timeout, and proceeds to call snd_card_free() to release the card, the embedded ep1_in_urb object is also freed. When the dummy HCD driver detects that the URB has been unlinked, it returns the URB (by usb_hcd_giveback_urb()), which triggers [1].
Decouple the ep1_in_urb object from the struct snd_usb_caiaqdev and switch to using a pointer instead. Separately allocate and manage the memory for ep1_in_urb to prevent the release of the snd_card memory object from interfering with it.
midi_out_urb has the same issue as ep1_in_urb and is handled in the same way.
[1]
BUG: KASAN: slab-use-after-free in usb_free_urb+0x24/0x120 drivers/usb/core/urb.c:96 Write of size 4 at addr ffff88803cee1050 by task ktimers/1/29 Call Trace: usb_free_urb+0x24/0x120 drivers/usb/core/urb.c:96 dummy_timer+0xaac/0x4d50 drivers/usb/gadget/udc/dummy_hcd.c:2019 __run_hrtimer kernel/time/hrtimer.c:2067 [inline] __hrtimer_run_queues+0x3eb/0xaf0 kernel/time/hrtimer.c:2124 hrtimer_run_softirq+0x1e1/0x2e0 kernel/time/hrtimer.c:2141 Allocated by task 36: snd_card_new+0x7b/0x110 sound/core/init.c:184 create_card sound/usb/caiaq/device.c:429 [inline] snd_probe+0x236/0x1af0 sound/usb/caiaq/device.c:544 Freed by task 36: snd_card_free_when_closed sound/core/init.c:630 [inline] snd_card_free+0x138/0x1d0 sound/core/init.c:662 snd_probe+0x162b/0x1af0 sound/usb/caiaq/device.c:553
--- sound/usb/caiaq/device.c | 36 ++++++++++++++++++++++++------------ sound/usb/caiaq/device.h | 4 ++-- sound/usb/caiaq/midi.c | 6 +++--- 3 files changed, 29 insertions(+), 17 deletions(-)
sound/usb/caiaq/device.c +24 -12
@@ -192,8 +192,8 @@ static void usb_ep1_command_reply_dispatch (struct urb* urb)break ; } - cdev->ep1_in_urb.actual_length =0 ; - ret =usb_submit_urb (&cdev->ep1_in_urb,GFP_ATOMIC ); + cdev->ep1_in_urb->actual_length =0 ; + ret =usb_submit_urb (cdev->ep1_in_urb,GFP_ATOMIC );if (ret <0 )dev_err (dev,"unable to submit urb. OOM!?\n" ); }
@@ -408,6 +408,10 @@ static void card_free(struct snd_card *card)#endif snd_usb_caiaq_audio_free (cdev);usb_put_dev (cdev->chip.dev); +usb_free_urb (cdev->ep1_in_urb); + cdev->ep1_in_urb =NULL ; +usb_free_urb (cdev->midi_out_urb); + cdev->midi_out_urb =NULL ; } static int create_card(struct usb_device *usb_dev,
@@ -457,22 +461,30 @@ static int init_card(struct snd_usb_caiaqdev *cdev)return -EIO ; } -usb_init_urb (&cdev->ep1_in_urb); -usb_init_urb (&cdev->midi_out_urb); + cdev->ep1_in_urb =usb_alloc_urb (0 ,GFP_KERNEL ); +if (!cdev->ep1_in_urb) +return -ENOMEM ; -usb_fill_bulk_urb (&cdev->ep1_in_urb, usb_dev, + cdev->midi_out_urb =usb_alloc_urb (0 ,GFP_KERNEL ); +if (!cdev->midi_out_urb) { +usb_free_urb (cdev->ep1_in_urb); + cdev->ep1_in_urb =NULL ; +return -ENOMEM ; + } + +usb_fill_bulk_urb (cdev->ep1_in_urb, usb_dev,usb_rcvbulkpipe (usb_dev,0x1 ), cdev->ep1_in_buf,EP1_BUFSIZE , usb_ep1_command_reply_dispatch, cdev); -usb_fill_bulk_urb (&cdev->midi_out_urb, usb_dev, +usb_fill_bulk_urb (cdev->midi_out_urb, usb_dev,usb_sndbulkpipe (usb_dev,0x1 ), cdev->midi_out_buf,EP1_BUFSIZE , snd_usb_caiaq_midi_output_done, cdev);/* sanity checks of EPs before actually submitting */ -if (usb_urb_ep_type_check (&cdev->ep1_in_urb) || -usb_urb_ep_type_check (&cdev->midi_out_urb)) { +if (usb_urb_ep_type_check (cdev->ep1_in_urb) || +usb_urb_ep_type_check (cdev->midi_out_urb)) {dev_err (dev,"invalid EPs\n" );return -EINVAL ; }
@@ -480,7 +492,7 @@ static int init_card(struct snd_usb_caiaqdev *cdev)init_waitqueue_head (&cdev->ep1_wait_queue);init_waitqueue_head (&cdev->prepare_wait_queue); -if (usb_submit_urb (&cdev->ep1_in_urb,GFP_KERNEL ) !=0 ) +if (usb_submit_urb (cdev->ep1_in_urb,GFP_KERNEL ) !=0 )return -EIO ; err =snd_usb_caiaq_send_command (cdev,EP1_CMD_GET_DEVICE_INFO ,NULL ,0 );
@@ -530,7 +542,7 @@ static int init_card(struct snd_usb_caiaqdev *cdev)return 0 ; err_kill_urb: -usb_kill_urb (&cdev->ep1_in_urb); +usb_kill_urb (cdev->ep1_in_urb);return err; }
@@ -576,8 +588,8 @@ static void snd_disconnect(struct usb_interface *intf)#endif snd_usb_caiaq_audio_disconnect (cdev); -usb_kill_urb (&cdev->ep1_in_urb); -usb_kill_urb (&cdev->midi_out_urb); +usb_kill_urb (cdev->ep1_in_urb); +usb_kill_urb (cdev->midi_out_urb);snd_card_free_when_closed (card); }
sound/usb/caiaq/device.h +2 -2
@@ -60,8 +60,8 @@ struct snd_usb_caiaq_cb_info;struct snd_usb_caiaqdev {struct snd_usb_audio chip; -struct urb ep1_in_urb; -struct urb midi_out_urb; +struct urb *ep1_in_urb; +struct urb *midi_out_urb;struct urb **data_urbs_in;struct urb **data_urbs_out;struct snd_usb_caiaq_cb_info *data_cb_info;
sound/usb/caiaq/midi.c +3 -3
@@ -43,7 +43,7 @@ static int snd_usb_caiaq_midi_output_close(struct snd_rawmidi_substream *substre {struct snd_usb_caiaqdev *cdev = substream->rmidi->private_data;if (cdev->midi_out_active) { -usb_kill_urb (&cdev->midi_out_urb); +usb_kill_urb (cdev->midi_out_urb); cdev->midi_out_active =0 ; }return 0 ;
@@ -64,9 +64,9 @@ static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *cdev,return ; cdev->midi_out_buf[2 ] = len; - cdev->midi_out_urb.transfer_buffer_length = len+3 ; + cdev->midi_out_urb->transfer_buffer_length = len+3 ; - ret =usb_submit_urb (&cdev->midi_out_urb,GFP_ATOMIC ); + ret =usb_submit_urb (cdev->midi_out_urb,GFP_ATOMIC );if (ret <0 )dev_err (dev, "snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed,"
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 323/752 ASoC: bcm: bcm63xx: Publish the OF module aliases
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: hpp.iscas <[email protected]>
[ Upstream commit 32689f0fc54fd801f1cd11637666e534984cb04a ]
The BCM63xx I2S platform driver matches brcm,bcm63xx-i2s using snd_soc_bcm_audio_match. With SND_BCM63XX_I2S_WHISTLER=m, the platform bus emits an OF modalias but snd-soc-63xx does not publish that table.
Export the existing OF IDs for module autoloading. The PCM companion and the probe path remain unchanged.
--- sound/soc/bcm/bcm63xx-i2s-whistler.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/bcm/bcm63xx-i2s-whistler.c +1 -0
@@ -299,6 +299,7 @@ static const struct of_device_id snd_soc_bcm_audio_match[] = { {.compatible = "brcm,bcm63xx-i2s"}, { } }; +MODULE_DEVICE_TABLE (of, snd_soc_bcm_audio_match);#endif static struct platform_driver bcm63xx_i2s_driver = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 324/752 ASoC: Intel: SST: Publish the PCI module aliases
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: hpp.iscas <[email protected]>
[ Upstream commit d112159df5c6cc5ee6ab91cc32bf6ed29939df38 ]
The legacy SST PCI driver matches Intel Tangier devices using intel_sst_ids, but its only explicit module alias is "sst". That alias does not match PCI modalias events when this driver is built as a module.
Publish its PCI table. The independently configurable SOF driver does not provide aliases for the legacy SST module.
--- sound/soc/intel/atom/sst/sst_pci.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/intel/atom/sst/sst_pci.c +1 -0
@@ -179,6 +179,7 @@ static const struct pci_device_id intel_sst_ids[] = { { PCI_VDEVICE(INTEL, SST_MRFLD_PCI_ID), 0}, { 0, } }; +MODULE_DEVICE_TABLE (pci, intel_sst_ids);static struct pci_driver sst_driver = { .name = SST_DRV_NAME,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 325/752 netfilter: nfnetlink_log: cope with concurrent instance destruction
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit 387d744fa7e499d2c3748a4e60e02ebb24e7fb16 ]
Instances are refcounted. However, only memory release happens on the 1 -> 0 transition; the unlink from hashes can occur with any refcount.
Uncooperative userspace can force a situation where a queue is pending for destruction from netlink event while a different socket with same portid processes an UNBIND request.
With right timing, this will unhash the instance again:
Oops: general protection fault, [..] Call Trace: <TASK> nfulnl_recv_config+0x31a/0xd50 nfnetlink_rcv_msg+0x7c2/0xeb0
--- net/netfilter/nfnetlink_log.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
net/netfilter/nfnetlink_log.c +9 -4
@@ -217,13 +217,18 @@ static void __nfulnl_flush(struct nfulnl_instance *inst);static void __instance_destroy (struct nfulnl_instance *inst) { +spin_lock (&inst->lock); +if (inst->copy_mode ==NFULNL_COPY_DISABLED ) { +/* attempt to UNBIND a queue already pending +* destruction via netlink close event. Ignore. +*/ +spin_unlock (&inst->lock); +return ; + } +/* first pull it out of the global list */ hlist_del_rcu (&inst->hlist); -/* then flush all pending packets from skb */ - -spin_lock (&inst->lock); -/* lockless readers wont be able to use us */ inst->copy_mode =NFULNL_COPY_DISABLED ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 326/752 netfilter: ip6_tables: set F_PROTO when proto value is nonzero
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit da4afc5a956d407443988e97a4d4ca14c2e999c7 ]
The ip6tables traverser doesn't search the extension header chain unless userspace did set the IP6T_F_PROTO flag.
This also means that userspace that sets the e->ipv6.proto flag can bypass the protocol check for the rule by not setting this flag.
That in turn means that all ip6_tables modules and targets that want to reject rules without '-p' flag MUST also check for that flag.
Not all do, likely because they got copied from iptables which lacks this flag (no extension headers).
Instead of fixing up all the relevant targets, emulate ip6tables behaviour in the kernel (like nft_compat.c) and set the flag if the protocol is set.
--- net/ipv6/netfilter/ip6_tables.c | 5 +++++ 1 file changed, 5 insertions(+)
net/ipv6/netfilter/ip6_tables.c +5 -0
@@ -649,6 +649,11 @@ check_entry_size_and_hooks(struct ip6t_entry *e,/* Clear counters and comefrom */ e->counters = ((struct xt_counters ) {0 ,0 }); e->comefrom =0 ; + +/* set F_PROTO, else ip6_packet_match won't do the right thing. */ +if (e->ipv6.proto) + e->ipv6.flags |=IP6T_F_PROTO ; +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 327/752 ASoC: mt6351: Publish the OF module alias
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: hpp.iscas <[email protected]>
[ Upstream commit 9c3882ec10399c14c59b7e4599d33c4395367c37 ]
The MT6351 codec platform driver uses mt6351_of_match to bind devices with compatible mediatek,mt6351-sound. The codec can be a separate module, but the OF table is not exported to module alias metadata.
Publish the existing table without changing codec matching, register access or the machine-driver configuration.
--- sound/soc/codecs/mt6351.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/codecs/mt6351.c +1 -0
@@ -1481,6 +1481,7 @@ static const struct of_device_id mt6351_of_match[] = { {.compatible = "mediatek,mt6351-sound",}, {} }; +MODULE_DEVICE_TABLE (of, mt6351_of_match);static struct platform_driver mt6351_codec_driver = { .driver = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 328/752 virtio-console: call scheduler when we free unused buffs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xianting Tian <[email protected]>
[ Upstream commit 56b5e65efe0001fb5f95e412ee4167363debfc46 ]
For virtio-net we were getting CPU stall warnings, and fixed it by calling the scheduler: see f8bb51043945 ("virtio_net: suppress cpu stall when free_unused_bufs").
This driver is similar so theoretically the same logic applies.
Message-Id: <[email protected]>
Stable-dep-of: 894f98e73983 ("virtio_console: do not free control-out buffers on remove")
--- drivers/char/virtio_console.c | 1 + 1 file changed, 1 insertion(+)
drivers/char/virtio_console.c +1 -0
@@ -1940,6 +1940,7 @@ static void remove_vqs(struct ports_device *portdev)flush_bufs (vq, true);while ((buf =virtqueue_detach_unused_buf (vq)))free_buf (buf, true); +cond_resched (); } portdev->vdev->config->del_vqs (portdev->vdev);kfree (portdev->in_vqs);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 329/752 virtio_console: do not free control-out buffers on remove
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jia Jia <[email protected]>
[ Upstream commit 894f98e73983f37354214a89a3a7fd35bf9e3072 ]
__send_control_msg() publishes &portdev->cpkt as the control-out virtqueue cookie. remove_vqs() walks every virtqueue and passes leftover cookies to free_buf(), which treats them as struct port_buffer and reads sgpages.
If a control message is still on c_ovq when the device is unbound, free_buf() reads past the ports_device object.
KASAN reported slab-out-of-bounds in free_buf():
free_buf
remove_vqs
virtcons_remove
unbind_store
The object was the ports_device allocated in virtcons_probe().
Drain c_ovq without freeing. The packet lives in portdev and is released with it.
Message-ID: <[email protected]>
--- drivers/char/virtio_console.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
drivers/char/virtio_console.c +18 -3
@@ -1933,13 +1933,28 @@ static const struct file_operations portdev_fops = {static void remove_vqs (struct ports_device *portdev) {struct virtqueue *vq; +bool multiport =use_multiport (portdev);virtio_device_for_each_vq (portdev->vdev, vq) {struct port_buffer *buf; +unsigned int len; -flush_bufs (vq, true); -while ((buf =virtqueue_detach_unused_buf (vq))) -free_buf (buf, true); +/* +* c_ovq cookies are &portdev->cpkt, not port_buffer. +* Detach them but do not free_buf(). +*/ +if (multiport && vq == portdev->c_ovq) { +spin_lock (&portdev->c_ovq_lock); +while (virtqueue_get_buf (vq, &len)) + ; +while (virtqueue_detach_unused_buf (vq)) + ; +spin_unlock (&portdev->c_ovq_lock); + }else { +flush_bufs (vq, true); +while ((buf =virtqueue_detach_unused_buf (vq))) +free_buf (buf, true); + }cond_resched (); } portdev->vdev->config->del_vqs (portdev->vdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 330/752 vhost-vdpa: dont install the eventfd_ctx_fdget() error in config_ctx
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Zhang <[email protected]>
[ Upstream commit e74a9fa50749b9940b4fb13199652325e08d3c4a ]
vhost_vdpa_set_config_call() swaps the eventfd_ctx_fdget() return value into v->config_ctx before checking it, so on failure the field briefly holds an ERR_PTR:
ctx = fd == VHOST_FILE_UNBIND ? NULL : eventfd_ctx_fdget(fd);
swap(ctx, v->config_ctx);
if (!IS_ERR_OR_NULL(ctx))
eventfd_ctx_put(ctx);
if (IS_ERR(v->config_ctx)) {
long ret = PTR_ERR(v->config_ctx);
v->config_ctx = NULL;
return ret;
}Commit 0bde59c1723a ("vhost-vdpa: set v->config_ctx to NULL if eventfd_ctx_fdget() fails") added that clearing, and spelled out the invariant the rest of the file relies on: "we consider 'v->config_ctx' valid if it is not NULL". The window between the swap and the clearing still breaks it. vhost_vdpa_config_cb() only tests for NULL, so a config interrupt delivered inside the window hands the ERR_PTR to eventfd_signal().
Check the fd before installing it instead. That closes the window and matches how vhost_vring_ioctl() handles the same failure for the vq call fd.
It also stops a rejected fd from tearing down a config interrupt that was
working: until now the swap replaced the live context and put it, so after an EBADF the device silently stopped delivering config interrupts until userspace installed a new fd.
Message-ID: <[email protected]>
--- drivers/vhost/vdpa.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/vhost/vdpa.c +4 -8
@@ -326,18 +326,14 @@ static long vhost_vdpa_set_config_call(struct vhost_vdpa *v, u32 __user *argp)return -EFAULT ; ctx = fd ==VHOST_FILE_UNBIND ?NULL :eventfd_ctx_fdget (fd); +if (IS_ERR (ctx)) +return PTR_ERR (ctx); +swap (ctx, v->config_ctx); -if (!IS_ERR_OR_NULL (ctx)) +if (ctx)eventfd_ctx_put (ctx); -if (IS_ERR (v->config_ctx)) { -long ret =PTR_ERR (v->config_ctx); - - v->config_ctx =NULL ; -return ret; - } - v->vdpa->config->set_config_cb (v->vdpa, &cb);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 331/752 vdpa_sim_blk: use dev_dbg() to print errors
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefano Garzarella <[email protected]>
[ Upstream commit 42a84c09eff355d895723866b1a5ff48f093112a ]
Use dev_dbg() instead of dev_err()/dev_warn() to avoid flooding the host with prints, when the guest driver is misbehaving. In this way, prints can be dynamically enabled when the vDPA block simulator is used to validate a driver.
Message-Id: <[email protected]>
Stable-dep-of: 0a8693f00c40 ("vdpa_sim_blk: reject out-of-range sector starts")
--- drivers/vdpa/vdpa_sim/vdpa_sim_blk.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/vdpa/vdpa_sim/vdpa_sim_blk.c +10 -10
@@ -76,13 +76,13 @@ static bool vdpasim_blk_handle_req(struct vdpasim *vdpasim,return false;if (vq->out_iov.used <1 || vq->in_iov.used <1 ) { -dev_err (&vdpasim->vdpa.dev,"missing headers - out_iov: %u in_iov %u\n" , +dev_dbg (&vdpasim->vdpa.dev,"missing headers - out_iov: %u in_iov %u\n" , vq->out_iov.used, vq->in_iov.used);return false; }if (vq->in_iov.iov[vq->in_iov.used -1 ].iov_len <1 ) { -dev_err (&vdpasim->vdpa.dev,"request in header too short\n" ); +dev_dbg (&vdpasim->vdpa.dev,"request in header too short\n" );return false; }
@@ -96,7 +96,7 @@ static bool vdpasim_blk_handle_req(struct vdpasim *vdpasim, bytes =vringh_iov_pull_iotlb (&vq->vring, &vq->out_iov, &hdr,sizeof (hdr));if (bytes !=sizeof (hdr)) { -dev_err (&vdpasim->vdpa.dev,"request out header too short\n" ); +dev_dbg (&vdpasim->vdpa.dev,"request out header too short\n" );return false; }
@@ -110,7 +110,7 @@ static bool vdpasim_blk_handle_req(struct vdpasim *vdpasim,switch (type) {case VIRTIO_BLK_T_IN :if (!vdpasim_blk_check_range (sector, to_push)) { -dev_err (&vdpasim->vdpa.dev, +dev_dbg (&vdpasim->vdpa.dev,"reading over the capacity - offset: 0x%llx len: 0x%zx\n" , offset, to_push); status =VIRTIO_BLK_S_IOERR ;
@@ -121,7 +121,7 @@ static bool vdpasim_blk_handle_req(struct vdpasim *vdpasim, vdpasim->buffer + offset, to_push);if (bytes <0 ) { -dev_err (&vdpasim->vdpa.dev, +dev_dbg (&vdpasim->vdpa.dev,"vringh_iov_push_iotlb() error: %zd offset: 0x%llx len: 0x%zx\n" , bytes, offset, to_push); status =VIRTIO_BLK_S_IOERR ;
@@ -133,7 +133,7 @@ static bool vdpasim_blk_handle_req(struct vdpasim *vdpasim,case VIRTIO_BLK_T_OUT :if (!vdpasim_blk_check_range (sector, to_pull)) { -dev_err (&vdpasim->vdpa.dev, +dev_dbg (&vdpasim->vdpa.dev,"writing over the capacity - offset: 0x%llx len: 0x%zx\n" , offset, to_pull); status =VIRTIO_BLK_S_IOERR ;
@@ -144,7 +144,7 @@ static bool vdpasim_blk_handle_req(struct vdpasim *vdpasim, vdpasim->buffer + offset, to_pull);if (bytes <0 ) { -dev_err (&vdpasim->vdpa.dev, +dev_dbg (&vdpasim->vdpa.dev,"vringh_iov_pull_iotlb() error: %zd offset: 0x%llx len: 0x%zx\n" , bytes, offset, to_pull); status =VIRTIO_BLK_S_IOERR ;
@@ -157,7 +157,7 @@ static bool vdpasim_blk_handle_req(struct vdpasim *vdpasim, vdpasim_blk_id, VIRTIO_BLK_ID_BYTES);if (bytes <0 ) { -dev_err (&vdpasim->vdpa.dev, +dev_dbg (&vdpasim->vdpa.dev,"vringh_iov_push_iotlb() error: %zd\n" , bytes); status =VIRTIO_BLK_S_IOERR ;break ;
@@ -167,8 +167,8 @@ static bool vdpasim_blk_handle_req(struct vdpasim *vdpasim,break ;default : -dev_warn (&vdpasim->vdpa.dev, -"Unsupported request type %d\n" , type); +dev_dbg (&vdpasim->vdpa.dev, +"Unsupported request type %d\n" , type); status =VIRTIO_BLK_S_IOERR ;break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 332/752 vdpa_sim_blk: make vdpasim_blk_check_range usable by other requests
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefano Garzarella <[email protected]>
[ Upstream commit ac926e1b468e03818e31568f6e520390b945b038 ]
Next patches will add handling of other requests, where will be useful to reuse vdpasim_blk_check_range().
So let's make it more generic by adding the max_sectors parameter, since different requests allow different numbers of maximum sectors.
Let's also print the messages directly in vdpasim_blk_check_range() to avoid duplicate prints.
Message-Id: <[email protected]>
Stable-dep-of: 0a8693f00c40 ("vdpa_sim_blk: reject out-of-range sector starts")
--- drivers/vdpa/vdpa_sim/vdpa_sim_blk.c | 38 +++++++++++++++++----------- 1 file changed, 23 insertions(+), 15 deletions(-)
drivers/vdpa/vdpa_sim/vdpa_sim_blk.c +23 -15
@@ -38,18 +38,28 @@static char vdpasim_blk_id[VIRTIO_BLK_ID_BYTES ] ="vdpa_blk_sim" ; -static bool vdpasim_blk_check_range (u64 start_sector,size_t range_size) +static bool vdpasim_blk_check_range (struct vdpasim *vdpasim,u64 start_sector, +u64 num_sectors,u64 max_sectors) { -u64 range_sectors = range_size >>SECTOR_SHIFT ; - -if (range_size >VDPASIM_BLK_SIZE_MAX *VDPASIM_BLK_SEG_MAX ) -return false; +if (start_sector >VDPASIM_BLK_CAPACITY ) { +dev_dbg (&vdpasim->vdpa.dev, +"starting sector exceeds the capacity - start: 0x%llx capacity: 0x%x\n" , + start_sector,VDPASIM_BLK_CAPACITY ); + } -if (start_sector >VDPASIM_BLK_CAPACITY ) +if (num_sectors > max_sectors) { +dev_dbg (&vdpasim->vdpa.dev, +"number of sectors exceeds the max allowed in a request - num: 0x%llx max: 0x%llx\n" , + num_sectors, max_sectors);return false; + } -if (range_sectors >VDPASIM_BLK_CAPACITY - start_sector) +if (num_sectors >VDPASIM_BLK_CAPACITY - start_sector) { +dev_dbg (&vdpasim->vdpa.dev, +"request exceeds the capacity - start: 0x%llx num: 0x%llx capacity: 0x%x\n" , + start_sector, num_sectors,VDPASIM_BLK_CAPACITY );return false; + }return true; }
@@ -109,10 +119,9 @@ static bool vdpasim_blk_handle_req(struct vdpasim *vdpasim,switch (type) {case VIRTIO_BLK_T_IN : -if (!vdpasim_blk_check_range (sector, to_push)) { -dev_dbg (&vdpasim->vdpa.dev, -"reading over the capacity - offset: 0x%llx len: 0x%zx\n" , - offset, to_push); +if (!vdpasim_blk_check_range (vdpasim, sector, + to_push >>SECTOR_SHIFT , +VDPASIM_BLK_SIZE_MAX *VDPASIM_BLK_SEG_MAX )) { status =VIRTIO_BLK_S_IOERR ;break ; }
@@ -132,10 +141,9 @@ static bool vdpasim_blk_handle_req(struct vdpasim *vdpasim,break ;case VIRTIO_BLK_T_OUT : -if (!vdpasim_blk_check_range (sector, to_pull)) { -dev_dbg (&vdpasim->vdpa.dev, -"writing over the capacity - offset: 0x%llx len: 0x%zx\n" , - offset, to_pull); +if (!vdpasim_blk_check_range (vdpasim, sector, + to_pull >>SECTOR_SHIFT , +VDPASIM_BLK_SIZE_MAX *VDPASIM_BLK_SEG_MAX )) { status =VIRTIO_BLK_S_IOERR ;break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 333/752 vdpa_sim_blk: reject out-of-range sector starts
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linfeng Sun <[email protected]>
[ Upstream commit 0a8693f00c408d85f086ad85d29e7030bf1e2055 ]
vdpasim_blk_check_range() logs an invalid start sector but continues validating the request. The subsequent unsigned capacity subtraction can underflow and let an out-of-range buffer offset reach the data path.
The invalid offset is used by three request paths. VIRTIO_BLK_T_OUT copies guest data to blk->buffer + offset through vringh_iov_pull_iotlb(), causing an out-of-bounds write in _copy_from_iter() or memcpy(). VIRTIO_BLK_T_IN copies from blk->buffer + offset to the guest through vringh_iov_push_iotlb(), causing an out-of-bounds read in _copy_to_iter(). VIRTIO_BLK_T_WRITE_ZEROES passes blk->buffer + offset to memset(), causing an out-of-bounds write.
Reject starts at or beyond the capacity before the subtraction. Treat the capacity boundary as invalid because the IN and OUT paths round byte counts down to sectors for validation but later copy the original byte counts. A sub-sector request at the capacity boundary would otherwise still access past the end of the buffer.
I found this bug myself, though the patch was written with AI assistance.
Message-ID: <[email protected]>
--- drivers/vdpa/vdpa_sim/vdpa_sim_blk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/vdpa/vdpa_sim/vdpa_sim_blk.c +2 -1
@@ -41,10 +41,11 @@ static char vdpasim_blk_id[VIRTIO_BLK_ID_BYTES] = "vdpa_blk_sim";static bool vdpasim_blk_check_range (struct vdpasim *vdpasim,u64 start_sector,u64 num_sectors,u64 max_sectors) { -if (start_sector >VDPASIM_BLK_CAPACITY ) { +if (start_sector >=VDPASIM_BLK_CAPACITY ) {dev_dbg (&vdpasim->vdpa.dev,"starting sector exceeds the capacity - start: 0x%llx capacity: 0x%x\n" , start_sector,VDPASIM_BLK_CAPACITY ); +return false; }if (num_sectors > max_sectors) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 334/752 virtio-pci: return IRQ_HANDLED after non-zero ISR
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Stellman <[email protected]>
[ Upstream commit 93fa09455fb1a9624b73d42ac1f83771f4818e80 ]
vp_interrupt() reads the ISR before dispatching config-change and vring handling. Reading the ISR also clears it, so once the read returns non-zero the interrupt was from this device and has already been consumed.
Currently vp_interrupt() returns the result of vp_vring_interrupt(). For a config-change interrupt with no vring work, that can return IRQ_NONE even though the ISR was non-zero and the interrupt was handled.
Call vp_vring_interrupt() for any queue work, but once the ISR is non-zero return IRQ_HANDLED.
Tested with QEMU virtio-blk-pci forced to INTx using vectors=0 and pci=nomsi. On an idle device, 200 config-change interrupts were generated using QMP block_resize.
Before this change, irq_handler_exit reported ret=unhandled and /proc/irq/11/spurious increased from 0 to 200 unhandled interrupts. After this change, irq_handler_exit reported ret=handled and the unhandled count remained at 0.
The issue was found during an LLM-assisted Quality Playbook review.
Message-ID: <[email protected]>
--- drivers/virtio/virtio_pci_common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/virtio/virtio_pci_common.c +3 -1
@@ -96,7 +96,9 @@ static irqreturn_t vp_interrupt(int irq, void *opaque)if (isr &VIRTIO_PCI_ISR_CONFIG )vp_config_changed (irq, opaque); -return vp_vring_interrupt (irq, opaque); +vp_vring_interrupt (irq, opaque); + +return IRQ_HANDLED ; } static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 335/752 net: ipv6: Clamp to IP6_MAX_MTU in ip6_dst_mtu_maybe_forward
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alice Mikityanska <[email protected]>
[ Upstream commit 199271ebc71c1e0913b2fad988a7bff330a8828a ]
Commit 427faee167bc ("net: ipv6: introduce ip6_dst_mtu_maybe_forward") dropped the IP6_MAX_MTU clamp that used to be present in ip6_mtu(). A similar IPv4 commit ac6627a28dbf ("net: ipv4: Consolidate ipv4_mtu and ip_dst_mtu_maybe_forward") preserves the IP_MAX_MTU clamp.
Restore the upper bound in the IPv6 flow to avoid potential 16-bit overflows in forwarding paths.
--- include/net/ip6_route.h | 2 ++ 1 file changed, 2 insertions(+)
include/net/ip6_route.h +2 -0
@@ -336,6 +336,8 @@ static inline unsigned int ip6_dst_mtu_maybe_forward(const struct dst_entry *dstrcu_read_unlock (); out: + mtu = min_t(unsigned int, mtu, IP6_MAX_MTU); +return mtu -lwtunnel_headroom (dst->lwtstate, mtu); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 336/752 net: ethernet: cortina: Fix budget accounting
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit a0de06d0da78a3db53de65dfd7452cc6d111f703 ]
The gmac_rx() function returns the remaining NAPI budget, but its caller treats the return value as the number of packets received. An idle poll therefore reports a full budget and remains scheduled.
Return the number of received packets instead. Preserve the existing free queue refill accounting by adding that count directly; continuing to subtract it from the budget would invert the refill behavior.
--- drivers/net/ethernet/cortina/gemini.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/cortina/gemini.c +5 -3
@@ -1419,6 +1419,7 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget)unsigned int frame_len, frag_len;struct gmac_rxdesc *rx =NULL ;struct gmac_queue_page *gpage; +unsigned int received =0 ;union gmac_rxdesc_0 word0;union gmac_rxdesc_1 word1;union gmac_rxdesc_3 word3;
@@ -1514,7 +1515,8 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget)napi_gro_frags (&port->napi); skb =NULL ; frag_nr =0 ; - --budget; + budget--; + received++; }continue ;
@@ -1534,7 +1536,7 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget) port->rx_skb = skb; port->rx_frag_nr = frag_nr;writew (r, ptr_reg); -return budget; +return received; }static int gmac_napi_poll (struct napi_struct *napi,int budget)
@@ -1555,7 +1557,7 @@ static int gmac_napi_poll(struct napi_struct *napi, int budget) ++port->rx_napi_exits; } - port->freeq_refill += (budget - received); + port->freeq_refill += received;if (port->freeq_refill > freeq_threshold) { port->freeq_refill -= freeq_threshold;geth_fill_freeq (geth, true);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 337/752 net: ethernet: cortina: Finish RX updates before NAPI completion
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit baa26841cb9a2cdc7e0e99d6854a4e3359bf7393 ]
napi_complete_done() releases ownership of the NAPI instance, but the Gemini poll keeps the RX statistics writer section open and updates the free queue after calling it. A new poll can therefore start while the old writer is still active.
Finish the statistics and free queue updates before releasing ownership. Only re-enable RX interrupts when napi_complete_done() reports successful completion.
--- drivers/net/ethernet/cortina/gemini.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/cortina/gemini.c +6 -6
@@ -1550,12 +1550,10 @@ static int gmac_napi_poll(struct napi_struct *napi, int budget)u64_stats_update_begin (&port->rx_stats_syncp); received =gmac_rx (napi->dev, budget); -if (received < budget) { -napi_gro_flush (napi, false); -napi_complete_done (napi, received); -gmac_enable_rx_irq (napi->dev,1 ); +if (received < budget) ++port->rx_napi_exits; - } + +u64_stats_update_end (&port->rx_stats_syncp); port->freeq_refill += received;if (port->freeq_refill > freeq_threshold) {
@@ -1563,7 +1561,9 @@ static int gmac_napi_poll(struct napi_struct *napi, int budget)geth_fill_freeq (geth, true); } -u64_stats_update_end (&port->rx_stats_syncp); +if (received < budget &&napi_complete_done (napi, received)) +gmac_enable_rx_irq (napi->dev,1 ); +return received; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 338/752 net: ethernet: cortina: Count dropped frames as NAPI work
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit b856c552f556bc0341c1dbe0bf88e630fd1dc4b7 ]
The RX loop only consumes budget when it successfully delivers a frame. Error paths keep consuming descriptors without reducing the budget, so a stream of bad frames can process the entire receive ring in one poll.
Move the budget accounting to a common end-of-frame path. This counts each completed frame as NAPI work whether it was delivered or dropped, matching the behavior of the vendor driver.
--- drivers/net/ethernet/cortina/gemini.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/net/ethernet/cortina/gemini.c +10 -5
@@ -1470,7 +1470,7 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget) skb =NULL ; frag_nr =0 ; } -continue ; + goto next_desc; } page = gpage->page;
@@ -1492,7 +1492,7 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget) }else if (!skb) {put_page (page); -continue ; + goto next_desc; }if (word3.bits32 &EOF_BIT )
@@ -1515,10 +1515,8 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget)napi_gro_frags (&port->napi); skb =NULL ; frag_nr =0 ; - budget--; - received++; } -continue ; + goto next_desc; err_drop:if (skb) {
@@ -1531,6 +1529,13 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget)put_page (page); port->stats.rx_dropped++; + +next_desc: +/* Final or single-descriptor fragment, advance things */ +if (word3.bits32 &EOF_BIT ) { + budget--; + received++; + } } port->rx_skb = skb;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 339/752 net: ethernet: cortina: No mapping is a dropped rx
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 2cb156213093a62b80cf40b1ec71738e93491971 ]
Increase stats.rx_dropped++ even if this is the first fragment (skb == NULL) so we are doing proper accounting.
Stable-dep-of: 6520198c430c ("net: ethernet: cortina: Count RX drops once per frame")
--- drivers/net/ethernet/cortina/gemini.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/cortina/gemini.c +1 -1
@@ -1464,9 +1464,9 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget) gpage =gmac_get_queue_page (geth, port, mapping +PAGE_SIZE );if (!gpage) {dev_err (geth->dev,"could not find mapping\n" ); + port->stats.rx_dropped++;if (skb) {napi_free_frags (&port->napi); - port->stats.rx_dropped++; skb =NULL ; frag_nr =0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 340/752 net: ethernet: cortina: Count RX drops once per frame
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 6520198c430c81bcc367f0dd5e32f2fb740b9d51 ]
The absence of a partial skb means either that the driver is not assembling a frame or that the current frame was already dropped. Consequently, repeated descriptor errors can increment rx_dropped more than once, while an orphaned descriptor chain can reach EOF without being counted at all.
Track the dropping state across NAPI polls. Clear it at frame boundaries and route mapping failures and orphaned continuations through the common drop path so each discarded frame is counted exactly once.
--- drivers/net/ethernet/cortina/gemini.c | 41 +++++++++++++++------------ 1 file changed, 23 insertions(+), 18 deletions(-)
drivers/net/ethernet/cortina/gemini.c +23 -18
@@ -122,6 +122,7 @@ struct gemini_ethernet_port {unsigned int rx_coalesce_nsecs;struct sk_buff *rx_skb;unsigned int rx_frag_nr; +bool rx_dropping;unsigned int freeq_refill;struct gmac_txq txq[TX_QUEUE_NUM ];
@@ -1420,6 +1421,7 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget)struct gmac_rxdesc *rx =NULL ;struct gmac_queue_page *gpage;unsigned int received =0 ; +bool dropping = port->rx_dropping;union gmac_rxdesc_0 word0;union gmac_rxdesc_1 word1;union gmac_rxdesc_3 word3;
@@ -1441,6 +1443,7 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget) w = rw.bits.wptr;while (budget && w != r) { + page =NULL ; rx = port->rxq_ring + r; word0 = rx->word0; word1 = rx->word1;
@@ -1454,6 +1457,16 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget) frame_len = word1.bits.byte_count; page_offs = mapping & ~PAGE_MASK ; +if (word3.bits32 &SOF_BIT ) { +if (skb) { +napi_free_frags (&port->napi); + port->stats.rx_dropped++; + skb =NULL ; + frag_nr =0 ; + } + dropping = false; + } +if (!mapping) {netdev_err (netdev,"rxq[%u]: HW BUG: zero DMA desc\n" , r);
@@ -1464,24 +1477,11 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget) gpage =gmac_get_queue_page (geth, port, mapping +PAGE_SIZE );if (!gpage) {dev_err (geth->dev,"could not find mapping\n" ); - port->stats.rx_dropped++; -if (skb) { -napi_free_frags (&port->napi); - skb =NULL ; - frag_nr =0 ; - } - goto next_desc; + goto err_drop; } page = gpage->page;if (word3.bits32 &SOF_BIT ) { -if (skb) { -napi_free_frags (&port->napi); - port->stats.rx_dropped++; - skb =NULL ; - frag_nr =0 ; - } - skb =gmac_skb_if_good_frame (port, word0, frame_len);if (!skb) goto err_drop;
@@ -1491,8 +1491,7 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget) frag_nr =0 ; }else if (!skb) { -put_page (page); - goto next_desc; + goto err_drop; }if (word3.bits32 &EOF_BIT )
@@ -1525,21 +1524,26 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget) frag_nr =0 ; } -if (mapping) +if (page)put_page (page); - port->stats.rx_dropped++; +if (!dropping) { + port->stats.rx_dropped++; + dropping = true; + } next_desc:/* Final or single-descriptor fragment, advance things */ if (word3.bits32 &EOF_BIT ) { budget--; received++; + dropping = false; } } port->rx_skb = skb; port->rx_frag_nr = frag_nr; + port->rx_dropping = dropping;writew (r, ptr_reg);return received; }
@@ -1870,6 +1874,7 @@ static int gmac_stop(struct net_device *netdev)napi_disable (&port->napi); port->rx_skb =NULL ; port->rx_frag_nr =0 ; + port->rx_dropping = false;gmac_enable_irq (netdev,0 );gmac_cleanup_rxq (netdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 341/752 net: ethernet: cortina: Count RX descriptors for freeq refill
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit e89e88ad41d9f31c829c2af39c48313e8e48d5b0 ]
The software free queue provides one buffer fragment for every descriptor moved to an RX queue. The refill heuristic instead advances by NAPI work, which counts frames. A fragmented or discarded frame can consume several queue entries while adding only one to the refill count.
Count the RX descriptors as they are consumed and report that separately from NAPI work. Use the descriptor count to drive free queue refills.
--- drivers/net/ethernet/cortina/gemini.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/net/ethernet/cortina/gemini.c +8 -3
@@ -1409,7 +1409,8 @@ static struct sk_buff *gmac_skb_if_good_frame(struct gemini_ethernet_port *port,return skb; } -static unsigned int gmac_rx (struct net_device *netdev,unsigned int budget) +static unsigned int gmac_rx (struct net_device *netdev,unsigned int budget, +unsigned int *freeq_consumed) {struct gemini_ethernet_port *port =netdev_priv (netdev);unsigned short m = (1 << port->rxq_order) -1 ;
@@ -1417,6 +1418,7 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget)void __iomem *ptr_reg = port->rxq_rwptr;unsigned int frag_nr = port->rx_frag_nr;struct sk_buff *skb = port->rx_skb; +unsigned int consumed =0 ;unsigned int frame_len, frag_len;struct gmac_rxdesc *rx =NULL ;struct gmac_queue_page *gpage;
@@ -1452,6 +1454,7 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget) r++; r &= m; + consumed++; frag_len = word0.bits.buffer_size; frame_len = word1.bits.byte_count;
@@ -1544,6 +1547,7 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget) port->rx_skb = skb; port->rx_frag_nr = frag_nr; port->rx_dropping = dropping; + *freeq_consumed = consumed;writew (r, ptr_reg);return received; }
@@ -1553,18 +1557,19 @@ static int gmac_napi_poll(struct napi_struct *napi, int budget)struct gemini_ethernet_port *port =netdev_priv (napi->dev);struct gemini_ethernet *geth = port->geth;unsigned int freeq_threshold; +unsigned int freeq_consumed;unsigned int received; freeq_threshold =1 << (geth->freeq_order -1 );u64_stats_update_begin (&port->rx_stats_syncp); - received =gmac_rx (napi->dev, budget); + received =gmac_rx (napi->dev, budget, &freeq_consumed);if (received < budget) ++port->rx_napi_exits;u64_stats_update_end (&port->rx_stats_syncp); - port->freeq_refill += received; + port->freeq_refill += freeq_consumed;if (port->freeq_refill > freeq_threshold) { port->freeq_refill -= freeq_threshold;geth_fill_freeq (geth, true);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 342/752 watchdog: fix hrtimer start when pretimeout is zero
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Arcari <[email protected]>
[ Upstream commit 0fa37512eb747e4ffdcf367274f9e72845f1bca4 ]
Per the watchdog API, a pretimeout value of 0 disables the feature. However, watchdog_hrtimer_pretimeout_start() fails to verify if the pretimeout is non-zero before arming the timer.
This omission inadvertently starts the software pretimeout timer, which could result in the pretimeout handler executing incorrectly when the watchdog timeout is reached.
Fix this by adding a check for wdd->pretimeout before calling hrtimer_start(), ensuring the disabled state is respected.
--- drivers/watchdog/watchdog_hrtimer_pretimeout.c | 1 + 1 file changed, 1 insertion(+)
drivers/watchdog/watchdog_hrtimer_pretimeout.c +1 -0
@@ -30,6 +30,7 @@ void watchdog_hrtimer_pretimeout_init(struct watchdog_device *wdd)void watchdog_hrtimer_pretimeout_start (struct watchdog_device *wdd) {if (!(wdd->info->options &WDIOF_PRETIMEOUT ) && + wdd->pretimeout && !watchdog_pretimeout_invalid (wdd, wdd->pretimeout)) hrtimer_start(&wdd->wd_data->pretimeout_timer, ktime_set(wdd->timeout - wdd->pretimeout, 0),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 343/752 watchdog: msc313e: Avoid division by zero
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tzung-Bi Shih <[email protected]>
[ Upstream commit 3c73a37f5e40972ce26d8eeb98e8b938d719b069 ]
clk_get_rate() could return 0. Avoid a division by zero panic.
--- drivers/watchdog/msc313e_wdt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/watchdog/msc313e_wdt.c +5 -1
@@ -98,6 +98,7 @@ static int msc313e_wdt_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct msc313e_wdt_priv *priv; +unsigned long rate; priv =devm_kzalloc (&pdev->dev,sizeof (*priv),GFP_KERNEL );if (!priv)
@@ -117,7 +118,10 @@ static int msc313e_wdt_probe(struct platform_device *pdev) priv->wdev.ops = &msc313e_wdt_ops, priv->wdev.parent = dev; priv->wdev.min_timeout =MSC313E_WDT_MIN_TIMEOUT ; - priv->wdev.max_timeout =U32_MAX /clk_get_rate (priv->clk); + rate =clk_get_rate (priv->clk); +if (!rate) +return -EINVAL ; + priv->wdev.max_timeout =U32_MAX / rate; priv->wdev.timeout =MSC313E_WDT_DEFAULT_TIMEOUT ;watchdog_set_drvdata (&priv->wdev, priv);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 344/752 watchdog: msc313e: Fix clock leak and spurious timer in settimeout()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tzung-Bi Shih <[email protected]>
[ Upstream commit 3db30f315935c2fb0d95f46b7a593b5b4d3ec3d0 ]
msc313e_wdt_settimeout() unconditionally calls msc313e_wdt_start() which introduces two severe bugs:
1. If the watchdog is already active, calling start() again will increase the reference count of the clock again. However stop() is only called once, the reference count is unbalance.
2. If the watchdog is stopped, calling settimeout() will start the hardware timer accidentally.
Factor out the register-writing logic into a helper function. Only call it in settimeout() if the watchdog is running. Otherwise, simply update wdev->timeout.
--- drivers/watchdog/msc313e_wdt.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
drivers/watchdog/msc313e_wdt.c +16 -6
@@ -32,20 +32,26 @@ struct msc313e_wdt_priv {struct clk *clk; }; +static void msc313e_wdt_set_hw_timeout (struct msc313e_wdt_priv *priv, +unsigned int timeout) +{ +u32 t = timeout *clk_get_rate (priv->clk); + +writew (t &0xffff , priv->base +REG_WDT_MAX_PRD_L ); +writew ((t >>16 ) &0xffff , priv->base +REG_WDT_MAX_PRD_H ); +writew (1 , priv->base +REG_WDT_CLR ); +} +static int msc313e_wdt_start (struct watchdog_device *wdev) {struct msc313e_wdt_priv *priv =watchdog_get_drvdata (wdev); -u32 timeout;int err; err =clk_prepare_enable (priv->clk);if (err)return err; - timeout = wdev->timeout *clk_get_rate (priv->clk); -writew (timeout &0xffff , priv->base +REG_WDT_MAX_PRD_L ); -writew ((timeout >>16 ) &0xffff , priv->base +REG_WDT_MAX_PRD_H ); -writew (1 , priv->base +REG_WDT_CLR ); +msc313e_wdt_set_hw_timeout (priv, wdev->timeout);return 0 ; }
@@ -70,9 +76,13 @@ static int msc313e_wdt_stop(struct watchdog_device *wdev)static int msc313e_wdt_settimeout (struct watchdog_device *wdev,unsigned int new_time) { +struct msc313e_wdt_priv *priv =watchdog_get_drvdata (wdev); + wdev->timeout = new_time; -return msc313e_wdt_start (wdev); +if (watchdog_hw_running (wdev) ||watchdog_active (wdev)) +msc313e_wdt_set_hw_timeout (priv, wdev->timeout); +return 0 ; }static const struct watchdog_info msc313e_wdt_ident = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 345/752 hwmon: (gpio-fan) take fan_data->lock in gpio_fan_shutdown()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cong Nguyen <[email protected]>
[ Upstream commit bb2424c3502cc72292eedade46960c331d5f28fb ]
set_fan_speed() writes the control GPIOs one bit at a time. Every other caller locks around it; gpio_fan_shutdown() doesn't. If it races a locked caller, the GPIO writes can interleave and leave the fan at a speed neither caller asked for.
--- drivers/hwmon/gpio-fan.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/hwmon/gpio-fan.c +4 -1
@@ -562,8 +562,11 @@ static void gpio_fan_shutdown(struct platform_device *pdev) {struct gpio_fan_data *fan_data =platform_get_drvdata (pdev); -if (fan_data->gpios) +if (fan_data->gpios) { +mutex_lock (&fan_data->lock);set_fan_speed (fan_data,0 ); +mutex_unlock (&fan_data->lock); + } }#ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 346/752 hwmon: (aspeed-pwm-tacho) Propagate reset deassert errors
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 09a9e1746a87845d7d8e2b4e23bb613306effdff ]
aspeed_pwm_tacho_probe() installs its reset cleanup action and configures the
controller after an unchecked reset deassertion.
Stop probing when the reset controller rejects the transition, before the hwmon device becomes visible.
--- drivers/hwmon/aspeed-pwm-tacho.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/hwmon/aspeed-pwm-tacho.c +3 -1
@@ -922,7 +922,9 @@ static int aspeed_pwm_tacho_probe(struct platform_device *pdev) "missing or invalid reset controller device tree entry");return PTR_ERR (priv->rst); } -reset_control_deassert (priv->rst); + ret =reset_control_deassert (priv->rst); +if (ret) +return ret; ret =devm_add_action_or_reset (dev, aspeed_pwm_tacho_remove, priv);if (ret)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 347/752 ppp_synctty: ensure a writeable skb header
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qingfang Deng <[email protected]>
[ Upstream commit 8aaeb56aff2a557a88f83ae866da2c91ad247e59 ]
ppp_sync_txmunge() checks headroom before prepending the address and control bytes, but does not ensure that the skb header is writable. A received skb can reach this function through PPP channel bridging without passing through ppp_start_xmit(), which calls skb_cow_head().
For example, a PPPoE frame may share its buffer with a clone queued to an AF_PACKET socket. If it is bridged to a synchronous tty channel, the address/control bytes can overwrite data still visible to that socket.
Use skb_cow_head() to ensure both sufficient headroom and a writable header.
--- drivers/net/ppp/ppp_synctty.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
drivers/net/ppp/ppp_synctty.c +3 -11
@@ -536,17 +536,9 @@ ppp_sync_txmunge(struct syncppp *ap, struct sk_buff *skb)/* prepend address/control fields if necessary */ if ((ap->flags &SC_COMP_AC ) ==0 || islcp) { -if (skb_headroom (skb) <2 ) { -struct sk_buff *npkt =dev_alloc_skb (skb->len +2 ); -if (npkt ==NULL ) { -kfree_skb (skb); -return NULL ; - } -skb_reserve (npkt,2 ); -skb_copy_from_linear_data (skb, -skb_put (npkt, skb->len), skb->len); -consume_skb (skb); - skb = npkt; +if (skb_cow_head (skb,2 )) { +kfree_skb (skb); +return NULL ; }skb_push (skb,2 ); skb->data[0 ] =PPP_ALLSTATIONS ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 348/752 net: stmmac: optimize locking around PTP clock reads
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yannick Vignon <[email protected]>
[ Upstream commit 642436a1ad34a28c45bbc2bdc131640a73782356 ]
Reading the PTP clock is a simple operation requiring only 3 register reads. Under a PREEMPT_RT kernel, protecting those reads by a spin_lock is
counter-productive: if the 2nd task preempting the 1st has a higher prio but needs to read time as well, it will require 2 context switches, which will pretty much always be more costly than just disabling preemption for the duration of the reads. Moreover, with the code logic recently added to get_systime(), disabling preemption is not even required anymore:
reads and writes just need to be protected from each other, to prevent a clock read while the clock is being updated.
Improve the above situation by replacing the PTP spinlock by a rwlock, and using read_lock for PTP clock reads so simultaneous reads do not block each other.
Stable-dep-of: 0338c68e22ab ("net: stmmac: initialize ptp_lock at probe time")
--- .../net/ethernet/stmicro/stmmac/dwmac-intel.c | 4 ++-- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 +- .../ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 4 ++-- .../net/ethernet/stmicro/stmmac/stmmac_ptp.c | 22 +++++++++---------- .../stmicro/stmmac/stmmac_selftests.c | 8 +++---- 5 files changed, 20 insertions(+), 20 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +2 -2
@@ -388,10 +388,10 @@ static int intel_crosststamp(ktime_t *device,/* Repeat until the timestamps are from the FIFO last segment */ for (i =0 ; i < num_snapshot; i++) { -spin_lock_irqsave (&priv->ptp_lock, flags); +read_lock_irqsave (&priv->ptp_lock, flags);stmmac_get_ptptime (priv, ptpaddr, &ptp_time); *device =ns_to_ktime (ptp_time); -spin_unlock_irqrestore (&priv->ptp_lock, flags); +read_unlock_irqrestore (&priv->ptp_lock, flags);get_arttime (priv->mii, intel_priv->mdio_adhoc_addr, &art_time); *system =convert_art_to_tsc (art_time); }
drivers/net/ethernet/stmicro/stmmac/stmmac.h +1 -1
@@ -266,7 +266,7 @@ struct stmmac_priv {u32 adv_ts;int use_riwt;int irq_wake; -spinlock_t ptp_lock; +rwlock_t ptp_lock;/* Protects auxiliary snapshot registers from concurrent access. */ struct mutex aux_ts_lock;wait_queue_head_t tstamp_busy_wait;
drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c +2 -2
@@ -206,9 +206,9 @@ static void timestamp_interrupt(struct stmmac_priv *priv) channel =ilog2 (FIELD_GET (PTP_ACR_MASK , acr_value));for (i =0 ; i < num_snapshot; i++) { -spin_lock_irqsave (&priv->ptp_lock, flags); +read_lock_irqsave (&priv->ptp_lock, flags);get_ptptime (priv->ptpaddr, &ptp_time); -spin_unlock_irqrestore (&priv->ptp_lock, flags); +read_unlock_irqrestore (&priv->ptp_lock, flags); event.type =PTP_CLOCK_EXTTS ; event.index = channel; event.timestamp = ptp_time;
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +11 -11
@@ -39,9 +39,9 @@ static int stmmac_adjust_freq(struct ptp_clock_info *ptp, s32 ppb) diff =div_u64 (adj,1000000000ULL ); addend = neg_adj ? (addend - diff) : (addend + diff); -spin_lock_irqsave (&priv->ptp_lock, flags); +write_lock_irqsave (&priv->ptp_lock, flags);stmmac_config_addend (priv, priv->ptpaddr, addend); -spin_unlock_irqrestore (&priv->ptp_lock, flags); +write_unlock_irqrestore (&priv->ptp_lock, flags);return 0 ; }
@@ -86,9 +86,9 @@ static int stmmac_adjust_time(struct ptp_clock_info *ptp, s64 delta)mutex_unlock (&priv->plat->est->lock); } -spin_lock_irqsave (&priv->ptp_lock, flags); +write_lock_irqsave (&priv->ptp_lock, flags);stmmac_adjust_systime (priv, priv->ptpaddr, sec, nsec, neg_adj, xmac); -spin_unlock_irqrestore (&priv->ptp_lock, flags); +write_unlock_irqrestore (&priv->ptp_lock, flags);/* Caculate new basetime and re-configured EST after PTP time adjust. */ if (est_rst) {
@@ -137,9 +137,9 @@ static int stmmac_get_time(struct ptp_clock_info *ptp, struct timespec64 *ts)unsigned long flags;u64 ns =0 ; -spin_lock_irqsave (&priv->ptp_lock, flags); +read_lock_irqsave (&priv->ptp_lock, flags);stmmac_get_systime (priv, priv->ptpaddr, &ns); -spin_unlock_irqrestore (&priv->ptp_lock, flags); +read_unlock_irqrestore (&priv->ptp_lock, flags); *ts =ns_to_timespec64 (ns);
@@ -162,9 +162,9 @@ static int stmmac_set_time(struct ptp_clock_info *ptp, container_of(ptp, struct stmmac_priv, ptp_clock_ops);unsigned long flags; -spin_lock_irqsave (&priv->ptp_lock, flags); +write_lock_irqsave (&priv->ptp_lock, flags);stmmac_init_systime (priv, priv->ptpaddr, ts->tv_sec, ts->tv_nsec); -spin_unlock_irqrestore (&priv->ptp_lock, flags); +write_unlock_irqrestore (&priv->ptp_lock, flags);return 0 ; }
@@ -193,12 +193,12 @@ static int stmmac_enable(struct ptp_clock_info *ptp, cfg->period.tv_sec = rq->perout.period.sec; cfg->period.tv_nsec = rq->perout.period.nsec; -spin_lock_irqsave (&priv->ptp_lock, flags); +write_lock_irqsave (&priv->ptp_lock, flags); ret =stmmac_flex_pps_config (priv, priv->ioaddr, rq->perout.index, cfg, on, priv->sub_second_inc, priv->systime_flags); -spin_unlock_irqrestore (&priv->ptp_lock, flags); +write_unlock_irqrestore (&priv->ptp_lock, flags);break ;case PTP_CLK_REQ_EXTTS : priv->plat->ext_snapshot_en = on;
@@ -302,7 +302,7 @@ void stmmac_ptp_register(struct stmmac_priv *priv) stmmac_ptp_clock_ops.n_per_out = priv->dma_cap.pps_out_num; stmmac_ptp_clock_ops.n_ext_ts = priv->dma_cap.aux_snapshot_n; -spin_lock_init (&priv->ptp_lock); +rwlock_init (&priv->ptp_lock);mutex_init (&priv->aux_ts_lock); priv->ptp_clock_ops = stmmac_ptp_clock_ops;
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +4 -4
@@ -1803,9 +1803,9 @@ static int stmmac_test_tbs(struct stmmac_priv *priv)if (ret)return ret; -spin_lock_irqsave (&priv->ptp_lock, flags); +read_lock_irqsave (&priv->ptp_lock, flags);stmmac_get_systime (priv, priv->ptpaddr, &curr_time); -spin_unlock_irqrestore (&priv->ptp_lock, flags); +read_unlock_irqrestore (&priv->ptp_lock, flags);if (!curr_time) { ret = -EOPNOTSUPP ;
@@ -1825,9 +1825,9 @@ static int stmmac_test_tbs(struct stmmac_priv *priv) goto fail_disable;/* Check if expected time has elapsed */ -spin_lock_irqsave (&priv->ptp_lock, flags); +read_lock_irqsave (&priv->ptp_lock, flags);stmmac_get_systime (priv, priv->ptpaddr, &curr_time); -spin_unlock_irqrestore (&priv->ptp_lock, flags); +read_unlock_irqrestore (&priv->ptp_lock, flags);if ((curr_time - start_time) <STMMAC_TBS_LT_OFFSET ) ret = -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 349/752 net: stmmac: initialize ptp_lock at probe time
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit 0338c68e22abd2ee509ec2e32508a50896618c32 ]
priv->ptp_lock is only initialized in stmmac_ptp_register(), which runs during __stmmac_open(). However, the lock is also used while the interface is down and has never been opened: tc_taprio_configure() invokes the PTP gettime64() callback to compute the EST base time when offloading a TAPRIO schedule, and stmmac_get_time() takes priv->ptp_lock. Using an uninitialized rwlock is undefined behaviour. Move the rwlock_init() to __stmmac_dvr_probe(), together with the other private locks, so that ptp_lock is always valid regardless of the interface state.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 1 + drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -0
@@ -7221,6 +7221,7 @@ int stmmac_dvr_probe(struct device *device,stmmac_napi_add (ndev);mutex_init (&priv->lock); +rwlock_init (&priv->ptp_lock);/* If a specific clk_csr value is passed from the platform * this means that the CSR Clock Range selection cannot be
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +0 -1
@@ -302,7 +302,6 @@ void stmmac_ptp_register(struct stmmac_priv *priv) stmmac_ptp_clock_ops.n_per_out = priv->dma_cap.pps_out_num; stmmac_ptp_clock_ops.n_ext_ts = priv->dma_cap.aux_snapshot_n; -rwlock_init (&priv->ptp_lock);mutex_init (&priv->aux_ts_lock); priv->ptp_clock_ops = stmmac_ptp_clock_ops;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 350/752 selftests/powerpc/tm: Fix tcheck() reading uninitialised CR value
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thibault Ferrante <[email protected]>
[ Upstream commit ed28b16eab705071d28edaace47189c2eb3aa108 ]
tcheck() is used to check the current transaction state (active, suspended, doomed) via the "tcheck" instruction, which writes its result into CR field 0. The inline asm declared a GPR output operand for this result but never actually moved the CR into it.
Every caller (tcheck_doomed(), tcheck_active(), tcheck_suspended(), tcheck_transactional()) has effectively been testing bits of an unrelated, arbitrary register value since this helper was introduced.
The "& 4" mask discards the TDOOMED and TS_lsb (suspended) bits before they ever reach the callers, so tcheck_doomed() and tcheck_suspended() can never return true, and tcheck_transactional() degrades to being equivalent to tcheck_active().
Fix tcheck() to actually move CR into the output register with mfcr, and widen the mask from "& 4" to "& 0xf" so the full CR0 nibble (TDOOMED | TS_msb | TS_lsb | reserved) is preserved for the callers.
This bug has been present since tcheck() was introduced.
--- tools/testing/selftests/powerpc/tm/tm.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
tools/testing/selftests/powerpc/tm/tm.h +6 -2
@@ -105,8 +105,12 @@ static inline bool failure_is_nesting(void)static inline int tcheck (void ) {long cr; - asmvolatile ("tcheck 0" :"=r" (cr) : :"cr0" ); -return (cr >>28 ) &4 ; + asmvolatile ("tcheck 0;" +"mfcr %0;" + :"=r" (cr) + : + :"cr0" ); +return (cr >>28 ) &0xf ; }static inline bool tcheck_doomed (void )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 351/752 net/sched: cls_route: free emptied bucket on filter move
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit 1853f30cf5c84971f99788a76207c6f745380896 ]
route4_change can move an existing filter to a different top-level
bucket: route4_set_parms recomputes the handle from TCA_ROUTE4_TO/ FROM/IIF, and the handle-mismatch check is gated on the 'new' flag, so for an existing filter the new handle may differ from the old one and land in a different bucket. When this happens, the filter is unlinked from the old bucket, but the bucket itself is never freed once it goes empty. The stale empty bucket remains in head->table[], causing route4_delete to report *last=false even after the last live filter is gone. That pins the empty tcf_proto and causes a leak.
Fix this by refcounting the filters linked to a bucket and freeing the bucket when the count drops to zero. The existing scan in route4_delete goes away with it.
The count is updated at all sites that link or unlink a filter during add, change and delete, and the bucket is dropped from head->table[] as soon as it reaches zero.
Conditions to recreate the bug:
CONFIG_NET_CLS_ROUTE4=y, CONFIG_NET_SCH_INGRESS=y, CONFIG_NET_CLS_ACT=y.
tc qdisc replace dev lo clsact
tc filter add dev lo ingress protocol ip pref 100 route from 1 to 1 tc filter change dev lo ingress protocol ip pref 100 handle 0x10001 \
route from 1 to 2
tc filter del dev lo ingress protocol ip pref 100 handle 0x10002 \
route from 1 to 2
tc filter show dev lo ingress | grep -c 'pref 100 route chain 0 '
--- net/sched/cls_route.c | 45 +++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 23 deletions(-)
net/sched/cls_route.c +22 -23
@@ -11,6 +11,7 @@#include <linux/kernel.h> #include <linux/string.h> #include <linux/errno.h> +#include <linux/refcount.h> #include <linux/skbuff.h> #include <net/dst.h> #include <net/route.h>
@@ -40,6 +41,7 @@ struct route4_head {struct route4_bucket {/* 16 FROM buckets + 16 IIF buckets + 1 wildcard bucket */ struct route4_filter __rcu *ht[16 +16 +1 ]; +refcount_t filters_ref;struct rcu_head rcu; };
@@ -334,7 +336,7 @@ static int route4_delete(struct tcf_proto *tp, void *arg, bool *last,struct route4_filter *nf;struct route4_bucket *b;unsigned int h =0 ; -int i, h1; +int h1;if (!head || !f)return -EINVAL ;
@@ -360,23 +362,14 @@ static int route4_delete(struct tcf_proto *tp, void *arg, bool *last,tcf_exts_get_net (&f->exts);tcf_queue_work (&f->rwork, route4_delete_filter_work); -/* Strip RTNL protected tree */ -for (i =0 ; i <=32 ; i++) { -struct route4_filter *rt; - - rt =rtnl_dereference (b->ht[i]); -if (rt) - goto out; +if (refcount_dec_and_test (&b->filters_ref)) { +RCU_INIT_POINTER (head->table[to_hash (h)],NULL ); +kfree_rcu (b, rcu); } - -/* OK, session has no flows */ -RCU_INIT_POINTER (head->table[to_hash (h)],NULL ); -kfree_rcu (b, rcu);break ; } } -out: *last = true;for (h1 =0 ; h1 <=256 ; h1++) {if (rcu_access_pointer (head->table[h1])) {
@@ -453,6 +446,7 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp,if (b ==NULL )return -ENOBUFS ; +refcount_set (&b->filters_ref,1 );rcu_assign_pointer (head->table[h1], b); }else {unsigned int h2 =from_hash (nhandle >>16 );
@@ -462,6 +456,8 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp, fp = rtnl_dereference(fp->next))if (fp->handle == f->handle)return -EEXIST ; + +refcount_inc (&b->filters_ref); }if (tb[TCA_ROUTE4_TO ])
@@ -495,7 +491,7 @@ static int route4_change(struct net *net, struct sk_buff *in_skb,struct route4_bucket *b;struct nlattr *opt = tca[TCA_OPTIONS ];struct nlattr *tb[TCA_ROUTE4_MAX +1 ]; -unsigned int h, th; +unsigned int h;int err;bool new = true;
@@ -553,17 +549,20 @@ static int route4_change(struct net *net, struct sk_buff *in_skb,rcu_assign_pointer (*fp, f);if (fold) { - th =to_hash (fold->handle); + b = fold->bkt; h =from_hash (fold->handle >>16 ); - b =rtnl_dereference (head->table[th]); -if (b) { - fp = &b->ht[h]; -for (pfp =rtnl_dereference (*fp); pfp; - fp = &pfp->next, pfp =rtnl_dereference (*fp)) { -if (pfp == fold) { -rcu_assign_pointer (*fp, fold->next); -break ; + fp = &b->ht[h]; +for (pfp =rtnl_dereference (*fp); pfp; + fp = &pfp->next, pfp =rtnl_dereference (*fp)) { +if (pfp == fold) { +rcu_assign_pointer (*fp, fold->next); +if (refcount_dec_and_test (&b->filters_ref)) { +unsigned int th =to_hash (fold->handle); + +RCU_INIT_POINTER (head->table[th],NULL ); +kfree_rcu (b, rcu); } +break ; } } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 352/752 net/sched: cls_api: Dont replay RTM_GETCHAIN in tc_ctl_chain().
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit dff39930ad5e53d202bfdfb14687d1d2fd753b4d ]
If a netlink socket sends RTM_GETCHAIN requests repeatedly without recv()ing the responses, tc_ctl_chain() hogs CPU and triggers Hung Task splat. [0]
As caught in the stack trace, netlink_attachskb() could confuse tc_ctl_chain() by returning -EAGAIN when the userspace netlink socket's receive buffer is full.
The replay: label exists since commit 32a4f5ecd738 ("net: sched:
introduce chain object to uapi") but was not used initially.
Since commit 9f407f1768d3 ("net: sched: introduce chain templates"), the label is needed for RTM_NEWCHAIN because tcf_proto_lookup_ops() may release RTNL to call request_module().
However, the replay logic is unnecessary for RTM_GETCHAIN.
Let's apply the replay logic only for RTM_NEWCHAIN.
[0]:
INFO: task repro:1018 is blocked on a mutex likely owned by task repro:1022. task:repro state:R running task stack:14096 pid:1022 tgid:1014 ppid:961 task_flags:0x400040 flags:0x00080000 Call Trace: <TASK> ? clockevents_program_event (kernel/time/clockevents.c:372) ? pskb_expand_head (net/core/skbuff.c:615) ? skb_release_data (net/core/skbuff.c:1122) ? netlink_attachskb (./include/linux/skbuff.h:1323 ./include/linux/skbuff.h:1332 net/netlink/af_netlink.c:1232) ? __netlink_lookup (./include/linux/rcupdate.h:882 ./include/linux/rhashtable.h:711 net/netlink/af_netlink.c:499) ? tc_chain_notify (net/sched/cls_api.c:3045) ? tc_chain_notify (./include/linux/skbuff.h:1384 net/sched/cls_api.c:3041) ? netlink_unicast (net/netlink/af_netlink.c:1335) ? rtnl_unicast (./include/net/netlink.h:1198 net/core/rtnetlink.c:985) ? tc_ctl_chain (net/sched/cls_api.c:3242) ? rtnetlink_rcv_msg (net/core/rtnetlink.c:7146) ? netlink_unicast (net/netlink/af_netlink.c:1354) ? __pfx_rtnetlink_rcv_msg (net/core/rtnetlink.c:7177) ? netlink_rcv_skb (net/netlink/af_netlink.c:2556) ? netlink_unicast (net/netlink/af_netlink.c:1319) ? netlink_sendmsg (net/netlink/af_netlink.c:1900) ? __sock_sendmsg (net/socket.c:800) ? __sys_sendto (net/socket.c:2281) ? __x64_sys_sendto (net/socket.c:2288 net/socket.c:2284 net/socket.c:2284) ? do_syscall_64 (arch/x86/entry/syscall_64.c:61 arch/x86/entry/syscall_64.c:84) ? entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) </TASK>
--- net/sched/cls_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/cls_api.c +1 -1
@@ -2936,7 +2936,7 @@ static int tc_ctl_chain(struct sk_buff *skb, struct nlmsghdr *n,tcf_chain_put (chain); errout_block:tcf_block_release (q, block, true); -if (err == -EAGAIN ) +if (err == -EAGAIN && n->nlmsg_type ==RTM_NEWCHAIN )/* Replay the request. */ goto replay;return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 353/752 net: sun4i-emac: fix missing of_node_put() for phy_node
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Youhong <[email protected]>
[ Upstream commit af406abfecad2f48d8f1fc646d3994f0982bac62 ]
of_parse_phandle() returns a node pointer with an elevated refcount. Add the missing of_node_put() on the probe error path after register_netdev() fails and in emac_remove().
--- drivers/net/ethernet/allwinner/sun4i-emac.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/allwinner/sun4i-emac.c +2 -0
@@ -886,6 +886,7 @@ static int emac_probe(struct platform_device *pdev)return 0 ; out_release_sram: +of_node_put (db->phy_node);sunxi_sram_release (&pdev->dev); out_clk_disable_unprepare:clk_disable_unprepare (db->clk);
@@ -907,6 +908,7 @@ static int emac_remove(struct platform_device *pdev)struct emac_board_info *db =netdev_priv (ndev);unregister_netdev (ndev); +of_node_put (db->phy_node);sunxi_sram_release (&pdev->dev);clk_disable_unprepare (db->clk);irq_dispose_mapping (ndev->irq);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 354/752 net: hinic: fix mailbox segment buffer overflow
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aamir Ahmed <[email protected]>
[ Upstream commit 5d4d985957434867bbe85e4fa5e638f3e48ad522 ]
check_mbox_seq_id_and_seg_len() validates that seq_id does not exceed SEQ_ID_MAX_VAL (42) and seg_len does not exceed MBOX_SEG_LEN (48). However, this allows the last segment (seq_id=42) to carry a full 48-byte payload, writing to offset 42*48=2016 for 48 bytes (ending at byte 2064). The receive buffer is only MBOX_MAX_BUF_SZ (2048) bytes, resulting in a 16-byte heap buffer overflow.
The hinic3 driver already handles this correctly by defining MBOX_LAST_SEG_MAX_LEN and rejecting the last segment when it exceeds the remaining buffer space. Apply the same fix to the hinic driver.
--- drivers/net/ethernet/huawei/hinic/hinic_hw_mbox.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/huawei/hinic/hinic_hw_mbox.c +3 -1
@@ -129,6 +129,7 @@ enum hinic_mbox_tx_status {#define SEQ_ID_START_VAL 0#define SEQ_ID_MAX_VAL 42 +#define MBOX_LAST_SEG_MAX_LEN (MBOX_MAX_BUF_SZ - SEQ_ID_MAX_VAL * MBOX_SEG_LEN)#define DST_AEQ_IDX_DEFAULT_VAL 0#define SRC_AEQ_IDX_DEFAULT_VAL 0
@@ -377,7 +378,8 @@ recv_pf_from_vf_mbox_handler(struct hinic_mbox_func_to_func *func_to_func,static bool check_mbox_seq_id_and_seg_len (struct hinic_recv_mbox *recv_mbox,u8 seq_id,u8 seg_len) { -if (seq_id >SEQ_ID_MAX_VAL || seg_len >MBOX_SEG_LEN ) +if (seq_id >SEQ_ID_MAX_VAL || seg_len >MBOX_SEG_LEN || + (seq_id ==SEQ_ID_MAX_VAL && seg_len >MBOX_LAST_SEG_MAX_LEN ))return false;if (seq_id ==0 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 355/752 octeontx2-af: fix PF/CGX debugfs PCI bus lookup
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ratheesh Kannoth <[email protected]>
[ Upstream commit 4f4b743c2d2bbc336cb164d9d3d2ed6956ad8437 ]
rvu_dbg_rvu_pf_cgx_map_display() locates each RVU PF PCI device via pci_get_domain_bus_and_slot() when printing the PF-to-CGX map. It assumed PF0 always sits on PCI bus 1 and derived other PF bus numbers as pf + 1, but the AF device can be enumerated on a different bus.
Use rvu->pdev->bus->number as the base bus instead, so each PF lookup uses pf + start on systems where RVU functions are on contiguous buses but do not start at bus 1.
--- .../net/ethernet/marvell/octeontx2/af/rvu_debugfs.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +8 -2
@@ -406,19 +406,25 @@ static int rvu_dbg_rvu_pf_cgx_map_display(struct seq_file *filp, void *unused)int pf, domain, blkid;u8 cgx_id, lmac_id;u16 pcifunc; +u8 start; - domain =2 ; + domain =pci_domain_nr (rvu->pdev->bus); mac_ops =get_mac_ops (rvu_first_cgx_pdata (rvu));/* There can be no CGX devices at all */ if (!mac_ops)return 0 ;seq_printf (filp,"PCI dev\t\tRVU PF Func\tNIX block\t%s\tLMAC\n" , mac_ops->name); + +/* All the PF devices are on contiguous PCI bus numbers, but the PF0(AF) +* may not start from 1 always. Hence get domain and bus from PCI device. +*/ + start = rvu->pdev->bus->number;for (pf =0 ; pf < rvu->hw->total_pfs; pf++) {if (!is_pf_cgxmapped (rvu, pf))continue ; - pdev =pci_get_domain_bus_and_slot (domain, pf +1 ,0 ); + pdev =pci_get_domain_bus_and_slot (domain, pf + start,0 );if (!pdev)continue ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 356/752 net/rds: Pass a pointer to virt_to_page()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit a60511cf15204e41f4edbcdc4ee80208d528917c ]
Functions that work on a pointer to virtual memory such as virt_to_pfn() and users of that function such as virt_to_page() are supposed to pass a pointer to virtual memory, ideally a (void *) or other pointer. However since many architectures implement virt_to_pfn() as a macro, this function becomes polymorphic and accepts both a (unsigned long) and a (void *).
If we instead implement a proper virt_to_pfn(void *addr) function the following happens (occurred on arch/arm):
net/rds/message.c:357:56: warning: passing argument 1
of 'virt_to_pfn' makes pointer from integer without a cast [-Wint-conversion]
Fix this with an explicit cast.
Stable-dep-of: 2ac09b5353fe ("net/rds: fix tcp stream corruption with large pages")
--- net/rds/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/rds/message.c +1 -1
@@ -364,7 +364,7 @@ struct rds_message *rds_message_map_pages(unsigned long *page_addrs, unsigned infor (i =0 ; i < rm->data.op_nents; ++i) {sg_set_page (&rm->data.op_sg[i], -virt_to_page (page_addrs[i]), +virt_to_page ((void *)page_addrs[i]),PAGE_SIZE ,0 ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 357/752 net/rds: fix tcp stream corruption with large pages
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Marsden <[email protected]>
[ Upstream commit 2ac09b5353fe6858411fdc8c6efa60d832e20f13 ]
rds_message_map_pages() assigns PAGE_SIZE bytes to every scatterlist entry, even when total_len ends in a partial page. The RDS congestion map is defined as 8192 bytes, so on systems with PAGE_SIZE greater than 8192 the scatterlist maps bytes beyond the end of the congestion map. RDS-TCP transmits the SG contents according to those lengths, so the extra bytes become part of the TCP RDS stream and are interpreted as subsequent RDS message headers, corrupting the stream.
Limit the final scatterlist mapping to the number of bytes remaining. This has no effect on systems with a 4K page size and allows RDS-TCP to be used on systems with 16K and larger page sizes.
The RDS selftest, which previously hung on 16K pages, now passes.
--- net/rds/message.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/rds/message.c +3 -1
@@ -365,7 +365,9 @@ struct rds_message *rds_message_map_pages(unsigned long *page_addrs, unsigned infor (i =0 ; i < rm->data.op_nents; ++i) {sg_set_page (&rm->data.op_sg[i],virt_to_page ((void *)page_addrs[i]), -PAGE_SIZE ,0 ); + i == rm->data.op_nents -1 + ? total_len - (i *PAGE_SIZE ) + :PAGE_SIZE ,0 ); }return rm;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 358/752 sunvdc: unmap LDC cookies when the descriptor send fails
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stian Halseth <[email protected]>
[ Upstream commit 0c6da21fa35e03fc74f09895433ccd6d4a9c3530 ]
__send_request() maps the request's pages into the LDC channel's map table (ldc_map_sg()), fills in the descriptor and marks it VIO_DESC_READY before ringing the doorbell via __vdc_tx_trigger(). When the trigger fails, the error path only prints a message: the descriptor stays READY and the cookies are never unmapped. The mapping is normally released in vdc_end_one() when the peer completes the descriptor - but a descriptor whose doorbell was never sent will never complete, and since dr->prod is not advanced on failure, the reset path (vdc_requeue_inflight(), which walks [cons, prod)) never visits it either. The map table entries are leaked permanently.
Since commit a11f6ca9aef9 ("sunvdc: Do not spin in an infinite loop when vio_ldc_send() returns EAGAIN") trigger failures occur in practice under load, so every resulting I/O error also leaks one request's worth of entries from the fixed-size (8192 entries per channel) map table. Because the allocator hands out contiguous ranges, fragmentation makes large multi-segment requests fail first as the table drains, until ldc_map_sg() fails permanently and the disk is dead until reboot.
It also makes any retry-based recovery unusable: requeuing the request on -EAGAIN remaps the pages on every attempt, overwriting desc->cookies and orphaning the previous mapping, so the table drains at the retry rate. This is the memory exhaustion observed when the requeue approach was first tested in October 2025.
Roll back on failure: unmap the cookies, mark the descriptor FREE again and clear the request entry. If the trigger failed with -ENOTCONN, __vdc_tx_trigger() has already reset the port, which tears down and reallocates both the dring and the LDC channel including its map table - nothing to roll back, and the stale descriptor must not be touched.
--- drivers/block/sunvdc.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/block/sunvdc.c +17 -0
@@ -524,6 +524,23 @@ static int __send_request(struct request *req) err =__vdc_tx_trigger (port);if (err <0 ) { printk(KERN_ERR PFX "vdc_tx_trigger() failure, err=%d\n", err); +/* +* If the port was reset (-ENOTCONN), the dring and the +* LDC channel including all of its mappings are already +* torn down and reallocated - there is nothing to undo +* and @desc must not be touched. +* +* For any other failure the descriptor was never handed +* to the peer: unmap the cookies and free the descriptor +* again, so that a later retry of the request does not +* leak LDC map table entries. +*/ +if (err != -ENOTCONN ) { +ldc_unmap (port->vio.lp, desc->cookies, + desc->ncookies); + desc->hdr.state =VIO_DESC_FREE ; + rqe->req =NULL ; + } }else { port->req_id++; dr->prod =vio_dring_next (dr, dr->prod);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 359/752 drm/amd/display: set new_stream to NULL after release
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: WenTao Liang <[email protected]>
commit 9fa26b9eed6195bf840f39ac183b9a6237548755 upstream.
In dm_update_crtc_state(), the skip_modeset path releases new_stream via dc_stream_release() but does not set the pointer to NULL.
If a later error (e.g., color management failure) triggers the fail label, the error path calls dc_stream_release() again on the same dangling pointer, causing a double release and potential use-after-free.
Fix this by setting new_stream to NULL after the initial release.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
@@ -10484,6 +10484,7 @@ static int dm_update_crtc_state(struct amdgpu_display_manager *dm,/* Release extra reference */ if (new_stream)dc_stream_release (new_stream); + new_stream =NULL ;/* * We want to do dc stream updates that do not require a
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 360/752 scsi: target: iscsi: Handle abort for WRITE_PENDING cmds
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Bogdanov <[email protected]>
[ Upstream commit ea87981a0ee8fb8ced1c87d004a541b60623ff97 ]
Sometimes an initiator does not send data for a WRITE command and tries to abort it. The abort hangs waiting for frontend driver completion. iSCSI driver waits for data and that timeout eventually initiates connection reinstatment. The connection closing releases the commands in the connection, but those aborted commands still did not handle the abort and did not decrease a command ref counter. Because of that the connection reinstatement hangs indefinitely and prevents re-login for that initiator.
Add handling in TCM of the abort for the WRITE_PENDING commands at connection closing moment to make it possible to release them.
--- drivers/target/iscsi/iscsi_target.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/target/iscsi/iscsi_target.c +11 -0
@@ -26,6 +26,7 @@#include <target/target_core_base.h> #include <target/target_core_fabric.h> +#include <target/target_core_backend.h> #include <target/iscsi/iscsi_target_core.h> #include "iscsi_target_parameters.h" #include "iscsi_target_seq_pdu_list.h"
@@ -4104,6 +4105,16 @@ static void iscsit_release_commands_from_conn(struct iscsi_conn *conn) }else { se_cmd->transport_state |=CMD_T_FABRIC_STOP ; } + +if (cmd->se_cmd.t_state ==TRANSPORT_WRITE_PENDING ) { +/* +* We never submitted the cmd to LIO core, so we have +* to tell LIO to perform the completion process. +*/ +spin_unlock_irq (&se_cmd->t_state_lock); +target_complete_cmd (&cmd->se_cmd,SAM_STAT_TASK_ABORTED ); +continue ; + }spin_unlock_irq (&se_cmd->t_state_lock); }spin_unlock_bh (&conn->cmd_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 361/752 scsi: target: iscsi: Fix hang for aborted WRITE_PENDING commands
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maurizio Lombardi <[email protected]>
[ Upstream commit d5869dae5080e976d4b03cc33eb7ceb527f242bf ]
When a LUN_RESET aborts a WRITE command that is in the TRANSPORT_WRITE_PENDING state, the target core sets CMD_T_ABORTED and waits for the frontend to finish processing.
If the initiator subsequently sends the remaining dataout PDUs, __iscsit_check_dataout_hdr() catches the payload, stops the dataout timer if the sequence is final and finally dumps the data. However, the iSCSI target doesn't trigger the completion process for these aborted commands. Because of this, the abort path hangs indefinitely in target_put_cmd_and_wait(), leading to a deadlocked target worker thread.
Fix this by explicitly calling target_complete_cmd() when the final dataout PDU is received for an aborted WRITE command. target_complete_cmd() detects the CMD_T_ABORTED flag and cleanly routes the command into target_abort_work, allowing the abort completion to successfully unblock.
--- drivers/target/iscsi/iscsi_target.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/target/iscsi/iscsi_target.c +3 -1
@@ -1530,8 +1530,10 @@ __iscsit_check_dataout_hdr(struct iscsi_conn *conn, void *buf,*/ if (se_cmd->transport_state &CMD_T_ABORTED ) {if (hdr->flags &ISCSI_FLAG_CMD_FINAL && - --cmd->outstanding_r2ts <1 ) + --cmd->outstanding_r2ts <1 ) {iscsit_stop_dataout_timer (cmd); +target_complete_cmd (se_cmd,SAM_STAT_TASK_ABORTED ); + }return iscsit_dump_data_payload (conn, payload_length,1 ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 362/752 ksmbd: prevent out-of-bounds reads in share config responses
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit f25e93768fcc5d8287e50b1ec52a42e4c276df34 ]
Validate IPC share configuration payload sizes before consuming variable-length fields. Bound veto list parsing and account for the separator byte when deriving the path length.
--- fs/ksmbd/mgmt/share_config.c | 38 ++++++++++++++++++++++++++---------- fs/ksmbd/transport_ipc.c | 24 +++++++++++++++++------ 2 files changed, 46 insertions(+), 16 deletions(-)
fs/ksmbd/mgmt/share_config.c +28 -10
@@ -87,9 +87,9 @@ static struct ksmbd_share_config *__share_lookup(const char *name)static int parse_veto_list (struct ksmbd_share_config *share,char *veto_list, -int veto_list_sz) +size_t veto_list_sz) { -int sz =0 ; +size_t sz;if (!veto_list_sz)return 0 ;
@@ -97,7 +97,7 @@ static int parse_veto_list(struct ksmbd_share_config *share,while (veto_list_sz >0 ) {struct ksmbd_veto_pattern *p; - sz =strlen (veto_list); + sz =strnlen (veto_list, veto_list_sz);if (!sz)break ;
@@ -105,7 +105,7 @@ static int parse_veto_list(struct ksmbd_share_config *share,if (!p)return -ENOMEM ; - p->pattern =kstrdup (veto_list,GFP_KERNEL ); + p->pattern =kstrndup (veto_list, sz,GFP_KERNEL );if (!p->pattern) {kfree (p);return -ENOMEM ;
@@ -113,6 +113,9 @@ static int parse_veto_list(struct ksmbd_share_config *share,list_add (&p->list, &share->veto_list); +if (sz == veto_list_sz) +break ; + veto_list += sz +1 ; veto_list_sz -= (sz +1 ); }
@@ -158,13 +161,27 @@ static struct ksmbd_share_config *share_config_request(struct unicode_map *um, share->name =kstrdup (name,GFP_KERNEL );if (!test_share_config_flag (share,KSMBD_SHARE_FLAG_PIPE )) { -int path_len =PATH_MAX ; +size_t path_len; -if (resp->payload_sz) +if (resp->payload_sz <= resp->veto_list_sz) { + ret = -EINVAL ; + }else { path_len = resp->payload_sz - resp->veto_list_sz; - - share->path =kstrndup (ksmbd_share_config_path (resp), path_len, -GFP_KERNEL ); +if (resp->veto_list_sz) + path_len--; + +if (!path_len) { + ret = -EINVAL ; + }else { + share->path =kstrndup ( +ksmbd_share_config_path (resp), + path_len,GFP_KERNEL ); +if (!share->path) + ret = -ENOMEM ; +else + ret =0 ; + } + }if (share->path) { share->path_sz =strlen (share->path); while (share->path_sz > 1 &&
@@ -177,7 +194,8 @@ static struct ksmbd_share_config *share_config_request(struct unicode_map *um, share->force_directory_mode = resp->force_directory_mode; share->force_uid = resp->force_uid; share->force_gid = resp->force_gid; - ret =parse_veto_list (share, +if (!ret) + ret =parse_veto_list (share,KSMBD_SHARE_CONFIG_VETO_LIST (resp), resp->veto_list_sz);if (!ret && share->path) {
fs/ksmbd/transport_ipc.c +18 -6
@@ -475,13 +475,25 @@ static int ipc_validate_msg(struct ipc_msg_table_entry *entry) }else if (entry->type ==KSMBD_EVENT_SHARE_CONFIG_REQUEST ) {struct ksmbd_share_config_response *resp = entry->response; -if (resp->payload_sz) { -if (resp->payload_sz < resp->veto_list_sz) -return -EINVAL ; +if (entry->msg_sz <sizeof (struct ksmbd_share_config_response )) +return -EINVAL ; + +if (strnlen (resp->share_name,sizeof (resp->share_name)) == +sizeof (resp->share_name)) +return -EINVAL ; + +if (resp->veto_list_sz > resp->payload_sz) +return -EINVAL ; + +if (resp->flags !=KSMBD_SHARE_FLAG_INVALID && + !(resp->flags &KSMBD_SHARE_FLAG_PIPE ) && + resp->payload_sz <= resp->veto_list_sz) +return -EINVAL ; + +if (check_add_overflow (sizeof (struct ksmbd_share_config_response ), + resp->payload_sz, &msg_sz)) +return -EINVAL ; - msg_sz =sizeof (struct ksmbd_share_config_response ) + - resp->payload_sz; - } }return entry->msg_sz != msg_sz ? -EINVAL :0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 363/752 macvlan: inherit needed_headroom and needed_tailroom from lowerdev
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit cef51860becd9700217c81732ca1eb1ea6ed6fe1 ]
macvlan devices inherit hard_header_len from lowerdev during macvlan_init(), but leave needed_headroom and needed_tailroom set to 0.
When the underlying lowerdev requires extra headroom or tailroom for headers/trailers (e.g. macsec, ipsec, wireguard, tunnels, or veth with rx headroom), upper layers calculating packet headroom and tailroom fail to reserve sufficient space.
This can result in reallocation overhead, skb headroom underflows, or KASAN slab-use-after-free crashes when dev_hard_header() / macvlan_hard_header() prepends header data or when lower devices append tailroom.
Fix this by:
1. Inheriting needed_headroom and needed_tailroom from lowerdev in macvlan_init().
2. Propagating needed_headroom and needed_tailroom updates to attached macvlans in macvlan_device_event() when receiving NETDEV_FEAT_CHANGE events.
--- drivers/net/macvlan.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/macvlan.c +4 -0
@@ -913,6 +913,8 @@ static int macvlan_init(struct net_device *dev) dev->gso_max_size = lowerdev->gso_max_size; dev->gso_max_segs = lowerdev->gso_max_segs; dev->hard_header_len = lowerdev->hard_header_len; + dev->needed_headroom = lowerdev->needed_headroom; + dev->needed_tailroom = lowerdev->needed_tailroom;macvlan_set_lockdep_class (dev); vlan->pcpu_stats = netdev_alloc_pcpu_stats(struct vlan_pcpu_stats);
@@ -1769,6 +1771,8 @@ static int macvlan_device_event(struct notifier_block *unused,list_for_each_entry (vlan, &port->vlans, list) { vlan->dev->gso_max_size = dev->gso_max_size; vlan->dev->gso_max_segs = dev->gso_max_segs; + vlan->dev->needed_headroom = dev->needed_headroom; + vlan->dev->needed_tailroom = dev->needed_tailroom;netdev_update_features (vlan->dev); }break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 364/752 Revert "scsi: smartpqi: Fix AIO retry marker cleared by SCSI core between dispatches."
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit 9349b8c77be9d50625d12b58dca4ee2b91f12017.
--- drivers/scsi/smartpqi/smartpqi_init.c | 18 ------------------ 1 file changed, 18 deletions(-)
drivers/scsi/smartpqi/smartpqi_init.c +0 -18
@@ -63,12 +63,6 @@ static struct pqi_cmd_priv *pqi_cmd_priv(struct scsi_cmnd *cmd)return scsi_cmd_priv (cmd); } -static int pqi_init_cmd_priv (struct Scsi_Host *shost,struct scsi_cmnd *cmd) -{ -memset (pqi_cmd_priv (cmd),0 ,sizeof (struct pqi_cmd_priv )); -return 0 ; -} -static void pqi_verify_structures (void );static void pqi_take_ctrl_offline (struct pqi_ctrl_info *ctrl_info,enum pqi_ctrl_shutdown_reason ctrl_shutdown_reason);
@@ -5641,17 +5635,6 @@ void pqi_prep_for_scsi_done(struct scsi_cmnd *scmd) {struct pqi_scsi_dev *device; -/* -* Clear the AIO-retry marker on final completion so the tag -* starts clean on its next dispatch. On DID_IMM_RETRY leave -* it intact: pqi_aio_io_complete() sets DID_IMM_RETRY and -* bumps the marker to steer the requeue onto the RAID path, -* and pqi_process_raid_io_error() consumes the non-zero -* marker to offline a misbehaving drive. -*/ -if (host_byte (scmd->result) !=DID_IMM_RETRY ) -pqi_cmd_priv (scmd)->this_residual =0 ; -if (!scmd->device) {set_host_byte (scmd,DID_NO_CONNECT );return ;
@@ -7007,7 +6990,6 @@ static struct scsi_host_template pqi_driver_template = { .sdev_groups = pqi_sdev_groups, .shost_groups = pqi_shost_groups, .cmd_size = sizeof(struct pqi_cmd_priv), - .init_cmd_priv = pqi_init_cmd_priv, };static int pqi_register_scsi (struct pqi_ctrl_info *ctrl_info)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 365/752 Revert "scsi: smartpqi: Stop using the SCSI pointer"
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit 3285f3a01085e815a2e2a6b72dcffbb037a62553.
--- drivers/scsi/smartpqi/smartpqi_init.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
drivers/scsi/smartpqi/smartpqi_init.c +2 -12
@@ -54,15 +54,6 @@ MODULE_DESCRIPTION("Driver for Microchip Smart Family Controller version "MODULE_VERSION (DRIVER_VERSION );MODULE_LICENSE ("GPL" ); -struct pqi_cmd_priv { -int this_residual; -}; - -static struct pqi_cmd_priv *pqi_cmd_priv (struct scsi_cmnd *cmd) -{ -return scsi_cmd_priv (cmd); -} -static void pqi_verify_structures (void );static void pqi_take_ctrl_offline (struct pqi_ctrl_info *ctrl_info,enum pqi_ctrl_shutdown_reason ctrl_shutdown_reason);
@@ -5399,7 +5390,7 @@ static void pqi_aio_io_complete(struct pqi_io_request *io_request,scsi_dma_unmap (scmd);if (io_request->status == -EAGAIN ||pqi_raid_bypass_retry_needed (io_request)) {set_host_byte (scmd,DID_IMM_RETRY ); -pqi_cmd_priv (scmd)->this_residual++; + scmd->SCp.this_residual++; }pqi_free_io_request (io_request);
@@ -5623,7 +5614,7 @@ static inline bool pqi_is_bypass_eligible_request(struct scsi_cmnd *scmd)if (blk_rq_is_passthrough (scsi_cmd_to_rq (scmd)))return false; -return pqi_cmd_priv (scmd)->this_residual ==0 ; +return scmd->SCp.this_residual ==0 ; }/*
@@ -6989,7 +6980,6 @@ static struct scsi_host_template pqi_driver_template = { .map_queues = pqi_map_queues, .sdev_groups = pqi_sdev_groups, .shost_groups = pqi_shost_groups, - .cmd_size = sizeof(struct pqi_cmd_priv), };static int pqi_register_scsi (struct pqi_ctrl_info *ctrl_info)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 366/752 Revert "scsi: smartpqi: Fix BUILD_BUG_ON() statements"
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit e434879e7e0880de501f745550671cb71a556bc8.
--- drivers/scsi/smartpqi/smartpqi_init.c | 5 +---- drivers/scsi/smartpqi/smartpqi_sis.c | 2 +- drivers/scsi/smartpqi/smartpqi_sis.h | 1 - 3 files changed, 2 insertions(+), 6 deletions(-)
drivers/scsi/smartpqi/smartpqi_init.c +1 -4
@@ -54,7 +54,6 @@ MODULE_DESCRIPTION("Driver for Microchip Smart Family Controller version "MODULE_VERSION (DRIVER_VERSION );MODULE_LICENSE ("GPL" ); -static void pqi_verify_structures (void );static void pqi_take_ctrl_offline (struct pqi_ctrl_info *ctrl_info,enum pqi_ctrl_shutdown_reason ctrl_shutdown_reason);static void pqi_ctrl_offline_worker (struct work_struct *work);
@@ -9296,8 +9295,6 @@ static int __init pqi_init(void)int rc;pr_info (DRIVER_NAME "\n" ); -pqi_verify_structures (); -sis_verify_structures (); pqi_sas_transport_template =sas_attach_transport (&pqi_sas_transport_functions);if (!pqi_sas_transport_template)
@@ -9321,7 +9318,7 @@ static void __exit pqi_cleanup(void)module_init (pqi_init);module_exit (pqi_cleanup); -static void pqi_verify_structures (void ) +static void __attribute__((unused))verify_structures (void ) {BUILD_BUG_ON (offsetof(struct pqi_ctrl_registers , sis_host_to_ctrl_doorbell) !=0x20 );
drivers/scsi/smartpqi/smartpqi_sis.c +1 -1
@@ -479,7 +479,7 @@ int sis_wait_for_fw_triage_completion(struct pqi_ctrl_info *ctrl_info)return rc; } -void sis_verify_structures (void ) +static void __attribute__((unused))verify_structures (void ) {BUILD_BUG_ON (offsetof(struct sis_base_struct , revision) !=0x0 );
drivers/scsi/smartpqi/smartpqi_sis.h +0 -1
@@ -12,7 +12,6 @@#if !defined(_SMARTPQI_SIS_H)#define _SMARTPQI_SIS_H -void sis_verify_structures (void );int sis_wait_for_ctrl_ready (struct pqi_ctrl_info *ctrl_info);int sis_wait_for_ctrl_ready_resume (struct pqi_ctrl_info *ctrl_info);bool sis_is_firmware_running (struct pqi_ctrl_info *ctrl_info);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 367/752 Revert "scsi: smartpqi: Switch to attribute groups"
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit e3789fa42d068f0c0c5c24063a1f941c8c4a8627.
--- drivers/scsi/smartpqi/smartpqi_init.c | 46 ++++++++++++--------------- 1 file changed, 21 insertions(+), 25 deletions(-)
drivers/scsi/smartpqi/smartpqi_init.c +21 -25
@@ -6664,22 +6664,20 @@ static DEVICE_ATTR(enable_r5_writes, 0644, static DEVICE_ATTR(enable_r6_writes, 0644, pqi_host_enable_r6_writes_show, pqi_host_enable_r6_writes_store); -static struct attribute *pqi_shost_attrs[] = { - &dev_attr_driver_version.attr, - &dev_attr_firmware_version.attr, - &dev_attr_model.attr, - &dev_attr_serial_number.attr, - &dev_attr_vendor.attr, - &dev_attr_rescan.attr, - &dev_attr_lockup_action.attr, - &dev_attr_enable_stream_detection.attr, - &dev_attr_enable_r5_writes.attr, - &dev_attr_enable_r6_writes.attr, +static struct device_attribute *pqi_shost_attrs[] = { + &dev_attr_driver_version, + &dev_attr_firmware_version, + &dev_attr_model, + &dev_attr_serial_number, + &dev_attr_vendor, + &dev_attr_rescan, + &dev_attr_lockup_action, + &dev_attr_enable_stream_detection, + &dev_attr_enable_r5_writes, + &dev_attr_enable_r6_writes,NULL }; -ATTRIBUTE_GROUPS (pqi_shost); -static ssize_t pqi_unique_id_show (struct device *dev,struct device_attribute *attr,char *buffer) {
@@ -6950,19 +6948,17 @@ static DEVICE_ATTR(ssd_smart_path_enabled, 0444, pqi_ssd_smart_path_enabled_show static DEVICE_ATTR(raid_level, 0444, pqi_raid_level_show, NULL); static DEVICE_ATTR(raid_bypass_cnt, 0444, pqi_raid_bypass_cnt_show, NULL); -static struct attribute *pqi_sdev_attrs[] = { - &dev_attr_lunid.attr, - &dev_attr_unique_id.attr, - &dev_attr_path_info.attr, - &dev_attr_sas_address.attr, - &dev_attr_ssd_smart_path_enabled.attr, - &dev_attr_raid_level.attr, - &dev_attr_raid_bypass_cnt.attr, +static struct device_attribute *pqi_sdev_attrs[] = { + &dev_attr_lunid, + &dev_attr_unique_id, + &dev_attr_path_info, + &dev_attr_sas_address, + &dev_attr_ssd_smart_path_enabled, + &dev_attr_raid_level, + &dev_attr_raid_bypass_cnt,NULL }; -ATTRIBUTE_GROUPS (pqi_sdev); -static struct scsi_host_template pqi_driver_template = { .module =THIS_MODULE , .name =DRIVER_NAME_SHORT ,
@@ -6977,8 +6973,8 @@ static struct scsi_host_template pqi_driver_template = { .slave_configure = pqi_slave_configure, .slave_destroy = pqi_slave_destroy, .map_queues = pqi_map_queues, - .sdev_groups = pqi_sdev_groups, - .shost_groups = pqi_shost_groups, + .sdev_attrs = pqi_sdev_attrs, + .shost_attrs = pqi_shost_attrs, };static int pqi_register_scsi (struct pqi_ctrl_info *ctrl_info)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 368/752 Revert "scsi: core: Register sysfs attributes earlier"
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit 694e1b6aabe4cd359b42c44b54c409c3147b6020.
--- drivers/scsi/hosts.c | 23 +---------- drivers/scsi/scsi_priv.h | 4 +- drivers/scsi/scsi_sysfs.c | 81 +++++++++++++++++++------------------- include/scsi/scsi_device.h | 7 ---- include/scsi/scsi_host.h | 12 ------ 5 files changed, 43 insertions(+), 84 deletions(-)
drivers/scsi/hosts.c +2 -21
@@ -387,7 +387,7 @@ static struct device_type scsi_host_type = {struct Scsi_Host *scsi_host_alloc (struct scsi_host_template *sht,int privsize) {struct Scsi_Host *shost; -int index, i, j =0 ; +int index; shost =kzalloc (sizeof (struct Scsi_Host ) + privsize,GFP_KERNEL );if (!shost)
@@ -492,26 +492,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) shost->shost_dev.parent = &shost->shost_gendev; shost->shost_dev.class = &shost_class;dev_set_name (&shost->shost_dev,"host%d" , shost->host_no); - shost->shost_dev.groups = shost->shost_dev_attr_groups; - shost->shost_dev_attr_groups[j++] = &scsi_shost_attr_group; -if (sht->shost_attrs) { - shost->lld_attr_group = (struct attribute_group ){ - .attrs =scsi_convert_dev_attrs (&shost->shost_gendev, - sht->shost_attrs) - }; -if (shost->lld_attr_group.attrs) - shost->shost_dev_attr_groups[j++] = - &shost->lld_attr_group; - } -if (sht->shost_groups) { -for (i =0 ; sht->shost_groups[i] && - j <ARRAY_SIZE (shost->shost_dev_attr_groups); - i++, j++) { - shost->shost_dev_attr_groups[j] = - sht->shost_groups[i]; - } - } -WARN_ON_ONCE (j >=ARRAY_SIZE (shost->shost_dev_attr_groups)); + shost->shost_dev.groups = scsi_sysfs_shost_attr_groups; shost->ehandler =kthread_run (scsi_error_handler, shost,"scsi_eh_%d" , shost->host_no);
drivers/scsi/scsi_priv.h +1 -3
@@ -138,15 +138,13 @@ extern int scsi_sysfs_add_sdev(struct scsi_device *);extern int scsi_sysfs_add_host (struct Scsi_Host *);extern int scsi_sysfs_register (void );extern void scsi_sysfs_unregister (void ); -struct attribute **scsi_convert_dev_attrs (struct device *dev, -struct device_attribute **dev_attr);extern void scsi_sysfs_device_initialize (struct scsi_device *);extern int scsi_sysfs_target_initialize (struct scsi_device *);extern struct scsi_transport_template blank_transport_template;extern void __scsi_remove_device (struct scsi_device *);extern struct bus_type scsi_bus_type; -extern const struct attribute_group scsi_shost_attr_group; +extern const struct attribute_group *scsi_sysfs_shost_attr_groups[];/* scsi_netlink.c */ #ifdef CONFIG_SCSI_NETLINK
drivers/scsi/scsi_sysfs.c +40 -41
133 lines not on this page · raw message
include/scsi/scsi_device.h +0 -7
@@ -226,13 +226,6 @@ struct scsi_device {struct device sdev_gendev, sdev_dev; -struct attribute_group lld_attr_group; -/* -* The array size 6 provides space for one attribute group for the -* SCSI core, four attribute groups defined by SCSI LLDs and one -* terminating NULL pointer. -*/ -const struct attribute_group *gendev_attr_groups[6 ];struct execute_work ew;/* used to get process context on put */ struct work_struct requeue_work;
include/scsi/scsi_host.h +0 -12
@@ -483,11 +483,6 @@ struct scsi_host_template {*/ struct device_attribute **sdev_attrs; -/* -* Pointer to the SCSI host sysfs attribute groups, NULL terminated. -*/ -const struct attribute_group **shost_groups; -/* * Pointer to the SCSI device attribute groups for this host, * NULL terminated.
@@ -703,13 +698,6 @@ struct Scsi_Host {/* ldm bits */ struct device shost_gendev, shost_dev; -struct attribute_group lld_attr_group; -/* -* The array size 3 provides space for one attribute group defined by -* the SCSI core, one attribute group defined by the SCSI LLD and one -* terminating NULL pointer. -*/ -const struct attribute_group *shost_dev_attr_groups[3 ];/* * Points to the transport data (if any) which is allocated
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 369/752 Revert "scsi: smartpqi: Capture controller reason codes"
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit 36ea920f00c59fce51e4faefd3522b7ce2a80380.
--- drivers/scsi/smartpqi/smartpqi.h | 25 ++--------------- drivers/scsi/smartpqi/smartpqi_init.c | 40 +++++++++------------------ drivers/scsi/smartpqi/smartpqi_sis.c | 9 ++---- drivers/scsi/smartpqi/smartpqi_sis.h | 3 +- 4 files changed, 20 insertions(+), 57 deletions(-)
drivers/scsi/smartpqi/smartpqi.h +3 -22
@@ -82,11 +82,9 @@ struct pqi_ctrl_registers {__le32 sis_product_identifier;/* B4h */ u8 reserved5[0xbc - (0xb4 +sizeof (__le32))];__le32 sis_firmware_status;/* BCh */ -u8 reserved6[0xcc - (0xbc +sizeof (__le32))]; -__le32 sis_ctrl_shutdown_reason_code;/* CCh */ -u8 reserved7[0x1000 - (0xcc +sizeof (__le32))]; +u8 reserved6[0x1000 - (0xbc +sizeof (__le32))];__le32 sis_mailbox[8 ];/* 1000h */ -u8 reserved8[0x4000 - (0x1000 + (sizeof (__le32) *8 ))]; +u8 reserved7[0x4000 - (0x1000 + (sizeof (__le32) *8 ))];/* * The PQI spec states that the PQI registers should be at * offset 0 from the PCIe BAR 0. However, we can't map
@@ -104,21 +102,6 @@ struct pqi_ctrl_registers {#define PQI_DEVICE_REGISTERS_OFFSET 0x4000 -/* shutdown reasons for taking the controller offline */ -enum pqi_ctrl_shutdown_reason { -PQI_IQ_NOT_DRAINED_TIMEOUT =1 , -PQI_LUN_RESET_TIMEOUT =2 , -PQI_IO_PENDING_POST_LUN_RESET_TIMEOUT =3 , -PQI_NO_HEARTBEAT =4 , -PQI_FIRMWARE_KERNEL_NOT_UP =5 , -PQI_OFA_RESPONSE_TIMEOUT =6 , -PQI_INVALID_REQ_ID =7 , -PQI_UNMATCHED_REQ_ID =8 , -PQI_IO_PI_OUT_OF_RANGE =9 , -PQI_EVENT_PI_OUT_OF_RANGE =10 , -PQI_UNEXPECTED_IU_TYPE =11 -}; -enum pqi_io_path {RAID_PATH =0 ,AIO_PATH =1
@@ -867,8 +850,7 @@ struct pqi_config_table_firmware_features {#define PQI_FIRMWARE_FEATURE_TMF_IU_TIMEOUT 14#define PQI_FIRMWARE_FEATURE_RAID_BYPASS_ON_ENCRYPTED_NVME 15#define PQI_FIRMWARE_FEATURE_UNIQUE_WWID_IN_REPORT_PHYS_LUN 16 -#define PQI_FIRMWARE_FEATURE_FW_TRIAGE 17 -#define PQI_FIRMWARE_FEATURE_MAXIMUM 17 +#define PQI_FIRMWARE_FEATURE_MAXIMUM 16struct pqi_config_table_debug {struct pqi_config_table_section_header header;
@@ -1315,7 +1297,6 @@ struct pqi_ctrl_info { u8 raid_iu_timeout_supported : 1; u8 tmf_iu_timeout_supported : 1; u8 unique_wwid_in_report_phys_lun_supported : 1; - u8 firmware_triage_supported : 1; u8 enable_r1_writes : 1; u8 enable_r5_writes : 1; u8 enable_r6_writes : 1;
drivers/scsi/smartpqi/smartpqi_init.c +13 -27
@@ -54,8 +54,7 @@ MODULE_DESCRIPTION("Driver for Microchip Smart Family Controller version "MODULE_VERSION (DRIVER_VERSION );MODULE_LICENSE ("GPL" ); -static void pqi_take_ctrl_offline (struct pqi_ctrl_info *ctrl_info, -enum pqi_ctrl_shutdown_reason ctrl_shutdown_reason); +static void pqi_take_ctrl_offline (struct pqi_ctrl_info *ctrl_info);static void pqi_ctrl_offline_worker (struct work_struct *work);static int pqi_scan_scsi_devices (struct pqi_ctrl_info *ctrl_info);static void pqi_scan_start (struct Scsi_Host *shost);
@@ -227,7 +226,7 @@ static inline void pqi_check_ctrl_health(struct pqi_ctrl_info *ctrl_info) {if (ctrl_info->controller_online)if (!sis_is_firmware_running (ctrl_info)) -pqi_take_ctrl_offline (ctrl_info,PQI_FIRMWARE_KERNEL_NOT_UP ); +pqi_take_ctrl_offline (ctrl_info); }static inline bool pqi_is_hba_lunid (u8 *scsi3addr)
@@ -3164,10 +3163,9 @@ static int pqi_interpret_task_management_response(struct pqi_ctrl_info *ctrl_infreturn rc; } -static inline void pqi_invalid_response (struct pqi_ctrl_info *ctrl_info, -enum pqi_ctrl_shutdown_reason ctrl_shutdown_reason) +static inline void pqi_invalid_response (struct pqi_ctrl_info *ctrl_info) { -pqi_take_ctrl_offline (ctrl_info, ctrl_shutdown_reason); +pqi_take_ctrl_offline (ctrl_info); }static int pqi_process_io_intr (struct pqi_ctrl_info *ctrl_info,struct pqi_queue_group *queue_group)
@@ -3185,7 +3183,7 @@ static int pqi_process_io_intr(struct pqi_ctrl_info *ctrl_info, struct pqi_queuewhile (1 ) { oq_pi =readl (queue_group->oq_pi);if (oq_pi >= ctrl_info->num_elements_per_oq) { -pqi_invalid_response (ctrl_info,PQI_IO_PI_OUT_OF_RANGE ); +pqi_invalid_response (ctrl_info);dev_err (&ctrl_info->pci_dev->dev,"I/O interrupt: producer index (%u) out of range (0-%u): consumer index: %u\n" , oq_pi, ctrl_info->num_elements_per_oq -1 , oq_ci);
@@ -3200,7 +3198,7 @@ static int pqi_process_io_intr(struct pqi_ctrl_info *ctrl_info, struct pqi_queue request_id =get_unaligned_le16 (&response->request_id);if (request_id >= ctrl_info->max_io_slots) { -pqi_invalid_response (ctrl_info,PQI_INVALID_REQ_ID ); +pqi_invalid_response (ctrl_info);dev_err (&ctrl_info->pci_dev->dev,"request ID in response (%u) out of range (0-%u): producer index: %u consumer index: %u\n" , request_id, ctrl_info->max_io_slots -1 , oq_pi, oq_ci);
@@ -3209,7 +3207,7 @@ static int pqi_process_io_intr(struct pqi_ctrl_info *ctrl_info, struct pqi_queue io_request = &ctrl_info->io_request_pool[request_id];if (atomic_read (&io_request->refcount) ==0 ) { -pqi_invalid_response (ctrl_info,PQI_UNMATCHED_REQ_ID ); +pqi_invalid_response (ctrl_info);dev_err (&ctrl_info->pci_dev->dev,"request ID in response (%u) does not match an outstanding I/O request: producer index: %u consumer index: %u\n" , request_id, oq_pi, oq_ci);
@@ -3245,7 +3243,7 @@ static int pqi_process_io_intr(struct pqi_ctrl_info *ctrl_info, struct pqi_queuepqi_process_io_error (response->header.iu_type, io_request);break ;default : -pqi_invalid_response (ctrl_info,PQI_UNEXPECTED_IU_TYPE ); +pqi_invalid_response (ctrl_info);dev_err (&ctrl_info->pci_dev->dev,"unexpected IU type: 0x%x: producer index: %u consumer index: %u\n" , response->header.iu_type, oq_pi, oq_ci);
@@ -3427,7 +3425,7 @@ static void pqi_process_soft_reset(struct pqi_ctrl_info *ctrl_info)pqi_ofa_free_host_buffer (ctrl_info);pqi_ctrl_ofa_done (ctrl_info);pqi_ofa_ctrl_unquiesce (ctrl_info); -pqi_take_ctrl_offline (ctrl_info,PQI_OFA_RESPONSE_TIMEOUT ); +pqi_take_ctrl_offline (ctrl_info);break ; } }
@@ -3552,7 +3550,7 @@ static void pqi_heartbeat_timer_handler(struct timer_list *t)dev_err (&ctrl_info->pci_dev->dev,"no heartbeat detected - last heartbeat count: %u\n" , heartbeat_count); -pqi_take_ctrl_offline (ctrl_info,PQI_NO_HEARTBEAT ); +pqi_take_ctrl_offline (ctrl_info);return ; } }else {
@@ -3616,7 +3614,7 @@ static int pqi_process_event_intr(struct pqi_ctrl_info *ctrl_info)while (1 ) { oq_pi =readl (event_queue->oq_pi);if (oq_pi >=PQI_NUM_EVENT_QUEUE_ELEMENTS ) { -pqi_invalid_response (ctrl_info,PQI_EVENT_PI_OUT_OF_RANGE ); +pqi_invalid_response (ctrl_info);dev_err (&ctrl_info->pci_dev->dev,"event interrupt: producer index (%u) out of range (0-%u): consumer index: %u\n" , oq_pi,PQI_NUM_EVENT_QUEUE_ELEMENTS -1 , oq_ci);
@@ -7334,10 +7332,7 @@ static void pqi_ctrl_update_feature_flags(struct pqi_ctrl_info *ctrl_info, ctrl_info->unique_wwid_in_report_phys_lun_supported = firmware_feature->enabled;break ; -case PQI_FIRMWARE_FEATURE_FW_TRIAGE : - ctrl_info->firmware_triage_supported = firmware_feature->enabled;pqi_save_fw_triage_setting (ctrl_info, firmware_feature->enabled); -break ; }pqi_firmware_feature_status (ctrl_info, firmware_feature);
@@ -7433,11 +7428,6 @@ static struct pqi_firmware_feature pqi_firmware_features[] = { .feature_bit = PQI_FIRMWARE_FEATURE_UNIQUE_WWID_IN_REPORT_PHYS_LUN, .feature_status = pqi_ctrl_update_feature_flags, }, - { - .feature_name = "Firmware Triage", - .feature_bit = PQI_FIRMWARE_FEATURE_FW_TRIAGE, - .feature_status = pqi_ctrl_update_feature_flags, - }, }; static void pqi_process_firmware_features(
@@ -7538,7 +7528,6 @@ static void pqi_ctrl_reset_config(struct pqi_ctrl_info *ctrl_info) ctrl_info->raid_iu_timeout_supported = false; ctrl_info->tmf_iu_timeout_supported = false; ctrl_info->unique_wwid_in_report_phys_lun_supported = false; - ctrl_info->firmware_triage_supported = false; }static int pqi_process_config_table (struct pqi_ctrl_info *ctrl_info)
@@ -8485,8 +8474,7 @@ static void pqi_ctrl_offline_worker(struct work_struct *work)pqi_take_ctrl_offline_deferred (ctrl_info); } -static void pqi_take_ctrl_offline (struct pqi_ctrl_info *ctrl_info, -enum pqi_ctrl_shutdown_reason ctrl_shutdown_reason) +static void pqi_take_ctrl_offline (struct pqi_ctrl_info *ctrl_info) {if (!ctrl_info->controller_online)return ;
@@ -8495,7 +8483,7 @@ static void pqi_take_ctrl_offline(struct pqi_ctrl_info *ctrl_info, ctrl_info->pqi_mode_enabled = false;pqi_ctrl_block_requests (ctrl_info);if (!pqi_disable_ctrl_shutdown) -sis_shutdown_ctrl (ctrl_info, ctrl_shutdown_reason); +sis_shutdown_ctrl (ctrl_info);pci_disable_device (ctrl_info->pci_dev);dev_err (&ctrl_info->pci_dev->dev,"controller offline\n" );schedule_work (&ctrl_info->ctrl_offline_work);
@@ -9330,8 +9318,6 @@ static void __attribute__((unused)) verify_structures(void) sis_product_identifier) != 0xb4);BUILD_BUG_ON (offsetof(struct pqi_ctrl_registers , sis_firmware_status) !=0xbc ); -BUILD_BUG_ON (offsetof(struct pqi_ctrl_registers , - sis_ctrl_shutdown_reason_code) !=0xcc );BUILD_BUG_ON (offsetof(struct pqi_ctrl_registers , sis_mailbox) !=0x1000 ); BUILD_BUG_ON(offsetof(struct pqi_ctrl_registers,
drivers/scsi/smartpqi/smartpqi_sis.c +3 -6
@@ -397,17 +397,14 @@ void sis_enable_intx(struct pqi_ctrl_info *ctrl_info)sis_set_doorbell_bit (ctrl_info,SIS_ENABLE_INTX ); } -void sis_shutdown_ctrl (struct pqi_ctrl_info *ctrl_info, -enum pqi_ctrl_shutdown_reason ctrl_shutdown_reason) +void sis_shutdown_ctrl (struct pqi_ctrl_info *ctrl_info) {if (readl (&ctrl_info->registers->sis_firmware_status) &SIS_CTRL_KERNEL_PANIC )return ; -if (ctrl_info->firmware_triage_supported) -writel (ctrl_shutdown_reason, &ctrl_info->registers->sis_ctrl_shutdown_reason_code); - -writel (SIS_TRIGGER_SHUTDOWN , &ctrl_info->registers->sis_host_to_ctrl_doorbell); +writel (SIS_TRIGGER_SHUTDOWN , + &ctrl_info->registers->sis_host_to_ctrl_doorbell); }int sis_pqi_reset_quiesce (struct pqi_ctrl_info *ctrl_info)
drivers/scsi/smartpqi/smartpqi_sis.h +1 -2
@@ -21,8 +21,7 @@ int sis_get_pqi_capabilities(struct pqi_ctrl_info *ctrl_info);int sis_init_base_struct_addr (struct pqi_ctrl_info *ctrl_info);void sis_enable_msix (struct pqi_ctrl_info *ctrl_info);void sis_enable_intx (struct pqi_ctrl_info *ctrl_info); -void sis_shutdown_ctrl (struct pqi_ctrl_info *ctrl_info, -enum pqi_ctrl_shutdown_reason ctrl_shutdown_reason); +void sis_shutdown_ctrl (struct pqi_ctrl_info *ctrl_info);int sis_pqi_reset_quiesce (struct pqi_ctrl_info *ctrl_info);int sis_reenable_sis_mode (struct pqi_ctrl_info *ctrl_info);void sis_write_driver_scratch (struct pqi_ctrl_info *ctrl_info,u32 value);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 370/752 powerpc/eeh: Fix recursive locking on devices without EEH sensitive driver
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shivaprasad G Bhat <[email protected]>
commit c5e68706527968282e49de205cc2b935823cb88a upstream.
The commit 1010b4c012b0 ("powerpc/eeh: Make EEH driver device hotplug safe") refactored the EEH code such that the pci_rescan_remove_lock is held at the beginning of eeh_handle_normal_event() and the eeh_reset_device() is called with that lock being held. Looks like the commit missed to remove the existing lock/unlock inside eeh_rmv_device() which is no longer necessary. This is causing the eehd to hang on the lock which it actually holds when that code path is taken.
[<0>] 0xc00000011c78f870
[<0>] __switch_to+0xfc/0x1a0 [<0>] pci_lock_rescan_remove+0x30/0x44 [<0>] eeh_rmv_device+0x290/0x2e0 [<0>] eeh_pe_dev_traverse+0x80/0x130 [<0>] eeh_reset_device+0xcc/0x23c [<0>] eeh_handle_normal_event+0x830/0xa80 [<0>] eeh_event_handler+0xf8/0x190 [<0>] kthread+0x194/0x1b0 [<0>] start_kernel_thread+0x14/0x18
The issue is seen for cases where the errors are detected on the PHB directly AND|OR for devices where the driver error_detected() returns PCI_ERS_RESULT_NEED_RESET, and driver being not EEH sensitive(i.e no error handlers like slot_reset(), resume() etc defined).
--- arch/powerpc/kernel/eeh_driver.c | 2 -- 1 file changed, 2 deletions(-)
arch/powerpc/kernel/eeh_driver.c +0 -2
@@ -534,9 +534,7 @@ static void eeh_rmv_device(struct eeh_deif (rmv_data)list_add (&edev->rmv_entry, &rmv_data->removed_vf_list); }else { -pci_lock_rescan_remove ();pci_stop_and_remove_bus_device (dev); -pci_unlock_rescan_remove (); } }
Greg Kroah-Hartman
maintainerPATCH 371/752 ipv6: fix fib6 walker UAF on seq stop
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zihan Xi <[email protected]>
commit 19b4ed644d68098cc62ab612727f40d30f43476c upstream.
ipv6_route_iter_active() treats a walker in FWS_U at the table root as already unlinked. fib6_del_route() can move a still-linked walker into that same state when the current leaf is the last route at the root, so ipv6_route_native_seq_stop() skips fib6_walker_unlink(). The seq private object can then be freed while it remains on net->ipv6.fib6_walkers. A later route deletion walks the dangling list and uses the freed walker.
Use the list head as membership state and reinitialize it when unlinking. Keep the existing w->node check so a never-started iterator with a zeroed private object is not treated as linked.
The same stop helper is used by /proc/net/ipv6_route and by the BPF ipv6_route iterator. The BPF show path only widens the race.
--- net/ipv6/ip6_fib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv6/ip6_fib.c +2 -2
@@ -84,7 +84,7 @@ static void fib6_walker_link(struct netstatic void fib6_walker_unlink (struct net *net,struct fib6_walker *w) {write_lock_bh (&net->ipv6.fib6_walker_lock); -list_del (&w->lh); +list_del_init (&w->lh);write_unlock_bh (&net->ipv6.fib6_walker_lock); }
@@ -2647,7 +2647,7 @@ static void *ipv6_route_seq_start(structstatic bool ipv6_route_iter_active (struct ipv6_route_iter *iter) {struct fib6_walker *w = &iter->w; -return w->node && !(w->state ==FWS_U && w->node == w->root); +return w->node && !list_empty (&w->lh); }static void ipv6_route_native_seq_stop (struct seq_file *seq,void *v)
Greg Kroah-Hartman
maintainerPATCH 372/752 ALSA: ctxfi: Fix CA20K2 S/PDIF passthrough
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roman Prucha <[email protected]>
commit b26a7a80e6bbf8dd17dacb127d12435d79375cf2 upstream.
dao_rsc_init() encodes the DAIO configuration as
conf = (desc->msr & 0x7) | (desc->passthru << 3);
S/PDIF passthrough uses msr=1 and passthru=1, resulting in conf=9.
daio_mgr_dao_init() masks conf with 0xf, but handles only values 1, 2, 4 and 8 when programming ATXCTL_NUC. As a result, conf=9 falls through to the default case and leaves NUC at its previous setting.
On a Creative X-Fi Titanium HD SB1270 (CA20K2), this breaks AC3 IEC61937 passthrough when snd_ctxfi runs with reference_rate=48000,multiple=2. The receiver detects a non-audio stream but cannot decode the AC3 payload.
With the unmodified driver, multiple=1 makes the same stream work. Handle conf=9 through the same NUC=0 path as conf=1.
The change was runtime tested on the SB1270 with multiple=2 using IEC958 stereo PCM, pre-encoded AC3 IEC61937 passthrough and ALSA A52 live 5.1 encoding.
--- sound/pci/ctxfi/cthw20k2.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/ctxfi/cthw20k2.c +1 -0
@@ -993,6 +993,7 @@ static int daio_mgr_dao_init(void *blk,/* S/PDIF output */ switch ((conf &0xf )) {case 1 : +case 9 :set_field (&ctl->txctl[idx],ATXCTL_NUC ,0 );break ;case 2 :
Greg Kroah-Hartman
maintainerPATCH 373/752 ALSA: usbusx2y: fix in04_last array size mismatch with in04_buf
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tristan Madani <[email protected]>
commit 861111a14740e12c36d363e9830f8daa734279c9 upstream.
The in04_last array in struct usx2ydev is declared as char[24], but in04_buf is allocated as sizeof(struct us428_ctls) which is 21 bytes. In i_usx2y_in04_int(), when ctl_snapshot_last == -2 (initialization path):
memcpy(usx2y->in04_last, usx2y->in04_buf, sizeof(usx2y->in04_last));
This copies 24 bytes from a 21-byte slab allocation, reading 3 bytes past the end of the source object.
Introduce a USX2Y_IN04_SIZE constant defined as sizeof(struct us428_ctls) and use it consistently for the in04_last array, the in04_buf allocation, the URB transfer length, and the comparison loop, replacing the bare 24 and 21 literals throughout.
--- sound/usb/usx2y/usbusx2y.c | 6 +++--- sound/usb/usx2y/usbusx2y.h | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-)
sound/usb/usx2y/usbusx2y.c +3 -3
@@ -197,7 +197,7 @@ static void i_usx2y_in04_int(struct urbmemcpy (usx2y->in04_last, usx2y->in04_buf,sizeof (usx2y->in04_last)); us428ctls->ctl_snapshot_last =-1 ; }else { -for (i =0 ; i <21 ; i++) { +for (i =0 ; i <USX2Y_IN04_SIZE ; i++) {if (usx2y->in04_last[i] != ((char *)usx2y->in04_buf)[i]) {if (diff <0 ) diff = i;
@@ -306,7 +306,7 @@ int usx2y_in04_init(struct usx2ydev *usx goto error; } - usx2y->in04_buf =kmalloc (21 ,GFP_KERNEL ); + usx2y->in04_buf =kmalloc (USX2Y_IN04_SIZE ,GFP_KERNEL );if (!usx2y->in04_buf) { err = -ENOMEM ; goto error;
@@ -314,7 +314,7 @@ int usx2y_in04_init(struct usx2ydev *usxinit_waitqueue_head (&usx2y->in04_wait_queue);usb_fill_int_urb (usx2y->in04_urb, usx2y->dev,usb_rcvintpipe (usx2y->dev,0x4 ), - usx2y->in04_buf,21 , + usx2y->in04_buf,USX2Y_IN04_SIZE , i_usx2y_in04_int, usx2y,10 );if (usb_urb_ep_type_check (usx2y->in04_urb)) {
sound/usb/usx2y/usbusx2y.h +3 -1
@@ -5,6 +5,8 @@#include "../midi.h" #include "usbus428ctldefs.h" +#define USX2Y_IN04_SIZE sizeof(struct us428_ctls) +#define NRURBS 2/* Default value used for nr of packs per urb.
@@ -55,7 +57,7 @@ struct usx2ydev {int stride;struct urb *in04_urb;void *in04_buf; -char in04_last[24 ]; +char in04_last[USX2Y_IN04_SIZE ];unsigned int in04_int_calls;struct snd_usx2y_urb_seq *us04;wait_queue_head_t in04_wait_queue;
Greg Kroah-Hartman
maintainerPATCH 374/752 dm/amdgpu: fix malformed link_settings debugfs output
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harry Wentland <[email protected]>
commit 622b4e8505aa7453a53d17fa3a288871f270fc8b upstream.
[Why]dp_link_settings_read() passed strlen() of each format string as the size argument to snprintf() and then advanced rd_buf_ptr by that same fixed amount. The format-string length has no relation to the formatted output length, so snprintf() truncated each field at a NUL it wrote inside the buffer while the pointer was advanced past it. The result is a buffer peppered with embedded NUL bytes and fields that are silently cut short, so the data read back from the debugfs node does not reflect the actual link settings.
[How]
Use scnprintf() with the real remaining buffer size (rd_buf_size - (rd_buf_ptr - rd_buf)) and advance rd_buf_ptr by its return value, which is the number of characters actually written. This both bounds each write to the space left in rd_buf and keeps the output a single, properly terminated string. The now-unused str_len local is removed.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 20 +++++--------- 1 file changed, 8 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c +8 -12
@@ -185,7 +185,6 @@ static ssize_t dp_link_settings_read(strchar *rd_buf_ptr =NULL ;const uint32_t rd_buf_size =100 ;uint32_t result =0 ; -uint8_t str_len =0 ;int r;if (*pos &3 || size &3 )
@@ -197,29 +196,26 @@ static ssize_t dp_link_settings_read(str rd_buf_ptr = rd_buf; - str_len =strlen ("Current: %d 0x%x %d " ); -snprintf (rd_buf_ptr, str_len,"Current: %d 0x%x %d " , + rd_buf_ptr +=scnprintf (rd_buf_ptr, rd_buf_size - (rd_buf_ptr - rd_buf), +"Current: %d 0x%x %d " , link->cur_link_settings.lane_count, link->cur_link_settings.link_rate, link->cur_link_settings.link_spread); - rd_buf_ptr += str_len; - str_len =strlen ("Verified: %d 0x%x %d " ); -snprintf (rd_buf_ptr, str_len,"Verified: %d 0x%x %d " , + rd_buf_ptr +=scnprintf (rd_buf_ptr, rd_buf_size - (rd_buf_ptr - rd_buf), +"Verified: %d 0x%x %d " , link->verified_link_cap.lane_count, link->verified_link_cap.link_rate, link->verified_link_cap.link_spread); - rd_buf_ptr += str_len; - str_len =strlen ("Reported: %d 0x%x %d " ); -snprintf (rd_buf_ptr, str_len,"Reported: %d 0x%x %d " , + rd_buf_ptr +=scnprintf (rd_buf_ptr, rd_buf_size - (rd_buf_ptr - rd_buf), +"Reported: %d 0x%x %d " , link->reported_link_cap.lane_count, link->reported_link_cap.link_rate, link->reported_link_cap.link_spread); - rd_buf_ptr += str_len; - str_len =strlen ("Preferred: %d 0x%x %d " ); -snprintf (rd_buf_ptr, str_len,"Preferred: %d 0x%x %d\n" , + rd_buf_ptr +=scnprintf (rd_buf_ptr, rd_buf_size - (rd_buf_ptr - rd_buf), +"Preferred: %d 0x%x %d\n" , link->preferred_link_setting.lane_count, link->preferred_link_setting.link_rate, link->preferred_link_setting.link_spread);
Greg Kroah-Hartman
maintainerPATCH 375/752 watchdog: sunxi_wdt: preserve boot-enabled watchdog
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Hilliard <[email protected]>
commit aab55360fa11a2c054798a484ac67ad606f563e4 upstream.
sunxi_wdt_probe() unconditionally stops the watchdog even when firmware left it running. This opens an unprotected interval during boot and prevents CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED from taking over the active watchdog.
Detect an enabled watchdog and decode its programmed interval. Preserve representable timeouts, and round the 0.5-second interval up to the minimum representable one-second timeout. Use the configured timeout for reserved interval encodings. Set the Linux reset mode and ping the watchdog without clearing its enable bit, then mark it hardware-running before registration so the watchdog core services it until userspace takes control. Leave disabled watchdogs untouched.
--- drivers/watchdog/sunxi_wdt.c | 45 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-)
drivers/watchdog/sunxi_wdt.c +44 -1
@@ -125,6 +125,38 @@ static int sunxi_wdt_ping(struct watchdoreturn 0 ; } +static bool sunxi_wdt_is_running (struct watchdog_device *wdt_dev) +{ +struct sunxi_wdt_dev *sunxi_wdt =watchdog_get_drvdata (wdt_dev); +const struct sunxi_wdt_reg *regs = sunxi_wdt->wdt_regs; + +return readl (sunxi_wdt->wdt_base + regs->wdt_mode) &WDT_MODE_EN ; +} + +static unsigned int sunxi_wdt_get_timeout (struct watchdog_device *wdt_dev) +{ +struct sunxi_wdt_dev *sunxi_wdt =watchdog_get_drvdata (wdt_dev); +const struct sunxi_wdt_reg *regs = sunxi_wdt->wdt_regs; +unsigned int timeout; +u32 interval; + + interval =readl (sunxi_wdt->wdt_base + regs->wdt_mode); + interval >>= regs->wdt_timeout_shift; + interval &=WDT_TIMEOUT_MASK ; +/* Round the 0.5-second interval up to the minimum representable timeout. */ +if (!interval) +return WDT_MIN_TIMEOUT ; + +for (timeout =WDT_MIN_TIMEOUT ; + timeout <ARRAY_SIZE (wdt_timeout_map); timeout++) { +if (wdt_timeout_map[timeout] == interval) +return timeout; + } + +/* Reserved interval encoding. */ +return 0 ; +} +static int sunxi_wdt_set_timeout (struct watchdog_device *wdt_dev,unsigned int timeout) {
@@ -231,6 +263,7 @@ static int sunxi_wdt_probe(struct platfo {struct device *dev = &pdev->dev;struct sunxi_wdt_dev *sunxi_wdt; +unsigned int running_timeout;int err; sunxi_wdt =devm_kzalloc (dev,sizeof (*sunxi_wdt),GFP_KERNEL );
@@ -258,7 +291,17 @@ static int sunxi_wdt_probe(struct platfowatchdog_set_drvdata (&sunxi_wdt->wdt_dev, sunxi_wdt); -sunxi_wdt_stop (&sunxi_wdt->wdt_dev); +if (sunxi_wdt_is_running (&sunxi_wdt->wdt_dev)) { + running_timeout =sunxi_wdt_get_timeout (&sunxi_wdt->wdt_dev); +if (running_timeout) + sunxi_wdt->wdt_dev.timeout = running_timeout; + + err =sunxi_wdt_start (&sunxi_wdt->wdt_dev); +if (err) +return err; + +set_bit (WDOG_HW_RUNNING , &sunxi_wdt->wdt_dev.status); + }watchdog_stop_on_reboot (&sunxi_wdt->wdt_dev); err =devm_watchdog_register_device (dev, &sunxi_wdt->wdt_dev);
Greg Kroah-Hartman
maintainerPATCH 376/752 ufs: create the root dentry after loading cylinder metadata
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ali Ahmet Memis <[email protected]>
commit 55a4c98abb9694b067c6a031d11501f06b6b523c upstream.
ufs_fill_super() installed sb->s_root before it loaded the cylinder group structures for a writable mount:
sb->s_root = d_make_root(inode); ... if (!sb_rdonly(sb)) if (!ufs_read_cylinder_structures(sb)) goto failed;
When ufs_read_cylinder_structures() failed, the error path freed the in-core superblock information and set sb->s_fs_info to NULL while sb->s_root stayed installed. get_tree_bdev() then reached deactivate_locked_super(), and because s_root was present, generic_shutdown_super() called sync_filesystem() and the put_super operation. Both dereference UFS_SB(sb), which is now NULL, so a mount that fails only while reading the cylinder groups oopses during teardown. A crafted image whose first cylinder group cannot be read reaches this path.
Load the cylinder group metadata first and create the root dentry last, so the superblock is published to the VFS only once it is fully set up. ufs_setup_cstotal() and ufs_read_cylinder_structures() take only the super_block and do not use the root inode, so the reordering is safe.
--- fs/ufs/super.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
fs/ufs/super.c +9 -8
@@ -1268,6 +1268,15 @@ magic_found: sb->s_maxbytes =ufs_max_bytes (sb); sb->s_max_links =UFS_LINK_MAX ; +ufs_setup_cstotal (sb); +/* +* Read cylinder group structures +*/ +if (!sb_rdonly (sb)) +if (!ufs_read_cylinder_structures (sb)) + goto failed; + +/* create the root dentry last, once UFS_SB(sb) is fully set up */ inode =ufs_iget (sb,UFS_ROOTINO );if (IS_ERR (inode)) { ret =PTR_ERR (inode);
@@ -1279,14 +1288,6 @@ magic_found: goto failed; } -ufs_setup_cstotal (sb); -/* -* Read cylinder group structures -*/ -if (!sb_rdonly (sb)) -if (!ufs_read_cylinder_structures (sb)) - goto failed; -UFSD ("EXIT\n" );return 0 ;
Greg Kroah-Hartman
maintainerPATCH 377/752 ufs: validate cylinder group metadata before caching it
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ali Ahmet Memis <[email protected]>
commit c9d263be26806d388129fab8c6904bed197fc6af upstream.
ufs_read_cylinder() copies the cylinder group index and the rotor positions straight from the on-disk group and caches them without any check:
ucpi->c_cgx = fs32_to_cpu(sb, ucg->cg_cgx); ucpi->c_rotor = fs32_to_cpu(sb, ucg->cg_rotor); ucpi->c_frotor = fs32_to_cpu(sb, ucg->cg_frotor); ucpi->c_irotor = fs32_to_cpu(sb, ucg->cg_irotor);
They are then used as indices during allocation and free:
- c_cgx indexes the cylinder summary array as UFS_SB(sb)->fs_cs(ucpi->c_cgx), so a value past s_ncg writes a 32 bit count outside the s_csp allocation.
- c_frotor becomes a bitmap scan start, start = c_frotor >> 3, and then length = ((s_fpg + 7) >> 3) - start. A start beyond the block bitmap wraps the unsigned length to a huge value, so ubh_scanc() walks far past the cylinder group buffers. c_irotor drives the inode bitmap the same way.
A crafted image can set any of these freely, turning an ordinary allocation into an out of bounds access.
Reject a cylinder group whose recorded index does not match the group being read, or whose rotors fall outside the group, before the metadata is cached. Valid filesystems keep cg_cgx equal to the group number and the rotors within the group, so only malformed images are rejected.
--- fs/ufs/cylinder.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/ufs/cylinder.c +10 -0
@@ -66,6 +66,16 @@ static void ufs_read_cylinder (struct su ucpi->c_clustersumoff =fs32_to_cpu (sb, ucg->cg_u.cg_44.cg_clustersumoff); ucpi->c_clusteroff =fs32_to_cpu (sb, ucg->cg_u.cg_44.cg_clusteroff); ucpi->c_nclusterblks =fs32_to_cpu (sb, ucg->cg_u.cg_44.cg_nclusterblks); + +/* these on-disk values become array and bitmap indices */ +if (ucpi->c_cgx != cgno || + ucpi->c_rotor >= uspi->s_fpg || + ucpi->c_frotor >= uspi->s_fpg || + ucpi->c_irotor >= uspi->s_ipg) { +ufs_error (sb, __func__, +"inconsistent metadata in cylinder group %u\n" , cgno); + goto failed; + }UFSD ("EXIT\n" );return ;
Greg Kroah-Hartman
maintainerPATCH 378/752 tunnels: Drop stale dst when building an ICMP error for PMTUD
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
commit b58d749633203d92c265317b45fccee555090352 upstream.
Bridged UDP tunnels such as VXLAN and GENEVE build an ICMP error packet around an overlay packet if the packet is going to exceed the underlay path MTU. The ICMP error packet is then injected back into the Rx path with the source and destination addresses swapped, so that it will be delivered to the overlay source.
If the overlay packet was routed to the UDP tunnel or locally generated, then it is already carrying a valid dst entry and this entry is not dropped when transforming the packet to an ICMP error packet. This causes the IP layer to reuse the dst entry, leading to the ICMP error packet being dropped or routed out of the UDP tunnel interface in case of forwarding.
Prior to the blamed commit this could not happen, as skb_tunnel_check_pmtu() did not build ICMP errors for PACKET_HOST packets. Such packets were instead encapsulated and, unless the DF bit was set in the outer header, fragmented by the underlay.
Fix this by making sure that the ICMP error packet does not have a valid dst entry, thereby forcing the IP layer to perform a route lookup.
Adjust the bridged PMTU exception selftests accordingly. When the local sender in ns_a pings the overlay destination with a deadline (-w), ping exits on the first socket error before any reply is received and returns a non-zero exit code. The test therefore only passed because the ICMP error was never delivered. Use a packet count (-c) like the ns_c line above it, so that the ICMP error counts against the packet budget and the exit code depends on whether echo replies were received. This passes with and without the fix.
--- net/ipv4/ip_tunnel_core.c | 6 ++++++ tools/testing/selftests/net/pmtu.sh | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-)
net/ipv4/ip_tunnel_core.c +6 -0
@@ -250,6 +250,9 @@ static int iptunnel_pmtud_build_icmp(streth_header (skb, skb->dev,ntohs (eh.h_proto), eh.h_source, eh.h_dest,0 );skb_reset_mac_header (skb); +if (skb_valid_dst (skb)) +skb_dst_drop (skb); +return skb->len; }
@@ -353,6 +356,9 @@ static int iptunnel_pmtud_build_icmpv6(seth_header (skb, skb->dev,ntohs (eh.h_proto), eh.h_source, eh.h_dest,0 );skb_reset_mac_header (skb); +if (skb_valid_dst (skb)) +skb_dst_drop (skb); +return skb->len; }
tools/testing/selftests/net/pmtu.sh +1 -1
@@ -1369,7 +1369,7 @@ test_pmtu_ipvX_over_bridged_vxlanY_or_ge mtu "${ns_b}" ${type}_b $((${ll_mtu} + 1000)) run_cmd ${ns_c} ${ping} -q -M want -i 0.1 -c 10 -s $((${ll_mtu} + 500)) ${dst} || return 1 - run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s $((${ll_mtu} + 500)) ${dst} || return 1 + run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -c 10 -s $((${ll_mtu} + 500)) ${dst} || return 1 # Check that exceptions were created pmtu="$(route_get_dst_pmtu_from_exception "${ns_c}" ${dst})"
Greg Kroah-Hartman
maintainerPATCH 379/752 tracing: Free histogram the var ref when its initialization fails
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Donggeun Yoo <[email protected]>
commit 516001d53e6b2ea95a251ee2ef54a1a689a3fd58 upstream.
create_var_ref() allocates a VAR_REF hist_field and then calls init_var_ref() to fill it in. When that fails the field is leaked.
commit 656fe2ba85e8 ("tracing: Use hist trigger's var_ref array to destroy var_refs") made destroy_hist_field() return early for HIST_FIELD_FL_VAR_REF, since var refs are freed by walking the trigger's var_refs[] array instead. create_var_ref() adds the field to that array only after init_var_ref() has succeeded, so on this path the field is in neither place and nothing frees it. The call was correct when it was written, before var refs were taken out of destroy_hist_field().
init_var_ref() cannot free it either. The caller owns the field, so init_var_ref() undoes only its own string allocations and leaves the field alone. Freeing it there would leave create_var_ref() passing freed memory to destroy_hist_field(), which reads its flags.
Call __destroy_hist_field(), which frees the field without consulting the flag.
--- kernel/trace/trace_events_hist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_hist.c +1 -1
@@ -1902,7 +1902,7 @@ static struct hist_field *create_var_ref ref_field =create_hist_field (var_field->hist_data,NULL , flags,NULL );if (ref_field) {if (init_var_ref (ref_field, var_field, system, event_name)) { -destroy_hist_field (ref_field,0 ); +__destroy_hist_field (ref_field);return NULL ; }
Greg Kroah-Hartman
maintainerPATCH 380/752 ASoC: sprd: validate compress buffer sizes against fixed allocations
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tianchu Chen <[email protected]>
commit 7a4ce92d150b9e7ecf1a710a34d8cdeb590d3751 upstream.
sprd_platform_compr_open() allocates the stage 0 IRAM buffer (32K data area) and the stage 1 DDR buffer (2M data area) with fixed sizes, but sprd_platform_compr_copy() derives all copy lengths from the user controlled runtime->fragment_size and the write() count, never comparing them against the physical buffer sizes. The compress core only checks fragment_size * fragments for an u32 overflow in snd_compress_check_input(), so a local user can configure a logical buffer of up to ~4GB via SNDRV_COMPRESS_SET_PARAMS, far exceeding the fixed allocations.
A fragment_size larger than the 32K IRAM data area makes the stage 0 copy_from_user() overflow past the IRAM allocation, and a buffer_size larger than the 2M DDR buffer makes the wrapping copy at the end of sprd_platform_compr_copy() write fully user controlled data past the buffer. No SNDRV_PCM_TRIGGER_START is needed, a write() in SETUP state reaches the copy callback directly.
Reject parameters that do not fit into the fixed buffers in set_params(), and fix the advertised max fragment size: 128K never fitted into the 32K IRAM buffer. The caps values may have been carried over from the qdsp6 driver, which allocates its buffers according to the advertised maxima, unlike this driver. With 32K as max fragment size the advertised limits are self-consistent: 32K * 64 = 2M equals the DDR buffer size.
Discovered by Atuin - Automated Vulnerability Discovery Engine.
--- sound/soc/sprd/sprd-pcm-compress.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
sound/soc/sprd/sprd-pcm-compress.c +14 -1
@@ -17,7 +17,7 @@/* Default values if userspace does not set */ #define SPRD_COMPR_MIN_FRAGMENT_SIZE SZ_8K -#define SPRD_COMPR_MAX_FRAGMENT_SIZE SZ_128K +#define SPRD_COMPR_MAX_FRAGMENT_SIZE SZ_32K#define SPRD_COMPR_MIN_NUM_FRAGMENTS 4#define SPRD_COMPR_MAX_NUM_FRAGMENTS 64
@@ -272,6 +272,19 @@ static int sprd_platform_compr_set_paramint ret;/* +* The stage 0 IRAM buffer and the stage 1 DDR buffer are allocated +* with fixed sizes at open time, so the requested fragment size and +* fragments must fit into them, otherwise sprd_platform_compr_copy() +* would overflow the buffers. Note the compress core only checks the +* fragment size and fragments against an u32 overflow, not against +* the buffer sizes advertised by get_caps. +*/ +if (params->buffer.fragment_size >SPRD_COMPR_IRAM_BUF_SIZE || + (u64 )params->buffer.fragment_size * params->buffer.fragments > +SPRD_COMPR_AREA_BUF_SIZE ) +return -EINVAL ; + +/* * Configure the DMA engine 2-stage transfer mode. Channel 1 set as the * destination channel, and channel 0 set as the source channel, that * means once the source channel's transaction is done, it will trigger
Greg Kroah-Hartman
maintainerPATCH 381/752 ASoC: sti: initialize IRQ lock before requesting IRQ
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
commit 04405aeef4f8d7bcac6dcb1947acafdb4420c2c3 upstream.
uni_reader_init() registers the shared IRQ before initializing reader->irq_lock. A pending interrupt can invoke the handler while the lock is still uninitialized.
Initialize the lock before registering the IRQ so the interrupt path always sees valid lock state.
--- sound/soc/sti/uniperif_reader.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/sti/uniperif_reader.c +2 -2
@@ -421,6 +421,8 @@ int uni_reader_init(struct platform_devielse reader->hw = &uni_reader_pcm_hw; +spin_lock_init (&reader->irq_lock); + ret =devm_request_irq (&pdev->dev, reader->irq, uni_reader_irq_handler,IRQF_SHARED ,dev_name (&pdev->dev), reader);
@@ -429,8 +431,6 @@ int uni_reader_init(struct platform_devireturn -EBUSY ; } -spin_lock_init (&reader->irq_lock); -return 0 ; }EXPORT_SYMBOL_GPL (uni_reader_init);
Greg Kroah-Hartman
maintainerPATCH 382/752 cpufreq: zero-initialize policy cpumask before sysfs publication
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhongqiu Han <[email protected]>
commit 54d37bcf2f497140b9207968557ddb484058e749 upstream.
cpufreq_policy_alloc() allocates policy->cpus with alloc_cpumask_var(), i.e. without __GFP_ZERO, unlike the sibling related_cpus and real_cpus masks. With CONFIG_CPUMASK_OFFSTACK=y the mask is a separate kmalloc_node() allocation, so its bitmap holds whatever the slab allocator left behind:
cpufreq_online()
cpufreq_policy_alloc()
alloc_cpumask_var(&policy->cpus) /* bitmap is uninitialized */
kobject_init_and_add() /* policy%u/ appears in sysfs */
cpufreq_policy_online()
cpumask_copy(policy->cpus, cpumask_of(cpu)) /* first valid value */This leaves a window in which the sysfs attributes are already reachable while policy->cpus is still garbage. show()/store() gate on policy_is_inactive(), i.e. cpumask_empty(policy->cpus), so a non-zero bitmap makes them run the attribute callbacks on a policy that is not initialized yet.
Fix this by using zalloc_cpumask_var() for policy->cpus.
--- drivers/cpufreq/cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +1 -1
@@ -1205,7 +1205,7 @@ static struct cpufreq_policy *cpufreq_poif (!policy)return NULL ; -if (!alloc_cpumask_var (&policy->cpus,GFP_KERNEL )) +if (!zalloc_cpumask_var (&policy->cpus,GFP_KERNEL )) goto err_free_policy;if (!zalloc_cpumask_var (&policy->related_cpus,GFP_KERNEL ))
Greg Kroah-Hartman
maintainerPATCH 383/752 cpufreq: initialize policy rwsem before sysfs publication
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
commit 3e5d1bf4bd687beb2cb4e32a07af695455925588 upstream.
cpufreq_policy_alloc() initializes policy->rwsem after kobject_init_and_add() has created the policy sysfs directory and its default attributes. A sysfs access can therefore reach a policy callback before the semaphore has been initialized.
Initialize policy->rwsem before publishing the policy kobject so sysfs callbacks always see an initialized semaphore.
--- drivers/cpufreq/cpufreq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/cpufreq.c +2 -2
@@ -1214,6 +1214,8 @@ static struct cpufreq_policy *cpufreq_poif (!zalloc_cpumask_var (&policy->real_cpus,GFP_KERNEL )) goto err_free_rcpumask; +init_rwsem (&policy->rwsem); +init_completion (&policy->kobj_unregister); ret =kobject_init_and_add (&policy->kobj, &ktype_cpufreq, cpufreq_global_kobject,"policy%u" , cpu);
@@ -1228,8 +1230,6 @@ static struct cpufreq_policy *cpufreq_po goto err_free_real_cpus; } -init_rwsem (&policy->rwsem); -freq_constraints_init (&policy->constraints); policy->nb_min.notifier_call = cpufreq_notifier_min;
Greg Kroah-Hartman
maintainerPATCH 384/752 exec: do_close_on_exec() before taking exec_update_lock
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit e780259b54e618ceb4763fbc21314acf3565e813 upstream.
do_close_on_exec() currently happens while holding the exec_update_lock, which is used in a lot of places that access process state to synchronize access checks.
I recently added another such use of exec_update_lock, causing a regression.
do_close_on_exec() can block waiting for a reply from a filesystem. That means a hung filesystem can block codepaths that use exec_update_lock; and it also means that a FUSE filesystem which attempts to inspect the calling process can deadlock.
To avoid such problems, move do_close_on_exec() before the exec_update_lock is taken, but after the FD table has been copied if necessary.
I have looked through all the calls between the old and new position of the do_close_on_exec() call; there seems to be no file descriptor table access in between.
--- fs/exec.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)
fs/exec.c +14 -8
@@ -1273,6 +1273,20 @@ int begin_new_exec(struct linux_binprm * goto out;/* +* We have to apply CLOEXEC before we change whether the process is +* dumpable (in setup_new_exec) to avoid a race with a process in userspace +* trying to access the should-be-closed file descriptors of a process +* undergoing exec(2). +* +* This can block on filesystem ->flush() handlers, including waiting +* for FUSE daemons, so do it before exec_mmap takes the +* exec_update_lock. +* This must happen after the point of no return, and after unsharing +* the FD table. +*/ +do_close_on_exec (me->files); + +/* * Must be called _before_ exec_mmap() as bprm->mm is * not visibile until then. This also enables the update * to be lockless.
@@ -1324,14 +1338,6 @@ int begin_new_exec(struct linux_binprm *clear_syscall_work_syscall_user_dispatch (me); -/* -* We have to apply CLOEXEC before we change whether the process is -* dumpable (in setup_new_exec) to avoid a race with a process in userspace -* trying to access the should-be-closed file descriptors of a process -* undergoing exec(2). -*/ -do_close_on_exec (me->files); -if (bprm->secureexec) {/* Make sure parent cannot signal privileged process. */ me->pdeath_signal =0 ;
Greg Kroah-Hartman
maintainerPATCH 385/752 drm/i915: Fix memory leak in query_perf_config_list()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
commit cbd3dafc2003db679ccd2f6c6a2551db79657049 upstream.
When krealloc() fails, free the original oa_config_ids before returning to avoid a memory leak.
--- drivers/gpu/drm/i915/i915_query.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_query.c +3 -1
@@ -364,8 +364,10 @@ static int query_perf_config_list(struct ids =krealloc (oa_config_ids, n_configs *sizeof (*oa_config_ids),GFP_KERNEL ); -if (!ids) +if (!ids) { +kfree (oa_config_ids);return -ENOMEM ; + } alloc =fetch_and_zero (&n_configs);
Greg Kroah-Hartman
maintainerPATCH 386/752 net: hso: fix TIOCMIWAIT race
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 00f9fbc12320253bfc576fb7539d860029c82d0f upstream.
The task state must be updated before checking the wakeup condition to avoid missing a racing modem status update.
--- drivers/net/usb/hso.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/hso.c +1 -1
@@ -1555,10 +1555,10 @@ hso_wait_modem_status(struct hso_serialspin_unlock_irq (&serial->serial_lock);add_wait_queue (&tiocmget->waitq, &wait);for (;;) { +set_current_state (TASK_INTERRUPTIBLE );spin_lock_irq (&serial->serial_lock);memcpy (&cnow, &tiocmget->icount,sizeof (struct uart_icount ));spin_unlock_irq (&serial->serial_lock); -set_current_state (TASK_INTERRUPTIBLE );if (((arg &TIOCM_RNG ) && (cnow.rng != cprev.rng)) || ((arg &TIOCM_DSR ) && (cnow.dsr != cprev.dsr)) || ((arg &TIOCM_CD ) && (cnow.dcd != cprev.dcd))) {
Greg Kroah-Hartman
maintainerPATCH 387/752 net: mpls: clear inner_protocol when the last label is popped
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fourie Zhang <[email protected]>
commit 78a86d75a70e1e227711c72865c59b1422d0a5ae upstream.
skb_mpls_push() records the pre-encapsulation network header once, gated on !skb->inner_protocol. skb_mpls_pop() never clears that record, so it outlives the encapsulation it describes.
Open vSwitch can then re-push MPLS onto a packet whose inner_network_header still points at the older, deeper offset: push a label, pop every label, recirculate (ovs_flow_key_update() re-derives key->eth.type and resets network_header, but leaves inner_*), then push again. ovs_fragment() trusts the record:
skb->network_header = skb->inner_network_header;
so skb_network_offset() goes negative. The bound check is signed:
if (skb_network_offset(skb) > MAX_L2_LEN)
a negative offset passes it, and prepare_frag() widens the value:
unsigned int hlen = skb_network_offset(skb); memcpy(&data->l2_data, skb->data, hlen);
which is a ~4GiB memcpy out of a 30-byte per-CPU buffer.
Reproduced on v7.3-rc1. RDX is the truncated length, (unsigned int)(-8):
BUG: unable to handle page fault for address: ffffe8ffffc16000 #PF: supervisor write access in kernel mode Oops: 0002 [#1] SMP KASAN NOPTI RIP: 0010:memcpy+0x8/0x20 RDX: 00000000fffffff8 RSI: ffff888105d732db RDI: ffffe8ffffc16000 prepare_frag+0x3df/0x4e0 ovs_fragment+0x589/0x7e0 do_output+0x4ce/0x5e0 do_execute_actions+0x55d2/0x7b30 ovs_execute_actions+0xea/0x450
Same root-cause shape as commit 975b5b067f52 ("ipv6: sr: restore network header before routing and forwarding"): a stale network header offset reaching a consumer that widens it. Here it originates in the MPLS push/pop path.
Clear inner_protocol once the packet is no longer MPLS, so a later push re-records the current header. net/sched/act_mpls.c is the only other skb_mpls_pop() caller and gets the same fix; sch_frag.c saves and restores inner_protocol around fragmentation in the same way OVS does.
--- net/core/skbuff.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/core/skbuff.c +7 -0
@@ -6096,6 +6096,13 @@ int skb_mpls_pop(struct sk_buff *skb, __ } skb->protocol = next_proto; +/* The last label is gone, so the inner header recorded by +* skb_mpls_push() no longer describes this packet. Drop it, or a +* later push keeps the stale offset. +*/ +if (!eth_p_mpls (next_proto)) + skb->inner_protocol =0 ; +return 0 ; }EXPORT_SYMBOL_GPL (skb_mpls_pop);
Greg Kroah-Hartman
maintainerPATCH 388/752 net: openvswitch: fix use-after-free of the flow table mask array
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Norbert Szetei <[email protected]>
commit ba4ba11ed6eb8972c69070417fc27b48deb002e8 upstream.
tbl_mask_array_realloc() retires the old mask_array before it stops being reachable:
old = ovsl_dereference(tbl->mask_array);
if (old) {
...
call_rcu(&old->rcu, mask_array_rcu_cb);
}
rcu_assign_pointer(tbl->mask_array, new);call_rcu() only waits for read-side critical sections already in flight. tbl->mask_array still points at old between the call_rcu() and the rcu_assign_pointer(), so a reader entering ovs_flow_tbl_lookup_stats() in that window picks up old in a fresh critical section that the pending grace period does not cover.
tbl_mask_array_realloc() runs in process context under ovs_mutex, so the window is preemptible and can outlast the grace period. Then mask_array_rcu_cb() frees old before the swap runs:
BUG: KASAN: slab-use-after-free in flow_lookup.constprop.0+0x2bf/0x2f0 Read of size 8 at addr ffff888020b3e018 by task poc/741 flow_lookup.constprop.0+0x2bf/0x2f0 ovs_flow_tbl_lookup_stats+0x4a3/0x5c0 ovs_dp_process_packet+0x19c/0x710 ovs_vport_receive+0x243/0x390 internal_dev_xmit+0x81/0x170 Freed by task 728: kfree+0x16a/0x4e0 rcu_core+0x853/0x1030
Publish the new array before retiring the old one. The kfree_rcu() that call_rcu() replaced ran after the swap.
--- net/openvswitch/flow_table.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/openvswitch/flow_table.c +3 -1
@@ -261,11 +261,13 @@ static int tbl_mask_array_realloc(structif (ovsl_dereference (old->masks[i])) new->masks[new->count++] = old->masks[i]; } -call_rcu (&old->rcu, mask_array_rcu_cb); }rcu_assign_pointer (tbl->mask_array, new); +if (old) +call_rcu (&old->rcu, mask_array_rcu_cb); +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 389/752 netfilter: nf_log: unregister loggers before per-net teardown
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chengfeng Ye <[email protected]>
commit 2c018cc4842c33f0c732962e2ab58635e8ae5823 upstream.
nf_log_syslog and nfnetlink_log unregister their per-network namespace operations before unregistering their global logger backends. This leaves a window where a sysctl or netlink writer can rebind the still- registered logger after the per-net pre-exit callback cleared the old selection.
The race looks like this:
CPU 0 CPU 1
---- ----
unregister_pernet_subsys()
nf_log_unset(net, logger)
net->nf.nf_loggers[pf] = NULL
lock nf_log_mutex
find logger in loggers[][]
net->nf.nf_loggers[pf] = logger
unlock nf_log_mutex nf_log_unregister(logger)
lock nf_log_mutex
loggers[pf][type] = NULL
unlock nf_log_mutex
synchronize_rcu()
module exit returns
module core frees backend memory
Later, a sysctl read or packet logging operation can dereference the stale per-net logger pointer.
Fix this by unregistering the global logger backends before tearing down per-net state. Once the global registrations are gone, later writers can no longer rebind the logger. unregister_pernet_subsys() already waits for an RCU grace period after the pre-exit callback clears the per-net selection, while nf_log_unregister() continues to cover readers of the global logger table.
Apply this ordering fix to both nf_log backends that combine per-net teardown with global logger registration.
--- net/netfilter/nf_log_syslog.c | 2 +- net/netfilter/nfnetlink_log.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nf_log_syslog.c +1 -1
@@ -1070,12 +1070,12 @@ err1: static void __exit nf_log_syslog_exit(void) { -unregister_pernet_subsys (&nf_log_syslog_net_ops);nf_log_unregister (&nf_ip_logger);nf_log_unregister (&nf_arp_logger);nf_log_unregister (&nf_ip6_logger);nf_log_unregister (&nf_netdev_logger);nf_log_unregister (&nf_bridge_logger); +unregister_pernet_subsys (&nf_log_syslog_net_ops); }module_init (nf_log_syslog_init);
net/netfilter/nfnetlink_log.c +1 -1
@@ -1194,8 +1194,8 @@ static void __exit nfnetlink_log_fini(vo {nfnetlink_subsys_unregister (&nfulnl_subsys);netlink_unregister_notifier (&nfulnl_rtnl_notifier); -unregister_pernet_subsys (&nfnl_log_net_ops);nf_log_unregister (&nfulnl_logger); +unregister_pernet_subsys (&nfnl_log_net_ops); }MODULE_DESCRIPTION ("netfilter userspace logging" );
Greg Kroah-Hartman
maintainerPATCH 390/752 netfilter: report NLM_F_DUMP_FILTERED when all is filtered out
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Maximets <[email protected]>
commit 7a099b347fef536a84068076e2d384f044e5cfc5 upstream.
NLM_F_DUMP_FILTERED is only set on data elements in the conntrack dump. But when everything is filtered out it is confusing for the user space, since the flag is not reported anymore and it looks like the table was empty, which may or may not be the case.
'answer_flags' were introduced precisely for this use case, and the conntrack dump should set the flag in there in case the filtering was applied.
This is important, for example, to be able to tell if the filters are supported or not by the kernel without modifying the kernel state.
With the proper reporting of NLM_F_DUMP_FILTERED on NLMSG_DONE, an application in user space can just try and dump with an arbitrary filter without worrying that there could be no matching entry. The reported flag will signal that the filtering was applied and therefore supported.
--- net/netfilter/nf_conntrack_netlink.c | 2 ++ 1 file changed, 2 insertions(+)
net/netfilter/nf_conntrack_netlink.c +2 -0
@@ -1037,6 +1037,8 @@ static int ctnetlink_start(struct netlin } cb->data = filter; +if (filter) + cb->answer_flags =NLM_F_DUMP_FILTERED ;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 391/752 fbdev: vfb: defer cleanup until the last reference
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
commit a0a34a40ed299c9c7cff6af163a5b883ee9d6d73 upstream.
FBIOGETCMAP takes a shallow snapshot of info->cmap and performs the usercopy after dropping info->lock. vfb_remove() frees the colormap immediately after unregistering the framebuffer, even when an open file still holds a reference to fb_info. A concurrent driver unbind can therefore free the colormap while the ioctl copies it to userspace.
KASAN reports:
BUG: KASAN: slab-use-after-free in _copy_to_user Read of size 512 by task poc/125 _copy_to_user (./include/linux/instrumented.h:129 ./include/linux/uaccess.h:201 lib/usercopy.c:24) fb_cmap_to_user (./include/linux/uaccess.h:230 drivers/video/fbdev/core/fbcmap.c:211) do_fb_ioctl (drivers/video/fbdev/core/fb_chrdev.c:114) Allocated by task 1: fb_alloc_cmap_gfp (./include/linux/slab.h:973 ./include/linux/slab.h:1290 drivers/video/fbdev/core/fbcmap.c:108) vfb_probe (drivers/video/fbdev/vfb.c:459) Freed by task 124: fb_dealloc_cmap (drivers/video/fbdev/core/fbcmap.c:151) vfb_remove (drivers/video/fbdev/vfb.c:489)
unregister_framebuffer() drops the registration reference, and fbdev calls fb_destroy after the last put_fb_info(). Move the registered framebuffer's cleanup into an fb_destroy callback so its colormap and screen buffer stay alive until all file references have been released.
--- drivers/video/fbdev/vfb.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/video/fbdev/vfb.c +8 -3
@@ -78,6 +78,13 @@ static int vfb_pan_display(struct fb_varstatic int vfb_mmap (struct fb_info *info,struct vm_area_struct *vma); +static void vfb_destroy (struct fb_info *info) +{ +vfree (info->screen_buffer); +fb_dealloc_cmap (&info->cmap); +framebuffer_release (info); +} +static const struct fb_ops vfb_ops = { .fb_read = fb_sys_read, .fb_write = fb_sys_write,
@@ -89,6 +96,7 @@ static const struct fb_ops vfb_ops = { .fb_copyarea = sys_copyarea, .fb_imageblit = sys_imageblit, .fb_mmap = vfb_mmap, + .fb_destroy = vfb_destroy, };/*
@@ -485,9 +493,6 @@ static int vfb_remove(struct platform_deif (info) {unregister_framebuffer (info); -vfree (videomemory); -fb_dealloc_cmap (&info->cmap); -framebuffer_release (info); }return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 392/752 ieee802154: 6lowpan: fix NULL dereference in lowpan_newlink
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiling Zou <[email protected]>
commit bf79662bc85e820ac3b846e2f347da29fbf6ac95 upstream.
TUNSETLINK allows a TUN device to change its link-layer type to ARPHRD_IEEE802154 without initializing ieee802154_ptr. lowpan_newlink() checks only the device type before dereferencing the pointer, so an RTM_NEWLINK request can trigger a NULL pointer dereference.
Reject devices without ieee802154_ptr along with devices of the wrong type.
--- net/ieee802154/6lowpan/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ieee802154/6lowpan/core.c +1 -1
@@ -145,7 +145,7 @@ static int lowpan_newlink(struct net *sr wdev =dev_get_by_index (dev_net (ldev),nla_get_u32 (tb[IFLA_LINK ]));if (!wdev)return -ENODEV ; -if (wdev->type !=ARPHRD_IEEE802154 ) { +if (wdev->type !=ARPHRD_IEEE802154 || !wdev->ieee802154_ptr) {dev_put (wdev);return -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 393/752 ipv4: fib: bound automatic table ID allocation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zihan Xi <[email protected]>
commit efdfb1e27a3328085b79540dfe781d537b576ea1 upstream.
fib_empty_table() probes every table ID from 1 until it finds a free one. IPv4 tables are stored in a 256-bucket hash table, so a dense set of IDs makes each probe walk a growing hash chain while RTNL is held.
Automatic table assignment ("ip rule ... table 0") is an IPv4-only legacy path. Bound the automatically allocated ID to 4096 so the RTNL hold stays bounded, without changing lookups of explicitly specified table IDs.
This changes user-visible behavior. A table-0 rule previously received the lowest free ID in 1..RT_TABLE_MAX (0xFFFFFFFF). After this patch the search stops at 4096 and the rule add fails with ENOBUFS if that range is fully occupied. Explicit table IDs above 4096 remain usable.
The automatic path is unused in practice: it is IPv4-only, not documented by ip-rule, uncovered by kernel selftests, and both NetworkManager and systemd refuse table 0.
--- net/ipv4/fib_rules.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/ipv4/fib_rules.c +3 -1
@@ -202,6 +202,8 @@ INDIRECT_CALLABLE_SCOPE int fib4_rule_mareturn 1 ; } +#define FIB_MAX_AUTO_TABLE_ID 4096 +static struct fib_table *fib_empty_table (struct net *net) {u32 id =1 ;
@@ -210,7 +212,7 @@ static struct fib_table *fib_empty_tableif (!fib_get_table (net, id))return fib_new_table (net, id); -if (id++ ==RT_TABLE_MAX ) +if (id++ ==FIB_MAX_AUTO_TABLE_ID )break ; }return NULL ;
Greg Kroah-Hartman
maintainerPATCH 394/752 ipvs: reject invalid states in connection template sync records
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <[email protected]>
commit 74cb39735b6cd0aff4b5584158f09376fd97aadf upstream.
IPVS sync receivers validate protocol states before creating or updating a connection. For connection templates, however, they only log states outside the template state range and still store the value in the connection.
A template can be returned by ordinary connection lookup. TCP and SCTP then use the invalid state as an index into their transition tables.
Reject invalid template states in both sync protocol versions before looking up or modifying a connection. The version 1 path handles both IPv4 and IPv6 records.
--- net/netfilter/ipvs/ip_vs_sync.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
net/netfilter/ipvs/ip_vs_sync.c +8 -8
@@ -1000,10 +1000,10 @@ static void ip_vs_process_message_v0(str pp->name, state);continue ; } - }else { -if (state >=IP_VS_CTPL_S_LAST ) -IP_VS_DBG (7 ,"BACKUP v0, Invalid tpl state %u\n" , - state); + }else if (state >=IP_VS_CTPL_S_LAST ) { +IP_VS_DBG (7 ,"BACKUP v0, Invalid tpl state %u\n" , + state); +continue ; } ip_vs_conn_fill_param(ipvs, AF_INET, s->protocol,
@@ -1160,10 +1160,10 @@ static inline int ip_vs_proc_sync_conn(s retc =40 ; goto out; } - }else { -if (state >=IP_VS_CTPL_S_LAST ) -IP_VS_DBG (7 ,"BACKUP, Invalid tpl state %u\n" , - state); + }else if (state >=IP_VS_CTPL_S_LAST ) { +IP_VS_DBG (7 ,"BACKUP, Invalid tpl state %u\n" , state); + retc =40 ; + goto out; }if (ip_vs_conn_fill_param_sync (ipvs, af, s, ¶m, pe_data, pe_data_len, pe_name, pe_name_len)) {
Greg Kroah-Hartman
maintainerPATCH 395/752 KVM: PPC: Book3S HV: Set irqfd->producer only on success
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: leixiang <[email protected]>
commit 1144454ea22290d7c6998a2af6239e5995476afc upstream.
Set irqfd->producer only after kvmppc_set_passthru_irq() succeeds to avoid leaving a dangling pointer on failure. The bypass manager does not register a failed producer, so the pointer is never cleared.
--- arch/powerpc/kvm/book3s_hv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kvm/book3s_hv.c +2 -2
@@ -5571,12 +5571,12 @@ static int kvmppc_irq_bypass_add_producestruct kvm_kernel_irqfd *irqfd = container_of(cons, struct kvm_kernel_irqfd, consumer); - irqfd->producer = prod; - ret =kvmppc_set_passthru_irq (irqfd->kvm, prod->irq, irqfd->gsi);if (ret)pr_info ("kvmppc_set_passthru_irq (irq %d, gsi %d) fails: %d\n" , prod->irq, irqfd->gsi, ret); +else + irqfd->producer = prod;return ret; }
Greg Kroah-Hartman
maintainerPATCH 396/752 s390/qeth: allow bridgeport queries despite OS_MISMATCH
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nagamani PV <[email protected]>
commit 74f27fc8642b7e8d139796f8c18ee46df393c2b2 upstream.
When HiperSockets interfaces on the same VCHID span different OS families, reads of the sysfs attributes bridge_role and bridge_state fail with -EPERM if bridge port ownership belongs to another OS family.
As a result, userspace tools such as 'lszdev -ii' cannot retrieve bridge_role and bridge_state, even though firmware returns valid bridge port data for QUERY_BRIDGE_PORTS requests.
The firmware reports IPA_RC_SBP_IQD_OS_MISMATCH (0x0010) to indicate that bridge port ownership belongs to a different OS family. For QUERY_BRIDGE_PORTS operations, firmware still returns valid bridge port data (role=none, state=inactive) together with a primary return code of 0x0000 (success).
Allow QUERY_BRIDGE_PORTS requests to return the bridge port data provided by the firmware despite OS_MISMATCH. To make the OS family mismatch visible to userspace, represent the firmware-reported role "none" as "none (OS family mismatch)" while preserving the reported bridge_state.
The behavior for non-QUERY bridge port commands is unchanged; SET operations continue to return -EPERM when another OS family owns the bridge port.
This restores readability of bridge_role and bridge_state.
--- drivers/s390/net/qeth_l2.h | 3 ++- drivers/s390/net/qeth_l2_main.c | 26 ++++++++++++++++++++++---- drivers/s390/net/qeth_l2_sys.c | 7 ++++++- 3 files changed, 30 insertions(+), 6 deletions(-)
drivers/s390/net/qeth_l2.h +2 -1
@@ -13,7 +13,8 @@ extern const struct attribute_group *qetint qeth_bridgeport_query_ports (struct qeth_card *card,enum qeth_sbp_roles *role, -enum qeth_sbp_states *state); +enum qeth_sbp_states *state, +bool *os_mismatch);int qeth_bridgeport_setrole (struct qeth_card *card,enum qeth_sbp_roles role);int qeth_bridgeport_an_set (struct qeth_card *card,int enable);
drivers/s390/net/qeth_l2_main.c +22 -4
@@ -1143,7 +1143,7 @@ static void qeth_l2_setup_bridgeport_attqeth_bridgeport_setrole (card, card->options.sbp.role);/* Let the callback function refresh the stored role value. */ qeth_bridgeport_query_ports (card, &card->options.sbp.role, -NULL ); +NULL ,NULL ); }if (card->options.sbp.hostnotification) {if (qeth_bridgeport_an_set (card,1 ))
@@ -1529,6 +1529,7 @@ struct _qeth_sbp_cbctl {struct {enum qeth_sbp_roles *role;enum qeth_sbp_states *state; +bool *os_mismatch; } qports; } data; };
@@ -1705,10 +1706,19 @@ static int qeth_bridgeport_query_ports_cstruct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data;struct _qeth_sbp_cbctl *cbctl = (struct _qeth_sbp_cbctl *)reply->param;struct qeth_sbp_port_data *qports; +u16 sbp_rc;int rc;QETH_CARD_TEXT (card,2 ,"brqprtcb" ); - rc =qeth_bridgeport_makerc (card, cmd); + sbp_rc = cmd->data.sbp.hdr.return_code; + +/* on OS family mismatch, query still returns valid port data; +* treat as success +*/ +if (sbp_rc ==IPA_RC_SBP_IQD_OS_MISMATCH && !cmd->hdr.return_code) + rc =0 ; +else + rc =qeth_bridgeport_makerc (card, cmd);if (rc)return rc;
@@ -1724,6 +1734,9 @@ static int qeth_bridgeport_query_ports_cif (cbctl->data.qports.state) *cbctl->data.qports.state = qports->entry[0 ].state; } +if (cbctl->data.qports.os_mismatch) + *cbctl->data.qports.os_mismatch = + (sbp_rc ==IPA_RC_SBP_IQD_OS_MISMATCH );return 0 ; }
@@ -1732,13 +1745,17 @@ static int qeth_bridgeport_query_ports_c* @card: qeth_card structure pointer. * @role: Role of the port: 0-none, 1-primary, 2-secondary. * @state: State of the port: 0-inactive, 1-standby, 2-active. +* @os_mismatch: if non-NULL, set to true when firmware reports +* OS family mismatch. * * Returns negative errno-compatible error indication or 0 on success. * -* 'role' and 'state' are not updated in case of hardware operation failure. +* 'role', 'state' and 'os_mismatch' are not updated in case of +* hardware operation failure. */ int qeth_bridgeport_query_ports (struct qeth_card *card, -enum qeth_sbp_roles *role,enum qeth_sbp_states *state) +enum qeth_sbp_roles *role,enum qeth_sbp_states *state, +bool *os_mismatch) {struct qeth_cmd_buffer *iob;struct _qeth_sbp_cbctl cbctl = {
@@ -1746,6 +1763,7 @@ int qeth_bridgeport_query_ports(struct q .qports = { .role = role, .state = state, + .os_mismatch = os_mismatch, }, }, };
drivers/s390/net/qeth_l2_sys.c +6 -1
@@ -15,6 +15,7 @@ static ssize_t qeth_bridge_port_role_sta {struct qeth_card *card =dev_get_drvdata (dev);enum qeth_sbp_states state =QETH_SBP_STATE_INACTIVE ; +bool os_mismatch = false;int rc =0 ;char *word;
@@ -25,7 +26,7 @@ static ssize_t qeth_bridge_port_role_staif (qeth_card_hw_is_reachable (card) && card->options.sbp.supported_funcs) rc =qeth_bridgeport_query_ports (card, - &card->options.sbp.role, &state); + &card->options.sbp.role, &state, &os_mismatch);if (!rc) {if (show_state)switch (state) {
@@ -52,6 +53,10 @@ static ssize_t qeth_bridge_port_role_staif (rc)QETH_CARD_TEXT_ (card,2 ,"SBP%02x:%02x" , card->options.sbp.role, state); +else if (!show_state && + card->options.sbp.role ==QETH_SBP_ROLE_NONE && + os_mismatch) + rc =sysfs_emit (buf,"%s (OS family mismatch)\n" , word);else rc =sprintf (buf,"%s\n" , word); }
Greg Kroah-Hartman
maintainerPATCH 397/752 s390/crypto: Fix missing scrub of temp buffers with AES ctr and gcm algorithm
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harald Freudenberger <[email protected]>
commit 8b7c3b6914f19caf648d05726a86af6326d3c2c6 upstream.
In function ctr_aes_crypt() there is a buffer used to process remaining bytes < AES_BLOCK_SIZE. This buffer was not scrubbed and thus could lead to expose of unwanted data. When the buffer is used explicitly scrub it at the end of the code block to avoid exposure of maybe sensitive data.
In a similar way the function gcm_aes_crypt() hat an error path where the CPACF param block was not scrubbed. Instead of return early now these error paths go to end of function where explicit scrubbing is done. Similar with the buffers which are part of the gcm_sg_walk structs from the variables gw_in and gw_out.
--- arch/s390/crypto/aes_s390.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
arch/s390/crypto/aes_s390.c +12 -4
@@ -608,6 +608,7 @@ static int ctr_aes_crypt(struct skciphermemcpy (walk.dst.virt.addr, buf, nbytes);crypto_inc (walk.iv,AES_BLOCK_SIZE ); ret =skcipher_walk_done (&walk,0 ); +memzero_explicit (buf,sizeof (buf)); }return ret;
@@ -909,10 +910,14 @@ static int gcm_aes_crypt(struct aead_req gw_in.ptr, aad_bytes); n = aad_bytes + pc_bytes; -if (gcm_in_walk_done (&gw_in, n) != n) -return -ENOMEM ; -if (gcm_out_walk_done (&gw_out, n) != n) -return -ENOMEM ; +if (gcm_in_walk_done (&gw_in, n) != n) { + ret = -ENOMEM ; + goto out; + } +if (gcm_out_walk_done (&gw_out, n) != n) { + ret = -ENOMEM ; + goto out; + } aadlen -= aad_bytes; pclen -= pc_bytes; }while (aadlen + pclen >0 );
@@ -924,7 +929,10 @@ static int gcm_aes_crypt(struct aead_req }else scatterwalk_map_and_copy (param.t, req->dst, len, taglen,1 ); +out:memzero_explicit (¶m,sizeof (param)); +memzero_explicit (gw_in.buf,sizeof (gw_in.buf)); +memzero_explicit (gw_out.buf,sizeof (gw_out.buf));return ret; }