6.12.119-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 1412/1756 ALSA: pcmtest: Pin the module while pattern files are open
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 069003afab42b5a9394faa6985a3d76bd4700e72 ]
The fill_pattern_fops table must remain alive until the final release of each pattern debugfs file. It has no .owner, so the fops_get() call in full_proxy_open_regular() does not take a PCMTest module reference.
With snd-pcmtest loaded as a module, a user with permission to open a fill_patternN file and unload the module can retain the descriptor across normal unload, provided no PCM file or other module reference prevents it. The following ordering is possible:
Pattern file user Module unload
----------------- -------------
open(fill_patternN)
full_proxy_open_regular()
fops_get(fill_pattern_fops)
owner == NULL: no module pin
keep the descriptor open
mod_exit()
clear_debug_files()
debugfs_remove_recursive()
drain active operations
return from mod_exit()
free_module()
free the module image
close(fd)
full_proxy_release()
read real_fops->release -> UAF
fops_put(real_fops)
read real_fops->owner
access freed module memoryEven though the table has no release callback, reading those fields is a use-after-free and can fault. The retained dentry keeps the proxy's bookkeeping alive, but does not retain the module storage.
Set .owner to THIS_MODULE so the existing fops_get()/fops_put() pair pins PCMTest until final release has finished accessing the table. Normal module unload is then blocked while any pattern file is open.
--- sound/drivers/pcmtest.c | 1 + 1 file changed, 1 insertion(+)
sound/drivers/pcmtest.c +1 -0
@@ -683,6 +683,7 @@ static ssize_t pattern_read(struct file *file, char __user *u_buff, size_t len, }static const struct file_operations fill_pattern_fops = { + .owner =THIS_MODULE , .read = pattern_read, .write = pattern_write, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1413/1756 ALSA: pcm: Remove channel-map controls before freeing substreams
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit d5dd05c1f72a95d8ab06828d7272a185ad2b9185 ]
A late HDA codec bind on an already registered card builds new PCMs before registering them. add_std_chmaps() publishes generic channel-map controls during this BUILD stage. If an earlier chmap succeeds and a later allocation fails, probe cleanup frees the BUILD PCM while the card's control device remains accessible.
These generic controls are added directly by snd_pcm_add_chmap_ctls(); snd_hda_ctls_clear() only removes codec-tracked mixer controls. BUILD devices also skip dev_disconnect. snd_pcm_free_stream() then frees the substreams before free_chmap() withdraws their generic control:
Late HDA codec bind / rollback Control GET on the live card
------------------------------ ----------------------------
hda_codec_driver_probe()
snd_hda_codec_build_pcms()
PCM is BUILD
snd_hda_codec_build_controls()
add_std_chmaps()
publish an earlier chmap
later allocation: -ENOMEM
snd_hda_codec_cleanup_for_unbind()
snd_hda_ctls_clear()
generic chmap remains
codec_release_pcms()
snd_device_free()
BUILD: skip dev_disconnect snd_pcm_free_stream()
kfree(substream)
snd_ctl_elem_read()
down_read(controls_rwsem) pcm_chmap_ctl_get()
walk freed substream
free_chmap()
snd_ctl_remove()
wait for GET
up_read(controls_rwsem)
The control read lock cannot protect a substream already freed before control removal starts. The failure above occurs before snd_card_register(), so the PCM has not transitioned out of BUILD.
Move free_chmap() before the substream free loop. Its snd_ctl_remove() withdraws the control and drains readers under controls_rwsem before any substream is released. Normal registered-device disconnect already removes the control, so the later call remains harmless on that path.
--- sound/core/pcm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/core/pcm.c +3 -1
@@ -823,6 +823,9 @@ static void snd_pcm_free_stream(struct snd_pcm_str * pstr)/* free all proc files under the stream */ snd_pcm_stream_proc_done (pstr); +/* Drain channel-map callbacks before freeing the substreams. */ +free_chmap (pstr); + substream = pstr->substream;while (substream) { substream_next = substream->next;
@@ -837,7 +840,6 @@ static void snd_pcm_free_stream(struct snd_pcm_str * pstr) kfree(setup); }#endif -free_chmap (pstr);if (pstr->substream_count)put_device (pstr->dev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1414/1756 ALSA: jack: Pin the module while debugfs files are open
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 8b479b265301e97bfbec0ef25de1c1f7eb4d2f74 ]
With CONFIG_SND=m and CONFIG_SND_JACK_INJECTION_DEBUG enabled, an in-tree HDA jack creates these debugfs files through snd_jack_new() and snd_jack_add_debugfs(). Their file_operations live in snd, but none sets .owner. full_proxy_open_regular() therefore takes no snd module reference when it calls fops_get(real_fops).
A debugfs descriptor can outlive removal of its HDA card. Once the card and dependent modules, including the OSS emulation modules, have been removed, snd can be unloaded while that descriptor is still open:
Descriptor holder Card/module teardown
----------------- --------------------
open jack debugfs file
full_proxy_open_regular()
fops_get(real_fops)
owner == NULL: no snd pin
keep descriptor open
remove HDA card
snd_card_disconnect()
snd_jack_dev_disconnect()
remove debugfs nodes
snd_jack_dev_free()
unload dependent modules
rmmod snd
alsa_sound_exit()
free_module(): unmap snd
close descriptor
full_proxy_release()
read real_fops->release
fops_put(real_fops)
read real_fops->ownerdebugfs_remove() drains active operations, but does not wait for idle open descriptors. Release deliberately bypasses removal protection and reads the real table even when no release callback is installed. The last close can therefore access unloaded snd storage.
Set .owner to THIS_MODULE in all six tables. The existing proxy fops_get()/fops_put() pair then keeps snd loaded through the final table access on close.
--- sound/core/jack.c | 6 ++++++ 1 file changed, 6 insertions(+)
sound/core/jack.c +6 -0
@@ -307,6 +307,7 @@ static ssize_t jack_type_read(struct file *file, }static const struct file_operations jack_type_fops = { + .owner =THIS_MODULE , .open = simple_open, .read = jack_type_read, .llseek = default_llseek,
@@ -314,6 +315,7 @@ static const struct file_operations jack_type_fops = {#endif static const struct file_operations sw_inject_enable_fops = { + .owner =THIS_MODULE , .open = simple_open, .read = sw_inject_enable_read, .write = sw_inject_enable_write,
@@ -321,24 +323,28 @@ static const struct file_operations sw_inject_enable_fops = { };static const struct file_operations jackin_inject_fops = { + .owner =THIS_MODULE , .open = simple_open, .write = jackin_inject_write, .llseek = default_llseek, };static const struct file_operations jack_kctl_id_fops = { + .owner =THIS_MODULE , .open = simple_open, .read = jack_kctl_id_read, .llseek = default_llseek, };static const struct file_operations jack_kctl_mask_bits_fops = { + .owner =THIS_MODULE , .open = simple_open, .read = jack_kctl_mask_bits_read, .llseek = default_llseek, };static const struct file_operations jack_kctl_status_fops = { + .owner =THIS_MODULE , .open = simple_open, .read = jack_kctl_status_read, .llseek = default_llseek,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1415/1756 ALSA: pcm: Protect channel-map reads against runtime detach
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit bb4834d5242c4829c0d8467ee68eb25a9bafc38d ]
Channel-map controls remain accessible between PCM opens. In-tree HDA code publishes the generic controls through add_std_chmaps(), so a SNDRV_CTL_IOCTL_ELEM_READ can overlap the final close of the same PCM substream.
pcm_chmap_ctl_get() checks substream->runtime and later reads its channel count. Final close clears and frees that runtime under pcm->open_mutex, while the control callback holds only controls_rwsem:
Control GET Final PCM close
----------- ---------------
snd_ctl_elem_read()
down_read(controls_rwsem)
pcm_chmap_ctl_get()
check substream->runtime
lock(pcm->open_mutex)
snd_pcm_release_substream()
snd_pcm_detach_substream()
substream->runtime = NULL
kfree(runtime)
unlock(pcm->open_mutex)
substream->runtime->channels
NULL or freed-pointer access
up_read(controls_rwsem)Reloading the cleared field can fault through NULL, while retaining the old pointer can access freed storage. controls_rwsem keeps the control alive, but does not serialize the matching PCM close.
Copy the channel count under open_mutex and use that scalar for the map lookup. Use trylock with -EBUSY because snd_pcm_dev_disconnect() takes open_mutex before removing controls under controls_rwsem; blocking in the reverse order from GET could deadlock.
--- sound/core/pcm_lib.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
sound/core/pcm_lib.c +13 -3
@@ -2496,6 +2496,7 @@ static int pcm_chmap_ctl_get(struct snd_kcontrol *kcontrol,unsigned int idx =snd_ctl_get_ioffidx (kcontrol, &ucontrol->id);struct snd_pcm_substream *substream;const struct snd_pcm_chmap_elem *map; +unsigned int channels;if (!info->chmap)return -EINVAL ;
@@ -2504,11 +2505,20 @@ static int pcm_chmap_ctl_get(struct snd_kcontrol *kcontrol,return -ENODEV ;memset (ucontrol->value.integer.value,0 ,sizeof (long ) * info->max_channels); -if (!substream->runtime) -return 0 ;/* no channels set */ +/* +* PCM disconnect takes open_mutex before removing controls. +* Use trylock to avoid a deadlock with controls_rwsem. +*/ +scoped_cond_guard (mutex_try, return -EBUSY , + &info->pcm->open_mutex) { +if (!substream->runtime) +return 0 ;/* no channels set */ + channels = substream->runtime->channels; + }for (map = info->chmap; map->channels; map++) {int i; -if (map->channels == substream->runtime->channels && + +if (map->channels == channels &&valid_chmap_channels (info, map->channels)) {for (i =0 ; i < map->channels; i++) ucontrol->value.integer.value[i] = map->map[i];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1416/1756 nfsv4/pnfs: use the MDS authflavor for data server connections
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tigran Mkrtchyan <[email protected]>
[ Upstream commit 4b27670ea25b955b710021151471cb252240b1e0 ]
When a pNFS client connects to an NFSv4.1 data server, the EXCHANGE_ID is always attempted with RPCSEC_GSS krb5i first, even if the auth flavor with the MDS is AUTH_SYS. On a host that runs rpc.gssd but has no usable machine credential, every first contact with a data server therefore upcalls to rpc.gssd before falling back to AUTH_SYS.
As nfs4_discover_server_trunking is serialized by nfs_clid_init_mutex such an extra upcall creates a backlog of DS connections when many files accessed in parallel.
Pass the authflavor of the MDS lease to nfs4_alloc_client() and skip the krb5i attempt if the MDS already ended up with AUTH_SYS. Nothing changes for the MDS itself, or for data servers of an MDS whose lease was established with krb5i.
--- fs/nfs/internal.h | 1 + fs/nfs/nfs4client.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-)
fs/nfs/internal.h +1 -0
@@ -86,6 +86,7 @@ struct nfs_client_initdata {struct xprtsec_parms xprtsec;unsigned long connect_timeout;unsigned long reconnect_timeout; +rpc_authflavor_t authflavor;/* Auth flavor to use for DS connection */ };/*
fs/nfs/nfs4client.c +6 -1
@@ -238,8 +238,12 @@ struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init)/* * Set up the connection to the server before we add add to the * global list. +* +* Prefer krb5i unless the caller already knows AUTH_UNIX is required. */ - err =nfs_create_rpc_client (clp, cl_init,RPC_AUTH_GSS_KRB5I ); + err = -EINVAL ; +if (cl_init->authflavor !=RPC_AUTH_UNIX ) + err =nfs_create_rpc_client (clp, cl_init,RPC_AUTH_GSS_KRB5I );if (err == -EINVAL ) err =nfs_create_rpc_client (clp, cl_init,RPC_AUTH_UNIX );if (err <0 )
@@ -999,6 +1003,7 @@ struct nfs_client *nfs4_set_ds_client(struct nfs_server *mds_srv, .cert_serial = TLS_NO_CERT, .privkey_serial = TLS_NO_PRIVKEY, }, + .authflavor = mds_clp->cl_rpcclient->cl_auth->au_flavor, };char buf[INET6_ADDRSTRLEN +1 ];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1417/1756 pNFS/flexfiles: make pg_init retry loops killable
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tigran Mkrtchyan <[email protected]>
[ Upstream commit fde27289503beabe7e0856dac164a5ced4be0342 ]
When a task is killed while the pNFS client connects to a data server, nfs4_pnfs_ds_connect() fails with -ERESTARTSYS. If the layout has FF_FLAGS_NO_IO_THRU_MDS set, ff_layout_pg_init_read() cannot fall back to the MDS and retries after an uninterruptible ssleep. As the fatal signal stays pending, every new connect attempt is aborted the same way and the task loops forever without returning to user space:
# grep -E 'SigPnd|ShdPnd' /proc/156021/status SigPnd: 0000000000000100 ShdPnd: 0000000000000100
# cat /proc/156021/stack msleep+0x2e/0x50 ff_layout_pg_init_read+0x267/0x310 [nfs_layout_flexfiles] __nfs_pageio_add_request+0x1c1/0x480 [nfs] nfs_pageio_add_request+0x21d/0x2c0 [nfs] nfs_read_add_folio+0x143/0x200 [nfs] nfs_readahead+0x204/0x290 [nfs] read_pages+0x62/0x230 page_cache_ra_unbounded+0x136/0x180 filemap_get_pages+0xf2/0x350 filemap_read+0xd5/0x320 nfs_file_read+0x6d/0xc0 [nfs] vfs_read+0x24f/0x3a0 __x64_sys_pread64+0x90/0xc0 do_syscall_64+0x5f/0xe0
Previous attempt propagates the error from nfs4_ff_layout_prepare_ds(), but only ff_layout_{read,write}_pagelist() look at it. The pg_init functions test IS_ERR() and retry on any error.
Check for a fatal signal or an exiting task before sleeping in ff_layout_pg_init_read() and ff_layout_pg_init_write() and fail the I/O instead of retrying.
--- fs/nfs/flexfilelayout/flexfilelayout.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)
fs/nfs/flexfilelayout/flexfilelayout.c +20 -3
@@ -854,6 +854,20 @@ ff_layout_get_ds_for_read(struct nfs_pageio_descriptor *pgio,return ff_layout_choose_best_ds_for_read (lseg,0 , best_idx); } +/* +* Wait before retrying pg_init. Returns false, with pgio->pg_error set, +* if the task was killed or is exiting and must not retry. +*/ +static bool ff_layout_pg_retry_wait (struct nfs_pageio_descriptor *pgio) +{ +if (fatal_signal_pending (current) ||nfs_current_task_exiting ()) { + pgio->pg_error = -ERESTARTSYS ; +return false; + } +ssleep (1 ); +return true; +} + static void ff_layout_pg_get_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *req,
@@ -904,7 +918,8 @@ ff_layout_pg_init_read(struct nfs_pageio_descriptor *pgio, goto out_mds;pnfs_generic_pg_cleanup (pgio);/* Sleep for 1 second before retrying */ -ssleep (1 ); +if (!ff_layout_pg_retry_wait (pgio)) +return ; goto retry; }
@@ -943,7 +958,8 @@ ff_layout_pg_init_read(struct nfs_pageio_descriptor *pgio, } pgio->pg_error =0 ;/* Sleep for 1 second before retrying */ -ssleep (1 ); +if (!ff_layout_pg_retry_wait (pgio)) +return ; goto retry; out_mds: trace_pnfs_mds_fallback_pg_init_read(pgio->pg_inode,
@@ -992,7 +1008,8 @@ ff_layout_pg_init_write(struct nfs_pageio_descriptor *pgio, goto out_mds;pnfs_generic_pg_cleanup (pgio);/* Sleep for 1 second before retrying */ -ssleep (1 ); +if (!ff_layout_pg_retry_wait (pgio)) +return ; goto retry; } pgm = &pgio->pg_mirrors[i];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1418/1756 ALSA: aloop: Keep the timer source alive until card release
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 762ef425cf0ac9c4b9e9e61e0da0950e16e6fbea ]
The timer_source string must remain valid while PCM opens can select and parse it. loopback_set_timer_source() allocates the string with parent-device devres, which can release it while the card is still registered.
A successful nonempty proc replacement after snd_card_register() adds the string allocation after trigger_card_free. Unbinding the platform device while snd_aloop remains loaded releases devres in reverse order. An open for an unused cable can run after the string is freed and before the card-free action disconnects the card:
Device unbind PCM open
devres_release_all()
free replacement string
snd_pcm_open()
snd_card_file_add()
loopback_open()
loopback_snd_timer_open()
loopback_parse_timer_id()
trigger_card_free()
snd_card_free()
snd_card_disconnect()The parser can then read freed memory. KASAN has reported a one-byte use-after-free read in strchr() from loopback_snd_timer_open(). The cable_lock mutex serializes explicit replacements with opens, but implicit devres release does not take it. The card and module references held by PCM open do not retain this separate devres allocation.
Use kstrdup() and release the current string from card->private_free. PCM admission already retains the card until each file is removed, and card disconnect drains proc callbacks before final card release. This keeps the string alive across admitted PCM opens and preserves the cable_lock serialization of replacements. Install the callback before the initial allocation so probe failures also release the string.
--- sound/drivers/aloop.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
sound/drivers/aloop.c +11 -6
@@ -1784,13 +1784,10 @@ static int loopback_cable_proc_new(struct loopback *loopback, int cidx)static void loopback_set_timer_source (struct loopback *loopback,const char *value) { -if (loopback->timer_source) { -devm_kfree (loopback->card->dev, loopback->timer_source); - loopback->timer_source =NULL ; - } +kfree (loopback->timer_source); + loopback->timer_source =NULL ;if (value && *value) - loopback->timer_source =devm_kstrdup (loopback->card->dev, - value,GFP_KERNEL ); + loopback->timer_source =kstrdup (value,GFP_KERNEL ); } static void print_timer_source_info(struct snd_info_entry *entry,
@@ -1821,6 +1818,13 @@ static int loopback_timer_source_proc_new(struct loopback *loopback) change_timer_source_info); } +static void loopback_private_free (struct snd_card *card) +{ +struct loopback *loopback = card->private_data; + +kfree (loopback->timer_source); +} +static int loopback_probe (struct platform_device *devptr) {struct snd_card *card;
@@ -1846,6 +1850,7 @@ static int loopback_probe(struct platform_device *devptr) pcm_substreams[dev] =MAX_PCM_SUBSTREAMS ; loopback->card = card; + card->private_free = loopback_private_free;loopback_set_timer_source (loopback, timer_source[dev]);mutex_init (&loopback->cable_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1419/1756 block, bfq: initialize active lists for all actuators
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit 00c2c34ead7e84d6594e20fa37a3c503823f5756 ]
Commit 2d31c684a053 ("block, bfq: inject I/O to underutilized actuators") extended bfqd->active_list from a single list_head to an array indexed by actuator, but bfq_init_queue() still only initialized the first two entries:
INIT_LIST_HEAD(&bfqd->active_list[0]);
INIT_LIST_HEAD(&bfqd->active_list[1]);For devices with more than two independent access ranges, the remaining list heads stay zeroed by kzalloc() and are never set up as empty lists. When BFQ later adds a bfq_queue to one of those lists, list_add() writes through head->next, which is NULL, corrupting the list or crashing the kernel.
Initialize every actuator's active list using bfqd->num_actuators, which is already set up earlier in bfq_init_queue().
--- block/bfq-iosched.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
block/bfq-iosched.c +2 -2
@@ -7321,8 +7321,8 @@ static int bfq_init_queue(struct request_queue *q, struct elevator_type *e) bfqd->num_groups_with_pending_reqs =0 ;#endif -INIT_LIST_HEAD (&bfqd->active_list[0 ]); -INIT_LIST_HEAD (&bfqd->active_list[1 ]); +for (i =0 ; i < bfqd->num_actuators; i++) +INIT_LIST_HEAD (&bfqd->active_list[i]);INIT_LIST_HEAD (&bfqd->idle_list);INIT_HLIST_HEAD (&bfqd->burst_list);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1420/1756 cgroup/cpuset: use mems_allowed_seq when checking a policy nodemask
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gregory Price (Meta) <[email protected]>
[ Upstream commit b0cec62d2867ab3ed27604d5c177b8960c43b17a ]
A cpuset update changes the task's mems_allowed and rebinds its mempolicy in separate steps under mems_allowed_seq, but the check reads both without it. This can cause a spurious numa placement miss under some cpuset/mempolicy combinations.
A reader that loads one mask before the update and the other after it can see a spurious empty intersection and drop the nodemask.
For example, a task with cpuset.mems={0} and MPOL_BIND={0}. If the cpuset moves to mems={1,2}, the policy is rebound to {1}.
The allocator can race and compare the old mems_allowed {0} against the new policy {1} - which will result in a dropped nodemask and a misplaced allocation on node 2.
Simply retry the intersection until mems_allowed_seq is stable.
This covers the task policy, which is rebound under mems_allowed_seq. VMA policies are rebound afterwards by mpol_rebind_mm(), outside mems_allowed_seq, and are not covered by this change.
--- kernel/cgroup/cpuset.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
kernel/cgroup/cpuset.c +12 -1
@@ -4185,10 +4185,21 @@ nodemask_t cpuset_mems_allowed(struct task_struct *tsk)* @nodemask: the nodemask to be checked * * Are any of the nodes in the nodemask allowed in current->mems_allowed? +* +* A cpuset update rebinds the task's mempolicy and changes mems_allowed in +* separate steps, so retry if an update raced with the check. */ int cpuset_nodemask_valid_mems_allowed (nodemask_t *nodemask) { -return nodes_intersects (*nodemask, current->mems_allowed); +unsigned int seq; +int ret; + +do { + seq =read_mems_allowed_begin (); + ret =nodes_intersects (*nodemask, current->mems_allowed); + }while (read_mems_allowed_retry (seq)); + +return ret; }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1421/1756 ipe: fix invalid sgid value in audit event documentation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manuel Ebner <[email protected]>
[ Upstream commit edf43c031902787117822b23324cf08ccc023bf6 ]
The audit event example in the IPE documentation contains 'sgid=)', which is not a valid Set Group ID value. Fix it to use 'sgid=0'.
--- Documentation/admin-guide/LSM/ipe.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/admin-guide/LSM/ipe.rst +2 -2
@@ -458,11 +458,11 @@ Field descriptions: Event Examples:: type=1404 audit(1653425689.008:55): enforcing=0 old_enforcing=1 auid=4294967295 ses=4294967295 enabled=1 old-enabled=1 lsm=ipe res=1 - type=1300 audit(1653425689.008:55): arch=c000003e syscall=1 success=yes exit=2 a0=1 a1=55c1065e5c60 a2=2 a3=0 items=0 ppid=405 pid=441 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=) + type=1300 audit(1653425689.008:55): arch=c000003e syscall=1 success=yes exit=2 a0=1 a1=55c1065e5c60 a2=2 a3=0 items=0 ppid=405 pid=441 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 type=1327 audit(1653425689.008:55): proctitle="-bash" type=1404 audit(1653425689.008:55): enforcing=1 old_enforcing=0 auid=4294967295 ses=4294967295 enabled=1 old-enabled=1 lsm=ipe res=1 - type=1300 audit(1653425689.008:55): arch=c000003e syscall=1 success=yes exit=2 a0=1 a1=55c1065e5c60 a2=2 a3=0 items=0 ppid=405 pid=441 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=) + type=1300 audit(1653425689.008:55): arch=c000003e syscall=1 success=yes exit=2 a0=1 a1=55c1065e5c60 a2=2 a3=0 items=0 ppid=405 pid=441 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 type=1327 audit(1653425689.008:55): proctitle="-bash" This record will always be emitted in conjunction with a ``AUDITSYSCALL`` record for the ``write`` syscall.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1422/1756 ipe: fix enforcement audit
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
[ Upstream commit 0e5f66bf052223aa5c8caeb8554a7577b54c302f ]
ipe_audit_enforce() starts an audit buffer but writes the state change with audit_log(), which logs its own record. Ending the unused buffer then emits an extra empty AUDIT_MAC_STATUS record.
Remove the unused buffer and log the state change with audit_log() alone.
--- security/ipe/audit.c | 8 -------- 1 file changed, 8 deletions(-)
security/ipe/audit.c +0 -8
@@ -275,18 +275,10 @@ void ipe_audit_policy_load(const struct ipe_policy *const p)*/ void ipe_audit_enforce (bool new_enforce,bool old_enforce) { -struct audit_buffer *ab; - - ab =audit_log_start (audit_context (),GFP_KERNEL ,AUDIT_MAC_STATUS ); -if (!ab) -return ; -audit_log (audit_context (),GFP_KERNEL ,AUDIT_MAC_STATUS ,"enforcing=%d old_enforcing=%d auid=%u ses=%u" " enabled=1 old-enabled=1 lsm=ipe res=1" , new_enforce, old_enforce,from_kuid (&init_user_ns,audit_get_loginuid (current)),audit_get_sessionid (current)); - -audit_log_end (ab); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1423/1756 net/sched: act_api: reject duplicate actions in a batch
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit f67b3ed1308d7a282e2d6202d61af052ab0da39e ]
tca_action_gd() builds actions[] with one tcf_action_get_1() per nested TCA_ACT_TAB entry. Each successful lookup takes its own reference to the resolved action, so repeated TCA_ACT_INDEX entries in one request yield the same pointer in multiple slots.
For RTM_DELACTION, tcf_action_delete() then consumes two references per
slot: one in tcf_action_put() and one in tcf_idr_delete_index(). A duplicate therefore drives the refcount to zero mid-walk -- the delete frees the action and removes its IDR slot -- and the next slot calls tcf_action_put() on the freed action:
refcount_t: underflow; use-after-free.
WARNING: lib/refcount.c:87 at refcount_dec_not_one refcount_dec_and_mutex_lock __tcf_action_put tca_action_gd
Three duplicate entries are enough. Reject a repeated action while a delete batch is built, dropping the reference the extra lookup took, and return -EINVAL. RTM_GETACTION balances its own references and keeps accepting duplicate entries.
Conditions to recreate the bug:
tc actions add action gact index 100
tc actions delete action gact index 100 action gact index 100 \
action gact index 100
--- net/sched/act_api.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
net/sched/act_api.c +20 -1
@@ -2001,7 +2001,7 @@ static int tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n, u32 portid, int event, struct netlink_ext_ack *extack) { - int i, ret; + int i, j, ret;struct nlattr *tb[TCA_ACT_MAX_PRIO +1 ];struct tc_action *act;size_t attr_size =0 ;
@@ -2026,6 +2026,25 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n, ret =PTR_ERR (act); goto err; } + +/* A delete consumes two references per slot (tcf_action_put() +* and tcf_idr_delete_index()) but each entry takes one, so a +* repeated action would hit zero mid-walk. GET balances its +* own references and keeps accepting duplicates. +*/ +if (event ==RTM_DELACTION ) { +for (j =0 ; j < i -1 ; j++) { +if (actions[j] != act) +continue ; + +tcf_action_put (act); +NL_SET_ERR_MSG (extack, +"Duplicate TC action in a delete batch" ); + ret = -EINVAL ; + goto err; + } + } + attr_size +=tcf_action_fill_size (act); actions[i -1 ] = act; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1424/1756 RDMA/mlx5: Fix CQ resize destination index mask
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit 0fe31052d948a3a993bb2f58cd5886f7ec279ea7 ]
In copy_resize_cqes, the destination CQE index is computed as (i + 1) & cq->resize_buf->nent, but resize_buf->nent is produced by roundup_pow_of_two(), so it is a power of two with exactly one bit set. Masking with a single-bit value can only yield 0 or nent itself. The buffer has nent entries, so valid indices are 0 .. nent - 1 and nent is one past the last slot; whenever the masked result is nent the following memcpy writes one entry out of bounds.
Use (nent - 1) as the wrap mask instead. For a power-of-two nent, (i + 1) & (nent - 1) is the correct modulo-nent reduction, keeping the index within [0, nent - 1]. This matches get_sw_cqe(), which addresses the CQ buffer via n & cq->ibcq.cqe, where cq->ibcq.cqe == entries - 1 is exactly the nent - 1 wrap mask.
--- drivers/infiniband/hw/mlx5/cq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/cq.c +1 -1
@@ -1262,7 +1262,7 @@ static int copy_resize_cqes(struct mlx5_ib_cq *cq)while (get_cqe_opcode (scqe64) !=MLX5_CQE_RESIZE_CQ ) { dcqe =mlx5_frag_buf_get_wqe (&cq->resize_buf->fbc, - (i +1 ) & cq->resize_buf->nent); + (i +1 ) & (cq->resize_buf->nent -1 )); dcqe64 = dsize ==64 ? dcqe : dcqe +64 ; sw_own =sw_ownership_bit (i +1 , cq->resize_buf->nent);memcpy (dcqe, scqe, dsize);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1425/1756 net: stmmac: xgmac: do not treat TBU as a TX event
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengfei Zhang <[email protected]>
[ Upstream commit 305deb54c6c287e586bed92da2375ae1220e8dde ]
Commit 8d07a7930434 ("net: stmmac: xgmac: Do not enable TBU interrupt") removed TBUE from the default DMA interrupt mask, but did not remove the TBU check from dwxgmac2_dma_interrupt().
TBU is set whenever a TX channel runs out of descriptors. Since TBUE is not enabled and only enabled bits are cleared, the TBU status bit is never cleared. As a result, TBU stays set on every idle TX channel, regardless of whether there is any TX traffic.
With a shared interrupt, stmmac_dma_interrupt() checks all channels, so every interrupt from any source schedules TX NAPI on every idle TX channel.
Only use TI to trigger TX processing.
--- drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +1 -1
@@ -366,7 +366,7 @@ static int dwxgmac2_dma_interrupt(struct stmmac_priv *priv,u64_stats_update_end (&stats->syncp); ret |= handle_rx; } -if (likely (intr_status & (XGMAC_TI |XGMAC_TBU ))) { +if (likely (intr_status &XGMAC_TI )) {u64_stats_update_begin (&stats->syncp);u64_stats_inc (&stats->tx_normal_irq_n[chan]);u64_stats_update_end (&stats->syncp);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1426/1756 mptcp: options: mpc: avoid printing uninit data
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
[ Upstream commit a234ee8eb9a20d1a272f0d2ceabdb35165071778 ]
When parsing the MP_CAPABLE suboption, this pr_debug() might read and print uninitialised values.
That's mostly harmless, but that's also confusing. Fixing that also avoids some tools to complain about accessing uninit data.
So read these fields only if they have been set.
Note: this was initially reported by Clashiko as an existing issue. The code has been analysed by a human and confirmed. This is a non-urgent fix.
--- net/mptcp/options.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/mptcp/options.c +5 -2
@@ -126,8 +126,11 @@ static void mptcp_parse_option(const struct sk_buff *skb, ptr +=2 ; }pr_debug ("MP_CAPABLE version=%x, flags=%x, optlen=%d sndr=%llu, rcvr=%llu len=%d csum=%u\n" , - version, flags, opsize, mp_opt->sndr_key, - mp_opt->rcvr_key, mp_opt->data_len, mp_opt->csum); + version, flags, opsize, + opsize >=TCPOLEN_MPTCP_MPC_SYNACK ? mp_opt->sndr_key :0 , + opsize >=TCPOLEN_MPTCP_MPC_ACK ? mp_opt->rcvr_key :0 , + opsize >=TCPOLEN_MPTCP_MPC_ACK_DATA ? mp_opt->data_len :0 , + opsize ==TCPOLEN_MPTCP_MPC_ACK_DATA_CSUM ? mp_opt->csum :0 );break ;case MPTCPOPT_MP_JOIN :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1427/1756 mptcp: options: dss: avoid printing uninit csum
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
[ Upstream commit 00e2690c9dad0e09cd2a4435b98de6d8efd5fbc2 ]
When parsing the DSS suboption, this pr_debug() might read and print uninitialised checksum value.
That's mostly harmless, but that's also confusing. Fixing that also avoids some tools to complain about accessing uninit data.
So read this csum field only if it has been set.
Note: this was initially reported by Clashiko as an existing issue. The code has been analysed by a human and confirmed. This is a non-urgent fix.
--- net/mptcp/options.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mptcp/options.c +1 -1
@@ -259,7 +259,7 @@ static void mptcp_parse_option(const struct sk_buff *skb,pr_debug ("data_seq=%llu subflow_seq=%u data_len=%u csum=%d:%u\n" , mp_opt->data_seq, mp_opt->subflow_seq, mp_opt->data_len, !!(mp_opt->suboptions &OPTION_MPTCP_CSUMREQD ), - mp_opt->csum); + (mp_opt->suboptions &OPTION_MPTCP_CSUMREQD ) ? mp_opt->csum :0 ); }break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1428/1756 net: phy: qca83xx: read resolved QCA8337 link status
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yongzhao Chen <[email protected]>
[ Upstream commit 42a91cbfc7a3ab99d05cb2ed0de5a24b9652cfed ]
After a QCA8337 SmartSpeed downshift, genphy_read_status() can report 1000 Mbit/s from the advertised modes when the PHY is running at 100 Mbit/s. On a Redmi AX5400 running downstream OpenWrt Linux 6.18.52, this caused qca8k to program the user-port MAC for 1000 Mbit/s and traffic failed. An earlier prototype that read the resolved speed from the PHY restored traffic.
Wrap genphy_read_status() and use at803x_read_specific_status() to replace its speed and duplex result when an autonegotiated link comes up. Resolve pause for the resulting duplex. Until the PHY reports a resolved speed and duplex, report the link as down so that the next poll reads them again, as marvell_read_status_page_an() does. In that case also clear the duplex, master/slave state and link partner modes that genphy_read_status() read for an up link. QCA8337's register layout matches the helper (data sheet 80-Y0619-3 Rev. D, pages 327-328).
Keep the generic master/slave read order and the early return for a steady autonegotiated link. This avoids additional reads of the clear-on-read idle error count in MII_STAT1000. Forced mode continues to use BMCR. Report the MDI-X state read at link-up and invalidate it when the link goes down or autonegotiation is disabled. Clear mdix_ctrl because this driver does not implement MDI-X configuration.
The QCA8327 entries keep genphy_read_status(). The AR8327 data sheet (MKG-15791 Rev. 1.0) lists the QCA8327-A PHY ID and documents the same PHY-specific status layout, with SmartSpeed enabled after a hardware reset, so those PHYs may have the same problem. That is untested on QCA8327 hardware, so limit this change to QCA8337.
--- drivers/net/phy/qcom/qca83xx.c | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+)
drivers/net/phy/qcom/qca83xx.c +58 -0
@@ -94,6 +94,63 @@ static int qca83xx_probe(struct phy_device *phydev)return 0 ; } +static int qca8337_read_status (struct phy_device *phydev) +{ +struct at803x_ss_mask ss_mask = { + .speed_mask =AT803X_SS_SPEED_MASK , + .speed_shift =__bf_shf (AT803X_SS_SPEED_MASK ), + }; +int ret, old_link = phydev->link; + + ret =genphy_read_status (phydev); +if (ret) +return ret; + +/* Keep the state resolved at link-up while the link stays up */ +if (phydev->autoneg ==AUTONEG_ENABLE && old_link && phydev->link) + goto out; + + phydev->mdix =ETH_TP_MDI_INVALID ; + +/* genphy_read_status() derives speed and duplex from the +* advertisements, which is wrong after a SmartSpeed downshift. +* Use what the PHY resolved instead. +*/ +if (phydev->autoneg ==AUTONEG_ENABLE && phydev->autoneg_complete && + phydev->link) { + phydev->speed =SPEED_UNKNOWN ; + phydev->duplex =DUPLEX_UNKNOWN ; + phydev->pause = false; + phydev->asym_pause = false; + + ret =at803x_read_specific_status (phydev, ss_mask); +if (ret) +return ret; + +/* Report the link down until speed and duplex are resolved, +* so that the next poll reads them again. Also clear what +* genphy_read_status() read for an up link, as the +* PHY_HALTED path of the state machine does. +*/ +if (phydev->speed ==SPEED_UNKNOWN || + phydev->duplex ==DUPLEX_UNKNOWN ) { + phydev->link =0 ; + phydev->duplex =DUPLEX_UNKNOWN ; + phydev->mdix =ETH_TP_MDI_INVALID ; + phydev->master_slave_state =MASTER_SLAVE_STATE_UNKNOWN ; +linkmode_zero (phydev->lp_advertising); + }else { +phy_resolve_aneg_pause (phydev); + } + } + +out: +/* MDI-X configuration is not implemented */ + phydev->mdix_ctrl =ETH_TP_MDI_INVALID ; + +return 0 ; +} +static int qca83xx_config_init (struct phy_device *phydev) {u8 switch_revision;
@@ -222,6 +279,7 @@ static struct phy_driver qca83xx_driver[] = { .flags = PHY_IS_INTERNAL, .config_init = qca83xx_config_init, .soft_reset = genphy_soft_reset, + .read_status = qca8337_read_status, .get_sset_count = qca83xx_get_sset_count, .get_strings = qca83xx_get_strings, .get_stats = qca83xx_get_stats,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1429/1756 net: stmmac: avoid duplicate XSK TX completions
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Hilliard <[email protected]>
[ Upstream commit daac93975b8ff0a0a036a5e3562236c0b40c3e36 ]
stmmac_tx_clean() reports completed AF_XDP TX descriptors through xsk_tx_completed(), but leaves their buffer type as STMMAC_TXBUF_T_XSK_TX. The slots retain that type until they are reused for another buffer type.
On interface close or XDP teardown, dma_free_tx_skbufs() walks the entire TX ring, not just the dirty_tx..cur_tx range. stmmac_free_tx_buffer() counts the stale XSK_TX slots again, causing xsk_tx_completed() to advance the completion-ring producer for buffers that have already been returned. This publishes completion entries without matching outstanding TX reservations and corrupts completion accounting for a socket which stays bound across the teardown.
Reset the XSK buffer type after counting the completion in both stmmac_tx_clean() and stmmac_free_tx_buffer(). XSK TX slots have a NULL skb pointer and no per-slot DMA mapping, so the SKB type represents an empty slot. Pending XSK descriptors keep their type until they are completed or released, and a released slot can no longer be counted again by a later cleanup.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +7 -2
@@ -1534,8 +1534,10 @@ static void stmmac_free_tx_buffer(struct stmmac_priv *priv, tx_q->xdpf[i] =NULL ; } -if (tx_q->tx_skbuff_dma[i].buf_type ==STMMAC_TXBUF_T_XSK_TX ) +if (tx_q->tx_skbuff_dma[i].buf_type ==STMMAC_TXBUF_T_XSK_TX ) { tx_q->xsk_frames_done++; + tx_q->tx_skbuff_dma[i].buf_type =STMMAC_TXBUF_T_SKB ; + }if (tx_q->tx_skbuff[i] && tx_q->tx_skbuff_dma[i].buf_type ==STMMAC_TXBUF_T_SKB ) {
@@ -2728,8 +2730,11 @@ static int stmmac_tx_clean(struct stmmac_priv *priv, int budget, u32 queue, tx_q->xdpf[entry] =NULL ; } -if (tx_q->tx_skbuff_dma[entry].buf_type ==STMMAC_TXBUF_T_XSK_TX ) +if (tx_q->tx_skbuff_dma[entry].buf_type ==STMMAC_TXBUF_T_XSK_TX ) { tx_q->xsk_frames_done++; +/* Teardown must not count this slot again. */ + tx_q->tx_skbuff_dma[entry].buf_type =STMMAC_TXBUF_T_SKB ; + }if (tx_q->tx_skbuff_dma[entry].buf_type ==STMMAC_TXBUF_T_SKB ) {if (likely (skb)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1430/1756 rtc: mpfs: Fix alarm register word order
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baek Kyu, Kim <[email protected]>
[ Upstream commit d691a96370b6cd7e684e4da1c473c09df963611b ]
mpfs_rtc_readalarm() swaps the low and high words of the alarm time. The RTC core reads this value during device registration to initialize its alarm timer. This can populate the cached alarm and timer queue with an incorrect expiry time, or leave an enabled hardware alarm out of the timer queue if the decoded time appears to be in the past.
Read the low 32 bits from ALARM_LOWER_REG and place the masked high 11 bits from ALARM_UPPER_REG in bits 42:32. This matches the layout used by mpfs_rtc_setalarm() and the low/high assembly in mpfs_rtc_readtime(), so the RTC core imports the programmed alarm time correctly during device registration.
--- drivers/rtc/rtc-mpfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/rtc/rtc-mpfs.c +2 -2
@@ -131,8 +131,8 @@ static int mpfs_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm) alrm->enabled = mode &MODE_WAKE_EN ; - time = (u64 )readl (rtcdev->base +ALARM_LOWER_REG ) <<32 ; - time |= (readl (rtcdev->base +ALARM_UPPER_REG ) &ALARM_UPPER_MASK ); + time =readl (rtcdev->base +ALARM_LOWER_REG ); + time |= ((u64 )readl (rtcdev->base +ALARM_UPPER_REG ) &ALARM_UPPER_MASK ) <<32 ;rtc_time64_to_tm (time, &alrm->time);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1431/1756 rtc: class: Make the time32 hctosys limit configurable
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit b253c2e96a80aac8e2bc67b425bf007ed78d4d8c ]
The RTC_HCTOSYS feature faces an impossible dilemma on 32-bit systems:
a) systemd requires RTC_HCTOSYS=y with the correct timestamp for its intended operation
b) broken RTC hardware can produce random future timestamps beyond 2038 at boot time
c) time32 userspace immediately hangs if the time is set to a date beyond 2038 and requires timestamps to be clamped
d) time64 userspace is intended to survive the actual 2038 date and requires timestamps to not be clamped
Commit b3a5ac42ab18 ("rtc: hctosys: Ensure system time doesn't overflow time_t") introduced this limit to protect time32 userspace from future RTC dates that can break boot and address constraints a), b) and c), but broke d) in the process by limiting RTC_HCTOSYS to the time32 range and falling back to RTC_HCTOSYS=n behavior when the RTC time overflows that.
Make the behavior configurable with a new RTC_HCTOSYS_TIME32_LIMIT option that chooses between breaking c) or d). On systems with COMPAT_32BIT_TIME=n, only RTC_HCTOSYS_TIME32_LIMIT=n is allowed since userspace can be assumed to be fully built for time64. 64-bit kernels running 32-bit userland never had the cutoff and continue to not offer the option.
Warn on rejection with the RTC date and option name so users can identify the cause and find the setting.
[arnd: reword Kconfig text and patch description,
add COMPAT_32BIT_TIME dependency]
----
I ended up rewriting most of the text but kept Karl's ownership as he did the original patch.
--- drivers/rtc/Kconfig | 21 +++++++++++++++++++++ drivers/rtc/class.c | 8 +++++--- 2 files changed, 26 insertions(+), 3 deletions(-)
drivers/rtc/Kconfig +21 -0
@@ -30,6 +30,27 @@ config RTC_HCTOSYS the value read from a specified RTC device. This is useful to avoid unnecessary fsck runs at boot time, and to network better. +config RTC_HCTOSYS_TIME32_LIMIT + bool "Reject RTC dates after the 2038 cutoff" + depends on RTC_HCTOSYS && COMPAT_32BIT_TIME && !64BIT + default y + help + Reject RTC dates after 03:14:07 UTC on 19 January 2038 when + initializing the system clock in order to work around broken + RTC implementations that produce nondeterministic timestamps + without a working backup battery. + + A rejected date leaves system time unchanged, normally near + the Unix epoch, and the RTC's hctosys sysfs attribute reads + 0. Userspace must supply the time if no other source has + initialized it. + + Say Y here if the kernel may have to run old time32 userspace on + hardware that can produce unpredictable RTC timestamps. If the + kernel is intended to only run time64 compatible userspace and + continue working past 2038, you must pick N here in order to + have a working RTC_HCTOSYS functionality. + config RTC_HCTOSYS_DEVICE string "RTC used to set the system time" depends on RTC_HCTOSYS
drivers/rtc/class.c +5 -3
@@ -72,12 +72,14 @@ static void rtc_hctosys(struct rtc_device *rtc) tv64.tv_sec =rtc_tm_to_time64 (&tm); -#if BITS_PER_LONG ==32 -if (tv64.tv_sec >INT_MAX ) { +if (IS_ENABLED (CONFIG_RTC_HCTOSYS_TIME32_LIMIT ) && + tv64.tv_sec >INT_MAX ) { +dev_warn (rtc->dev.parent, +"hctosys: rejecting %ptR UTC due to CONFIG_RTC_HCTOSYS_TIME32_LIMIT=y\n" , + &tm); err = -ERANGE ; goto err_read; } -#endif err =do_settimeofday64 (&tv64);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1432/1756 timers: Clear pending_map on CPU hotplug
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liang Hao <[email protected]>
[ Upstream commit e7cad586d73276cbd4466de81b2092287d7475c0 ]
CPU hotplug migration leaves pending_map bits set on the outgoing CPU while its wheel vectors are empty. After re-online, a later next_expiry recalc can treat those empty buckets as pending and temporarily pull next_expiry forward until collect drains the bits.
Clear pending_map under the base lock after migration in timers_dead_cpu().
--- kernel/time/timer.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/time/timer.c +2 -0
@@ -45,6 +45,7 @@#include <linux/compat.h> #include <linux/random.h> #include <linux/sysctl.h> +#include <linux/bitmap.h> #include <linux/uaccess.h> #include <asm/unistd.h>
@@ -2722,6 +2723,7 @@ int timers_dead_cpu(unsigned int cpu)for (i =0 ; i <WHEEL_SIZE ; i++)migrate_timer_list (new_base, old_base->vectors + i); +bitmap_zero (old_base->pending_map,WHEEL_SIZE );raw_spin_unlock (&old_base->lock);raw_spin_unlock_irq (&new_base->lock);put_cpu_ptr (&timer_bases);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1433/1756 ASoC: cs42l56: Remove the ADC Mute Switch control
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit ff404ef11b975baf38c4472c51a6674c239e8021 ]
The ADC Mute Switch control writes bits 2 and 3 of the Misc ADC Control register. These are the ADCA Invert and ADCB Invert bits, which have their own controls. The ADC mute bits are bits 0 and 1, and the DAI mute callback already sets them.
So the control has never muted the ADCs, and nobody can be relying on it. Remove it rather than point it at the mute bits, so the ADCs are muted in one place only.
--- sound/soc/codecs/cs42l56.c | 1 - 1 file changed, 1 deletion(-)
sound/soc/codecs/cs42l56.c +0 -1
@@ -387,7 +387,6 @@ static const struct snd_kcontrol_new cs42l56_snd_controls[] = { CS42L56_PGAB_MUX_VOLUME, 0, 0x34, 0x24, pga_tlv),SOC_DOUBLE_R_TLV ("ADC Volume" ,CS42L56_ADCA_ATTENUATOR ,CS42L56_ADCB_ATTENUATOR ,0 ,0x00 ,1 , adc_tlv), -SOC_DOUBLE ("ADC Mute Switch" ,CS42L56_MISC_ADC_CTL ,2 ,3 ,1 ,1 ),SOC_DOUBLE ("ADC Boost Switch" ,CS42L56_GAIN_BIAS_CTL ,3 ,2 ,1 ,1 ), SOC_DOUBLE_R_SX_TLV("Headphone Volume", CS42L56_HPA_VOLUME,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1434/1756 dt-bindings: clock: mediatek: Add MT8516 fallbacks
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rob Herring (Arm) <[email protected]>
[ Upstream commit 1d48ecb48e2ab9dd2564e735a1c1b29a5eeeb599 ]
MT8516 topckgen and apmixedsys nodes use the common syscon fallback form. Add the MT8516 compatibles to the branches that allow the syscon fallback.
--- .../devicetree/bindings/clock/mediatek,apmixedsys.yaml | 2 +- Documentation/devicetree/bindings/clock/mediatek,topckgen.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/clock/mediatek,apmixedsys.yaml +1 -1
@@ -25,7 +25,6 @@ properties: - mediatek,mt7988-apmixedsys - mediatek,mt8135-apmixedsys - mediatek,mt8173-apmixedsys - - mediatek,mt8516-apmixedsys - items: - const: mediatek,mt7623-apmixedsys - const: mediatek,mt2701-apmixedsys
@@ -40,6 +39,7 @@ properties: - mediatek,mt7629-apmixedsys - mediatek,mt8167-apmixedsys - mediatek,mt8183-apmixedsys + - mediatek,mt8516-apmixedsys - const: syscon reg:
Documentation/devicetree/bindings/clock/mediatek,topckgen.yaml +1 -1
@@ -22,7 +22,6 @@ properties: - mediatek,mt7622-topckgen - mediatek,mt8135-topckgen - mediatek,mt8173-topckgen - - mediatek,mt8516-topckgen - items: - const: mediatek,mt7623-topckgen - const: mediatek,mt2701-topckgen
@@ -41,6 +40,7 @@ properties: - mediatek,mt7988-topckgen - mediatek,mt8167-topckgen - mediatek,mt8183-topckgen + - mediatek,mt8516-topckgen - const: syscon reg:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1435/1756 vhost: vringh: use get_user()/put_user() for IOTLB 16-bit accesses
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Torvalds <[email protected]>
[ Upstream commit 95a214f31a3b1ef40034f1e1cb3b9d758a374f01 ]
getu16_iotlb() and putu16_iotlb() use __get_user() and __put_user() when the IOTLB maps to user virtual addresses. Nothing nearby checks the translated address: that relies on the mapping having been validated against the user's VMAs when it was set up.
Use get_user() and put_user(), which do the same single, untorn access and also check the address. The only atomic-context use, the vdpa simulators' notification check, now disables page faults around it, so the might_fault() in the checked accessors stays quiet there.
This is part of getting rid of __get_user() and __put_user() entirely.
--- drivers/vhost/vringh.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/vhost/vringh.c +2 -2
@@ -1290,7 +1290,7 @@ static inline int getu16_iotlb(const struct vringh *vrh,return ret;if (vrh->use_va) { - ret =__get_user (tmp, (__virtio16 __user *)ivec.iov.iovec[0 ].iov_base); + ret =get_user (tmp, (__virtio16 __user *)ivec.iov.iovec[0 ].iov_base);if (ret)return ret; }else {
@@ -1329,7 +1329,7 @@ static inline int putu16_iotlb(const struct vringh *vrh, tmp =cpu_to_vringh16 (vrh, val);if (vrh->use_va) { - ret =__put_user (tmp, (__virtio16 __user *)ivec.iov.iovec[0 ].iov_base); + ret =put_user (tmp, (__virtio16 __user *)ivec.iov.iovec[0 ].iov_base);if (ret)return ret; }else {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1436/1756 net: openvswitch: skip IPv4 later fragments on TCP/UDP set actions
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fernando Fernandez Mancera <[email protected]>
[ Upstream commit 14c0350142ab0a10ebeefed03b779df23749e16a ]
An IPv4 later fragment carries no L4 header, but key extraction leaves ip.proto set to the real protocol and the flow may wildcard the frag field, so validate_set() accepts such packets. set_tcp() and set_udp() then treat the first bytes of the fragment payload as an L4 header, rewrite them as ports and patch the bytes at the checksum offset, corrupting the packet.
Skip these actions for OVS_FRAG_TYPE_LATER. IPv6 later fragments are not affected, since their ip.proto is NEXTHDR_FRAGMENT and validate_set() rejects L4 set actions for them.
--- net/openvswitch/actions.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/openvswitch/actions.c +6 -0
@@ -635,6 +635,9 @@ static int set_udp(struct sk_buff *skb, struct sw_flow_key *flow_key,__be16 src, dst;int err; +if (flow_key->ip.frag ==OVS_FRAG_TYPE_LATER ) +return 0 ; + err =skb_ensure_writable (skb,skb_transport_offset (skb) +sizeof (struct udphdr ));if (unlikely (err))
@@ -678,6 +681,9 @@ static int set_tcp(struct sk_buff *skb, struct sw_flow_key *flow_key,__be16 src, dst;int err; +if (flow_key->ip.frag ==OVS_FRAG_TYPE_LATER ) +return 0 ; + err =skb_ensure_writable (skb,skb_transport_offset (skb) +sizeof (struct tcphdr ));if (unlikely (err))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1437/1756 net: openvswitch: drop IP fragments on SCTP set action
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fernando Fernandez Mancera <[email protected]>
[ Upstream commit 4d0d8f491307f22aea34b22f73351e1cd2ede735 ]
The SCTP checksum is a CRC32c over the whole SCTP packet. set_sctp() updates it as old_csum ^ old_correct_csum ^ new_csum, with the two CRCs computed over the bytes of the current skb only. That is correct only when the skb holds the whole SCTP packet. For a first fragment, and for a later fragment, it holds just a part of it, and the CRC delta of a change at the start of the packet depends on how many bytes follow, so the checksum written is wrong. The receiver drops the reassembled packet.
validate_set() accepts SCTP set action for any flow with ip.proto set to SCTP, regardless of the fragmentation bits, as it only receives the masked key. As the checksum cannot be fixed up without the whole datagram, fail the action for packets that are IP fragments of either family, so the packet is dropped with OVS_DROP_ACTION_ERROR instead of being forwarded with modified ports and an invalid checksum.
--- net/openvswitch/actions.c | 3 +++ 1 file changed, 3 insertions(+)
net/openvswitch/actions.c +3 -0
@@ -714,6 +714,9 @@ static int set_sctp(struct sk_buff *skb, struct sw_flow_key *flow_key,__le32 old_correct_csum, new_csum, old_csum;int err; +if (flow_key->ip.frag !=OVS_FRAG_TYPE_NONE ) +return -EINVAL ; + err =skb_ensure_writable (skb, sctphoff +sizeof (struct sctphdr ));if (unlikely (err))return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1438/1756 tcp: tcp_metrics: use the socket netns, not the dst device netns
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 504bdcb8c1566a6f887f9accebe1aa99b502ae97 ]
tcp_get_metrics(), __tcp_get_metrics_req() and tcpm_new() look up and create metrics entries in the netns of the cached dst device rather than in the netns of the socket.
These usually match, but not after the device has been moved to another netns or unregistered: a socket can keep a stale dst in sk_dst_cache until it is checked again, and tcp_update_metrics() reads it with __sk_dst_get() without any dst_check(). Once dst_dev_put() has run, the dst device is blackhole_netdev and the entry is created in init_net. Before that, for instance for routes through nexthop objects whose cached dsts are released from a nested RCU callback, it is the netns the device has just been moved to.
A TCP socket of netns A that enters TIME_WAIT in that window then creates or updates an entry carrying A's addresses and RTT in another netns, where TCP_METRICS_CMD_GET can dump it and where new connections to the same peer inherit those metrics.
The metrics belong to the netns of the socket, so use sock_net() for full sockets and request sockets, and pass it to tcpm_new().
Kernel sockets that do not hold a netns reference can still reach tcp_time_wait() after tcp_net_metrics_exit_batch() has flushed the entries of their dismantling netns, and an entry created then would never be flushed and would keep a dangling tcpm_net. Make tcpm_new() refuse to create entries when check_net() fails. Its callers are in an RCU read-side section, and cleanup_net() waits for a grace period between the refcount reaching zero and the flush, so an entry added after a successful check is always seen by the flush.
--- net/ipv4/tcp_metrics.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
net/ipv4/tcp_metrics.c +15 -5
@@ -161,16 +161,26 @@ static void tcpm_check_stamp(struct tcp_metrics_block *tm, rcu_dereference_protected(p, lockdep_is_held(&tcp_metrics_lock))static struct tcp_metrics_block *tcpm_new (struct dst_entry *dst, +struct net *net,struct inetpeer_addr *saddr,struct inetpeer_addr *daddr,unsigned int hash) {struct tcp_metrics_block *tm;bool reclaim = false; -struct net *net;spin_lock_bh (&tcp_metrics_lock); - net =dst_dev_net_rcu (dst); + +/* Do not add entries to a dismantling netns: they would not be +* flushed again. Callers are in an RCU read-side section, and +* cleanup_net() waits for a grace period after the netns refcount +* reached zero and before tcp_metrics_flush_all(NULL) runs, so an +* entry added after a successful check_net() is seen by the flush. +*/ +if (unlikely (!check_net (net))) { + tm =NULL ; + goto out_unlock; + }/* While waiting for the spin-lock the cache might have been populated * with this entry and so we have to check again.
@@ -273,7 +283,7 @@ static struct tcp_metrics_block *__tcp_get_metrics_req(struct request_sock *req,return NULL ; } - net =dst_dev_net_rcu (dst); + net =sock_net (req_to_sk (req)); hash ^=net_hash_mix (net); hash =hash_32 (hash, tcp_metrics_hash_log);
@@ -318,7 +328,7 @@ static struct tcp_metrics_block *tcp_get_metrics(struct sock *sk,else return NULL ; - net =dst_dev_net_rcu (dst); + net =sock_net (sk); hash ^=net_hash_mix (net); hash =hash_32 (hash, tcp_metrics_hash_log);
@@ -326,7 +336,7 @@ static struct tcp_metrics_block *tcp_get_metrics(struct sock *sk,if (tm ==TCP_METRICS_RECLAIM_PTR ) tm =NULL ;if (!tm && create) - tm =tcpm_new (dst, &saddr, &daddr, hash); + tm =tcpm_new (dst, net, &saddr, &daddr, hash);else tcpm_check_stamp (tm, dst);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1439/1756 tls: device: protect async RX resync state during device-down
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rishikesh Jethwani <[email protected]>
[ Upstream commit f89a228125238f8d4c7e2b8161e2a85fe35307b6 ]
tls_device_rx_resync_new_rec() can run in process context with the socket lock held, but without an RCU read lock: from the strparser work item (tls_strp_work()) and from the receive paths (tls_rx_rec_wait(), tls_rx_rec_done()). The resync_async pointer belongs to the driver RX context, which tls_device_down() tears down from the netdev notifier without taking the socket lock; only the softirq entry to the parser is implicitly inside an RCU section.
If the parser passes the TLS_RX_DEV_DEGRADED check before device-down sets it, tls_device_down() can complete synchronize_net() and delete the driver context before the parser accesses resync_async->req or its record log. In the asynchronous stage the parser also writes the record log, so this is a write to freed memory, not only a stale read. The RCU section in tls_device_resync_rx() starts after those accesses and therefore does not prevent the use-after-free.
Found by code inspection; not reproduced. Hitting the window requires the parser to be preempted between the DEGRADED check and the resync_async access across the device-down grace period and the driver's teardown.
--- net/tls/tls_device.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
net/tls/tls_device.c +15 -6
@@ -782,8 +782,15 @@ void tls_device_rx_resync_new_rec(struct sock *sk, u32 rcd_len, u32 seq)if (tls_ctx->rx_conf !=TLS_HW )return ; + +/* The parser also runs in process context, without an RCU read lock. +* Protect the driver's resync_async state before checking the flags: +* device-down sets DEGRADED and waits for synchronize_net() before +* freeing it, without taking the socket lock. +*/ +rcu_read_lock ();if (unlikely (test_bit (TLS_RX_DEV_DEGRADED , &tls_ctx->flags))) -return ; + goto out; prot = &tls_ctx->prot_info; rx_ctx =tls_offload_ctx_rx (tls_ctx);
@@ -798,11 +805,11 @@ void tls_device_rx_resync_new_rec(struct sock *sk, u32 rcd_len, u32 seq)if (likely (!is_req_pending) || req_seq != seq || !atomic64_try_cmpxchg (&rx_ctx->resync_req, &resync_req,0 )) -return ; + goto out;break ;case TLS_OFFLOAD_SYNC_TYPE_CORE_NEXT_HINT :if (likely (!rx_ctx->resync_nh_do_now)) -return ; + goto out;/* head of next rec is already in, note that the sock_inq will * include the currently parsed message when called from parser
@@ -811,7 +818,7 @@ void tls_device_rx_resync_new_rec(struct sock *sk, u32 rcd_len, u32 seq)if (sock_data > rcd_len) {trace_tls_device_rx_resync_nh_delay (sk, sock_data, rcd_len); -return ; + goto out; } rx_ctx->resync_nh_do_now =0 ;
@@ -822,16 +829,18 @@ void tls_device_rx_resync_new_rec(struct sock *sk, u32 rcd_len, u32 seq) resync_req =atomic64_read (&rx_ctx->resync_async->req); is_req_pending = resync_req;if (likely (!is_req_pending)) -return ; + goto out;if (!tls_device_rx_resync_async (rx_ctx->resync_async, resync_req, &seq, &rcd_delta)) -return ; + goto out;tls_bigint_subtract (rcd_sn, rcd_delta);break ; }tls_device_resync_rx (tls_ctx, sk, seq, rcd_sn); +out: +rcu_read_unlock (); } static void tls_device_core_ctrl_rx_resync(struct tls_context *tls_ctx,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1440/1756 octeontx2: Fix use-after-free of qos node in delete path
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Binbin Deng <[email protected]>
[ Upstream commit dcaa6219648955f7a8160313f1685321dbd1bf28 ]
hash_del_rcu() only unlinks the node; a reader that already holds the bucket iterator still uses the node. The immediate kfree() has no grace period, so a concurrent transmit on a socket whose skb priority carries the deleted classid reads node->classid / node->qid from freed memory (use-after-free in the softirq transmit path).
Fix this by calling synchronize_net() before the node is freed, as mlx5e does.
Found during a static-analysis-assisted audit: candidate sites were surfaced by a Coccinelle rule, and the reader/writer paths were confirmed by LLM-assisted (GLM-5.3) code inspection. The issue was not observed at runtime; it is identified by code inspection only.
--- drivers/net/ethernet/marvell/octeontx2/nic/qos.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/marvell/octeontx2/nic/qos.c +2 -0
@@ -331,6 +331,8 @@ static void otx2_qos_sw_node_delete(struct otx2_nic *pfvf,otx2_qos_update_tx_netdev_queues (pfvf); } +synchronize_net (); +list_del (&node->list);kfree (node); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1441/1756 net: qede: initialize extack in qede_flow_spec_to_rule()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anirudh Virdi <[email protected]>
[ Upstream commit 106e562966a02f61917c2e0b83909aa2b088447f ]
qede_flow_spec_to_rule() declares a netlink_ext_ack on the stack without initializing it. qede_parse_flow_attr() and qede_flow_spec_validate() only set extack._msg on error paths via NL_SET_ERR_MSG_MOD(), so on a successful parse the err_out block reads an uninitialized pointer. If that garbage happens to be non-NULL, DP_NOTICE("%s", extack._msg) dereferences it inside vsnprintf, causing a page fault and kernel panic.
This manifests when configuring ethtool ntuple flow rules (ethtool -U flow-type tcp4/udp4) on kernels built with CONFIG_INIT_STACK_NONE=y. With CONFIG_INIT_STACK_ALL_ZERO=y the bug is masked because the compiler zero-initializes extack, making _msg NULL.
Reproduced on RHEL 9.8 (kernel-5.14.0-687.47.1.el9_8) and mainline (v7.3-rc6) with the following reproducer:
IFACE=ens2f0
ip link set $IFACE up
ethtool -K $IFACE ntuple on
for i in $(seq 1 100); do
ethtool -U $IFACE flow-type udp4 src-ip 192.168.2.$i action -1
doneThe loop panics reliably after 10-15 iterations with:
BUG: unable to handle page fault RIP: string+0x49/0xd0 Call Trace: vsnprintf qede_flow_spec_to_rule+0x2b6/0x4b0 [qede] qede_add_cls_rule ethtool_set_rxnfc
Zero-initialize extack so _msg is NULL unless explicitly set by an error path.
--- drivers/net/ethernet/qlogic/qede/qede_filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/qlogic/qede/qede_filter.c +1 -1
@@ -1991,8 +1991,8 @@ static int qede_flow_spec_to_rule(struct qede_dev *edev, struct ethtool_rx_flow_spec *fs) {struct ethtool_rx_flow_spec_input input = {}; +struct netlink_ext_ack extack = {};struct ethtool_rx_flow_rule *flow; -struct netlink_ext_ack extack;__be16 proto;int err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1442/1756 net: phy: move realtek PHY driver to its own subdirectory
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiner Kallweit <[email protected]>
[ Upstream commit 1416a9b2ba710d31954131c06d46f298e340aa2c ]
In preparation of adding a source file with hwmon support, move the Realtek PHY driver to its own subdirectory and rename realtek.c to realtek_main.c.
Stable-dep-of: 20c0c6773624 ("net: phy: realtek: restore RTL8211F RGMII delays on resume")
---
drivers/net/phy/Kconfig | 5 +----
drivers/net/phy/Makefile | 2 +-
drivers/net/phy/realtek/Kconfig | 5 +++++
drivers/net/phy/realtek/Makefile | 3 +++
drivers/net/phy/{realtek.c => realtek/realtek_main.c} | 0
5 files changed, 10 insertions(+), 5 deletions(-)
create mode 100644 drivers/net/phy/realtek/Kconfig
create mode 100644 drivers/net/phy/realtek/Makefile
rename drivers/net/phy/{realtek.c => realtek/realtek_main.c} (100%)drivers/net/phy/Kconfig +1 -4
@@ -343,10 +343,7 @@ config QSEMI_PHY help Currently supports the qs6612 -config REALTEK_PHY - tristate "Realtek PHYs" - help - Supports the Realtek 821x PHY. +source "drivers/net/phy/realtek/Kconfig" config RENESAS_PHY tristate "Renesas PHYs"
drivers/net/phy/Makefile +1 -1
@@ -94,7 +94,7 @@ obj-$(CONFIG_NXP_CBTX_PHY) += nxp-cbtx.o obj-$(CONFIG_NXP_TJA11XX_PHY) += nxp-tja11xx.o obj-y += qcom/ obj-$(CONFIG_QSEMI_PHY) += qsemi.o -obj-$(CONFIG_REALTEK_PHY) += realtek.o +obj-$(CONFIG_REALTEK_PHY) += realtek/ obj-$(CONFIG_RENESAS_PHY) += uPD60620.o obj-$(CONFIG_ROCKCHIP_PHY) += rockchip.o obj-$(CONFIG_SMSC_PHY) += smsc.o
drivers/net/phy/realtek/Kconfig new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-only +config REALTEK_PHY + tristate "Realtek PHYs" + help + Currently supports RTL821x/RTL822x and fast ethernet PHYs
drivers/net/phy/realtek/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 +realtek-y += realtek_main.o +obj-$(CONFIG_REALTEK_PHY) += realtek.o
drivers/net/phy/realtek/realtek_main.c renamed from drivers/net/phy/realtek.c +0 -0
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1443/1756 net: phy: realtek: use string choices helpers
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiner Kallweit <[email protected]>
[ Upstream commit 0bea93fdbaf8675b7e8124bdcaf51497dcc8bcfa ]
Use string choices helpers to simplify the code.
Stable-dep-of: 20c0c6773624 ("net: phy: realtek: restore RTL8211F RGMII delays on resume")
--- drivers/net/phy/realtek/realtek_main.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/net/phy/realtek/realtek_main.c +5 -4
@@ -13,6 +13,7 @@#include <linux/module.h> #include <linux/delay.h> #include <linux/clk.h> +#include <linux/string_choices.h> #define RTL821x_PHYSR 0x11#define RTL821x_PHYSR_DUPLEX BIT(13)
@@ -417,11 +418,11 @@ static int rtl8211f_config_init(struct phy_device *phydev) }else if (ret) {dev_dbg (dev,"%s 2ns TX delay (and changing the value from pin-strapping RXD1 or the bootloader)\n" , - val_txdly ?"Enabling" :"Disabling" ); +str_enable_disable (val_txdly)); }else {dev_dbg (dev,"2ns TX delay was already %s (by pin-strapping RXD1 or bootloader configuration)\n" , - val_txdly ?"enabled" :"disabled" ); +str_enabled_disabled (val_txdly)); } ret = phy_modify_paged_changed(phydev, 0xd08, 0x15, RTL8211F_RX_DELAY,
@@ -432,11 +433,11 @@ static int rtl8211f_config_init(struct phy_device *phydev) }else if (ret) {dev_dbg (dev,"%s 2ns RX delay (and changing the value from pin-strapping RXD0 or the bootloader)\n" , - val_rxdly ?"Enabling" :"Disabling" ); +str_enable_disable (val_rxdly)); }else {dev_dbg (dev,"2ns RX delay was already %s (by pin-strapping RXD0 or bootloader configuration)\n" , - val_rxdly ?"enabled" :"disabled" ); +str_enabled_disabled (val_rxdly)); }if (priv->has_phycr2) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1444/1756 net: phy: realtek: disable PHY-mode EEE
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Russell King (Oracle) <[email protected]>
[ Upstream commit bfc17c1658353f22843c7c13e27c2d31950f1887 ]
Realtek RTL8211F has a "PHY-mode" EEE support which interferes with an IEEE 802.3 compliant implementation. This mode defaults to enabled, and results in the MAC receive path not seeing the link transition to LPI state.
Fix this by disabling PHY-mode EEE.
Stable-dep-of: 20c0c6773624 ("net: phy: realtek: restore RTL8211F RGMII delays on resume")
--- drivers/net/phy/realtek/realtek_main.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/phy/realtek/realtek_main.c +9 -2
@@ -31,6 +31,9 @@#define RTL8211F_PHYCR1 0x18#define RTL8211F_PHYCR2 0x19 +#define RTL8211F_CLKOUT_EN BIT(0) +#define RTL8211F_PHYCR2_PHY_EEE_ENABLE BIT(5) +#define RTL8211F_INSR 0x1d#define RTL8211F_LEDCR 0x10
@@ -53,8 +56,6 @@#define RTL8211E_TX_DELAY BIT(12)#define RTL8211E_RX_DELAY BIT(11) -#define RTL8211F_CLKOUT_EN BIT(0) -#define RTL8201F_ISR 0x1e#define RTL8201F_ISR_ANERR BIT(15)#define RTL8201F_ISR_DUPLEX BIT(13)
@@ -440,6 +441,12 @@ static int rtl8211f_config_init(struct phy_device *phydev) str_enabled_disabled(val_rxdly)); } +/* Disable PHY-mode EEE so LPI is passed to the MAC */ + ret =phy_modify_paged (phydev,0xa43 ,RTL8211F_PHYCR2 , +RTL8211F_PHYCR2_PHY_EEE_ENABLE ,0 ); +if (ret) +return ret; +if (priv->has_phycr2) { ret =phy_modify_paged (phydev,0xa43 ,RTL8211F_PHYCR2 ,RTL8211F_CLKOUT_EN , priv->phycr2);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1445/1756 net: phy: realtek: Add support for WOL magic packet on RTL8211F
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Braunwarth <[email protected]>
[ Upstream commit 7840e4d6f48a75413470935ebdc4bab4fc0c035e ]
The RTL8211F supports multiple WOL modes. This patch adds support for magic packets.
The PHY notifies the system via the INTB/PMEB pin when a WOL event occurs.
Stable-dep-of: 20c0c6773624 ("net: phy: realtek: restore RTL8211F RGMII delays on resume")
--- drivers/net/phy/realtek/realtek_main.c | 69 ++++++++++++++++++++++++++ 1 file changed, 69 insertions(+)
drivers/net/phy/realtek/realtek_main.c +69 -0
@@ -10,6 +10,7 @@#include <linux/bitops.h> #include <linux/of.h> #include <linux/phy.h> +#include <linux/netdevice.h> #include <linux/module.h> #include <linux/delay.h> #include <linux/clk.h>
@@ -36,6 +37,24 @@#define RTL8211F_INSR 0x1d +/* RTL8211F WOL interrupt configuration */ +#define RTL8211F_INTBCR_PAGE 0xd40 +#define RTL8211F_INTBCR 0x16 +#define RTL8211F_INTBCR_INTB_PMEB BIT(5) + +/* RTL8211F WOL settings */ +#define RTL8211F_WOL_SETTINGS_PAGE 0xd8a +#define RTL8211F_WOL_SETTINGS_EVENTS 16 +#define RTL8211F_WOL_EVENT_MAGIC BIT(12) +#define RTL8211F_WOL_SETTINGS_STATUS 17 +#define RTL8211F_WOL_STATUS_RESET (BIT(15) | 0x1fff) + +/* RTL8211F Unique phyiscal and multicast address (WOL) */ +#define RTL8211F_PHYSICAL_ADDR_PAGE 0xd8c +#define RTL8211F_PHYSICAL_ADDR_WORD0 16 +#define RTL8211F_PHYSICAL_ADDR_WORD1 17 +#define RTL8211F_PHYSICAL_ADDR_WORD2 18 +#define RTL8211F_LEDCR 0x10#define RTL8211F_LEDCR_MODE BIT(15)#define RTL8211F_LEDCR_ACT_TXRX BIT(4)
@@ -110,6 +129,7 @@ struct rtl821x_priv {u16 phycr2;bool has_phycr2;struct clk *clk; +u32 saved_wolopts; };static int rtl821x_read_page (struct phy_device *phydev)
@@ -341,6 +361,53 @@ static irqreturn_t rtl8211f_handle_interrupt(struct phy_device *phydev)return IRQ_HANDLED ; } +static void rtl8211f_get_wol (struct phy_device *dev,struct ethtool_wolinfo *wol) +{ + wol->supported =WAKE_MAGIC ; +if (phy_read_paged (dev,RTL8211F_WOL_SETTINGS_PAGE ,RTL8211F_WOL_SETTINGS_EVENTS ) + &RTL8211F_WOL_EVENT_MAGIC ) + wol->wolopts =WAKE_MAGIC ; +} + +static int rtl8211f_set_wol (struct phy_device *dev,struct ethtool_wolinfo *wol) +{ +const u8 *mac_addr = dev->attached_dev->dev_addr; +int oldpage; + + oldpage =phy_save_page (dev); +if (oldpage <0 ) + goto err; + +if (wol->wolopts &WAKE_MAGIC ) { +/* Store the device address for the magic packet */ +rtl821x_write_page (dev,RTL8211F_PHYSICAL_ADDR_PAGE ); +__phy_write (dev,RTL8211F_PHYSICAL_ADDR_WORD0 , mac_addr[1 ] <<8 | (mac_addr[0 ])); +__phy_write (dev,RTL8211F_PHYSICAL_ADDR_WORD1 , mac_addr[3 ] <<8 | (mac_addr[2 ])); +__phy_write (dev,RTL8211F_PHYSICAL_ADDR_WORD2 , mac_addr[5 ] <<8 | (mac_addr[4 ])); + +/* Enable magic packet matching and reset WOL status */ +rtl821x_write_page (dev,RTL8211F_WOL_SETTINGS_PAGE ); +__phy_write (dev,RTL8211F_WOL_SETTINGS_EVENTS ,RTL8211F_WOL_EVENT_MAGIC ); +__phy_write (dev,RTL8211F_WOL_SETTINGS_STATUS ,RTL8211F_WOL_STATUS_RESET ); + +/* Enable the WOL interrupt */ +rtl821x_write_page (dev,RTL8211F_INTBCR_PAGE ); +__phy_set_bits (dev,RTL8211F_INTBCR ,RTL8211F_INTBCR_INTB_PMEB ); + }else { +/* Disable the WOL interrupt */ +rtl821x_write_page (dev,RTL8211F_INTBCR_PAGE ); +__phy_clear_bits (dev,RTL8211F_INTBCR ,RTL8211F_INTBCR_INTB_PMEB ); + +/* Disable magic packet matching and reset WOL status */ +rtl821x_write_page (dev,RTL8211F_WOL_SETTINGS_PAGE ); +__phy_write (dev,RTL8211F_WOL_SETTINGS_EVENTS ,0 ); +__phy_write (dev,RTL8211F_WOL_SETTINGS_STATUS ,RTL8211F_WOL_STATUS_RESET ); + } + +err: +return phy_restore_page (dev, oldpage,0 ); +} +static int rtl8211_config_aneg (struct phy_device *phydev) {int ret;
@@ -1349,6 +1416,8 @@ static struct phy_driver realtek_drvs[] = { .read_status = rtlgen_read_status, .config_intr = &rtl8211f_config_intr, .handle_interrupt = rtl8211f_handle_interrupt, + .set_wol = rtl8211f_set_wol, + .get_wol = rtl8211f_get_wol, .suspend = rtl821x_suspend, .resume = rtl821x_resume, .read_page = rtl821x_read_page,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1446/1756 net: phy: realtek: add RTL8211F register defines
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Klein <[email protected]>
[ Upstream commit 12d40df259e38851a0d973535e6023b33e2ea4f9 ]
Add some more defines for RTL8211F page and register numbers.
Stable-dep-of: 20c0c6773624 ("net: phy: realtek: restore RTL8211F RGMII delays on resume")
--- drivers/net/phy/realtek/realtek_main.c | 34 ++++++++++++++++++-------- 1 file changed, 24 insertions(+), 10 deletions(-)
drivers/net/phy/realtek/realtek_main.c +24 -10
@@ -30,11 +30,14 @@#define RTL821x_EXT_PAGE_SELECT 0x1e#define RTL821x_PAGE_SELECT 0x1f +/* RTL8211F PHY configuration */ +#define RTL8211F_PHYCR_PAGE 0xa43#define RTL8211F_PHYCR1 0x18#define RTL8211F_PHYCR2 0x19#define RTL8211F_CLKOUT_EN BIT(0)#define RTL8211F_PHYCR2_PHY_EEE_ENABLE BIT(5) +#define RTL8211F_INSR_PAGE 0xa43#define RTL8211F_INSR 0x1d/* RTL8211F WOL interrupt configuration */
@@ -55,6 +58,8 @@#define RTL8211F_PHYSICAL_ADDR_WORD1 17#define RTL8211F_PHYSICAL_ADDR_WORD2 18 +/* RTL8211F LED configuration */ +#define RTL8211F_LEDCR_PAGE 0xd04#define RTL8211F_LEDCR 0x10#define RTL8211F_LEDCR_MODE BIT(15)#define RTL8211F_LEDCR_ACT_TXRX BIT(4)
@@ -64,7 +69,13 @@#define RTL8211F_LEDCR_MASK GENMASK(4, 0)#define RTL8211F_LEDCR_SHIFT 5 +/* RTL8211F RGMII configuration */ +#define RTL8211F_RGMII_PAGE 0xd08 + +#define RTL8211F_TXCR 0x11#define RTL8211F_TX_DELAY BIT(8) + +#define RTL8211F_RXCR 0x15#define RTL8211F_RX_DELAY BIT(3)#define RTL8211F_ALDPS_PLL_OFF BIT(1)
@@ -158,7 +169,7 @@ static int rtl821x_probe(struct phy_device *phydev)return dev_err_probe (dev,PTR_ERR (priv->clk),"failed to get phy clock\n" ); - ret =phy_read_paged (phydev,0xa43 ,RTL8211F_PHYCR1 ); + ret =phy_read_paged (phydev,RTL8211F_PHYCR_PAGE ,RTL8211F_PHYCR1 );if (ret <0 )return ret;
@@ -168,7 +179,7 @@ static int rtl821x_probe(struct phy_device *phydev) priv->has_phycr2 = !(phy_id ==RTL_8211FVD_PHYID );if (priv->has_phycr2) { - ret =phy_read_paged (phydev,0xa43 ,RTL8211F_PHYCR2 ); + ret =phy_read_paged (phydev,RTL8211F_PHYCR_PAGE ,RTL8211F_PHYCR2 );if (ret <0 )return ret;
@@ -204,7 +215,7 @@ static int rtl8211f_ack_interrupt(struct phy_device *phydev) {int err; - err =phy_read_paged (phydev,0xa43 ,RTL8211F_INSR ); + err =phy_read_paged (phydev,RTL8211F_INSR_PAGE ,RTL8211F_INSR );return (err <0 ) ? err :0 ; }
@@ -347,7 +358,7 @@ static irqreturn_t rtl8211f_handle_interrupt(struct phy_device *phydev) {int irq_status; - irq_status =phy_read_paged (phydev,0xa43 ,RTL8211F_INSR ); + irq_status =phy_read_paged (phydev,RTL8211F_INSR_PAGE ,RTL8211F_INSR );if (irq_status <0 ) {phy_error (phydev);return IRQ_NONE ;
@@ -444,7 +455,7 @@ static int rtl8211f_config_init(struct phy_device *phydev)u16 val_txdly, val_rxdly;int ret; - ret =phy_modify_paged_changed (phydev,0xa43 ,RTL8211F_PHYCR1 , + ret =phy_modify_paged_changed (phydev,RTL8211F_PHYCR_PAGE ,RTL8211F_PHYCR1 ,RTL8211F_ALDPS_PLL_OFF |RTL8211F_ALDPS_ENABLE |RTL8211F_ALDPS_XTAL_OFF , priv->phycr1);if (ret <0 ) {
@@ -478,7 +489,8 @@ static int rtl8211f_config_init(struct phy_device *phydev)return 0 ; } - ret =phy_modify_paged_changed (phydev,0xd08 ,0x11 ,RTL8211F_TX_DELAY , + ret =phy_modify_paged_changed (phydev,RTL8211F_RGMII_PAGE , +RTL8211F_TXCR ,RTL8211F_TX_DELAY , val_txdly);if (ret <0 ) {dev_err (dev,"Failed to update the TX delay register\n" );
@@ -493,7 +505,8 @@ static int rtl8211f_config_init(struct phy_device *phydev) str_enabled_disabled(val_txdly)); } - ret =phy_modify_paged_changed (phydev,0xd08 ,0x15 ,RTL8211F_RX_DELAY , + ret =phy_modify_paged_changed (phydev,RTL8211F_RGMII_PAGE , +RTL8211F_RXCR ,RTL8211F_RX_DELAY , val_rxdly);if (ret <0 ) {dev_err (dev,"Failed to update the RX delay register\n" );
@@ -509,14 +522,15 @@ static int rtl8211f_config_init(struct phy_device *phydev) }/* Disable PHY-mode EEE so LPI is passed to the MAC */ - ret =phy_modify_paged (phydev,0xa43 ,RTL8211F_PHYCR2 , + ret =phy_modify_paged (phydev,RTL8211F_PHYCR_PAGE ,RTL8211F_PHYCR2 ,RTL8211F_PHYCR2_PHY_EEE_ENABLE ,0 );if (ret)return ret;if (priv->has_phycr2) { - ret =phy_modify_paged (phydev,0xa43 ,RTL8211F_PHYCR2 , -RTL8211F_CLKOUT_EN , priv->phycr2); + ret =phy_modify_paged (phydev,RTL8211F_PHYCR_PAGE , +RTL8211F_PHYCR2 ,RTL8211F_CLKOUT_EN , + priv->phycr2);if (ret <0 ) {dev_err (dev,"clkout configuration failed: %pe\n" ,ERR_PTR (ret));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1447/1756 net: phy: realtek: Avoid PHYCR2 access if PHYCR2 not present
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Vasut <[email protected]>
[ Upstream commit 2c67301584f2671e320236df6bbe75ae09feb4d0 ]
The driver is currently checking for PHYCR2 register presence in rtl8211f_config_init(), but it does so after accessing PHYCR2 to disable EEE. This was introduced in commit bfc17c165835 ("net:
phy: realtek: disable PHY-mode EEE"). Move the PHYCR2 presence test before the EEE disablement and simplify the code.
Stable-dep-of: 20c0c6773624 ("net: phy: realtek: restore RTL8211F RGMII delays on resume")
--- drivers/net/phy/realtek/realtek_main.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
drivers/net/phy/realtek/realtek_main.c +11 -12
@@ -521,26 +521,25 @@ static int rtl8211f_config_init(struct phy_device *phydev) str_enabled_disabled(val_rxdly)); } +if (!priv->has_phycr2) +return 0 ; +/* Disable PHY-mode EEE so LPI is passed to the MAC */ ret =phy_modify_paged (phydev,RTL8211F_PHYCR_PAGE ,RTL8211F_PHYCR2 ,RTL8211F_PHYCR2_PHY_EEE_ENABLE ,0 );if (ret)return ret; -if (priv->has_phycr2) { - ret =phy_modify_paged (phydev,RTL8211F_PHYCR_PAGE , -RTL8211F_PHYCR2 ,RTL8211F_CLKOUT_EN , - priv->phycr2); -if (ret <0 ) { -dev_err (dev,"clkout configuration failed: %pe\n" , -ERR_PTR (ret)); -return ret; - } - -return genphy_soft_reset (phydev); + ret =phy_modify_paged (phydev,RTL8211F_PHYCR_PAGE , +RTL8211F_PHYCR2 ,RTL8211F_CLKOUT_EN , + priv->phycr2); +if (ret <0 ) { +dev_err (dev,"clkout configuration failed: %pe\n" , +ERR_PTR (ret)); +return ret; } -return 0 ; +return genphy_soft_reset (phydev); }static int rtl821x_suspend (struct phy_device *phydev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1448/1756 net: phy: realtek: create rtl8211f_config_rgmii_delay()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Oltean <[email protected]>
[ Upstream commit 8e982441ba601d982dd0739972115d85ae01d99b ]
The control flow in rtl8211f_config_init() has some pitfalls which were probably unintended. Specifically it has an early return:
switch (phydev->interface) {
...
default: /* the rest of the modes imply leaving delay as is. */
return 0;
}which exits the entire config_init() function. This means it also skips doing things such as disabling CLKOUT or disabling PHY-mode EEE.
For the RTL8211FS, which uses PHY_INTERFACE_MODE_SGMII, this might be a problem. However, I don't know that it is, so there is no Fixes: tag. The issue was observed through code inspection.
Stable-dep-of: 20c0c6773624 ("net: phy: realtek: restore RTL8211F RGMII delays on resume")
--- drivers/net/phy/realtek/realtek_main.c | 65 +++++++++++++++----------- 1 file changed, 39 insertions(+), 26 deletions(-)
drivers/net/phy/realtek/realtek_main.c +39 -26
@@ -448,22 +448,11 @@ static int rtl8211c_config_init(struct phy_device *phydev) CTL1000_ENABLE_MASTER | CTL1000_AS_MASTER); } -static int rtl8211f_config_init (struct phy_device *phydev) +static int rtl8211f_config_rgmii_delay (struct phy_device *phydev) { -struct rtl821x_priv *priv = phydev->priv; -struct device *dev = &phydev->mdio.dev;u16 val_txdly, val_rxdly;int ret; - ret =phy_modify_paged_changed (phydev,RTL8211F_PHYCR_PAGE ,RTL8211F_PHYCR1 , -RTL8211F_ALDPS_PLL_OFF |RTL8211F_ALDPS_ENABLE |RTL8211F_ALDPS_XTAL_OFF , - priv->phycr1); -if (ret <0 ) { -dev_err (dev,"aldps mode configuration failed: %pe\n" , -ERR_PTR (ret)); -return ret; - } -switch (phydev->interface) {case PHY_INTERFACE_MODE_RGMII : val_txdly =0 ;
@@ -493,34 +482,58 @@ static int rtl8211f_config_init(struct phy_device *phydev)RTL8211F_TXCR ,RTL8211F_TX_DELAY , val_txdly);if (ret <0 ) { -dev_err (dev,"Failed to update the TX delay register\n" ); +phydev_err (phydev,"Failed to update the TX delay register: %pe\n" , +ERR_PTR (ret));return ret; }else if (ret) { -dev_dbg (dev, -"%s 2ns TX delay (and changing the value from pin-strapping RXD1 or the bootloader)\n" , -str_enable_disable (val_txdly)); +phydev_dbg (phydev, +"%s 2ns TX delay (and changing the value from pin-strapping RXD1 or the bootloader)\n" , +str_enable_disable (val_txdly)); }else { -dev_dbg (dev, -"2ns TX delay was already %s (by pin-strapping RXD1 or bootloader configuration)\n" , -str_enabled_disabled (val_txdly)); +phydev_dbg (phydev, +"2ns TX delay was already %s (by pin-strapping RXD1 or bootloader configuration)\n" , +str_enabled_disabled (val_txdly)); } ret =phy_modify_paged_changed (phydev,RTL8211F_RGMII_PAGE ,RTL8211F_RXCR ,RTL8211F_RX_DELAY , val_rxdly);if (ret <0 ) { -dev_err (dev,"Failed to update the RX delay register\n" ); +phydev_err (phydev,"Failed to update the RX delay register: %pe\n" , +ERR_PTR (ret));return ret; }else if (ret) { -dev_dbg (dev, -"%s 2ns RX delay (and changing the value from pin-strapping RXD0 or the bootloader)\n" , -str_enable_disable (val_rxdly)); +phydev_dbg (phydev, +"%s 2ns RX delay (and changing the value from pin-strapping RXD0 or the bootloader)\n" , +str_enable_disable (val_rxdly)); }else { -dev_dbg (dev, -"2ns RX delay was already %s (by pin-strapping RXD0 or bootloader configuration)\n" , -str_enabled_disabled (val_rxdly)); +phydev_dbg (phydev, +"2ns RX delay was already %s (by pin-strapping RXD0 or bootloader configuration)\n" , +str_enabled_disabled (val_rxdly)); } +return 0 ; +} + +static int rtl8211f_config_init (struct phy_device *phydev) +{ +struct rtl821x_priv *priv = phydev->priv; +struct device *dev = &phydev->mdio.dev; +int ret; + + ret =phy_modify_paged_changed (phydev,RTL8211F_PHYCR_PAGE ,RTL8211F_PHYCR1 , +RTL8211F_ALDPS_PLL_OFF |RTL8211F_ALDPS_ENABLE |RTL8211F_ALDPS_XTAL_OFF , + priv->phycr1); +if (ret <0 ) { +dev_err (dev,"aldps mode configuration failed: %pe\n" , +ERR_PTR (ret)); +return ret; + } + + ret =rtl8211f_config_rgmii_delay (phydev); +if (ret) +return ret; +if (!priv->has_phycr2)return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1449/1756 net: phy: realtek: restore RTL8211F RGMII delays on resume
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 20c0c677362468b0af23e26e5fdb871ea911bc25 ]
RTL8211F and RTL8211F-VD both use rtl8211f_config_rgmii_delay() during initialization and share rtl821x_resume(). The RTL8211F-VD loses its RGMII TX and RX delay enable bits across a software power-down, but the shared resume path only clears BMCR_PDOWN and waits for the receive clock to stabilize.
On a BeagleV Ahead configured for rgmii-id, carrier and the negotiated speed return after an interface close/open, but the receive path does not work. At 100 Mbit/s no frames were received. At 1000 Mbit/s all 11 observed frames had CRC errors.
Reapply the RGMII delay configuration after the existing resume delay.
Tested on a BeagleV Ahead with an RTL8211F-VD at 100 and 1000 Mbit/s, including close/open without a link partner.
--- drivers/net/phy/realtek/realtek_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/realtek/realtek_main.c +1 -1
@@ -586,7 +586,7 @@ static int rtl821x_resume(struct phy_device *phydev)msleep (20 ); -return 0 ; +return rtl8211f_config_rgmii_delay (phydev); } static int rtl8211f_led_hw_is_supported(struct phy_device *phydev, u8 index,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1450/1756 net: hix5hd2: serialize timeout recovery with interface teardown
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 87cce46329a811ea3fe108ac721e0a2400d0a3bb ]
The timeout worker calls the driver's close and open methods without RTNL or a running-state check. A timeout queued before an interface is closed can call close again after ndo_stop has disabled NAPI. The second napi_disable() can then wait indefinitely. The worker can also race with an ongoing close.
Take RTNL and skip recovery when the interface is no longer running. Use the netdev core close and open helpers so a failed reopen leaves the interface down, rather than leaving it marked running with NAPI disabled.
After unregister_netdev() has stopped the watchdog, drain the worker before releasing its MDIO and descriptor resources. This wait is outside RTNL, allowing an already queued worker to take RTNL, observe the down state, and finish.
This issue was identified as part of our ongoing research while reviewing kernel code.
--- drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c +9 -3
@@ -12,6 +12,7 @@#include <linux/of_net.h> #include <linux/of_mdio.h> #include <linux/reset.h> +#include <linux/rtnetlink.h> #include <linux/clk.h> #include <linux/circ_buf.h>
@@ -890,8 +891,13 @@ static void hix5hd2_tx_timeout_task(struct work_struct *work)struct hix5hd2_priv *priv; priv = container_of(work, struct hix5hd2_priv, tx_timeout_task); -hix5hd2_net_close (priv->netdev); -hix5hd2_net_open (priv->netdev); + +rtnl_lock (); +if (netif_running (priv->netdev)) { +dev_close (priv->netdev); +dev_open (priv->netdev,NULL ); + } +rtnl_unlock (); }static void hix5hd2_net_timeout (struct net_device *dev,unsigned int txqueue)
@@ -1283,6 +1289,7 @@ static void hix5hd2_dev_remove(struct platform_device *pdev)struct hix5hd2_priv *priv =netdev_priv (ndev);unregister_netdev (ndev); +cancel_work_sync (&priv->tx_timeout_task);mdiobus_unregister (priv->bus);mdiobus_free (priv->bus);
@@ -1290,7 +1297,6 @@ static void hix5hd2_dev_remove(struct platform_device *pdev)hix5hd2_destroy_sg_desc_queue (priv);hix5hd2_destroy_hw_desc_queue (priv);of_node_put (priv->phy_node); -cancel_work_sync (&priv->tx_timeout_task);free_netdev (ndev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1451/1756 net: bcmasp: fix mib counters struct alignment with ethtool stats
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit db45c15c98134f5ebd13c4dc5b6be5d1cd3fc706 ]
When EDPKT stats were removed in commit e9f31435ee7d ("net: bcmasp: Add support for asp-v3.0"), the corresponding entries were removed from bcmasp_gstrings_stats in bcmasp_ethtool.c, but the edpkt_* fields were left at the beginning of struct bcmasp_mib_counters in bcmasp.h.
Because bcmasp_update_mib_counters() and bcmasp_get_ethtool_stats() index into struct bcmasp_mib_counters sequentially based on the order of bcmasp_gstrings_stats, this 16-byte offset caused ethtool to read from shifted offsets: the first four software counters read unused fields and reported 0, the next four software counters reported the values of alloc_rx_skb_failed, tx_dma_failed, mc_filters_full_cnt, and uc_filters_full_cnt, while filters_combine_cnt, promisc_filters_cnt, tx_realloc_offload_failed, and tx_timeout_cnt were never reported.
Remove the obsolete edpkt_* fields from struct bcmasp_mib_counters so that it aligns with bcmasp_gstrings_stats.
--- drivers/net/ethernet/broadcom/asp2/bcmasp.h | 4 ---- 1 file changed, 4 deletions(-)
drivers/net/ethernet/broadcom/asp2/bcmasp.h +0 -4
@@ -249,10 +249,6 @@ struct bcmasp_intf_stats64 { };struct bcmasp_mib_counters { -u32 edpkt_ts; -u32 edpkt_rx_pkt_cnt; -u32 edpkt_hdr_ext_cnt; -u32 edpkt_hdr_out_cnt;u32 umac_frm_cnt;u32 fb_frm_cnt;u32 fb_rx_fifo_depth;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1452/1756 net: bcmasp: unmap previous DMA mappings on TX map failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit a3cf9877558ab2c51182af558815dde64fc17cb9 ]
When mapping an skb with fragments for transmission in bcmasp_xmit(), if mapping fails on fragment i > 0, the error handler calls bcmasp_clean_txcb() for previous iterations j < i. However, bcmasp_clean_txcb() only zeroes the control block fields without unmapping the DMA buffers, leaking the DMA mappings allocated for the head and earlier fragments.
Call dma_unmap_single() before calling bcmasp_clean_txcb() in the error cleanup loop.
--- drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +5 -0
@@ -317,6 +317,11 @@ static netdev_tx_t bcmasp_xmit(struct sk_buff *skb, struct net_device *dev) intf->mib.tx_dma_failed++; spb_index = intf->tx_spb_index;for (j =0 ; j < i; j++) { + txcb = &intf->tx_cbs[spb_index]; +dma_unmap_single (kdev, +dma_unmap_addr (txcb, dma_addr), +dma_unmap_len (txcb, dma_len), +DMA_TO_DEVICE );bcmasp_clean_txcb (intf, spb_index); spb_index =incr_ring (spb_index,DESC_RING_COUNT );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1453/1756 net: bcmasp: validate minimum RX packet size in bcmasp_rx_poll()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit 07b624d2f5a4517d7d0022fbd4aef17e884b5686 ]
In bcmasp_rx_poll(), the driver removes a 2-byte alignment pad and optionally strips the ETH_FCS_LEN CRC from received packets before passing them to eth_type_trans().
If the hardware reports a descriptor size smaller than the sum of the 2-byte pad, the Ethernet header (ETH_HLEN), and optional CRC (ETH_FCS_LEN), subtracting the pad and CRC lengths underflows u32 len. This adds ~4 GiB to rx_bytes statistics, while the undersized frame reaches eth_type_trans(), which reads past skb->len into stale buffer data.
Check that desc->size is at least (2 + ETH_HLEN + (crc_fwd ? ETH_FCS_LEN : 0)) before proceeding to process the descriptor.
--- drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +6 -0
@@ -560,6 +560,12 @@ static int bcmasp_rx_poll(struct napi_struct *napi, int budget) DMA_FROM_DEVICE); len = desc->size; +if (unlikely (len <2 +ETH_HLEN + (intf->crc_fwd ?ETH_FCS_LEN :0 ))) { +u64_stats_update_begin (&stats->syncp); +u64_stats_inc (&stats->rx_dropped); +u64_stats_update_end (&stats->syncp); + goto next; + } skb =napi_alloc_skb (napi, len);if (!skb) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1454/1756 net: bcmasp: fix OF node reference leak for phy_dn
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit a31623d91c6e48b08c74dc95567aeb62f1f35938 ]
In bcmasp_interface_create(), intf->phy_dn is obtained via of_parse_phandle() or assigned ndev_dn. of_parse_phandle() returns a node reference with its refcount incremented, but of_node_put() was never called on intf->phy_dn in bcmasp_interface_destroy() or the error unwind path in bcmasp_interface_create().
Acquire a reference on ndev_dn for the fixed-link case as well so that intf->phy_dn consistently holds a reference, and release it with of_node_put() on teardown and error.
--- drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +3 -1
@@ -1260,7 +1260,7 @@ struct bcmasp_intf *bcmasp_interface_create(struct bcmasp_priv *priv, ndev_dn->name); goto err_free_netdev; } - intf->phy_dn = ndev_dn; + intf->phy_dn =of_node_get (ndev_dn); }/* Map resource */
@@ -1299,6 +1299,7 @@ struct bcmasp_intf *bcmasp_interface_create(struct bcmasp_priv *priv, err_deregister_fixed_link:if (of_phy_is_fixed_link (ndev_dn))of_phy_deregister_fixed_link (ndev_dn); +of_node_put (intf->phy_dn); err_free_netdev:free_netdev (ndev); err:
@@ -1311,6 +1312,7 @@ void bcmasp_interface_destroy(struct bcmasp_intf *intf)unregister_netdev (intf->ndev);if (of_phy_is_fixed_link (intf->ndev_dn))of_phy_deregister_fixed_link (intf->ndev_dn); +of_node_put (intf->phy_dn);free_netdev (intf->ndev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1455/1756 net: bcmasp: account for offload header in TX short packet padding
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit 74667a55122ad2fad88af4fd7672e4c8175c2558 ]
When hardware checksum offload is enabled for an skb, bcmasp_csum_offload() prepends a struct bcmasp_pkt_offload header (20 bytes) to the skb via skb_push(). This increases skb->len and skb_headlen(skb) by sizeof(struct bcmasp_pkt_offload).
Because the hardware descriptor processor strips this offload header before transmitting the packet on the wire, the wire packet length is smaller by sizeof(struct bcmasp_pkt_offload). The padding calculation must account for this extra header; otherwise, short frames are sent on the wire smaller than the minimum Ethernet frame size (ETH_ZLEN + ETH_FCS_LEN).
Furthermore, small frames with payload in page fragments (such as small TCP segments with CHECKSUM_PARTIAL) have nr_frags > 0 and were skipping padding entirely because the padding check was restricted to nr_frags == 0.
Perform the padding check on skb->len before the descriptor loop using skb_put_padto(), adding sizeof(struct bcmasp_pkt_offload) to min_size when checksum offload is enabled, and re-read nr_frags after padding in case the skb was linearized.
--- .../net/ethernet/broadcom/asp2/bcmasp_intf.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +11 -6
@@ -268,7 +268,7 @@ static const struct bcmasp_intf_ops bcmasp_intf_ops = {static netdev_tx_t bcmasp_xmit (struct sk_buff *skb,struct net_device *dev) {struct bcmasp_intf *intf =netdev_priv (dev); -unsigned int total_bytes, size; +unsigned int total_bytes, size, min_size;int spb_index, nr_frags, i, j;struct bcmasp_tx_cb *txcb;dma_addr_t mapping, valid;
@@ -294,16 +294,21 @@ static netdev_tx_t bcmasp_xmit(struct sk_buff *skb, struct net_device *dev)if (!skb)return NETDEV_TX_OK ; + min_size =ETH_ZLEN +ETH_FCS_LEN ; +if (csum_hw) + min_size +=sizeof (struct bcmasp_pkt_offload ); + +if (skb->len < min_size) { +if (skb_put_padto (skb, min_size)) +return NETDEV_TX_OK ; + nr_frags =skb_shinfo (skb)->nr_frags; + } + spb_index = intf->tx_spb_index; valid = intf->tx_spb_dma_valid;for (i =0 ; i <= nr_frags; i++) {if (!i) { size =skb_headlen (skb); -if (!nr_frags && size < (ETH_ZLEN +ETH_FCS_LEN )) { -if (skb_put_padto (skb,ETH_ZLEN +ETH_FCS_LEN )) -return NETDEV_TX_OK ; - size = skb->len; - } mapping =dma_map_single (kdev, skb->data, size,DMA_TO_DEVICE ); }else {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1456/1756 net: bcmasp: fix network filter lookup and wake filter pair allocation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit fa1459375794f14fb65039cd19c9398d759b491e ]
In bcmasp_netfilt_get_init(), when looking up an existing filter (!init) for a specified location, if the filter at loc was not claimed, the previous loop continued searching higher indices and could return an arbitrary unrelated filter belonging to the port. This caused flow get or delete operations on an empty rule location to return or delete an unintended filter.
Fix this by checking only the requested location on lookup and rejecting RX_CLS_LOC_ANY when !init. In addition, harden wake filter allocation and release by ensuring wake filter pair searches stay on even boundaries where both entries are free, checking that loc + 1 is free for positioned wake filters, and validating parity and bounds on release.
--- drivers/net/ethernet/broadcom/asp2/bcmasp.c | 121 +++++++++++--------- 1 file changed, 70 insertions(+), 51 deletions(-)
drivers/net/ethernet/broadcom/asp2/bcmasp.c +70 -51
@@ -511,6 +511,13 @@ static int bcmasp_netfilt_wr_to_hw(struct bcmasp_priv *priv,return 0 ; } +static bool bcmasp_netfilt_is_companion (struct bcmasp_priv *priv,int i) +{ +return i >0 && (i %2 ) && + priv->net_filters[i].wake_filter && + priv->net_filters[i -1 ].wake_filter; +} +void bcmasp_netfilt_suspend (struct bcmasp_intf *intf) {struct bcmasp_priv *priv = intf->parent;
@@ -524,9 +531,7 @@ void bcmasp_netfilt_suspend(struct bcmasp_intf *intf) priv->net_filters[i].port != intf->port)continue ; -if (i >0 && (i %2 ) && - priv->net_filters[i].wake_filter && - priv->net_filters[i -1 ].wake_filter) +if (bcmasp_netfilt_is_companion (priv, i))continue ; ret =bcmasp_netfilt_wr_to_hw (priv, &priv->net_filters[i]);
@@ -556,9 +561,7 @@ int bcmasp_netfilt_get_all_active(struct bcmasp_intf *intf, u32 *rule_locs, priv->net_filters[i].port != intf->port)continue ; -if (i >0 && (i %2 ) && - priv->net_filters[i].wake_filter && - priv->net_filters[i -1 ].wake_filter) +if (bcmasp_netfilt_is_companion (priv, i))continue ;if (j == *rule_cnt)
@@ -583,9 +586,7 @@ int bcmasp_netfilt_get_active(struct bcmasp_intf *intf)continue ;/* Skip over a wake filter pair */ -if (i >0 && (i %2 ) && - priv->net_filters[i].wake_filter && - priv->net_filters[i -1 ].wake_filter) +if (bcmasp_netfilt_is_companion (priv, i))continue ; cnt++;
@@ -607,6 +608,9 @@ bool bcmasp_netfilt_check_dup(struct bcmasp_intf *intf, priv->net_filters[i].port != intf->port)continue ; +if (bcmasp_netfilt_is_companion (priv, i)) +continue ; + cur = &priv->net_filters[i].fs; if (cur->flow_type != fs->flow_type ||
@@ -659,7 +663,7 @@ bool bcmasp_netfilt_check_dup(struct bcmasp_intf *intf, }/* If no network filter found, return open filter. -* If no more open filters return NULL +* If no more open filters return error. */ struct bcmasp_net_filter *bcmasp_netfilt_get_init(struct bcmasp_intf *intf, u32 loc, bool wake_filter,
@@ -669,45 +673,55 @@ struct bcmasp_net_filter *bcmasp_netfilt_get_init(struct bcmasp_intf *intf,struct bcmasp_priv *priv = intf->parent;int i, open_index =-1 ; -/* Check whether we exceed the filter table capacity */ +if (!init) { +if (loc ==RX_CLS_LOC_ANY || loc >= priv->num_net_filters) +return ERR_PTR (-EINVAL ); + +if (priv->net_filters[loc].claimed && + priv->net_filters[loc].port == intf->port && + !bcmasp_netfilt_is_companion (priv, loc)) +return &priv->net_filters[loc]; + +return ERR_PTR (-ENOENT ); + } +if (loc !=RX_CLS_LOC_ANY && loc >= priv->num_net_filters)return ERR_PTR (-EINVAL );/* If the filter location is busy (already claimed) and we are initializing * the filter (insertion), return a busy error code. */ -if (loc !=RX_CLS_LOC_ANY && init && priv->net_filters[loc].claimed) -return ERR_PTR (-EBUSY ); - -/* We need two filters for wake-up, so we cannot use an odd filter */ -if (wake_filter && loc !=RX_CLS_LOC_ANY && (loc %2 )) -return ERR_PTR (-EINVAL ); - -/* Initialize the loop index based on the desired location or from 0 */ - i = loc ==RX_CLS_LOC_ANY ?0 : loc; - -for ( ; i < priv->num_net_filters; i++) { -/* Found matching network filter */ -if (!init && - priv->net_filters[i].claimed && - priv->net_filters[i].hw_index == i && - priv->net_filters[i].port == intf->port) -return &priv->net_filters[i]; - -/* If we don't need a new filter or new filter already found */ -if (!init || open_index >=0 ) -continue ; - -/* Wake filter conslidates two filters to cover more bytes -* Wake filter is open if... -* 1. It is an even filter -* 2. The current and next filter is not claimed -*/ -if (wake_filter && !(i %2 ) && !priv->net_filters[i].claimed && - !priv->net_filters[i +1 ].claimed) - open_index = i; -else if (!priv->net_filters[i].claimed) - open_index = i; +if (loc !=RX_CLS_LOC_ANY ) { +if (priv->net_filters[loc].claimed) +return ERR_PTR (-EBUSY ); + +/* We need two filters for wake-up, so we cannot use an odd filter */ +if (wake_filter) { +if ((loc %2 ) || loc +1 >= priv->num_net_filters) +return ERR_PTR (-EINVAL ); +if (priv->net_filters[loc +1 ].claimed) +return ERR_PTR (-EBUSY ); + } + open_index = loc; + }else { +for (i =0 ; i < priv->num_net_filters; i++) { +/* Wake filter consolidates two filters to cover more bytes. +* Wake filter is open if: +* 1. It is an even filter +* 2. The current and next filter is not claimed +*/ +if (wake_filter) { +if (!(i %2 ) && (i +1 < priv->num_net_filters) && + !priv->net_filters[i].claimed && + !priv->net_filters[i +1 ].claimed) { + open_index = i; +break ; + } + }else if (!priv->net_filters[i].claimed) { + open_index = i; +break ; + } + } }if (open_index >=0 ) {
@@ -716,16 +730,20 @@ struct bcmasp_net_filter *bcmasp_netfilt_get_init(struct bcmasp_intf *intf, nfilter->port = intf->port; nfilter->ch = intf->channel + priv->tx_chan_offset; nfilter->hw_index = open_index; - } -if (wake_filter && open_index >=0 ) { -/* Claim next filter */ - priv->net_filters[open_index +1 ].claimed = true; - priv->net_filters[open_index +1 ].wake_filter = true; - nfilter->wake_filter = true; +if (wake_filter) { +/* Claim next filter */ + priv->net_filters[open_index +1 ].claimed = true; + priv->net_filters[open_index +1 ].wake_filter = true; + priv->net_filters[open_index +1 ].hw_index = open_index +1 ; + priv->net_filters[open_index +1 ].port = intf->port; + priv->net_filters[open_index +1 ].ch = intf->channel + + priv->tx_chan_offset; + nfilter->wake_filter = true; + } } -return nfilter ? nfilter :ERR_PTR (-EINVAL ); +return nfilter ? nfilter :ERR_PTR (-ENOSPC ); } void bcmasp_netfilt_release(struct bcmasp_intf *intf,
@@ -733,7 +751,8 @@ void bcmasp_netfilt_release(struct bcmasp_intf *intf, {struct bcmasp_priv *priv = intf->parent; -if (nfilt->wake_filter) { +if (nfilt->wake_filter && !(nfilt->hw_index %2 ) && + nfilt->hw_index +1 < priv->num_net_filters) {memset (&priv->net_filters[nfilt->hw_index +1 ],0 ,sizeof (struct bcmasp_net_filter )); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1457/1756 bridge: mcast: Delete empty MDB entry when port group creation fails
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
[ Upstream commit 1d0590f96fa4133578b7370ea9ce1d871f6bfc21 ]
When a port group cannot be created for a new group, the MDB entry that was created for it is left with no ports and is not joined by the host. Its timer is never armed, so the entry is never deleted, but it is counted towards mcast_hash_max. When this maximum is reached, the bridge disables multicast snooping.
Since commit b57e8d870d52 ("net: bridge: Maintain number of MDB entries in net_bridge_mcast_port"), port group creation also fails when the port reached its mcast_max_groups limit. A host behind such a port can therefore disable snooping by sending reports for new groups, which is what the limit is meant to prevent. The RTM_NEWMDB path has the same problem.
Fix by deleting the entry after a failure if it is unused. Delete it immediately rather than arming its timer, so that it stops counting towards the maximum right away.
--- net/bridge/br_mdb.c | 16 +++++++++++++--- net/bridge/br_multicast.c | 9 +++++++++ net/bridge/br_private.h | 1 + 3 files changed, 23 insertions(+), 3 deletions(-)
net/bridge/br_mdb.c +13 -3
@@ -801,6 +801,7 @@ static int br_mdb_add_group_src_fwd(const struct br_mdb_config *cfg,struct br_mdb_config sg_cfg;struct br_ip sg_ip;u8 flags =0 ; +int err; sg_ip = cfg->group; sg_ip.src = src_ip->src;
@@ -824,7 +825,11 @@ static int br_mdb_add_group_src_fwd(const struct br_mdb_config *cfg, sg_cfg.filter_mode =MCAST_INCLUDE ; sg_cfg.rt_protocol = cfg->rt_protocol; sg_cfg.nlflags = cfg->nlflags; -return br_mdb_add_group_sg (&sg_cfg, sgmp, brmctx, flags, extack); + err =br_mdb_add_group_sg (&sg_cfg, sgmp, brmctx, flags, extack); +if (err) +br_multicast_del_group (sgmp); + +return err; } static int br_mdb_add_group_src(const struct br_mdb_config *cfg,
@@ -1029,6 +1034,7 @@ static int br_mdb_add_group(const struct br_mdb_config *cfg,struct net_bridge_mcast *brmctx;struct br_ip group = cfg->group;unsigned char flags =0 ; +int err; brmctx =__br_mdb_choose_context (br, entry, extack);if (!brmctx)
@@ -1055,9 +1061,13 @@ static int br_mdb_add_group(const struct br_mdb_config *cfg, flags |=MDB_PG_FLAGS_PERMANENT ;if (br_multicast_is_star_g (&group)) -return br_mdb_add_group_star_g (cfg, mp, brmctx, flags, extack); + err =br_mdb_add_group_star_g (cfg, mp, brmctx, flags, extack);else -return br_mdb_add_group_sg (cfg, mp, brmctx, flags, extack); + err =br_mdb_add_group_sg (cfg, mp, brmctx, flags, extack); +if (err) +br_multicast_del_group (mp); + +return err; } static int __br_mdb_add(const struct br_mdb_config *cfg,
net/bridge/br_multicast.c +9 -0
@@ -647,6 +647,14 @@ static void br_multicast_del_mdb_entry(struct net_bridge_mdb_entry *mp)queue_work (system_long_wq, &br->mcast_gc_work); } +void br_multicast_del_group (struct net_bridge_mdb_entry *mp) +{ +if (mp->ports || mp->host_joined) +return ; + +br_multicast_del_mdb_entry (mp); +} +static void br_multicast_group_expired (struct timer_list *t) {struct net_bridge_mdb_entry *mp =from_timer (mp, t, timer);
@@ -1561,6 +1569,7 @@ __br_multicast_add_group(struct net_bridge_mcast *brmctx, p =br_multicast_new_port_group (pmctx->port, group, *pp,0 , src, filter_mode,RTPROT_KERNEL ,NULL );if (unlikely (!p)) { +br_multicast_del_group (mp); p =ERR_PTR (-ENOMEM ); goto out; }
net/bridge/br_private.h +1 -0
@@ -985,6 +985,7 @@ struct net_bridge_mdb_entry * br_mdb_ip_get(struct net_bridge *br, struct br_ip *dst);struct net_bridge_mdb_entry *br_multicast_new_group (struct net_bridge *br,struct br_ip *group); +void br_multicast_del_group (struct net_bridge_mdb_entry *mp);struct net_bridge_port_group * br_multicast_new_port_group(struct net_bridge_port *port, const struct br_ip *group,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1458/1756 net: axienet: release every RX buffer in axienet_dma_bd_release()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sagi Maimon <[email protected]>
[ Upstream commit b59787892d04a5647a7e662fbb02cd0abdb1a993 ]
The RX walk in axienet_dma_bd_release() stops at the first descriptor without an skb, assuming that such a slot and all after it were never filled. That holds on the axienet_dma_bd_init() error path, but not once the ring has been running: when axienet_rx_poll() fails to allocate or map a replacement buffer it leaves the slot it emptied with a NULL skb, in the middle of a populated ring, until a later poll refills it. Closing the interface before then leaks the skb and the streaming DMA mapping of every descriptor after that slot, which can be most of the ring, and is most likely under memory pressure.
The walk also frees each skb before unmapping it. With swiotlb, the DMA_FROM_DEVICE unmap copies the bounce buffer back into the skb data that was just freed, and on non-coherent platforms it invalidates cache lines that may already belong to a new owner.
Skip empty slots instead of stopping at the first one. An emptied slot still has a non-zero cntrl but its buffer is already unmapped, so the skip has to cover the unmap too, which it does by coming before it. Then unmap before freeing, as axienet_rx_poll() does.
This was reported by the Sashiko AI review bot.
Tested on the AXI Ethernet MAC of an ADVA TimeCard X2 (PCIe card, with the built-in AXI DMA): traffic passes after each of ten down/up cycles, each running axienet_dma_bd_release(), so the unmap-then-free order is exercised on every buffer. A failed RX refill was not reproduced, so the skip over an empty slot was not exercised.
--- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +7 -5
@@ -245,13 +245,13 @@ static void axienet_dma_bd_release(struct net_device *ndev)for (i =0 ; i < lp->rx_bd_num; i++) {dma_addr_t phys; -/* A NULL skb means this descriptor has not been initialised -* at all. +/* A NULL skb means the descriptor holds no buffer: it was +* never filled, or axienet_rx_poll() took its skb and could +* not refill it, having already unmapped the old buffer. +* Such slots can sit anywhere in a ring that has been running. */ if (!lp->rx_bd_v[i].skb) -break ; - -dev_kfree_skb (lp->rx_bd_v[i].skb); +continue ;/* For each descriptor, we programmed cntrl with the (non-zero) * descriptor size, after it had been successfully allocated.
@@ -262,6 +262,8 @@ static void axienet_dma_bd_release(struct net_device *ndev)dma_unmap_single (lp->dev, phys, lp->max_frm_size,DMA_FROM_DEVICE ); } + +dev_kfree_skb (lp->rx_bd_v[i].skb); } dma_free_coherent(lp->dev,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1459/1756 ipv6: account route exceptions to the netns of their dst
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 8ff017b891e89276c15f06dfd7155981d572af77 ]
rt6_insert_exception() and rt6_remove_exception() update rt6_stats->fib_rt_cache of dev_net(rt6i->dst.dev), but the device of an exception dst can move to another netns while the exception is still in its bucket.
This happens when the bucket is flushed from an RCU callback, for instance from nexthop_free_rcu() for the nh_info of a replaced nexthop, whose exceptions still point to live routes. If the device moves to another netns before that callback runs, the decrement hits the other netns, whose u32 counter underflows in /proc/net/rt6_stats, while the counter of the original netns never goes back down.
Account exceptions to the netns their dst was allocated in, derived from dst->ops as ip6_dst_gc() already does, which does not depend on the device. The dst already relies on that netns' ip6_dst_ops being alive when it is destroyed, which happens after the exception is removed.
--- net/ipv6/route.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
net/ipv6/route.c +11 -2
@@ -1503,6 +1503,15 @@ static struct rt6_info *rt6_make_pcpu_route(struct net *net,*/ static DEFINE_SPINLOCK (rt6_exception_lock); +/* Exceptions are accounted to the netns their dst was allocated in. +* Unlike dev_net(dst->dev), it does not change when the device moves to +* another netns or when dst_dev_put() points the dst to blackhole_netdev. +*/ +static struct net *rt6_exception_net (const struct rt6_info *rt) +{ + return container_of(rt->dst.ops, struct net, ipv6.ip6_dst_ops); +} +/* Remove rt6_ex from hash table and free the memory * Caller must hold rt6_exception_lock */
@@ -1514,7 +1523,7 @@ static void rt6_remove_exception(struct rt6_exception_bucket *bucket,if (!bucket || !rt6_ex)return ; - net =dev_net (rt6_ex->rt6i->dst.dev); + net =rt6_exception_net (rt6_ex->rt6i); net->ipv6.rt6_stats->fib_rt_cache--;/* purge completely the exception to allow releasing the held resources:
@@ -1774,7 +1783,7 @@ static int rt6_insert_exception(struct rt6_info *nrt, rt6_ex->stamp = jiffies;hlist_add_head_rcu (&rt6_ex->hlist, &bucket->chain); bucket->depth++; - net->ipv6.rt6_stats->fib_rt_cache++; +rt6_exception_net (nrt)->ipv6.rt6_stats->fib_rt_cache++;/* Randomize max depth to avoid some side channels attacks. */ max_depth =FIB6_MAX_DEPTH +get_random_u32_below (FIB6_MAX_DEPTH );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1460/1756 platform/x86: gpd pocket fan: Cancel work before releasing GPIOs
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 9962770049c715fc30a7b3274d8f245167c0a410 ]
The fan worker changes the direction of both GPIOs and schedules its next run. Its managed cancellation action is registered before the GPIOs are acquired, so devres releases the GPIOs before cancelling the work. A running worker can therefore change a GPIO after the driver has released it.
Register the work cancellation action after both GPIO acquisitions. This makes devres cancel and drain the worker before releasing either GPIO. No work has been queued yet if GPIO acquisition or action registration fails.
This issue was identified as part of our ongoing research while reviewing kernel code.
--- drivers/platform/x86/gpd-pocket-fan.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/platform/x86/gpd-pocket-fan.c +5 -4
@@ -153,10 +153,6 @@ static int gpd_pocket_fan_probe(struct platform_device *pdev)return -ENOMEM ; fan->dev = &pdev->dev; - ret =devm_delayed_work_autocancel (&pdev->dev, &fan->work, - gpd_pocket_fan_worker); -if (ret) -return ret;/* Note this returns a "weak" reference which we don't need to free */ fan->dts0 =thermal_zone_get_zone_by_name ("soc_dts0" );
@@ -175,6 +171,11 @@ static int gpd_pocket_fan_probe(struct platform_device *pdev)if (IS_ERR (fan->gpio1))return PTR_ERR (fan->gpio1); + ret =devm_delayed_work_autocancel (&pdev->dev, &fan->work, + gpd_pocket_fan_worker); +if (ret) +return ret; +gpd_pocket_fan_force_update (fan);platform_set_drvdata (pdev, fan);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1461/1756 net: phy: marvell: keep WOL_EIE across interrupt reconfiguration
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit f434191f93884c9de58c38f18ac7fc7f1fdf9e42 ]
marvell_config_intr() rewrites the whole interrupt enable register, so the config_intr call from phy_init_hw() on resume silently cleared WOL_EIE on the 88E1318S and 88E1510: m88e1318_get_wol() still reported WAKE_MAGIC, but a matched magic packet was no longer routed to INTn and the board did not wake.
Bit 7 of that register is WOL_EIE only on these two PHYs; on others, such as the 88E1111, it enables a FIFO error interrupt. So give the 88E1318S and 88E1510 their own config_intr and handle_interrupt, and leave the shared callbacks unchanged.
m88e1318_set_wol() now records whether WoL is enabled, and both it and the new config_intr derive WOL_EIE from that state under the MDIO bus lock. WOL_EIE stays set across config_intr while WoL is enabled, except when the PHY has an interrupt line and interrupts are being disabled, as in phy_free_interrupt(): INTn is then the PHY IRQ, and nothing would read IEVENT after free_irq() to release it. The bit is set again once interrupts are re-enabled. phy_probe() still clears a WOL_EIE left by a previous boot, since WoL starts out disabled. The new handler also claims WoL events, so they do not go unacknowledged when the PHY IRQ is in use.
Helios4 (Armada 388, 88E1512), 7.2.9. With this patch WOL_EIE stays set over 3 link down/up cycles, "wol d" clears it, and a magic packet on a running board is a handled interrupt. Without it, WOL_EIE is lost on the first down/up, survives "wol d", and the magic packet is an unhandled interrupt.
--- drivers/net/phy/marvell.c | 97 ++++++++++++++++++++++++++++++--------- 1 file changed, 75 insertions(+), 22 deletions(-)
drivers/net/phy/marvell.c +75 -22
@@ -55,6 +55,8 @@#define MII_M1011_IMASK 0x12#define MII_M1011_IMASK_INIT 0x6400#define MII_M1011_IMASK_CLEAR 0x0000 +/* WOL Event Interrupt Enable, 88E1318S and 88E1510 only */ +#define MII_M1011_IMASK_WOL BIT(7)#define MII_M1011_PHY_SCR 0x10#define MII_M1011_PHY_SCR_DOWNSHIFT_EN BIT(11)
@@ -139,11 +141,6 @@#define MII_88E1318S_PHY_MSCR1_REG 16#define MII_88E1318S_PHY_MSCR1_PAD_ODD BIT(6) -/* Copper Specific Interrupt Enable Register */ -#define MII_88E1318S_PHY_CSIER 0x12 -/* WOL Event Interrupt Enable */ -#define MII_88E1318S_PHY_CSIER_WOL_EIE BIT(7) -#define MII_88E1318S_PHY_LED_FUNC 0x10#define MII_88E1318S_PHY_LED_FUNC_OFF (0x8)#define MII_88E1318S_PHY_LED_FUNC_ON (0x9)
@@ -353,6 +350,7 @@ struct marvell_priv {u32 step;s8 pair;u8 vct_phase; +bool wol_enabled; };static int marvell_read_page (struct phy_device *phydev)
@@ -406,7 +404,8 @@ static int marvell_config_intr(struct phy_device *phydev)return err; } -static irqreturn_t marvell_handle_interrupt (struct phy_device *phydev) +static irqreturn_t __marvell_handle_interrupt (struct phy_device *phydev, +u16 mask) {int irq_status;
@@ -416,7 +415,7 @@ static irqreturn_t marvell_handle_interrupt(struct phy_device *phydev)return IRQ_NONE ; } -if (!(irq_status &MII_M1011_IMASK_INIT )) +if (!(irq_status & mask))return IRQ_NONE ;phy_trigger_machine (phydev);
@@ -424,6 +423,57 @@ static irqreturn_t marvell_handle_interrupt(struct phy_device *phydev)return IRQ_HANDLED ; } +static irqreturn_t marvell_handle_interrupt (struct phy_device *phydev) +{ +return __marvell_handle_interrupt (phydev,MII_M1011_IMASK_INIT ); +} + +/* WOL_EIE also routes WoL events to INTn. Keep it set while WoL is enabled, +* unless INTn is the PHY interrupt and that interrupt is being disabled: +* nothing would read IEVENT after free_irq() to release the line. +*/ +static u16 m88e1318_wol_imask (struct phy_device *phydev) +{ +struct marvell_priv *priv = phydev->priv; + +if (priv->wol_enabled && + (phydev->interrupts ==PHY_INTERRUPT_ENABLED || + !phy_interrupt_is_valid (phydev))) +return MII_M1011_IMASK_WOL ; + +return 0 ; +} + +static int m88e1318_config_intr (struct phy_device *phydev) +{ +bool enable = phydev->interrupts ==PHY_INTERRUPT_ENABLED ; +u16 imask; +int err; + +if (enable) { + err =marvell_ack_interrupt (phydev); +if (err) +return err; + } + +/* Serialise against m88e1318_set_wol() updating wol_enabled */ +phy_lock_mdio_bus (phydev); + imask = enable ?MII_M1011_IMASK_INIT :MII_M1011_IMASK_CLEAR ; + imask |=m88e1318_wol_imask (phydev); + err =__phy_write (phydev,MII_M1011_IMASK , imask); +phy_unlock_mdio_bus (phydev); +if (err || enable) +return err; + +return marvell_ack_interrupt (phydev); +} + +static irqreturn_t m88e1318_handle_interrupt (struct phy_device *phydev) +{ +return __marvell_handle_interrupt (phydev,MII_M1011_IMASK_INIT | +MII_M1011_IMASK_WOL ); +} +static int marvell_set_polarity (struct phy_device *phydev,int polarity) {u16 val;
@@ -1915,18 +1965,27 @@ static void m88e1318_get_wol(struct phy_device *phydev,static int m88e1318_set_wol (struct phy_device *phydev,struct ethtool_wolinfo *wol) { +struct marvell_priv *priv = phydev->priv;int err =0 , oldpage; oldpage =phy_save_page (phydev);if (oldpage <0 ) goto error; -if (wol->wolopts & (WAKE_MAGIC |WAKE_PHY )) { -/* Explicitly switch to page 0x00, just to be sure */ - err =marvell_write_page (phydev,MII_MARVELL_COPPER_PAGE ); -if (err <0 ) - goto error; + priv->wol_enabled = !!(wol->wolopts & (WAKE_MAGIC |WAKE_PHY )); +/* Explicitly switch to page 0x00, just to be sure */ + err =marvell_write_page (phydev,MII_MARVELL_COPPER_PAGE ); +if (err <0 ) + goto error; + +/* Update the WOL interrupt enable */ + err =__phy_modify (phydev,MII_M1011_IMASK ,MII_M1011_IMASK_WOL , +m88e1318_wol_imask (phydev)); +if (err <0 ) + goto error; + +if (priv->wol_enabled) {/* If WOL event happened once, the LED[2] interrupt pin * will not be cleared unless we reading the interrupt status * register. If interrupts are in use, the normal interrupt
@@ -1936,12 +1995,6 @@ static int m88e1318_set_wol(struct phy_device *phydev,if (!phy_interrupt_is_valid (phydev))__phy_read (phydev,MII_M1011_IEVENT ); -/* Enable the WOL interrupt */ - err =__phy_set_bits (phydev,MII_88E1318S_PHY_CSIER , -MII_88E1318S_PHY_CSIER_WOL_EIE ); -if (err <0 ) - goto error; - err =marvell_write_page (phydev,MII_MARVELL_LED_PAGE );if (err <0 ) goto error;
@@ -3812,8 +3865,8 @@ static struct phy_driver marvell_drivers[] = { .config_init = m88e1318_config_init, .config_aneg = m88e1318_config_aneg, .read_status = marvell_read_status, - .config_intr = marvell_config_intr, - .handle_interrupt = marvell_handle_interrupt, + .config_intr = m88e1318_config_intr, + .handle_interrupt = m88e1318_handle_interrupt, .get_wol = m88e1318_get_wol, .set_wol = m88e1318_set_wol, .resume = genphy_resume,
@@ -3920,8 +3973,8 @@ static struct phy_driver marvell_drivers[] = { .config_init = m88e1510_config_init, .config_aneg = m88e1510_config_aneg, .read_status = marvell_read_status, - .config_intr = marvell_config_intr, - .handle_interrupt = marvell_handle_interrupt, + .config_intr = m88e1318_config_intr, + .handle_interrupt = m88e1318_handle_interrupt, .get_wol = m88e1318_get_wol, .set_wol = m88e1318_set_wol, .resume = m88e1510_resume,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1462/1756 ipv6: Hold RCU when emitting route hardware flags notification
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
[ Upstream commit 7c9cb1edaf8fd8e1af25e39741e603500986ef66 ]
fib6_info_hw_flags_set() is called by drivers from process context without RTNL or RCU. When the route uses a nexthop object, rt6_nlmsg_size() and rt6_fill_node() access the nexthop's RCU protected nexthop info and group pointers via rcu_dereference_rtnl(), resulting in suspicious RCU usage splats [1].
Fix by holding RCU while sizing and filling the notification, like fib_alias_hw_flags_set() already does. Switch to GFP_ATOMIC for the skb allocation accordingly.
Reproducer:
# echo "10 0" > /sys/bus/netdevsim/new_device # sysctl -wq net.ipv6.fib_notify_on_flag_change=1 # sysctl -wq net.ipv4.nexthop_compat_mode=1 # ip -6 nexthop add id 1 blackhole # ip -6 route add 2001:db8:1::1/128 nhid 1
[1]
WARNING: suspicious RCU usage 7.3.0-rc7-virtme-g191aa41548b2 #38 Not tainted net/ipv4/nexthop.c:1539 suspicious rcu_dereference_check() usage! [...]
Workqueue: events nsim_fib_event_work Call Trace: <TASK> dump_stack_lvl (lib/dump_stack.c:94 lib/dump_stack.c:120) lockdep_rcu_suspicious.cold (kernel/locking/lockdep.c:6972) nexthop_for_each_fib6_nh (net/ipv4/nexthop.c:1539 (discriminator 16)) rt6_nlmsg_size (net/ipv6/route.c:5728) fib6_info_hw_flags_set (net/ipv6/route.c:6503) nsim_fib6_rt_add (drivers/net/netdevsim/fib.c:671 drivers/net/netdevsim/fib.c:694) nsim_fib6_rt_insert (drivers/net/netdevsim/fib.c:759) nsim_fib_event_work (drivers/net/netdevsim/fib.c:856 drivers/net/netdevsim/fib.c:889 drivers/net/netdevsim/fib.c:1493) process_one_work (kernel/workqueue.c:3396) worker_thread (kernel/workqueue.c:3479 kernel/workqueue.c:3560) kthread (kernel/kthread.c:436) ret_from_fork (arch/x86/kernel/process.c:158) ret_from_fork_asm (arch/x86/entry/entry_64.S:245) </TASK>
--- net/ipv6/route.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/ipv6/route.c +6 -1
@@ -6356,7 +6356,9 @@ void fib6_info_hw_flags_set(struct net *net, struct fib6_info *f6i,if (!net->ipv6.sysctl.fib_notify_on_flag_change)return ; - skb =nlmsg_new (rt6_nlmsg_size (f6i),GFP_KERNEL ); +rcu_read_lock (); + + skb =nlmsg_new (rt6_nlmsg_size (f6i),GFP_ATOMIC );if (!skb) { err = -ENOBUFS ; goto errout;
@@ -6369,10 +6371,13 @@ void fib6_info_hw_flags_set(struct net *net, struct fib6_info *f6i, goto errout; } +rcu_read_unlock (); +rtnl_notify (skb, net,0 ,RTNLGRP_IPV6_ROUTE ,NULL ,GFP_KERNEL );return ; errout: +rcu_read_unlock ();rtnl_set_sk_err (net,RTNLGRP_IPV6_ROUTE , err); }EXPORT_SYMBOL (fib6_info_hw_flags_set);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1463/1756 team: reject CAN, IEEE 802.15.4 and 6LoWPAN devices in team_port_add
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 9043be310c6a4c5e57f7bba4b9870554eac7aa96 ]
When the first port has a non-Ethernet type, team_setup_by_port() copies port_dev->type to the team device while netdev_priv() of the team device still holds a struct team. Several L2 stacks identify their devices by dev->type alone and then access type specific data that the team driver never sets up:
- CAN protocols rely on the CAN mid-layer private data (ml_priv)
- IEEE 802.15.4 code dereferences ieee802154_ptr and the mlme ops in ml_priv
- the 6LoWPAN netdev notifier writes through lowpan_dev(dev) on NETDEV_DOWN and reads it on NETDEV_UP/NETDEV_CHANGE
Enslaving such a device (e.g. vxcan, wpan0, lowpan0) therefore leads to NULL pointer dereferences or to writes into struct team.
This is the same problem that syzbot reported for the bonding driver with a vxcan device enslaved to a bond master, which crashed in can_rx_unregister() and was fixed by commit 8ba68464e478 ("bonding:
refuse to enslave CAN devices"). The team driver has the same gap.
Reject ARPHRD_CAN, ARPHRD_IEEE802154, ARPHRD_IEEE802154_MONITOR and ARPHRD_6LOWPAN devices in team_port_add().
--- drivers/net/team/team_core.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/net/team/team_core.c +11 -0
@@ -1173,6 +1173,17 @@ static int team_port_add(struct team *team, struct net_device *port_dev,return -EINVAL ; } +if (port_dev->type ==ARPHRD_CAN || + port_dev->type ==ARPHRD_IEEE802154 || + port_dev->type ==ARPHRD_IEEE802154_MONITOR || + port_dev->type ==ARPHRD_6LOWPAN ) { +NL_SET_ERR_MSG (extack, +"CAN, IEEE 802.15.4 and 6LoWPAN devices can't be added as a team port" ); +netdev_err (dev,"Device %s is CAN, IEEE 802.15.4 or 6LoWPAN. These device types can't be added as a team port\n" , + portname); +return -EINVAL ; + } +if (netif_is_team_port (port_dev)) {NL_SET_ERR_MSG (extack,"Device is already a port of a team device" ); netdev_err(dev, "Device %s is already a port "
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1464/1756 net: stmmac: Drop useless code related to ethtool rx-copybreak
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Furong Xu <[email protected]>
[ Upstream commit 5c98e89d96ecbf0e4ed38a20c46727c0ed2c112b ]
After commit 2af6106ae949 ("net: stmmac: Introducing support for Page Pool"), the driver always copies frames to get a better performance, zero-copy for RX frames is no more, then these code turned to be useless and users of ethtool may get confused about the unhandled rx-copybreak parameter.
This patch mostly reverts
commit 22ad38381547 ("stmmac: do not perform zero-copy for rx frames")
Stable-dep-of: 9dd534187819 ("net: stmmac: Track the TX DMA threshold per queue")
--- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 - .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 39 ------------------- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 5 --- 3 files changed, 46 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac.h +0 -2
@@ -125,7 +125,6 @@ struct stmmac_rx_queue {unsigned int cur_rx;unsigned int dirty_rx;unsigned int buf_alloc_num; -u32 rx_zeroc_thresh;dma_addr_t dma_rx_phy;u32 rx_tail_addr;unsigned int state_saved;
@@ -273,7 +272,6 @@ struct stmmac_priv {int sph_cap;u32 sarc_type; -unsigned int rx_copybreak;u32 rx_riwt[MTL_MAX_TX_QUEUES ];int hwts_rx_en;
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +0 -39
@@ -1225,43 +1225,6 @@ static int stmmac_get_ts_info(struct net_device *dev,return ethtool_op_get_ts_info (dev, info); } -static int stmmac_get_tunable (struct net_device *dev, -const struct ethtool_tunable *tuna,void *data) -{ -struct stmmac_priv *priv =netdev_priv (dev); -int ret =0 ; - -switch (tuna->id) { -case ETHTOOL_RX_COPYBREAK : - *(u32 *)data = priv->rx_copybreak; -break ; -default : - ret = -EINVAL ; -break ; - } - -return ret; -} - -static int stmmac_set_tunable (struct net_device *dev, -const struct ethtool_tunable *tuna, -const void *data) -{ -struct stmmac_priv *priv =netdev_priv (dev); -int ret =0 ; - -switch (tuna->id) { -case ETHTOOL_RX_COPYBREAK : - priv->rx_copybreak = *(u32 *)data; -break ; -default : - ret = -EINVAL ; -break ; - } - -return ret; -} -static int stmmac_get_mm (struct net_device *ndev,struct ethtool_mm_state *state) {
@@ -1388,8 +1351,6 @@ static const struct ethtool_ops stmmac_ethtool_ops = { .set_per_queue_coalesce = stmmac_set_per_queue_coalesce, .get_channels = stmmac_get_channels, .set_channels = stmmac_set_channels, - .get_tunable = stmmac_get_tunable, - .set_tunable = stmmac_set_tunable, .get_link_ksettings = stmmac_ethtool_get_link_ksettings, .set_link_ksettings = stmmac_ethtool_set_link_ksettings, .get_mm = stmmac_get_mm,
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0 -5
@@ -76,7 +76,6 @@ module_param(phyaddr, int, 0444);MODULE_PARM_DESC (phyaddr,"Physical device address" );#define STMMAC_TX_THRESH (x) ((x)->dma_conf.dma_tx_size / 4) -#define STMMAC_RX_THRESH (x) ((x)->dma_conf.dma_rx_size / 4)/* Limit to make sure XDP TX and slow path can coexist */ #define STMMAC_XSK_TX_BUDGET_MAX 256
@@ -107,8 +106,6 @@ static int buf_sz = DEFAULT_BUFSIZE;module_param (buf_sz, int,0644 );MODULE_PARM_DESC (buf_sz,"DMA buffer size" ); -#define STMMAC_RX_COPYBREAK 256 -static const u32 default_msg_level = (NETIF_MSG_DRV |NETIF_MSG_PROBE |NETIF_MSG_LINK |NETIF_MSG_IFUP |NETIF_MSG_IFDOWN |NETIF_MSG_TIMER );
@@ -3929,8 +3926,6 @@ static int __stmmac_open(struct net_device *dev, } } - priv->rx_copybreak =STMMAC_RX_COPYBREAK ; - buf_sz = dma_conf->dma_buf_sz;for (int i =0 ; i <MTL_MAX_TX_QUEUES ; i++)if (priv->dma_conf.tx_queue[i].tbs &STMMAC_TBS_EN )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1465/1756 net: stmmac: Correct usage of maximum queue number macros
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kunihiko Hayashi <[email protected]>
[ Upstream commit 352bc4513ec3907db71cb5674fb93a76fc341ca9 ]
The maximum numbers of each Rx and Tx queues are defined by MTL_MAX_RX_QUEUES and MTL_MAX_TX_QUEUES respectively.
There are some places where Rx and Tx are used in reverse. There is no issue when the Tx and Rx macros have the same value, but should correct usage of macros for maximum queue number to keep consistency and prevent unexpected mistakes.
Stable-dep-of: 9dd534187819 ("net: stmmac: Track the TX DMA threshold per queue")
--- drivers/net/ethernet/stmicro/stmmac/common.h | 4 ++-- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-)
drivers/net/ethernet/stmicro/stmmac/common.h +2 -2
@@ -101,8 +101,8 @@ struct stmmac_rxq_stats {/* Updates on each CPU protected by not allowing nested irqs. */ struct stmmac_pcpu_stats {struct u64_stats_sync syncp; -u64_stats_t rx_normal_irq_n[MTL_MAX_TX_QUEUES ]; -u64_stats_t tx_normal_irq_n[MTL_MAX_RX_QUEUES ]; +u64_stats_t rx_normal_irq_n[MTL_MAX_RX_QUEUES ]; +u64_stats_t tx_normal_irq_n[MTL_MAX_TX_QUEUES ]; };/* Extra statistic and debug information exposed by ethtool */
drivers/net/ethernet/stmicro/stmmac/stmmac.h +3 -4
@@ -263,7 +263,7 @@ struct stmmac_priv {/* Frequently used values are kept adjacent for cache effect */ u32 tx_coal_frames[MTL_MAX_TX_QUEUES ];u32 tx_coal_timer[MTL_MAX_TX_QUEUES ]; -u32 rx_coal_frames[MTL_MAX_TX_QUEUES ]; +u32 rx_coal_frames[MTL_MAX_RX_QUEUES ];int hwts_tx_en;bool tx_path_in_lpi_mode;
@@ -271,8 +271,7 @@ struct stmmac_priv {int sph;int sph_cap;u32 sarc_type; - -u32 rx_riwt[MTL_MAX_TX_QUEUES ]; +u32 rx_riwt[MTL_MAX_RX_QUEUES ];int hwts_rx_en;void __iomem *ioaddr;
@@ -350,7 +349,7 @@ struct stmmac_priv {char int_name_sfty[IFNAMSIZ +10 ];char int_name_sfty_ce[IFNAMSIZ +10 ];char int_name_sfty_ue[IFNAMSIZ +10 ]; -char int_name_rx_irq[MTL_MAX_TX_QUEUES ][IFNAMSIZ +14 ]; +char int_name_rx_irq[MTL_MAX_RX_QUEUES ][IFNAMSIZ +14 ];char int_name_tx_irq[MTL_MAX_TX_QUEUES ][IFNAMSIZ +18 ];#ifdef CONFIG_DEBUG_FS
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1466/1756 net: stmmac: Track the TX DMA threshold per queue
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ovidiu Panait <[email protected]>
[ Upstream commit 9dd53418781900f02897c805eed397555cf98417 ]
Commit 3a6c12a0c6c3 ("net: stmmac: bump tc when get underflow error from DMA descriptor") made dwmac4 raise the DMA threshold of the queues that report TX underflows. This is done by incrementing a module global parameter 'tc' by 64 on each underflow.
This leads to inconsistent TX DMA thresholds between queues and causes issues on platforms with multiple stmmac controllers, as 'tc' is shared by all of them. Once 'tc' goes over 256 the bumping stops, and queues that did not underflow before are left at the initial threshold.
On the Renesas RZ/V2H platform, which has two dwmac4 controllers, we observed sporadic iperf3 TCP TX failures:
iperf3 -c <server> -t5 --bind-dev end1 ... [ 5] 0.00-5.00 sec 1.00 MBytes 1.68 Mbits/sec 87 sender [ 5] 0.00-5.00 sec 768 KBytes 1.26 Mbits/sec receiver
This happens because the TX queues of end1 were underflowing on a large fraction of the packets, but the DMA TX threshold was never raised from the default of 64 bytes. The threshold was not raised because end0 had underflowed first and had already pushed 'tc' past 256. Which controller is affected depends on which one underflows first.
To fix this, make the TX DMA threshold per queue instead of global. Each time an underflow happens on a queue, its TX DMA threshold gets incremented, without affecting other queues or controllers. With this change, 'tc' is only used as the initial value, and the RX threshold is no longer bumped together with the TX one, as TX underflows have nothing to do with the RX side.
--- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 1 + .../net/ethernet/stmicro/stmmac/stmmac_main.c | 33 +++++++++++-------- 2 files changed, 21 insertions(+), 13 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac.h +1 -0
@@ -272,6 +272,7 @@ struct stmmac_priv {int sph_cap;u32 sarc_type;u32 rx_riwt[MTL_MAX_RX_QUEUES ]; +u32 tx_threshold[MTL_MAX_TX_QUEUES ];int hwts_rx_en;void __iomem *ioaddr;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +20 -13
@@ -2381,7 +2381,6 @@ static void stmmac_dma_operation_mode(struct stmmac_priv *priv) }if (priv->plat->force_thresh_dma_mode) { - txmode = tc; rxmode = tc; }else if (priv->plat->force_sf_dma_mode || priv->plat->tx_coe) {/*
@@ -2395,7 +2394,6 @@ static void stmmac_dma_operation_mode(struct stmmac_priv *priv) rxmode =SF_DMA_MODE ; priv->xstats.threshold =SF_DMA_MODE ; }else { - txmode = tc; rxmode =SF_DMA_MODE ; }
@@ -2424,8 +2422,11 @@ static void stmmac_dma_operation_mode(struct stmmac_priv *priv)for (chan =0 ; chan < tx_channels_count; chan++) { qmode = priv->plat->tx_queues_cfg[chan].mode_to_use; -stmmac_dma_tx_mode (priv, priv->ioaddr, txmode, chan, - txfifosz, qmode); +if (txmode ==SF_DMA_MODE ) + priv->tx_threshold[chan] =SF_DMA_MODE ; + +stmmac_dma_tx_mode (priv, priv->ioaddr, priv->tx_threshold[chan], + chan, txfifosz, qmode); } }
@@ -2592,17 +2593,20 @@ static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget)static void stmmac_bump_dma_threshold (struct stmmac_priv *priv,u32 chan) { -if (unlikely (priv->xstats.threshold !=SF_DMA_MODE ) && tc <=256 ) { - tc +=64 ; +u32 thresh = priv->tx_threshold[chan]; -if (priv->plat->force_thresh_dma_mode) -stmmac_set_dma_operation_mode (priv, tc, tc, chan); -else -stmmac_set_dma_operation_mode (priv, tc,SF_DMA_MODE , - chan); +if (unlikely (thresh ==SF_DMA_MODE ) || thresh >256 ) +return ; - priv->xstats.threshold = tc; - } + thresh +=64 ; + +if (priv->plat->force_thresh_dma_mode) +stmmac_set_dma_operation_mode (priv, thresh, tc, chan); +else +stmmac_set_dma_operation_mode (priv, thresh,SF_DMA_MODE , chan); + + priv->tx_threshold[chan] = thresh; + priv->xstats.threshold = thresh; }/**
@@ -7789,6 +7793,9 @@ int stmmac_dvr_probe(struct device *device, priv->xstats.threshold = tc; +for (i =0 ; i <MTL_MAX_TX_QUEUES ; i++) + priv->tx_threshold[i] = tc; +/* Initialize RSS */ rxq = priv->plat->rx_queues_to_use;netdev_rss_key_fill (priv->rss.key,sizeof (priv->rss.key));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1467/1756 ibmveth: fix netpoll races with RX replenish
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mingming Cao <[email protected]>
[ Upstream commit 8d9ecac6b96e61d0e6d126c60644829fd9f66952 ]
ibmveth_poll_controller() runs RX replenish outside NAPI and without a lock, racing NAPI's replenish on another CPU. Both can fill the same slot, so an skb and its DMA mapping leak and PHYP can write into an unmapped buffer. netpoll calls it from netconsole and from netpoll-enabled bonds.
ibmveth_open() also enables NAPI before the RX resources exist. ibmveth_change_mtu(), veth_pool_store(), ibmveth_set_csum_offload() and ibmveth_set_tso() call close() and open() directly, so while open() is still setting up, netpoll and the direct ibmveth_interrupt() calls can replenish NULL pools and read freed memory.
Remove the callback, as Eric Dumazet did for many drivers after commit ac3d9dd034e5 ("netpoll: make ndo_poll_controller() optional"), including ibmvnic in commit 0c3b9d1b37df ("ibmvnic: remove ndo_poll_controller"). netpoll then polls NAPI itself with budget 0. napi->poll_owner serializes that with NAPI, but not with a NAPI poll that was already running when netpoll was set up, so skip RX replenish at budget 0, which netpoll uses for TX only. TX completes synchronously, so ibmveth_poll() has nothing else to do for netpoll.
Enable NAPI just before request_irq(), once everything ibmveth_poll() touches exists.
Found in review of the ibmveth multi-queue RX series and confirmed by code inspection of poll_one_napi() and the direct close()/open() callers; neither race was reproduced. Tested on a POWER10 LPAR with netconsole over ibmveth: a ping flood (678,470 packets, no loss) during a printk flood, and MTU changes and buffer pool toggles under traffic, with no warnings. No kernel selftests cover ibmveth.
--- drivers/net/ethernet/ibm/ibmveth.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
drivers/net/ethernet/ibm/ibmveth.c +13 -15
@@ -517,8 +517,6 @@ static int ibmveth_open(struct net_device *netdev)netdev_dbg (netdev,"open starting\n" ); -napi_enable (&adapter->napi); -for (i =0 ; i <IBMVETH_NUM_BUFF_POOLS ; i++) rxq_entries += adapter->rx_buff_pool[i].size;
@@ -606,10 +604,18 @@ static int ibmveth_open(struct net_device *netdev) } } +/* NAPI can run as soon as it is enabled, from netpoll during the +* direct close()/open() pairs or from a direct ibmveth_interrupt() +* call, so enable it only once everything ibmveth_poll() touches +* exists. +*/ +napi_enable (&adapter->napi); +netdev_dbg (netdev,"registering irq 0x%x\n" , netdev->irq); rc =request_irq (netdev->irq, ibmveth_interrupt,0 , netdev->name, netdev);if (rc !=0 ) { +napi_disable (&adapter->napi);netdev_err (netdev,"unable to request irq 0x%x, rc %d\n" , netdev->irq, rc); goto out_free_buffer_pools;
@@ -654,7 +660,6 @@ static int ibmveth_open(struct net_device *netdev) out_free_buffer_list:free_page ((unsigned long )adapter->buffer_list_addr); out: -napi_disable (&adapter->napi);return rc; }
@@ -1397,7 +1402,11 @@ static int ibmveth_poll(struct napi_struct *napi, int budget) } } -ibmveth_replenish_task (adapter); +/* netpoll polls with budget 0 for TX only, and is not serialized +* with a NAPI poll that was already running when it was set up +*/ +if (budget) +ibmveth_replenish_task (adapter);if (frames_processed == budget) goto out;
@@ -1534,14 +1543,6 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)return -EINVAL ; } -#ifdef CONFIG_NET_POLL_CONTROLLER -static void ibmveth_poll_controller (struct net_device *dev) -{ -ibmveth_replenish_task (netdev_priv (dev)); -ibmveth_interrupt (dev->irq, dev); -} -#endif -/** * ibmveth_get_desired_dma - Calculate IO memory desired by the driver *
@@ -1643,9 +1644,6 @@ static const struct net_device_ops ibmveth_netdev_ops = { .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = ibmveth_set_mac_addr, .ndo_features_check = ibmveth_features_check, -#ifdef CONFIG_NET_POLL_CONTROLLER - .ndo_poll_controller = ibmveth_poll_controller, -#endif };static int ibmveth_probe (struct vio_dev *dev,const struct vio_device_id *id)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1468/1756 ibmveth: return the error when set_channels cannot add TX queues
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mingming Cao <[email protected]>
[ Upstream commit 16abfa871dc840e55f1726408c5994c66a9773e2 ]
When ibmveth_set_channels() cannot allocate a TX buffer for a new queue, it falls back to the old queue count, and the successful netif_set_real_num_tx_queues() call then overwrites rc. ethtool -L reports success while the queue count is unchanged.
Return the allocation error when the fallback succeeds.
Found in review of the ibmveth multi-queue RX series and confirmed by code inspection. Tested on a POWER10 LPAR with the TX buffer allocation forced to fail by a test-only module parameter (not part of this patch):
ethtool -L tx 8 now fails with -ENOMEM and the device keeps its four queues and passes traffic. No kernel selftests cover ibmveth.
--- drivers/net/ethernet/ibm/ibmveth.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/ibm/ibmveth.c +4 -1
@@ -987,7 +987,7 @@ static int ibmveth_set_channels(struct net_device *netdev,struct ibmveth_adapter *adapter =netdev_priv (netdev);unsigned int old = netdev->real_num_tx_queues, goal = channels->tx_count; -int rc, i; +int rc, i, alloc_rc =0 ;/* If ndo_open has not been called yet then don't allocate, just set * desired netdev_queue's and return
@@ -1012,6 +1012,7 @@ static int ibmveth_set_channels(struct net_device *netdev,/* if something goes wrong, free everything we just allocated */ netdev_err (netdev,"Failed to allocate more tx queues, returning to %d queues\n" , old); + alloc_rc = rc; goal = old; old = i;break ;
@@ -1022,6 +1023,8 @@ static int ibmveth_set_channels(struct net_device *netdev, old); goal = old; old = i; + }else if (alloc_rc) { + rc = alloc_rc; }/* Free any that are no longer needed */ for (i = old; i > goal; i--) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1469/1756 ibmveth: wait for in-flight transmits in ibmveth_close()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mingming Cao <[email protected]>
[ Upstream commit c807573ea58e615339a9c72675c45c157ffe245c ]
ibmveth_close() frees the TX buffers after netif_tx_stop_all_queues(), which does not wait for an ibmveth_start_xmit() already running on another CPU. That transmit can copy into a freed buffer and hand PHYP a stale DMA address.
MTU, csum/TSO and buffer pool changes call ibmveth_close() directly while traffic flows. ifdown and the reset work go through dev_close(), which waits for running transmits only when the qdisc has an enqueue function, so with noqueue they race the same way.
Use netif_tx_disable(), which waits for running transmits.
Found in review of the ibmveth multi-queue RX series and confirmed by code inspection; the race was not reproduced. Tested on a POWER10 LPAR with MTU changes during a ping flood, with no warnings. No kernel selftests cover ibmveth.
--- drivers/net/ethernet/ibm/ibmveth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/ibm/ibmveth.c +1 -1
@@ -674,7 +674,7 @@ static int ibmveth_close(struct net_device *netdev)napi_disable (&adapter->napi); -netif_tx_stop_all_queues (netdev); +netif_tx_disable (netdev);h_vio_signal (adapter->vdev->unit_address,VIO_IRQ_DISABLE );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1470/1756 ibmveth: wait for the RX poll to return before freeing the RX queue
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mingming Cao <[email protected]>
[ Upstream commit 3f872b34368c7c1d2a8900950e0fee4cb4dd9a34 ]
napi_disable() returns once ibmveth_poll() has called napi_complete_done(), but the poll is not finished: it then re-enables the interrupt and calls ibmveth_rxq_pending_buffer(), which reads the RX queue. ibmveth_close() can free that queue in the meantime, and the late enable can leave the interrupt unmasked after close() masked it. The request_irq() failure path in ibmveth_open() frees the same memory after napi_disable() too.
Call synchronize_net() after napi_disable() on both paths. Every caller of ibmveth_poll() runs it with bottom halves or interrupts disabled, so this waits for the poll to return.
Found in review of the ibmveth multi-queue RX series and confirmed by code inspection; also raised by the Sashiko review of the first version of this series. The race was not reproduced. Tested on a POWER10 LPAR under an incoming ping flood with 30 rapid link down/up cycles and 30 rapid MTU cycles (1500 <-> 9000); ran cleanly with no warnings or faults. No kernel selftests cover ibmveth.
--- drivers/net/ethernet/ibm/ibmveth.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/ibm/ibmveth.c +6 -0
@@ -616,6 +616,7 @@ static int ibmveth_open(struct net_device *netdev) netdev);if (rc !=0 ) {napi_disable (&adapter->napi); +synchronize_net ();netdev_err (netdev,"unable to request irq 0x%x, rc %d\n" , netdev->irq, rc); goto out_free_buffer_pools;
@@ -673,6 +674,11 @@ static int ibmveth_close(struct net_device *netdev)netdev_dbg (netdev,"close starting\n" );napi_disable (&adapter->napi); +/* napi_disable() returns once ibmveth_poll() has called +* napi_complete_done(), but the poll still re-enables the +* interrupt and reads the RX queue after that. +*/ +synchronize_net ();netif_tx_disable (netdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1471/1756 ksmbd: fix link speed query in fsctl_query_iface_info_ioctl()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Hu <[email protected]>
[ Upstream commit 2bc1d25fc8597fa6cbf6b1ff92653881939a6436 ]
fsctl_query_iface_info_ioctl() used to call netdev->ethtool_ops->get_link_ksettings() directly and never checked the return value. If the callback fails, cmd.base.speed may be left uninitialized. Also, SPEED_UNKNOWN (-1) is treated as a numeric link speed and would be converted into a bogus link speed.
Use __ethtool_get_link_ksettings() to acquire the per-netdev ops lock when needed. Fall back to 1Gbps when the query fails, or when the reported speed is 0 or SPEED_UNKNOWN.
--- fs/smb/server/smb2pdu.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
fs/smb/server/smb2pdu.c +3 -4
@@ -8205,6 +8205,7 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn,struct sockaddr_storage_rsp *sockaddr_storage;unsigned int flags;unsigned long long speed; +struct ethtool_link_ksettings cmd;rtnl_lock ();for_each_netdev (&init_net, netdev) {
@@ -8239,10 +8240,8 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn, nii_rsp->Next =cpu_to_le32 (152 ); nii_rsp->Reserved =0 ; -if (netdev->ethtool_ops->get_link_ksettings) { -struct ethtool_link_ksettings cmd; - - netdev->ethtool_ops->get_link_ksettings (netdev, &cmd); +if (!__ethtool_get_link_ksettings (netdev, &cmd) && + cmd.base.speed && cmd.base.speed !=SPEED_UNKNOWN ) { speed = cmd.base.speed; }else { ksmbd_debug(SMB, "%s %s\n", netdev->name,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1472/1756 ksmbd: fix unlocked IPv6 addr_list walk in fsctl_query_iface_info_ioctl()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Hu <[email protected]>
[ Upstream commit a63bb4d91c784f63ad7c063717dff7920d8445be ]
fsctl_query_iface_info_ioctl() walks idev6->addr_list with a plain list_for_each_entry() while holding only rtnl_lock(). rtnl does not serialize all writers of this list: the DAD-failure path (addrconf_dad_failure -> ipv6_add_addr) can insert addresses without holding RTNL. It updates idev->addr_list with list_add_tail_rcu() under write_lock_bh(&idev->lock), so it can race with the unlocked walk.
addr_list is RCU managed, so walk it with list_for_each_entry_rcu() under rcu_read_lock(), matching the other lockless readers of the list.
--- fs/smb/server/smb2pdu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/smb/server/smb2pdu.c +3 -1
@@ -8283,13 +8283,15 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn,if (!idev6)continue ; -list_for_each_entry (ifa, &idev6->addr_list, if_list) { +rcu_read_lock (); +list_for_each_entry_rcu (ifa, &idev6->addr_list, if_list) {if (ifa->flags & (IFA_F_TENTATIVE |IFA_F_DEPRECATED ))continue ;memcpy (ipv6_addr, ifa->addr.s6_addr,16 );break ; } +rcu_read_unlock (); sockaddr_storage->addr6.ScopeId =0 ; nbytes +=sizeof (struct network_interface_info_ioctl_rsp ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1473/1756 ksmbd: fix invalid Next offset in interface info replies
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Hu <[email protected]>
[ Upstream commit 2c50a4a5e75db55880eca43c035649cb51fcb52a ]
fsctl_query_iface_info_ioctl() assigns nii_rsp to the next output slot before checking whether the interface has an in_device or inet6_dev. If either lookup returns NULL, the loop continues without advancing nbytes, leaving nii_rsp pointing at an uncommitted slot. If no later entry is committed, clearing nii_rsp->Next updates that slot instead of the last returned entry, leaving the latter with a nonzero Next offset.
Fix this by using nbytes to locate the last committed entry and clear its Next field, but only when the response contains at least one entry.
--- fs/smb/server/smb2pdu.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
fs/smb/server/smb2pdu.c +8 -2
@@ -8298,9 +8298,15 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn, }rtnl_unlock (); -/* zero if this is last one */ -if (nii_rsp) +/* +* nii_rsp may point to an entry not included in nbytes if the IPv4 +* or IPv6 device lookup failed. Clear Next in the last returned entry. +*/ +if (nbytes >0 ) { + nii_rsp = (struct network_interface_info_ioctl_rsp *) + &rsp->Buffer[nbytes -sizeof (*nii_rsp)]; nii_rsp->Next =0 ; + } rsp->PersistentFileId =SMB2_NO_FID ; rsp->VolatileFileId =SMB2_NO_FID ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1474/1756 cifs: Update description about ACL permissions
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pali Rohár <[email protected]>
[ Upstream commit a46221fcdd40a29eb08900221797ad63d0271118 ]
There are some incorrect information about individual SMB permission constants like WRITE_DAC can change ownership, or incomplete information to distinguish between ACL types (discretionary vs system) and there is completely missing information how permissions apply for directory objects and what is meaning of GENERIC_* bits.
Also there is missing constant for MAXIMUM_ALLOWED permission.
Fix and extend description of all SMB permission constants to match the reality, how the reference Windows SMB / NTFS implementation handles them.
Links to official Microsoft documentation related to permissions:
https://learn.microsoft.com/en-us/windows/win32/fileio/file-access-rights-constants
https://learn.microsoft.com/en-us/windows/win32/secauthz/access-mask
https://learn.microsoft.com/en-us/windows/win32/secauthz/standard-access-rights
https://learn.microsoft.com/en-us/windows/win32/secauthz/generic-access-rights
https://learn.microsoft.com/en-us/windows/win32/api/winternl/nf-winternl-ntcreatefile
https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/nf-ntifs-ntcreatefile
Stable-dep-of: bb0326a58060 ("ksmbd: report IPv4 and IPv6 addresses independently in iface query")
--- fs/smb/client/cifspdu.h | 82 ++++++++++++++++++++++++++++++----------- 1 file changed, 61 insertions(+), 21 deletions(-)
fs/smb/client/cifspdu.h +61 -21
@@ -190,42 +190,82 @@*/ #define FILE_READ_DATA 0x00000001/* Data can be read from the file */ +/* or directory child entries can */ +/* be listed together with the */ +/* associated child attributes */ +/* (so the FILE_READ_ATTRIBUTES on */ +/* the child entry is not needed) */ #define FILE_WRITE_DATA 0x00000002/* Data can be written to the file */ +/* or new file can be created in */ +/* the directory */ #define FILE_APPEND_DATA 0x00000004/* Data can be appended to the file */ +/* (for non-local files over SMB it */ +/* is same as FILE_WRITE_DATA) */ +/* or new subdirectory can be */ +/* created in the directory */ #define FILE_READ_EA 0x00000008/* Extended attributes associated */ /* with the file can be read */ #define FILE_WRITE_EA 0x00000010/* Extended attributes associated */ /* with the file can be written */ #define FILE_EXECUTE 0x00000020/*Data can be read into memory from */ /* the file using system paging I/O */ -#define FILE_DELETE_CHILD 0x00000040 +/* for executing the file / script */ +/* or right to traverse directory */ +/* (but by default all users have */ +/* directory bypass traverse */ +/* privilege and do not need this */ +/* permission on directories at all)*/ +#define FILE_DELETE_CHILD 0x00000040/* Child entry can be deleted from */ +/* the directory (so the DELETE on */ +/* the child entry is not needed) */ #define FILE_READ_ATTRIBUTES 0x00000080/* Attributes associated with the */ -/* file can be read */ +/* file or directory can be read */ #define FILE_WRITE_ATTRIBUTES 0x00000100/* Attributes associated with the */ -/* file can be written */ -#define DELETE 0x00010000/* The file can be deleted */ -#define READ_CONTROL 0x00020000/* The access control list and */ -/* ownership associated with the */ -/* file can be read */ -#define WRITE_DAC 0x00040000/* The access control list and */ -/* ownership associated with the */ -/* file can be written. */ +/* file or directory can be written */ +#define DELETE 0x00010000/* The file or dir can be deleted */ +#define READ_CONTROL 0x00020000/* The discretionary access control */ +/* list and ownership associated */ +/* with the file or dir can be read */ +#define WRITE_DAC 0x00040000/* The discretionary access control */ +/* list associated with the file or */ +/* directory can be written */ #define WRITE_OWNER 0x00080000/* Ownership information associated */ -/* with the file can be written */ +/* with the file/dir can be written */ #define SYNCHRONIZE 0x00100000/* The file handle can waited on to */ /* synchronize with the completion */ /* of an input/output request */ #define SYSTEM_SECURITY 0x01000000/* The system access control list */ -/* can be read and changed */ -#define GENERIC_ALL 0x10000000 -#define GENERIC_EXECUTE 0x20000000 -#define GENERIC_WRITE 0x40000000 -#define GENERIC_READ 0x80000000 -/* In summary - Relevant file */ -/* access flags from CIFS are */ -/* file_read_data, file_write_data */ -/* file_execute, file_read_attributes*/ -/* write_dac, and delete. */ +/* associated with the file or */ +/* directory can be read or written */ +/* (cannot be in DACL, can in SACL) */ +#define MAXIMUM_ALLOWED 0x02000000/* Maximal subset of GENERIC_ALL */ +/* permissions which can be granted */ +/* (cannot be in DACL nor SACL) */ +#define GENERIC_ALL 0x10000000/* Same as: GENERIC_EXECUTE | */ +/* GENERIC_WRITE | */ +/* GENERIC_READ | */ +/* FILE_DELETE_CHILD | */ +/* DELETE | */ +/* WRITE_DAC | */ +/* WRITE_OWNER */ +/* So GENERIC_ALL contains all bits */ +/* mentioned above except these two */ +/* SYSTEM_SECURITY MAXIMUM_ALLOWED */ +#define GENERIC_EXECUTE 0x20000000/* Same as: FILE_EXECUTE | */ +/* FILE_READ_ATTRIBUTES | */ +/* READ_CONTROL | */ +/* SYNCHRONIZE */ +#define GENERIC_WRITE 0x40000000/* Same as: FILE_WRITE_DATA | */ +/* FILE_APPEND_DATA | */ +/* FILE_WRITE_EA | */ +/* FILE_WRITE_ATTRIBUTES | */ +/* READ_CONTROL | */ +/* SYNCHRONIZE */ +#define GENERIC_READ 0x80000000/* Same as: FILE_READ_DATA | */ +/* FILE_READ_EA | */ +/* FILE_READ_ATTRIBUTES | */ +/* READ_CONTROL | */ +/* SYNCHRONIZE */ #define FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_READ_ATTRIBUTES)#define FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1475/1756 smb: move smb_sockaddr_in and smb_sockaddr_in6 to common/smb2pdu.h
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: ZhangGuoDong <[email protected]>
[ Upstream commit 7844d50ca239f0788e732608820f7026cb0cc8fb ]
Rename 4 places:
- iface_info_ipv4 -> smb_sockaddr_in
- iface_info_ipv6 -> smb_sockaddr_in6
- IPv4address -> IPv4Address
- IPv6address -> IPv6Address
Then move duplicate definitions to common header file.
Stable-dep-of: bb0326a58060 ("ksmbd: report IPv4 and IPv6 addresses independently in iface query")
--- fs/smb/client/smb2ops.c | 8 ++++---- fs/smb/client/smb2pdu.h | 13 ------------- fs/smb/common/smb2pdu.h | 15 +++++++++++++++ fs/smb/server/smb2pdu.c | 4 ++-- fs/smb/server/smb2pdu.h | 13 ------------- 5 files changed, 21 insertions(+), 32 deletions(-)
fs/smb/client/smb2ops.c +4 -4
@@ -635,8 +635,8 @@ parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,struct network_interface_info_ioctl_rsp *p;struct sockaddr_in *addr4;struct sockaddr_in6 *addr6; -struct iface_info_ipv4 *p4; -struct iface_info_ipv6 *p6; +struct smb_sockaddr_in *p4; +struct smb_sockaddr_in6 *p6;struct cifs_server_iface *info =NULL , *iface =NULL , *niface =NULL ;struct cifs_server_iface tmp_iface;__be16 port;
@@ -698,7 +698,7 @@ parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,*/ case INTERNETWORK : addr4 = (struct sockaddr_in *)&tmp_iface.sockaddr; - p4 = (struct iface_info_ipv4 *)p->Buffer; + p4 = (struct smb_sockaddr_in *)p->Buffer; addr4->sin_family =AF_INET ;memcpy (&addr4->sin_addr, &p4->IPv4Address,4 );
@@ -710,7 +710,7 @@ parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,break ;case INTERNETWORKV6 : addr6 = (struct sockaddr_in6 *)&tmp_iface.sockaddr; - p6 = (struct iface_info_ipv6 *)p->Buffer; + p6 = (struct smb_sockaddr_in6 *)p->Buffer; addr6->sin6_family =AF_INET6 ;memcpy (&addr6->sin6_addr, &p6->IPv6Address,16 );
fs/smb/client/smb2pdu.h +0 -13
@@ -255,19 +255,6 @@ struct network_interface_info_ioctl_rsp {__u8 Buffer[126 ]; } __packed; -struct iface_info_ipv4 { -__be16 Port; -__be32 IPv4Address; -__be64 Reserved; -} __packed; - -struct iface_info_ipv6 { -__be16 Port; -__be32 FlowInfo; -__u8 IPv6Address[16 ]; -__be32 ScopeId; -} __packed; -#define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL/* general ioctls to srv not to file */ struct compress_ioctl {
fs/smb/common/smb2pdu.h +15 -0
@@ -1433,6 +1433,21 @@ struct smb2_ioctl_rsp {__u8 Buffer[]; } __packed; +/* See MS-SMB2 2.2.32.5.1.1 */ +struct smb_sockaddr_in { +__be16 Port; +__be32 IPv4Address; +__u8 Reserved[8 ]; +} __packed; + +/* See MS-SMB2 2.2.32.5.1.2 */ +struct smb_sockaddr_in6 { +__be16 Port; +__be32 FlowInfo; +__u8 IPv6Address[16 ]; +__be32 ScopeId; +} __packed; +/* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */ struct file_zero_data_information {__le64 FileOffset;
fs/smb/server/smb2pdu.c +2 -2
@@ -8265,7 +8265,7 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn, idev =__in_dev_get_rtnl (netdev);if (!idev)continue ; - sockaddr_storage->addr4.IPv4address = + sockaddr_storage->addr4.IPv4Address =idev_ipv4_address (idev); nbytes +=sizeof (struct network_interface_info_ioctl_rsp ); ipv4_set = true;
@@ -8273,7 +8273,7 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn, }else {struct inet6_dev *idev6;struct inet6_ifaddr *ifa; -__u8 *ipv6_addr = sockaddr_storage->addr6.IPv6address; +__u8 *ipv6_addr = sockaddr_storage->addr6.IPv6Address; sockaddr_storage->Family =cpu_to_le16 (INTERNETWORKV6 ); sockaddr_storage->addr6.Port =0 ;
fs/smb/server/smb2pdu.h +0 -13
@@ -144,19 +144,6 @@ struct smb2_buffer_desc_v1 {#define SMB2_0_IOCTL_IS_FSCTL 0x00000001 -struct smb_sockaddr_in { -__be16 Port; -__be32 IPv4address; -__u8 Reserved[8 ]; -} __packed; - -struct smb_sockaddr_in6 { -__be16 Port; -__be32 FlowInfo; -__u8 IPv6address[16 ]; -__be32 ScopeId; -} __packed; -#define INTERNETWORK 0x0002#define INTERNETWORKV6 0x0017
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1476/1756 smb: move create_durable_req_v2 to common/smb2pdu.h
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: ChenXiaoSong <[email protected]>
[ Upstream commit 833a75fc9ecc3856a52223d8c245e52703e0a9f1 ]
Modify the following places:
- some fields in "struct create_durable_req_v2" -> struct durable_context_v2
- durable_context_v2 -> durable_context_v2_req
- create_durable_v2 -> create_durable_req_v2
Then move duplicate definitions to common header file.
Stable-dep-of: bb0326a58060 ("ksmbd: report IPv4 and IPv6 addresses independently in iface query")
--- fs/smb/client/smb2pdu.c | 14 +++++++------- fs/smb/client/smb2pdu.h | 12 ------------ fs/smb/common/smb2pdu.h | 14 ++++++++++++++ fs/smb/server/smb2pdu.c | 8 ++++---- fs/smb/server/smb2pdu.h | 9 --------- 5 files changed, 25 insertions(+), 32 deletions(-)
fs/smb/client/smb2pdu.c +7 -7
@@ -2473,21 +2473,21 @@ add_lease_context(struct TCP_Server_Info *server,return 0 ; } -static struct create_durable_v2 * +static struct create_durable_req_v2 *create_durable_v2_buf (struct cifs_open_parms *oparms) {struct cifs_fid *pfid = oparms->fid; -struct create_durable_v2 *buf; +struct create_durable_req_v2 *buf; - buf =kzalloc (sizeof (struct create_durable_v2 ),GFP_KERNEL ); + buf =kzalloc (sizeof (struct create_durable_req_v2 ),GFP_KERNEL );if (!buf)return NULL ; buf->ccontext.DataOffset =cpu_to_le16 (offsetof - (struct create_durable_v2 , dcontext)); - buf->ccontext.DataLength =cpu_to_le32 (sizeof (struct durable_context_v2 )); + (struct create_durable_req_v2 , dcontext)); + buf->ccontext.DataLength =cpu_to_le32 (sizeof (struct durable_context_v2_req )); buf->ccontext.NameOffset =cpu_to_le16 (offsetof - (struct create_durable_v2 , Name)); + (struct create_durable_req_v2 , Name)); buf->ccontext.NameLength =cpu_to_le16 (4 );/*
@@ -2557,7 +2557,7 @@ add_durable_v2_context(struct kvec *iov, unsigned int *num_iovec, iov[num].iov_base =create_durable_v2_buf (oparms);if (iov[num].iov_base ==NULL )return -ENOMEM ; - iov[num].iov_len =sizeof (struct create_durable_v2 ); + iov[num].iov_len =sizeof (struct create_durable_req_v2 ); *num_iovec = num +1 ;return 0 ; }
fs/smb/client/smb2pdu.h +0 -12
@@ -137,18 +137,6 @@ struct share_redirect_error_context_rsp {/* See MS-SMB2 2.2.13.2.11 */ /* Flags */ #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002 -struct durable_context_v2 { -__le32 Timeout; -__le32 Flags; -__u64 Reserved; -__u8 CreateGuid[16 ]; -} __packed; - -struct create_durable_v2 { -struct create_context_hdr ccontext; -__u8 Name[8 ]; -struct durable_context_v2 dcontext; -} __packed;/* See MS-SMB2 2.2.13.2.12 */ struct durable_reconnect_context_v2 {
fs/smb/common/smb2pdu.h +14 -0
@@ -1290,6 +1290,20 @@ struct create_mxac_req {__le64 Timestamp; } __packed; +/* See MS-SMB2 2.2.13.2.11 */ +struct durable_context_v2_req { +__le32 Timeout; +__le32 Flags;/* see SMB2_DHANDLE_FLAG_PERSISTENT */ +__u64 Reserved; +__u8 CreateGuid[16 ]; +} __packed; + +struct create_durable_req_v2 { +struct create_context_hdr ccontext; +__u8 Name[8 ]; +struct durable_context_v2_req dcontext; +} __packed; +/* See MS-SMB2 2.2.14.2.5 */ struct create_mxac_rsp {struct create_context_hdr ccontext;
fs/smb/server/smb2pdu.c +4 -4
@@ -2916,7 +2916,7 @@ static int parse_durable_handle_context(struct ksmbd_work *work, durable_v2_blob = (struct create_durable_req_v2 *)context;ksmbd_debug (SMB ,"Request for durable v2 open\n" ); - dh_info->fp =ksmbd_lookup_fd_cguid (durable_v2_blob->CreateGuid); + dh_info->fp =ksmbd_lookup_fd_cguid (durable_v2_blob->dcontext.CreateGuid);if (dh_info->fp) {if (!memcmp (conn->ClientGUID, dh_info->fp->client_guid,SMB2_CLIENT_GUID_SIZE )) {
@@ -2941,11 +2941,11 @@ static int parse_durable_handle_context(struct ksmbd_work *work,if ((lc && (lc->req_state &SMB2_LEASE_HANDLE_CACHING_LE )) || req_op_level ==SMB2_OPLOCK_LEVEL_BATCH ) { dh_info->CreateGuid = - durable_v2_blob->CreateGuid; + durable_v2_blob->dcontext.CreateGuid; dh_info->persistent = -le32_to_cpu (durable_v2_blob->Flags); +le32_to_cpu (durable_v2_blob->dcontext.Flags); dh_info->timeout = -le32_to_cpu (durable_v2_blob->Timeout); +le32_to_cpu (durable_v2_blob->dcontext.Timeout); dh_info->type = dh_idx; }break ;
fs/smb/server/smb2pdu.h +0 -9
@@ -66,15 +66,6 @@ struct preauth_integrity_info {/* Apple Defined Contexts */ #define SMB2_CREATE_AAPL "AAPL" -struct create_durable_req_v2 { -struct create_context_hdr ccontext; -__u8 Name[8 ]; -__le32 Timeout; -__le32 Flags; -__u8 Reserved[8 ]; -__u8 CreateGuid[16 ]; -} __packed; -#define DURABLE_HANDLE_MAX_TIMEOUT 300000struct create_durable_reconn_req {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1477/1756 smb: move create_durable_handle_reconnect_v2 to common/smb2pdu.h
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: ChenXiaoSong <[email protected]>
[ Upstream commit 81a45de432c6c7d82821fb09cb9fc1cf58629f3a ]
Modify the following places:
- some fields in "struct create_durable_reconn_v2_req" -> struct durable_reconnect_context_v2
- create_durable_reconn_v2_req -> create_durable_handle_reconnect_v2
Then move duplicate definitions to common header file.
Stable-dep-of: bb0326a58060 ("ksmbd: report IPv4 and IPv6 addresses independently in iface query")
--- fs/smb/client/smb2pdu.h | 17 ----------------- fs/smb/common/smb2pdu.h | 16 ++++++++++++++++ fs/smb/server/smb2pdu.c | 10 +++++----- fs/smb/server/smb2pdu.h | 11 ----------- 4 files changed, 21 insertions(+), 33 deletions(-)
fs/smb/client/smb2pdu.h +0 -17
@@ -138,29 +138,12 @@ struct share_redirect_error_context_rsp {/* Flags */ #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002 -/* See MS-SMB2 2.2.13.2.12 */ -struct durable_reconnect_context_v2 { -struct { -__u64 PersistentFileId; -__u64 VolatileFileId; - } Fid; -__u8 CreateGuid[16 ]; -__le32 Flags;/* see above DHANDLE_FLAG_PERSISTENT */ -} __packed; -/* See MS-SMB2 2.2.14.2.12 */ struct durable_reconnect_context_v2_rsp {__le32 Timeout;__le32 Flags;/* see above DHANDLE_FLAG_PERSISTENT */ } __packed; -struct create_durable_handle_reconnect_v2 { -struct create_context_hdr ccontext; -__u8 Name[8 ]; -struct durable_reconnect_context_v2 dcontext; -__u8 Pad[4 ]; -} __packed; -/* See MS-SMB2 2.2.13.2.5 */ struct crt_twarp_ctxt {struct create_context_hdr ccontext;
fs/smb/common/smb2pdu.h +16 -0
@@ -1304,6 +1304,22 @@ struct create_durable_req_v2 {struct durable_context_v2_req dcontext; } __packed; +/* See MS-SMB2 2.2.13.2.12 */ +struct durable_reconnect_context_v2 { +struct { +__u64 PersistentFileId; +__u64 VolatileFileId; + } Fid; +__u8 CreateGuid[16 ]; +__le32 Flags;/* see SMB2_DHANDLE_FLAG_PERSISTENT */ +} __packed; + +struct create_durable_handle_reconnect_v2 { +struct create_context_hdr ccontext; +__u8 Name[8 ]; +struct durable_reconnect_context_v2 dcontext; +} __packed; +/* See MS-SMB2 2.2.14.2.5 */ struct create_mxac_rsp {struct create_context_hdr ccontext;
fs/smb/server/smb2pdu.c +5 -5
@@ -2826,7 +2826,7 @@ static int parse_durable_handle_context(struct ksmbd_work *work,switch (dh_idx) {case DURABLE_RECONN_V2 : { -struct create_durable_reconn_v2_req *recon_v2; +struct create_durable_handle_reconnect_v2 *recon_v2;if (dh_info->type ==DURABLE_RECONN || dh_info->type ==DURABLE_REQ_V2 ) {
@@ -2836,13 +2836,13 @@ static int parse_durable_handle_context(struct ksmbd_work *work,if (le16_to_cpu (context->DataOffset) +le32_to_cpu (context->DataLength) < -sizeof (struct create_durable_reconn_v2_req )) { +sizeof (struct create_durable_handle_reconnect_v2 )) { err = -EINVAL ; goto out; } - recon_v2 = (struct create_durable_reconn_v2_req *)context; - persistent_id = recon_v2->Fid.PersistentFileId; + recon_v2 = (struct create_durable_handle_reconnect_v2 *)context; + persistent_id = recon_v2->dcontext.Fid.PersistentFileId; dh_info->fp =ksmbd_lookup_durable_fd (persistent_id);if (!dh_info->fp) {ksmbd_debug (SMB ,"Failed to get durable handle state\n" );
@@ -2850,7 +2850,7 @@ static int parse_durable_handle_context(struct ksmbd_work *work, goto out; } -if (memcmp (dh_info->fp->create_guid, recon_v2->CreateGuid, +if (memcmp (dh_info->fp->create_guid, recon_v2->dcontext.CreateGuid,SMB2_CREATE_GUID_SIZE )) { err = -EBADF ;ksmbd_put_durable_fd (dh_info->fp);
fs/smb/server/smb2pdu.h +0 -11
@@ -80,17 +80,6 @@ struct create_durable_reconn_req { } Data; } __packed; -struct create_durable_reconn_v2_req { -struct create_context_hdr ccontext; -__u8 Name[8 ]; -struct { -__u64 PersistentFileId; -__u64 VolatileFileId; - } Fid; -__u8 CreateGuid[16 ]; -__le32 Flags; -} __packed; -struct create_alloc_size_req {struct create_context_hdr ccontext;__u8 Name[8 ];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1478/1756 smb: move create_durable_rsp_v2 to common/smb2pdu.h
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: ChenXiaoSong <[email protected]>
[ Upstream commit 96721fd292264d712b7b9a51752ab87de5035db4 ]
Modify the following places:
- some fields in "struct create_durable_v2_rsp" -> struct durable_context_v2_rsp
- durable_reconnect_context_v2_rsp -> durable_context_v2_rsp
- create_durable_v2_rsp -> create_durable_rsp_v2
Then move them to common header file.
Stable-dep-of: bb0326a58060 ("ksmbd: report IPv4 and IPv6 addresses independently in iface query")
--- fs/smb/client/smb2pdu.h | 6 ------ fs/smb/common/smb2pdu.h | 12 ++++++++++++ fs/smb/server/oplock.c | 8 ++++---- fs/smb/server/smb2ops.c | 6 +++--- fs/smb/server/smb2pdu.h | 6 ------ 5 files changed, 19 insertions(+), 19 deletions(-)
fs/smb/client/smb2pdu.h +0 -6
@@ -138,12 +138,6 @@ struct share_redirect_error_context_rsp {/* Flags */ #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002 -/* See MS-SMB2 2.2.14.2.12 */ -struct durable_reconnect_context_v2_rsp { -__le32 Timeout; -__le32 Flags;/* see above DHANDLE_FLAG_PERSISTENT */ -} __packed; -/* See MS-SMB2 2.2.13.2.5 */ struct crt_twarp_ctxt {struct create_context_hdr ccontext;
fs/smb/common/smb2pdu.h +12 -0
@@ -1320,6 +1320,18 @@ struct create_durable_handle_reconnect_v2 {struct durable_reconnect_context_v2 dcontext; } __packed; +/* See MS-SMB2 2.2.14.2.12 */ +struct durable_context_v2_rsp { +__le32 Timeout; +__le32 Flags;/* see SMB2_DHANDLE_FLAG_PERSISTENT */ +} __packed; + +struct create_durable_rsp_v2 { +struct create_context_hdr ccontext; +__u8 Name[8 ]; +struct durable_context_v2_rsp dcontext; +} __packed; +/* See MS-SMB2 2.2.14.2.5 */ struct create_mxac_rsp {struct create_context_hdr ccontext;
fs/smb/server/oplock.c +4 -4
@@ -1858,9 +1858,9 @@ void create_durable_rsp_buf(char *cc)*/ void create_durable_v2_rsp_buf (char *cc,struct ksmbd_file *fp) { -struct create_durable_v2_rsp *buf; +struct create_durable_rsp_v2 *buf; - buf = (struct create_durable_v2_rsp *)cc; + buf = (struct create_durable_rsp_v2 *)cc;memset (buf,0 ,sizeof (struct create_durable_rsp )); buf->ccontext.DataOffset =cpu_to_le16 (offsetof (struct create_durable_rsp , Data));
@@ -1874,9 +1874,9 @@ void create_durable_v2_rsp_buf(char *cc, struct ksmbd_file *fp) buf->Name[2 ] ='2' ; buf->Name[3 ] ='Q' ; - buf->Timeout =cpu_to_le32 (fp->durable_timeout); + buf->dcontext.Timeout =cpu_to_le32 (fp->durable_timeout);if (fp->is_persistent) - buf->Flags =cpu_to_le32 (SMB2_DHANDLE_FLAG_PERSISTENT ); + buf->dcontext.Flags =cpu_to_le32 (SMB2_DHANDLE_FLAG_PERSISTENT ); }/**
fs/smb/server/smb2ops.c +3 -3
@@ -59,7 +59,7 @@ static struct smb_version_values smb30_server_values = { .cap_large_files = SMB2_LARGE_FILES, .create_lease_size = sizeof(struct create_lease_v2), .create_durable_size = sizeof(struct create_durable_rsp), - .create_durable_v2_size = sizeof(struct create_durable_v2_rsp), + .create_durable_v2_size = sizeof(struct create_durable_rsp_v2), .create_mxac_size = sizeof(struct create_mxac_rsp), .create_disk_id_size = sizeof(struct create_disk_id_rsp), .create_posix_size = sizeof(struct create_posix_rsp),
@@ -86,7 +86,7 @@ static struct smb_version_values smb302_server_values = { .cap_large_files = SMB2_LARGE_FILES, .create_lease_size = sizeof(struct create_lease_v2), .create_durable_size = sizeof(struct create_durable_rsp), - .create_durable_v2_size = sizeof(struct create_durable_v2_rsp), + .create_durable_v2_size = sizeof(struct create_durable_rsp_v2), .create_mxac_size = sizeof(struct create_mxac_rsp), .create_disk_id_size = sizeof(struct create_disk_id_rsp), .create_posix_size = sizeof(struct create_posix_rsp),
@@ -113,7 +113,7 @@ static struct smb_version_values smb311_server_values = { .cap_large_files = SMB2_LARGE_FILES, .create_lease_size = sizeof(struct create_lease_v2), .create_durable_size = sizeof(struct create_durable_rsp), - .create_durable_v2_size = sizeof(struct create_durable_v2_rsp), + .create_durable_v2_size = sizeof(struct create_durable_rsp_v2), .create_mxac_size = sizeof(struct create_mxac_rsp), .create_disk_id_size = sizeof(struct create_disk_id_rsp), .create_posix_size = sizeof(struct create_posix_rsp),
fs/smb/server/smb2pdu.h +0 -6
@@ -98,12 +98,6 @@ struct create_durable_rsp {/* See MS-SMB2 2.2.13.2.11 */ /* Flags */ #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002 -struct create_durable_v2_rsp { -struct create_context_hdr ccontext; -__u8 Name[8 ]; -__le32 Timeout; -__le32 Flags; -} __packed;/* equivalent of the contents of SMB3.1.1 POSIX open context response */ struct create_posix_rsp {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1479/1756 smb: move some duplicate definitions to common/smb2pdu.h
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: ZhangGuoDong <[email protected]>
[ Upstream commit 1172d8598499a006d172bb24bebaa3fdc99064a8 ]
In order to maintain the code more easily, move duplicate definitions to common header file.
There are only 4 different definitions, the client uses cpu_to_le16() but the server does not:
- RSS_CAPABLE
- RDMA_CAPABLE
- INTERNETWORK
- INTERNETWORKV6
The other definitions are exactly the same on both client and server.
The struct smb_hdr is defined in MS-CIFS and MS-SMB, but it's also used by SMB2 and SMB3, so move it to the common smb2pdu.h.
Stable-dep-of: bb0326a58060 ("ksmbd: report IPv4 and IPv6 addresses independently in iface query")
--- fs/smb/client/cifspdu.h | 135 +---------------------------- fs/smb/client/smb2pdu.h | 21 ----- fs/smb/common/smb2pdu.h | 172 +++++++++++++++++++++++++++++++++++-- fs/smb/server/smb2pdu.c | 8 +- fs/smb/server/smb2pdu.h | 19 ---- fs/smb/server/smb_common.h | 75 +--------------- 6 files changed, 173 insertions(+), 257 deletions(-)
fs/smb/client/cifspdu.h +2 -133
@@ -12,6 +12,7 @@#include <net/sock.h> #include <linux/unaligned.h> #include "../common/smbfsctl.h" +#include "../common/smb2pdu.h" #define CIFS_PROT 0#define POSIX_PROT (CIFS_PROT+1)
@@ -180,98 +181,7 @@#define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000)#define SMBFLG2_UNICODE cpu_to_le16(0x8000) -/* -* These are the file access permission bits defined in CIFS for the -* NTCreateAndX as well as the level 0x107 -* TRANS2_QUERY_PATH_INFORMATION API. The level 0x107, SMB_QUERY_FILE_ALL_INFO -* responds with the AccessFlags. -* The AccessFlags specifies the access permissions a caller has to the -* file and can have any suitable combination of the following values: -*/ - -#define FILE_READ_DATA 0x00000001/* Data can be read from the file */ -/* or directory child entries can */ -/* be listed together with the */ -/* associated child attributes */ -/* (so the FILE_READ_ATTRIBUTES on */ -/* the child entry is not needed) */ -#define FILE_WRITE_DATA 0x00000002/* Data can be written to the file */ -/* or new file can be created in */ -/* the directory */ -#define FILE_APPEND_DATA 0x00000004/* Data can be appended to the file */ -/* (for non-local files over SMB it */ -/* is same as FILE_WRITE_DATA) */ -/* or new subdirectory can be */ -/* created in the directory */ -#define FILE_READ_EA 0x00000008/* Extended attributes associated */ -/* with the file can be read */ -#define FILE_WRITE_EA 0x00000010/* Extended attributes associated */ -/* with the file can be written */ -#define FILE_EXECUTE 0x00000020/*Data can be read into memory from */ -/* the file using system paging I/O */ -/* for executing the file / script */ -/* or right to traverse directory */ -/* (but by default all users have */ -/* directory bypass traverse */ -/* privilege and do not need this */ -/* permission on directories at all)*/ -#define FILE_DELETE_CHILD 0x00000040/* Child entry can be deleted from */ -/* the directory (so the DELETE on */ -/* the child entry is not needed) */ -#define FILE_READ_ATTRIBUTES 0x00000080/* Attributes associated with the */ -/* file or directory can be read */ -#define FILE_WRITE_ATTRIBUTES 0x00000100/* Attributes associated with the */ -/* file or directory can be written */ -#define DELETE 0x00010000/* The file or dir can be deleted */ -#define READ_CONTROL 0x00020000/* The discretionary access control */ -/* list and ownership associated */ -/* with the file or dir can be read */ -#define WRITE_DAC 0x00040000/* The discretionary access control */ -/* list associated with the file or */ -/* directory can be written */ -#define WRITE_OWNER 0x00080000/* Ownership information associated */ -/* with the file/dir can be written */ -#define SYNCHRONIZE 0x00100000/* The file handle can waited on to */ -/* synchronize with the completion */ -/* of an input/output request */ -#define SYSTEM_SECURITY 0x01000000/* The system access control list */ -/* associated with the file or */ -/* directory can be read or written */ -/* (cannot be in DACL, can in SACL) */ -#define MAXIMUM_ALLOWED 0x02000000/* Maximal subset of GENERIC_ALL */ -/* permissions which can be granted */ -/* (cannot be in DACL nor SACL) */ -#define GENERIC_ALL 0x10000000/* Same as: GENERIC_EXECUTE | */ -/* GENERIC_WRITE | */ -/* GENERIC_READ | */ -/* FILE_DELETE_CHILD | */ -/* DELETE | */ -/* WRITE_DAC | */ -/* WRITE_OWNER */ -/* So GENERIC_ALL contains all bits */ -/* mentioned above except these two */ -/* SYSTEM_SECURITY MAXIMUM_ALLOWED */ -#define GENERIC_EXECUTE 0x20000000/* Same as: FILE_EXECUTE | */ -/* FILE_READ_ATTRIBUTES | */ -/* READ_CONTROL | */ -/* SYNCHRONIZE */ -#define GENERIC_WRITE 0x40000000/* Same as: FILE_WRITE_DATA | */ -/* FILE_APPEND_DATA | */ -/* FILE_WRITE_EA | */ -/* FILE_WRITE_ATTRIBUTES | */ -/* READ_CONTROL | */ -/* SYNCHRONIZE */ -#define GENERIC_READ 0x80000000/* Same as: FILE_READ_DATA | */ -/* FILE_READ_EA | */ -/* FILE_READ_ATTRIBUTES | */ -/* READ_CONTROL | */ -/* SYNCHRONIZE */ - -#define FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_READ_ATTRIBUTES) -#define FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \ - | FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES) -#define FILE_EXEC_RIGHTS (FILE_EXECUTE) - +/* Combinations of file access permission bits */ #define SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_WRITE_EA \ | FILE_READ_ATTRIBUTES \ | FILE_WRITE_ATTRIBUTES \
@@ -283,15 +193,6 @@ | FILE_WRITE_ATTRIBUTES \ |DELETE |READ_CONTROL |WRITE_DAC \ | WRITE_OWNER | SYNCHRONIZE) -#define SET_FILE_EXEC_RIGHTS (FILE_READ_EA | FILE_WRITE_EA | FILE_EXECUTE \ - | FILE_READ_ATTRIBUTES \ - | FILE_WRITE_ATTRIBUTES \ - | DELETE | READ_CONTROL | WRITE_DAC \ - | WRITE_OWNER | SYNCHRONIZE) - -#define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \ - | READ_CONTROL | SYNCHRONIZE) -/* * Invalid readdir handle
@@ -417,38 +318,6 @@#define GETU16 (var) (*((__u16 *)var))/* BB check for endian issues */ #define GETU32 (var) (*((__u32 *)var))/* BB check for endian issues */ -struct smb_hdr { -__be32 smb_buf_length;/* BB length is only two (rarely three) bytes, -with one or two byte "type" preceding it that will be -zero - we could mask the type byte off */ -__u8 Protocol[4 ]; -__u8 Command; -union { -struct { -__u8 ErrorClass; -__u8 Reserved; -__le16 Error; - } __attribute__((packed)) DosError; -__le32 CifsError; - } __attribute__((packed)) Status; -__u8 Flags; -__le16 Flags2;/* note: le */ -__le16 PidHigh; -union { -struct { -__le32 SequenceNumber;/* le */ -__u32 Reserved;/* zero */ - } __attribute__((packed)) Sequence; -__u8 SecuritySignature[8 ];/* le */ - } __attribute__((packed)) Signature; -__u8 pad[2 ]; -__u16 Tid; -__le16 Pid; -__u16 Uid; -__le16 Mid; -__u8 WordCount; -} __attribute__((packed)); -/* given a pointer to an smb_hdr, retrieve a void pointer to the ByteCount */ static inline void *BCC (struct smb_hdr *smb)
fs/smb/client/smb2pdu.h +0 -21
@@ -133,11 +133,6 @@ struct share_redirect_error_context_rsp {#define SMB2_LEASE_HANDLE_CACHING_HE 0x02#define SMB2_LEASE_WRITE_CACHING_HE 0x04 - -/* See MS-SMB2 2.2.13.2.11 */ -/* Flags */ -#define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002 -/* See MS-SMB2 2.2.13.2.5 */ struct crt_twarp_ctxt {struct create_context_hdr ccontext;
@@ -204,22 +199,6 @@ struct network_resiliency_req { } __packed;/* There is no buffer for the response ie no struct network_resiliency_rsp */ -#define RSS_CAPABLE cpu_to_le32(0x00000001) -#define RDMA_CAPABLE cpu_to_le32(0x00000002) - -#define INTERNETWORK cpu_to_le16(0x0002) -#define INTERNETWORKV6 cpu_to_le16(0x0017) - -struct network_interface_info_ioctl_rsp { -__le32 Next;/* next interface. zero if this is last one */ -__le32 IfIndex; -__le32 Capability;/* RSS or RDMA Capable */ -__le32 Reserved; -__le64 LinkSpeed; -__le16 Family; -__u8 Buffer[126 ]; -} __packed; -#define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL/* general ioctls to srv not to file */ struct compress_ioctl {
fs/smb/common/smb2pdu.h +166 -6
196 lines not on this page · raw message
fs/smb/server/smb2pdu.c +4 -4
@@ -8233,9 +8233,9 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn, nii_rsp->Capability =0 ;if (netdev->real_num_tx_queues >1 ) - nii_rsp->Capability |=cpu_to_le32 (RSS_CAPABLE ); + nii_rsp->Capability |=RSS_CAPABLE ;if (ksmbd_rdma_capable_netdev (netdev)) - nii_rsp->Capability |=cpu_to_le32 (RDMA_CAPABLE ); + nii_rsp->Capability |=RDMA_CAPABLE ; nii_rsp->Next =cpu_to_le32 (152 ); nii_rsp->Reserved =0 ;
@@ -8259,7 +8259,7 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn,if (!ipv4_set) {struct in_device *idev; - sockaddr_storage->Family =cpu_to_le16 (INTERNETWORK ); + sockaddr_storage->Family =INTERNETWORK ; sockaddr_storage->addr4.Port =0 ; idev =__in_dev_get_rtnl (netdev);
@@ -8275,7 +8275,7 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn,struct inet6_ifaddr *ifa;__u8 *ipv6_addr = sockaddr_storage->addr6.IPv6Address; - sockaddr_storage->Family =cpu_to_le16 (INTERNETWORKV6 ); + sockaddr_storage->Family =INTERNETWORKV6 ; sockaddr_storage->addr6.Port =0 ; sockaddr_storage->addr6.FlowInfo =0 ;
fs/smb/server/smb2pdu.h +0 -19
@@ -95,10 +95,6 @@ struct create_durable_rsp { } Data; } __packed; -/* See MS-SMB2 2.2.13.2.11 */ -/* Flags */ -#define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002 -/* equivalent of the contents of SMB3.1.1 POSIX open context response */ struct create_posix_rsp {struct create_context_hdr ccontext;
@@ -118,9 +114,6 @@ struct smb2_buffer_desc_v1 {#define SMB2_0_IOCTL_IS_FSCTL 0x00000001 -#define INTERNETWORK 0x0002 -#define INTERNETWORKV6 0x0017 -struct sockaddr_storage_rsp {__le16 Family;union {
@@ -129,18 +122,6 @@ struct sockaddr_storage_rsp { }; } __packed; -#define RSS_CAPABLE 0x00000001 -#define RDMA_CAPABLE 0x00000002 - -struct network_interface_info_ioctl_rsp { -__le32 Next;/* next interface. zero if this is last one */ -__le32 IfIndex; -__le32 Capability;/* RSS or RDMA Capable */ -__le32 Reserved; -__le64 LinkSpeed; -char SockAddr_Storage[128 ]; -} __packed; -struct file_object_buf_type1_ioctl_rsp {__u8 ObjectId[16 ];__u8 BirthVolumeId[16 ];
fs/smb/server/smb_common.h +1 -74
93 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1480/1756 ksmbd: report IPv4 and IPv6 addresses independently in iface query
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Hu <[email protected]>
[ Upstream commit bb0326a5806015fb7e5a6a721a50ff172c92c6e4 ]
fsctl_query_iface_info_ioctl() appends an entry before checking that a usable address was found, so it advertises unspecified-address
placeholders: an entry containing 0.0.0.0 when an in_device exists but has no primary IPv4 address, and an entry containing :: when an inet6_dev exists but its address list is empty or every address is tentative or deprecated.
The loop also couples IPv6 reporting to IPv4 success: when __in_dev_get_rtnl() returns NULL it continues to the next interface, skipping the IPv6 pass, so an interface without an in_device is dropped even if it has a usable IPv6 address.
Query IPv4 and IPv6 independently and append an entry only when an address is found. Factor out the common entry initialization and query the link speed once per interface instead of once per address family.
--- fs/smb/server/smb2pdu.c | 127 ++++++++++++++++++++++------------------ 1 file changed, 70 insertions(+), 57 deletions(-)
fs/smb/server/smb2pdu.c +70 -57
@@ -8195,6 +8195,27 @@ static __be32 idev_ipv4_address(struct in_device *idev)return addr; } +static struct network_interface_info_ioctl_rsp * +ksmbd_iface_entry_init (struct smb2_ioctl_rsp *rsp,int nbytes, +struct net_device *netdev,unsigned long long speed) +{ +struct network_interface_info_ioctl_rsp *nii_rsp; + + nii_rsp = (struct network_interface_info_ioctl_rsp *)&rsp->Buffer[nbytes]; + nii_rsp->IfIndex =cpu_to_le32 (netdev->ifindex); + nii_rsp->Capability =0 ; +if (netdev->real_num_tx_queues >1 ) + nii_rsp->Capability |=RSS_CAPABLE ; +if (ksmbd_rdma_capable_netdev (netdev)) + nii_rsp->Capability |=RDMA_CAPABLE ; + nii_rsp->Next =cpu_to_le32 (152 ); + nii_rsp->Reserved =0 ; + nii_rsp->LinkSpeed =cpu_to_le64 (speed); +memset (nii_rsp->SockAddr_Storage,0 ,128 ); + +return nii_rsp; +} +static int fsctl_query_iface_info_ioctl (struct ksmbd_conn *conn,struct smb2_ioctl_rsp *rsp,unsigned int out_buf_len)
@@ -8209,7 +8230,12 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn,rtnl_lock ();for_each_netdev (&init_net, netdev) { -bool ipv4_set = false; +struct inet6_ifaddr *ifa; +struct inet6_dev *idev6; +struct in_device *idev; +struct in6_addr ip6 = { }; +bool have_ip6 = false; +__be32 ip4 =0 ;if (netdev->type ==ARPHRD_LOOPBACK )continue ;
@@ -8220,25 +8246,6 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn, flags =dev_get_flags (netdev);if (!(flags &IFF_RUNNING ))continue ; -ipv6_retry: -if (out_buf_len < - nbytes +sizeof (struct network_interface_info_ioctl_rsp )) { -rtnl_unlock (); -return -ENOSPC ; - } - - nii_rsp = (struct network_interface_info_ioctl_rsp *) - &rsp->Buffer[nbytes]; - nii_rsp->IfIndex =cpu_to_le32 (netdev->ifindex); - - nii_rsp->Capability =0 ; -if (netdev->real_num_tx_queues >1 ) - nii_rsp->Capability |=RSS_CAPABLE ; -if (ksmbd_rdma_capable_netdev (netdev)) - nii_rsp->Capability |=RDMA_CAPABLE ; - - nii_rsp->Next =cpu_to_le32 (152 ); - nii_rsp->Reserved =0 ;if (!__ethtool_get_link_ksettings (netdev, &cmd) && cmd.base.speed && cmd.base.speed !=SPEED_UNKNOWN ) {
@@ -8248,60 +8255,66 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn, "speed is unknown, defaulting to 1Gb/sec"); speed =SPEED_1000 ; } - speed *=1000000 ; - nii_rsp->LinkSpeed =cpu_to_le64 (speed); - sockaddr_storage = (struct sockaddr_storage_rsp *) - nii_rsp->SockAddr_Storage; -memset (sockaddr_storage,0 ,128 ); +/* +* Query IPv4 and IPv6 independently; emit an entry only when a +* usable address exists, so an interface missing one family is +* still reported for the other and 0.0.0.0 / :: placeholders are +* never advertised. +*/ + idev =__in_dev_get_rtnl (netdev); +if (idev) + ip4 =idev_ipv4_address (idev); -if (!ipv4_set) { -struct in_device *idev; + idev6 =__in6_dev_get (netdev); +if (idev6) { +rcu_read_lock (); +list_for_each_entry_rcu (ifa, &idev6->addr_list, if_list) { +if (ifa->flags & (IFA_F_TENTATIVE |IFA_F_DEPRECATED )) +continue ; +memcpy (&ip6, ifa->addr.s6_addr,sizeof (ip6)); + have_ip6 = true; +break ; + } +rcu_read_unlock (); + } +if (ip4) { +if (out_buf_len < + nbytes +sizeof (struct network_interface_info_ioctl_rsp )) { +rtnl_unlock (); +return -ENOSPC ; + } + + nii_rsp =ksmbd_iface_entry_init (rsp, nbytes, netdev, speed); + sockaddr_storage = (struct sockaddr_storage_rsp *)nii_rsp->SockAddr_Storage; sockaddr_storage->Family =INTERNETWORK ; sockaddr_storage->addr4.Port =0 ; - - idev =__in_dev_get_rtnl (netdev); -if (!idev) -continue ; - sockaddr_storage->addr4.IPv4Address = -idev_ipv4_address (idev); + sockaddr_storage->addr4.IPv4Address = ip4; nbytes +=sizeof (struct network_interface_info_ioctl_rsp ); - ipv4_set = true; - goto ipv6_retry; - }else { -struct inet6_dev *idev6; -struct inet6_ifaddr *ifa; -__u8 *ipv6_addr = sockaddr_storage->addr6.IPv6Address; + } + +if (have_ip6) { +if (out_buf_len < + nbytes +sizeof (struct network_interface_info_ioctl_rsp )) { +rtnl_unlock (); +return -ENOSPC ; + } + nii_rsp =ksmbd_iface_entry_init (rsp, nbytes, netdev, speed); + sockaddr_storage = (struct sockaddr_storage_rsp *)nii_rsp->SockAddr_Storage; sockaddr_storage->Family =INTERNETWORKV6 ; sockaddr_storage->addr6.Port =0 ; sockaddr_storage->addr6.FlowInfo =0 ; - - idev6 =__in6_dev_get (netdev); -if (!idev6) -continue ; - -rcu_read_lock (); -list_for_each_entry_rcu (ifa, &idev6->addr_list, if_list) { -if (ifa->flags & (IFA_F_TENTATIVE | -IFA_F_DEPRECATED )) -continue ; -memcpy (ipv6_addr, ifa->addr.s6_addr,16 ); -break ; - } -rcu_read_unlock (); +memcpy (sockaddr_storage->addr6.IPv6Address, ip6.s6_addr,16 ); sockaddr_storage->addr6.ScopeId =0 ; nbytes +=sizeof (struct network_interface_info_ioctl_rsp ); } }rtnl_unlock (); -/* -* nii_rsp may point to an entry not included in nbytes if the IPv4 -* or IPv6 device lookup failed. Clear Next in the last returned entry. -*/ +/* Clear Next of the last committed entry to terminate the list. */ if (nbytes >0 ) { nii_rsp = (struct network_interface_info_ioctl_rsp *) &rsp->Buffer[nbytes -sizeof (*nii_rsp)];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1481/1756 smb/server: fix trailing period in generated short names
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: ChenXiaoSong <[email protected]>
[ Upstream commit e8486c5cfbdd07811afa4196060bafbf78ccdae2 ]
Reproducer:
1. touch /mnt/file
2. smbinfo filealternatenameinfo /mnt/file
Alternate Name: FILE~9!.
See MS-FSCC 2.1.5.2.1. The base filename MUST be 1-8 characters in length and MUST NOT contain a "." period character.
--- fs/smb/server/smb_common.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/smb/server/smb_common.c +1 -3
@@ -494,8 +494,6 @@ int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work, int info_level,* @shortname: destination short filename * * Return: shortname length or 0 when source long name is '.' or '..' -* TODO: Though this function conforms the restriction of 8.3 Filename spec, -* but the result is different with Windows 7's one. need to check. */ int ksmbd_extract_shortname (struct ksmbd_conn *conn,const char *longname,char *shortname)
@@ -559,7 +557,7 @@ int ksmbd_extract_shortname(struct ksmbd_conn *conn, const char *longname,if (dot_present)memcpy (out + baselen +4 , extension,4 );else - out[baselen +4 ] ='\0' ; + out[baselen +3 ] ='\0' ;smbConvertToUTF16 ((__le16 *)shortname, out,PATH_MAX , conn->local_nls,0 ); len =strlen (out) *2 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1482/1756 ksmbd: fix fd_limit accounting across durable reconnects
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit df5c868f6b80ca16c171cfac5e4e6c9be83ba4c2 ]
A disconnected durable handle keeps its ksmbd_file and the fd_limit reservation taken at its initial open. Reconnecting allocates another volatile ID and takes another reservation for the same file. Final close returns only one reservation, so repeated reconnects permanently reduce the server-wide open-file budget.
Move reservation into ksmbd_open_fd() and release it on every creation failure. Keep the reservation until final close, including while a durable handle is disconnected. Make ID allocation independent of fd_limit so reconnects neither consume nor return slots. This also avoids returning an unreserved slot when persistent ID allocation fails.
New opens continue to return -EMFILE when the budget is exhausted, keeping the existing STATUS_INSUFFICIENT_RESOURCES mapping.
--- fs/smb/server/vfs_cache.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
fs/smb/server/vfs_cache.c +8 -7
@@ -721,11 +721,6 @@ static int __open_id(struct ksmbd_file_table *ft, struct ksmbd_file *fp,u64 id =0 ;int ret; -if (type ==OPEN_ID_TYPE_VOLATILE_ID &&fd_limit_depleted ()) { -__open_id_set (fp,KSMBD_NO_FID , type); -return -EMFILE ; - } -idr_preload (KSMBD_DEFAULT_GFP );write_lock (&ft->lock); ret = idr_alloc_cyclic(ft->idr, fp, KSMBD_START_FID, INT_MAX - 1,
@@ -735,7 +730,6 @@ static int __open_id(struct ksmbd_file_table *ft, struct ksmbd_file *fp, ret =0 ; }else { id =KSMBD_NO_FID ; -fd_limit_close (); }__open_id_set (fp, id, type);
@@ -755,10 +749,15 @@ struct ksmbd_file *ksmbd_open_fd(struct ksmbd_work *work, struct file *filp)struct ksmbd_file *fp;int ret; +/* Durable reconnects reuse the slot held for the lifetime of fp. */ +if (fd_limit_depleted ()) +return ERR_PTR (-EMFILE ); + fp =kmem_cache_zalloc (filp_cache,KSMBD_DEFAULT_GFP );if (!fp) {pr_err ("Failed to allocate memory\n" ); -return ERR_PTR (-ENOMEM ); + ret = -ENOMEM ; + goto err_fd_limit; }INIT_LIST_HEAD (&fp->blocked_works);
@@ -801,6 +800,8 @@ struct ksmbd_file *ksmbd_open_fd(struct ksmbd_work *work, struct file *filp)/* fp->conn was set and refcounted before every branch here. */ ksmbd_conn_put (fp->conn);kmem_cache_free (filp_cache, fp); +err_fd_limit: +fd_limit_close ();return ERR_PTR (ret); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1483/1756 ksmbd: reject foreign RPC pipe handles on IPC$ read and write
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohammed Alquraini <[email protected]>
[ Upstream commit da25995071e5e0f3aa9a41160b00b2f833127b3e ]
RPC pipe handles on IPC$ are allocated from a single server-global IDA, and ksmbd.mountd looks a pipe up by handle alone, with no session information. smb2_read_pipe() and smb2_write_pipe() take the handle straight from the client request (VolatileFileId) and pass it to the daemon without checking that the requesting session opened it. An authenticated user can therefore issue an SMB2 READ or WRITE on IPC$ with another session's handle and receive that session's in-flight DCERPC response, or write attacker-chosen bytes into its pipe stream. A tree connect to IPC$, which every RPC client already has, is the only requirement.
Validate ownership before the transfer, the way the sibling pipe paths already do: under sess->rpc_lock, ksmbd_session_rpc_method() returns 0 for a handle the session did not open. smb2_get_info_file_pipe() and the FSCTL_PIPE_TRANSCEIVE ioctl already reject such handles; read and write were the remaining gap. Reject them with STATUS_FILE_CLOSED, as the ioctl path does.
--- fs/smb/server/smb2pdu.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
fs/smb/server/smb2pdu.c +20 -0
@@ -6946,6 +6946,16 @@ static noinline int smb2_read_pipe(struct ksmbd_work *work) id = req->VolatileFileId; +lockdep_assert_not_held (&work->sess->rpc_lock); +down_read (&work->sess->rpc_lock); +if (!ksmbd_session_rpc_method (work->sess, id)) { +up_read (&work->sess->rpc_lock); + rsp->hdr.Status =STATUS_FILE_CLOSED ; +smb2_set_err_rsp (work); +return -ENOENT ; + } +up_read (&work->sess->rpc_lock); + rpc_resp =ksmbd_rpc_read (work->sess, id);if (rpc_resp) {void *aux_payload_buf;
@@ -7256,6 +7266,16 @@ static noinline int smb2_write_pipe(struct ksmbd_work *work) goto out; } +lockdep_assert_not_held (&work->sess->rpc_lock); +down_read (&work->sess->rpc_lock); +if (!ksmbd_session_rpc_method (work->sess, id)) { +up_read (&work->sess->rpc_lock); + rsp->hdr.Status =STATUS_FILE_CLOSED ; +smb2_set_err_rsp (work); +return -ENOENT ; + } +up_read (&work->sess->rpc_lock); + data_buf = (char *)(((char *)&req->hdr.ProtocolId) + data_offset);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1484/1756 ksmbd: reject FILE_ATTRIBUTE_TEMPORARY on directories
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michail Andreas Michalopoulos <[email protected]>
[ Upstream commit 8323aab48525b83f750e712f66e6e9387b550cf4 ]
Setting FILE_ATTRIBUTE_TEMPORARY on a directory with SMB2 SET_INFO (FileBasicInformation) succeeds: ksmbd keeps the attribute and, with "store dos attributes" enabled, also writes it to the DOS attribute xattr.
MS-FSA (FileBasicInformation) says the request must fail with STATUS_INVALID_PARAMETER when FILE_ATTRIBUTE_TEMPORARY is set on a directory, and Samba rejects it too. smbtorture's smb2.create.dosattr_tmp_dir checks this and fails against ksmbd.
Return -EINVAL, which is sent as STATUS_INVALID_PARAMETER, when a directory is asked to become TEMPORARY. Do the check before any timestamp is changed, so a rejected request leaves the open file and the inode unchanged.
--- fs/smb/server/smb2pdu.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/smb/server/smb2pdu.c +5 -0
@@ -6450,6 +6450,11 @@ static int set_file_basic_info(struct ksmbd_file *fp, inode =file_inode (filp); idmap =file_mnt_idmap (filp); +/* MS-FSA FileBasicInformation: a directory can't be marked TEMPORARY */ +if (S_ISDIR (inode->i_mode) && + (file_info->Attributes &FILE_ATTRIBUTE_TEMPORARY_LE )) +return -EINVAL ; +if (file_info->CreationTime) fp->create_time =le64_to_cpu (file_info->CreationTime);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1485/1756 net: skbuff: dont copy alloc_cpu in skb header copies
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carolina Jubran <[email protected]>
[ Upstream commit 78d4bd22ec9df490135303c00e190ac43d5c334a ]
Commit 68822bdf76f1 ("net: generalize skb freeing deferral to per-cpu lists") added alloc_cpu to struct sk_buff and placed it in the headers group copied by __copy_skb_header().
This is wrong for newly allocated skbs. For example, skb_segment() allocates a new skb and records the current CPU in alloc_cpu, but __copy_skb_header() overwrites it with the value from the original skb.
If the original skb was allocated on another CPU, the segment may later be treated as remotely allocated and unnecessarily deferred there when it is freed.
Move alloc_cpu out of the headers group so it is preserved across header copies. Copy it explicitly in skb_clone(), which allocates the skb object directly instead of going through __alloc_skb().
This was discovered while investigating a throughput regression with software IPsec. The load used 512 IPsec tunnels carrying traffic over VXLAN, with 512 parallel iperf3 flows and an MTU of 4500.
Before the fix:
16.09% queued_spin_lock_slowpath
|
--15.90%--_raw_spin_lock_irqsave
|
--9.37%--__slab_free
kfree
skb_release_data
napi_consume_skb
mlx5e_poll_tx_cqAfter the fix:
6.84% queued_spin_lock_slowpath
|
--6.57%--_raw_spin_lock_irqsave
|
--5.00%--__slab_free
kfree
skb_release_data
napi_consume_skb
mlx5e_poll_tx_cq--- include/linux/skbuff.h | 4 ++-- net/core/skbuff.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
include/linux/skbuff.h +2 -2
@@ -1014,8 +1014,6 @@ struct sk_buff {__u16 tc_index;/* traffic control index */ #endif -u16 alloc_cpu; - union { __wsum csum; struct {
@@ -1068,6 +1066,8 @@ struct sk_buff { ); /* end headers group */ +u16 alloc_cpu; +/* These elements must be at the end, see alloc_skb() for details. */ sk_buff_data_t tail;sk_buff_data_t end;
net/core/skbuff.c +1 -1
@@ -1560,7 +1560,6 @@ static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old)#ifdef CONFIG_NET_RX_BUSY_POLL CHECK_SKB_FIELD (napi_id);#endif -CHECK_SKB_FIELD (alloc_cpu);#ifdef CONFIG_XPS CHECK_SKB_FIELD (sender_cpu);#endif
@@ -1592,6 +1591,7 @@ static struct sk_buff *__skb_clone(struct sk_buff *n, struct sk_buff *skb)C (pfmemalloc);C (pp_recycle); n->destructor =NULL ; +C (alloc_cpu);C (tail);C (end);C (head);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1486/1756 ocfs2: reserve xattr value tree metadata only once
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit 5365f1f417b36627f825aacf9844ae24b671b525 ]
ocfs2_calc_xattr_set_need() asks for the new value's extent tree twice when it replaces an inline value smaller than a value root with one large enough to be stored outside. The "stored outside" branch reserves the tree and then falls through to meta_guess instead of going out:
if (!ocfs2_xattr_is_local(xe)) {
...
xv = (struct ocfs2_xattr_value_root *)
(base + name_offset + name_len);
value_size = OCFS2_XATTR_ROOT_SIZE;
} else
xv = &def_xv.xv;
if (old_clusters >= new_clusters) {
...
goto out;
} else {
meta_add += ocfs2_extend_meta_needed(&xv->xr_list);
...
if (value_size >= OCFS2_XATTR_ROOT_SIZE)
goto out;
}On the fall-through xv is def_xv, so what gets added here is the two blocks ocfs2_extend_meta_needed() wants for an empty value root -- and both sides of meta_guess reserve that same tree again. The create side has done so since commit 3ed2be719eb9 ("ocfs2: allow for more than one data extent when creating xattr"), which ported this reservation to the create case without noticing it was already on the way in, and the existing-block side since commit 0cdc7dde00ec ("ocfs2: fix missing metadata reservation for large xattrs"). Both were chasing the same RESTART_META failure in ocfs2_xattr_extend_allocation(), for xattr create and then for xattr update.
ocfs2_init_xattr_set_ctxt() hands the total straight to ocfs2_reserve_new_metadata_blocks(), so the surplus is two blocks held for the whole transaction. A setxattr that would otherwise fit can come back -ENOSPC on a filesystem whose metadata allocator is nearly exhausted.
Move the reservation into the branch that stops there, leaving meta_guess as the only place that reserves for a value tree the fall through is about to create. The paths that do go out keep reserving against the value root they already have, which for an external old value is the on-disk one and so can legitimately ask for more than two blocks.
Both sides of meta_guess have to come out even on their own now that the copy covering for them is gone. The existing-block side only started reserving the value tree in the commit this one is tagged against. The create side has reserved the tree since 3ed2be719eb9, but only the tree:
the block ocfs2_create_xattr_block() claims came out of the same two, and on the fall-through it was the duplicate removed here that made up the difference. So "ocfs2: reserve metadata for a new xattr block and its value tree" has to land first -- without it the create side reserves 2 where 3 are needed and the value tree is back to RESTART_META. That one fixes a shortfall of its own on the path that reaches meta_guess directly, where there was never a duplicate to cover it, so it is worth taking alone; this patch is not.
--- fs/ocfs2/xattr.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
fs/ocfs2/xattr.c +15 -2
@@ -3451,12 +3451,21 @@ static int ocfs2_calc_xattr_set_need(struct inode *inode, credits +=ocfs2_remove_extent_credits (inode->i_sb); goto out; }else { - meta_add +=ocfs2_extend_meta_needed (&xv->xr_list); clusters_add += new_clusters - old_clusters; credits +=ocfs2_calc_extend_credits (inode->i_sb, &xv->xr_list); -if (value_size >=OCFS2_XATTR_ROOT_SIZE ) +/* +* The old value occupies at least as much room as a +* value root, whether it sat outside or inline, so the +* new root fits where it was and no new xattr block or +* bucket is needed -- only the metadata to extend the +* tree hanging off it. A smaller one is replaced +* outright, which meta_guess below reserves for. +*/ +if (value_size >=OCFS2_XATTR_ROOT_SIZE ) { + meta_add +=ocfs2_extend_meta_needed (&xv->xr_list); goto out; + } } }else {/*
@@ -3508,6 +3517,10 @@ static int ocfs2_calc_xattr_set_need(struct inode *inode,* Reserve metadata for the new xattr's value extent tree. * The not_found path above adds credits for this tree but * omits meta_add, leaving meta_ac NULL for large values. +* +* This is all of meta_ac on this side beyond the xattr tree +* above: no xattr block is allocated here, and a new bucket or +* index block is paid for out of data_ac. */ if (xi->xi_value_len >OCFS2_XATTR_INLINE_SIZE ) meta_add +=ocfs2_extend_meta_needed (&def_xv.xv.xr_list);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1487/1756 ocfs2: initialize status waiters before publishing them
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit f6bfa6c458288d72948af95391b205f3eb775721 ]
o2net_prep_nsw() publishes its stack waiter in nn_status_idr and nn_status_list under nn_lock, then initializes the wait queue and completion status after releasing the lock. A concurrent disconnect can find that waiter through o2net_complete_nodes_nsw() and call wake_up() before the wait queue has a valid lock and list head. The sender can also overwrite a completion status with its initial value.
Initialize the wait queue and status before publishing the waiter. nn_lock then orders publication against completion, and no reader can observe a partially initialized object. Leave the IDR allocation and its failure handling unchanged.
A controlled case-modified test kernel used a synthetic connection to enter the real send path and overlap publication with disconnect. The candidate completion and wake-up code were unchanged. Its Oops includes:
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] RIP: 0010:__wake_up_common+0xa0/0x1f0 Call Trace: <TASK> __wake_up+0x36/0x60 o2net_complete_nsw_locked+0x222/0x370 o2net_set_nn_state+0x917/0xea0 o2net_disconnect_node+0xd0/0x190 o2net_validate_control_write+0x454/0x500 full_proxy_write+0x11f/0x180 vfs_write+0x25a/0x1010 ksys_write+0x111/0x200 do_syscall_64+0x114/0x620 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK> Modules linked in:
--- fs/ocfs2/cluster/tcp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
fs/ocfs2/cluster/tcp.c +5 -3
@@ -301,6 +301,11 @@ static int o2net_prep_nsw(struct o2net_node *nn, struct o2net_status_wait *nsw) {int ret; +/* Initialize all completion-visible state before publishing the waiter. */ +init_waitqueue_head (&nsw->ns_wq); + nsw->ns_sys_status =O2NET_ERR_NONE ; + nsw->ns_status =0 ; +spin_lock (&nn->nn_lock); ret =idr_alloc (&nn->nn_status_idr, nsw,0 ,0 ,GFP_ATOMIC );if (ret >=0 ) {
@@ -311,9 +316,6 @@ static int o2net_prep_nsw(struct o2net_node *nn, struct o2net_status_wait *nsw)if (ret <0 )return ret; -init_waitqueue_head (&nsw->ns_wq); - nsw->ns_sys_status =O2NET_ERR_NONE ; - nsw->ns_status =0 ;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1488/1756 Drivers: hv: vmbus: Check ACPI companion before use
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit dd57772e36f72f8d9a53d7fa4d90c974d8ebbcff ]
Platform drivers can be forced to bind to devices outside their match tables through driver_override. vmbus_acpi_add() assumes that every bound device has an ACPI companion and dereferences it without checking.
Return -ENODEV when the companion is absent to avoid a NULL pointer dereference.
--- drivers/hv/vmbus_drv.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/hv/vmbus_drv.c +6 -2
@@ -2459,10 +2459,14 @@ EXPORT_SYMBOL_GPL(vmbus_free_mmio);#ifdef CONFIG_ACPI static int vmbus_acpi_add (struct platform_device *pdev) { +struct acpi_device *ancestor; +struct acpi_device *device;acpi_status result;int ret_val = -ENODEV ; -struct acpi_device *ancestor; -struct acpi_device *device =ACPI_COMPANION (&pdev->dev); + + device =ACPI_COMPANION (&pdev->dev); +if (!device) +return -ENODEV ; hv_dev = &device->dev;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1489/1756 platform/x86: ibm_rtl: Fix potential OOB read at signature search
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit f1d81af2521ad504a20481fef12c358d26e6c3a6 ]
The loop for signature search fetches 22 bytes of struct ibm_rtl_table at each check, while the loop count is calculated in 4 bytes unit, which means that, at the last entry, it fetches over the limit.
Rewrite the loop to use the byte offset and correct the boundary condition check for avoiding the potential OOB access.
--- drivers/platform/x86/ibm_rtl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/platform/x86/ibm_rtl.c +4 -4
@@ -234,9 +234,9 @@ static const struct dmi_system_id ibm_rtl_dmi_table[] __initconst = { };static int __init ibm_rtl_init (void ) { -unsigned long ebda_addr, ebda_size; +unsigned long ebda_addr, ebda_size, offset;unsigned int ebda_kb; -int ret = -ENODEV , i; +int ret = -ENODEV ;if (force)pr_warn ("module loaded by force\n" );
@@ -271,9 +271,9 @@ static int __init ibm_rtl_init(void) {return -ENOMEM ;/* search for the _RTL_ signature at the start of the table */ -for (i =0 ; i < ebda_size/sizeof (unsigned int ); i++) { +for (offset =0 ; offset +sizeof (*rtl_table) <= ebda_size; offset +=4 ) {struct ibm_rtl_table __iomem * tmp; - tmp = (struct ibm_rtl_table __iomem *) (ebda_map + i*sizeof (unsigned int )); + tmp = (struct ibm_rtl_table __iomem *) (ebda_map + offset);if ((readq (&tmp->signature) &RTL_MASK ) ==RTL_SIGNATURE ) {phys_addr_t addr;unsigned int plen;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1490/1756 selftests: ALSA: pcmtest: Check the frame count of each transfer
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 317f2ddb6662fca8954e381a1bc632667872c4a3 ]
The tests keep the result of snd_pcm_writei(), snd_pcm_readi() and their non-interleaved forms in a size_t. A size_t is never negative, so ASSERT_GE(res, 0) always passes.
The capture tests still catch a failed read when they compare the data. But the playback tests do not. The driver sets pc_test to 1 when it saw no corrupted data, and that is also true when it saw no data at all. So a playback test passes even when every write fails.
Store the result as snd_pcm_sframes_t and check that the whole request was transferred. The calls block, so a short count means an error.
--- .../selftests/alsa/test-pcmtest-driver.c | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-)
tools/testing/selftests/alsa/test-pcmtest-driver.c +12 -9
@@ -166,7 +166,7 @@ FIXTURE_SETUP(pcmtest) { TEST_F(pcmtest, playback) {snd_pcm_t *handle;unsigned char *it; -size_t write_res; +snd_pcm_sframes_t write_res;int test_results;int i, cur_ch, pos_in_ch;void *samples;
@@ -190,7 +190,7 @@ TEST_F(pcmtest, playback) { it[i] = patterns[cur_ch].buf[pos_in_ch % patterns[cur_ch].len]; } write_res =snd_pcm_writei (handle, samples, params->rate * params->time); -ASSERT_GE (write_res,0 ); +ASSERT_EQ (write_res, params->rate * params->time);snd_pcm_close (handle);free (samples);
@@ -206,7 +206,7 @@ TEST_F(pcmtest, playback) { TEST_F(pcmtest, capture) {snd_pcm_t *handle;unsigned char *it; -size_t read_res; +snd_pcm_sframes_t read_res;int i, cur_ch, pos_in_ch;void *samples;struct pcmtest_test_params *params = &self->params;
@@ -222,7 +222,7 @@ TEST_F(pcmtest, capture) {snd_pcm_format_set_silence (params->format, samples, params->rate * params->channels * params->time); read_res =snd_pcm_readi (handle, samples, params->rate * params->time); -ASSERT_GE (read_res,0 ); +ASSERT_EQ (read_res, params->rate * params->time);snd_pcm_close (handle); it = (unsigned char *)samples;for (i =0 ; i < self->params.sec_buf_len * self->params.time; i++) {
@@ -239,7 +239,8 @@ TEST_F(pcmtest, ni_capture) {snd_pcm_t *handle;struct pcmtest_test_params params = self->params;char **chan_samples; -size_t i, j, read_res; +snd_pcm_sframes_t read_res; +size_t i, j; chan_samples =calloc (CH_NUM ,sizeof (*chan_samples));ASSERT_NE (chan_samples,NULL );
@@ -257,7 +258,7 @@ TEST_F(pcmtest, ni_capture) {for (i =0 ; i <1 ; i++) { read_res =snd_pcm_readn (handle, (void **)chan_samples, params.rate * params.time); -ASSERT_GE (read_res,0 ); +ASSERT_EQ (read_res, params.rate * params.time); }snd_pcm_close (handle);
@@ -273,7 +274,8 @@ TEST_F(pcmtest, ni_playback) {snd_pcm_t *handle;struct pcmtest_test_params params = self->params;char **chan_samples; -size_t i, j, read_res; +snd_pcm_sframes_t write_res; +size_t i, j;int test_res; chan_samples =calloc (CH_NUM ,sizeof (*chan_samples));
@@ -294,8 +296,9 @@ TEST_F(pcmtest, ni_playback) { }for (i =0 ; i <1 ; i++) { - read_res =snd_pcm_writen (handle, (void **)chan_samples, params.rate * params.time); -ASSERT_GE (read_res,0 ); + write_res =snd_pcm_writen (handle, (void **)chan_samples, + params.rate * params.time); +ASSERT_EQ (write_res, params.rate * params.time); }snd_pcm_close (handle);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1491/1756 selftests: ALSA: pcmtest: Make room for the longest fill pattern
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit c338e77291d6b1b6aee6d45b3cc523f97199a011 ]
The driver accepts fill patterns of up to 4096 bytes, as pcmtest.rst documents. The test reads each pattern into a 1024-byte buffer, using the length the driver reports. So a pattern longer than 1024 bytes overflows the buffer into the next pattern and past the array.
Size the buffer to the driver's maximum.
--- tools/testing/selftests/alsa/test-pcmtest-driver.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/testing/selftests/alsa/test-pcmtest-driver.c +3 -1
@@ -10,9 +10,11 @@#include "../kselftest_harness.h" #define CH_NUM 4 +/* The driver accepts patterns of up to 4096 bytes */ +#define MAX_PATTERN_LEN 4096struct pattern_buf { -char buf[1024 ]; +char buf[MAX_PATTERN_LEN ];int len; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1492/1756 gtp: set a valid genl command in PDP context get and dump replies
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anil Kaushik <[email protected]>
[ Upstream commit 758d8928d2c5d6703da827577cef86d643155236 ]
gtp_genl_fill_info() stamps the reply with the command its callers pass in. gtp_genl_get_pdp() and gtp_genl_dump_pdp() pass nlmsg_type, which in a genl message is the dynamically assigned family id rather than a GTP_CMD_* value, so replies to a PDP context get or dump carry a meaningless command number.
libgtpnl ignores the command and is unaffected, but parsers that check it (for example the ynl tooling) treat the reply as an unknown command and discard it. Pass GTP_CMD_GETPDP, as gtp_tunnel_notify() already passes a real command on the notification path. No uapi change.
--- drivers/net/gtp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/gtp.c +2 -2
@@ -2280,7 +2280,7 @@ static int gtp_genl_get_pdp(struct sk_buff *skb, struct genl_info *info) } err =gtp_genl_fill_info (skb2,NETLINK_CB (skb).portid, info->snd_seq, -0 , info->nlhdr->nlmsg_type, pctx); +0 ,GTP_CMD_GETPDP , pctx);if (err <0 ) goto err_unlock_free;
@@ -2327,7 +2327,7 @@ static int gtp_genl_dump_pdp(struct sk_buff *skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, NLM_F_MULTI, - cb->nlh->nlmsg_type, pctx)) { + GTP_CMD_GETPDP, pctx)) { cb->args[0 ] = i; cb->args[1 ] = j; cb->args[2 ] = (unsigned long )gtp;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1493/1756 gtp: hold RCU for the device lookup when adding a PDP context
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anil Kaushik <[email protected]>
[ Upstream commit fe3e1a42fb7eb18d8c55d714b50a3d51f8cd6ffe ]
gtp_genl_new_pdp() calls gtp_find_dev(), which looks the device up with dev_get_by_index_rcu(). Since commit e2d1baca2b33 ("gtp: remove useless rcu_read_lock()"), this only runs under the rtnl lock, and kernels with CONFIG_PROVE_RCU_LIST warn:
WARNING: suspicious RCU usage
net/core/dev.c:1047 RCU-list traversed in non-reader section!!
...
dev_get_by_index_rcu
gtp_find_dev
gtp_genl_new_pdp
Hold the RCU read lock around the lookup only: gtp_pdp_add() allocates with GFP_KERNEL, and the rtnl lock keeps the device alive afterwards.
Found with the gtp selftest on a debug kernel.
--- drivers/net/gtp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/gtp.c +3 -0
@@ -2048,7 +2048,10 @@ static int gtp_genl_new_pdp(struct sk_buff *skb, struct genl_info *info)rtnl_lock (); +/* the rtnl lock keeps the device alive once found */ +rcu_read_lock (); gtp =gtp_find_dev (sock_net (skb->sk), info->attrs); +rcu_read_unlock ();if (!gtp) { err = -ENODEV ; goto out_unlock;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1494/1756 net/mlx5: HWS, fix modify header pattern compare on big-endian
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandre Cassen <[email protected]>
[ Upstream commit 7eed173447fba937a19e2f5f2dc79780793f72e7 ]
mlx5hws_pat_compare_pattern() casts each __be64 action to __be32 to compare only its control dword. On big-endian this keeps the data dword instead, which HWS clears from the pattern of set and add actions. Two such actions writing the same value into different fields then share a pattern and the second rule modifies the wrong field.
Read the first dword of each action from memory instead. Little-endian behavior is unchanged.
Discovered by an AI code review agent [1] and confirmed by code inspection. Not reproduced for lack of big-endian hardware running HWS. Tested for regressions on ConnectX-7 with firmware 28.48.1000 on a little-endian host.
--- .../mellanox/mlx5/core/steering/hws/mlx5hws_pat_arg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_pat_arg.c +2 -2
@@ -116,8 +116,8 @@ static bool mlx5hws_pat_compare_pattern(int cur_num_of_actions,return false; }else {/* Compare just the control, not the values */ -if ((__force __be32 )actions[i] != - (__force __be32 )cur_actions[i]) +if (*(__be32 *)&actions[i] != + *(__be32 *)&cur_actions[i])return false; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1495/1756 selftests: ALSA: pcmtest: Compare all captured bytes in ni_capture
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit c8c199e1b1b3bb0ef52a2a02d1ec87bee574ce13 ]
The ni_capture test reads rate * time frames into each channel buffer and then compares rate * time bytes. A frame is sample_size bytes per channel, so with S16_LE only the first half of each channel is checked. If the second half is wrong the test still passes.
Compare rate * time * sample_size bytes per channel.
--- tools/testing/selftests/alsa/test-pcmtest-driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/alsa/test-pcmtest-driver.c +1 -1
@@ -265,7 +265,7 @@ TEST_F(pcmtest, ni_capture) {snd_pcm_close (handle);for (i =0 ; i <CH_NUM ; i++) { -for (j =0 ; j < params.rate * params.time; j++) +for (j =0 ; j < params.rate * params.time * params.sample_size; j++)ASSERT_EQ (chan_samples[i][j], patterns[i].buf[j % patterns[i].len]);free (chan_samples[i]); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1496/1756 ASoC: wm8994: fix MCLK gating for AIF clocks sourced from MCLK2
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
[ Upstream commit 872215109fc880de7a03fa30437346f9212649e8 ]
aif_mclk_set() masks the AIFnCLK_SRC field of the AIFn clocking register, but compares the result with unshifted field values. The MCLK2 source (0x08) therefore never matches, so MCLK2 is never enabled for an AIF clocked from it, and the AIF relies on other users of that clock to keep it running.
On the Exynos4412 Trats2 board, AIF1 and SYSCLK run from MCLK2, the 32768Hz PMIC clock, while the codec is idle. That clock is shared with the WLAN and Bluetooth chips, which enable it only once their drivers are loaded. Until then the codec runs from a stopped clock: FLL1 fails to lock when configured from that state, and the codec floods the kernel log with FIFO error interrupts once a digital path is powered up:
wm8994-codec wm8994-codec: Timed out waiting for FLL lock wm8994-codec wm8994-codec: FIFO error
Booting with clk_ignore_unused, which keeps that clock running from the bootloader, makes both issues disappear.
Fixing just the comparison is not enough. The AIF clock source can be changed while the AIF clock is running, for example the Midas machine driver switches AIF1 between MCLK2 and FLL1 while AIF1CLK is kept enabled for jack detection. Looking up the clock again on disable can then release a different MCLK than the one enabled, leaking the enable count of one clock and underflowing the other.
Shift the field value before decoding it, and remember which MCLK has been enabled for each AIF, so that the same clock is released on disable. While at it, report the MCLK number 1-based in the error message.
--- sound/soc/codecs/wm8994.c | 28 ++++++++++++++++++---------- sound/soc/codecs/wm8994.h | 1 + 2 files changed, 19 insertions(+), 10 deletions(-)
sound/soc/codecs/wm8994.c +18 -10
@@ -1062,13 +1062,24 @@ static int aif_mclk_set(struct snd_soc_component *component, int aif, bool enablunsigned int offset, val, clk_idx;int ret; +/* +* The AIF clock source may be changed while the AIF clock is +* running, so release the MCLK which has been enabled for it +* instead of the one currently selected. +*/ +if (!enable) { +clk_disable_unprepare (wm8994->aif_mclk[aif]); + wm8994->aif_mclk[aif] =NULL ; +return 0 ; + } +if (aif) offset =4 ;else offset =0 ; val =snd_soc_component_read (component,WM8994_AIF1_CLOCKING_1 + offset); - val &=WM8994_AIF1CLK_SRC_MASK ; + val = (val &WM8994_AIF1CLK_SRC_MASK ) >>WM8994_AIF1CLK_SRC_SHIFT ;switch (val) {case 0 :
@@ -1081,16 +1092,13 @@ static int aif_mclk_set(struct snd_soc_component *component, int aif, bool enablreturn 0 ; } -if (enable) { - ret =clk_prepare_enable (wm8994->mclk[clk_idx].clk); -if (ret <0 ) { -dev_err (component->dev,"Failed to enable MCLK%d\n" , - clk_idx); -return ret; - } - }else { -clk_disable_unprepare (wm8994->mclk[clk_idx].clk); + ret =clk_prepare_enable (wm8994->mclk[clk_idx].clk); +if (ret <0 ) { +dev_err (component->dev,"Failed to enable MCLK%d\n" , + clk_idx +1 ); +return ret; } + wm8994->aif_mclk[aif] = wm8994->mclk[clk_idx].clk;return 0 ; }
sound/soc/codecs/wm8994.h +1 -0
@@ -81,6 +81,7 @@ struct wm8994_priv {struct wm_hubs_data hubs;struct wm8994 *wm8994;struct clk_bulk_data mclk[WM8994_NUM_MCLK ]; +struct clk *aif_mclk[2 ];int sysclk[2 ];int sysclk_rate[2 ];int mclk_rate[2 ];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1497/1756 ASoC: wm8994: dont lose the AIF clock ratio when staying at 32kHz SYSCLK
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
[ Upstream commit 693574504051a19383640cfb99524a6b69e4624f ]
When SYSCLK drops below 50kHz, the AIFnCLK rate ratio is saved and temporarily lowered to 128fs for accessory detection, then restored once SYSCLK gets fast enough again. The ratio is however saved again on each clock reconfiguration done while SYSCLK is still slow, which overwrites the original ratio with the 128fs one.
This happens on the Exynos4412 Trats2 board, which set MCLK2 as SYSCLK twice during the card probe and then configure FLL1 while still running from MCLK2. Once SYSCLK is switched to FLL1, the 128fs ratio is "restored", so AIF1 is left configured for 48kHz at 128fs while being clocked at 256fs. If any digital path is powered up before a stream reconfigures the AIF, the codec raises FIFO error interrupts every 10ms, flooding the kernel log:
wm8994-codec wm8994-codec: FIFO error
Save the original ratio only when entering the low SYSCLK mode. While at it, move the code duplicated in _wm8994_set_fll() and wm8994_set_dai_sysclk() to a common helper.
--- sound/soc/codecs/wm8994.c | 94 +++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 54 deletions(-)
sound/soc/codecs/wm8994.c +40 -54
@@ -2210,6 +2210,44 @@ static int wm8994_get_fll_config(struct wm8994 *control, struct fll_div *fll,return 0 ; } +/* +* If SYSCLK is less than 50kHz adjust AIFnCLK dividers for detection, +* restoring the original ones once SYSCLK is fast enough again. +*/ +static void wm8994_update_aif_clk_rate (struct snd_soc_component *component) +{ +struct wm8994_priv *wm8994 =snd_soc_component_get_drvdata (component); + +if (max (wm8994->aifclk[0 ], wm8994->aifclk[1 ]) <50000 ) { +/* Don't overwrite the saved dividers with the 128fs ones */ +if (!wm8994->aifdiv[0 ]) { +dev_dbg (component->dev,"Configuring AIFs for 128fs\n" ); + + wm8994->aifdiv[0 ] =snd_soc_component_read (component, +WM8994_AIF1_RATE ) + &WM8994_AIF1CLK_RATE_MASK ; + wm8994->aifdiv[1 ] =snd_soc_component_read (component, +WM8994_AIF2_RATE ) + &WM8994_AIF1CLK_RATE_MASK ; + } + +snd_soc_component_update_bits (component,WM8994_AIF1_RATE , +WM8994_AIF1CLK_RATE_MASK ,0x1 ); +snd_soc_component_update_bits (component,WM8994_AIF2_RATE , +WM8994_AIF2CLK_RATE_MASK ,0x1 ); + }else if (wm8994->aifdiv[0 ]) { +snd_soc_component_update_bits (component,WM8994_AIF1_RATE , +WM8994_AIF1CLK_RATE_MASK , + wm8994->aifdiv[0 ]); +snd_soc_component_update_bits (component,WM8994_AIF2_RATE , +WM8994_AIF2CLK_RATE_MASK , + wm8994->aifdiv[1 ]); + + wm8994->aifdiv[0 ] =0 ; + wm8994->aifdiv[1 ] =0 ; + } +} +static int _wm8994_set_fll (struct snd_soc_component *component,int id,int src,unsigned int freq_in,unsigned int freq_out) {
@@ -2444,33 +2482,7 @@ static int _wm8994_set_fll(struct snd_soc_component *component, int id, int src,configure_clock (component); -/* -* If SYSCLK will be less than 50kHz adjust AIFnCLK dividers -* for detection. -*/ -if (max (wm8994->aifclk[0 ], wm8994->aifclk[1 ]) <50000 ) { -dev_dbg (component->dev,"Configuring AIFs for 128fs\n" ); - - wm8994->aifdiv[0 ] =snd_soc_component_read (component,WM8994_AIF1_RATE ) - &WM8994_AIF1CLK_RATE_MASK ; - wm8994->aifdiv[1 ] =snd_soc_component_read (component,WM8994_AIF2_RATE ) - &WM8994_AIF1CLK_RATE_MASK ; - -snd_soc_component_update_bits (component,WM8994_AIF1_RATE , -WM8994_AIF1CLK_RATE_MASK ,0x1 ); -snd_soc_component_update_bits (component,WM8994_AIF2_RATE , -WM8994_AIF2CLK_RATE_MASK ,0x1 ); - }else if (wm8994->aifdiv[0 ]) { -snd_soc_component_update_bits (component,WM8994_AIF1_RATE , -WM8994_AIF1CLK_RATE_MASK , - wm8994->aifdiv[0 ]); -snd_soc_component_update_bits (component,WM8994_AIF2_RATE , -WM8994_AIF2CLK_RATE_MASK , - wm8994->aifdiv[1 ]); - - wm8994->aifdiv[0 ] =0 ; - wm8994->aifdiv[1 ] =0 ; - } +wm8994_update_aif_clk_rate (component);return 0 ; }
@@ -2588,33 +2600,7 @@ static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai,configure_clock (component); -/* -* If SYSCLK will be less than 50kHz adjust AIFnCLK dividers -* for detection. -*/ -if (max (wm8994->aifclk[0 ], wm8994->aifclk[1 ]) <50000 ) { -dev_dbg (component->dev,"Configuring AIFs for 128fs\n" ); - - wm8994->aifdiv[0 ] =snd_soc_component_read (component,WM8994_AIF1_RATE ) - &WM8994_AIF1CLK_RATE_MASK ; - wm8994->aifdiv[1 ] =snd_soc_component_read (component,WM8994_AIF2_RATE ) - &WM8994_AIF1CLK_RATE_MASK ; - -snd_soc_component_update_bits (component,WM8994_AIF1_RATE , -WM8994_AIF1CLK_RATE_MASK ,0x1 ); -snd_soc_component_update_bits (component,WM8994_AIF2_RATE , -WM8994_AIF2CLK_RATE_MASK ,0x1 ); - }else if (wm8994->aifdiv[0 ]) { -snd_soc_component_update_bits (component,WM8994_AIF1_RATE , -WM8994_AIF1CLK_RATE_MASK , - wm8994->aifdiv[0 ]); -snd_soc_component_update_bits (component,WM8994_AIF2_RATE , -WM8994_AIF2CLK_RATE_MASK , - wm8994->aifdiv[1 ]); - - wm8994->aifdiv[0 ] =0 ; - wm8994->aifdiv[1 ] =0 ; - } +wm8994_update_aif_clk_rate (component);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1498/1756 ASoC: wm8994: fix MCLK index used for setting MCLK rate
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
[ Upstream commit 7916b55b100973b5fb5b974e8f7c8ae9f3ac1d2e ]
wm8994_set_dai_sysclk() passes the AIF index (dai->id - 1) to wm8994_set_mclk_rate(), which uses it to index the MCLK clocks and their cached rates. As a result, selecting MCLK2 as the AIF1 clock source sets and reads back the rate of MCLK1 instead, and the rate of MCLK1 is then stored as the MCLK2 rate.
On the Exynos4412 Trats2 board, where MCLK1 is a fixed 24MHz clock and MCLK2 a 32768Hz clock used when the codec is idle, this gives:
wm8994-codec wm8994-codec: AIF1 using MCLK2 at 24000000Hz
so the driver assumes a 12MHz SYSCLK while it actually runs at 32kHz. This skips the 128fs AIF clock ratio setup for low SYSCLK rates and makes the mic detection rate configuration use the wrong clock rate.
Pass the MCLK index matching the selected clock source instead.
--- sound/soc/codecs/wm8994.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/wm8994.c +2 -2
@@ -2542,7 +2542,7 @@ static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai,case WM8994_SYSCLK_MCLK1 : wm8994->sysclk[dai->id -1 ] =WM8994_SYSCLK_MCLK1 ; - ret =wm8994_set_mclk_rate (wm8994, dai->id -1 , &freq); + ret =wm8994_set_mclk_rate (wm8994,WM8994_MCLK1 , &freq);if (ret <0 )return ret;
@@ -2555,7 +2555,7 @@ static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai,/* TODO: Set GPIO AF */ wm8994->sysclk[dai->id -1 ] =WM8994_SYSCLK_MCLK2 ; - ret =wm8994_set_mclk_rate (wm8994, dai->id -1 , &freq); + ret =wm8994_set_mclk_rate (wm8994,WM8994_MCLK2 , &freq);if (ret <0 )return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1499/1756 ASoC: samsung: midas_wm1811: run FLL1 at the AIF1 configured rate when idle
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
[ Upstream commit d9c23ac1217ab094e6bd9ab95e159ec72c8baca5 ]
When the codec is brought up without an active stream, for example because the mixer state restored by alsactl powers up a digital path, midas_start_fll1() sets FLL1 to the default 11.2896MHz rate. The codec's AIF1 however keeps the configuration of the last stream, or its reset default of 48kHz at 256fs before the first stream, which needs a 12.288MHz AIF1 clock. The digital paths then run with AIF1 clocked at a rate not matching its configuration.
Remember the FLL1 rate requested by the last hw_params() call, which matches the AIF1 configuration kept in the codec, and use it when no specific rate is requested. Change the default rate used before the first stream to 12.288MHz, matching the codec's default AIF1 configuration.
--- sound/soc/samsung/midas_wm1811.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
sound/soc/samsung/midas_wm1811.c +10 -4
@@ -25,7 +25,8 @@*/ #define MCLK1_RATE 24000000U#define MCLK2_RATE 32768U -#define DEFAULT_FLL1_RATE 11289600U +/* Matches the codec's default AIF1 configuration: 48kHz, 256fs */ +#define DEFAULT_FLL1_RATE 12288000Ustruct midas_priv {struct gpio_desc *gpio_fm_sel;
@@ -34,6 +35,7 @@ struct midas_priv {struct gpio_desc *gpio_headset_key;struct iio_channel *adc_headset_detect;unsigned int fll1_rate; +unsigned int aif1clk_rate;struct snd_soc_jack headset_jack; };
@@ -171,11 +173,12 @@ static int midas_start_fll1(struct snd_soc_pcm_runtime *rtd, unsigned int rate)if (!rate) rate = priv->fll1_rate;/* -* If no new rate is requested, set FLL1 to a sane default for jack -* detection. +* If no new rate is requested, set FLL1 to the rate the codec's AIF1 +* is currently configured for, as its digital paths can be powered +* up without an active stream. */ if (!rate) - rate =DEFAULT_FLL1_RATE ; + rate = priv->aif1clk_rate ?:DEFAULT_FLL1_RATE ;if (rate != priv->fll1_rate && priv->fll1_rate) {/* while reconfiguring, switch to MCLK2 for SYSCLK */
@@ -241,6 +244,7 @@ static int midas_aif1_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) {struct snd_soc_pcm_runtime *rtd =snd_soc_substream_to_rtd (substream); +struct midas_priv *priv =snd_soc_card_get_drvdata (rtd->card);unsigned int pll_out;/* AIF1CLK should be at least 3MHz for "optimal performance" */
@@ -249,6 +253,8 @@ static int midas_aif1_hw_params(struct snd_pcm_substream *substream,else pll_out =params_rate (params) *256 ; + priv->aif1clk_rate = pll_out; +return midas_start_fll1 (rtd, pll_out); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1500/1756 sh: Select BINFMT_FLAT_NO_DATA_START_OFFSET for !MMU
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Waldemar Brodkorb <[email protected]>
[ Upstream commit f45711b39e03ff5e80b60dcc1fd34b3fc7d3d36c ]
binfmt_flat offsets the in-memory start of the data segment by MAX_SHARED_LIBS words and then aligns it to FLAT_DATA_ALIGN, so FLAT_FLAG_RAM binaries end up with a gap between text and data (commit 2217b9826246 ("binfmt_flat: revert "binfmt_flat: don't offset the data start"")).
SH position-independent code finds the GOT with a PC-relative mova of _GLOBAL_OFFSET_TABLE_, which assumes data follows text directly, as elf2flt lays out the image. With the gap, the GOT register points below the real GOT, so every GOT load reads the neighbouring slot and gets a wrong pointer. On a J2 (sh2eb, no MMU) this made userland crash or hang right after start-up. In my case the data was moved up by 0x20 bytes.
Commit 04d82a6d0881 ("binfmt_flat: allow not offsetting data start") added CONFIG_BINFMT_FLAT_NO_DATA_START_OFFSET for architectures that cannot tolerate such a gap; currently only riscv !MMU selects it. Select it on SH as well when building without an MMU.
Tested on a J2 board (Numato Mimas V2, sh2eb, no MMU) with Linux 7.3 and FLAT binaries built with elf2flt: with this change the data segment starts exactly at the end of text and init runs.
Without the patch bootup fails with:
[ 12.080472] Fixing up unaligned userspace access in "init" pid=1 pc=0x(ptrval) ins=0x6583 [ 12.123609] Fixing up unaligned userspace access in "init" pid=1 pc=0x(ptrval) ins=0x6583 [ 12.175153] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00007f00
--- arch/sh/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/sh/Kconfig +1 -0
@@ -15,6 +15,7 @@ config SUPERH select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_WANT_IPC_PARSE_VERSION select ARCH_NEED_CMPXCHG_1_EMU + select BINFMT_FLAT_NO_DATA_START_OFFSET if !MMU select CPU_NO_EFFICIENT_FFS select DMA_DECLARE_COHERENT select GENERIC_ATOMIC64
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1501/1756 perf c2c: Fix memory leaks on output fields
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namhyung Kim <[email protected]>
[ Upstream commit 7d0fe18bc905a4bf59271e2f7ecc95479caebd7b ]
The perf_hpp_list was not freed after use. Let's add it for the main c2c hists list in perf c2c report and a local list in print_pareto().
Previously it was detected by ASAN like below.
=================================================================
==42183==ERROR: LeakSanitizer: detected memory leaks
Indirect leak of 1064 byte(s) in 7 object(s) allocated from:
#0 0x7f17334ef24f in calloc (/lib64/libasan.so.8+0xef24f) (BuildId: 61e8165ca90f7a4f06b73f064a938c76deaae079)
#1 0x0000005fa099 in zalloc ../../lib/zalloc.c:8
#2 0x0000004faf6d in get_format tools/perf/builtin-c2c.c:1978
#3 0x0000004fb45e in c2c_hists__init_output tools/perf/builtin-c2c.c:2004
#4 0x0000004fb7de in __hpp_list__parse tools/perf/builtin-c2c.c:2047
#5 0x0000004fbae9 in hpp_list__parse tools/perf/builtin-c2c.c:2085
#6 0x0000004fee13 in print_pareto tools/perf/builtin-c2c.c:2563
#7 0x0000004ffcd7 in perf_c2c__hists_fprintf tools/perf/builtin-c2c.c:2708
#8 0x000000500ab5 in perf_c2c_display tools/perf/builtin-c2c.c:2949
#9 0x0000005045c3 in perf_c2c__report tools/perf/builtin-c2c.c:3522
#10 0x000000505caa in cmd_c2c tools/perf/builtin-c2c.c:3676
#11 0x0000005df50e in run_builtin tools/perf/perf.c:383
#12 0x0000005df9b1 in handle_internal_command tools/perf/perf.c:436
#13 0x0000005dfd7f in run_argv tools/perf/perf.c:480
#14 0x0000005e02d6 in main tools/perf/perf.c:581
#15 0x7f1729450680 in __libc_start_call_main (/lib64/libc.so.6+0x3680) (BuildId: 85075e2ae2e13352a1413d41c327dacf6461526c)
#16 0x7f1729450797 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x3797) (BuildId: 85075e2ae2e13352a1413d41c327dacf6461526c)
#17 0x000000409c34 in _start (tools/perf/perf+0x409c34) (BuildId: 36a64600776d92e4ab7dfd5ca20c92280d72a645)SUMMARY: AddressSanitizer: 1064 byte(s) leaked in 7 allocation(s).
--- tools/perf/builtin-c2c.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
tools/perf/builtin-c2c.c +13 -3
@@ -2076,6 +2076,11 @@ static int c2c_hists__reinit(struct c2c_hists *c2c_hists,return hpp_list__parse (&c2c_hists->list, output, sort); } +static void c2c_hists__exit (struct c2c_hists *c2c_hists) +{ +perf_hpp__reset_output_field (&c2c_hists->list); +} +#define DISPLAY_LINE_LIMIT 0.001static u8 filter_display (u32 val,u32 sum)
@@ -2475,7 +2480,7 @@ static void print_pareto(FILE *out) ret =hpp_list__parse (&hpp_list, cl_output,NULL );if (WARN_ONCE (ret,"failed to setup sort entries\n" )) -return ; + goto out; nd =rb_first_cached (&c2c.hists.hists.entries);
@@ -2489,6 +2494,9 @@ static void print_pareto(FILE *out) c2c_he = container_of(he, struct c2c_hist_entry, he);print_cacheline (c2c_he->hists, he, &hpp_list, out); } + +out: +perf_hpp__reset_output_field (&hpp_list); }static void print_c2c_info (FILE *out,struct perf_session *session)
@@ -3105,12 +3113,12 @@ static int perf_c2c__report(int argc, const char **argv) err =setup_nodes (session);if (err) {pr_err ("Failed setup nodes\n" ); - goto out_session; + goto out_hists; } err =mem2node__init (&c2c.mem2node, &session->header.env);if (err) - goto out_session; + goto out_hists; err =setup_callchain (session->evlist);if (err)
@@ -3197,6 +3205,8 @@ static int perf_c2c__report(int argc, const char **argv) out_mem2node:mem2node__exit (&c2c.mem2node); +out_hists: +c2c_hists__exit (&c2c.hists); out_session:perf_session__delete (session); out:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1502/1756 perf cs-etm: Bounds-check CPU in cs_etm__get_queue()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 9a989e60cc6e29d98aed2087425cba53bf4b392d ]
cs_etm__get_queue() indexes etm->queues.queue_array[cpu] without validating that cpu is within nr_queues. When processing AUX_OUTPUT_HW_ID events, the cpu value comes from untrusted perf.data trace payload and flows through cs_etm__process_trace_id_v0_1() and cs_etm__queue_aux_fragment() without bounds checking, allowing an out-of-bounds read with a crafted file.
Add a bounds check in cs_etm__get_queue() and NULL checks in all callers.
Also add NULL checks for queue_array[i].priv in the queue iteration loops in cs_etm__map_trace_id_v0() and cs_etm__process_trace_id_v0_1() — after auxtrace_queues__grow() new entries are zero-initialized so .priv can be NULL. Add a get_cpu_data() NULL check in cs_etm__process_trace_id_v0_1(), matching the existing check in cs_etm__process_trace_id_v0().
Stable-dep-of: 31627cfb63ae ("perf cs-etm: Don't add global v0 HW_IDs to unformatted queues")
--- tools/perf/util/cs-etm.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)
tools/perf/util/cs-etm.c +23 -2
@@ -292,8 +292,11 @@ static struct cs_etm_queue *cs_etm__get_queue(struct cs_etm_auxtrace *etm, int c {if (etm->per_thread_decoding)return etm->queues.queue_array[0 ].priv; -else -return etm->queues.queue_array[cpu].priv; + +if (cpu <0 || cpu >= (int )etm->queues.nr_queues) +return NULL ; + +return etm->queues.queue_array[cpu].priv; } static int cs_etm__map_trace_id_v0(struct cs_etm_auxtrace *etm, u8 trace_chan_id,
@@ -306,6 +309,9 @@ static int cs_etm__map_trace_id_v0(struct cs_etm_auxtrace *etm, u8 trace_chan_id* queue associated with that CPU so only one decoder is made. */ etmq =cs_etm__get_queue (etm, cpu_metadata[CS_ETM_CPU ]); +if (!etmq) +return -EINVAL ; +if (etmq->format ==UNFORMATTED )return cs_etm__insert_trace_id_node (etmq, trace_chan_id, cpu_metadata);
@@ -318,6 +324,9 @@ static int cs_etm__map_trace_id_v0(struct cs_etm_auxtrace *etm, u8 trace_chan_idint ret; etmq = etm->queues.queue_array[i].priv; +if (!etmq) +continue ; + ret =cs_etm__insert_trace_id_node (etmq, trace_chan_id, cpu_metadata);if (ret)
@@ -358,6 +367,9 @@ static int cs_etm__process_trace_id_v0_1(struct cs_etm_auxtrace *etm, int cpu,u32 sink_id =FIELD_GET (CS_AUX_HW_ID_SINK_ID_MASK , hw_id);u8 trace_id =FIELD_GET (CS_AUX_HW_ID_TRACE_ID_MASK , hw_id); +if (!etmq) +return -EINVAL ; +/* * Check sink id hasn't changed in per-cpu mode. In per-thread mode, * let it pass for now until an actual overlapping trace ID is hit. In
@@ -375,6 +387,9 @@ static int cs_etm__process_trace_id_v0_1(struct cs_etm_auxtrace *etm, int cpu,for (unsigned int i =0 ; i < etm->queues.nr_queues; ++i) {struct cs_etm_queue *other_etmq = etm->queues.queue_array[i].priv; +if (!other_etmq) +continue ; +/* Different sinks, skip */ if (other_etmq->sink_id != etmq->sink_id)continue ;
@@ -396,6 +411,9 @@ static int cs_etm__process_trace_id_v0_1(struct cs_etm_auxtrace *etm, int cpu, } cpu_data =get_cpu_data (etm, cpu); +if (!cpu_data) +return -EINVAL ; + ret =cs_etm__insert_trace_id_node (etmq, trace_id, cpu_data);if (ret)return ret;
@@ -3192,6 +3210,9 @@ static int cs_etm__queue_aux_fragment(struct perf_session *session, off_t file_o aux_offset + aux_size <= auxtrace_event->offset + auxtrace_event->size) {struct cs_etm_queue *etmq = etm->queues.queue_array[auxtrace_event->idx].priv; +if (!etmq) +return -EINVAL ; +/* * If this AUX event was inside this buffer somewhere, create a new auxtrace event * based on the sizes of the aux event, and queue that fragment.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1503/1756 perf cs-etm: Dont add global v0 HW_IDs to unformatted queues
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Clark <[email protected]>
[ Upstream commit 31627cfb63ae4af5a233dc6ced04e5172789aa92 ]
In the case of mixed formatted and unformatted trace with v0 HW_IDs, or no HW_IDs at all resulting in the cs_etm__map_trace_ids_metadata() fallback, formatted queues will write their HW_IDs to unformatted queues. This will result in an assert because of multiple decoders on an unformatted queue.
Fix it by not inserting trace ID nodes on other unformatted queues. This isn't an issue for v0.1 HW_IDs because they aren't global so will only add to their own queue.
--- tools/perf/util/cs-etm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
tools/perf/util/cs-etm.c +6 -6
@@ -304,27 +304,27 @@ static int cs_etm__map_trace_id_v0(struct cs_etm_auxtrace *etm, u8 trace_chan_id {struct cs_etm_queue *etmq; -/* -* If the queue is unformatted then only save one mapping in the -* queue associated with that CPU so only one decoder is made. -*/ etmq =cs_etm__get_queue (etm, cpu_metadata[CS_ETM_CPU ]);if (!etmq)return -EINVAL ; +/* +* If the queue is unformatted then only save one mapping in the +* queue associated with that CPU so only one decoder is made. +*/ if (etmq->format ==UNFORMATTED )return cs_etm__insert_trace_id_node (etmq, trace_chan_id, cpu_metadata);/* * Otherwise, version 0 trace IDs are global so save them into every -* queue. +* formatted queue. */ for (unsigned int i =0 ; i < etm->queues.nr_queues; ++i) {int ret; etmq = etm->queues.queue_array[i].priv; -if (!etmq) +if (!etmq || etmq->format ==UNFORMATTED )continue ; ret = cs_etm__insert_trace_id_node(etmq, trace_chan_id,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1504/1756 nvme-fabrics: reset io_queues before computing the queue mapping
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Wagner <[email protected]>
[ Upstream commit 9588769af5fc8ac12290d48ce1014a78916681fc ]
nvmf_set_io_queues only sets the io_queues entries of the queue types it hands out, but the array is reused on every reconnect. When the controller grants fewer queues on a reconnect, stale entries survive and nvmf_map_queues maps CPUs to hardware contexts that don't exist anymore, which crashes blk_mq_map_swqueue with a NULL pointer dereference. E.g. with nr_io_queues=8, nr_write_queues=8 and nr_poll_queues=8, 24 queues are mapped 8/8/8 (default/read/poll). If the controller grants only 16 queues on the reconnect, the poll map still starts at hardware context 16.
Clear the array before computing the new mapping.
--- drivers/nvme/host/fabrics.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/nvme/host/fabrics.c +2 -0
@@ -1097,6 +1097,8 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,void nvmf_set_io_queues (struct nvmf_ctrl_options *opts,u32 nr_io_queues,u32 io_queues[HCTX_MAX_TYPES ]) { +memset (io_queues,0 ,sizeof (*io_queues) *HCTX_MAX_TYPES ); +if (opts->nr_write_queues && opts->nr_io_queues < nr_io_queues) {/* * separate read/write queues
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1505/1756 nvme-fabrics: limit each queue type to the number of online CPUs
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Wagner <[email protected]>
[ Upstream commit 99fd0cbae84988e0af34784aa18ddd51ae094ade ]
nvmf_nr_io_queues limits each queue type to the number of online CPUs when asking for I/O queues, but nvmf_set_io_queues hands out the granted queues without these limits, and only nr_io_queues is clamped when parsing the options.
E.g. with 2 CPUs, nr_io_queues=2, nr_write_queues=10 and nr_poll_queues=10, 2 + 2 + 2 = 6 queues are requested, but handed out as 4 default, 2 read and 0 poll queues. blk_mq_map_queues can't create more CPU masks than there are CPUs, so default queues 2 and 3 take over the CPUs of default queues 0 and 1, and connecting the I/O queue of default queue 1 fails with -EXDEV.
Apply the same limits in nvmf_set_io_queues. A queue type with more queues than online CPUs always has a hardware context without an online CPU, so no working setup changes. The options are not modified, so the limits follow CPU hotplug on reconnect.
--- drivers/nvme/host/fabrics.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/nvme/host/fabrics.c +15 -6
@@ -1097,18 +1097,27 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,void nvmf_set_io_queues (struct nvmf_ctrl_options *opts,u32 nr_io_queues,u32 io_queues[HCTX_MAX_TYPES ]) { +/* +* Each queue type is mapped to the CPUs separately, so a type with +* more queues than online CPUs has hardware contexts without an online +* CPU. Use the same limits as nvmf_nr_io_queues. +*/ +u32 nr_io =min (opts->nr_io_queues,num_online_cpus ()); +u32 nr_write =min (opts->nr_write_queues,num_online_cpus ()); +u32 nr_poll =min (opts->nr_poll_queues,num_online_cpus ()); +memset (io_queues,0 ,sizeof (*io_queues) *HCTX_MAX_TYPES ); -if (opts->nr_write_queues && opts->nr_io_queues < nr_io_queues) { +if (nr_write && nr_io < nr_io_queues) {/* * separate read/write queues * hand out dedicated default queues only after we have * sufficient read queues. */ - io_queues[HCTX_TYPE_READ ] = opts->nr_io_queues; + io_queues[HCTX_TYPE_READ ] = nr_io; nr_io_queues -= io_queues[HCTX_TYPE_READ ]; io_queues[HCTX_TYPE_DEFAULT ] = -min (opts->nr_write_queues, nr_io_queues); +min (nr_write, nr_io_queues); nr_io_queues -= io_queues[HCTX_TYPE_DEFAULT ]; }else {/*
@@ -1117,14 +1126,14 @@ void nvmf_set_io_queues(struct nvmf_ctrl_options *opts, u32 nr_io_queues,* sufficient queue count to have dedicated default queues. */ io_queues[HCTX_TYPE_DEFAULT ] = -min (opts->nr_io_queues, nr_io_queues); +min (nr_io, nr_io_queues); nr_io_queues -= io_queues[HCTX_TYPE_DEFAULT ]; } -if (opts->nr_poll_queues && nr_io_queues) { +if (nr_poll && nr_io_queues) {/* map dedicated poll queues only if we have queues left */ io_queues[HCTX_TYPE_POLL ] = -min (opts->nr_poll_queues, nr_io_queues); +min (nr_poll, nr_io_queues); } }EXPORT_SYMBOL_GPL (nvmf_set_io_queues);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1506/1756 nvme-fabrics: clear the poll map if no poll queues are mapped
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Wagner <[email protected]>
[ Upstream commit 36ede1aa85d5d74c39ed375a906f6eadb15cee5b ]
blk_mq_alloc_tag_set sets the nr_queues of every map to nr_hw_queues. When nr_poll_queues is set but no queues are left for polling, nvmf_map_queues skips the poll map and leaves it this way, with all CPUs mapped to hctx 0. The queue then claims poll support, polled I/O ends up on hctx 0, which isn't a poll queue, and hctx 0 is marked as a poll hctx, so even the Connect command of the first I/O queue is marked as polled.
Clear the poll map when no poll queues are mapped, so polled I/O is rejected with -EOPNOTSUPP.
--- drivers/nvme/host/fabrics.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/nvme/host/fabrics.c +7 -0
@@ -1171,6 +1171,13 @@ void nvmf_map_queues(struct blk_mq_tag_set *set, struct nvme_ctrl *ctrl, io_queues[HCTX_TYPE_DEFAULT ] + io_queues[HCTX_TYPE_READ ];blk_mq_map_queues (&set->map[HCTX_TYPE_POLL ]); + }else { +/* +* blk_mq_alloc_tag_set sets nr_queues of all maps to +* nr_hw_queues. Clear the poll map, otherwise the queue claims +* poll support and polled I/O ends up on hctx 0. +*/ + set->map[HCTX_TYPE_POLL ].nr_queues =0 ; } dev_info(ctrl->device,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1507/1756 mailbox: qcom-cpucp: Add support for Nord CPUCP mailbox controller
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Deepti Jaggi <[email protected]>
[ Upstream commit 0edda639ba13d9da37447586b5480582a2581e2b ]
The Nord SoC CPUCP mailbox supports 16 IPC channels, compared to 3 on x1e80100. The existing driver hardcodes the channel count via a compile-time constant (APSS_CPUCP_IPC_CHAN_SUPPORTED), making it impossible to support hardware with a different number of channels.
Introduce a qcom_cpucp_mbox_data per-hardware configuration struct that carries the channel count, and retrieve it via of_device_get_match_data() at probe time. Switch the channel array from a fixed-size member to a dynamically allocated buffer sized from the hardware data. Update the x1e80100 entry to supply its own data struct, and add a new Nord entry with num_chans = 16.
Stable-dep-of: 74f1cf02d9fe ("mailbox: qcom-cpucp: read mbox hardware register using readq()")
--- drivers/mailbox/qcom-cpucp-mbox.c | 35 ++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-)
drivers/mailbox/qcom-cpucp-mbox.c +30 -5
@@ -12,7 +12,6 @@#include <linux/module.h> #include <linux/platform_device.h> -#define APSS_CPUCP_IPC_CHAN_SUPPORTED 3#define APSS_CPUCP_MBOX_CMD_OFF 0x4/* Tx Registers */
@@ -26,6 +25,14 @@#define APSS_CPUCP_RX_MBOX_EN 0x4c00#define APSS_CPUCP_RX_MBOX_CMD_MASK GENMASK_ULL(63, 0) +/** +* struct qcom_cpucp_mbox_data - Per-hardware mailbox configuration data +* @num_chans: Number of IPC channels supported by this hardware +*/ +struct qcom_cpucp_mbox_data { +int num_chans; +}; +/** * struct qcom_cpucp_mbox - Holder for the mailbox driver * @chans: The mailbox channel
@@ -34,7 +41,7 @@* @rx_base: Base address of the CPUCP rx registers */ struct qcom_cpucp_mbox { -struct mbox_chan chans[APSS_CPUCP_IPC_CHAN_SUPPORTED ]; +struct mbox_chan *chans;struct mbox_controller mbox;void __iomem *tx_base;void __iomem *rx_base;
@@ -53,7 +60,7 @@ static irqreturn_t qcom_cpucp_mbox_irq_fn(int irq, void *data) status =readq (cpucp->rx_base +APSS_CPUCP_RX_MBOX_STAT ); -for_each_set_bit (i, (unsigned long *)&status,APSS_CPUCP_IPC_CHAN_SUPPORTED ) { +for_each_set_bit (i, (unsigned long *)&status, cpucp->mbox.num_chans) {u32 val =readl (cpucp->rx_base +APSS_CPUCP_RX_MBOX_CMD (i) +APSS_CPUCP_MBOX_CMD_OFF );struct mbox_chan *chan = &cpucp->chans[i];struct mbox_client *cl;
@@ -131,15 +138,24 @@ static const struct mbox_chan_ops qcom_cpucp_mbox_chan_ops = {static int qcom_cpucp_mbox_probe (struct platform_device *pdev) { +const struct qcom_cpucp_mbox_data *data;struct device *dev = &pdev->dev;struct qcom_cpucp_mbox *cpucp;struct mbox_controller *mbox;int irq, ret; + data =of_device_get_match_data (dev); +if (!data) +return dev_err_probe (dev, -EINVAL ,"No match data found\n" ); + cpucp =devm_kzalloc (dev,sizeof (*cpucp),GFP_KERNEL );if (!cpucp)return -ENOMEM ; + cpucp->chans =devm_kcalloc (dev, data->num_chans,sizeof (*cpucp->chans),GFP_KERNEL ); +if (!cpucp->chans) +return -ENOMEM ; + cpucp->rx_base =devm_of_iomap (dev, dev->of_node,0 ,NULL );if (IS_ERR (cpucp->rx_base))return PTR_ERR (cpucp->rx_base);
@@ -165,7 +181,7 @@ static int qcom_cpucp_mbox_probe(struct platform_device *pdev) mbox = &cpucp->mbox; mbox->dev = dev; - mbox->num_chans =APSS_CPUCP_IPC_CHAN_SUPPORTED ; + mbox->num_chans = data->num_chans; mbox->chans = cpucp->chans; mbox->ops = &qcom_cpucp_mbox_chan_ops;
@@ -176,8 +192,17 @@ static int qcom_cpucp_mbox_probe(struct platform_device *pdev)return 0 ; } +static const struct qcom_cpucp_mbox_data qcom_x1e80100_mbox_data = { + .num_chans =3 , +}; + +static const struct qcom_cpucp_mbox_data qcom_nord_mbox_data = { + .num_chans =16 , +}; +static const struct of_device_id qcom_cpucp_mbox_of_match[] = { - { .compatible ="qcom,x1e80100-cpucp-mbox" }, + { .compatible ="qcom,nord-cpucp-mbox" , .data = &qcom_nord_mbox_data }, + { .compatible ="qcom,x1e80100-cpucp-mbox" , .data = &qcom_x1e80100_mbox_data }, {} };MODULE_DEVICE_TABLE (of, qcom_cpucp_mbox_of_match);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1508/1756 mailbox: qcom-cpucp: read mbox hardware register using readq()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sivansh Gupta <[email protected]>
[ Upstream commit 74f1cf02d9fe0fd32ca299cd4d71bc29d3bf2a54 ]
Mailbox hardware registers are 64 bit wide, but the interrupt handler currently reads only 32 bits with readl() at offset 0x4 (upper 32 bits). This returns an incorrect value, while reading using readq() returns the expected value.
Use readq() to access the 64 bit register and pass the expected value to the mailbox client.
--- drivers/mailbox/qcom-cpucp-mbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mailbox/qcom-cpucp-mbox.c +1 -1
@@ -61,7 +61,7 @@ static irqreturn_t qcom_cpucp_mbox_irq_fn(int irq, void *data) status =readq (cpucp->rx_base +APSS_CPUCP_RX_MBOX_STAT );for_each_set_bit (i, (unsigned long *)&status, cpucp->mbox.num_chans) { -u32 val =readl (cpucp->rx_base +APSS_CPUCP_RX_MBOX_CMD (i) +APSS_CPUCP_MBOX_CMD_OFF ); +u64 val =readq (cpucp->rx_base +APSS_CPUCP_RX_MBOX_CMD (i));struct mbox_chan *chan = &cpucp->chans[i];struct mbox_client *cl;unsigned long flags;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1509/1756 ionic: fix port_info use-after-free on firmware recovery
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikhil P. Rao <[email protected]>
[ Upstream commit d90d1a768b3b022c52beafb3a4701ee2ee3d2b5e ]
ionic_port_init() allocates port_info when the pointer is NULL, but its error path frees it without checking whether this call allocated it. Before commit ddc5911b9bd2 ("ionic: call ionic_port_init after fw-upgrade") the function returned early when the buffer already existed, so the two were symmetric.
Since then a failed PORT_INIT on either recovery path - fw_up or reset_done - frees a buffer an earlier init owns, while the netdev is registered and the ethtool ops are reading it.
Free only what this call allocated.
--- drivers/net/ethernet/pensando/ionic/ionic_main.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_main.c +9 -4
@@ -715,6 +715,7 @@ int ionic_port_init(struct ionic *ionic) {struct ionic_identity *ident = &ionic->ident;struct ionic_dev *idev = &ionic->idev; +bool allocated = false;size_t sz;int err;
@@ -726,6 +727,8 @@ int ionic_port_init(struct ionic *ionic) GFP_KERNEL);if (!idev->port_info)return -ENOMEM ; + + allocated = true; } sz =min (sizeof (ident->port.config),sizeof (idev->dev_cmd_regs->data));
@@ -742,10 +745,12 @@ int ionic_port_init(struct ionic *ionic)mutex_unlock (&ionic->dev_cmd_lock);if (err) {dev_err (ionic->dev,"Failed to init port\n" ); -dma_free_coherent (ionic->dev, idev->port_info_sz, - idev->port_info, idev->port_info_pa); - idev->port_info =NULL ; - idev->port_info_pa =0 ; +if (allocated) { +dma_free_coherent (ionic->dev, idev->port_info_sz, + idev->port_info, idev->port_info_pa); + idev->port_info =NULL ; + idev->port_info_pa =0 ; + } }return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1510/1756 ionic: free port_info when probe fails after the port is set up
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Joyner <[email protected]>
[ Upstream commit 4e15e0a941ce901d51b5f203713fa90feee9c4d3 ]
ionic_probe() allocates the port_info DMA buffer via ionic_setup_one() -> ionic_port_init(). If probe then fails anywhere after that, it unwinds through err_out_pci, which never calls ionic_port_reset(); ionic_dev_teardown() and ionic_clear_pci() do not touch port_info, and so the buffer is leaked. The call was lost when the setup code was moved into ionic_setup_one().
Since ionic_remove() already frees the port_info DMA buffer with ionic_port_reset(), call that on the probe error path too. Every path to err_out_pci runs after ionic_setup_one() succeeded, so the BARs are still mapped and the firmware gets a PORT_RESET before the buffer is freed, the same order as in ionic_remove().
--- drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c +1 -0
@@ -392,6 +392,7 @@ static int ionic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err_out_free_irqs:ionic_bus_free_irq_vectors (ionic); err_out_pci: +ionic_port_reset (ionic);ionic_dev_teardown (ionic);ionic_clear_pci (ionic);ionic_debugfs_del_dev (ionic);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1511/1756 virtio-net: fix frag overflow in big packets receive
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Willem de Bruijn <[email protected]>
[ Upstream commit b0e4ea3a0cd42eccad9cc4153afcad555480b9e6 ]
In big packets mode with guest GSO, add_recvbuf_big() posts a chain of MAX_SKB_FRAGS + 1 pages. page_to_skb() copies only ETH_HLEN of the first page into the linear area and adds the rest of that page as a frag, then one frag per remaining page. A device that fills the entire buffer therefore causes MAX_SKB_FRAGS + 1 frags, writing one skb_frag_t past the end of skb_shinfo(skb)->frags[].
Post one page less. The buffer still fits a maximal GSO packet. A well behaved device does not trigger this, as GSO packets are at most 64KB.
Also check the frag count in page_to_skb() before adding any frag as defense in depth.
--- drivers/net/virtio_net.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/net/virtio_net.c +11 -1
@@ -847,6 +847,15 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi, }BUG_ON (offset >=PAGE_SIZE ); + +/* The first frag starts at offset, each next frag is a full page. */ +if (unlikely (DIV_ROUND_UP (offset + len,PAGE_SIZE ) >MAX_SKB_FRAGS )) { +pr_debug ("%s: rx error: len %u needs more than %d frags\n" , + vi->dev->name, len,MAX_SKB_FRAGS ); +kfree_skb (skb); +return NULL ; + } +while (len) {unsigned int frag_size =min ((unsigned )PAGE_SIZE - offset, len); skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page, offset,
@@ -6450,7 +6459,8 @@ static void virtnet_set_big_packets(struct virtnet_info *vi, const int mtu)*/ if (mtu >ETH_DATA_LEN || guest_gso) { vi->big_packets = true; - vi->big_packets_num_skbfrags = guest_gso ?MAX_SKB_FRAGS :DIV_ROUND_UP (mtu,PAGE_SIZE ); + vi->big_packets_num_skbfrags = guest_gso ?MAX_SKB_FRAGS -1 : +DIV_ROUND_UP (mtu,PAGE_SIZE ); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1512/1756 net: sparx5/lan969x: do not clobber the PSFP cycle timer update period
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Machon <[email protected]>
[ Upstream commit 5a3dcad8e101ddcd3a886907c8992df54472f749 ]
sparx5_psfp_init() enables the periodic stream gate cycle timer update, which keeps the cycle start time of each stream gate within one cycle time of the current time. SG_CT_CLKS sets the update period, in system clock cycles.
Before this patch, the update is enabled with a full register write of SG_CT_UPDATE_ENA only, which also sets SG_CT_CLKS to zero. That is below the documented minimum, the number of stream gates (1024 on sparx5 and 256 on lan969x).
Write both fields, and set the period to the recommended 10 us, computed from the core clock since it differs per target (6250 cycles at 625 MHz, 3280 at 328 MHz).
Found by an AI code review agent, and confirmed on lan969x and sparx5 by reading the register back as 0x80000000.
--- drivers/net/ethernet/microchip/sparx5/sparx5_psfp.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/ethernet/microchip/sparx5/sparx5_psfp.c +9 -1
@@ -317,6 +317,7 @@ int sparx5_psfp_fm_del(struct sparx5 *sparx5, u32 id)void sparx5_psfp_init (struct sparx5 *sparx5) {const struct sparx5_sdlb_group *group; +u32 sg_ct_clks;int i;for (i =0 ; i <SPX5_SDLB_GROUP_CNT ; i++) {
@@ -325,7 +326,14 @@ void sparx5_psfp_init(struct sparx5 *sparx5) group->min_burst, group->frame_size, i); } -spx5_wr (ANA_AC_SG_CYCLETIME_UPDATE_PERIOD_SG_CT_UPDATE_ENA_SET (1 ), +/* Poll the stream gate cycle start times every 10 us. The core clock +* period is in picoseconds. +*/ + sg_ct_clks =10 *NSEC_PER_USEC *PSEC_PER_NSEC / +sparx5_clk_period (sparx5->coreclock); + +spx5_wr (ANA_AC_SG_CYCLETIME_UPDATE_PERIOD_SG_CT_CLKS_SET (sg_ct_clks) | +ANA_AC_SG_CYCLETIME_UPDATE_PERIOD_SG_CT_UPDATE_ENA_SET (1 ), sparx5,ANA_AC_SG_CYCLETIME_UPDATE_PERIOD ); spx5_rmw(ANA_L2_FWD_CFG_ISDX_LOOKUP_ENA_SET(1),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1513/1756 veth: schedule the peers NAPI after XDP_TX when only GRO is enabled
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tianyi Gao <[email protected]>
[ Upstream commit f16b8c6a656e62bfa7bb6a3b876f9ccdaf53bd43 ]
veth_xdp_xmit() queues XDP_TX frames on the peer's ring if the peer has NAPI. A peer with GRO enabled and no XDP program also has NAPI.
veth_xdp_flush() then schedules the peer's NAPI, but only if the peer's xdp_prog is set, so for such a peer the frames are never processed. Nothing else schedules that NAPI by default.
Once the ring is full, every XDP_TX frame is dropped, and so are the skbs that veth_xmit() queues on the same ring.
Commit 0e672f306a28 ("veth: check for NAPI instead of xdp_prog before xmit of XDP frame") changed the check in veth_xdp_xmit() but not the one in veth_xdp_flush(). Make veth_xdp_flush() check the napi pointer instead of xdp_prog, as veth_xdp_xmit() does.
--- drivers/net/veth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/veth.c +1 -1
@@ -615,7 +615,7 @@ static void veth_xdp_flush(struct veth_rq *rq, struct veth_xdp_tx_bq *bq) rcv_priv =netdev_priv (rcv); rcv_rq = &rcv_priv->rq[veth_select_rxq (rcv)];/* xdp_ring is initialized on receive side? */ -if (unlikely (!rcu_access_pointer (rcv_rq->xdp_prog))) +if (unlikely (!rcu_access_pointer (rcv_rq->napi))) goto out;__veth_xdp_flush (rcv_rq);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1514/1756 net: shrink the payload-only part of skb dataref to one bit
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 4957ea03bf2696f5da12c09144f48d040696ecc2 ]
skb_shinfo(skb)->dataref is split in two 16-bit halves: the lower one counts all references, the upper one the payload-only (nohdr) references.
__skb_clone() increments dataref without bound, and skb_cloned() only checks the low 16 bits. With 65,537 references the low half reads 1, the head looks private, and pskb_expand_head() (or skb_unclone(), skb_cow(), ...) frees it while clones still point to it.
An unprivileged user can reach this from a user and network namespace:
about 32,770 AF_PACKET sockets on lo bring dataref to 0x10001, then any pskb_expand_head() on the receive path (here a pull of a large IPv6 Hop-by-Hop header) frees the shared head:
BUG: KASAN: slab-use-after-free in _copy_to_iter+0x187/0x1330 Read of size 1590 at addr ff110001104a9002 by task dataref_wrap/87 skb_copy_datagram_iter+0x60/0x190 packet_recvmsg+0x1f5/0x12b0 __sys_recvfrom+0x18d/0x290 Freed by task 87: kfree+0xf3/0x3b0 pskb_expand_head+0x344/0xeb0 __pskb_pull_tail+0xf9/0x1bf0 ipv6_parse_hopopts+0x377/0x4f0 ip6_rcv_core+0xc67/0x1620
The upper half never holds more than 1. It is only set by __skb_header_release(), with atomic_set() on an skb owning its head (TCP/SCTP output, and GRO which never sees cloned skbs). __skb_clone() clears nohdr, and __copy_skb_header() does not copy it.
Move SKB_DATAREF_SHIFT to 30, so that the reference count gets 30 bits, and dataref stays positive. Wrapping it would need 2^30 live clones of a single skb, which socket buffer limits and memory make unreachable.
This issue was found by Anthropic using Claude, and validated by Ada Logics.
--- include/linux/skbuff.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
include/linux/skbuff.h +4 -4
@@ -619,9 +619,9 @@ struct skb_shared_info {* * Transport layers send out clones of payload skbs they hold for * retransmissions. To allow lower layers of the stack to prepend their headers -* we split &skb_shared_info.dataref into two halves. -* The lower 16 bits count the overall number of references. -* The higher 16 bits indicate how many of the references are payload-only. +* we split &skb_shared_info.dataref into two parts. +* The lower 30 bits count the overall number of references. +* Bit 30 indicates whether one of the references is payload-only. * skb_header_cloned() checks if skb is allowed to add / write the headers. * * The creator of the skb (e.g. TCP) marks its skb as &sk_buff.nohdr
@@ -641,7 +641,7 @@ struct skb_shared_info {* Having multiple payload-only skbs with different lengths of hdr_len is not * possible. The payload-only skbs should never leave their owner. */ -#define SKB_DATAREF_SHIFT 16 +#define SKB_DATAREF_SHIFT 30#define SKB_DATAREF_MASK ((1 << SKB_DATAREF_SHIFT) - 1)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1515/1756 tg3: Add Datto SIRIS 5 1U Server to restart AER quirk table
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Travis Howard <[email protected]>
[ Upstream commit a55eb6a622141352131aa6156bbd6ce5da79d9b5 ]
The Datto SIRIS 5 1U Server is a Dell OEMR XL R640 (Dell's OEM-ready variant of the PowerEdge R640) sold under Datto's identity. Its DMI strings report sys_vendor "datto" and product_name "SIRIS 5 1U Server", so it does not match the existing "PowerEdge R640" entry in tg3_restart_aer_quirk_table.
As on the PowerEdge R640, a system restart triggers a fatal PCIe AER on the BCM5720 during ACPI _PTS for S5, which the iDRAC logs as PCI1318 and which hangs the reboot. Power off is unaffected.
Clearing the same PCI_EXP_DEVCTL error-reporting bits on both BCM5720 functions from userspace immediately before restart allows the system to reboot normally, confirming the quirk applies to this platform.
--- drivers/net/ethernet/broadcom/tg3.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/broadcom/tg3.c +6 -0
@@ -18187,6 +18187,12 @@ static const struct dmi_system_id tg3_restart_snp_quirk_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge R750"), }, }, + { + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "datto"), + DMI_MATCH(DMI_PRODUCT_NAME, "SIRIS 5 1U Server"), + }, + }, {} };
Signature · 1 line
2.53.0
Re: [PATCH 6.12 1515/1756] tg3: Add Datto SIRIS 5 1U Server to restart AER quirk table
Hi Greg/Sasha,
Quoted 36 lines · Greg Kroah-Hartman
6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Travis Howard <[email protected]>
[ Upstream commit
a55eb6a622141352131aa6156bbd6ce5da79d9b5]The Datto SIRIS 5 1U Server is a Dell OEMR XL R640 (Dell's OEM-ready variant of the PowerEdge R640) sold under Datto's identity. Its DMI strings report
sys_vendor"datto" andproduct_name"SIRIS 5 1U Server", so it does not match the existing "PowerEdge R640" entry intg3_restart_aer_quirk_table.As on the PowerEdge R640, a system restart triggers a fatal PCIe AER on the BCM5720 during ACPI
_PTSfor S5, which the iDRAC logs as PCI1318 and which hangs the reboot. Power off is unaffected.Clearing the same
PCI_EXP_DEVCTLerror-reporting bits on both BCM5720 functions from userspace immediately before restart allows the system to reboot normally, confirming the quirk applies to this platform.Fixes e0efe83ed325 ("tg3: Disable tg3 PCIe AER on system reboot")Signed-off-by Travis Howard <[email protected]>Link https://patch.msgid.link/20261019-tg3-datto-aer-quirk-v1-1-f0eccfb2ab5d@lafayetteinstrument.com open hereSigned-off-by Jakub Kicinski <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/net/ethernet/broadcom/tg3.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/net/ethernet/broadcom/tg3.c +0
-0
drivers/net/ethernet/broadcom/tg3.c static const struct dmi_system_id tg3_restart_snp_quirk_table[] = { · line 18194
Quoted 8 lines
drivers/net/ethernet/broadcom/tg3.c +5
-0@@ -18187,6 +18187,12 @@ static const struct dmi_system_id tg3_restart_snp_quirk_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge R750"), }, }, + { + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"datto" ), + DMI_MATCH(DMI_PRODUCT_NAME, "SIRIS 5 1U Server"), + },
I ran an AI-assisted backport review and I checked the finding against the code, and it looks valid to me.
Verdict: lets drop this ?
Upstream a55eb6a62214 added Datto to tg3_restart_aer_quirk_table to disable AER reporting during restart.
But 6.12.y already has ccbf0e078b4f, which replaces that table with tg3_restart_snp_quirk_table and removes Datto.
This backport adds Datto to the replacement table, which controls power-down in tg3_shutdown():
if (!dmi_first_match(tg3_restart_snp_quirk_table) ||
system_state == SYSTEM_POWER_OFF) {
tg3_power_down(tp);Datto now skips tg3_power_down() during restart, reversing the behavior established by ccbf0e078b4f.
Could we drop this patch? The original AER quirk was superseded; adding it to the replacement table changes its meaning I think.
Thanks,
Harshit
Quoted 4 lines
drivers/net/ethernet/broadcom/tg3.c +1
-0+ }, {} };
Sasha Levin
maintainerRe: [PATCH 6.12 1515/1756] tg3: Add Datto SIRIS 5 1U Server to restart AER quirk table
Quoted 2 lines
Could we drop this patch? The original AER quirk was superseded; adding it to the replacement table changes its meaning I think.
Dropped from all trees, thanks.
Signature · 2 lines
Thanks, Sasha
Greg Kroah-Hartman
maintainerPATCH 1516/1756 ata: libata-core: Ignore forced transfer modes the host does not support
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rand Deeb <[email protected]>
[ Upstream commit ea5a5af9159cc89e8bcb7a95336e02c8b70aa3d2 ]
The libata.force parameter can force a transfer mode (pio0-6, mwdma0-4, udma0-7) for a port or device. ata_force_xfermask() applies it in ata_do_set_mode() right after ata_dev_xfermask() has limited the device masks to what the host supports. It replaces those masks with the forced mode without checking the host masks, so a mode the controller does not support is passed to the driver's ->set_piomode() or ->set_dmamode().
Several PATA drivers rely on the host masks to keep the mode number in range when indexing their timing tables. ata_piix, pata_efar, pata_it8213, pata_oldpiix, pata_radisys and pata_rdc declare ATA_PIO4 and ATA_MWDMA12_ONLY, index a five-entry PIO timing table with pio_mode - XFER_PIO_0, and index a three-entry needed_pio[] table with dma_mode - XFER_MW_DMA_0. Booting with libata.force=pio5, pio6, mwdma3 or mwdma4 makes them read past those tables, use the values read as further indices into the timing table, and write the result to the controller's timing registers.
Make ata_force_xfermask() skip, with a warning, a forced transfer mode that is not in the port's PIO, MWDMA or UDMA mask, and keep looking for an earlier matching libata.force entry, as it already does for entries that do not apply to the device. With libata.force=pio4,1.0:pio5 on a PIO4 host, device 1.0 now gets pio4 instead of pio5. Forcing a mode the host supports still works as before, including a mode that ata_dev_xfermask() removed for the device or cable.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/ata/libata-core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/ata/libata-core.c +12 -0
@@ -432,6 +432,7 @@ static void ata_force_link_limits(struct ata_link *link)*/ static void ata_force_xfermask (struct ata_device *dev) { +struct ata_port *ap = dev->link->ap;int devno = dev->link->pmp + dev->devno;int alt_devno = devno;int i;
@@ -456,6 +457,17 @@ static void ata_force_xfermask(struct ata_device *dev)ata_unpack_xfermask (fe->param.xfer_mask, &pio_mask, &mwdma_mask, &udma_mask); + +/* Make sure that the port supports the specified xfer modes. */ +if (!(pio_mask & ap->pio_mask) && + !(mwdma_mask & ap->mwdma_mask) && + !(udma_mask & ap->udma_mask)) { +ata_dev_warn (dev, +"FORCE: ignoring unsupported xfer_mask %s\n" , + fe->param.name); +continue ; + } +if (udma_mask) dev->udma_mask = udma_mask;else if (mwdma_mask) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1517/1756 tipc: fix use-after-free of broadcast reception link at node release
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Binbin Deng <[email protected]>
[ Upstream commit 473167593f42551ce6b00c05cee8cd20309d45ac ]
When the last reference to a tipc_node is dropped, the node itself is deferred to the RCU callback tipc_node_free(), but the nested broadcast reception link, n->bc_entry.link, is kfree()d synchronously in tipc_node_kref_release(), before call_rcu(), and the pointer is never cleared. Readers that obtained the node from node_list and then dereference bc_entry.link deep into the link (tipc_link_name() in tipc_nl_node_reset_link_stats(), bcl->name/stats in tipc_nl_add_bc_link() on the link dump path) therefore touch freed memory although the enclosing node stays alive for a full grace period. The sibling per-bearer links get "kfree + NULL" under the node write lock in tipc_node_clear_links(); the broadcast entry was missed.
The race is reachable through the node cleanup timer: once a peer has been unreachable for NODE_CLEANUP_AFTER (300 s), tipc_node_timeout() -> tipc_node_cleanup() unlinks the node under the write lock, and the final tipc_node_put() at the caller runs outside node_list_lock, so the kfree executes in timer softirq context, concurrently with genl dump/ reset walkers that hold only rcu_read_lock(). (A netlink "peer remove" cannot race those walkers itself: tipc_genl_family has no parallel_ops, so all doit/dumpit calls serialize on the global genl lock.)
Reproduced in a QEMU/KVM guest running v7.3.0 with KASAN and PREEMPT(full): 10 TIPC peer namespaces on veth bearers, bearer removal staggered so the 300 s node cleanup timers expire while other tasks loop link dumps with the broadcast filter and reset-link-stats lookups. KASAN hit within two cleanup cycles:
BUG: KASAN: slab-use-after-free in strlen+0x85/0xa0 Read of size 1 at addr ffff88800b54a004 by task poc_eth/371 strlen+0x85/0xa0 tipc_nl_add_bc_link+0x2f9/0xd40 __tipc_nl_add_node_links+0x10c/0x140 tipc_nl_node_dump_link+0x8d5/0xd50 Freed by task 0: kfree+0x121/0x380 tipc_node_timeout+0xa33/0xcf0 run_timer_softirq+0x144/0x250 sysvec_apic_timer_interrupt
with the freed object being the kmalloc-1k tipc_link allocated by tipc_link_bc_create() during peer discovery. The same defect fires in strcmp() called from tipc_nl_node_reset_link_stats().
Move the kfree of n->bc_entry.link into the tipc_node_free() RCU callback so the broadcast link lives exactly as long as the enclosing node. All readers are covered: the netlink walkers are inside rcu_read_lock(), and the packet reception path reaches the node via tipc_node_find(), whose kref defers kref_release itself.
Found during a static-analysis-assisted audit: candidate sites were surfaced by a Coccinelle rule, and the reader/writer paths were confirmed by LLM-assisted (GLM-5.3) code inspection.
--- net/tipc/node.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/tipc/node.c +1 -1
@@ -303,6 +303,7 @@ static void tipc_node_free(struct rcu_head *rp)#ifdef CONFIG_TIPC_CRYPTO tipc_crypto_stop (&n->crypto_rx);#endif +kfree (n->bc_entry.link);kfree (n); }
@@ -310,7 +311,6 @@ static void tipc_node_kref_release(struct kref *kref) { struct tipc_node *n = container_of(kref, struct tipc_node, kref); -kfree (n->bc_entry.link);call_rcu (&n->rcu, tipc_node_free); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1518/1756 ASoC: wm8994: follow AIF clock source changes in MCLK gating
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
[ Upstream commit 8731e33a3b98ea1ccade059b3a1ce06b7dd66b17 ]
The AIF clock source can be changed by configure_aif_clock() while the AIF clock is running, for example the Midas machine driver switches AIF1 between MCLK2 and FLL1 while AIF1CLK is kept enabled for jack detection. aif_mclk_set() only enables the MCLK selected at the time the AIF clock is turned on, so an MCLK selected later this way is never enabled, and the codec may run from a stopped clock.
Track whether the AIF clock is running and, if so, enable the newly selected MCLK in configure_aif_clock() before switching to it, then release the previously enabled one.
--- sound/soc/codecs/wm8994.c | 27 +++++++++++++++++++++++++++ sound/soc/codecs/wm8994.h | 1 + 2 files changed, 28 insertions(+)
sound/soc/codecs/wm8994.c +27 -0
@@ -162,9 +162,12 @@ static void wm8958_micd_set_rate(struct snd_soc_component *component)static int configure_aif_clock (struct snd_soc_component *component,int aif) {struct wm8994_priv *wm8994 =snd_soc_component_get_drvdata (component); +struct clk *mclk =NULL ; +bool switch_mclk;int rate;int reg1 =0 ;int offset; +int ret;if (aif) offset =4 ;
@@ -173,11 +176,13 @@ static int configure_aif_clock(struct snd_soc_component *component, int aif)switch (wm8994->sysclk[aif]) {case WM8994_SYSCLK_MCLK1 : + mclk = wm8994->mclk[WM8994_MCLK1 ].clk; rate = wm8994->mclk_rate[0 ];break ;case WM8994_SYSCLK_MCLK2 : reg1 |=0x8 ; + mclk = wm8994->mclk[WM8994_MCLK2 ].clk; rate = wm8994->mclk_rate[1 ];break ;
@@ -195,6 +200,20 @@ static int configure_aif_clock(struct snd_soc_component *component, int aif)return -EINVAL ; } +/* +* If the AIF clock is running, enable the new MCLK before switching +* to it and release the previous one afterwards. +*/ + switch_mclk = wm8994->aif_clk_on[aif] && mclk != wm8994->aif_mclk[aif]; +if (switch_mclk) { + ret =clk_prepare_enable (mclk); +if (ret <0 ) { +dev_err (component->dev, +"Failed to enable MCLK for AIF%d\n" , aif +1 ); +return ret; + } + } +if (rate >=13500000 ) { rate /=2 ; reg1 |=WM8994_AIF1CLK_DIV ;
@@ -209,6 +228,11 @@ static int configure_aif_clock(struct snd_soc_component *component, int aif)WM8994_AIF1CLK_SRC_MASK |WM8994_AIF1CLK_DIV , reg1); +if (switch_mclk) { +clk_disable_unprepare (wm8994->aif_mclk[aif]); + wm8994->aif_mclk[aif] = mclk; + } +return 0 ; }
@@ -1070,6 +1094,7 @@ static int aif_mclk_set(struct snd_soc_component *component, int aif, bool enablif (!enable) {clk_disable_unprepare (wm8994->aif_mclk[aif]); wm8994->aif_mclk[aif] =NULL ; + wm8994->aif_clk_on[aif] = false;return 0 ; }
@@ -1089,6 +1114,7 @@ static int aif_mclk_set(struct snd_soc_component *component, int aif, bool enabl clk_idx =WM8994_MCLK2 ;break ;default : + wm8994->aif_clk_on[aif] = true;return 0 ; }
@@ -1099,6 +1125,7 @@ static int aif_mclk_set(struct snd_soc_component *component, int aif, bool enablreturn ret; } wm8994->aif_mclk[aif] = wm8994->mclk[clk_idx].clk; + wm8994->aif_clk_on[aif] = true;return 0 ; }
sound/soc/codecs/wm8994.h +1 -0
@@ -82,6 +82,7 @@ struct wm8994_priv {struct wm8994 *wm8994;struct clk_bulk_data mclk[WM8994_NUM_MCLK ];struct clk *aif_mclk[2 ]; +bool aif_clk_on[2 ];int sysclk[2 ];int sysclk_rate[2 ];int mclk_rate[2 ];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1519/1756 proc/kcore: advance the vmalloc retry by the last copy, not the total
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nickolai Zeldovich <[email protected]>
[ Upstream commit 88c3f9d6145204cfd88e5d9cbc9463ffd892e10a ]
A readv() or preadv() of /proc/kcore fails with EFAULT, although every byte of the destination is writable, when the page of a later iovec is not present at the moment the copy of a KCORE_VMALLOC chunk is retried:
swapped out, migrated by compaction or NUMA balancing, write-protected by KSM, or unmapped by MADV_DONTNEED from another thread. Only root can read /proc/kcore, and the read must use more than one iovec. On an x86_64 defconfig kernel (v7.3-rc7) a preadv() of one vmalloc page into two 2 KiB iovecs on separate pages, with a second thread repeatedly unmapping the second page, failed 77701 of 200000 calls with EFAULT; with the fix all 200000 succeed. Affected since v6.4.
read_kcore_iter() copies a KCORE_VMALLOC chunk with vread_iter(), which writes to the user buffer with page faults disabled and stops at the first iovec whose page is absent, after the earlier iovecs were written; the loop then faults the rest of the buffer in and calls vread_iter() again for what is left. It keeps the running total in read and advances the source address and the remaining length by that total:
read += vread_iter(iter, src, left); if (read == tsz) break; src += read; left -= read;
In the reproducer the first call copies the 2048 bytes of the first iovec and stops at the second: read is 2048, and src and left move by 2048, which is right. The page that fault_in_iov_iter_writeable() then faults in is unmapped again before the second call, which copies 0
bytes: read is still 2048, but src moves by another 2048 to the end of the chunk and left drops to 0. The third call has nothing to copy, src moves by 2048 once more, left wraps around, and fault_in_iov_iter_writeable() fails on that length, so the read returns -EFAULT. When both short copies are non-zero (three or more iovecs) the extra call also copies bytes from the wrong offset of the page into the buffer before the failure. A single iovec is not affected: its nofault copy is all or nothing, so a short copy is always empty and the advance by the total is still the advance by the last copy.
Keep the return value of each vread_iter() call and advance src and left by that; read stays the running total compared with tsz.
Found while formally verifying vread_iter() against the kernel binary.
--- fs/proc/kcore.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
fs/proc/kcore.c +5 -3
@@ -531,12 +531,14 @@ static ssize_t read_kcore_iter(struct kiocb *iocb, struct iov_iter *iter)* again until we are done. */ while (true) { - read +=vread_iter (iter, src, left); +size_t n =vread_iter (iter, src, left); + + read += n;if (read == tsz)break ; - src += read; - left -= read; + src += n; + left -= n;if (fault_in_iov_iter_writeable (iter, left)) { ret = -EFAULT ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1520/1756 eventpoll: propagate wakeup source creation failure in ep_modify()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tianyi Chen <[email protected]>
[ Upstream commit 9f2b8f4a452db79741c06e6ea91448347f4a975c ]
When EPOLL_CTL_MOD adds EPOLLWAKEUP, ep_modify() ignores the return value of ep_create_wakeup_source(). If allocation fails, it returns success with EPOLLWAKEUP set but no per-item wakeup source, so the requested suspend protection is missing.
This can happen without fault injection on SELinux systems: creating the wakeup source's sysfs nodes can require GFP_KERNEL_ACCOUNT allocations for security.selinux xattrs, which can fail when the caller's memory cgroup is over its limit.
Create the wakeup source before updating the event mask and data, and return the error if creation fails. Leave any newly created per-epoll source in place until ep_free(), as ep_insert() does on failure.
--- fs/eventpoll.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
fs/eventpoll.c +13 -5
@@ -1912,11 +1912,22 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi, {int pwake =0 ;poll_table pt; +int error;lockdep_assert_irqs_enabled ();init_poll_funcptr (&pt,NULL ); +/* +* Create the wakeup source before committing the new event mask. +* Leave the old mask and data unchanged if allocation fails. +*/ +if ((event->events &EPOLLWAKEUP ) && !ep_has_wakeup_source (epi)) { + error =ep_create_wakeup_source (epi); +if (error) +return error; + } +/* * Set the new event interest mask before calling f_op->poll(); * otherwise we might miss an event that happens between the
@@ -1924,12 +1935,9 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi,*/ epi->event.events = event->events;/* need barrier below */ epi->event.data = event->data;/* protected by mtx */ -if (epi->event.events &EPOLLWAKEUP ) { -if (!ep_has_wakeup_source (epi)) -ep_create_wakeup_source (epi); - }else if (ep_has_wakeup_source (epi)) { +if (!(epi->event.events &EPOLLWAKEUP ) && +ep_has_wakeup_source (epi))ep_destroy_wakeup_source (epi); - }/* * The following barrier has two effects:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1521/1756 netfs: Restore selective debug mask handling
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 62400ce406f66b1154dfbd0d60a7e3baa374e105 ]
The netfs debug macros test only whether netfs_debug is nonzero. Consequently, selecting one debug point enables every entry, exit and general debug message.
Documentation/filesystems/caching/fscache.rst and the NETFS_DEBUG Kconfig help still describe /sys/module/netfs/parameters/debug as a bitmask of per-stream function entry, exit and general debugging points, and the fscache_*.c files still define FSCACHE_DEBUG_LEVEL, but nothing has decoded either since the mask handling was dropped when FS-Cache was folded into netfs.
Restore the per-level and per-point mask decoding. Files that do not define FSCACHE_DEBUG_LEVEL, which includes the netfs core, fall under the cache management stream, the same default the FS-Cache macros had.
--- fs/netfs/internal.h | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-)
fs/netfs/internal.h +29 -3
@@ -401,6 +401,32 @@ void fscache_create_volume(struct fscache_volume *volume, bool wait);#define kleave (FMT , ...) dbgprintk("<== %s()"FMT"", __func__, ##__VA_ARGS__)#define kdebug (FMT , ...) dbgprintk(FMT, ##__VA_ARGS__) +#define FSCACHE_DEBUG_CACHE 0 +#define FSCACHE_DEBUG_COOKIE 1 +#define FSCACHE_DEBUG_OBJECT 2 +#define FSCACHE_DEBUG_OPERATION 3 + +#define FSCACHE_POINT_ENTER 1 +#define FSCACHE_POINT_LEAVE 2 +#define FSCACHE_POINT_DEBUG 4 + +#ifndef FSCACHE_DEBUG_LEVEL +#define FSCACHE_DEBUG_LEVEL CACHE +#endif + +/* +* Determine whether a particular optional debugging point should be logged. +* Three levels of indirection are needed to expand FSCACHE_DEBUG_LEVEL before +* joining it with its prefix. +*/ +#define ____do_kdebug (LEVEL ,POINT ) \ + unlikely(netfs_debug & \ + (FSCACHE_POINT_##POINT << (FSCACHE_DEBUG_ ## LEVEL * 3))) +#define ___do_kdebug (LEVEL ,POINT ) \ + ____do_kdebug(LEVEL, POINT) +#define __do_kdebug (POINT ) \ + ___do_kdebug(FSCACHE_DEBUG_LEVEL, POINT) +#ifdef __KDEBUG#define _enter (FMT , ...) kenter(FMT, ##__VA_ARGS__)#define _leave (FMT , ...) kleave(FMT, ##__VA_ARGS__)
@@ -409,19 +435,19 @@ void fscache_create_volume(struct fscache_volume *volume, bool wait);#elif defined(CONFIG_NETFS_DEBUG )#define _enter (FMT , ...) \ do { \ - if (netfs_debug) \ + if (__do_kdebug(ENTER)) \ kenter(FMT, ##__VA_ARGS__); \ } while (0)#define _leave (FMT , ...) \ do { \ - if (netfs_debug) \ + if (__do_kdebug(LEAVE)) \ kleave(FMT, ##__VA_ARGS__); \ } while (0)#define _debug (FMT , ...) \ do { \ - if (netfs_debug) \ + if (__do_kdebug(DEBUG)) \ kdebug(FMT, ##__VA_ARGS__); \ } while (0)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1522/1756 signal: skip blocked signals in dequeue_synchronous_signal()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Avi Weiss <[email protected]>
[ Upstream commit 4bd3a0e8e53decd614853fbb487a268f139f679e ]
dequeue_synchronous_signal() checks whether an unblocked synchronous signal is pending, but its queue scan can select a different blocked entry with a positive si_code. This can deliver a signal while it is still blocked.
Check the blocked mask for each queued entry. Forced faults are unblocked when necessary by force_sig_info_to_task(), and the existing pending bookkeeping is unchanged.
--- kernel/signal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/signal.c +3 -2
@@ -716,12 +716,13 @@ static int dequeue_synchronous_signal(kernel_siginfo_t *info)return 0 ;/* -* Return the first synchronous signal in the queue. +* Return the first unblocked synchronous signal in the queue. */ list_for_each_entry (q, &pending->list, list) {/* Synchronous signals have a positive si_code */ if ((q->info.si_code >SI_USER ) && - (sigmask (q->info.si_signo) &SYNCHRONOUS_MASK )) { + (sigmask (q->info.si_signo) &SYNCHRONOUS_MASK ) && + !sigismember (&tsk->blocked, q->info.si_signo)) { sync = q; goto next; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1523/1756 nsproxy: Fix cred leak in the error path of prepare_nsset()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nickolai Zeldovich <[email protected]>
[ Upstream commit e08601d3a7b2236f4915497dca353dcf117bab5c ]
A task that calls setns() with CLONE_NEWUSER together with CLONE_NEWNS and at least one more namespace flag leaks a struct cred (and the user_namespace, ucounts and group_info references it holds) whenever the call fails at the fs_struct copy. On a kernel with CONFIG_USER_NS the leak is one cred per failed setns(); under memory pressure, or driven by a fault-injecting attacker, it accumulates and pins user namespaces that can then never be freed.
prepare_nsset() sets nsset->flags only on the success path:
if (flags & CLONE_NEWUSER)
nsset->cred = prepare_creds();
...
} else if (flags & CLONE_NEWNS) {
nsset->fs = copy_fs_struct(me->fs);
if (!nsset->fs)
goto out; /* flags still 0 here */
}
nsset->flags = flags;
return 0;
out:
put_nsset(nsset);put_nsset() decides what to release from nsset->flags:
if (flags & CLONE_NEWUSER) put_cred(nsset_cred(nsset));
On the copy_fs_struct() failure arm prepare_creds() has already allocated the cred, but nsset->flags is still the zero from the caller's "struct nsset nsset = {}", so put_nsset() does not see CLONE_NEWUSER and never drops it. The caller (__do_sys_setns) returns the error without touching nsset, so the cred is lost.
Set nsset->flags at the start of prepare_nsset(), before anything can fail, so every error exit through put_nsset() releases what was taken. commit_nsset(), which clears nsset->cred on success, is unaffected.
Reproduced on x86_64 under QEMU with failslab aimed at the fs_struct cache and kmemleak enabled: 500 calls ofsetns(pidfd, CLONE_NEWUSER | CLONE_NEWNS | CLONE_NEWUTS) each fail with -ENOMEM and leave 851 unreferenced cred objects allocated from prepare_creds() via setns() before the fix, and none after (the program is in the notes below).
Found by formal verification of kernel/nsproxy.c.
--- kernel/nsproxy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/nsproxy.c +1 -1
@@ -332,6 +332,7 @@ static int prepare_nsset(unsigned flags, struct nsset *nsset) {struct task_struct *me = current; + nsset->flags = flags; nsset->nsproxy =create_new_namespaces (0 , me,current_user_ns (), me->fs);if (IS_ERR (nsset->nsproxy))return PTR_ERR (nsset->nsproxy);
@@ -352,7 +353,6 @@ static int prepare_nsset(unsigned flags, struct nsset *nsset) goto out; } - nsset->flags = flags;return 0 ; out:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1524/1756 ACPICA: Initialize parser_state.aml_end in acpi_install_method()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ivan Hu <[email protected]>
[ Upstream commit ec696f34774db985841bac9a2df179c0040ef073 ]
In AcpiInstallMethod(), the local ParserState is stack-allocated and only ParserState.Aml was initialized. Parser helpers called by this path read ParserState.AmlEnd for bounds checking: AcpiPsPeekOpcode() reads it before validating the first AML opcode, and AcpiPsGetNextPackageEnd() reads it indirectly via AcpiPsGetNextPackageLength(). The subsequent package-limit check also compares against ParserState.AmlEnd. Because AmlEnd was never set, these checks operated on an uninitialized value, which Coverity flagged as an uninitialized read (CID 1684785) and which could lead to incorrect parser bounds decisions.
Coverity report:
*** CID 1684785: Memory - illegal accesses (UNINIT)
/src/acpica/source/components/namespace/nsxfname.c: 712 in AcpiInstallMethod()
ParserState.Aml += AcpiPsGetOpcodeSize (Opcode);
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
CID 1684785: Memory - illegal accesses (UNINIT)
Using uninitialized value "ParserState.AmlEnd" when calling
"AcpiPsGetNextPackageEnd".
ParserState.PkgEnd = AcpiPsGetNextPackageEnd (&ParserState);Initialize ParserState.AmlEnd to the end of the table (Buffer + Table->Length) so the parser bounds checks operate on a valid limit.
--- drivers/acpi/acpica/nsxfname.c | 1 + 1 file changed, 1 insertion(+)
drivers/acpi/acpica/nsxfname.c +1 -0
@@ -503,6 +503,7 @@ acpi_status acpi_install_method(u8 *buffer)/* First AML opcode in the table must be a control method */ parser_state.aml = buffer +sizeof (struct acpi_table_header ); + parser_state.aml_end = buffer + table->length; opcode =acpi_ps_peek_opcode (&parser_state);if (opcode !=AML_METHOD_OP ) {return (AE_BAD_PARAMETER );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1525/1756 ksmbd: select CRYPTO_AES
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michail Andreas Michalopoulos <[email protected]>
[ Upstream commit 2c36c4a86104d763ee798d4a89e2d3384b4cd626 ]
ksmbd allocates "gcm(aes)" and "ccm(aes)" AEAD transforms for SMB3 encryption, but SMB_SERVER only selects CRYPTO_GCM and CRYPTO_CCM, not an AES cipher. With a configuration in which nothing else enables CRYPTO_AES, ksmbd builds but cannot allocate the transforms, and every session that uses encryption fails:
ksmbd: Failed to alloc encrypt aead : -2
ksmbd: crypto alloc failed
Select CRYPTO_AES, as the SMB client already does.
--- fs/smb/server/Kconfig | 1 + 1 file changed, 1 insertion(+)
fs/smb/server/Kconfig +1 -0
@@ -18,6 +18,7 @@ config SMB_SERVER select CRYPTO_AEAD2 select CRYPTO_CCM select CRYPTO_GCM + select CRYPTO_AES select ASN1 select OID_REGISTRY select CRC32
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1526/1756 ASoC: amd: raven: Fix memory leak in acp3x_dma_close()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit e0b17f84f6e3fa1201b8e2857094023c42ce5636 ]
acp3x_dma_open() allocates a struct i2s_stream_instance for each substream, but acp3x_dma_close() never frees it, leaking it on every open/close cycle.
Free it in acp3x_dma_close().
--- sound/soc/amd/raven/acp3x-pcm-dma.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/amd/raven/acp3x-pcm-dma.c +2 -0
@@ -354,6 +354,8 @@ static int acp3x_dma_close(struct snd_soc_component *component, } } +kfree (ins); +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1527/1756 cpuidle: haltpoll: Only define guest_halt_poll_ns tracepoint when used
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <[email protected]>
[ Upstream commit 107b87efc8fcd6a597f1b534f116385620770e56 ]
Tracepoints that are defined take up around 5K each, even if they are not used. When a tracepoint is used only in code when a specific config is enabled, their definition must also be only defined when the same config is enabled otherwise it wastes memory.
The tracepoint guest_halt_poll_ns is only used when CONFIG_CPU_IDLE_GOV_HALTPOLL is enabled. Guard the definition of that tracepoint with the same config.
--- include/trace/events/power.h | 3 +++ 1 file changed, 3 insertions(+)
include/trace/events/power.h +3 -0
@@ -522,6 +522,7 @@ DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_remove_request,TP_ARGS (name, type, new_value) ); +#ifdef CONFIG_CPU_IDLE_GOV_HALTPOLL TRACE_EVENT(guest_halt_poll_ns, TP_PROTO(bool grow, unsigned int new, unsigned int old),
@@ -550,6 +551,8 @@ TRACE_EVENT(guest_halt_poll_ns, trace_guest_halt_poll_ns(true, new, old)#define trace_guest_halt_poll_ns_shrink (new, old) \ trace_guest_halt_poll_ns(false, new, old) +#endif /* CONFIG_CPU_IDLE_GOV_HALTPOLL */ +#endif /* _TRACE_POWER_H */ /* This part must be outside protection */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1528/1756 regulator: irq_helper: replace use of system_wq with system_dfl_wq
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marco Crivellari <[email protected]>
[ Upstream commit b6f4bd64f453183954184ffbc2b89d73ed8fb135 ]
Currently if a user enqueues a work item using schedule_delayed_work() the used wq is "system_wq" (per-cpu wq) while queue_delayed_work() use WORK_CPU_UNBOUND (used when a cpu is not specified). The same applies to schedule_work() that is using system_wq and queue_work(), that makes use again of WORK_CPU_UNBOUND.
This lack of consistency cannot be addressed without refactoring the API.
This continues the effort to refactor worqueue APIs, which has begun with the change introducing new workqueues and a new alloc_workqueue flag:
commit 128ea9f6ccfb ("workqueue: Add system_percpu_wq and system_dfl_wq") commit 930c2ea566af ("workqueue: Add new WQ_PERCPU flag")
This specific workload do not benefit from a per-cpu workqueue, so use the default unbound workqueue (system_dfl_wq) instead.
Stable-dep-of: 8a6d73e316f9 ("regulator: irq: freeze deferred hardware access during suspend")
--- drivers/regulator/irq_helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/irq_helpers.c +1 -1
@@ -146,7 +146,7 @@ static void regulator_notifier_isr_work(struct work_struct *work) reschedule:if (!d->high_prio) -mod_delayed_work (system_wq, &h->isr_work, +mod_delayed_work (system_dfl_wq, &h->isr_work,msecs_to_jiffies (tmo));else mod_delayed_work(system_highpri_wq, &h->isr_work,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1529/1756 regulator: irq: freeze deferred hardware access during suspend
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 8a6d73e316f95e398a1de1d1f58314b6d3e7f641 ]
The regulator IRQ helper delays status checks and recovery callbacks on non-freezable workqueues. Those callbacks may access regulator hardware after the backing bus has been suspended.
Use system_freezable_wq for normal-priority callbacks. Allocate a freezable high-priority workqueue when requested so the high_prio contract is preserved while hardware access is frozen across suspend.
--- drivers/regulator/irq_helpers.c | 38 +++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 16 deletions(-)
drivers/regulator/irq_helpers.c +22 -16
@@ -15,6 +15,7 @@#include <linux/regmap.h> #include <linux/slab.h> #include <linux/spinlock.h> +#include <linux/workqueue.h> #include <linux/regulator/driver.h> #include "internal.h"
@@ -27,6 +28,7 @@ struct regulator_irq {int irq;int retry_cnt;struct delayed_work isr_work; +struct workqueue_struct *wq; };/*
@@ -145,12 +147,7 @@ static void regulator_notifier_isr_work(struct work_struct *work)return ; reschedule: -if (!d->high_prio) -mod_delayed_work (system_dfl_wq, &h->isr_work, -msecs_to_jiffies (tmo)); -else -mod_delayed_work (system_highpri_wq, &h->isr_work, -msecs_to_jiffies (tmo)); +mod_delayed_work (h->wq, &h->isr_work,msecs_to_jiffies (tmo)); }static irqreturn_t regulator_notifier_isr (int irq,void *data)
@@ -248,13 +245,8 @@ static irqreturn_t regulator_notifier_isr(int irq, void *data) }if (d->irq_off_ms) { -if (!d->high_prio) -schedule_delayed_work (&h->isr_work, -msecs_to_jiffies (d->irq_off_ms)); -else -mod_delayed_work (system_highpri_wq, - &h->isr_work, -msecs_to_jiffies (d->irq_off_ms)); +mod_delayed_work (h->wq, &h->isr_work, +msecs_to_jiffies (d->irq_off_ms)); }return IRQ_HANDLED ;
@@ -363,13 +355,25 @@ void *regulator_irq_helper(struct device *dev,init_rdev_errors (h); -if (h->desc.irq_off_ms) +if (h->desc.irq_off_ms) { +if (h->desc.high_prio) { + h->wq =alloc_workqueue ("regulator_irq_highpri" , +WQ_FREEZABLE |WQ_HIGHPRI ,0 ); +if (!h->wq) +return ERR_PTR (-ENOMEM ); + }else { + h->wq = system_freezable_wq; + } +INIT_DELAYED_WORK (&h->isr_work, regulator_notifier_isr_work); + } ret =request_threaded_irq (h->irq,NULL , regulator_notifier_isr,IRQF_ONESHOT | irq_flags, h->desc.name, h);if (ret) {dev_err (dev,"Failed to request IRQ %d\n" , irq); +if (h->desc.irq_off_ms && h->desc.high_prio) +destroy_workqueue (h->wq);return ERR_PTR (ret); }
@@ -393,8 +397,11 @@ void regulator_irq_helper_cancel(void **handle)struct regulator_irq *h = *handle;free_irq (h->irq, h); -if (h->desc.irq_off_ms) +if (h->desc.irq_off_ms) {cancel_delayed_work_sync (&h->isr_work); +if (h->desc.high_prio) +destroy_workqueue (h->wq); + } h =NULL ; }
@@ -441,4 +448,3 @@ int regulator_irq_map_event_simple(int irq, struct regulator_irq_data *rid,return 0 ; }EXPORT_SYMBOL_GPL (regulator_irq_map_event_simple); -
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1530/1756 sctp: reject forged cookie peer_addr with unknown address family
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xingyuan Mo <[email protected]>
[ Upstream commit 9802123ceca818aa69284c615114ca55b9cc94a1 ]
When cookie authentication is disabled, COOKIE-ECHO peer_addr is attacker-controlled. An invalid sa_family made sctp_get_af_specific() return NULL and crash in sctp_transport_init() on af_specific->sockaddr_len. Validate it with af->addr_valid() in sctp_unpack_cookie(), which also rejects a mismatched family, e.g. an AF_INET6 peer_addr on an IPv4 socket that would later crash in sctp_v6_get_dst() on inet6_sk(sk)->opt. Validate a copy of peer_addr, since addr_valid() rewrites a v4-mapped v6 address in place and the cookie still lives in the received skb, which is not guaranteed to be unshared. Store the validated copy in the new association and pass it to sctp_process_init() instead of the raw cookie, so a v4-mapped v6 address is normalised to AF_INET before the association and its primary transport are built from it.
For that, sctp_v6_addr_valid() has to return 0 for a non-v4-mapped address when it is called with a socket that is not PF_INET6, so that IPv6 addresses are never used on IPv4 sockets. The check is done after the v4-mapped handling, so v4-mapped addresses passed to an IPv4 socket through the socket API keep being accepted. As addr_valid() now also checks sk_family and ipv6_only_sock, simplify the address handling in sctp_process_param() with it, as it additionally filters out non-unicast addresses. As a side effect, a v4-mapped address in an IPv6 address parameter is now normalised to AF_INET before the transport is created, matching what the socket API paths already do.
Also add the missing !af check in sctp_process_init(), as sctp_get_af_specific(AF_INET6) returns NULL on CONFIG_IPV6=n builds.
BUG: KASAN: null-ptr-deref in sctp_transport_new+0xa7/0x350 Read of size 4 at addr 00000000000000b4 by task poc/682 Call Trace: <IRQ> sctp_transport_new+0xa7/0x350 sctp_assoc_add_peer+0x153/0x850 sctp_process_init+0xf9/0x1180 sctp_sf_do_5_1D_ce+0x464/0xbc0 sctp_do_sm+0x114/0x2990 sctp_endpoint_bh_rcv+0x280/0x430 sctp_inq_push+0xdd/0x100 sctp_rcv+0x17f5/0x1ae0 sctp4_rcv+0x2b/0x40 ip_protocol_deliver_rcu+0x25b/0x270 ip_local_deliver+0xd1/0xe0 </IRQ> Kernel panic - not syncing: Fatal exception in interrupt
--- net/sctp/ipv6.c | 6 +++++- net/sctp/sm_make_chunk.c | 24 +++++++++++++----------- net/sctp/sm_statefuns.c | 2 +- 3 files changed, 19 insertions(+), 13 deletions(-)
net/sctp/ipv6.c +5 -1
@@ -723,7 +723,8 @@ static int sctp_v6_available(union sctp_addr *addr, struct sctp_sock *sp)* SCTP. * * Output: -* Return 0 - If the address is a non-unicast or an illegal address. +* Return 0 - If the address is a non-unicast or an illegal address, +* or a non-v4-mapped address on a non-PF_INET6 socket. * Return 1 - If the address is a unicast. */ static int sctp_v6_addr_valid(union sctp_addr *addr,
@@ -747,6 +748,9 @@ static int sctp_v6_addr_valid(union sctp_addr *addr,if (!(ret &IPV6_ADDR_UNICAST ))return 0 ; +if (sp &&sctp_opt2sk (sp)->sk_family !=PF_INET6 ) +return 0 ; +return 1 ; }
net/sctp/sm_make_chunk.c +13 -11
@@ -1760,7 +1760,9 @@ struct sctp_association *sctp_unpack_cookie(__u8 *digest = ep->digest;struct sctp_chunkhdr *ch;unsigned int len, chlen; +union sctp_addr paddr;enum sctp_scope scope; +struct sctp_af *af;ktime_t kt;/* Header size is static data prior to the actual cookie, including
@@ -1880,6 +1882,11 @@ struct sctp_association *sctp_unpack_cookie( goto fail; } + paddr = bear_cookie->peer_addr; + af =sctp_get_af_specific (paddr.sa.sa_family); +if (!af || !af->addr_valid (&paddr,sctp_sk (ep->base.sk),NULL )) + goto malformed; +/* Make a new base association. */ scope =sctp_scope (sctp_source (chunk)); retval =sctp_association_new (ep, ep->base.sk, scope, gfp);
@@ -1896,6 +1903,7 @@ struct sctp_association *sctp_unpack_cookie(/* Populate the association from the cookie. */ memcpy (&retval->c, bear_cookie,sizeof (*bear_cookie)); + retval->c.peer_addr = paddr;if (sctp_assoc_set_bind_addr_from_cookie (retval, bear_cookie,GFP_ATOMIC ) <0 ) {
@@ -2420,8 +2428,8 @@ int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk, (param.p->type == SCTP_PARAM_IPV4_ADDRESS || param.p->type == SCTP_PARAM_IPV6_ADDRESS)) { af =sctp_get_af_specific (param_type2af (param.p->type)); -if (!af->from_addr_param (&addr, param.addr, - chunk->sctp_hdr->source,0 )) +if (!af || !af->from_addr_param (&addr, param.addr, + chunk->sctp_hdr->source,0 ))continue ;if (sctp_cmp_addr_exact (sctp_source (chunk), &addr)) src_match =1 ;
@@ -2593,17 +2601,11 @@ static int sctp_process_param(struct sctp_association *asoc,*/ switch (param.p->type) {case SCTP_PARAM_IPV6_ADDRESS : -if (PF_INET6 != asoc->base.sk->sk_family) -break ; - goto do_addr_param; -case SCTP_PARAM_IPV4_ADDRESS : -/* v4 addresses are not allowed on v6-only socket */ -if (ipv6_only_sock (asoc->base.sk)) -break ; -do_addr_param: af =sctp_get_af_specific (param_type2af (param.p->type)); -if (!af->from_addr_param (&addr, param.addr,htons (asoc->peer.port),0 )) +if (!af || !af->from_addr_param (&addr, param.addr, +htons (asoc->peer.port),0 ) || + !af->addr_valid (&addr,sctp_sk (asoc->base.sk),NULL ))break ; scope =sctp_scope (peer_addr);if (sctp_in_scope (net, &addr, scope))
net/sctp/sm_statefuns.c +1 -1
@@ -814,7 +814,7 @@ enum sctp_disposition sctp_sf_do_5_1D_ce(struct net *net,* effects--it is safe to run them here. */ if (!sctp_process_init (new_asoc, chunk, - &chunk->subh.cookie_hdr->c.peer_addr, + &new_asoc->c.peer_addr, peer_init,GFP_ATOMIC )) goto nomem_init;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1531/1756 cgroup/cpuset: check effective mems for a movable-only configuration
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gregory Price (Meta) <[email protected]>
[ Upstream commit 4c047bd0499602161959478b90e66f4c8e523c9b ]
check_insane_mems_config() warns and enables cpusets_insane_config_key when a cpuset's tasks can allocate only from movable memory.
In cgroup v2 the request may name a memoryless node, which has no zones and cpusets reports it as a movable-only nodemask.
For example, with node 2 a CPU-only node:
# echo +cpuset > /sys/fs/cgroup/cgroup.subtree_control
# mkdir /sys/fs/cgroup/test
# echo 2 > /sys/fs/cgroup/test/cpuset.mems
# cat /sys/fs/cgroup/test/cpuset.mems.effective
0-1
# dmesg
Unsupported (movable nodes only) cpuset configuration detected (nmask=2)!This is a bit confusing, especially consider mems.effective ends up with a valid nodemask by-design (cpuset.mems is treated as-if it were empty).
Check each new effective mask in update_nodemasks_hier() instead, as the hotplug path already does. The allocator's bail-out tests the task's mems_allowed, which comes from the effective mask.
A request naming a movable-only not present in the parent's nodemask no longer warns (since, again, the cpuset.mems gets overridden and treated as empty). However, it will warn if the parent's mems include the node later.
For Example, with node 3 a movable-only node:
# echo 0 > /sys/fs/cgroup/test/cpuset.mems
# echo 3 > /sys/fs/cgroup/test/child/cpuset.mems
# cat /sys/fs/cgroup/test/child/cpuset.mems.effective
0
# dmesg
{ empty }
# echo 0,3 > /sys/fs/cgroup/test/cpuset.mems
# cat /sys/fs/cgroup/test/child/cpuset.mems.effective
3
# dmesg
Unsupported (movable nodes only) cpuset configuration detected (nmask=3)!--- kernel/cgroup/cpuset.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/cgroup/cpuset.c +2 -2
@@ -2721,6 +2721,8 @@ static void update_nodemasks_hier(struct cpuset *cs, nodemask_t *new_mems)continue ;rcu_read_unlock (); +check_insane_mems_config (new_mems); +spin_lock_irq (&callback_lock); cp->effective_mems = *new_mems;spin_unlock_irq (&callback_lock);
@@ -2791,8 +2793,6 @@ static int update_nodemask(struct cpuset *cs, struct cpuset *trialcs,if (retval <0 ) goto done; -check_insane_mems_config (&trialcs->mems_allowed); -spin_lock_irq (&callback_lock); cs->mems_allowed = trialcs->mems_allowed;spin_unlock_irq (&callback_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1532/1756 ALSA: sh: aica: Fix spu_memset() stride
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fuchs <[email protected]>
[ Upstream commit 0d01f90b07e877ef31f9959e9b0bc6bcca9b99df ]
spu_memset() writes one 32-bit word per iteration, but advances the destination offset by only one byte. spu_reset() calls it with 0x200000 / 4 words to clear the 2 MiB of sound RAM, so:
- three out of four writel() calls target an unaligned address. The SH4 can't do that. Each one traps and is emulated by the unaligned access fixup. This call to spu_memset() causes 393216 unaligned accesses, visible in /proc/cpu/alignment.
- the clear covered only about 512 KiB of sound RAM, not 2 MiB.
Advance the offset by the size of the written word, to clear the full sound RAM using aligned writes.
--- sound/sh/aica.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/sh/aica.c +1 -1
@@ -94,7 +94,7 @@ static void spu_memset(u32 toi, u32 what, int length)local_irq_save (flags);writel (what, toi +SPU_MEMORY_BASE );local_irq_restore (flags); - toi++; + toi +=sizeof (what); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1533/1756 net: sparx5/lan969x: do not read past skb->len when injecting a frame
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Machon <[email protected]>
[ Upstream commit 9642ce6cb51ebd596d0a02074ba9b2a387e974b0 ]
sparx5_inject() writes the frame to the injection FIFO one 32-bit word at a time, and pads frames shorter than 60 bytes with zero words.
Before this patch, the last word is loaded whole even when skb->len is not a multiple of four, so 1 to 3 bytes past the end of the frame are read. For a frame shorter than 60 bytes those bytes are also transmitted, as VLD_BYTES marks the whole last word valid and the padding starts at the next word.
Write the trailing bytes from a zeroed word. The number of words written and VLD_BYTES are unchanged.
Found by an AI code review agent, and reproduced on lan969x and sparx5 with register injection: bytes 57 to 59 of a 57 byte frame were not zero. With the fix they are zero, and traffic still passes on both chips.
--- .../net/ethernet/microchip/sparx5/sparx5_packet.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/net/ethernet/microchip/sparx5/sparx5_packet.c +12 -3
@@ -168,8 +168,8 @@ static int sparx5_inject(struct sparx5 *sparx5,struct sk_buff *skb, struct net_device *ndev) { + u32 val, w, count, last;int grp =INJ_QUEUE ; -u32 val, w, count;u8 *buf; val =spx5_rd (sparx5,QS_INJ_STATUS );
@@ -188,14 +188,23 @@ static int sparx5_inject(struct sparx5 *sparx5,for (w =0 ; w <IFH_LEN ; w++)spx5_wr (ifh[w], sparx5,QS_INJ_WR (grp)); -/* Write words, round up */ - count =DIV_ROUND_UP (skb->len,4 ); +/* Write the whole words of the frame */ + count = skb->len /4 ; buf = skb->data;for (w =0 ; w < count; w++, buf +=4 ) { val =get_unaligned ((const u32 *)buf);spx5_wr (val, sparx5,QS_INJ_WR (grp)); } +/* Write the last 1 to 3 bytes, zero padded to a whole word */ + last = skb->len %4 ; +if (last) { + val =0 ; +memcpy (&val, buf, last); +spx5_wr (val, sparx5,QS_INJ_WR (grp)); + w++; + } +/* Add padding */ while (w < (60 /4 )) {spx5_wr (0 , sparx5,QS_INJ_WR (grp));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1534/1756 net: sparx5: split sparx5_fdma_{start(),stop()}
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Machon <[email protected]>
[ Upstream commit b91dcb237c69a05b06d64e2f4ba0a74a0552b80f ]
The two functions: sparx5_fdma_{start(),stop()} are responsible for a number of things, namely: allocation and initialization of FDMA buffers, activation FDMA channels in hardware and activation of the NAPI instance.
This patch splits the buffer allocation and initialization into init and deinit functions, and the channel and NAPI activation into start and stop functions. This serves two purposes: 1) the start() and stop() functions can be reused for lan969x and 2) prepares for future MTU change support, where we must be able to stop and start the FDMA channels and NAPI instance, without free'ing and reallocating the FDMA buffers.
Stable-dep-of: 1df26063ab9b ("net: sparx5: fix tx DCB index drift in fdma xmit")
--- .../ethernet/microchip/sparx5/sparx5_fdma.c | 44 ++++++++++++++----- .../ethernet/microchip/sparx5/sparx5_main.c | 7 ++- .../ethernet/microchip/sparx5/sparx5_main.h | 2 + 3 files changed, 41 insertions(+), 12 deletions(-)
drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c +34 -10
@@ -258,10 +258,6 @@ static int sparx5_fdma_rx_alloc(struct sparx5 *sparx5)fdma_dcbs_init (fdma,FDMA_DCB_INFO_DATAL (fdma->db_size),FDMA_DCB_STATUS_INTR ); -netif_napi_add_weight (rx->ndev, &rx->napi, sparx5_fdma_napi_callback, -FDMA_WEIGHT ); -napi_enable (&rx->napi); -sparx5_fdma_rx_activate (sparx5, rx);return 0 ; }
@@ -406,7 +402,7 @@ static void sparx5_fdma_injection_mode(struct sparx5 *sparx5) } } -int sparx5_fdma_start (struct sparx5 *sparx5) +int sparx5_fdma_init (struct sparx5 *sparx5) {int err;
@@ -439,24 +435,52 @@ int sparx5_fdma_start(struct sparx5 *sparx5)return err; } +int sparx5_fdma_deinit (struct sparx5 *sparx5) +{ +sparx5_fdma_stop (sparx5); +fdma_free_phys (&sparx5->rx.fdma); +fdma_free_phys (&sparx5->tx.fdma); + +return 0 ; +} +static u32 sparx5_fdma_port_ctrl (struct sparx5 *sparx5) {return spx5_rd (sparx5,FDMA_PORT_CTRL (0 )); } +int sparx5_fdma_start (struct sparx5 *sparx5) +{ +struct sparx5_rx *rx = &sparx5->rx; + +netif_napi_add_weight (rx->ndev, + &rx->napi, + sparx5_fdma_napi_callback, +FDMA_WEIGHT ); + +napi_enable (&rx->napi); + +sparx5_fdma_rx_activate (sparx5, rx); + +return 0 ; +} +int sparx5_fdma_stop (struct sparx5 *sparx5) { +struct sparx5_rx *rx = &sparx5->rx; +struct sparx5_tx *tx = &sparx5->tx;u32 val; -napi_disable (&sparx5->rx.napi); +napi_disable (&rx->napi); +/* Stop the fdma and channel interrupts */ -sparx5_fdma_rx_deactivate (sparx5, &sparx5->rx); -sparx5_fdma_tx_deactivate (sparx5, &sparx5->tx); +sparx5_fdma_rx_deactivate (sparx5, rx); +sparx5_fdma_tx_deactivate (sparx5, tx); +/* Wait for the RX channel to stop */ read_poll_timeout (sparx5_fdma_port_ctrl, val,FDMA_PORT_CTRL_XTR_BUF_IS_EMPTY_GET (val) ==0 ,500 ,10000 ,0 , sparx5); -fdma_free_phys (&sparx5->rx.fdma); -fdma_free_phys (&sparx5->tx.fdma); +return 0 ; }
drivers/net/ethernet/microchip/sparx5/sparx5_main.c +5 -2
@@ -698,8 +698,11 @@ static int sparx5_start(struct sparx5 *sparx5) sparx5_fdma_handler,0 , "sparx5-fdma", sparx5); -if (!err) - err =sparx5_fdma_start (sparx5); +if (!err) { + err =sparx5_fdma_init (sparx5); +if (!err) +sparx5_fdma_start (sparx5); + }if (err) sparx5->fdma_irq = -ENXIO ; }else {
drivers/net/ethernet/microchip/sparx5/sparx5_main.h +2 -0
@@ -314,6 +314,8 @@ int sparx5_manual_injection_mode(struct sparx5 *sparx5);void sparx5_port_inj_timer_setup (struct sparx5_port *port);/* sparx5_fdma.c */ +int sparx5_fdma_init (struct sparx5 *sparx5); +int sparx5_fdma_deinit (struct sparx5 *sparx5);int sparx5_fdma_start (struct sparx5 *sparx5);int sparx5_fdma_stop (struct sparx5 *sparx5);int sparx5_fdma_xmit (struct sparx5 *sparx5,u32 *ifh,struct sk_buff *skb);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1535/1756 net: sparx5: activate FDMA tx in start()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Machon <[email protected]>
[ Upstream commit cded2e0f1b0de5aa1ebd4bf42c3f1919b7adf6cd ]
The function sparx5_fdma_tx_activate() is responsible for configuring the TX FDMA instance and activating the channel. TX activation has previously been done in the xmit() function, when the first frame is transmitted. Now that we have separate functions for starting and stopping the FDMA, it seems reasonable to move the TX activation to the start function. This change has no implications on the functionality.
Stable-dep-of: 1df26063ab9b ("net: sparx5: fix tx DCB index drift in fdma xmit")
--- drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c +4 -7
@@ -215,7 +215,6 @@ int sparx5_fdma_xmit(struct sparx5 *sparx5, u32 *ifh, struct sk_buff *skb) {struct sparx5_tx *tx = &sparx5->tx;struct fdma *fdma = &tx->fdma; -static bool first_time = true;void *virt_addr;fdma_dcb_advance (fdma);
@@ -236,12 +235,8 @@ int sparx5_fdma_xmit(struct sparx5 *sparx5, u32 *ifh, struct sk_buff *skb)FDMA_DCB_STATUS_BLOCKO (0 ) | FDMA_DCB_STATUS_BLOCKL(skb->len + IFH_LEN * 4 + 4)); -if (first_time) { -sparx5_fdma_tx_activate (sparx5, tx); - first_time = false; - }else { -sparx5_fdma_reload (sparx5, fdma); - } +sparx5_fdma_reload (sparx5, fdma); +return NETDEV_TX_OK ; }
@@ -452,6 +447,7 @@ static u32 sparx5_fdma_port_ctrl(struct sparx5 *sparx5)int sparx5_fdma_start (struct sparx5 *sparx5) {struct sparx5_rx *rx = &sparx5->rx; +struct sparx5_tx *tx = &sparx5->tx; netif_napi_add_weight(rx->ndev, &rx->napi,
@@ -461,6 +457,7 @@ int sparx5_fdma_start(struct sparx5 *sparx5)napi_enable (&rx->napi);sparx5_fdma_rx_activate (sparx5, rx); +sparx5_fdma_tx_activate (sparx5, tx);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1536/1756 net: sparx5: fix tx DCB index drift in fdma xmit
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Machon <[email protected]>
[ Upstream commit 1df26063ab9ba64f5fb11049fa4be686b7fc309e ]
sparx5_fdma_xmit() advances dcb_index before checking that the FDMA is done with the DCB, and does not undo the advance when the check fails. Before commit f4aa7e361ae2 ("net: sparx5: use FDMA library for adding DCB's in the tx path") the next DCB was always the one after last_dcb. Since then dcb_index drifts one DCB further away from last_dcb on every failed transmit.
While the ring is full, this drops frames even though completed DCBs sit behind dcb_index. After a run of failures, dcb_index can also land on last_dcb itself. Re-adding last_dcb loses the frame, because the FDMA has already passed the tail of the chain, and that DCB is never completed again.
Fix this by making dcb_index the next DCB to use, and advancing it only after the DCB has been added, as the rx path does. dcb_index and last_dcb now only move together, so dcb_index always points at the DCB after last_dcb.
The issue was found by an AI code review agent. It was reproduced on a sparx5 PCB135 board with a modified kernel that forces 63 consecutive transmit failures. Afterwards, about 1 in 64 frames is lost for good. With the fix, the same test loses no frames.
--- drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c +2 -1
@@ -217,7 +217,6 @@ int sparx5_fdma_xmit(struct sparx5 *sparx5, u32 *ifh, struct sk_buff *skb)struct fdma *fdma = &tx->fdma;void *virt_addr; -fdma_dcb_advance (fdma);if (!fdma_db_is_done (fdma_db_get (fdma, fdma->dcb_index,0 )))return -EINVAL ;
@@ -235,6 +234,8 @@ int sparx5_fdma_xmit(struct sparx5 *sparx5, u32 *ifh, struct sk_buff *skb)FDMA_DCB_STATUS_BLOCKO (0 ) | FDMA_DCB_STATUS_BLOCKL(skb->len + IFH_LEN * 4 + 4)); +fdma_dcb_advance (fdma); +sparx5_fdma_reload (sparx5, fdma);return NETDEV_TX_OK ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1537/1756 net: fix frag_list leak in skb_segment_list() error path
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 546daf344420b5dce27eded3ad15be12628dd185 ]
skb_segment_list() detaches the frag_list from the head skb and moves its members one by one to the skb->next chain. On error, err_linearize frees that chain with kfree_skb_list(skb->next), relying on the members not yet processed to still be linked after the current one.
This does not hold when the current member was shared: it is replaced by skb_clone(), and __skb_clone() clears ->next. If __skb_linearize() then fails on that clone, the remaining members are no longer reachable from skb->next nor from skb_shinfo(skb)->frag_list, and they leak.
The skb_shared() error branch already relinks nskb->next to list_skb before jumping to err_linearize. Do it unconditionally right after nskb is added to the chain, so every error exit sees the remaining members. On the last member list_skb is NULL, which still terminates the chain.
--- net/core/skbuff.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/core/skbuff.c +6 -3
@@ -4673,10 +4673,13 @@ struct sk_buff *skb_segment_list(struct sk_buff *skb,else tail->next = nskb; -if (unlikely (err)) { - nskb->next = list_skb; +/* nskb may be a clone with a NULL ->next: keep the remaining +* members linked so that err_linearize frees them. +*/ + nskb->next = list_skb; + +if (unlikely (err)) goto err_linearize; - } tail = nskb;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1538/1756 net/mlx5e: IPsec, Fix out-of-bounds comparison of neighbour keys
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gal Pressman <[email protected]>
[ Upstream commit 520631554a689d2cd52452578f3140f045730ee0 ]
mlx5e_ipsec_netevent_event() keeps the L2 headers of offloaded tunnel mode SAs up to date: on every neighbour change it looks for SAs whose endpoint matches the neighbour's address. The compare width, 4 bytes for IPv4 or 16 for IPv6, is chosen from the SA's address family, with no check that the neighbour is of the same family.
An ARP entry only stores a 4-byte key, so with an IPv6 tunnel mode SA offloaded, any IPv4 neighbour update in the system is compared as if it were a 16-byte IPv6 address, reading past the end of the object:
BUG: KASAN: slab-out-of-bounds in mlx5e_ipsec_netevent_event+0x736/0x8d0 [mlx5_core] Read of size 4 at addr ff110001260a4ad8 by task swapper/8/0 Call Trace: <IRQ> mlx5e_ipsec_netevent_event+0x736/0x8d0 [mlx5_core] notifier_call_chain+0x97/0x2b0 atomic_notifier_call_chain+0x5d/0x130 neigh_timer_handler+0x35c/0x1140 call_timer_fn+0x164/0x490 __run_timers+0x5b9/0x960 run_timer_softirq+0xf0/0x1d0 handle_softirqs+0x189/0x8a0 __irq_exit_rcu+0x10d/0x250 ... Allocated by task 1015: __kmalloc_noprof+0x2e6/0x8b0 ___neigh_create+0xcc9/0x24c0 ip_finish_output2+0xfc7/0x1e80 ip_output+0x172/0x3b0 ip_send_skb+0xa5/0x1b0 udp_send_skb+0x852/0x10f0 udp_sendmsg+0x1333/0x2150 ...
The opposite mix (IPv4 SA with IPv6 neighbour) stays in bounds, but only the first 32 bits of the IPv6 address are compared, so an unrelated neighbour can match.
Skip neighbours whose address family doesn't match the SA.
--- drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +3 -0
@@ -938,6 +938,9 @@ static int mlx5e_ipsec_netevent_event(struct notifier_block *nb,xa_for_each_marked (&ipsec->sadb, idx, sa_entry,MLX5E_IPSEC_TUNNEL_SA ) { attrs = &sa_entry->attrs; +if (attrs->addrs.family != n->tbl->family) +continue ; +if (attrs->addrs.family ==AF_INET ) {if (!neigh_key_eq32 (n, &attrs->addrs.saddr.a4) && !neigh_key_eq32 (n, &attrs->addrs.daddr.a4))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1539/1756 net/rds: include the scope id in the sendmsg connection cache check
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Allison Henderson <[email protected]>
[ Upstream commit b7dfff5e3eb3984d42026a6d653ec2a3d5cec729 ]
rds_sendmsg() reuses the connection cached in rs->rs_conn when its peer address and ToS match the request. The interface index is part of a connection's identity as well: rds_conn_create_outgoing() passes the request's scope_id down as dev_if, and rds_conn_lookup() compares c_dev_if, so sends to the same link-local address through two interfaces are two different connections. The cache-hit test never looked at it.
A socket bound to a non-link-local address has rs_bound_scope_id 0, and the scope check at the top of rds_sendmsg() accepts any non-zero destination scope for such a socket. So after a send to fe80::x%ifA, a send to fe80::x%ifB hits the cached ifA connection and the datagram leaves through ifA, to whichever peer answers to that address there.
Compare c_dev_if with the request's scope_id in the cache test, so that such a send takes the lookup path and finds, or creates, the ifB connection - the same key the lookup uses. A send without a destination takes its scope from the socket, and the connection it created was keyed on that same scope, so the comparison holds for it too; the next patch gives that send the connected peer's own scope.
Found by inspection while reworking this cache for the connection lifetime series on net-next; not observed in the field.
--- net/rds/send.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/rds/send.c +2 -1
@@ -1308,7 +1308,8 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)/* rds_conn_create has a spinlock that runs with IRQ off. * Caching the conn in the socket helps a lot. */ if (rs->rs_conn &&ipv6_addr_equal (&rs->rs_conn->c_faddr, &daddr) && - rs->rs_tos == rs->rs_conn->c_tos) { + rs->rs_tos == rs->rs_conn->c_tos && + rs->rs_conn->c_dev_if == scope_id) { conn = rs->rs_conn; }else { conn = rds_conn_create_outgoing(sock_net(sock->sk),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1540/1756 net/rds: keep the connected peers scope id apart from the bound one
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Allison Henderson <[email protected]>
[ Upstream commit 3fe64a5f670dbd6c7c84c2345b0b9726b3b79b31 ]
rds_connect() has nowhere to keep the scope of a link-local peer, so it stores it in rs_bound_scope_id, the scope of the socket's own bound address, for rds_bind() to check a later link-local bind against. That field is then also what a send without a destination uses as the request's scope, what getpeername() and recvmsg() report as the peer's scope, and what a later bind() overwrites:rds_add_bound() stores the bound address's scope unconditionally, which for a non-link-local address is 0.
So after connect(fe80::x%ifA) followed by bind(global), a send() with no destination asks for fe80::x with scope 0. rds_conn_lookup() keys on the interface, so that finds or creates a connection with c_dev_if 0, which the TCP transport then tries to connect through sin6_scope_id 0 and tcp_v6_connect() rejects for a link-local peer:
the connected socket's data is queued on a connection that can never come up. In the other order, bind(global) then connect(fe80::x%ifB), the connect leaves a global-bound socket with rs_bound_scope_id ifB, so sends to other link-local peers are refused as off-link and sends to global peers inherit a meaningless interface.
Give the connected peer its own rs_conn_scope_id. rds_connect() records it there and leaves the bound scope alone, rds_bind()'s connected-socket check compares against it, and the destination-less send takes its scope from it - falling back to the bound scope for a non-link-local peer, so that send() and sendto() to the connected peer compute the same scope, and so the same connection. getpeername() reports the connected peer with its own scope. recvmsg() used to report every sender with the socket's bound scope; a connected socket receives from any peer, so neither the bound scope nor the connected peer's scope is right for an arbitrary sender. It now reports a link-local sender with the interface recorded on its connection, c_dev_if: the TCP accept path takes it from the incoming socket, and the IB passive side resolves it from the local address, the closest the CM gets to the arrival interface. Any other sender is reported with scope 0, the inet6 convention. Either way, a reply to the address an application was given reaches the same connection.
Found by inspection while reworking the sendmsg connection cache; not observed in the field.
--- net/rds/af_rds.c | 15 +++++++++------ net/rds/bind.c | 4 ++-- net/rds/rds.h | 2 ++ net/rds/recv.c | 11 ++++++++++- net/rds/send.c | 6 +++++- 5 files changed, 28 insertions(+), 10 deletions(-)
net/rds/af_rds.c +9 -6
@@ -135,8 +135,7 @@ static int rds_getname(struct socket *sock, struct sockaddr *uaddr, sin6->sin6_port = rs->rs_conn_port; sin6->sin6_addr = rs->rs_conn_addr; sin6->sin6_flowinfo =0 ; -/* scope_id is the same as in the bound address. */ - sin6->sin6_scope_id = rs->rs_bound_scope_id; + sin6->sin6_scope_id = rs->rs_conn_scope_id; uaddr_len =sizeof (*sin6); } }else {
@@ -568,6 +567,7 @@ static int rds_connect(struct socket *sock, struct sockaddr *uaddr, }ipv6_addr_set_v4mapped (sin->sin_addr.s_addr, &rs->rs_conn_addr); rs->rs_conn_port = sin->sin_port; + rs->rs_conn_scope_id =0 ;break ;#if IS_ENABLED (CONFIG_IPV6 )
@@ -612,11 +612,14 @@ static int rds_connect(struct socket *sock, struct sockaddr *uaddr, ret = -EINVAL ;break ; } -/* Remember the connected address scope ID. It will -* be checked against the binding local address when -* the socket is bound. +/* Remember the connected address scope ID. It is +* checked against the binding local address when +* the socket is bound, and gives a send without a +* destination its scope. */ - rs->rs_bound_scope_id = sin6->sin6_scope_id; + rs->rs_conn_scope_id = sin6->sin6_scope_id; + }else { + rs->rs_conn_scope_id =0 ; } rs->rs_conn_addr = sin6->sin6_addr; rs->rs_conn_port = sin6->sin6_port;
net/rds/bind.c +2 -2
@@ -233,8 +233,8 @@ int rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)* non-link local address (scope_id is 0). */ if (!ipv6_addr_any (&rs->rs_conn_addr) && scope_id && - rs->rs_bound_scope_id && - scope_id != rs->rs_bound_scope_id) { + rs->rs_conn_scope_id && + scope_id != rs->rs_conn_scope_id) { ret = -EINVAL ; goto out; }
net/rds/rds.h +2 -0
@@ -613,6 +613,8 @@ struct rds_sock {struct in6_addr rs_conn_addr;#define rs_conn_addr_v4 rs_conn_addr.s6_addr32[3]__be16 rs_conn_port; +/* scope of rs_conn_addr when it is link-local, 0 otherwise */ +__u32 rs_conn_scope_id;struct rds_transport *rs_transport;/*
net/rds/recv.c +10 -1
@@ -755,7 +755,16 @@ int rds_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, sin6->sin6_port = inc->i_hdr.h_sport; sin6->sin6_addr = inc->i_saddr; sin6->sin6_flowinfo =0 ; - sin6->sin6_scope_id = rs->rs_bound_scope_id; +/* A link-local sender is reported with the +* interface recorded on its connection (the +* accepting socket's device for TCP, the one +* resolved for the local address on IB); any +* other sender has no scope. +*/ + sin6->sin6_scope_id = + (ipv6_addr_type (&inc->i_saddr) & +IPV6_ADDR_LINKLOCAL ) ? + inc->i_conn->c_dev_if :0 ; msg->msg_namelen =sizeof (*sin6); } }
net/rds/send.c +5 -1
@@ -1222,7 +1222,11 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)lock_sock (sk); daddr = rs->rs_conn_addr; dport = rs->rs_conn_port; - scope_id = rs->rs_bound_scope_id; +/* The connected peer's scope for a link-local peer, else +* the bound scope, as an explicit send to that peer would +* compute below. +*/ + scope_id = rs->rs_conn_scope_id ?: rs->rs_bound_scope_id;release_sock (sk); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1541/1756 selftests/net: tcp_mmap: remove unused -k option and keepflag
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Thelen <[email protected]>
[ Upstream commit 5536d5553f274c8baa77c44854c9091657213970 ]
Commit aacb0c2e524c ("selftests: net: tcp_mmap must use TCP_ZEROCOPY_RECEIVE") removed the only read of keepflag in child_thread(), leaving the file-scope keepflag variable set by the -k option in main() but never read. This triggers a Clang 23 warning:
tcp_mmap.c:91:12: error: variable 'keepflag' set but not used [-Werror,-Wunused-but-set-global]
Remove the unused keepflag variable and the dead -k getopt option.
--- tools/testing/selftests/net/tcp_mmap.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
tools/testing/selftests/net/tcp_mmap.c +1 -5
@@ -85,7 +85,6 @@ static int rcvbuf; /* Default: autotuning. Can be set with -r <integer> optionstatic int sndbuf;/* Default: autotuning. Can be set with -w <integer> option */ static int zflg;/* zero copy option. (MSG_ZEROCOPY for sender, mmap() for receiver */ static int xflg;/* hash received data (simple xor) (-h option) */ -static int keepflag;/* -k option: receiver shall keep all received file in memory (no munmap() calls) */ static int integrity;/* -i option: sender and receiver compute sha256 over the data.*/ static size_t chunk_size =512 *1024 ;
@@ -456,7 +455,7 @@ int main(int argc, char *argv[])int sflg =0 ;int mss =0 ; -while ((c =getopt (argc, argv,"46p:svr:w:H:zxkP:M:C:a:i" )) !=-1 ) { +while ((c =getopt (argc, argv,"46p:svr:w:H:zxP:M:C:a:i" )) !=-1 ) {switch (c) {case '4' : cfg_family =PF_INET ;
@@ -490,9 +489,6 @@ int main(int argc, char *argv[])case 'x' : xflg =1 ;break ; -case 'k' : - keepflag =1 ; -break ;case 'P' : max_pacing_rate =atoi (optarg) ;break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1542/1756 tls: avoid field-spanning write when copying crypto info
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nandor Kracser <[email protected]>
[ Upstream commit c43c1c24f3cdc0d2d3f59e5686573ac3129637aa ]
do_tls_setsockopt_conf() copies the cipher-specific part of the crypto info to crypto_info + 1, where crypto_info points at the 4-byte info member of union tls_crypto_context. When optval is a kernel sockptr, copy_from_sockptr_offset() is a memcpy(), and FORTIFY_SOURCE bounds the destination by that member:
[ 6.948348] memcpy: detected field-spanning write (size 52) of single field "dst" at include/linux/sockptr.h:49 (size 0) [ 6.948480] WARNING: include/linux/sockptr.h:49 at tls_setsockopt+0x9b2/0xa30, CPU#1: init/1 [ 7.001355] Call Trace: [ 7.003146] do_sock_setsockopt+0xb0/0x190 [ 7.003975] __sys_setsockopt+0x76/0xc0 [ 7.005368] do_syscall_64+0xda/0x4b0
tls_setsockopt() gets a kernel sockptr whenever a cgroup setsockopt BPF program is attached, even one that leaves the option alone, because __cgroup_bpf_run_filter_setsockopt() passes optval on in a kernel buffer. With a no-op program on the root cgroup, a plain TLS_TX setsockopt() with AES-GCM-256 triggers the warning above on an x86_64 build with CONFIG_FORTIFY_SOURCE.
Copy into the union at offset sizeof(struct tls_crypto_info) instead. crypto_ctx already points at the right union for both the first set and the TLS 1.3 rekey (tmp) case, and the address is unchanged.
--- net/tls/tls_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/tls/tls_main.c +2 -2
@@ -666,8 +666,8 @@ static int do_tls_setsockopt_conf(struct sock *sk, sockptr_t optval, goto err_crypto_info; } - rc =copy_from_sockptr_offset (crypto_info +1 , optval, -sizeof (*crypto_info), + rc =copy_from_sockptr_offset ((u8 *)crypto_ctx +sizeof (*crypto_info), + optval,sizeof (*crypto_info), optlen -sizeof (*crypto_info));if (rc) { rc = -EFAULT ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1543/1756 net/sched: etf: initialise the sock_exterr_skb before filling it
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dudu Lu <[email protected]>
[ Upstream commit 7076f684d5132e6a6145e1da2fa74771ecd052e5 ]
report_sock_error() clones the transmitted skb, overlays a struct sock_exterr_skb on its control block and fills in the seven struct sock_extended_err fields, but never clears addr_offset and port. skb_clone() copies cb[] verbatim, so the errqueue entry carries the TX skb's stale control block to the receive side, and the ipv4 error-queue reader trusts those bytes:
net/ipv4/ip_sockglue.c:556
sin->sin_addr.s_addr = *(__be32 *)(skb_network_header(skb) + serr->addr_offset); sin->sin_port = serr->port;
The gate that is supposed to guard that read only asks whether an address was requested at all:
net/ipv4/ip_sockglue.c:484
return serr->ee.ee_origin == SO_EE_ORIGIN_ICMP || serr->ee.ee_origin == SO_EE_ORIGIN_LOCAL || serr->port;
SO_EE_ORIGIN_TXTIME is neither ICMP nor LOCAL, so for sch_etf the gate is decided by serr->port alone -- by the stale byte pair. When it is non-zero the reader dereferences skb_network_header() + addr_offset with an arbitrary offset. On the TCP path cb[40..44) is not zero: the transmit path stored delivered_mstamp there (tcp_rate_skb_sent()), which is exactly where addr_offset/port sit in the arm64 struct layout.
Reached with an unmodified 7.3-rc4 (arm64, KASAN, in-tree modules): a TCP socket enables TX-timestamp error reporting (SO_TXTIME with SOF_TXTIME_REPORT_ERRORS), a sch_etf qdisc drops the packet, and a recvmsg() reaches ip_recv_error():
BUG: KASAN: slab-out-of-bounds in ip_recv_error+0x970/0xa0c Read of size 4 at addr ffff0000158ffdd5 by task A-227-A227-1_S2/113 ip_recv_error+0x970/0xa0c inet_recv_error+0x94/0xdc tcp_recvmsg+0x378/0x408 ... The buggy address is located 149 bytes to the right of allocated 704-byte region
Zero the whole overlay rather than the two fields individually: the errqueue entry is handed to the receive side as a self-contained record, which is what every other producer in the tree already does (sch_etf was the only error-queue producer that cleared neither field). This does not change what the in-tree selftest observes -- so_txtime.c reads only ee_origin/ee_errno/ee_code/ee_data/ee_info, never msg_name or sin_port.
--- net/sched/sch_etf.c | 1 + 1 file changed, 1 insertion(+)
net/sched/sch_etf.c +1 -0
@@ -147,6 +147,7 @@ static void report_sock_error(struct sk_buff *skb, u32 err, u8 code)return ; serr =SKB_EXT_ERR (clone); +memset (serr,0 ,sizeof (*serr)); serr->ee.ee_errno = err; serr->ee.ee_origin =SO_EE_ORIGIN_TXTIME ; serr->ee.ee_type =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1544/1756 scsi: elx: libefc: Fix resource leak in efcport_init() error path
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haotian Zhang <[email protected]>
[ Upstream commit b4bd078b78c248d4263a1da7033cbe7a74ce0e12 ]
efcport_init() creates efc->node_pool and efc->node_dma_pool before allocating efc->els_io_pool. When the latter allocation fails it returns -ENOMEM without releasing the node dma pool or the node pool, leaking both. The caller efct_efclib_config() only logs the error and efct_device_attach() failure path never calls efcport_destroy(), so the resources are never freed.
Destroy node_dma_pool and node_pool before returning from the els_io_pool allocation failure path.
--- drivers/scsi/elx/libefc/efclib.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/elx/libefc/efclib.c +2 -0
@@ -50,6 +50,8 @@ int efcport_init(struct efc *efc) sizeof(struct efc_els_io_req));if (!efc->els_io_pool) {efc_log_err (efc,"Can't allocate els io pool\n" ); +dma_pool_destroy (efc->node_dma_pool); +mempool_destroy (efc->node_pool);return -ENOMEM ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1545/1756 bpf: Propagate btf_add_type() errors in btf_check_all_metas()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Feng Yang <[email protected]>
[ Upstream commit fb2b27d214c3b88d926a303267dd83cfdb428b13 ]
btf_check_all_metas() ignores the return value of btf_add_type(), so a type that could not be registered is silently dropped while the loop keeps walking over the type section.
Both failure modes are reachable:
- -E2BIG. Once the types array reaches its capacity (BTF_MAX_TYPE), every following btf_add_type() fails the same way, so btf_check_all_metas() still returns 0 and the BTF object is created with btf->nr_types capped while hdr->type_len claims more records.
- -ENOMEM. btf->nr_types is not incremented and the array is not grown, so the next type is recorded at the slot of the dropped one and btf->types[] stays off by one with respect to the type ids for all remaining types. btf_type_by_id() then returns the wrong type for those ids for the whole lifetime of the object, and the last type is silently left unresolved.
Propagate the error so that the object is rejected instead.
--- kernel/bpf/btf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
kernel/bpf/btf.c +5 -1
@@ -5268,6 +5268,7 @@ static int btf_check_all_metas(struct btf_verifier_env *env)struct btf *btf = env->btf;struct btf_header *hdr;void *cur, *end; +int err; hdr = &btf->hdr; cur = btf->nohdr_data + hdr->type_off;
@@ -5282,7 +5283,10 @@ static int btf_check_all_metas(struct btf_verifier_env *env)if (meta_size <0 )return meta_size; -btf_add_type (env, t); + err =btf_add_type (env, t); +if (err) +return err; + cur += meta_size; env->log_type_id++; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1546/1756 bpf: Use memmove() to load bytes from an skb and an xdp_buff
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ayushman Rout <[email protected]>
[ Upstream commit b93cf2c8a0552b544e90e25802e4bf989987d29d ]
bpf_dynptr_read() on an skb or xdp dynptr ends in bpf_skb_load_bytes() or bpf_xdp_load_bytes(). The destination can be a slice of the same packet, so it can overlap the source, which memcpy() does not allow. On x86 with FSRM memcpy() copies forward, so a destination above the source gets the first bytes repeated:
p = bpf_dynptr_slice_rdwr(&ptr, 8, NULL, 64); bpf_dynptr_read(p, 64, &ptr, 0, 0);
leaves bytes 8-71 of the packet as bytes 0-7 repeated, not bytes 0-63. Reproduced with BPF_PROG_TEST_RUN on both an xdp and a tc program.
Use memmove(), as the store side does since commit 1db084f42884 ("bpf: Use memmove() to store bytes in an skb") and commit ab08863c58b1 ("bpf: Use memmove() to store bytes in an xdp_buff"). A read that spans xdp frags still goes through bpf_xdp_copy_buf() and is not changed here.
bpf_skb_load_bytes_relative() has the same pattern and is reachable from tc and sk_filter programs, so use memmove() there as well. Reproduced with BPF_PROG_TEST_RUN on a tc program: loading into a slice at offset 8 gave wrong bytes before the change and correct bytes after.
--- net/core/filter.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/core/filter.c +3 -3
@@ -1776,7 +1776,7 @@ BPF_CALL_4(bpf_skb_load_bytes, const struct sk_buff *, skb, u32, offset,if (unlikely (!ptr)) goto err_clear;if (ptr != to) -memcpy (to, ptr, len); +memmove (to, ptr, len);return 0 ; err_clear:
@@ -1858,7 +1858,7 @@ BPF_CALL_5(bpf_skb_load_bytes_relative, const struct sk_buff *, skb, ptr = start + offset;if (likely (ptr + len <= end)) { -memcpy (to, ptr, len); +memmove (to, ptr, len);return 0 ; }
@@ -4157,7 +4157,7 @@ BPF_CALL_4(bpf_xdp_load_bytes, struct xdp_buff *, xdp, u32, offset,if (!ptr)bpf_xdp_copy_buf (xdp, offset, buf, len, false);else -memcpy (buf, ptr, len); +memmove (buf, ptr, len);return 0 ; }
Signature · 1 line
2.53.0