6.1.2-rc1 review
Subsystems (14)
Greg Kroah-Hartman
maintainerPATCH 117/1146 x86/sgx: Reduce delay and interference of enclave release
In reply to Greg Kroah-HartmanFrom: Reinette Chatre <[email protected]>
[ Upstream commit 7b72c823ddf8aaaec4e9fb28e6fbe4d511e7dad1 ]
commit 8795359e35bc ("x86/sgx: Silence softlockup detection when releasing large enclaves") introduced a cond_resched() during enclave release where the EREMOVE instruction is applied to every 4k enclave page. Giving other tasks an opportunity to run while tearing down a large enclave placates the soft lockup detector but Iqbal found that the fix causes a 25% performance degradation of a workload run using Gramine.
Gramine maintains a 1:1 mapping between processes and SGX enclaves. That means if a workload in an enclave creates a subprocess then Gramine creates a duplicate enclave for that subprocess to run in. The consequence is that the release of the enclave used to run the subprocess can impact the performance of the workload that is run in the original enclave, especially in large enclaves when SGX2 is not in use.
The workload run by Iqbal behaves as follows:
Create enclave (enclave "A")
/* Initialize workload in enclave "A" */
Create enclave (enclave "B")
/* Run subprocess in enclave "B" and send result to enclave "A" */ Release enclave (enclave "B")
/* Run workload in enclave "A" */
Release enclave (enclave "A")
The performance impact of releasing enclave "B" in the above scenario is amplified when there is a lot of SGX memory and the enclave size matches the SGX memory. When there is 128GB SGX memory and an enclave size of 128GB, from the time enclave "B" starts the 128GB SGX memory is oversubscribed with a combined demand for 256GB from the two enclaves.
Before commit 8795359e35bc ("x86/sgx: Silence softlockup detection when releasing large enclaves") enclave release was done in a tight loop without giving other tasks a chance to run. Even though the system experienced soft lockups the workload (run in enclave "A") obtained good performance numbers because when the workload started running there was no interference.
Commit 8795359e35bc ("x86/sgx: Silence softlockup detection when releasing large enclaves") gave other tasks opportunity to run while an enclave is released. The impact of this in this scenario is that while enclave "B" is released and needing to access each page that belongs to it in order to run the SGX EREMOVE instruction on it, enclave "A" is attempting to run the workload needing to access the enclave pages that belong to it. This causes a lot of swapping due to the demand for the oversubscribed SGX memory. Longer latencies are experienced by the workload in enclave "A" while enclave "B" is released.
Improve the performance of enclave release while still avoiding the soft lockup detector with two enhancements:
- Only call cond_resched() after XA_CHECK_SCHED iterations.
- Use the xarray advanced API to keep the xarray locked for XA_CHECK_SCHED iterations instead of locking and unlocking at every iteration.
This batching solution is copied from sgx_encl_may_map() that also iterates through all enclave pages using this technique.
With this enhancement the workload experiences a 5% performance degradation when compared to a kernel without commit 8795359e35bc ("x86/sgx: Silence softlockup detection when releasing large enclaves"), an improvement to the reported 25% degradation, while still placating the soft lockup detector.
Scenarios with poor performance are still possible even with these enhancements. For example, short workloads creating sub processes while running in large enclaves. Further performance improvements are pursued in user space through avoiding to create duplicate enclaves for certain sub processes, and using SGX2 that will do lazy allocation of pages as needed so enclaves created for sub processes start quickly and release quickly.
--- arch/x86/kernel/cpu/sgx/encl.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/sgx/encl.c +19 -4
@@ -680,11 +680,15 @@ const struct vm_operations_struct sgx_vm_ops = {void sgx_encl_release (struct kref *ref) { struct sgx_encl *encl = container_of(ref, struct sgx_encl, refcount); +unsigned long max_page_index =PFN_DOWN (encl->base + encl->size -1 );struct sgx_va_page *va_page;struct sgx_encl_page *entry; -unsigned long index; +unsigned long count =0 ; + +XA_STATE (xas, &encl->page_array,PFN_DOWN (encl->base)); -xa_for_each (&encl->page_array, index, entry) { +xas_lock (&xas); +xas_for_each (&xas, entry, max_page_index) {if (entry->epc_page) {/* * The page and its radix tree entry cannot be freed
@@ -699,9 +703,20 @@ void sgx_encl_release(struct kref *ref) }kfree (entry); -/* Invoke scheduler to prevent soft lockups. */ -cond_resched (); +/* +* Invoke scheduler on every XA_CHECK_SCHED iteration +* to prevent soft lockups. +*/ +if (!(++count %XA_CHECK_SCHED )) { +xas_pause (&xas); +xas_unlock (&xas); + +cond_resched (); + +xas_lock (&xas); + } } +xas_unlock (&xas);xa_destroy (&encl->page_array);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 118/1146 PM: hibernate: Fix mistake in kerneldoc comment
In reply to Greg Kroah-HartmanFrom: xiongxin <[email protected]>
[ Upstream commit 6e5d7300cbe7c3541bc31f16db3e9266e6027b4b ]
The actual maximum image size formula in hibernate_preallocate_memory() is as follows:
max_size = (count - (size + PAGES_FOR_IO)) / 2
- 2 * DIV_ROUND_UP(reserved_size, PAGE_SIZE);
but the one in the kerneldoc comment of the function is different and incorrect.
--- kernel/power/snapshot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/power/snapshot.c +2 -2
@@ -1723,8 +1723,8 @@ static unsigned long minimum_image_size(unsigned long saveable)* /sys/power/reserved_size, respectively). To make this happen, we compute the * total number of available page frames and allocate at least * -* ([page frames total] + PAGES_FOR_IO + [metadata pages]) / 2 -* + 2 * DIV_ROUND_UP(reserved_size, PAGE_SIZE) +* ([page frames total] - PAGES_FOR_IO - [metadata pages]) / 2 +* - 2 * DIV_ROUND_UP(reserved_size, PAGE_SIZE) * * of them, which corresponds to the maximum size of a hibernation image. *
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 119/1146 fs: dont audit the capability check in simple_xattr_list()
In reply to Greg Kroah-HartmanFrom: Ondrej Mosnacek <[email protected]>
[ Upstream commit e7eda157c4071cd1e69f4b1687b0fbe1ae5e6f46 ]
The check being unconditional may lead to unwanted denials reported by LSMs when a process has the capability granted by DAC, but denied by an LSM. In the case of SELinux such denials are a problem, since they can't be effectively filtered out via the policy and when not silenced, they produce noise that may hide a true problem or an attack.
Checking for the capability only if any trusted xattr is actually present wouldn't really address the issue, since calling listxattr(2) on such node on its own doesn't indicate an explicit attempt to see the trusted xattrs. Additionally, it could potentially leak the presence of trusted xattrs to an unprivileged user if they can check for the denials (e.g. through dmesg).
Therefore, it's best (and simplest) to keep the check unconditional and instead use ns_capable_noaudit() that will silence any associated LSM denials.
--- fs/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xattr.c +1 -1
@@ -1140,7 +1140,7 @@ static int xattr_list_one(char **buffer, ssize_t *remaining_size,ssize_t simple_xattr_list (struct inode *inode,struct simple_xattrs *xattrs,char *buffer,size_t size) { -bool trusted =capable (CAP_SYS_ADMIN ); +bool trusted =ns_capable_noaudit (&init_user_ns,CAP_SYS_ADMIN );struct simple_xattr *xattr;ssize_t remaining_size = size;int err =0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 120/1146 cpufreq: qcom-hw: Fix memory leak in qcom_cpufreq_hw_read_lut()
In reply to Greg Kroah-HartmanFrom: Chen Hui <[email protected]>
[ Upstream commit 9901c21bcaf2f01fe5078f750d624f4ddfa8f81b ]
If "cpu_dev" fails to get opp table in qcom_cpufreq_hw_read_lut(), the program will return, resulting in "table" resource is not released.
--- drivers/cpufreq/qcom-cpufreq-hw.c | 1 + 1 file changed, 1 insertion(+)
drivers/cpufreq/qcom-cpufreq-hw.c +1 -0
@@ -193,6 +193,7 @@ static int qcom_cpufreq_hw_read_lut(struct device *cpu_dev, } }else if (ret != -ENODEV ) {dev_err (cpu_dev,"Invalid opp table in device tree\n" ); +kfree (table);return ret; }else { policy->fast_switch_possible = true;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 121/1146 x86/split_lock: Add sysctl to control the misery mode
In reply to Greg Kroah-HartmanFrom: Guilherme G. Piccoli <[email protected]>
[ Upstream commit 727209376f4998bc84db1d5d8af15afea846a92b ]
Commit b041b525dab9 ("x86/split_lock: Make life miserable for split lockers") changed the way the split lock detector works when in "warn" mode; basically, it not only shows the warn message, but also intentionally introduces a slowdown through sleeping plus serialization mechanism on such task. Based on discussions in [0], seems the warning alone wasn't enough motivation for userspace developers to fix their applications.
This slowdown is enough to totally break some proprietary (aka. unfixable) userspace[1].
Happens that originally the proposal in [0] was to add a new mode which would warns + slowdown the "split locking" task, keeping the old warn mode untouched. In the end, that idea was discarded and the regular/default "warn" mode now slows down the applications. This is quite aggressive with regards proprietary/legacy programs that basically are unable to properly run in kernel with this change. While it is understandable that a malicious application could DoS by split locking, it seems unacceptable to regress old/proprietary userspace programs through a default configuration that previously worked. An example of such breakage was reported in [1].
Add a sysctl to allow controlling the "misery mode" behavior, as per Thomas suggestion on [2]. This way, users running legacy and/or proprietary software are allowed to still execute them with a decent performance while still observing the warning messages on kernel log.
[0] https://lore.kernel.org/lkml/[email protected]/
[1] https://github.com/doitsujin/dxvk/issues/2938
[2] https://lore.kernel.org/lkml/87pmf4bter.ffs@tglx/
[ dhansen: minor changelog tweaks, including clarifying the actual
problem ]
--- Documentation/admin-guide/sysctl/kernel.rst | 23 ++++++++ arch/x86/kernel/cpu/intel.c | 63 +++++++++++++++++---- 2 files changed, 76 insertions(+), 10 deletions(-)
Documentation/admin-guide/sysctl/kernel.rst +23 -0
@@ -1314,6 +1314,29 @@ watchdog work to be queued by the watchdog timer function, otherwise the NMI watchdog — if enabled — can detect a hard lockup condition. +split_lock_mitigate (x86 only) +============================== + +On x86, each "split lock" imposes a system-wide performance penalty. On larger +systems, large numbers of split locks from unprivileged users can result in +denials of service to well-behaved and potentially more important users. + +The kernel mitigates these bad users by detecting split locks and imposing +penalties: forcing them to wait and only allowing one core to execute split +locks at a time. + +These mitigations can make those bad applications unbearably slow. Setting +split_lock_mitigate=0 may restore some application performance, but will also +increase system exposure to denial of service attacks from split lock users. + += =================================================================== +0 Disable the mitigation mode - just warns the split lock on kernel log + and exposes the system to denials of service from the split lockers. +1 Enable the mitigation mode (this is the default) - penalizes the split + lockers with intentional performance degradation. += =================================================================== + + stack_erasing =============
arch/x86/kernel/cpu/intel.c +53 -10
97 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 122/1146 ACPI: irq: Fix some kernel-doc issues
In reply to Greg Kroah-HartmanFrom: Xiongfeng Wang <[email protected]>
[ Upstream commit ebb92d58b90753e658059f5d8590d9048395491a ]
The following commit change the second parameter of acpi_set_irq_model() but forgot to update the function description. Let's fix it.
commit 7327b16f5f56 ("APCI: irq: Add support for multiple GSI domains")
Also add description of parameter 'gsi' for acpi_get_irq_source_fwhandle() to avoid the following build W=1 warning.
drivers/acpi/irq.c:108: warning: Function parameter or member 'gsi' not described in 'acpi_get_irq_source_fwhandle'
--- drivers/acpi/irq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/acpi/irq.c +3 -2
@@ -94,6 +94,7 @@ EXPORT_SYMBOL_GPL(acpi_unregister_gsi);/** * acpi_get_irq_source_fwhandle() - Retrieve fwhandle from IRQ resource source. * @source: acpi_resource_source to use for the lookup. +* @gsi: GSI IRQ number * * Description: * Retrieve the fwhandle of the device referenced by the given IRQ resource
@@ -297,8 +298,8 @@ EXPORT_SYMBOL_GPL(acpi_irq_get);/** * acpi_set_irq_model - Setup the GSI irqdomain information * @model: the value assigned to acpi_irq_model -* @fwnode: the irq_domain identifier for mapping and looking up -* GSI interrupts +* @fn: a dispatcher function that will return the domain fwnode +* for a given GSI */ void __init acpi_set_irq_model (enum acpi_irq_model_id model,struct fwnode_handle *(*fn)(u32 ))
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 123/1146 selftests/ftrace: event_triggers: wait longer for test_event_enable
In reply to Greg Kroah-HartmanFrom: Yipeng Zou <[email protected]>
[ Upstream commit a1d6cd88c8973cfb08ee85722488b1d6d5d16327 ]
In some platform, the schedule event may came slowly, delay 100ms can't cover it.
I was notice that on my board which running in low cpu_freq,and this selftests allways gose fail.
So maybe we can check more times here to wait longer.
--- .../ftrace/test.d/ftrace/func_event_triggers.tc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc +11 -4
@@ -38,11 +38,18 @@ cnt_trace() { test_event_enabled() { val=$1 + check_times=10 # wait for 10 * SLEEP_TIME at most - e=`cat $EVENT_ENABLE` - if [ "$e" != $val ]; then - fail "Expected $val but found $e" - fi + while [ $check_times -ne 0 ]; do + e=`cat $EVENT_ENABLE` + if [ "$e" == $val ]; then + return 0 + fi + sleep $SLEEP_TIME + check_times=$((check_times - 1)) + done + + fail "Expected $val but found $e" } run_enable_disable() {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 124/1146 perf: Fix possible memleak in pmu_dev_alloc()
In reply to Greg Kroah-HartmanFrom: Chen Zhongjin <[email protected]>
[ Upstream commit e8d7a90c08ce963c592fb49845f2ccc606a2ac21 ]
In pmu_dev_alloc(), when dev_set_name() failed, it will goto free_dev and call put_device(pmu->dev) to release it.
However pmu->dev->release is assigned after this, which makes warning and memleak.
Call dev_set_name() after pmu->dev->release = pmu_dev_release to fix it.
Device '(null)' does not have a release() function...
WARNING: CPU: 2 PID: 441 at drivers/base/core.c:2332 device_release+0x1b9/0x240
...
Call Trace:
<TASK>
kobject_put+0x17f/0x460
put_device+0x20/0x30
pmu_dev_alloc+0x152/0x400
perf_pmu_register+0x96b/0xee0
...
kmemleak: 1 new suspected memory leaks (see /sys/kernel/debug/kmemleak)
unreferenced object 0xffff888014759000 (size 2048):
comm "modprobe", pid 441, jiffies 4294931444 (age 38.332s)
backtrace:
[<0000000005aed3b4>] kmalloc_trace+0x27/0x110
[<000000006b38f9b8>] pmu_dev_alloc+0x50/0x400
[<00000000735f17be>] perf_pmu_register+0x96b/0xee0
[<00000000e38477f1>] 0xffffffffc0ad8603
[<000000004e162216>] do_one_initcall+0xd0/0x4e0
...--- kernel/events/core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
kernel/events/core.c +5 -3
@@ -11193,13 +11193,15 @@ static int pmu_dev_alloc(struct pmu *pmu) pmu->dev->groups = pmu->attr_groups;device_initialize (pmu->dev); - ret =dev_set_name (pmu->dev,"%s" , pmu->name); -if (ret) - goto free_dev;dev_set_drvdata (pmu->dev, pmu); pmu->dev->bus = &pmu_bus; pmu->dev->release = pmu_dev_release; + + ret =dev_set_name (pmu->dev,"%s" , pmu->name); +if (ret) + goto free_dev; + ret =device_add (pmu->dev);if (ret) goto free_dev;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 125/1146 lib/debugobjects: fix stat count and optimize debug_objects_mem_init
In reply to Greg Kroah-HartmanFrom: wuchi <[email protected]>
[ Upstream commit eabb7f1ace53e127309407b2b5e74e8199e85270 ]
1. Var debug_objects_allocated tracks valid kmem_cache_alloc calls, so track it in debug_objects_replace_static_objects. Do similar things in object_cpu_offline.
2. In debug_objects_mem_init, there is no need to call function cpuhp_setup_state_nocalls when debug_objects_enabled = 0 (out of memory).
--- lib/debugobjects.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
lib/debugobjects.c +10 -0
@@ -437,6 +437,7 @@ static int object_cpu_offline(unsigned int cpu)struct debug_percpu_free *percpu_pool;struct hlist_node *tmp;struct debug_obj *obj; +unsigned long flags;/* Remote access is safe as the CPU is dead already */ percpu_pool =per_cpu_ptr (&percpu_obj_pool, cpu);
@@ -444,6 +445,12 @@ static int object_cpu_offline(unsigned int cpu)hlist_del (&obj->node);kmem_cache_free (obj_cache, obj); } + +raw_spin_lock_irqsave (&pool_lock, flags); + obj_pool_used -= percpu_pool->obj_free; + debug_objects_freed += percpu_pool->obj_free; +raw_spin_unlock_irqrestore (&pool_lock, flags); + percpu_pool->obj_free =0 ;return 0 ;
@@ -1318,6 +1325,8 @@ static int __init debug_objects_replace_static_objects(void)hlist_add_head (&obj->node, &objects); } + debug_objects_allocated += i; +/* * debug_objects_mem_init() is now called early that only one CPU is up * and interrupts have been disabled, so it is safe to replace the
@@ -1386,6 +1395,7 @@ void __init debug_objects_mem_init(void) debug_objects_enabled =0 ;kmem_cache_destroy (obj_cache);pr_warn ("out of memory.\n" ); +return ; }else debug_objects_selftest ();
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 126/1146 platform/x86: huawei-wmi: fix return value calculation
In reply to Greg Kroah-HartmanFrom: Barnabás Pőcze <[email protected]>
[ Upstream commit 0b9a1dcdb6a2c841899389bf2dd7a3e0e2aa0e99 ]
Previously, huawei_wmi_input_setup() returned the result of logical or-ing the return values of two functions that return negative errno-style error codes and one that returns acpi_status. If this returned value was non-zero, then it was propagated from the platform driver's probe function. That function should return a negative errno-style error code, so the result of the logical or that huawei_wmi_input_setup() returned was not appropriate.
Fix that by checking each function separately and returning the error code unmodified.
--- drivers/platform/x86/huawei-wmi.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/platform/x86/huawei-wmi.c +16 -4
@@ -760,6 +760,9 @@ static int huawei_wmi_input_setup(struct device *dev,const char *guid, struct input_dev **idev) { + acpi_status status; +int err; + *idev =devm_input_allocate_device (dev);if (!*idev)return -ENOMEM ;
@@ -769,10 +772,19 @@ static int huawei_wmi_input_setup(struct device *dev, (*idev)->id.bustype =BUS_HOST ; (*idev)->dev.parent = dev; -return sparse_keymap_setup (*idev, huawei_wmi_keymap,NULL ) || -input_register_device (*idev) || -wmi_install_notify_handler (guid, huawei_wmi_input_notify, - *idev); + err =sparse_keymap_setup (*idev, huawei_wmi_keymap,NULL ); +if (err) +return err; + + err =input_register_device (*idev); +if (err) +return err; + + status =wmi_install_notify_handler (guid, huawei_wmi_input_notify, *idev); +if (ACPI_FAILURE (status)) +return -EIO ; + +return 0 ; }static void huawei_wmi_input_exit (struct device *dev,const char *guid)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 127/1146 timerqueue: Use rb_entry_safe() in timerqueue_getnext()
In reply to Greg Kroah-HartmanFrom: Barnabás Pőcze <[email protected]>
[ Upstream commit 2f117484329b233455ee278f2d9b0a4356835060 ]
When timerqueue_getnext() is called on an empty timer queue, it will use rb_entry() on a NULL pointer, which is invalid. Fix that by using rb_entry_safe() which handles NULL pointers.
This has not caused any issues so far because the offset of the rb_node member in timerqueue_node is 0, so rb_entry() is essentially a no-op.
--- include/linux/timerqueue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/timerqueue.h +1 -1
@@ -35,7 +35,7 @@ struct timerqueue_node *timerqueue_getnext(struct timerqueue_head *head) {struct rb_node *leftmost =rb_first_cached (&head->rb_root); - return rb_entry(leftmost, struct timerqueue_node, node); + return rb_entry_safe(leftmost, struct timerqueue_node, node); }static inline void timerqueue_init (struct timerqueue_node *node)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 128/1146 proc: fixup uptime selftest
In reply to Greg Kroah-HartmanFrom: Alexey Dobriyan <[email protected]>
[ Upstream commit 5cc81d5c81af0dee54da9a67a3ebe4be076a13db ]
syscall(3) returns -1 and sets errno on error, unlike "syscall" instruction.
Systems which have <= 32/64 CPUs are unaffected. Test won't bounce to all CPUs before completing if there are more of them.
--- tools/testing/selftests/proc/proc-uptime-002.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/proc/proc-uptime-002.c +2 -1
@@ -17,6 +17,7 @@// while shifting across CPUs. #undef NDEBUG#include <assert.h> +#include <errno.h> #include <unistd.h> #include <sys/syscall.h> #include <stdlib.h>
@@ -54,7 +55,7 @@ int main(void) len +=sizeof (unsigned long );free (m); m =malloc (len); - }while (sys_sched_getaffinity (0 , len, m) == -EINVAL ); + }while (sys_sched_getaffinity (0 , len, m) ==-1 && errno ==EINVAL ); fd =open ("/proc/uptime" ,O_RDONLY );assert (fd >=0 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 129/1146 lib/fonts: fix undefined behavior in bit shift for get_default_font
In reply to Greg Kroah-HartmanFrom: Gaosheng Cui <[email protected]>
[ Upstream commit 6fe888c4d2fb174408e4540bb2d5602b9f507f90 ]
Shifting signed 32-bit value by 31 bits is undefined, so changing significant bit to unsigned. The UBSAN warning calltrace like below:
UBSAN: shift-out-of-bounds in lib/fonts/fonts.c:139:20 left shift of 1 by 31 places cannot be represented in type 'int' <TASK> dump_stack_lvl+0x7d/0xa5 dump_stack+0x15/0x1b ubsan_epilogue+0xe/0x4e __ubsan_handle_shift_out_of_bounds+0x1e7/0x20c get_default_font+0x1c7/0x1f0 fbcon_startup+0x347/0x3a0 do_take_over_console+0xce/0x270 do_fbcon_takeover+0xa1/0x170 do_fb_registered+0x2a8/0x340 fbcon_fb_registered+0x47/0xe0 register_framebuffer+0x294/0x4a0 __drm_fb_helper_initial_config_and_unlock+0x43c/0x880 [drm_kms_helper] drm_fb_helper_initial_config+0x52/0x80 [drm_kms_helper] drm_fbdev_client_hotplug+0x156/0x1b0 [drm_kms_helper] drm_fbdev_generic_setup+0xfc/0x290 [drm_kms_helper] bochs_pci_probe+0x6ca/0x772 [bochs] local_pci_probe+0x4d/0xb0 pci_device_probe+0x119/0x320 really_probe+0x181/0x550 __driver_probe_device+0xc6/0x220 driver_probe_device+0x32/0x100 __driver_attach+0x195/0x200 bus_for_each_dev+0xbb/0x120 driver_attach+0x27/0x30 bus_add_driver+0x22e/0x2f0 driver_register+0xa9/0x190 __pci_register_driver+0x90/0xa0 bochs_pci_driver_init+0x52/0x1000 [bochs] do_one_initcall+0x76/0x430 do_init_module+0x61/0x28a load_module+0x1f82/0x2e50 __do_sys_finit_module+0xf8/0x190 __x64_sys_finit_module+0x23/0x30 do_syscall_64+0x58/0x80 entry_SYSCALL_64_after_hwframe+0x63/0xcd </TASK>
--- lib/fonts/fonts.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/fonts/fonts.c +2 -2
@@ -135,8 +135,8 @@ const struct font_desc *get_default_font(int xres, int yres, u32 font_w,if (res >20 ) c +=20 - res; -if ((font_w & (1 << (f->width -1 ))) && - (font_h & (1 << (f->height -1 )))) +if ((font_w & (1U << (f->width -1 ))) && + (font_h & (1U << (f->height -1 )))) c +=1000 ;if (c > cc) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 130/1146 ocfs2: fix memory leak in ocfs2_stack_glue_init()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
[ Upstream commit 13b6269dd022aaa69ca8d1df374ab327504121cf ]
ocfs2_table_header should be free in ocfs2_stack_glue_init() if ocfs2_sysfs_init() failed, otherwise kmemleak will report memleak.
BUG: memory leak
unreferenced object 0xffff88810eeb5800 (size 128):
comm "modprobe", pid 4507, jiffies 4296182506 (age 55.888s)
hex dump (first 32 bytes):
c0 40 14 a0 ff ff ff ff 00 00 00 00 01 00 00 00 .@..............
01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<000000001e59e1cd>] __register_sysctl_table+0xca/0xef0
[<00000000c04f70f7>] 0xffffffffa0050037
[<000000001bd12912>] do_one_initcall+0xdb/0x480
[<0000000064f766c9>] do_init_module+0x1cf/0x680
[<000000002ba52db0>] load_module+0x6441/0x6f20
[<000000009772580d>] __do_sys_finit_module+0x12f/0x1c0
[<00000000380c1f22>] do_syscall_64+0x3f/0x90
[<000000004cf473bc>] entry_SYSCALL_64_after_hwframe+0x63/0xcd--- fs/ocfs2/stackglue.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
fs/ocfs2/stackglue.c +7 -1
@@ -669,6 +669,8 @@ static struct ctl_table_header *ocfs2_table_header;static int __init ocfs2_stack_glue_init (void ) { +int ret; +strcpy (cluster_stack_name,OCFS2_STACK_PLUGIN_O2CB ); ocfs2_table_header =register_sysctl ("fs/ocfs2/nm" , ocfs2_nm_table);
@@ -678,7 +680,11 @@ static int __init ocfs2_stack_glue_init(void)return -ENOMEM ;/* or something. */ } -return ocfs2_sysfs_init (); + ret =ocfs2_sysfs_init (); +if (ret) +unregister_sysctl_table (ocfs2_table_header); + +return ret; } static void __exit ocfs2_stack_glue_exit(void)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 131/1146 selftests: cgroup: fix unsigned comparison with less than zero
In reply to Greg Kroah-HartmanFrom: YueHaibing <[email protected]>
[ Upstream commit 333d073dee3a6865171d43e3b0a9ff688bff5891 ]
'size' is unsigned, it never less than zero.
--- tools/testing/selftests/cgroup/cgroup_util.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/testing/selftests/cgroup/cgroup_util.c +3 -2
@@ -555,6 +555,7 @@ int proc_mount_contains(const char *option)ssize_t proc_read_text (int pid,bool thread,const char *item,char *buf,size_t size) {char path[PATH_MAX ]; +ssize_t ret;if (!pid) snprintf(path, sizeof(path), "/proc/%s/%s",
@@ -562,8 +563,8 @@ ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, size_telse snprintf (path,sizeof (path),"/proc/%d/%s" , pid, item); - size =read_text (path, buf, size); -return size <0 ?-1 : size; + ret =read_text (path, buf, size); +return ret <0 ?-1 : ret; }int proc_read_strstr (int pid,bool thread,const char *item,const char *needle)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 132/1146 cpufreq: qcom-hw: Fix the frequency returned by cpufreq_driver->get()
In reply to Greg Kroah-HartmanFrom: Manivannan Sadhasivam <[email protected]>
[ Upstream commit c72cf0cb1d77f6b1b58c334dcc3d09fa13111c4c ]
The cpufreq_driver->get() callback is supposed to return the current frequency of the CPU and not the one requested by the CPUFreq core. Fix it by returning the frequency that gets supplied to the CPU after the DCVS operation of EPSS/OSM.
--- drivers/cpufreq/qcom-cpufreq-hw.c | 42 +++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 13 deletions(-)
drivers/cpufreq/qcom-cpufreq-hw.c +29 -13
@@ -125,7 +125,35 @@ static int qcom_cpufreq_hw_target_index(struct cpufreq_policy *policy,return 0 ; } +static unsigned long qcom_lmh_get_throttle_freq (struct qcom_cpufreq_data *data) +{ +unsigned int lval; + +if (data->soc_data->reg_current_vote) + lval =readl_relaxed (data->base + data->soc_data->reg_current_vote) &0x3ff ; +else + lval =readl_relaxed (data->base + data->soc_data->reg_domain_state) &0xff ; + +return lval * xo_rate; +} + +/* Get the current frequency of the CPU (after throttling) */ static unsigned int qcom_cpufreq_hw_get (unsigned int cpu) +{ +struct qcom_cpufreq_data *data; +struct cpufreq_policy *policy; + + policy =cpufreq_cpu_get_raw (cpu); +if (!policy) +return 0 ; + + data = policy->driver_data; + +return qcom_lmh_get_throttle_freq (data) /HZ_PER_KHZ ; +} + +/* Get the frequency requested by the cpufreq core for the CPU */ +static unsigned int qcom_cpufreq_get_freq (unsigned int cpu) {struct qcom_cpufreq_data *data;const struct qcom_cpufreq_soc_data *soc_data;
@@ -287,18 +315,6 @@ static void qcom_get_related_cpus(int index, struct cpumask *m) } } -static unsigned long qcom_lmh_get_throttle_freq (struct qcom_cpufreq_data *data) -{ -unsigned int lval; - -if (data->soc_data->reg_current_vote) - lval =readl_relaxed (data->base + data->soc_data->reg_current_vote) &0x3ff ; -else - lval =readl_relaxed (data->base + data->soc_data->reg_domain_state) &0xff ; - -return lval * xo_rate; -} -static void qcom_lmh_dcvs_notify (struct qcom_cpufreq_data *data) {struct cpufreq_policy *policy = data->policy;
@@ -342,7 +358,7 @@ static void qcom_lmh_dcvs_notify(struct qcom_cpufreq_data *data)* If h/w throttled frequency is higher than what cpufreq has requested * for, then stop polling and switch back to interrupt mechanism. */ -if (throttled_freq >=qcom_cpufreq_hw_get (cpu)) +if (throttled_freq >=qcom_cpufreq_get_freq (cpu))enable_irq (data->throttle_irq);else mod_delayed_work(system_highpri_wq, &data->throttle_work,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 133/1146 MIPS: vpe-mt: fix possible memory leak while module exiting
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 5822e8cc84ee37338ab0bdc3124f6eec04dc232d ]
Afer commit 1fa5ae857bb1 ("driver core: get rid of struct device's bus_id string array"), the name of device is allocated dynamically, it need be freed when module exiting, call put_device() to give up reference, so that it can be freed in kobject_cleanup() when the refcount hit to 0. The vpe_device is static, so remove kfree() from vpe_device_release().
--- arch/mips/kernel/vpe-mt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/kernel/vpe-mt.c +2 -2
@@ -313,7 +313,6 @@ ATTRIBUTE_GROUPS(vpe);static void vpe_device_release (struct device *cd) { -kfree (cd); }static struct class vpe_class = {
@@ -497,6 +496,7 @@ int __init vpe_module_init(void)device_del (&vpe_device); out_class: +put_device (&vpe_device);class_unregister (&vpe_class); out_chrdev:
@@ -509,7 +509,7 @@ void __exit vpe_module_exit(void) {struct vpe *v, *n; -device_del (&vpe_device); +device_unregister (&vpe_device);class_unregister (&vpe_class);unregister_chrdev (major,VPE_MODULE_NAME );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 134/1146 MIPS: vpe-cmp: fix possible memory leak while module exiting
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit c5ed1fe0801f0c66b0fbce2785239a5664629057 ]
dev_set_name() allocates memory for name, it need be freed when module exiting, call put_device() to give up reference, so that it can be freed in kobject_cleanup() when the refcount hit to 0. The vpe_device is static, so remove kfree() from vpe_device_release().
--- arch/mips/kernel/vpe-cmp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/kernel/vpe-cmp.c +2 -2
@@ -75,7 +75,6 @@ ATTRIBUTE_GROUPS(vpe);static void vpe_device_release (struct device *cd) { -kfree (cd); }static struct class vpe_class = {
@@ -157,6 +156,7 @@ int __init vpe_module_init(void)device_del (&vpe_device); out_class: +put_device (&vpe_device);class_unregister (&vpe_class); out_chrdev:
@@ -169,7 +169,7 @@ void __exit vpe_module_exit(void) {struct vpe *v, *n; -device_del (&vpe_device); +device_unregister (&vpe_device);class_unregister (&vpe_class);unregister_chrdev (major,VPE_MODULE_NAME );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 135/1146 selftests/efivarfs: Add checking of the test return value
In reply to Greg Kroah-HartmanFrom: Zhao Gongyi <[email protected]>
[ Upstream commit c93924267fe6f2b44af1849f714ae9cd8117a9cd ]
Add checking of the test return value, otherwise it will report success forever for test_create_read().
--- tools/testing/selftests/efivarfs/efivarfs.sh | 5 +++++ 1 file changed, 5 insertions(+)
tools/testing/selftests/efivarfs/efivarfs.sh +5 -0
@@ -87,6 +87,11 @@ test_create_read() { local file=$efivarfs_mount/$FUNCNAME-$test_guid ./create-read $file + if [ $? -ne 0 ]; then + echo "create and read $file failed" + file_cleanup $file + exit 1 + fi file_cleanup $file }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 136/1146 PNP: fix name memory leak in pnp_alloc_dev()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 110d7b0325c55ff3620073ba4201845f59e22ebf ]
After commit 1fa5ae857bb1 ("driver core: get rid of struct device's bus_id string array"), the name of device is allocated dynamically, move dev_set_name() after pnp_add_id() to avoid memory leak.
--- drivers/pnp/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pnp/core.c +2 -2
@@ -148,14 +148,14 @@ struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, dev->dev.coherent_dma_mask = dev->dma_mask; dev->dev.release = &pnp_release_device; -dev_set_name (&dev->dev,"%02x:%02x" , dev->protocol->number, dev->number); - dev_id =pnp_add_id (dev, pnpid);if (!dev_id) {kfree (dev);return NULL ; } +dev_set_name (&dev->dev,"%02x:%02x" , dev->protocol->number, dev->number); +return dev; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 137/1146 mailbox: pcc: Reset pcc_chan_count to zero in case of PCC probe failure
In reply to Greg Kroah-HartmanFrom: Huisong Li <[email protected]>
[ Upstream commit 6d7d3c287410c0ad499e478e2338dc3d7e3392b1 ]
Currently, 'pcc_chan_count' is remains set to a non-zero value if PCC subspaces are parsed successfully but something else fail later during the initial PCC probing phase. This will result in pcc_mbox_request_channel trying to access the resources that are not initialised or allocated and may end up in a system crash.
Reset pcc_chan_count to 0 when the PCC probe fails in order to prevent the possible issue as described above.
--- drivers/mailbox/pcc.c | 1 + 1 file changed, 1 insertion(+)
drivers/mailbox/pcc.c +1 -0
@@ -743,6 +743,7 @@ static int __init pcc_init(void)if (IS_ERR (pcc_pdev)) {pr_debug ("Err creating PCC platform bundle\n" ); + pcc_chan_count =0 ;return PTR_ERR (pcc_pdev); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 138/1146 ACPI: pfr_telemetry: use ACPI_FREE() to free acpi_object
In reply to Greg Kroah-HartmanFrom: Wang ShaoBo <[email protected]>
[ Upstream commit 0f2aa7fc2a9aee05bafb965d5b1638d3e74b4c61 ]
acpi_evaluate_dsm_typed()/acpi_evaluate_dsm() should be coupled with ACPI_FREE() to free the ACPI memory, because we need to track the allocation of acpi_object when ACPI_DBG_TRACK_ALLOCATIONS enabled, so use ACPI_FREE() instead of kfree().
--- drivers/acpi/pfr_telemetry.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/acpi/pfr_telemetry.c +3 -3
@@ -144,7 +144,7 @@ static int get_pfrt_log_data_info(struct pfrt_log_data_info *data_info, ret =0 ; free_acpi_buffer: -kfree (out_obj); +ACPI_FREE (out_obj);return ret; }
@@ -180,7 +180,7 @@ static int set_pfrt_log_level(int level, struct pfrt_log_device *pfrt_log_dev) ret = -EBUSY ; } -kfree (out_obj); +ACPI_FREE (out_obj);return ret; }
@@ -218,7 +218,7 @@ static int get_pfrt_log_level(struct pfrt_log_device *pfrt_log_dev) ret = obj->integer.value; free_acpi_buffer: -kfree (out_obj); +ACPI_FREE (out_obj);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 139/1146 ACPI: pfr_update: use ACPI_FREE() to free acpi_object
In reply to Greg Kroah-HartmanFrom: Wang ShaoBo <[email protected]>
[ Upstream commit e335beed78ec82656dcb554f9fe560709f0dc408 ]
acpi_evaluate_dsm_typed()/acpi_evaluate_dsm() should be coupled with ACPI_FREE() to free the ACPI memory, because we need to track the allocation of acpi_object when ACPI_DBG_TRACK_ALLOCATIONS enabled, so use ACPI_FREE() instead of kfree().
--- drivers/acpi/pfr_update.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/acpi/pfr_update.c +3 -3
@@ -178,7 +178,7 @@ static int query_capability(struct pfru_update_cap_info *cap_hdr, ret =0 ; free_acpi_buffer: -kfree (out_obj); +ACPI_FREE (out_obj);return ret; }
@@ -224,7 +224,7 @@ static int query_buffer(struct pfru_com_buf_info *info, ret =0 ; free_acpi_buffer: -kfree (out_obj); +ACPI_FREE (out_obj);return ret; }
@@ -385,7 +385,7 @@ static int start_update(int action, struct pfru_device *pfru_dev) ret =0 ; free_acpi_buffer: -kfree (out_obj); +ACPI_FREE (out_obj);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 140/1146 perf/x86/intel/uncore: Fix reference count leak in sad_cfg_iio_topology()
In reply to Greg Kroah-HartmanFrom: Xiongfeng Wang <[email protected]>
[ Upstream commit c508eb042d9739bf9473526f53303721b70e9100 ]
pci_get_device() will increase the reference count for the returned pci_dev, and also decrease the reference count for the input parameter *from* if it is not NULL.
If we break the loop in sad_cfg_iio_topology() with 'dev' not NULL. We need to call pci_dev_put() to decrease the reference count. Since pci_dev_put() can handle the NULL input parameter, we can just add one pci_dev_put() right before 'return ret'.
--- arch/x86/events/intel/uncore_snbep.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/events/intel/uncore_snbep.c +2 -0
@@ -4492,6 +4492,8 @@ static int sad_cfg_iio_topology(struct intel_uncore_type *type, u8 *sad_pmon_map type->topology =NULL ; } +pci_dev_put (dev); +return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 141/1146 perf/x86/intel/uncore: Fix reference count leak in hswep_has_limit_sbox()
In reply to Greg Kroah-HartmanFrom: Xiongfeng Wang <[email protected]>
[ Upstream commit 1ff9dd6e7071a561f803135c1d684b13c7a7d01d ]
pci_get_device() will increase the reference count for the returned 'dev'. We need to call pci_dev_put() to decrease the reference count. Since 'dev' is only used in pci_read_config_dword(), let's add pci_dev_put() right after it.
--- arch/x86/events/intel/uncore_snbep.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/events/intel/uncore_snbep.c +1 -0
@@ -2891,6 +2891,7 @@ static bool hswep_has_limit_sbox(unsigned int device)return false;pci_read_config_dword (dev,HSWEP_PCU_CAPID4_OFFET , &capid4); +pci_dev_put (dev);if (!hswep_get_chop (capid4))return true;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 142/1146 perf/x86/intel/uncore: Fix reference count leak in snr_uncore_mmio_map()
In reply to Greg Kroah-HartmanFrom: Xiongfeng Wang <[email protected]>
[ Upstream commit 8ebd16c11c346751b3944d708e6c181ed4746c39 ]
pci_get_device() will increase the reference count for the returned pci_dev, so snr_uncore_get_mc_dev() will return a pci_dev with its reference count increased. We need to call pci_dev_put() to decrease the reference count. Let's add the missing pci_dev_put().
--- arch/x86/events/intel/uncore_snbep.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/events/intel/uncore_snbep.c +2 -0
@@ -4860,6 +4860,8 @@ static int snr_uncore_mmio_map(struct intel_uncore_box *box, addr += box_ctl; +pci_dev_put (pdev); + box->io_addr =ioremap (addr, type->mmio_map_size);if (!box->io_addr) {pr_warn ("perf uncore: Failed to ioremap for %s.\n" , type->name);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 143/1146 perf/x86/intel/uncore: Fix reference count leak in __uncore_imc_init_box()
In reply to Greg Kroah-HartmanFrom: Xiongfeng Wang <[email protected]>
[ Upstream commit 17b8d847b92d815d1638f0de154654081d66b281 ]
pci_get_device() will increase the reference count for the returned pci_dev, so tgl_uncore_get_mc_dev() will return a pci_dev with its reference count increased. We need to call pci_dev_put() to decrease the reference count before exiting from __uncore_imc_init_box(). Add pci_dev_put() for both normal and error path.
--- arch/x86/events/intel/uncore_snb.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/events/intel/uncore_snb.c +3 -0
@@ -1338,6 +1338,7 @@ static void __uncore_imc_init_box(struct intel_uncore_box *box,/* MCHBAR is disabled */ if (!(mch_bar &BIT (0 ))) {pr_warn ("perf uncore: MCHBAR is disabled. Failed to map IMC free-running counters.\n" ); +pci_dev_put (pdev);return ; } mch_bar &= ~BIT (0 );
@@ -1352,6 +1353,8 @@ static void __uncore_imc_init_box(struct intel_uncore_box *box, box->io_addr =ioremap (addr, type->mmio_map_size);if (!box->io_addr)pr_warn ("perf uncore: Failed to ioremap for %s.\n" , type->name); + +pci_dev_put (pdev); }static void tgl_uncore_imc_freerunning_init_box (struct intel_uncore_box *box)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 144/1146 platform/chrome: cros_usbpd_notify: Fix error handling in cros_usbpd_notify_init()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit 5a2d96623670155d94aca72c320c0ac27bdc6bd2 ]
The following WARNING message was given when rmmod cros_usbpd_notify:
Unexpected driver unregister!
WARNING: CPU: 0 PID: 253 at drivers/base/driver.c:270 driver_unregister+0x8a/0xb0 Modules linked in: cros_usbpd_notify(-) CPU: 0 PID: 253 Comm: rmmod Not tainted 6.1.0-rc3 #24 ... Call Trace: <TASK> cros_usbpd_notify_exit+0x11/0x1e [cros_usbpd_notify] __x64_sys_delete_module+0x3c7/0x570 ? __ia32_sys_delete_module+0x570/0x570 ? lock_is_held_type+0xe3/0x140 ? syscall_enter_from_user_mode+0x17/0x50 ? rcu_read_lock_sched_held+0xa0/0xd0 ? syscall_enter_from_user_mode+0x1c/0x50 do_syscall_64+0x37/0x90 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f333fe9b1b7
The reason is that the cros_usbpd_notify_init() does not check the return value of platform_driver_register(), and the cros_usbpd_notify can install successfully even if platform_driver_register() failed.
Fix by checking the return value of platform_driver_register() and unregister cros_usbpd_notify_plat_driver when it failed.
--- drivers/platform/chrome/cros_usbpd_notify.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/platform/chrome/cros_usbpd_notify.c +5 -1
@@ -239,7 +239,11 @@ static int __init cros_usbpd_notify_init(void)return ret;#ifdef CONFIG_ACPI -platform_driver_register (&cros_usbpd_notify_acpi_driver); + ret =platform_driver_register (&cros_usbpd_notify_acpi_driver); +if (ret) { +platform_driver_unregister (&cros_usbpd_notify_plat_driver); +return ret; + }#endif return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 145/1146 thermal: core: fix some possible name leaks in error paths
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 4748f9687caaeefab8578285b97b2f30789fc4b4 ]
In some error paths before device_register(), the names allocated by dev_set_name() are not freed. Move dev_set_name() front to device_register(), so the name can be freed while calling put_device().
--- drivers/thermal/thermal_core.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/thermal/thermal_core.c +10 -8
@@ -883,10 +883,6 @@ __thermal_cooling_device_register(struct device_node *np, cdev->id = ret; id = ret; - ret =dev_set_name (&cdev->device,"cooling_device%d" , cdev->id); -if (ret) - goto out_ida_remove; - cdev->type =kstrdup (type ? type :"" ,GFP_KERNEL );if (!cdev->type) { ret = -ENOMEM ;
@@ -901,6 +897,11 @@ __thermal_cooling_device_register(struct device_node *np, cdev->device.class = &thermal_class; cdev->devdata = devdata;thermal_cooling_device_setup_sysfs (cdev); + ret =dev_set_name (&cdev->device,"cooling_device%d" , cdev->id); +if (ret) { +thermal_cooling_device_destroy_sysfs (cdev); + goto out_kfree_type; + } ret =device_register (&cdev->device);if (ret) goto out_kfree_type;
@@ -1234,10 +1235,6 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t tz->id = id;strscpy (tz->type, type,sizeof (tz->type)); - result =dev_set_name (&tz->device,"thermal_zone%d" , tz->id); -if (result) - goto remove_id; -if (!ops->critical) ops->critical = thermal_zone_device_critical;
@@ -1260,6 +1257,11 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t/* A new thermal zone needs to be updated anyway. */ atomic_set (&tz->need_update,1 ); + result =dev_set_name (&tz->device,"thermal_zone%d" , tz->id); +if (result) { +thermal_zone_destroy_device_groups (tz); + goto remove_id; + } result =device_register (&tz->device);if (result) goto release_device;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 146/1146 irqchip/loongson-pch-pic: Fix translate callback for DT path
In reply to Greg Kroah-HartmanFrom: Jianmin Lv <[email protected]>
[ Upstream commit c7c00138015975c8f0e268564249cc47d8de632c ]
In DT path of translate callback, if fwspec->param_count==1 and of_node is non-null, fwspec->param[1] will be accessed, which is introduced from previous commit bcdd75c596c8 (irqchip/loongson-pch-pic: Add ACPI init support).
Before the patch, for non-null of_node, translate callback (use irq_domain_translate_twocell()) will return -EINVAL if fwspec->param_count < 2, so the check in the patch is added.
--- drivers/irqchip/irq-loongson-pch-pic.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/irqchip/irq-loongson-pch-pic.c +3 -0
@@ -159,6 +159,9 @@ static int pch_pic_domain_translate(struct irq_domain *d,return -EINVAL ;if (of_node) { +if (fwspec->param_count <2 ) +return -EINVAL ; + *hwirq = fwspec->param[0 ] + priv->ht_vec_base; *type = fwspec->param[1 ] &IRQ_TYPE_SENSE_MASK ; }else {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 147/1146 irqchip: gic-pm: Use pm_runtime_resume_and_get() in gic_probe()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
[ Upstream commit f9ee20c85b3a3ba0afd3672630ec4f93d339f015 ]
gic_probe() calls pm_runtime_get_sync() and added fail path as rpm_put to put usage_counter. However, pm_runtime_get_sync() will increment usage_counter even it failed. Fix it by replacing it with pm_runtime_resume_and_get() to keep usage counter balanced.
--- drivers/irqchip/irq-gic-pm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic-pm.c +1 -1
@@ -102,7 +102,7 @@ static int gic_probe(struct platform_device *pdev)pm_runtime_enable (dev); - ret =pm_runtime_get_sync (dev); + ret =pm_runtime_resume_and_get (dev);if (ret <0 ) goto rpm_disable;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 148/1146 irqchip/wpcm450: Fix memory leak in wpcm450_aic_of_init()
In reply to Greg Kroah-HartmanFrom: Wei Yongjun <[email protected]>
[ Upstream commit 4208d4faf36573a507b5e5de17abe342e9276759 ]
If of_iomap() failed, 'aic' should be freed before return. Otherwise there is a memory leak.
--- drivers/irqchip/irq-wpcm450-aic.c | 1 + 1 file changed, 1 insertion(+)
drivers/irqchip/irq-wpcm450-aic.c +1 -0
@@ -146,6 +146,7 @@ static int __init wpcm450_aic_of_init(struct device_node *node, aic->regs =of_iomap (node,0 );if (!aic->regs) {pr_err ("Failed to map WPCM450 AIC registers\n" ); +kfree (aic);return -ENOMEM ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 149/1146 irqchip/loongson-liointc: Fix improper error handling in liointc_init()
In reply to Greg Kroah-HartmanFrom: Liu Peibao <[email protected]>
[ Upstream commit 4a60a3cdcf1875c965095eb9e22c3d12bbc5a53d ]
For cores less than 4, eg, loongson2k1000 with 2 cores, the of_property_match_string() may return with an error value, which causes that liointc could not work. At least isr0 is what should be checked like previous commit b2c4c3969fd7 ("irqchip/loongson-liointc: irqchip add 2.0 version") did.
--- drivers/irqchip/irq-loongson-liointc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/irqchip/irq-loongson-liointc.c +4 -1
@@ -207,10 +207,13 @@ static int liointc_init(phys_addr_t addr, unsigned long size, int revision, "reg-names", core_reg_names[i]);if (index <0 ) - goto out_iounmap; +continue ; priv->core_isr[i] =of_iomap (node, index); } + +if (!priv->core_isr[0 ]) + goto out_iounmap; }/* Setup IRQ domain */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 150/1146 EDAC/i10nm: fix refcount leak in pci_get_dev_wrapper()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 9c8921555907f4d723f01ed2d859b66f2d14f08e ]
As the comment of pci_get_domain_bus_and_slot() says, it returns a PCI device with refcount incremented, so it doesn't need to call an extra pci_dev_get() in pci_get_dev_wrapper(), and the PCI device needs to be put in the error path.
--- drivers/edac/i10nm_base.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/edac/i10nm_base.c +1 -2
@@ -304,11 +304,10 @@ static struct pci_dev *pci_get_dev_wrapper(int dom, unsigned int bus,if (unlikely (pci_enable_device (pdev) <0 )) {edac_dbg (2 ,"Failed to enable device %02x:%02x.%x\n" , bus, dev, fun); +pci_dev_put (pdev);return NULL ; } -pci_dev_get (pdev); -return pdev; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 151/1146 NFSD: Finish converting the NFSv2 GETACL result encoder
In reply to Greg Kroah-HartmanFrom: Chuck Lever <[email protected]>
[ Upstream commit ea5021e911d3479346a75ac9b7d9dcd751b0fb99 ]
The xdr_stream conversion inadvertently left some code that set the page_len of the send buffer. The XDR stream encoders should handle this automatically now.
This oversight adds garbage past the end of the Reply message. Clients typically ignore the garbage, but NFSD does not need to send it, as it leaks stale memory contents onto the wire.
--- fs/nfsd/nfs2acl.c | 10 ---------- 1 file changed, 10 deletions(-)
fs/nfsd/nfs2acl.c +0 -10
@@ -246,7 +246,6 @@ nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr)struct nfsd3_getaclres *resp = rqstp->rq_resp;struct dentry *dentry = resp->fh.fh_dentry;struct inode *inode; -int w;if (!svcxdr_encode_stat (xdr, resp->status))return false;
@@ -260,15 +259,6 @@ nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr)if (xdr_stream_encode_u32 (xdr, resp->mask) <0 )return false; - rqstp->rq_res.page_len = w =nfsacl_size ( - (resp->mask &NFS_ACL ) ? resp->acl_access :NULL , - (resp->mask &NFS_DFACL ) ? resp->acl_default :NULL ); -while (w >0 ) { -if (!*(rqstp->rq_next_page++)) -return true; - w -=PAGE_SIZE ; - } -if (!nfs_stream_encode_acl (xdr, inode, resp->acl_access, resp->mask &NFS_ACL ,0 ))return false;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 152/1146 NFSD: Finish converting the NFSv3 GETACL result encoder
In reply to Greg Kroah-HartmanFrom: Chuck Lever <[email protected]>
[ Upstream commit 841fd0a3cb490eae5dfd262eccb8c8b11d57f8b8 ]
For some reason, the NFSv2 GETACL result encoder was fully converted to use the new nfs_stream_encode_acl(), but the NFSv3 equivalent was not similarly converted.
--- fs/nfsd/nfs3acl.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-)
fs/nfsd/nfs3acl.c +6 -24
@@ -171,11 +171,7 @@ nfs3svc_encode_getaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr) {struct nfsd3_getaclres *resp = rqstp->rq_resp;struct dentry *dentry = resp->fh.fh_dentry; -struct kvec *head = rqstp->rq_res.head;struct inode *inode; -unsigned int base; -int n; -int w;if (!svcxdr_encode_nfsstat3 (xdr, resp->status))return false;
@@ -187,26 +183,12 @@ nfs3svc_encode_getaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr)if (xdr_stream_encode_u32 (xdr, resp->mask) <0 )return false; - base = (char *)xdr->p - (char *)head->iov_base; - - rqstp->rq_res.page_len = w =nfsacl_size ( - (resp->mask &NFS_ACL ) ? resp->acl_access :NULL , - (resp->mask &NFS_DFACL ) ? resp->acl_default :NULL ); -while (w >0 ) { -if (!*(rqstp->rq_next_page++)) -return false; - w -=PAGE_SIZE ; - } - - n =nfsacl_encode (&rqstp->rq_res, base, inode, - resp->acl_access, - resp->mask &NFS_ACL ,0 ); -if (n >0 ) - n =nfsacl_encode (&rqstp->rq_res, base + n, inode, - resp->acl_default, - resp->mask &NFS_DFACL , -NFS_ACL_DEFAULT ); -if (n <=0 ) +if (!nfs_stream_encode_acl (xdr, inode, resp->acl_access, + resp->mask &NFS_ACL ,0 )) +return false; +if (!nfs_stream_encode_acl (xdr, inode, resp->acl_default, + resp->mask &NFS_DFACL , +NFS_ACL_DEFAULT ))return false;break ;default :
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 153/1146 nfsd: dont call nfsd_file_put from client states seqfile display
In reply to Greg Kroah-HartmanFrom: Jeff Layton <[email protected]>
[ Upstream commit e0aa651068bfd520afcd357af8ecd2de005fc83d ]
We had a report of this:
BUG: sleeping function called from invalid context at fs/nfsd/filecache.c:440
...with a stack trace showing nfsd_file_put being called from nfs4_show_open. This code has always tried to call fput while holding a spinlock, but we recently changed this to use the filecache, and that started triggering the might_sleep() in nfsd_file_put.
states_start takes and holds the cl_lock while iterating over the client's states, and we can't sleep with that held.
Have the various nfs4_show_* functions instead hold the fi_lock instead of taking a nfsd_file reference.
--- fs/nfsd/nfs4state.c | 51 +++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 18 deletions(-)
fs/nfsd/nfs4state.c +33 -18
@@ -675,15 +675,26 @@ find_any_file(struct nfs4_file *f)return ret; } -static struct nfsd_file *find_deleg_file (struct nfs4_file *f) +static struct nfsd_file *find_any_file_locked (struct nfs4_file *f) { -struct nfsd_file *ret =NULL ; +lockdep_assert_held (&f->fi_lock); + +if (f->fi_fds[O_RDWR ]) +return f->fi_fds[O_RDWR ]; +if (f->fi_fds[O_WRONLY ]) +return f->fi_fds[O_WRONLY ]; +if (f->fi_fds[O_RDONLY ]) +return f->fi_fds[O_RDONLY ]; +return NULL ; +} + +static struct nfsd_file *find_deleg_file_locked (struct nfs4_file *f) +{ +lockdep_assert_held (&f->fi_lock); -spin_lock (&f->fi_lock);if (f->fi_deleg_file) - ret =nfsd_file_get (f->fi_deleg_file); -spin_unlock (&f->fi_lock); -return ret; +return f->fi_deleg_file; +return NULL ; }static atomic_long_t num_delegations;
@@ -2613,9 +2624,11 @@ static int nfs4_show_open(struct seq_file *s, struct nfs4_stid *st) ols =openlockstateid (st); oo = ols->st_stateowner; nf = st->sc_file; - file =find_any_file (nf); + +spin_lock (&nf->fi_lock); + file =find_any_file_locked (nf);if (!file) -return 0 ; + goto out;seq_printf (s,"- " );nfs4_show_stateid (s, &st->sc_stateid);
@@ -2637,8 +2650,8 @@ static int nfs4_show_open(struct seq_file *s, struct nfs4_stid *st)seq_printf (s,", " );nfs4_show_owner (s, oo);seq_printf (s," }\n" ); -nfsd_file_put (file); - +out: +spin_unlock (&nf->fi_lock);return 0 ; }
@@ -2652,9 +2665,10 @@ static int nfs4_show_lock(struct seq_file *s, struct nfs4_stid *st) ols =openlockstateid (st); oo = ols->st_stateowner; nf = st->sc_file; - file =find_any_file (nf); +spin_lock (&nf->fi_lock); + file =find_any_file_locked (nf);if (!file) -return 0 ; + goto out;seq_printf (s,"- " );nfs4_show_stateid (s, &st->sc_stateid);
@@ -2674,8 +2688,8 @@ static int nfs4_show_lock(struct seq_file *s, struct nfs4_stid *st)seq_printf (s,", " );nfs4_show_owner (s, oo);seq_printf (s," }\n" ); -nfsd_file_put (file); - +out: +spin_unlock (&nf->fi_lock);return 0 ; }
@@ -2687,9 +2701,10 @@ static int nfs4_show_deleg(struct seq_file *s, struct nfs4_stid *st) ds =delegstateid (st); nf = st->sc_file; - file =find_deleg_file (nf); +spin_lock (&nf->fi_lock); + file =find_deleg_file_locked (nf);if (!file) -return 0 ; + goto out;seq_printf (s,"- " );nfs4_show_stateid (s, &st->sc_stateid);
@@ -2705,8 +2720,8 @@ static int nfs4_show_deleg(struct seq_file *s, struct nfs4_stid *st)seq_printf (s,", " );nfs4_show_fname (s, file);seq_printf (s," }\n" ); -nfsd_file_put (file); - +out: +spin_unlock (&nf->fi_lock);return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 154/1146 genirq/irqdesc: Dont try to remove non-existing sysfs files
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 9049e1ca41983ab773d7ea244bee86d7835ec9f5 ]
Fault injection tests trigger warnings like this:
kernfs: can not remove 'chip_name', no directory
WARNING: CPU: 0 PID: 253 at fs/kernfs/dir.c:1616 kernfs_remove_by_name_ns+0xce/0xe0 RIP: 0010:kernfs_remove_by_name_ns+0xce/0xe0 Call Trace: <TASK> remove_files.isra.1+0x3f/0xb0 sysfs_remove_group+0x68/0xe0 sysfs_remove_groups+0x41/0x70 __kobject_del+0x45/0xc0 kobject_del+0x29/0x40 free_desc+0x42/0x70 irq_free_descs+0x5e/0x90
The reason is that the interrupt descriptor sysfs handling does not roll back on a failing kobject_add() during allocation. If the descriptor is freed later on, kobject_del() is invoked with a not added kobject resulting in the above warnings.
A proper rollback in case of a kobject_add() failure would be the straight forward solution. But this is not possible due to the way how interrupt descriptor sysfs handling works.
Interrupt descriptors are allocated before sysfs becomes available. So the sysfs files for the early allocated descriptors are added later in the boot process. At this point there can be nothing useful done about a failing kobject_add(). For consistency the interrupt descriptor allocation always treats kobject_add() failures as non-critical and just emits a warning.
To solve this problem, keep track in the interrupt descriptor whether kobject_add() was successful or not and make the invocation of kobject_del() conditional on that.
[ tglx: Massage changelog, comments and use a state bit. ]
--- kernel/irq/internals.h | 2 ++ kernel/irq/irqdesc.c | 15 +++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-)
kernel/irq/internals.h +2 -0
@@ -52,6 +52,7 @@ enum {* IRQS_PENDING - irq is pending and replayed later * IRQS_SUSPENDED - irq is suspended * IRQS_NMI - irq line is used to deliver NMIs +* IRQS_SYSFS - descriptor has been added to sysfs */ enum {IRQS_AUTODETECT =0x00000001 ,
@@ -64,6 +65,7 @@ enum {IRQS_SUSPENDED =0x00000800 ,IRQS_TIMINGS =0x00001000 ,IRQS_NMI =0x00002000 , + IRQS_SYSFS = 0x00004000, };#include "debug.h"
kernel/irq/irqdesc.c +9 -6
@@ -288,22 +288,25 @@ static void irq_sysfs_add(int irq, struct irq_desc *desc)if (irq_kobj_base) {/* * Continue even in case of failure as this is nothing -* crucial. +* crucial and failures in the late irq_sysfs_init() +* cannot be rolled back. */ if (kobject_add (&desc->kobj, irq_kobj_base,"%d" , irq))pr_warn ("Failed to add kobject for irq %d\n" , irq); +else + desc->istate |=IRQS_SYSFS ; } }static void irq_sysfs_del (struct irq_desc *desc) {/* -* If irq_sysfs_init() has not yet been invoked (early boot), then -* irq_kobj_base is NULL and the descriptor was never added. -* kobject_del() complains about a object with no parent, so make -* it conditional. +* Only invoke kobject_del() when kobject_add() was successfully +* invoked for the descriptor. This covers both early boot, where +* sysfs is not initialized yet, and the case of a failed +* kobject_add() invocation. */ -if (irq_kobj_base) +if (desc->istate &IRQS_SYSFS )kobject_del (&desc->kobj); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 155/1146 cpufreq: amd_freq_sensitivity: Add missing pci_dev_put()
In reply to Greg Kroah-HartmanFrom: Xiongfeng Wang <[email protected]>
[ Upstream commit 91fda1f88c0968f1491ab150bb01690525af150a ]
pci_get_device() will increase the reference count for the returned pci_dev. We need to use pci_dev_put() to decrease the reference count after using pci_get_device(). Let's add it.
--- drivers/cpufreq/amd_freq_sensitivity.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/cpufreq/amd_freq_sensitivity.c +2 -0
@@ -125,6 +125,8 @@ static int __init amd_freq_sensitivity_init(void)if (!pcidev) {if (!boot_cpu_has (X86_FEATURE_PROC_FEEDBACK ))return -ENODEV ; + }else { +pci_dev_put (pcidev); }if (rdmsrl_safe (MSR_AMD64_FREQ_SENSITIVITY_ACTUAL , &val))
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 156/1146 libfs: add DEFINE_SIMPLE_ATTRIBUTE_SIGNED for signed value
In reply to Greg Kroah-HartmanFrom: Akinobu Mita <[email protected]>
[ Upstream commit 2e41f274f9aa71cdcc69dc1f26a3f9304a651804 ]
Patch series "fix error when writing negative value to simple attribute files".
The simple attribute files do not accept a negative value since the commit 488dac0c9237 ("libfs: fix error cast of negative value in simple_attr_write()"), but some attribute files want to accept a negative value.
This patch (of 3):
The simple attribute files do not accept a negative value since the commit 488dac0c9237 ("libfs: fix error cast of negative value in simple_attr_write()"), so we have to use a 64-bit value to write a negative value.
This adds DEFINE_SIMPLE_ATTRIBUTE_SIGNED for a signed value.
--- fs/libfs.c | 22 +++++++++++++++++++--- include/linux/fs.h | 12 ++++++++++-- 2 files changed, 29 insertions(+), 5 deletions(-)
fs/libfs.c +19 -3
@@ -995,8 +995,8 @@ ssize_t simple_attr_read(struct file *file, char __user *buf,EXPORT_SYMBOL_GPL (simple_attr_read);/* interpret the buffer as a number to call the set function with */ -ssize_t simple_attr_write (struct file *file,const char __user *buf, -size_t len,loff_t *ppos) +static ssize_t simple_attr_write_xsigned (struct file *file,const char __user *buf, +size_t len,loff_t *ppos,bool is_signed) {struct simple_attr *attr;unsigned long long val;
@@ -1017,7 +1017,10 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf, goto out; attr->set_buf[size] ='\0' ; - ret =kstrtoull (attr->set_buf,0 , &val); +if (is_signed) + ret =kstrtoll (attr->set_buf,0 , &val); +else + ret =kstrtoull (attr->set_buf,0 , &val);if (ret) goto out; ret = attr->set (attr->data, val);
@@ -1027,8 +1030,21 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf,mutex_unlock (&attr->mutex);return ret; } + +ssize_t simple_attr_write (struct file *file,const char __user *buf, +size_t len,loff_t *ppos) +{ +return simple_attr_write_xsigned (file, buf, len, ppos, false); +}EXPORT_SYMBOL_GPL (simple_attr_write); +ssize_t simple_attr_write_signed (struct file *file,const char __user *buf, +size_t len,loff_t *ppos) +{ +return simple_attr_write_xsigned (file, buf, len, ppos, true); +} +EXPORT_SYMBOL_GPL (simple_attr_write_signed); +/** * generic_fh_to_dentry - generic helper for the fh_to_dentry export operation * @sb: filesystem to do the file handle conversion on
include/linux/fs.h +10 -2
@@ -3493,7 +3493,7 @@ void simple_transaction_set(struct file *file, size_t n);* All attributes contain a text representation of a numeric value * that are accessed with the get() and set() functions. */ -#define DEFINE_SIMPLE_ATTRIBUTE (__fops, __get, __set, __fmt) \ +#define DEFINE_SIMPLE_ATTRIBUTE_XSIGNED (__fops, __get, __set, __fmt, __is_signed) \ static int __fops ## _open(struct inode *inode, struct file *file) \ { \ __simple_attr_check_format(__fmt, 0ull); \
@@ -3504,10 +3504,16 @@ static const struct file_operations __fops = { \ .open = __fops ## _open, \ .release = simple_attr_release, \ .read = simple_attr_read, \ - .write = simple_attr_write, \ + .write = (__is_signed) ? simple_attr_write_signed : simple_attr_write, \ .llseek = generic_file_llseek, \ } +#define DEFINE_SIMPLE_ATTRIBUTE (__fops, __get, __set, __fmt) \ + DEFINE_SIMPLE_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, false) + +#define DEFINE_SIMPLE_ATTRIBUTE_SIGNED (__fops, __get, __set, __fmt) \ + DEFINE_SIMPLE_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, true) + static inline __printf(1, 2) void __simple_attr_check_format(const char *fmt, ...) {
@@ -3522,6 +3528,8 @@ ssize_t simple_attr_read(struct file *file, char __user *buf, size_t len, loff_t *ppos);ssize_t simple_attr_write (struct file *file,const char __user *buf,size_t len,loff_t *ppos); +ssize_t simple_attr_write_signed (struct file *file,const char __user *buf, +size_t len,loff_t *ppos);struct ctl_table ;int __init list_bdev_fs_names (char *buf,size_t size);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 157/1146 lib/notifier-error-inject: fix error when writing -errno to debugfs file
In reply to Greg Kroah-HartmanFrom: Akinobu Mita <[email protected]>
[ Upstream commit f883c3edd2c432a2931ec8773c70a570115a50fe ]
The simple attribute files do not accept a negative value since the commit 488dac0c9237 ("libfs: fix error cast of negative value in simple_attr_write()").
This restores the previous behaviour by using newly introduced DEFINE_SIMPLE_ATTRIBUTE_SIGNED instead of DEFINE_SIMPLE_ATTRIBUTE.
--- lib/notifier-error-inject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/notifier-error-inject.c +1 -1
@@ -15,7 +15,7 @@ static int debugfs_errno_get(void *data, u64 *val)return 0 ; } -DEFINE_SIMPLE_ATTRIBUTE (fops_errno, debugfs_errno_get, debugfs_errno_set, +DEFINE_SIMPLE_ATTRIBUTE_SIGNED (fops_errno, debugfs_errno_get, debugfs_errno_set,"%lld\n" ); static struct dentry *debugfs_create_errno(const char *name, umode_t mode,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 158/1146 debugfs: fix error when writing negative value to atomic_t debugfs file
In reply to Greg Kroah-HartmanFrom: Akinobu Mita <[email protected]>
[ Upstream commit d472cf797c4e268613dbce5ec9b95d0bcae19ecb ]
The simple attribute files do not accept a negative value since the commit 488dac0c9237 ("libfs: fix error cast of negative value in simple_attr_write()"), so we have to use a 64-bit value to write a negative value for a debugfs file created by debugfs_create_atomic_t().
This restores the previous behaviour by introducing DEFINE_DEBUGFS_ATTRIBUTE_SIGNED for a signed value.
--- .../fault-injection/fault-injection.rst | 10 +++---- fs/debugfs/file.c | 28 +++++++++++++++---- include/linux/debugfs.h | 19 +++++++++++-- 3 files changed, 43 insertions(+), 14 deletions(-)
Documentation/fault-injection/fault-injection.rst +4 -6
@@ -83,9 +83,7 @@ configuration of fault-injection capabilities. - /sys/kernel/debug/fail*/times: specifies how many times failures may happen at most. A value of -1 - means "no limit". Note, though, that this file only accepts unsigned - values. So, if you want to specify -1, you better use 'printf' instead - of 'echo', e.g.: $ printf %#x -1 > times + means "no limit". - /sys/kernel/debug/fail*/space:
@@ -284,7 +282,7 @@ Application Examples echo Y > /sys/kernel/debug/$FAILTYPE/task-filter echo 10 > /sys/kernel/debug/$FAILTYPE/probability echo 100 > /sys/kernel/debug/$FAILTYPE/interval - printf %#x -1 > /sys/kernel/debug/$FAILTYPE/times + echo -1 > /sys/kernel/debug/$FAILTYPE/times echo 0 > /sys/kernel/debug/$FAILTYPE/space echo 2 > /sys/kernel/debug/$FAILTYPE/verbose echo Y > /sys/kernel/debug/$FAILTYPE/ignore-gfp-wait
@@ -338,7 +336,7 @@ Application Examples echo N > /sys/kernel/debug/$FAILTYPE/task-filter echo 10 > /sys/kernel/debug/$FAILTYPE/probability echo 100 > /sys/kernel/debug/$FAILTYPE/interval - printf %#x -1 > /sys/kernel/debug/$FAILTYPE/times + echo -1 > /sys/kernel/debug/$FAILTYPE/times echo 0 > /sys/kernel/debug/$FAILTYPE/space echo 2 > /sys/kernel/debug/$FAILTYPE/verbose echo Y > /sys/kernel/debug/$FAILTYPE/ignore-gfp-wait
@@ -369,7 +367,7 @@ Application Examples echo N > /sys/kernel/debug/$FAILTYPE/task-filter echo 100 > /sys/kernel/debug/$FAILTYPE/probability echo 0 > /sys/kernel/debug/$FAILTYPE/interval - printf %#x -1 > /sys/kernel/debug/$FAILTYPE/times + echo -1 > /sys/kernel/debug/$FAILTYPE/times echo 0 > /sys/kernel/debug/$FAILTYPE/space echo 1 > /sys/kernel/debug/$FAILTYPE/verbose
fs/debugfs/file.c +22 -6
@@ -378,8 +378,8 @@ ssize_t debugfs_attr_read(struct file *file, char __user *buf, }EXPORT_SYMBOL_GPL (debugfs_attr_read); -ssize_t debugfs_attr_write (struct file *file,const char __user *buf, -size_t len,loff_t *ppos) +static ssize_t debugfs_attr_write_xsigned (struct file *file,const char __user *buf, +size_t len,loff_t *ppos,bool is_signed) {struct dentry *dentry =F_DENTRY (file);ssize_t ret;
@@ -387,12 +387,28 @@ ssize_t debugfs_attr_write(struct file *file, const char __user *buf, ret =debugfs_file_get (dentry);if (unlikely (ret))return ret; - ret =simple_attr_write (file, buf, len, ppos); +if (is_signed) + ret =simple_attr_write_signed (file, buf, len, ppos); +else + ret =simple_attr_write (file, buf, len, ppos);debugfs_file_put (dentry);return ret; } + +ssize_t debugfs_attr_write (struct file *file,const char __user *buf, +size_t len,loff_t *ppos) +{ +return debugfs_attr_write_xsigned (file, buf, len, ppos, false); +}EXPORT_SYMBOL_GPL (debugfs_attr_write); +ssize_t debugfs_attr_write_signed (struct file *file,const char __user *buf, +size_t len,loff_t *ppos) +{ +return debugfs_attr_write_xsigned (file, buf, len, ppos, true); +} +EXPORT_SYMBOL_GPL (debugfs_attr_write_signed); + static struct dentry *debugfs_create_mode_unsafe(const char *name, umode_t mode, struct dentry *parent, void *value, const struct file_operations *fops,
@@ -738,11 +754,11 @@ static int debugfs_atomic_t_get(void *data, u64 *val) *val =atomic_read ((atomic_t *)data);return 0 ; } -DEFINE_DEBUGFS_ATTRIBUTE (fops_atomic_t, debugfs_atomic_t_get, +DEFINE_DEBUGFS_ATTRIBUTE_SIGNED (fops_atomic_t, debugfs_atomic_t_get, debugfs_atomic_t_set,"%lld\n" ); -DEFINE_DEBUGFS_ATTRIBUTE (fops_atomic_t_ro, debugfs_atomic_t_get,NULL , +DEFINE_DEBUGFS_ATTRIBUTE_SIGNED (fops_atomic_t_ro, debugfs_atomic_t_get,NULL ,"%lld\n" ); -DEFINE_DEBUGFS_ATTRIBUTE (fops_atomic_t_wo,NULL , debugfs_atomic_t_set, +DEFINE_DEBUGFS_ATTRIBUTE_SIGNED (fops_atomic_t_wo,NULL , debugfs_atomic_t_set,"%lld\n" );/**
include/linux/debugfs.h +17 -2
@@ -45,7 +45,7 @@ struct debugfs_u32_array {extern struct dentry *arch_debugfs_dir; -#define DEFINE_DEBUGFS_ATTRIBUTE (__fops, __get, __set, __fmt) \ +#define DEFINE_DEBUGFS_ATTRIBUTE_XSIGNED (__fops, __get, __set, __fmt, __is_signed) \ static int __fops ## _open(struct inode *inode, struct file *file) \ { \ __simple_attr_check_format(__fmt, 0ull); \
@@ -56,10 +56,16 @@ static const struct file_operations __fops = { \ .open = __fops ## _open, \ .release = simple_attr_release, \ .read = debugfs_attr_read, \ - .write = debugfs_attr_write, \ + .write = (__is_signed) ? debugfs_attr_write_signed : debugfs_attr_write, \ .llseek = no_llseek, \ } +#define DEFINE_DEBUGFS_ATTRIBUTE (__fops, __get, __set, __fmt) \ + DEFINE_DEBUGFS_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, false) + +#define DEFINE_DEBUGFS_ATTRIBUTE_SIGNED (__fops, __get, __set, __fmt) \ + DEFINE_DEBUGFS_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, true) +typedef struct vfsmount *(*debugfs_automount_t )(struct dentry *,void *);#if defined(CONFIG_DEBUG_FS )
@@ -102,6 +108,8 @@ ssize_t debugfs_attr_read(struct file *file, char __user *buf, size_t len, loff_t *ppos);ssize_t debugfs_attr_write (struct file *file,const char __user *buf,size_t len,loff_t *ppos); +ssize_t debugfs_attr_write_signed (struct file *file,const char __user *buf, +size_t len,loff_t *ppos);struct dentry *debugfs_rename (struct dentry *old_dir,struct dentry *old_dentry,struct dentry *new_dir,const char *new_name);
@@ -254,6 +262,13 @@ static inline ssize_t debugfs_attr_write(struct file *file,return -ENODEV ; } +static inline ssize_t debugfs_attr_write_signed (struct file *file, +const char __user *buf, +size_t len,loff_t *ppos) +{ +return -ENODEV ; +} +static inline struct dentry *debugfs_rename (struct dentry *old_dir,struct dentry *old_dentry,struct dentry *new_dir,char *new_name) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 160/1146 rapidio: fix possible name leaks when rio_add_device() fails
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit f9574cd48679926e2a569e1957a5a1bcc8a719ac ]
Patch series "rapidio: fix three possible memory leaks".
This patchset fixes three name leaks in error handling.
- patch #1 fixes two name leaks while rio_add_device() fails.
- patch #2 fixes a name leak while rio_register_mport() fails.
This patch (of 2):
If rio_add_device() returns error, the name allocated by dev_set_name() need be freed. It should use put_device() to give up the reference in the error path, so that the name can be freed in kobject_cleanup(), and the 'rdev' can be freed in rio_release_dev().
--- drivers/rapidio/devices/rio_mport_cdev.c | 7 +++++-- drivers/rapidio/rio-scan.c | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/rapidio/devices/rio_mport_cdev.c +5 -2
@@ -1804,8 +1804,11 @@ static int rio_mport_add_riodev(struct mport_cdev_priv *priv,rio_init_dbell_res (&rdev->riores[RIO_DOORBELL_RESOURCE ],0 ,0xffff ); err =rio_add_device (rdev); -if (err) - goto cleanup; +if (err) { +put_device (&rdev->dev); +return err; + } +rio_dev_get (rdev);return 0 ;
drivers/rapidio/rio-scan.c +6 -2
@@ -454,8 +454,12 @@ static struct rio_dev *rio_setup_device(struct rio_net *net, 0, 0xffff); ret =rio_add_device (rdev); -if (ret) - goto cleanup; +if (ret) { +if (rswitch) +kfree (rswitch->route_table); +put_device (&rdev->dev); +return NULL ; + }rio_dev_get (rdev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 161/1146 rapidio: rio: fix possible name leak in rio_register_mport()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit e92a216d16bde65d21a3227e0fb2aa0794576525 ]
If device_register() returns error, the name allocated by dev_set_name() need be freed. It should use put_device() to give up the reference in the error path, so that the name can be freed in kobject_cleanup(), and list_del() is called to delete the port from rio_mports.
--- drivers/rapidio/rio.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/rapidio/rio.c +7 -2
@@ -2186,11 +2186,16 @@ int rio_register_mport(struct rio_mport *port)atomic_set (&port->state,RIO_DEVICE_RUNNING ); res =device_register (&port->dev); -if (res) +if (res) {dev_err (&port->dev,"RIO: mport%d registration failed ERR=%d\n" , port->id, res); -else +mutex_lock (&rio_mport_list_lock); +list_del (&port->node); +mutex_unlock (&rio_mport_list_lock); +put_device (&port->dev); + }else {dev_dbg (&port->dev,"RIO: registered mport%d\n" , port->id); + }return res; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 162/1146 clocksource/drivers/sh_cmt: Access registers according to spec
In reply to Greg Kroah-HartmanFrom: Wolfram Sang <[email protected]>
[ Upstream commit 3f44f7156f59cae06e9160eafb5d8b2dfd09e639 ]
Documentation for most CMTs say that it takes two input clocks before changes propagate to the timer. This is especially relevant when the timer is stopped to change further settings.
Implement the delays according to the spec. To avoid unnecessary delays in atomic mode, also check if the to-be-written value actually differs.
CMCNT is a bit special because testing showed that it requires 3 cycles to propagate, which affects all CMTs. Also, the WRFLAG needs to be checked before writing. This fixes "cannot clear CMCNT" messages which occur often on R-Car Gen4 SoCs, but only very rarely on older SoCs for some reason.
--- drivers/clocksource/sh_cmt.c | 88 ++++++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 33 deletions(-)
drivers/clocksource/sh_cmt.c +55 -33
@@ -13,6 +13,7 @@#include <linux/init.h> #include <linux/interrupt.h> #include <linux/io.h> +#include <linux/iopoll.h> #include <linux/ioport.h> #include <linux/irq.h> #include <linux/module.h>
@@ -116,6 +117,7 @@ struct sh_cmt_device {void __iomem *mapbase;struct clk *clk;unsigned long rate; +unsigned int reg_delay;raw_spinlock_t lock;/* Protect the shared start/stop register */
@@ -247,10 +249,17 @@ static inline u32 sh_cmt_read_cmstr(struct sh_cmt_channel *ch)static inline void sh_cmt_write_cmstr (struct sh_cmt_channel *ch,u32 value) { -if (ch->iostart) - ch->cmt->info->write_control (ch->iostart,0 , value); -else - ch->cmt->info->write_control (ch->cmt->mapbase,0 , value); +u32 old_value =sh_cmt_read_cmstr (ch); + +if (value != old_value) { +if (ch->iostart) { + ch->cmt->info->write_control (ch->iostart,0 , value); +udelay (ch->cmt->reg_delay); + }else { + ch->cmt->info->write_control (ch->cmt->mapbase,0 , value); +udelay (ch->cmt->reg_delay); + } + } }static inline u32 sh_cmt_read_cmcsr (struct sh_cmt_channel *ch)
@@ -260,7 +269,12 @@ static inline u32 sh_cmt_read_cmcsr(struct sh_cmt_channel *ch)static inline void sh_cmt_write_cmcsr (struct sh_cmt_channel *ch,u32 value) { - ch->cmt->info->write_control (ch->ioctrl,CMCSR , value); +u32 old_value =sh_cmt_read_cmcsr (ch); + +if (value != old_value) { + ch->cmt->info->write_control (ch->ioctrl,CMCSR , value); +udelay (ch->cmt->reg_delay); + } }static inline u32 sh_cmt_read_cmcnt (struct sh_cmt_channel *ch)
@@ -268,14 +282,33 @@ static inline u32 sh_cmt_read_cmcnt(struct sh_cmt_channel *ch)return ch->cmt->info->read_count (ch->ioctrl,CMCNT ); } -static inline void sh_cmt_write_cmcnt (struct sh_cmt_channel *ch,u32 value) +static inline int sh_cmt_write_cmcnt (struct sh_cmt_channel *ch,u32 value) { +/* Tests showed that we need to wait 3 clocks here */ +unsigned int cmcnt_delay =DIV_ROUND_UP (3 * ch->cmt->reg_delay,2 ); +u32 reg; + +if (ch->cmt->info->model >SH_CMT_16BIT ) { +int ret =read_poll_timeout_atomic (sh_cmt_read_cmcsr, reg, + !(reg &SH_CMT32_CMCSR_WRFLG ), +1 , cmcnt_delay, false, ch); +if (ret <0 ) +return ret; + } + ch->cmt->info->write_count (ch->ioctrl,CMCNT , value); +udelay (cmcnt_delay); +return 0 ; }static inline void sh_cmt_write_cmcor (struct sh_cmt_channel *ch,u32 value) { - ch->cmt->info->write_count (ch->ioctrl,CMCOR , value); +u32 old_value = ch->cmt->info->read_count (ch->ioctrl,CMCOR ); + +if (value != old_value) { + ch->cmt->info->write_count (ch->ioctrl,CMCOR , value); +udelay (ch->cmt->reg_delay); + } }static u32 sh_cmt_get_counter (struct sh_cmt_channel *ch,u32 *has_wrapped)
@@ -319,7 +352,7 @@ static void sh_cmt_start_stop_ch(struct sh_cmt_channel *ch, int start)static int sh_cmt_enable (struct sh_cmt_channel *ch) { -int k, ret; +int ret;dev_pm_syscore_device (&ch->cmt->pdev->dev, true);
@@ -347,26 +380,9 @@ static int sh_cmt_enable(struct sh_cmt_channel *ch) }sh_cmt_write_cmcor (ch,0xffffffff ); -sh_cmt_write_cmcnt (ch,0 ); - -/* -* According to the sh73a0 user's manual, as CMCNT can be operated -* only by the RCLK (Pseudo 32 kHz), there's one restriction on -* modifying CMCNT register; two RCLK cycles are necessary before -* this register is either read or any modification of the value -* it holds is reflected in the LSI's actual operation. -* -* While at it, we're supposed to clear out the CMCNT as of this -* moment, so make sure it's processed properly here. This will -* take RCLKx2 at maximum. -*/ -for (k =0 ; k <100 ; k++) { -if (!sh_cmt_read_cmcnt (ch)) -break ; -udelay (1 ); - } + ret =sh_cmt_write_cmcnt (ch,0 ); -if (sh_cmt_read_cmcnt (ch)) { +if (ret ||sh_cmt_read_cmcnt (ch)) {dev_err (&ch->cmt->pdev->dev,"ch%u: cannot clear CMCNT\n" , ch->index); ret = -ETIMEDOUT ;
@@ -995,8 +1011,8 @@ MODULE_DEVICE_TABLE(of, sh_cmt_of_table);static int sh_cmt_setup (struct sh_cmt_device *cmt,struct platform_device *pdev) { -unsigned int mask; -unsigned int i; +unsigned int mask, i; +unsigned long rate;int ret; cmt->pdev = pdev;
@@ -1032,10 +1048,16 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)if (ret <0 ) goto err_clk_unprepare; -if (cmt->info->width ==16 ) - cmt->rate =clk_get_rate (cmt->clk) /512 ; -else - cmt->rate =clk_get_rate (cmt->clk) /8 ; + rate =clk_get_rate (cmt->clk); +if (!rate) { + ret = -EINVAL ; + goto err_clk_disable; + } + +/* We shall wait 2 input clks after register writes */ +if (cmt->info->model >=SH_CMT_48BIT ) + cmt->reg_delay =DIV_ROUND_UP (2UL *USEC_PER_SEC , rate); + cmt->rate = rate / (cmt->info->width ==16 ?512 :8 );/* Map the memory resource(s). */ ret =sh_cmt_map_memory (cmt);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 163/1146 futex: Resend potentially swallowed owner death notification
In reply to Greg Kroah-HartmanFrom: Alexey Izbyshev <[email protected]>
[ Upstream commit 90d758896787048fa3d4209309d4800f3920e66f ]
Commit ca16d5bee598 ("futex: Prevent robust futex exit race") addressed two cases when tasks waiting on a robust non-PI futex remained blocked despite the futex not being owned anymore:
* if the owner died after writing zero to the futex word, but before waking up a waiter
* if a task waiting on the futex was woken up, but died before updating the futex word (effectively swallowing the notification without acting on it)
In the second case, the task could be woken up either by the previous owner (after the futex word was reset to zero) or by the kernel (after the OWNER_DIED bit was set and the TID part of the futex word was reset to zero) if the previous owner died without the resetting the futex.
Because the referenced commit wakes up a potential waiter only if the whole futex word is zero, the latter subcase remains unaddressed.
Fix this by looking only at the TID part of the futex when deciding whether a wake up is needed.
--- kernel/futex/core.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-)
kernel/futex/core.c +17 -9
@@ -638,6 +638,7 @@ static int handle_futex_death(u32 __user *uaddr, struct task_struct *curr, bool pi, bool pending_op) {u32 uval, nval, mval; +pid_t owner;int err;/* Futex address must be 32bit aligned */
@@ -659,6 +660,10 @@ static int handle_futex_death(u32 __user *uaddr, struct task_struct *curr,* 2. A woken up waiter is killed before it can acquire the * futex in user space. * +* In the second case, the wake up notification could be generated +* by the unlock path in user space after setting the futex value +* to zero or by the kernel after setting the OWNER_DIED bit below. +* * In both cases the TID validation below prevents a wakeup of * potential waiters which can cause these waiters to block * forever.
@@ -667,24 +672,27 @@ static int handle_futex_death(u32 __user *uaddr, struct task_struct *curr,* * 1) task->robust_list->list_op_pending != NULL * @pending_op == true -* 2) User space futex value == 0 +* 2) The owner part of user space futex value == 0 * 3) Regular futex: @pi == false * * If these conditions are met, it is safe to attempt waking up a * potential waiter without touching the user space futex value and -* trying to set the OWNER_DIED bit. The user space futex value is -* uncontended and the rest of the user space mutex state is -* consistent, so a woken waiter will just take over the -* uncontended futex. Setting the OWNER_DIED bit would create -* inconsistent state and malfunction of the user space owner died -* handling. +* trying to set the OWNER_DIED bit. If the futex value is zero, +* the rest of the user space mutex state is consistent, so a woken +* waiter will just take over the uncontended futex. Setting the +* OWNER_DIED bit would create inconsistent state and malfunction +* of the user space owner died handling. Otherwise, the OWNER_DIED +* bit is already set, and the woken waiter is expected to deal with +* this. */ -if (pending_op && !pi && !uval) { + owner = uval &FUTEX_TID_MASK ; + +if (pending_op && !pi && !owner) {futex_wake (uaddr,1 ,1 ,FUTEX_BITSET_MATCH_ANY );return 0 ; } -if ((uval &FUTEX_TID_MASK ) !=task_pid_vnr (curr)) +if (owner !=task_pid_vnr (curr))return 0 ;/*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 164/1146 cpu/hotplug: Make target_store() a nop when target == state
In reply to Greg Kroah-HartmanFrom: Phil Auld <[email protected]>
[ Upstream commit 64ea6e44f85b9b75925ebe1ba0e6e8430cc4e06f ]
Writing the current state back in hotplug/target calls cpu_down() which will set cpu dying even when it isn't and then nothing will ever clear it. A stress test that reads values and writes them back for all cpu device files in sysfs will trigger the BUG() in select_fallback_rq once all cpus are marked as dying.
kernel/cpu.c::target_store()
...
if (st->state < target)
ret = cpu_up(dev->id, target);
else
ret = cpu_down(dev->id, target);cpu_down() -> cpu_set_state()
bool bringup = st->state < target; ... if (cpu_dying(cpu) != !bringup) set_cpu_dying(cpu, !bringup);
Fix this by letting state==target fall through in the target_store() conditional. Also make sure st->target == target in that case.
--- kernel/cpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/cpu.c +3 -1
@@ -2326,8 +2326,10 @@ static ssize_t target_store(struct device *dev, struct device_attribute *attr,if (st->state < target) ret =cpu_up (dev->id, target); -else +else if (st->state > target) ret =cpu_down (dev->id, target); +else if (WARN_ON (st->target != target)) + st->target = target; out:unlock_device_hotplug ();return ret ? ret : count;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 165/1146 cpu/hotplug: Do not bail-out in DYING/STARTING sections
In reply to Greg Kroah-HartmanFrom: Vincent Donnefort <[email protected]>
[ Upstream commit 6f855b39e4602b6b42a8e5cbcfefb8a1b8b5f0be ]
The DYING/STARTING callbacks are not expected to fail. However, as reported by Derek, buggy drivers such as tboot are still free to return errors within those sections, which halts the hot(un)plug and leaves the CPU in an unrecoverable state.
As there is no rollback possible, only log the failures and proceed with the following steps.
This restores the hotplug behaviour prior to commit 453e41085183 ("cpu/hotplug: Add cpuhp_invoke_callback_range()")
--- kernel/cpu.c | 56 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 16 deletions(-)
kernel/cpu.c +40 -16
@@ -663,21 +663,51 @@ static bool cpuhp_next_state(bool bringup,return true; } -static int cpuhp_invoke_callback_range (bool bringup, -unsigned int cpu, -struct cpuhp_cpu_state *st, -enum cpuhp_state target) +static int __cpuhp_invoke_callback_range (bool bringup, +unsigned int cpu, +struct cpuhp_cpu_state *st, +enum cpuhp_state target, +bool nofail) {enum cpuhp_state state; -int err =0 ; +int ret =0 ;while (cpuhp_next_state (bringup, &state, st, target)) { +int err; + err =cpuhp_invoke_callback (cpu, state, bringup,NULL ,NULL ); -if (err) +if (!err) +continue ; + +if (nofail) { +pr_warn ("CPU %u %s state %s (%d) failed (%d)\n" , + cpu, bringup ?"UP" :"DOWN" , +cpuhp_get_step (st->state)->name, + st->state, err); + ret =-1 ; + }else { + ret = err;break ; + } } -return err; +return ret; +} + +static inline int cpuhp_invoke_callback_range (bool bringup, +unsigned int cpu, +struct cpuhp_cpu_state *st, +enum cpuhp_state target) +{ +return __cpuhp_invoke_callback_range (bringup, cpu, st, target, false); +} + +static inline void cpuhp_invoke_callback_range_nofail (bool bringup, +unsigned int cpu, +struct cpuhp_cpu_state *st, +enum cpuhp_state target) +{ +__cpuhp_invoke_callback_range (bringup, cpu, st, target, true); }static inline bool can_rollback_cpu (struct cpuhp_cpu_state *st)
@@ -999,7 +1029,6 @@ static int take_cpu_down(void *_param)struct cpuhp_cpu_state *st =this_cpu_ptr (&cpuhp_state);enum cpuhp_state target =max ((int )st->target,CPUHP_AP_OFFLINE );int err, cpu =smp_processor_id (); -int ret;/* Ensure this CPU doesn't handle any more interrupts. */ err =__cpu_disable ();
@@ -1012,13 +1041,10 @@ static int take_cpu_down(void *_param)*/ WARN_ON (st->state != (CPUHP_TEARDOWN_CPU -1 )); -/* Invoke the former CPU_DYING callbacks */ - ret =cpuhp_invoke_callback_range (false, cpu, st, target); -/* -* DYING must not fail! +* Invoke the former CPU_DYING callbacks. DYING must not fail! */ -WARN_ON_ONCE (ret); +cpuhp_invoke_callback_range_nofail (false, cpu, st, target);/* Give up timekeeping duties */ tick_handover_do_timer ();
@@ -1296,16 +1322,14 @@ void notify_cpu_starting(unsigned int cpu) {struct cpuhp_cpu_state *st =per_cpu_ptr (&cpuhp_state, cpu);enum cpuhp_state target =min ((int )st->target,CPUHP_AP_ONLINE ); -int ret;rcu_cpu_starting (cpu);/* Enables RCU usage on this CPU. */ cpumask_set_cpu (cpu, &cpus_booted_once_mask); - ret =cpuhp_invoke_callback_range (true, cpu, st, target);/* * STARTING must not fail! */ -WARN_ON_ONCE (ret); +cpuhp_invoke_callback_range_nofail (true, cpu, st, target); }/*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 166/1146 clocksource/drivers/timer-ti-dm: Fix warning for omap_timer_match
In reply to Greg Kroah-HartmanFrom: Tony Lindgren <[email protected]>
[ Upstream commit 9688498b1648aa98a3ee45d9f07763c099f6fb12 ]
We can now get a warning for 'omap_timer_match' defined but not used. Let's fix this by dropping of_match_ptr for omap_timer_match.
--- drivers/clocksource/timer-ti-dm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/timer-ti-dm.c +1 -1
@@ -1258,7 +1258,7 @@ static struct platform_driver omap_dm_timer_driver = { .remove = omap_dm_timer_remove, .driver = { .name = "omap_timer", - .of_match_table = of_match_ptr(omap_timer_match), + .of_match_table = omap_timer_match, .pm = &omap_dm_timer_pm_ops, }, };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 167/1146 clocksource/drivers/timer-ti-dm: Fix missing clk_disable_unprepare in dmtimer_systimer_init_clock()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 180d35a7c05d520314a590c99ad8643d0213f28b ]
If clk_get_rate() fails which is called after clk_prepare_enable(), clk_disable_unprepare() need be called in error path to disable the clock in dmtimer_systimer_init_clock().
--- drivers/clocksource/timer-ti-dm-systimer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clocksource/timer-ti-dm-systimer.c +3 -1
@@ -345,8 +345,10 @@ static int __init dmtimer_systimer_init_clock(struct dmtimer_systimer *t,return error; r =clk_get_rate (clock); -if (!r) +if (!r) { +clk_disable_unprepare (clock);return -ENODEV ; + }if (is_ick) t->ick = clock;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 168/1146 ACPICA: Fix use-after-free in acpi_ut_copy_ipackage_to_ipackage()
In reply to Greg Kroah-HartmanFrom: Li Zetao <[email protected]>
[ Upstream commit 470188b09e92d83c5a997f25f0e8fb8cd2bc3469 ]
There is an use-after-free reported by KASAN:
BUG: KASAN: use-after-free in acpi_ut_remove_reference+0x3b/0x82 Read of size 1 at addr ffff888112afc460 by task modprobe/2111 CPU: 0 PID: 2111 Comm: modprobe Not tainted 6.1.0-rc7-dirty Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), Call Trace: <TASK> kasan_report+0xae/0xe0 acpi_ut_remove_reference+0x3b/0x82 acpi_ut_copy_iobject_to_iobject+0x3be/0x3d5 acpi_ds_store_object_to_local+0x15d/0x3a0 acpi_ex_store+0x78d/0x7fd acpi_ex_opcode_1A_1T_1R+0xbe4/0xf9b acpi_ps_parse_aml+0x217/0x8d5 ... </TASK>
The root cause of the problem is that the acpi_operand_object is freed when acpi_ut_walk_package_tree() fails in acpi_ut_copy_ipackage_to_ipackage(), lead to repeated release in acpi_ut_copy_iobject_to_iobject(). The problem was introduced by "8aa5e56eeb61" commit, this commit is to fix memory leak in acpi_ut_copy_iobject_to_iobject(), repeatedly adding remove operation, lead to "acpi_operand_object" used after free.
Fix it by removing acpi_ut_remove_reference() in acpi_ut_copy_ipackage_to_ipackage(). acpi_ut_copy_ipackage_to_ipackage() is called to copy an internal package object into another internal package object, when it fails, the memory of acpi_operand_object should be freed by the caller.
--- drivers/acpi/acpica/utcopy.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/acpi/acpica/utcopy.c +0 -7
@@ -916,13 +916,6 @@ acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj, status =acpi_ut_walk_package_tree (source_obj, dest_obj, acpi_ut_copy_ielement_to_ielement, walk_state); -if (ACPI_FAILURE (status)) { - -/* On failure, delete the destination package object */ - -acpi_ut_remove_reference (dest_obj); - } -return_ACPI_STATUS (status); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 169/1146 uprobes/x86: Allow to probe a NOP instruction with 0x66 prefix
In reply to Greg Kroah-HartmanFrom: Oleg Nesterov <[email protected]>
[ Upstream commit cefa72129e45313655d53a065b8055aaeb01a0c9 ]
Intel ICC -hotpatch inserts 2-byte "0x66 0x90" NOP at the start of each function to reserve extra space for hot-patching, and currently it is not possible to probe these functions because branch_setup_xol_ops() wrongly rejects NOP with REP prefix as it treats them like word-sized branch instructions.
--- arch/x86/kernel/uprobes.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kernel/uprobes.c +3 -1
@@ -722,8 +722,9 @@ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn)switch (opc1) {case 0xeb :/* jmp 8 */ case 0xe9 :/* jmp 32 */ -case 0x90 :/* prefix* + nop; same as jmp with .offs = 0 */ break ; +case 0x90 :/* prefix* + nop; same as jmp with .offs = 0 */ + goto setup;case 0xe8 :/* call relative */ branch_clear_offset (auprobe, insn);
@@ -753,6 +754,7 @@ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn)return -ENOTSUPP ; } +setup: auprobe->branch.opc1 = opc1; auprobe->branch.ilen = insn->length; auprobe->branch.offs = insn->immediate.value;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 170/1146 x86/xen: Fix memory leak in xen_smp_intr_init{_pv}()
In reply to Greg Kroah-HartmanFrom: Xiu Jianfeng <[email protected]>
[ Upstream commit 69143f60868b3939ddc89289b29db593b647295e ]
These local variables @{resched|pmu|callfunc...}_name saves the new string allocated by kasprintf(), and when bind_{v}ipi_to_irqhandler() fails, it goes to the @fail tag, and calls xen_smp_intr_free{_pv}() to free resource, however the new string is not saved, which cause a memory leak issue. fix it.
--- arch/x86/xen/smp.c | 24 ++++++++++++------------ arch/x86/xen/smp_pv.c | 12 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-)
arch/x86/xen/smp.c +12 -12
@@ -32,30 +32,30 @@ static irqreturn_t xen_reschedule_interrupt(int irq, void *dev_id)void xen_smp_intr_free (unsigned int cpu) { +kfree (per_cpu (xen_resched_irq, cpu).name); +per_cpu (xen_resched_irq, cpu).name =NULL ;if (per_cpu (xen_resched_irq, cpu).irq >=0 ) {unbind_from_irqhandler (per_cpu (xen_resched_irq, cpu).irq,NULL );per_cpu (xen_resched_irq, cpu).irq =-1 ; -kfree (per_cpu (xen_resched_irq, cpu).name); -per_cpu (xen_resched_irq, cpu).name =NULL ; } +kfree (per_cpu (xen_callfunc_irq, cpu).name); +per_cpu (xen_callfunc_irq, cpu).name =NULL ;if (per_cpu (xen_callfunc_irq, cpu).irq >=0 ) {unbind_from_irqhandler (per_cpu (xen_callfunc_irq, cpu).irq,NULL );per_cpu (xen_callfunc_irq, cpu).irq =-1 ; -kfree (per_cpu (xen_callfunc_irq, cpu).name); -per_cpu (xen_callfunc_irq, cpu).name =NULL ; } +kfree (per_cpu (xen_debug_irq, cpu).name); +per_cpu (xen_debug_irq, cpu).name =NULL ;if (per_cpu (xen_debug_irq, cpu).irq >=0 ) {unbind_from_irqhandler (per_cpu (xen_debug_irq, cpu).irq,NULL );per_cpu (xen_debug_irq, cpu).irq =-1 ; -kfree (per_cpu (xen_debug_irq, cpu).name); -per_cpu (xen_debug_irq, cpu).name =NULL ; } +kfree (per_cpu (xen_callfuncsingle_irq, cpu).name); +per_cpu (xen_callfuncsingle_irq, cpu).name =NULL ;if (per_cpu (xen_callfuncsingle_irq, cpu).irq >=0 ) {unbind_from_irqhandler (per_cpu (xen_callfuncsingle_irq, cpu).irq,NULL );per_cpu (xen_callfuncsingle_irq, cpu).irq =-1 ; -kfree (per_cpu (xen_callfuncsingle_irq, cpu).name); -per_cpu (xen_callfuncsingle_irq, cpu).name =NULL ; } }
@@ -65,6 +65,7 @@ int xen_smp_intr_init(unsigned int cpu)char *resched_name, *callfunc_name, *debug_name; resched_name =kasprintf (GFP_KERNEL ,"resched%d" , cpu); +per_cpu (xen_resched_irq, cpu).name = resched_name; rc = bind_ipi_to_irqhandler(XEN_RESCHEDULE_VECTOR, cpu, xen_reschedule_interrupt,
@@ -74,9 +75,9 @@ int xen_smp_intr_init(unsigned int cpu)if (rc <0 ) goto fail;per_cpu (xen_resched_irq, cpu).irq = rc; -per_cpu (xen_resched_irq, cpu).name = resched_name; callfunc_name =kasprintf (GFP_KERNEL ,"callfunc%d" , cpu); +per_cpu (xen_callfunc_irq, cpu).name = callfunc_name; rc = bind_ipi_to_irqhandler(XEN_CALL_FUNCTION_VECTOR, cpu, xen_call_function_interrupt,
@@ -86,10 +87,10 @@ int xen_smp_intr_init(unsigned int cpu)if (rc <0 ) goto fail;per_cpu (xen_callfunc_irq, cpu).irq = rc; -per_cpu (xen_callfunc_irq, cpu).name = callfunc_name;if (!xen_fifo_events) { debug_name =kasprintf (GFP_KERNEL ,"debug%d" , cpu); +per_cpu (xen_debug_irq, cpu).name = debug_name; rc = bind_virq_to_irqhandler(VIRQ_DEBUG, cpu, xen_debug_interrupt, IRQF_PERCPU | IRQF_NOBALANCING,
@@ -97,10 +98,10 @@ int xen_smp_intr_init(unsigned int cpu)if (rc <0 ) goto fail;per_cpu (xen_debug_irq, cpu).irq = rc; -per_cpu (xen_debug_irq, cpu).name = debug_name; } callfunc_name =kasprintf (GFP_KERNEL ,"callfuncsingle%d" , cpu); +per_cpu (xen_callfuncsingle_irq, cpu).name = callfunc_name; rc = bind_ipi_to_irqhandler(XEN_CALL_FUNCTION_SINGLE_VECTOR, cpu, xen_call_function_single_interrupt,
@@ -110,7 +111,6 @@ int xen_smp_intr_init(unsigned int cpu)if (rc <0 ) goto fail;per_cpu (xen_callfuncsingle_irq, cpu).irq = rc; -per_cpu (xen_callfuncsingle_irq, cpu).name = callfunc_name;return 0 ;
arch/x86/xen/smp_pv.c +6 -6
@@ -97,18 +97,18 @@ asmlinkage __visible void cpu_bringup_and_idle(void)void xen_smp_intr_free_pv (unsigned int cpu) { +kfree (per_cpu (xen_irq_work, cpu).name); +per_cpu (xen_irq_work, cpu).name =NULL ;if (per_cpu (xen_irq_work, cpu).irq >=0 ) {unbind_from_irqhandler (per_cpu (xen_irq_work, cpu).irq,NULL );per_cpu (xen_irq_work, cpu).irq =-1 ; -kfree (per_cpu (xen_irq_work, cpu).name); -per_cpu (xen_irq_work, cpu).name =NULL ; } +kfree (per_cpu (xen_pmu_irq, cpu).name); +per_cpu (xen_pmu_irq, cpu).name =NULL ;if (per_cpu (xen_pmu_irq, cpu).irq >=0 ) {unbind_from_irqhandler (per_cpu (xen_pmu_irq, cpu).irq,NULL );per_cpu (xen_pmu_irq, cpu).irq =-1 ; -kfree (per_cpu (xen_pmu_irq, cpu).name); -per_cpu (xen_pmu_irq, cpu).name =NULL ; } }
@@ -118,6 +118,7 @@ int xen_smp_intr_init_pv(unsigned int cpu)char *callfunc_name, *pmu_name; callfunc_name =kasprintf (GFP_KERNEL ,"irqwork%d" , cpu); +per_cpu (xen_irq_work, cpu).name = callfunc_name; rc = bind_ipi_to_irqhandler(XEN_IRQ_WORK_VECTOR, cpu, xen_irq_work_interrupt,
@@ -127,10 +128,10 @@ int xen_smp_intr_init_pv(unsigned int cpu)if (rc <0 ) goto fail;per_cpu (xen_irq_work, cpu).irq = rc; -per_cpu (xen_irq_work, cpu).name = callfunc_name;if (is_xen_pmu) { pmu_name =kasprintf (GFP_KERNEL ,"pmu%d" , cpu); +per_cpu (xen_pmu_irq, cpu).name = pmu_name; rc = bind_virq_to_irqhandler(VIRQ_XENPMU, cpu, xen_pmu_irq_handler, IRQF_PERCPU|IRQF_NOBALANCING,
@@ -138,7 +139,6 @@ int xen_smp_intr_init_pv(unsigned int cpu)if (rc <0 ) goto fail;per_cpu (xen_pmu_irq, cpu).irq = rc; -per_cpu (xen_pmu_irq, cpu).name = pmu_name; }return 0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 171/1146 x86/xen: Fix memory leak in xen_init_lock_cpu()
In reply to Greg Kroah-HartmanFrom: Xiu Jianfeng <[email protected]>
[ Upstream commit ca84ce153d887b1dc8b118029976cc9faf2a9b40 ]
In xen_init_lock_cpu(), the @name has allocated new string by kasprintf(), if bind_ipi_to_irqhandler() fails, it should be freed, otherwise may lead to a memory leak issue, fix it.
--- arch/x86/xen/spinlock.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/xen/spinlock.c +3 -3
@@ -75,6 +75,7 @@ void xen_init_lock_cpu(int cpu) cpu, per_cpu(lock_kicker_irq, cpu)); name =kasprintf (GFP_KERNEL ,"spinlock%d" , cpu); +per_cpu (irq_name, cpu) = name; irq = bind_ipi_to_irqhandler(XEN_SPIN_UNLOCK_VECTOR, cpu, dummy_handler,
@@ -85,7 +86,6 @@ void xen_init_lock_cpu(int cpu)if (irq >=0 ) {disable_irq (irq);/* make sure it's never delivered */ per_cpu (lock_kicker_irq, cpu) = irq; -per_cpu (irq_name, cpu) = name; }printk ("cpu %d spinlock event irq %d\n" , cpu, irq);
@@ -98,6 +98,8 @@ void xen_uninit_lock_cpu(int cpu)if (!xen_pvspin)return ; +kfree (per_cpu (irq_name, cpu)); +per_cpu (irq_name, cpu) =NULL ;/* * When booting the kernel with 'mitigations=auto,nosmt', the secondary * CPUs are not activated, and lock_kicker_irq is not initialized.
@@ -108,8 +110,6 @@ void xen_uninit_lock_cpu(int cpu)unbind_from_irqhandler (irq,NULL );per_cpu (lock_kicker_irq, cpu) =-1 ; -kfree (per_cpu (irq_name, cpu)); -per_cpu (irq_name, cpu) =NULL ; }PV_CALLEE_SAVE_REGS_THUNK (xen_vcpu_stolen);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 172/1146 xen/privcmd: Fix a possible warning in privcmd_ioctl_mmap_resource()
In reply to Greg Kroah-HartmanFrom: Harshit Mogalapalli <[email protected]>
[ Upstream commit 8b997b2bb2c53b76a6db6c195930e9ab8e4b0c79 ]
As 'kdata.num' is user-controlled data, if user tries to allocate memory larger than(>=) MAX_ORDER, then kcalloc() will fail, it creates a stack trace and messes up dmesg with a warning.
Call trace:
-> privcmd_ioctl
--> privcmd_ioctl_mmap_resource
Add __GFP_NOWARN in order to avoid too large allocation warning. This is detected by static analysis using smatch.
--- drivers/xen/privcmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/xen/privcmd.c +1 -1
@@ -760,7 +760,7 @@ static long privcmd_ioctl_mmap_resource(struct file *file, goto out; } - pfns =kcalloc (kdata.num,sizeof (*pfns),GFP_KERNEL ); + pfns =kcalloc (kdata.num,sizeof (*pfns),GFP_KERNEL | __GFP_NOWARN);if (!pfns) { rc = -ENOMEM ; goto out;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 173/1146 PM: runtime: Do not call __rpm_callback() from rpm_idle()
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
[ Upstream commit bc80c2e438dcbfcf748452ec0f7ad5b79ff3ad88 ]
Calling __rpm_callback() from rpm_idle() after adding device links support to the former is a clear mistake.
Not only it causes rpm_idle() to carry out unnecessary actions, but it is also against the assumption regarding the stability of PM-runtime status across __rpm_callback() invocations, because rpm_suspend() and rpm_resume() may run in parallel with __rpm_callback() when it is called by rpm_idle() and the device's PM-runtime status can be updated by any of them.
--- drivers/base/power/runtime.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/base/power/runtime.c +11 -1
@@ -484,7 +484,17 @@ static int rpm_idle(struct device *dev, int rpmflags) dev->power.idle_notification = true; - retval =__rpm_callback (callback, dev); +if (dev->power.irq_safe) +spin_unlock (&dev->power.lock); +else +spin_unlock_irq (&dev->power.lock); + + retval =callback (dev); + +if (dev->power.irq_safe) +spin_lock (&dev->power.lock); +else +spin_lock_irq (&dev->power.lock); dev->power.idle_notification = false;wake_up_all (&dev->power.wait_queue);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 174/1146 erofs: check the uniqueness of fsid in shared domain in advance
In reply to Greg Kroah-HartmanFrom: Hou Tao <[email protected]>
[ Upstream commit 27f2a2dcc6261406b509b5022a1e5c23bf622830 ]
When shared domain is enabled, doing mount twice with the same fsid and domain_id will trigger sysfs warning as shown below:
sysfs: cannot create duplicate filename '/fs/erofs/d0,meta.bin'
CPU: 15 PID: 1051 Comm: mount Not tainted 6.1.0-rc6+ #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996) Call Trace: <TASK> dump_stack_lvl+0x38/0x49 dump_stack+0x10/0x12 sysfs_warn_dup.cold+0x17/0x27 sysfs_create_dir_ns+0xb8/0xd0 kobject_add_internal+0xb1/0x240 kobject_init_and_add+0x71/0xa0 erofs_register_sysfs+0x89/0x110 erofs_fc_fill_super+0x98c/0xaf0 vfs_get_super+0x7d/0x100 get_tree_nodev+0x16/0x20 erofs_fc_get_tree+0x20/0x30 vfs_get_tree+0x24/0xb0 path_mount+0x2fa/0xa90 do_mount+0x7c/0xa0 __x64_sys_mount+0x8b/0xe0 do_syscall_64+0x30/0x60 entry_SYSCALL_64_after_hwframe+0x46/0xb0
The reason is erofs_fscache_register_cookie() doesn't guarantee the primary data blob (aka fsid) is unique in the shared domain and erofs_register_sysfs() invoked by the second mount will fail due to the duplicated fsid in the shared domain and report warning.
It would be better to check the uniqueness of fsid before doing erofs_register_sysfs(), so adding a new flags parameter for erofs_fscache_register_cookie() and doing the uniqueness check if EROFS_REG_COOKIE_NEED_NOEXIST is enabled.
After the patch, the error in dmesg for the duplicated mount would be:
erofs: ...: erofs_domain_register_cookie: XX already exists in domain YY
--- fs/erofs/fscache.c | 47 +++++++++++++++++++++++++++++++++------------ fs/erofs/internal.h | 10 ++++++++-- fs/erofs/super.c | 2 +- 3 files changed, 44 insertions(+), 15 deletions(-)
fs/erofs/fscache.c +35 -12
@@ -494,7 +494,8 @@ static int erofs_fscache_register_domain(struct super_block *sb)static struct erofs_fscache *erofs_fscache_acquire_cookie (struct super_block *sb, -char *name,bool need_inode) +char *name, +unsigned int flags) {struct fscache_volume *volume =EROFS_SB (sb)->volume;struct erofs_fscache *ctx;
@@ -516,7 +517,7 @@ struct erofs_fscache *erofs_fscache_acquire_cookie(struct super_block *sb,fscache_use_cookie (cookie, false); ctx->cookie = cookie; -if (need_inode) { +if (flags &EROFS_REG_COOKIE_NEED_INODE ) {struct inode *const inode =new_inode (sb);if (!inode) {
@@ -554,14 +555,15 @@ static void erofs_fscache_relinquish_cookie(struct erofs_fscache *ctx)static struct erofs_fscache *erofs_fscache_domain_init_cookie (struct super_block *sb, -char *name,bool need_inode) +char *name, +unsigned int flags) {int err;struct inode *inode;struct erofs_fscache *ctx;struct erofs_domain *domain =EROFS_SB (sb)->domain; - ctx =erofs_fscache_acquire_cookie (sb, name, need_inode); + ctx =erofs_fscache_acquire_cookie (sb, name, flags);if (IS_ERR (ctx))return ctx;
@@ -589,7 +591,8 @@ struct erofs_fscache *erofs_fscache_domain_init_cookie(struct super_block *sb,static struct erofs_fscache *erofs_domain_register_cookie (struct super_block *sb, -char *name,bool need_inode) +char *name, +unsigned int flags) {struct inode *inode;struct erofs_fscache *ctx;
@@ -602,23 +605,30 @@ struct erofs_fscache *erofs_domain_register_cookie(struct super_block *sb, ctx = inode->i_private;if (!ctx || ctx->domain != domain ||strcmp (ctx->name, name))continue ; -igrab (inode); +if (!(flags &EROFS_REG_COOKIE_NEED_NOEXIST )) { +igrab (inode); + }else { +erofs_err (sb,"%s already exists in domain %s" , name, + domain->domain_id); + ctx =ERR_PTR (-EEXIST ); + }spin_unlock (&psb->s_inode_list_lock);mutex_unlock (&erofs_domain_cookies_lock);return ctx; }spin_unlock (&psb->s_inode_list_lock); - ctx =erofs_fscache_domain_init_cookie (sb, name, need_inode); + ctx =erofs_fscache_domain_init_cookie (sb, name, flags);mutex_unlock (&erofs_domain_cookies_lock);return ctx; }struct erofs_fscache *erofs_fscache_register_cookie (struct super_block *sb, -char *name,bool need_inode) +char *name, +unsigned int flags) {if (EROFS_SB (sb)->domain_id) -return erofs_domain_register_cookie (sb, name, need_inode); -return erofs_fscache_acquire_cookie (sb, name, need_inode); +return erofs_domain_register_cookie (sb, name, flags); +return erofs_fscache_acquire_cookie (sb, name, flags); }void erofs_fscache_unregister_cookie (struct erofs_fscache *ctx)
@@ -647,6 +657,7 @@ int erofs_fscache_register_fs(struct super_block *sb)int ret;struct erofs_sb_info *sbi =EROFS_SB (sb);struct erofs_fscache *fscache; +unsigned int flags;if (sbi->domain_id) ret =erofs_fscache_register_domain (sb);
@@ -655,8 +666,20 @@ int erofs_fscache_register_fs(struct super_block *sb)if (ret)return ret; -/* acquired domain/volume will be relinquished in kill_sb() on error */ - fscache =erofs_fscache_register_cookie (sb, sbi->fsid, true); +/* +* When shared domain is enabled, using NEED_NOEXIST to guarantee +* the primary data blob (aka fsid) is unique in the shared domain. +* +* For non-shared-domain case, fscache_acquire_volume() invoked by +* erofs_fscache_register_volume() has already guaranteed +* the uniqueness of primary data blob. +* +* Acquired domain/volume will be relinquished in kill_sb() on error. +*/ + flags =EROFS_REG_COOKIE_NEED_INODE ; +if (sbi->domain_id) + flags |=EROFS_REG_COOKIE_NEED_NOEXIST ; + fscache =erofs_fscache_register_cookie (sb, sbi->fsid, flags);if (IS_ERR (fscache))return PTR_ERR (fscache);
fs/erofs/internal.h +8 -2
@@ -604,13 +604,18 @@ static inline int z_erofs_load_lzma_config(struct super_block *sb, }#endif /* !CONFIG_EROFS_FS_ZIP */ +/* flags for erofs_fscache_register_cookie() */ +#define EROFS_REG_COOKIE_NEED_INODE 1 +#define EROFS_REG_COOKIE_NEED_NOEXIST 2 +/* fscache.c */ #ifdef CONFIG_EROFS_FS_ONDEMAND int erofs_fscache_register_fs (struct super_block *sb);void erofs_fscache_unregister_fs (struct super_block *sb);struct erofs_fscache *erofs_fscache_register_cookie (struct super_block *sb, -char *name,bool need_inode); +char *name, +unsigned int flags);void erofs_fscache_unregister_cookie (struct erofs_fscache *fscache);extern const struct address_space_operations erofs_fscache_access_aops;
@@ -623,7 +628,8 @@ static inline void erofs_fscache_unregister_fs(struct super_block *sb) {}static inline struct erofs_fscache *erofs_fscache_register_cookie (struct super_block *sb, -char *name,bool need_inode) +char *name, +unsigned int flags) {return ERR_PTR (-EOPNOTSUPP ); }
fs/erofs/super.c +1 -1
@@ -245,7 +245,7 @@ static int erofs_init_device(struct erofs_buf *buf, struct super_block *sb, }if (erofs_is_fscache_mode (sb)) { - fscache =erofs_fscache_register_cookie (sb, dif->path, false); + fscache =erofs_fscache_register_cookie (sb, dif->path,0 );if (IS_ERR (fscache))return PTR_ERR (fscache); dif->fscache = fscache;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 175/1146 erofs: Fix pcluster memleak when its block address is zero
In reply to Greg Kroah-HartmanFrom: Chen Zhongjin <[email protected]>
[ Upstream commit c42c0ffe81176940bd5dead474216b7198d77675 ]
syzkaller reported a memleak:
https://syzkaller.appspot.com/bug?id=62f37ff612f0021641eda5b17f056f1668aa9aed
unreferenced object 0xffff88811009c7f8 (size 136):
...
backtrace:
[<ffffffff821db19b>] z_erofs_do_read_page+0x99b/0x1740
[<ffffffff821dee9e>] z_erofs_readahead+0x24e/0x580
[<ffffffff814bc0d6>] read_pages+0x86/0x3d0
...syzkaller constructed a case: in z_erofs_register_pcluster(), ztailpacking = false and map->m_pa = zero. This makes pcl->obj.index be zero although pcl is not a inline pcluster.
Then following path adds refcount for grp, but the refcount won't be put because pcl is inline.
z_erofs_readahead()
z_erofs_do_read_page() # for another page
z_erofs_collector_begin()
erofs_find_workgroup()
erofs_workgroup_get()
Since it's illegal for the block address of a non-inlined pcluster to be zero, add check here to avoid registering the pcluster which would be leaked.
--- fs/erofs/zdata.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/erofs/zdata.c +2 -1
@@ -488,7 +488,8 @@ static int z_erofs_register_pcluster(struct z_erofs_decompress_frontend *fe)struct erofs_workgroup *grp;int err; -if (!(map->m_flags &EROFS_MAP_ENCODED )) { +if (!(map->m_flags &EROFS_MAP_ENCODED ) || + (!ztailpacking && !(map->m_pa >>PAGE_SHIFT ))) {DBG_BUGON (1 );return -EFSCORRUPTED ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 176/1146 erofs: fix missing unmap if z_erofs_get_extent_compressedlen() fails
In reply to Greg Kroah-HartmanFrom: Gao Xiang <[email protected]>
[ Upstream commit d5d188b8f8b38d3d71dd05993874b4fc9284ce95 ]
Otherwise, meta buffers could be leaked.
--- fs/erofs/zmap.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/erofs/zmap.c +2 -4
@@ -694,7 +694,7 @@ static int z_erofs_do_map_blocks(struct inode *inode, map->m_pa =blknr_to_addr (m.pblk); err =z_erofs_get_extent_compressedlen (&m, initial_lcn);if (err) - goto out; + goto unmap_out; }if (m.headtype ==Z_EROFS_VLE_CLUSTER_TYPE_PLAIN ) {
@@ -718,14 +718,12 @@ static int z_erofs_do_map_blocks(struct inode *inode,if (!err) map->m_flags |=EROFS_MAP_FULL_MAPPED ; } + unmap_out:erofs_unmap_metabuf (&m.map->buf); - -out:erofs_dbg ("%s, m_la %llu m_pa %llu m_llen %llu m_plen %llu m_flags 0%o" , __func__, map->m_la, map->m_pa, map->m_llen, map->m_plen, map->m_flags); -return err; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 177/1146 erofs: validate the extent length for uncompressed pclusters
In reply to Greg Kroah-HartmanFrom: Gao Xiang <[email protected]>
[ Upstream commit c505feba4c0d76084e56ec498ce819f02a7043ae ]
syzkaller reported a KASAN use-after-free:
https://syzkaller.appspot.com/bug?extid=2ae90e873e97f1faf6f2
The referenced fuzzed image actually has two issues:
- m_pa == 0 as a non-inlined pcluster;
- The logical length is longer than its physical length.
The first issue has already been addressed. This patch addresses the second issue by checking the extent length validity.
--- fs/erofs/zmap.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/erofs/zmap.c +5 -0
@@ -698,6 +698,11 @@ static int z_erofs_do_map_blocks(struct inode *inode, }if (m.headtype ==Z_EROFS_VLE_CLUSTER_TYPE_PLAIN ) { +if (map->m_llen > map->m_plen) { +DBG_BUGON (1 ); + err = -EFSCORRUPTED ; + goto unmap_out; + }if (vi->z_advise &Z_EROFS_ADVISE_INTERLACED_PCLUSTER ) map->m_algorithmformat =Z_EROFS_COMPRESSION_INTERLACED ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 178/1146 platform/chrome: cros_ec_typec: zero out stale pointers
In reply to Greg Kroah-HartmanFrom: Victor Ding <[email protected]>
[ Upstream commit 9a8aadcf0b459c1257b9477fd6402e1d5952ae07 ]
cros_typec_get_switch_handles allocates four pointers when obtaining type-c switch handles. These pointers are all freed if failing to obtain any of them; therefore, pointers in port become stale. The stale pointers eventually cause use-after-free or double free in later code paths. Zeroing out all pointer fields after freeing to eliminate these stale pointers.
--- drivers/platform/chrome/cros_ec_typec.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/platform/chrome/cros_ec_typec.c +3 -0
@@ -173,10 +173,13 @@ static int cros_typec_get_switch_handles(struct cros_typec_port *port, role_sw_err:typec_switch_put (port->ori_sw); + port->ori_sw =NULL ; ori_sw_err:typec_retimer_put (port->retimer); + port->retimer =NULL ; retimer_sw_err:typec_mux_put (port->mux); + port->mux =NULL ; mux_err:return -ENODEV ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 179/1146 platform/x86: mxm-wmi: fix memleak in mxm_wmi_call_mx[ds|mx]()
In reply to Greg Kroah-HartmanFrom: Yu Liao <[email protected]>
[ Upstream commit 727cc0147f5066e359aca65cc6cc5e6d64cc15d8 ]
The ACPI buffer memory (out.pointer) returned by wmi_evaluate_method() is not freed after the call, so it leads to memory leak.
The method results in ACPI buffer is not used, so just pass NULL to wmi_evaluate_method() which fixes the memory leak.
--- drivers/platform/x86/mxm-wmi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/platform/x86/mxm-wmi.c +2 -6
@@ -35,13 +35,11 @@ int mxm_wmi_call_mxds(int adapter) .xarg = 1, };struct acpi_buffer input = { (acpi_size )sizeof (args), &args }; -struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER ,NULL };acpi_status status;printk ("calling mux switch %d\n" , adapter); - status =wmi_evaluate_method (MXM_WMMX_GUID ,0x0 , adapter, &input, - &output); + status =wmi_evaluate_method (MXM_WMMX_GUID ,0x0 , adapter, &input,NULL );if (ACPI_FAILURE (status))return status;
@@ -60,13 +58,11 @@ int mxm_wmi_call_mxmx(int adapter) .xarg = 1, };struct acpi_buffer input = { (acpi_size )sizeof (args), &args }; -struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER ,NULL };acpi_status status;printk ("calling mux switch %d\n" , adapter); - status =wmi_evaluate_method (MXM_WMMX_GUID ,0x0 , adapter, &input, - &output); + status =wmi_evaluate_method (MXM_WMMX_GUID ,0x0 , adapter, &input,NULL );if (ACPI_FAILURE (status))return status;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 180/1146 platform/x86: intel_scu_ipc: fix possible name leak in __intel_scu_ipc_register()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 0b3d0cb7c0bed2fd6454f77ed75e7a662c6efd12 ]
In some error paths before device_register(), the names allocated by dev_set_name() are not freed. Move dev_set_name() front to device_register(), so the name can be freed while calling put_device().
--- drivers/platform/x86/intel_scu_ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/intel_scu_ipc.c +1 -1
@@ -583,7 +583,6 @@ __intel_scu_ipc_register(struct device *parent, scu->dev.parent = parent; scu->dev.class = &intel_scu_ipc_class; scu->dev.release = intel_scu_ipc_release; -dev_set_name (&scu->dev,"intel_scu_ipc" );if (!request_mem_region (scu_data->mem.start,resource_size (&scu_data->mem),"intel_scu_ipc" )) {
@@ -612,6 +611,7 @@ __intel_scu_ipc_register(struct device *parent,* After this point intel_scu_ipc_release() takes care of * releasing the SCU IPC resources once refcount drops to zero. */ +dev_set_name (&scu->dev,"intel_scu_ipc" ); err =device_register (&scu->dev);if (err) {put_device (&scu->dev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 181/1146 MIPS: BCM63xx: Add check for NULL for clk in clk_enable
In reply to Greg Kroah-HartmanFrom: Anastasia Belova <[email protected]>
[ Upstream commit ee9ef11bd2a59c2fefaa0959e5efcdf040d7c654 ]
Check clk for NULL before calling clk_enable_unlocked where clk is dereferenced. There is such check in other implementations of clk_enable.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- arch/mips/bcm63xx/clk.c | 2 ++ 1 file changed, 2 insertions(+)
arch/mips/bcm63xx/clk.c +2 -0
@@ -361,6 +361,8 @@ static struct clk clk_periph = {*/ int clk_enable (struct clk *clk) { +if (!clk) +return 0 ;mutex_lock (&clocks_mutex);clk_enable_unlocked (clk);mutex_unlock (&clocks_mutex);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 182/1146 MIPS: OCTEON: warn only once if deprecated link status is being used
In reply to Greg Kroah-HartmanFrom: Ladislav Michl <[email protected]>
[ Upstream commit 4c587a982603d7e7e751b4925809a1512099a690 ]
Avoid flooding kernel log with warnings.
--- arch/mips/cavium-octeon/executive/cvmx-helper-board.c | 2 +- arch/mips/cavium-octeon/executive/cvmx-helper.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/mips/cavium-octeon/executive/cvmx-helper-board.c +1 -1
@@ -211,7 +211,7 @@ union cvmx_helper_link_info __cvmx_helper_board_link_get(int ipd_port) {union cvmx_helper_link_info result; -WARN (!octeon_is_simulation (), +WARN_ONCE (!octeon_is_simulation (),"Using deprecated link status - please update your DT" );/* Unless we fix it later, all links are defaulted to down */
arch/mips/cavium-octeon/executive/cvmx-helper.c +1 -1
@@ -1096,7 +1096,7 @@ union cvmx_helper_link_info cvmx_helper_link_get(int ipd_port)if (index ==0 ) result =__cvmx_helper_rgmii_link_get (ipd_port);else { -WARN (1 ,"Using deprecated link status - please update your DT" ); +WARN_ONCE (1 ,"Using deprecated link status - please update your DT" ); result.s.full_duplex =1 ; result.s.link_up =1 ; result.s.speed =1000 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 183/1146 lockd: set other missing fields when unlocking files
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit 18ebd35b61b4693a0ddc270b6d4f18def232e770 ]
vfs_lock_file() expects the struct file_lock to be fully initialised by the caller. Re-exported NFSv3 has been seen to Oops if the fl_file field is NULL.
--- fs/lockd/svcsubs.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
fs/lockd/svcsubs.c +10 -7
@@ -176,7 +176,7 @@ nlm_delete_file(struct nlm_file *file) } } -static int nlm_unlock_files (struct nlm_file *file,fl_owner_t owner) +static int nlm_unlock_files (struct nlm_file *file,const struct file_lock *fl) {struct file_lock lock;
@@ -184,12 +184,15 @@ static int nlm_unlock_files(struct nlm_file *file, fl_owner_t owner) lock.fl_type =F_UNLCK ; lock.fl_start =0 ; lock.fl_end =OFFSET_MAX ; - lock.fl_owner = owner; -if (file->f_file[O_RDONLY ] && -vfs_lock_file (file->f_file[O_RDONLY ],F_SETLK , &lock,NULL )) + lock.fl_owner = fl->fl_owner; + lock.fl_pid = fl->fl_pid; + lock.fl_flags =FL_POSIX ; + + lock.fl_file = file->f_file[O_RDONLY ]; +if (lock.fl_file &&vfs_lock_file (lock.fl_file,F_SETLK , &lock,NULL )) goto out_err; -if (file->f_file[O_WRONLY ] && -vfs_lock_file (file->f_file[O_WRONLY ],F_SETLK , &lock,NULL )) + lock.fl_file = file->f_file[O_WRONLY ]; +if (lock.fl_file &&vfs_lock_file (lock.fl_file,F_SETLK , &lock,NULL )) goto out_err;return 0 ; out_err:
@@ -226,7 +229,7 @@ nlm_traverse_locks(struct nlm_host *host, struct nlm_file *file,if (match (lockhost, host)) {spin_unlock (&flctx->flc_lock); -if (nlm_unlock_files (file, fl->fl_owner)) +if (nlm_unlock_files (file, fl))return 1 ; goto again; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 184/1146 nfsd: return error if nfs4_setacl fails
In reply to Greg Kroah-HartmanFrom: Jeff Layton <[email protected]>
[ Upstream commit 01d53a88c08951f88f2a42f1f1e6568928e0590e ]
With the addition of POSIX ACLs to struct nfsd_attrs, we no longer return an error if setting the ACL fails. Ensure we return the na_aclerr error on SETATTR if there is one.
--- fs/nfsd/nfs4proc.c | 2 ++ 1 file changed, 2 insertions(+)
fs/nfsd/nfs4proc.c +2 -0
@@ -1133,6 +1133,8 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, 0, (time64_t)0);if (!status) status =nfserrno (attrs.na_labelerr); +if (!status) + status =nfserrno (attrs.na_aclerr); out:nfsd_attrs_free (&attrs);fh_drop_write (&cstate->current_fh);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 185/1146 NFSD: pass range end to vfs_fsync_range() instead of count
In reply to Greg Kroah-HartmanFrom: Brian Foster <[email protected]>
[ Upstream commit 79a1d88a36f77374c77fd41a4386d8c2736b8704 ]
_nfsd_copy_file_range() calls vfs_fsync_range() with an offset and count (bytes written), but the former wants the start and end bytes of the range to sync. Fix it up.
--- fs/nfsd/nfs4proc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/nfsd/nfs4proc.c +3 -2
@@ -1646,6 +1646,7 @@ static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy,u64 src_pos = copy->cp_src_pos;u64 dst_pos = copy->cp_dst_pos;int status; +loff_t end;/* See RFC 7862 p.67: */ if (bytes_total ==0 )
@@ -1665,8 +1666,8 @@ static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy,/* for a non-zero asynchronous copy do a commit of data */ if (nfsd4_copy_is_async (copy) && copy->cp_res.wr_bytes_written >0 ) { since =READ_ONCE (dst->f_wb_err); - status =vfs_fsync_range (dst, copy->cp_dst_pos, - copy->cp_res.wr_bytes_written,0 ); + end = copy->cp_dst_pos + copy->cp_res.wr_bytes_written -1 ; + status =vfs_fsync_range (dst, copy->cp_dst_pos, end,0 );if (!status) status =filemap_check_wb_err (dst->f_mapping, since);if (!status)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 186/1146 fs: sysv: Fix sysv_nblocks() returns wrong value
In reply to Greg Kroah-HartmanFrom: Chen Zhongjin <[email protected]>
[ Upstream commit e0c49bd2b4d3cd1751491eb2d940bce968ac65e9 ]
sysv_nblocks() returns 'blocks' rather than 'res', which only counting the number of triple-indirect blocks and causing sysv_getattr() gets a wrong result.
[AV: this is actually a sysv counterpart of minixfs fix - 0fcd426de9d0 "[PATCH] minix block usage counting fix" in historical tree; mea culpa, should've thought to check fs/sysv back then...]
--- fs/sysv/itree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/sysv/itree.c +1 -1
@@ -438,7 +438,7 @@ static unsigned sysv_nblocks(struct super_block *s, loff_t size) res += blocks; direct =1 ; } -return blocks; +return res; } int sysv_getattr(struct user_namespace *mnt_userns, const struct path *path,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 187/1146 rapidio: fix possible UAF when kfifo_alloc() fails
In reply to Greg Kroah-HartmanFrom: Wang Weiyang <[email protected]>
[ Upstream commit 02d7d89f816951e0862147d751b1150d67aaebdd ]
If kfifo_alloc() fails in mport_cdev_open(), goto err_fifo and just free priv. But priv is still in the chdev->file_list, then list traversal may cause UAF. This fixes the following smatch warning:
drivers/rapidio/devices/rio_mport_cdev.c:1930 mport_cdev_open() warn: '&priv->list' not removed from list
--- drivers/rapidio/devices/rio_mport_cdev.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/rapidio/devices/rio_mport_cdev.c +3 -4
@@ -1904,10 +1904,6 @@ static int mport_cdev_open(struct inode *inode, struct file *filp) priv->md = chdev; -mutex_lock (&chdev->file_mutex); -list_add_tail (&priv->list, &chdev->file_list); -mutex_unlock (&chdev->file_mutex); -INIT_LIST_HEAD (&priv->db_filters);INIT_LIST_HEAD (&priv->pw_filters);spin_lock_init (&priv->fifo_lock);
@@ -1926,6 +1922,9 @@ static int mport_cdev_open(struct inode *inode, struct file *filp)spin_lock_init (&priv->req_lock);mutex_init (&priv->dma_lock);#endif +mutex_lock (&chdev->file_mutex); +list_add_tail (&priv->list, &chdev->file_list); +mutex_unlock (&chdev->file_mutex); filp->private_data = priv; goto out;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 188/1146 eventfd: change int to __u64 in eventfd_signal() ifndef CONFIG_EVENTFD
In reply to Greg Kroah-HartmanFrom: Zhang Qilong <[email protected]>
[ Upstream commit fd4e60bf0ef8eb9edcfa12dda39e8b6ee9060492 ]
Commit ee62c6b2dc93 ("eventfd: change int to __u64 in eventfd_signal()") forgot to change int to __u64 in the CONFIG_EVENTFD=n stub function.
--- include/linux/eventfd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/eventfd.h +1 -1
@@ -61,7 +61,7 @@ static inline struct eventfd_ctx *eventfd_ctx_fdget(int fd)return ERR_PTR (-ENOSYS ); } -static inline int eventfd_signal (struct eventfd_ctx *ctx,int n) +static inline int eventfd_signal (struct eventfd_ctx *ctx,__u64 n) {return -ENOSYS ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 189/1146 relay: fix type mismatch when allocating memory in relay_create_buf()
In reply to Greg Kroah-HartmanFrom: Gavrilov Ilia <[email protected]>
[ Upstream commit 4d8586e04602fe42f0a782d2005956f8b6302678 ]
The 'padding' field of the 'rchan_buf' structure is an array of 'size_t' elements, but the memory is allocated for an array of 'size_t *' elements.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- kernel/relay.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/relay.c +2 -2
@@ -148,13 +148,13 @@ static struct rchan_buf *relay_create_buf(struct rchan *chan) {struct rchan_buf *buf; -if (chan->n_subbufs >KMALLOC_MAX_SIZE /sizeof (size_t *)) +if (chan->n_subbufs >KMALLOC_MAX_SIZE /sizeof (size_t ))return NULL ; buf =kzalloc (sizeof (struct rchan_buf ),GFP_KERNEL );if (!buf)return NULL ; - buf->padding =kmalloc_array (chan->n_subbufs,sizeof (size_t *), + buf->padding =kmalloc_array (chan->n_subbufs,sizeof (size_t ),GFP_KERNEL );if (!buf->padding) goto free_buf;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 190/1146 hfs: Fix OOB Write in hfs_asc2mac
In reply to Greg Kroah-HartmanFrom: ZhangPeng <[email protected]>
[ Upstream commit c53ed55cb275344086e32a7080a6b19cb183650b ]
Syzbot reported a OOB Write bug:
loop0: detected capacity change from 0 to 64
==================================================================
BUG: KASAN: slab-out-of-bounds in hfs_asc2mac+0x467/0x9a0 fs/hfs/trans.c:133 Write of size 1 at addr ffff88801848314e by task syz-executor391/3632 Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1b1/0x28e lib/dump_stack.c:106 print_address_description+0x74/0x340 mm/kasan/report.c:284 print_report+0x107/0x1f0 mm/kasan/report.c:395 kasan_report+0xcd/0x100 mm/kasan/report.c:495 hfs_asc2mac+0x467/0x9a0 fs/hfs/trans.c:133 hfs_cat_build_key+0x92/0x170 fs/hfs/catalog.c:28 hfs_lookup+0x1ab/0x2c0 fs/hfs/dir.c:31 lookup_open fs/namei.c:3391 [inline] open_last_lookups fs/namei.c:3481 [inline] path_openat+0x10e6/0x2df0 fs/namei.c:3710 do_filp_open+0x264/0x4f0 fs/namei.c:3740
If in->len is much larger than HFS_NAMELEN(31) which is the maximum length of an HFS filename, a OOB write could occur in hfs_asc2mac(). In that case, when the dst reaches the boundary, the srclen is still greater than 0, which causes a OOB write.
Fix this by adding a check on dstlen in while() before writing to dst address.
--- fs/hfs/trans.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/hfs/trans.c +1 -1
@@ -109,7 +109,7 @@ void hfs_asc2mac(struct super_block *sb, struct hfs_name *out, const struct qstrif (nls_io) {wchar_t ch; -while (srclen >0 ) { +while (srclen >0 && dstlen >0 ) { size = nls_io->char2uni (src, srclen, &ch);if (size <0 ) { ch ='?' ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 191/1146 rapidio: devices: fix missing put_device in mport_cdev_open
In reply to Greg Kroah-HartmanFrom: Cai Xinchen <[email protected]>
[ Upstream commit d5b6e6eba3af11cb2a2791fa36a2524990fcde1a ]
When kfifo_alloc fails, the refcount of chdev->dev is left incremental. We should use put_device(&chdev->dev) to decrease the ref count of chdev->dev to avoid refcount leak.
--- drivers/rapidio/devices/rio_mport_cdev.c | 1 + 1 file changed, 1 insertion(+)
drivers/rapidio/devices/rio_mport_cdev.c +1 -0
@@ -1912,6 +1912,7 @@ static int mport_cdev_open(struct inode *inode, struct file *filp)sizeof (struct rio_event ) *MPORT_EVENT_DEPTH , GFP_KERNEL);if (ret <0 ) { +put_device (&chdev->dev);dev_err (&chdev->dev,DRV_NAME ": kfifo_alloc failed\n" ); ret = -ENOMEM ; goto err_fifo;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 192/1146 ipc: fix memory leak in init_mqueue_fs()
In reply to Greg Kroah-HartmanFrom: Zhengchao Shao <[email protected]>
[ Upstream commit 12b677f2c697d61e5ddbcb6c1650050a39392f54 ]
When setup_mq_sysctls() failed in init_mqueue_fs(), mqueue_inode_cachep is not released. In order to fix this issue, the release path is reordered.
--- ipc/mqueue.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
ipc/mqueue.c +4 -2
@@ -1726,7 +1726,8 @@ static int __init init_mqueue_fs(void)if (!setup_mq_sysctls (&init_ipc_ns)) {pr_warn ("sysctl registration failed\n" ); -return -ENOMEM ; + error = -ENOMEM ; + goto out_kmem; } error =register_filesystem (&mqueue_fs_type);
@@ -1744,8 +1745,9 @@ static int __init init_mqueue_fs(void) out_filesystem:unregister_filesystem (&mqueue_fs_type); out_sysctl: -kmem_cache_destroy (mqueue_inode_cachep);retire_mq_sysctls (&init_ipc_ns); +out_kmem: +kmem_cache_destroy (mqueue_inode_cachep);return error; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 193/1146 platform/mellanox: mlxbf-pmc: Fix event typo
In reply to Greg Kroah-HartmanFrom: James Hurley <[email protected]>
[ Upstream commit b0b698b80c56b0712f0d4346d51bf0363ba03068 ]
Had a duplicate event typo, so just fixed the 1 character typo.
--- drivers/platform/mellanox/mlxbf-pmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/mellanox/mlxbf-pmc.c +1 -1
@@ -358,7 +358,7 @@ static const struct mlxbf_pmc_events mlxbf_pmc_hnfnet_events[] = { { 0x32, "DDN_DIAG_W_INGRESS" }, { 0x33, "DDN_DIAG_C_INGRESS" }, { 0x34, "DDN_DIAG_CORE_SENT" }, - { 0x35, "NDN_DIAG_S_OUT_OF_CRED" }, + { 0x35, "NDN_DIAG_N_OUT_OF_CRED" }, { 0x36, "NDN_DIAG_S_OUT_OF_CRED" }, { 0x37, "NDN_DIAG_E_OUT_OF_CRED" }, { 0x38, "NDN_DIAG_W_OUT_OF_CRED" },
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 194/1146 selftests/bpf: Add missing bpf_iter_vma_offset__destroy call
In reply to Greg Kroah-HartmanFrom: Jiri Olsa <[email protected]>
[ Upstream commit 1d2d941bc140b34587b4c889699fb0f89d29937f ]
Adding missing bpf_iter_vma_offset__destroy call and using in-skeletin link pointer so we don't need extra bpf_link__destroy call.
--- tools/testing/selftests/bpf/prog_tests/bpf_iter.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
tools/testing/selftests/bpf/prog_tests/bpf_iter.c +5 -6
@@ -1498,7 +1498,6 @@ static noinline int trigger_func(int arg)static void test_task_vma_offset_common (struct bpf_iter_attach_opts *opts,bool one_proc) {struct bpf_iter_vma_offset *skel; -struct bpf_link *link;char buf[16 ] = {};int iter_fd, len;int pgsz, shift;
@@ -1513,11 +1512,11 @@ static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, bool ; skel->bss->page_shift = shift; - link =bpf_program__attach_iter (skel->progs.get_vma_offset, opts); -if (!ASSERT_OK_PTR (link,"attach_iter" )) -return ; + skel->links.get_vma_offset =bpf_program__attach_iter (skel->progs.get_vma_offset, opts); +if (!ASSERT_OK_PTR (skel->links.get_vma_offset,"attach_iter" )) + goto exit; - iter_fd =bpf_iter_create (bpf_link__fd (link)); + iter_fd =bpf_iter_create (bpf_link__fd (skel->links.get_vma_offset));if (!ASSERT_GT (iter_fd,0 ,"create_iter" )) goto exit;
@@ -1535,7 +1534,7 @@ static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, boolclose (iter_fd); exit: -bpf_link__destroy (link); +bpf_iter_vma_offset__destroy (skel); }static void test_task_vma_offset (void )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 195/1146 wifi: fix multi-link element subelement iteration
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 1177aaa7fe9373c762cd5bf5f5de8517bac989d5 ]
The subelements obviously start after the common data, including the common multi-link element structure definition itself. This bug was possibly just hidden by the higher bits of the control being set to 0, so the iteration just found one bogus element and most of the code could continue anyway.
--- include/linux/ieee80211.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/ieee80211.h +1 -1
@@ -4594,7 +4594,7 @@ static inline u8 ieee80211_mle_common_size(const u8 *data)return 0 ; } -return common + mle->variable[0 ]; +return sizeof (*mle) + common + mle->variable[0 ]; }/**
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 196/1146 wifi: mac80211: mlme: fix null-ptr deref on failed assoc
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 78a6a43aaf87180ec7425a2a90468e1b4d09a1ec ]
If association to an AP without a link 0 fails, then we crash in tracing because it assumes that either ap_mld_addr or link 0 BSS is valid, since we clear sdata->vif.valid_links and then don't add the ap_mld_addr to the struct.
Since we clear also sdata->vif.cfg.ap_addr, keep a local copy of it and assign it earlier, before clearing valid_links, to fix this.
--- net/mac80211/mlme.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
net/mac80211/mlme.c +6 -2
@@ -5033,6 +5033,7 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,struct cfg80211_rx_assoc_resp resp = { .uapsd_queues =-1 , }; +u8 ap_mld_addr[ETH_ALEN ]__aligned(2) ;unsigned int link_id;sdata_assert_lock (sdata);
@@ -5199,6 +5200,11 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, resp.uapsd_queues |= ieee80211_ac_to_qos_mask[ac]; } +if (sdata->vif.valid_links) { +ether_addr_copy (ap_mld_addr, sdata->vif.cfg.ap_addr); + resp.ap_mld_addr = ap_mld_addr; + } + ieee80211_destroy_assoc_data(sdata, status_code == WLAN_STATUS_SUCCESS ? ASSOC_SUCCESS :
@@ -5208,8 +5214,6 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, resp.len = len; resp.req_ies = ifmgd->assoc_req_ies; resp.req_ies_len = ifmgd->assoc_req_ies_len; -if (sdata->vif.valid_links) - resp.ap_mld_addr = sdata->vif.cfg.ap_addr;cfg80211_rx_assoc_resp (sdata->dev, &resp); notify_driver:drv_mgd_complete_tx (sdata->local, sdata, &info);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 197/1146 wifi: mac80211: check link ID in auth/assoc continuation
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 85176a3fcd9748558cff72d4cdff5465b8732282 ]
Ensure that the link ID matches in auth/assoc continuation, otherwise we need to reset all the data.
--- net/mac80211/ieee80211_i.h | 1 + net/mac80211/mlme.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-)
net/mac80211/ieee80211_i.h +1 -0
@@ -390,6 +390,7 @@ struct ieee80211_mgd_auth_data {bool done, waiting;bool peer_confirmed;bool timeout_started; +int link_id;u8 ap_addr[ETH_ALEN ]__aligned(2) ;
net/mac80211/mlme.c +5 -2
@@ -6644,6 +6644,7 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, req->ap_mld_addr ?: req->bss->bssid, ETH_ALEN); auth_data->bss = req->bss; + auth_data->link_id = req->link_id;if (req->auth_data_len >=4 ) {if (req->auth_type ==NL80211_AUTHTYPE_SAE ) {
@@ -6662,7 +6663,8 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,* removal and re-addition of the STA entry in * ieee80211_prep_connection(). */ - cont_auth = ifmgd->auth_data && req->bss == ifmgd->auth_data->bss; + cont_auth = ifmgd->auth_data && req->bss == ifmgd->auth_data->bss && + ifmgd->auth_data->link_id == req->link_id;if (req->ie && req->ie_len) { memcpy(&auth_data->data[auth_data->data_len],
@@ -6986,7 +6988,8 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,/* keep sta info, bssid if matching */ match =ether_addr_equal (ifmgd->auth_data->ap_addr, - assoc_data->ap_addr); + assoc_data->ap_addr) && + ifmgd->auth_data->link_id == req->link_id;ieee80211_destroy_auth_data (sdata, match); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 198/1146 wifi: mac80211: fix ifdef symbol name
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 9d13aff91ecd3f077b432df35291c945bde585be ]
This should of course be CONFIG_, not CPTCFG_, which is an artifact from working with backports.
--- net/mac80211/tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/tx.c +1 -1
@@ -2973,7 +2973,7 @@ static struct sk_buff *ieee80211_build_hdr(struct ieee80211_sub_if_data *sdata,if (pre_conf_link_id != link_id && link_id !=IEEE80211_LINK_UNSPECIFIED ) { -#ifdef CPTCFG_MAC80211_VERBOSE_DEBUG +#ifdef CONFIG_MAC80211_VERBOSE_DEBUG net_info_ratelimited ("%s: dropped frame to %pM with bad link ID request (%d vs. %d)\n" , sdata->name, hdr.addr1, pre_conf_link_id, link_id);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 199/1146 drm/atomic-helper: Dont allocate new plane state in CRTC check
In reply to Greg Kroah-HartmanFrom: Thomas Zimmermann <[email protected]>
[ Upstream commit dbbf933d365da1a76a540211bee3d57bde520194 ]
In drm_atomic_helper_check_crtc_state(), do not add a new plane state to the global state if it does not exist already. Adding a new plane state will result in overhead for the plane during the atomic-commit step.
For the test in drm_atomic_helper_check_crtc_state() to succeed, it is important that the CRTC has an enabled primary plane after the commit. Simply testing the CRTC state's plane_mask for a primary plane is sufficient.
Note that the helper still only tests for an attached primary plane. Drivers have to ensure that the plane contains valid pixel information.
v5:
* fix commit description (Javier)
v3:
* test for a primary plane in plane_mask (Ville)
v2:
* remove unnecessary test for plane->crtc (Ville)
* inline drm_atomic_get_next_plane_state() (Ville)
* acquire plane lock before accessing plane->state (Ville)
--- drivers/gpu/drm/drm_atomic_helper.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +1 -9
@@ -945,7 +945,6 @@ int drm_atomic_helper_check_crtc_state(struct drm_crtc_state *crtc_state, bool can_disable_primary_planes) {struct drm_device *dev = crtc_state->crtc->dev; -struct drm_atomic_state *state = crtc_state->state;if (!crtc_state->enable)return 0 ;
@@ -956,14 +955,7 @@ int drm_atomic_helper_check_crtc_state(struct drm_crtc_state *crtc_state,struct drm_plane *plane;drm_for_each_plane_mask (plane, dev, crtc_state->plane_mask) { -struct drm_plane_state *plane_state; - -if (plane->type !=DRM_PLANE_TYPE_PRIMARY ) -continue ; - plane_state =drm_atomic_get_plane_state (state, plane); -if (IS_ERR (plane_state)) -return PTR_ERR (plane_state); -if (plane_state->fb && plane_state->crtc) { +if (plane->type ==DRM_PLANE_TYPE_PRIMARY ) { has_primary_plane = true;break ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 200/1146 wifi: ath9k: hif_usb: fix memory leak of urbs in ath9k_hif_usb_dealloc_tx_urbs()
In reply to Greg Kroah-HartmanFrom: Fedor Pchelkin <[email protected]>
[ Upstream commit c2a94de38c74e86f49124ac14f093d6a5c377a90 ]
Syzkaller reports a long-known leak of urbs inath9k_hif_usb_dealloc_tx_urbs().
The cause of the leak is that usb_get_urb() is called but usb_free_urb() (or usb_put_urb()) is not called inside usb_kill_urb() as urb->dev or urb->ep fields have not been initialized and usb_kill_urb() returns immediately.
The patch removes trying to kill urbs located in hif_dev->tx.tx_buf because hif_dev->tx.tx_buf is not supposed to contain urbs which are in pending state (the pending urbs are stored in hif_dev->tx.tx_pending). The tx.tx_lock is acquired so there should not be any changes in the list.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
--- drivers/net/wireless/ath/ath9k/hif_usb.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/net/wireless/ath/ath9k/hif_usb.c +0 -4
@@ -780,14 +780,10 @@ static void ath9k_hif_usb_dealloc_tx_urbs(struct hif_device_usb *hif_dev)spin_lock_irqsave (&hif_dev->tx.tx_lock, flags);list_for_each_entry_safe (tx_buf, tx_buf_tmp, &hif_dev->tx.tx_buf, list) { -usb_get_urb (tx_buf->urb); -spin_unlock_irqrestore (&hif_dev->tx.tx_lock, flags); -usb_kill_urb (tx_buf->urb);list_del (&tx_buf->list);usb_free_urb (tx_buf->urb);kfree (tx_buf->buf);kfree (tx_buf); -spin_lock_irqsave (&hif_dev->tx.tx_lock, flags); }spin_unlock_irqrestore (&hif_dev->tx.tx_lock, flags);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 201/1146 wifi: ath9k: hif_usb: Fix use-after-free in ath9k_hif_usb_reg_in_cb()
In reply to Greg Kroah-HartmanFrom: Fedor Pchelkin <[email protected]>
[ Upstream commit dd95f2239fc846795fc926787c3ae0ca701c9840 ]
It is possible that skb is freed in ath9k_htc_rx_msg(), then usb_submit_urb() fails and we try to free skb again. It causes use-after-free bug. Moreover, if alloc_skb() fails, urb->context becomes NULL but rx_buf is not freed and there can be a memory leak.
The patch removes unnecessary nskb and makes skb processing more clear: it is supposed that ath9k_htc_rx_msg() either frees old skb or passes its managing to another callback function.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
--- drivers/net/wireless/ath/ath9k/hif_usb.c | 28 +++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-)
drivers/net/wireless/ath/ath9k/hif_usb.c +15 -13
@@ -708,14 +708,13 @@ static void ath9k_hif_usb_reg_in_cb(struct urb *urb)struct rx_buf *rx_buf = (struct rx_buf *)urb->context;struct hif_device_usb *hif_dev = rx_buf->hif_dev;struct sk_buff *skb = rx_buf->skb; -struct sk_buff *nskb;int ret;if (!skb)return ;if (!hif_dev) - goto free; + goto free_skb;switch (urb->status) {case 0 :
@@ -724,7 +723,7 @@ static void ath9k_hif_usb_reg_in_cb(struct urb *urb)case -ECONNRESET :case -ENODEV :case -ESHUTDOWN : - goto free; + goto free_skb;default :skb_reset_tail_pointer (skb);skb_trim (skb,0 );
@@ -735,25 +734,27 @@ static void ath9k_hif_usb_reg_in_cb(struct urb *urb)if (likely (urb->actual_length !=0 )) {skb_put (skb, urb->actual_length); -/* Process the command first */ +/* +* Process the command first. +* skb is either freed here or passed to be +* managed to another callback function. +*/ ath9k_htc_rx_msg (hif_dev->htc_handle, skb, skb->len,USB_REG_IN_PIPE ); - - nskb =alloc_skb (MAX_REG_IN_BUF_SIZE ,GFP_ATOMIC ); -if (!nskb) { + skb =alloc_skb (MAX_REG_IN_BUF_SIZE ,GFP_ATOMIC ); +if (!skb) {dev_err (&hif_dev->udev->dev,"ath9k_htc: REG_IN memory allocation failure\n" ); - urb->context =NULL ; -return ; + goto free_rx_buf; } - rx_buf->skb = nskb; + rx_buf->skb = skb;usb_fill_int_urb (urb, hif_dev->udev,usb_rcvintpipe (hif_dev->udev,USB_REG_IN_PIPE ), - nskb->data,MAX_REG_IN_BUF_SIZE , + skb->data,MAX_REG_IN_BUF_SIZE , ath9k_hif_usb_reg_in_cb, rx_buf,1 ); }
@@ -762,12 +763,13 @@ static void ath9k_hif_usb_reg_in_cb(struct urb *urb) ret =usb_submit_urb (urb,GFP_ATOMIC );if (ret) {usb_unanchor_urb (urb); - goto free; + goto free_skb; }return ; -free: +free_skb:kfree_skb (skb); +free_rx_buf:kfree (rx_buf); urb->context =NULL ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 202/1146 wifi: rtl8xxxu: Fix reading the vendor of combo chips
In reply to Greg Kroah-HartmanFrom: Bitterblue Smith <[email protected]>
[ Upstream commit 6f103aeb5e985ac08f3a4a049a2c17294f40cff9 ]
The wifi + bluetooth combo chips (RTL8723AU and RTL8723BU) read the chip vendor from the wrong register because the val32 variable gets overwritten. Add one more variable to avoid this.
This had no real effect on RTL8723BU. It may have had an effect on RTL8723AU.
--- .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +8 -8
@@ -1608,18 +1608,18 @@ static int rtl8xxxu_identify_chip(struct rtl8xxxu_priv *priv) {struct device *dev = &priv->udev->dev;struct ieee80211_hw *hw = priv->hw; -u32 val32, bonding; +u32 val32, bonding, sys_cfg;u16 val16; - val32 =rtl8xxxu_read32 (priv,REG_SYS_CFG ); - priv->chip_cut = (val32 &SYS_CFG_CHIP_VERSION_MASK ) >> + sys_cfg =rtl8xxxu_read32 (priv,REG_SYS_CFG ); + priv->chip_cut = (sys_cfg &SYS_CFG_CHIP_VERSION_MASK ) >>SYS_CFG_CHIP_VERSION_SHIFT ; -if (val32 &SYS_CFG_TRP_VAUX_EN ) { +if (sys_cfg &SYS_CFG_TRP_VAUX_EN ) {dev_info (dev,"Unsupported test chip\n" );return -ENOTSUPP ; } -if (val32 &SYS_CFG_BT_FUNC ) { +if (sys_cfg &SYS_CFG_BT_FUNC ) {if (priv->chip_cut >=3 ) {sprintf (priv->chip_name,"8723BU" ); priv->rtl_chip =RTL8723B ;
@@ -1641,7 +1641,7 @@ static int rtl8xxxu_identify_chip(struct rtl8xxxu_priv *priv)if (val32 &MULTI_GPS_FUNC_EN ) priv->has_gps =1 ; priv->is_multi_func =1 ; - }else if (val32 &SYS_CFG_TYPE_ID ) { + }else if (sys_cfg &SYS_CFG_TYPE_ID ) { bonding =rtl8xxxu_read32 (priv,REG_HPON_FSM ); bonding &=HPON_FSM_BONDING_MASK ; if (priv->fops->tx_desc_size ==
@@ -1692,7 +1692,7 @@ static int rtl8xxxu_identify_chip(struct rtl8xxxu_priv *priv)case RTL8188E :case RTL8192E :case RTL8723B : -switch (val32 &SYS_CFG_VENDOR_EXT_MASK ) { +switch (sys_cfg &SYS_CFG_VENDOR_EXT_MASK ) {case SYS_CFG_VENDOR_ID_TSMC :sprintf (priv->chip_vendor,"TSMC" );break ;
@@ -1709,7 +1709,7 @@ static int rtl8xxxu_identify_chip(struct rtl8xxxu_priv *priv) }break ;default : -if (val32 &SYS_CFG_VENDOR_ID ) { +if (sys_cfg &SYS_CFG_VENDOR_ID ) {sprintf (priv->chip_vendor,"UMC" ); priv->vendor_umc =1 ; }else {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 203/1146 wifi: ath11k: fix firmware assert during bandwidth change for peer sta
In reply to Greg Kroah-HartmanFrom: Aditya Kumar Singh <[email protected]>
[ Upstream commit 3ff51d7416ee1ea2d771051a0ffa1ec8be054768 ]
Currently, ath11k sends peer assoc command for each peer to firmware when bandwidth changes. Peer assoc command is a bulky command and if many clients are connected, this could lead to firmware buffer getting overflowed leading to a firmware assert.
However, during bandwidth change, only phymode and bandwidth also can be updated by WMI set peer param command. This makes the overall command light when compared to peer assoc and for multi-client cases, firmware buffer overflow also does not occur.
Remove sending peer assoc command during sta bandwidth change and instead add sending WMI set peer param command for phymode and bandwidth.
Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.5.0.1-01100-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath11k/core.h | 2 + drivers/net/wireless/ath/ath11k/mac.c | 122 +++++++++++++++++-------- 2 files changed, 87 insertions(+), 37 deletions(-)
drivers/net/wireless/ath/ath11k/core.h +2 -0
@@ -505,6 +505,8 @@ struct ath11k_sta {u64 ps_start_jiffies;u64 ps_total_duration;bool peer_current_ps_valid; + +u32 bw_prev; };#define ATH11K_MIN_5G_FREQ 4150
drivers/net/wireless/ath/ath11k/mac.c +85 -37
173 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 204/1146 drm/bridge: adv7533: remove dynamic lane switching from adv7533 bridge
In reply to Greg Kroah-HartmanFrom: Abhinav Kumar <[email protected]>
[ Upstream commit 9a0cdcd6649b76f0b7ceec0e55b0a718321e34d3 ]
adv7533 bridge tries to dynamically switch lanes based on the mode by detaching and attaching the mipi dsi device.
This approach is incorrect because this method of dynamic switch of detaching and attaching the mipi dsi device also results in removing and adding the component which is not necessary.
This approach is also prone to deadlocks. So for example, on the db410c whenever this path is executed with lockdep enabled, this results in a deadlock due to below ordering of locks.
-> #1 (crtc_ww_class_acquire){+.+.}-{0:0}:
lock_acquire+0x6c/0x90
drm_modeset_acquire_init+0xf4/0x150
drmm_mode_config_init+0x220/0x770
msm_drm_bind+0x13c/0x654
try_to_bring_up_aggregate_device+0x164/0x1d0
__component_add+0xa8/0x174
component_add+0x18/0x2c
dsi_dev_attach+0x24/0x30
dsi_host_attach+0x98/0x14c
devm_mipi_dsi_attach+0x38/0xb0
adv7533_attach_dsi+0x8c/0x110
adv7511_probe+0x5a0/0x930
i2c_device_probe+0x30c/0x350
really_probe.part.0+0x9c/0x2b0
__driver_probe_device+0x98/0x144
driver_probe_device+0xac/0x14c
__device_attach_driver+0xbc/0x124
bus_for_each_drv+0x78/0xd0
__device_attach+0xa8/0x1c0
device_initial_probe+0x18/0x24
bus_probe_device+0xa0/0xac
deferred_probe_work_func+0x90/0xd0
process_one_work+0x28c/0x6b0
worker_thread+0x240/0x444
kthread+0x110/0x114
ret_from_fork+0x10/0x20-> #0 (component_mutex){+.+.}-{3:3}:
__lock_acquire+0x1280/0x20ac
lock_acquire.part.0+0xe0/0x230
lock_acquire+0x6c/0x90
__mutex_lock+0x84/0x400
mutex_lock_nested+0x3c/0x70
component_del+0x34/0x170
dsi_dev_detach+0x24/0x30
dsi_host_detach+0x20/0x64
mipi_dsi_detach+0x2c/0x40
adv7533_mode_set+0x64/0x90
adv7511_bridge_mode_set+0x210/0x214
drm_bridge_chain_mode_set+0x5c/0x84
crtc_set_mode+0x18c/0x1dc
drm_atomic_helper_commit_modeset_disables+0x40/0x50
msm_atomic_commit_tail+0x1d0/0x6e0
commit_tail+0xa4/0x180
drm_atomic_helper_commit+0x178/0x3b0
drm_atomic_commit+0xa4/0xe0
drm_client_modeset_commit_atomic+0x228/0x284
drm_client_modeset_commit_locked+0x64/0x1d0
drm_client_modeset_commit+0x34/0x60
drm_fb_helper_lastclose+0x74/0xcc
drm_lastclose+0x3c/0x80
drm_release+0xfc/0x114
__fput+0x70/0x224
____fput+0x14/0x20
task_work_run+0x88/0x1a0
do_exit+0x350/0xa50
do_group_exit+0x38/0xa4
__wake_up_parent+0x0/0x34
invoke_syscall+0x48/0x114
el0_svc_common.constprop.0+0x60/0x11c
do_el0_svc+0x30/0xc0
el0_svc+0x58/0x100
el0t_64_sync_handler+0x1b0/0x1bc
el0t_64_sync+0x18c/0x190Due to above reasons, remove the dynamic lane switching code from adv7533 bridge chip and filter out the modes which would need different number of lanes as compared to the initialization time using the mode_valid callback.
This can be potentially re-introduced by using the pre_enable() callback but this needs to be evaluated first whether such an approach will work so this will be done with a separate change.
changes since RFC:
- Fix commit text and add TODO comment
changes in v2:
- Fix checkpatch formatting errors
--- drivers/gpu/drm/bridge/adv7511/adv7511.h | 3 ++- drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 18 ++++++++++---- drivers/gpu/drm/bridge/adv7511/adv7533.c | 25 ++++++++++---------- 3 files changed, 29 insertions(+), 17 deletions(-)
drivers/gpu/drm/bridge/adv7511/adv7511.h +2 -1
@@ -402,7 +402,8 @@ static inline int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511)void adv7533_dsi_power_on (struct adv7511 *adv);void adv7533_dsi_power_off (struct adv7511 *adv); -void adv7533_mode_set (struct adv7511 *adv,const struct drm_display_mode *mode); +enum drm_mode_status adv7533_mode_valid (struct adv7511 *adv, +const struct drm_display_mode *mode);int adv7533_patch_registers (struct adv7511 *adv);int adv7533_patch_cec_registers (struct adv7511 *adv);int adv7533_attach_dsi (struct adv7511 *adv);
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +14 -4
@@ -697,7 +697,7 @@ adv7511_detect(struct adv7511 *adv7511, struct drm_connector *connector) }static enum drm_mode_status adv7511_mode_valid (struct adv7511 *adv7511, -struct drm_display_mode *mode) +const struct drm_display_mode *mode) {if (mode->clock >165000 )return MODE_CLOCK_HIGH ;
@@ -791,9 +791,6 @@ static void adv7511_mode_set(struct adv7511 *adv7511,regmap_update_bits (adv7511->regmap,0x17 ,0x60 , (vsync_polarity <<6 ) | (hsync_polarity <<5 )); -if (adv7511->type ==ADV7533 || adv7511->type ==ADV7535 ) -adv7533_mode_set (adv7511, adj_mode); -drm_mode_copy (&adv7511->curr_mode, adj_mode);/*
@@ -913,6 +910,18 @@ static void adv7511_bridge_mode_set(struct drm_bridge *bridge,adv7511_mode_set (adv, mode, adj_mode); } +static enum drm_mode_status adv7511_bridge_mode_valid (struct drm_bridge *bridge, +const struct drm_display_info *info, +const struct drm_display_mode *mode) +{ +struct adv7511 *adv =bridge_to_adv7511 (bridge); + +if (adv->type ==ADV7533 || adv->type ==ADV7535 ) +return adv7533_mode_valid (adv, mode); +else +return adv7511_mode_valid (adv, mode); +} +static int adv7511_bridge_attach (struct drm_bridge *bridge,enum drm_bridge_attach_flags flags) {
@@ -960,6 +969,7 @@ static const struct drm_bridge_funcs adv7511_bridge_funcs = { .enable = adv7511_bridge_enable, .disable = adv7511_bridge_disable, .mode_set = adv7511_bridge_mode_set, + .mode_valid = adv7511_bridge_mode_valid, .attach = adv7511_bridge_attach, .detect = adv7511_bridge_detect, .get_edid = adv7511_bridge_get_edid,
drivers/gpu/drm/bridge/adv7511/adv7533.c +13 -12
@@ -100,26 +100,27 @@ void adv7533_dsi_power_off(struct adv7511 *adv)regmap_write (adv->regmap_cec,0x27 ,0x0b ); } -void adv7533_mode_set (struct adv7511 *adv,const struct drm_display_mode *mode) +enum drm_mode_status adv7533_mode_valid (struct adv7511 *adv, +const struct drm_display_mode *mode) { +int lanes;struct mipi_dsi_device *dsi = adv->dsi; -int lanes, ret; - -if (adv->num_dsi_lanes !=4 ) -return ;if (mode->clock >80000 ) lanes =4 ;else lanes =3 ; -if (lanes != dsi->lanes) { -mipi_dsi_detach (dsi); - dsi->lanes = lanes; - ret =mipi_dsi_attach (dsi); -if (ret) -dev_err (&dsi->dev,"failed to change host lanes\n" ); - } +/* +* TODO: add support for dynamic switching of lanes +* by using the bridge pre_enable() op . Till then filter +* out the modes which shall need different number of lanes +* than what was configured in the device tree. +*/ +if (lanes != dsi->lanes) +return MODE_BAD ; + +return MODE_OK ; }int adv7533_patch_registers (struct adv7511 *adv)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 205/1146 libbpf: Fix use-after-free in btf_dump_name_dups
In reply to Greg Kroah-HartmanFrom: Xu Kuohai <[email protected]>
[ Upstream commit 93c660ca40b5d2f7c1b1626e955a8e9fa30e0749 ]
ASAN reports an use-after-free in btf_dump_name_dups:
ERROR: AddressSanitizer: heap-use-after-free on address 0xffff927006db at pc 0xaaaab5dfb618 bp 0xffffdd89b890 sp 0xffffdd89b928 READ of size 2 at 0xffff927006db thread T0
#0 0xaaaab5dfb614 in __interceptor_strcmp.part.0 (test_progs+0x21b614)
#1 0xaaaab635f144 in str_equal_fn tools/lib/bpf/btf_dump.c:127
#2 0xaaaab635e3e0 in hashmap_find_entry tools/lib/bpf/hashmap.c:143
#3 0xaaaab635e72c in hashmap__find tools/lib/bpf/hashmap.c:212
#4 0xaaaab6362258 in btf_dump_name_dups tools/lib/bpf/btf_dump.c:1525
#5 0xaaaab636240c in btf_dump_resolve_name tools/lib/bpf/btf_dump.c:1552
#6 0xaaaab6362598 in btf_dump_type_name tools/lib/bpf/btf_dump.c:1567
#7 0xaaaab6360b48 in btf_dump_emit_struct_def tools/lib/bpf/btf_dump.c:912
#8 0xaaaab6360630 in btf_dump_emit_type tools/lib/bpf/btf_dump.c:798
#9 0xaaaab635f720 in btf_dump__dump_type tools/lib/bpf/btf_dump.c:282
#10 0xaaaab608523c in test_btf_dump_incremental tools/testing/selftests/bpf/prog_tests/btf_dump.c:236
#11 0xaaaab6097530 in test_btf_dump tools/testing/selftests/bpf/prog_tests/btf_dump.c:875
#12 0xaaaab6314ed0 in run_one_test tools/testing/selftests/bpf/test_progs.c:1062
#13 0xaaaab631a0a8 in main tools/testing/selftests/bpf/test_progs.c:1697
#14 0xffff9676d214 in __libc_start_main ../csu/libc-start.c:308
#15 0xaaaab5d65990 (test_progs+0x185990)0xffff927006db is located 11 bytes inside of 16-byte region [0xffff927006d0,0xffff927006e0) freed by thread T0 here:
#0 0xaaaab5e2c7c4 in realloc (test_progs+0x24c7c4)
#1 0xaaaab634f4a0 in libbpf_reallocarray tools/lib/bpf/libbpf_internal.h:191
#2 0xaaaab634f840 in libbpf_add_mem tools/lib/bpf/btf.c:163
#3 0xaaaab636643c in strset_add_str_mem tools/lib/bpf/strset.c:106
#4 0xaaaab6366560 in strset__add_str tools/lib/bpf/strset.c:157
#5 0xaaaab6352d70 in btf__add_str tools/lib/bpf/btf.c:1519
#6 0xaaaab6353e10 in btf__add_field tools/lib/bpf/btf.c:2032
#7 0xaaaab6084fcc in test_btf_dump_incremental tools/testing/selftests/bpf/prog_tests/btf_dump.c:232
#8 0xaaaab6097530 in test_btf_dump tools/testing/selftests/bpf/prog_tests/btf_dump.c:875
#9 0xaaaab6314ed0 in run_one_test tools/testing/selftests/bpf/test_progs.c:1062
#10 0xaaaab631a0a8 in main tools/testing/selftests/bpf/test_progs.c:1697
#11 0xffff9676d214 in __libc_start_main ../csu/libc-start.c:308
#12 0xaaaab5d65990 (test_progs+0x185990)previously allocated by thread T0 here:
#0 0xaaaab5e2c7c4 in realloc (test_progs+0x24c7c4)
#1 0xaaaab634f4a0 in libbpf_reallocarray tools/lib/bpf/libbpf_internal.h:191
#2 0xaaaab634f840 in libbpf_add_mem tools/lib/bpf/btf.c:163
#3 0xaaaab636643c in strset_add_str_mem tools/lib/bpf/strset.c:106
#4 0xaaaab6366560 in strset__add_str tools/lib/bpf/strset.c:157
#5 0xaaaab6352d70 in btf__add_str tools/lib/bpf/btf.c:1519
#6 0xaaaab6353ff0 in btf_add_enum_common tools/lib/bpf/btf.c:2070
#7 0xaaaab6354080 in btf__add_enum tools/lib/bpf/btf.c:2102
#8 0xaaaab6082f50 in test_btf_dump_incremental tools/testing/selftests/bpf/prog_tests/btf_dump.c:162
#9 0xaaaab6097530 in test_btf_dump tools/testing/selftests/bpf/prog_tests/btf_dump.c:875
#10 0xaaaab6314ed0 in run_one_test tools/testing/selftests/bpf/test_progs.c:1062
#11 0xaaaab631a0a8 in main tools/testing/selftests/bpf/test_progs.c:1697
#12 0xffff9676d214 in __libc_start_main ../csu/libc-start.c:308
#13 0xaaaab5d65990 (test_progs+0x185990)The reason is that the key stored in hash table name_map is a string address, and the string memory is allocated by realloc() function, when the memory is resized by realloc() later, the old memory may be freed, so the address stored in name_map references to a freed memory, causing use-after-free.
Fix it by storing duplicated string address in name_map.
--- tools/lib/bpf/btf_dump.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
tools/lib/bpf/btf_dump.c +26 -3
@@ -219,6 +219,17 @@ static int btf_dump_resize(struct btf_dump *d)return 0 ; } +static void btf_dump_free_names (struct hashmap *map) +{ +size_t bkt; +struct hashmap_entry *cur; + +hashmap__for_each_entry (map, cur, bkt) +free ((void *)cur->key); + +hashmap__free (map); +} +void btf_dump__free (struct btf_dump *d) {int i;
@@ -237,8 +248,8 @@ void btf_dump__free(struct btf_dump *d)free (d->cached_names);free (d->emit_queue);free (d->decl_stack); -hashmap__free (d->type_names); -hashmap__free (d->ident_names); +btf_dump_free_names (d->type_names); +btf_dump_free_names (d->ident_names);free (d); }
@@ -1520,11 +1531,23 @@ static void btf_dump_emit_type_cast(struct btf_dump *d, __u32 id,static size_t btf_dump_name_dups (struct btf_dump *d,struct hashmap *name_map,const char *orig_name) { +char *old_name, *new_name;size_t dup_cnt =0 ; +int err; + + new_name =strdup (orig_name); +if (!new_name) +return 1 ;hashmap__find (name_map, orig_name, (void **)&dup_cnt); dup_cnt++; -hashmap__set (name_map, orig_name, (void *)dup_cnt,NULL ,NULL ); + + err =hashmap__set (name_map, new_name, (void *)dup_cnt, + (const void **)&old_name,NULL ); +if (err) +free (new_name); + +free (old_name);return dup_cnt; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 206/1146 libbpf: Fix memory leak in parse_usdt_arg()
In reply to Greg Kroah-HartmanFrom: Xu Kuohai <[email protected]>
[ Upstream commit 0dc9254e03704c75f2ebc9cbef2ce4de83fba603 ]
In the arm64 version of parse_usdt_arg(), when sscanf returns 2, reg_name is allocated but not freed. Fix it.
--- tools/lib/bpf/usdt.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
tools/lib/bpf/usdt.c +4 -7
@@ -1348,25 +1348,23 @@ static int calc_pt_regs_off(const char *reg_name)static int parse_usdt_arg (const char *arg_str,int arg_num,struct usdt_arg_spec *arg) { -char *reg_name =NULL ; +char reg_name[16 ];int arg_sz, len, reg_off;long off; -if (sscanf (arg_str," %d @ \[ %m[a-z0-9], %ld ] %n" , &arg_sz, ®_name, &off, &len) ==3 ) { +if (sscanf (arg_str," %d @ \[ %15[a-z0-9], %ld ] %n" , &arg_sz, reg_name, &off, &len) ==3 ) {/* Memory dereference case, e.g., -4@[sp, 96] */ arg->arg_type =USDT_ARG_REG_DEREF ; arg->val_off = off; reg_off =calc_pt_regs_off (reg_name); -free (reg_name);if (reg_off <0 )return reg_off; arg->reg_off = reg_off; - }else if (sscanf (arg_str," %d @ \[ %m[a-z0-9] ] %n" , &arg_sz, ®_name, &len) ==2 ) { + }else if (sscanf (arg_str," %d @ \[ %15[a-z0-9] ] %n" , &arg_sz, reg_name, &len) ==2 ) {/* Memory dereference case, e.g., -4@[sp] */ arg->arg_type =USDT_ARG_REG_DEREF ; arg->val_off =0 ; reg_off =calc_pt_regs_off (reg_name); -free (reg_name);if (reg_off <0 )return reg_off; arg->reg_off = reg_off;
@@ -1375,12 +1373,11 @@ static int parse_usdt_arg(const char *arg_str, int arg_num, struct usdt_arg_spec arg->arg_type =USDT_ARG_CONST ; arg->val_off = off; arg->reg_off =0 ; - }else if (sscanf (arg_str," %d @ %m[a-z0-9] %n" , &arg_sz, ®_name, &len) ==2 ) { + }else if (sscanf (arg_str," %d @ %15[a-z0-9] %n" , &arg_sz, reg_name, &len) ==2 ) {/* Register read case, e.g., -8@x4 */ arg->arg_type =USDT_ARG_REG ; arg->val_off =0 ; reg_off =calc_pt_regs_off (reg_name); -free (reg_name);if (reg_off <0 )return reg_off; arg->reg_off = reg_off;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 207/1146 selftests/bpf: Fix memory leak caused by not destroying skeleton
In reply to Greg Kroah-HartmanFrom: Xu Kuohai <[email protected]>
[ Upstream commit 6e8280b958c5d7edc514cf347a800b23b7732b2b ]
Some test cases does not destroy skeleton object correctly, causing ASAN to report memory leak warning. Fix it.
--- tools/testing/selftests/bpf/prog_tests/map_kptr.c | 3 ++- tools/testing/selftests/bpf/prog_tests/tracing_struct.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/prog_tests/map_kptr.c +2 -1
@@ -105,7 +105,7 @@ static void test_map_kptr_success(bool test_run)ASSERT_OK (opts.retval,"test_map_kptr_ref2 retval" );if (test_run) -return ; + goto exit; ret =bpf_map__update_elem (skel->maps.array_map, &key,sizeof (key), buf,sizeof (buf),0 );
@@ -132,6 +132,7 @@ static void test_map_kptr_success(bool test_run) ret =bpf_map__delete_elem (skel->maps.lru_hash_map, &key,sizeof (key),0 );ASSERT_OK (ret,"lru_hash_map delete" ); +exit:map_kptr__destroy (skel); }
tools/testing/selftests/bpf/prog_tests/tracing_struct.c +2 -1
@@ -15,7 +15,7 @@ static void test_fentry(void) err =tracing_struct__attach (skel);if (!ASSERT_OK (err,"tracing_struct__attach" )) -return ; + goto destroy_skel;ASSERT_OK (trigger_module_test_read (256 ),"trigger_read" );
@@ -54,6 +54,7 @@ static void test_fentry(void)ASSERT_EQ (skel->bss->t5_ret,1 ,"t5 ret" );tracing_struct__detach (skel); +destroy_skel:tracing_struct__destroy (skel); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 208/1146 selftest/bpf: Fix memory leak in kprobe_multi_test
In reply to Greg Kroah-HartmanFrom: Xu Kuohai <[email protected]>
[ Upstream commit 6d2e21dc4db3933db65293552ecc1ede26febeca ]
The get_syms() function in kprobe_multi_test.c does not free the string memory allocated by sscanf correctly. Fix it.
--- .../bpf/prog_tests/kprobe_multi_test.c | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-)
tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c +14 -12
@@ -325,7 +325,7 @@ static bool symbol_equal(const void *key1, const void *key2, void *ctx __maybe_ustatic int get_syms (char ***symsp,size_t *cntp) {size_t cap =0 , cnt =0 , i; -char *name, **syms =NULL ; +char *name =NULL , **syms =NULL ;struct hashmap *map;char buf[256 ];FILE *f;
@@ -352,6 +352,8 @@ static int get_syms(char ***symsp, size_t *cntp)/* skip modules */ if (strchr (buf,'[' ))continue ; + +free (name);if (sscanf (buf,"%ms$*[^\n]\n" , &name) !=1 )continue ;/*
@@ -371,32 +373,32 @@ static int get_syms(char ***symsp, size_t *cntp)if (!strncmp (name,"__ftrace_invalid_address__" ,sizeof ("__ftrace_invalid_address__" ) -1 ))continue ; + err =hashmap__add (map, name,NULL ); -if (err) { -free (name); -if (err == -EEXIST ) -continue ; +if (err == -EEXIST ) +continue ; +if (err) goto error; - } + err =libbpf_ensure_mem ((void **) &syms, &cap,sizeof (*syms), cnt +1 ); -if (err) { -free (name); +if (err) goto error; - } - syms[cnt] = name; - cnt++; + + syms[cnt++] = name; + name =NULL ; } *symsp = syms; *cntp = cnt; error: +free (name);fclose (f);hashmap__free (map);if (err) {for (i =0 ; i < cnt; i++) -free (syms[cnt]); +free (syms[i]);free (syms); }return err;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 209/1146 selftests/bpf: Fix error failure of case test_xdp_adjust_tail_grow
In reply to Greg Kroah-HartmanFrom: Xu Kuohai <[email protected]>
[ Upstream commit 4abdb1d5b250df4b5b3afd394d5e2fa516064c04 ]
test_xdp_adjust_tail_grow failed with ipv6:
test_xdp_adjust_tail_grow:FAIL:ipv6 unexpected error: -28 (errno 28)
The reason is that this test case tests ipv4 before ipv6, and when ipv4 test finished, topts.data_size_out was set to 54, which is smaller than the ipv6 output data size 114, so ipv6 test fails with NOSPC error.
Fix it by reset topts.data_size_out to sizeof(buf) before testing ipv6.
--- tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c +1 -0
@@ -63,6 +63,7 @@ static void test_xdp_adjust_tail_grow(void) expect_sz =sizeof (pkt_v6) +40 ;/* Test grow with 40 bytes */ topts.data_in = &pkt_v6; topts.data_size_in =sizeof (pkt_v6); + topts.data_size_out =sizeof (buf); err =bpf_prog_test_run_opts (prog_fd, &topts);ASSERT_OK (err,"ipv6" );ASSERT_EQ (topts.retval,XDP_TX ,"ipv6 retval" );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 210/1146 selftest/bpf: Fix error usage of ASSERT_OK in xdp_adjust_tail.c
In reply to Greg Kroah-HartmanFrom: Xu Kuohai <[email protected]>
[ Upstream commit cbc1c998da59687e8bbc4667154a72eead2daf2d ]
xdp_adjust_tail.c calls ASSERT_OK() to check the return value of bpf_prog_test_load(), but the condition is not correct. Fix it.
--- tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c +3 -3
@@ -18,7 +18,7 @@ static void test_xdp_adjust_tail_shrink(void) ); err =bpf_prog_test_load (file,BPF_PROG_TYPE_XDP , &obj, &prog_fd); -if (ASSERT_OK (err,"test_xdp_adjust_tail_shrink" )) +if (!ASSERT_OK (err,"test_xdp_adjust_tail_shrink" ))return ; err =bpf_prog_test_run_opts (prog_fd, &topts);
@@ -53,7 +53,7 @@ static void test_xdp_adjust_tail_grow(void) ); err =bpf_prog_test_load (file,BPF_PROG_TYPE_XDP , &obj, &prog_fd); -if (ASSERT_OK (err,"test_xdp_adjust_tail_grow" )) +if (!ASSERT_OK (err,"test_xdp_adjust_tail_grow" ))return ; err =bpf_prog_test_run_opts (prog_fd, &topts);
@@ -90,7 +90,7 @@ static void test_xdp_adjust_tail_grow2(void) ); err =bpf_prog_test_load (file,BPF_PROG_TYPE_XDP , &obj, &prog_fd); -if (ASSERT_OK (err,"test_xdp_adjust_tail_grow" )) +if (!ASSERT_OK (err,"test_xdp_adjust_tail_grow" ))return ;/* Test case-64 */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 211/1146 libbpf: Use elf_getshdrnum() instead of e_shnum
In reply to Greg Kroah-HartmanFrom: Shung-Hsi Yu <[email protected]>
[ Upstream commit 51deedc9b8680953437dfe359e5268120de10e30 ]
This commit replace e_shnum with the elf_getshdrnum() helper to fix two oss-fuzz-reported heap-buffer overflow in __bpf_object__open. Both reports are incorrectly marked as fixed and while still being reproducible in the latest libbpf.
# clusterfuzz-testcase-minimized-bpf-object-fuzzer-5747922482888704
libbpf: loading object 'fuzz-object' from buffer
libbpf: sec_cnt is 0
libbpf: elf: section(1) .data, size 0, link 538976288, flags 2020202020202020, type=2
libbpf: elf: section(2) .data, size 32, link 538976288, flags 202020202020ff20, type=1
=================================================================
==13==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6020000000c0 at pc 0x0000005a7b46 bp 0x7ffd12214af0 sp 0x7ffd12214ae8
WRITE of size 4 at 0x6020000000c0 thread T0
SCARINESS: 46 (4-byte-write-heap-buffer-overflow-far-from-bounds)
#0 0x5a7b45 in bpf_object__elf_collect /src/libbpf/src/libbpf.c:3414:24
#1 0x5733c0 in bpf_object_open /src/libbpf/src/libbpf.c:7223:16
#2 0x5739fd in bpf_object__open_mem /src/libbpf/src/libbpf.c:7263:20
...The issue lie in libbpf's direct use of e_shnum field in ELF header as the section header count. Where as libelf implemented an extra logic that, when e_shnum == 0 && e_shoff != 0, will use sh_size member of the initial section header as the real section header count (part of ELF spec to accommodate situation where section header counter is larger than SHN_LORESERVE).
The above inconsistency lead to libbpf writing into a zero-entry calloc area. So intead of using e_shnum directly, use the elf_getshdrnum() helper provided by libelf to retrieve the section header counter into sec_cnt.
--- tools/lib/bpf/libbpf.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
tools/lib/bpf/libbpf.c +9 -4
@@ -597,7 +597,7 @@ struct elf_state {size_t shstrndx;/* section index for section name strings */ size_t strtabidx;struct elf_sec_desc *secs; -int sec_cnt; +size_t sec_cnt;int btf_maps_shndx;__u32 btf_maps_sec_btf_id;int text_shndx;
@@ -3312,10 +3312,15 @@ static int bpf_object__elf_collect(struct bpf_object *obj)Elf64_Shdr *sh;/* ELF section indices are 0-based, but sec #0 is special "invalid" -* section. e_shnum does include sec #0, so e_shnum is the necessary -* size of an array to keep all the sections. +* section. Since section count retrieved by elf_getshdrnum() does +* include sec #0, it is already the necessary size of an array to keep +* all the sections. */ - obj->efile.sec_cnt = obj->efile.ehdr->e_shnum; +if (elf_getshdrnum (obj->efile.elf, &obj->efile.sec_cnt)) { +pr_warn ("elf: failed to get the number of sections for %s: %s\n" , + obj->path,elf_errmsg (-1 )); +return -LIBBPF_ERRNO__FORMAT ; + } obj->efile.secs =calloc (obj->efile.sec_cnt,sizeof (*obj->efile.secs));if (!obj->efile.secs)return -ENOMEM ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 212/1146 libbpf: Deal with section with no data gracefully
In reply to Greg Kroah-HartmanFrom: Shung-Hsi Yu <[email protected]>
[ Upstream commit 35a855509e6ee3442477c8ebc6827b5b5d32a7b5 ]
ELF section data pointer returned by libelf may be NULL (if section has SHT_NOBITS), so null check section data pointer before attempting to copy license and kversion section.
--- tools/lib/bpf/libbpf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/lib/bpf/libbpf.c +5 -1
@@ -1408,6 +1408,10 @@ static int bpf_object__check_endianness(struct bpf_object *obj)static int bpf_object__init_license (struct bpf_object *obj,void *data,size_t size) { +if (!data) { +pr_warn ("invalid license section in %s\n" , obj->path); +return -LIBBPF_ERRNO__FORMAT ; + }/* libbpf_strlcpy() only copies first N - 1 bytes, so size + 1 won't * go over allowed ELF data section buffer */
@@ -1421,7 +1425,7 @@ bpf_object__init_kversion(struct bpf_object *obj, void *data, size_t size) {__u32 kver; -if (size !=sizeof (kver)) { +if (!data || size !=sizeof (kver)) {pr_warn ("invalid kver section in %s\n" , obj->path);return -LIBBPF_ERRNO__FORMAT ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 213/1146 libbpf: Fix null-pointer dereference in find_prog_by_sec_insn()
In reply to Greg Kroah-HartmanFrom: Shung-Hsi Yu <[email protected]>
[ Upstream commit d0d382f95a9270dcf803539d6781d6bd67e3f5b2 ]
When there are no program sections, obj->programs is left unallocated, and find_prog_by_sec_insn()'s search lands on &obj->programs[0] == NULL, and will cause null-pointer dereference in the following access to prog->sec_idx.
Guard the search with obj->nr_programs similar to what's being done in __bpf_program__iter() to prevent null-pointer access from happening.
--- tools/lib/bpf/libbpf.c | 3 +++ 1 file changed, 3 insertions(+)
tools/lib/bpf/libbpf.c +3 -0
@@ -4115,6 +4115,9 @@ static struct bpf_program *find_prog_by_sec_insn(const struct bpf_object *obj,int l =0 , r = obj->nr_programs -1 , m;struct bpf_program *prog; +if (!obj->nr_programs) +return NULL ; +while (l < r) { m = l + (r - l +1 ) /2 ; prog = &obj->programs[m];
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 214/1146 drm: lcdif: Switch to limited range for RGB to YUV conversion
In reply to Greg Kroah-HartmanFrom: Laurent Pinchart <[email protected]>
[ Upstream commit ec39dee8b25229a646271815cc86a8fc865525cf ]
Up to and including v1.3, HDMI supported limited quantization range only for YCbCr. HDMI v1.4 introduced selectable quantization ranges, but this feature isn't supported in the dw-hdmi driver that is used in conjunction with the LCDIF in the i.MX8MP. The HDMI YCbCr output is thus always advertised in the AVI infoframe as limited range.
The LCDIF driver, on the other hand, configures the CSC to produce full range YCbCr. This mismatch results in loss of details and incorrect colours. Fix it by switching to limited range YCbCr.
The coefficients are copied from drivers/media/platforms/nxp/imx-pxp.c for coherency, as the hardware is most likely identical.
--- drivers/gpu/drm/mxsfb/lcdif_kms.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/gpu/drm/mxsfb/lcdif_kms.c +12 -6
@@ -52,16 +52,22 @@ static void lcdif_set_formats(struct lcdif_drm_private *lcdif,writel (DISP_PARA_LINE_PATTERN_UYVY_H , lcdif->base +LCDC_V8_DISP_PARA ); -/* CSC: BT.601 Full Range RGB to YCbCr coefficients. */ -writel (CSC0_COEF0_A2 (0x096 ) |CSC0_COEF0_A1 (0x04c ), +/* +* CSC: BT.601 Limited Range RGB to YCbCr coefficients. +* +* |Y | | 0.2568 0.5041 0.0979| |R| |16 | +* |Cb| = |-0.1482 -0.2910 0.4392| * |G| + |128| +* |Cr| | 0.4392 0.4392 -0.3678| |B| |128| +*/ +writel (CSC0_COEF0_A2 (0x081 ) |CSC0_COEF0_A1 (0x041 ), lcdif->base +LCDC_V8_CSC0_COEF0 ); -writel (CSC0_COEF1_B1 (0x7d5 ) |CSC0_COEF1_A3 (0x01d ), +writel (CSC0_COEF1_B1 (0x7db ) |CSC0_COEF1_A3 (0x019 ), lcdif->base +LCDC_V8_CSC0_COEF1 ); -writel (CSC0_COEF2_B3 (0x080 ) |CSC0_COEF2_B2 (0x7ac ), +writel (CSC0_COEF2_B3 (0x070 ) |CSC0_COEF2_B2 (0x7b6 ), lcdif->base +LCDC_V8_CSC0_COEF2 ); -writel (CSC0_COEF3_C2 (0x795 ) |CSC0_COEF3_C1 (0x080 ), +writel (CSC0_COEF3_C2 (0x7a2 ) |CSC0_COEF3_C1 (0x070 ), lcdif->base +LCDC_V8_CSC0_COEF3 ); -writel (CSC0_COEF4_D1 (0x000 ) |CSC0_COEF4_C3 (0x7ec ), +writel (CSC0_COEF4_D1 (0x010 ) |CSC0_COEF4_C3 (0x7ee ), lcdif->base +LCDC_V8_CSC0_COEF4 );writel (CSC0_COEF5_D3 (0x080 ) |CSC0_COEF5_D2 (0x080 ), lcdif->base +LCDC_V8_CSC0_COEF5 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 215/1146 ata: libata: fix NCQ autosense logic
In reply to Greg Kroah-HartmanFrom: Niklas Cassel <[email protected]>
[ Upstream commit 7390896b3484d44cbdb8bc4859964314ac66d3c9 ]
Currently, the logic if we should call ata_scsi_set_sense() (and set flag ATA_QCFLAG_SENSE_VALID to indicate that we have successfully added sense data to the struct ata_queued_cmd) looks like this:
if (dev->class == ATA_DEV_ZAC &&
((qc->result_tf.status & ATA_SENSE) || qc->result_tf.auxiliary))
The problem with this is that a drive can support the NCQ command error log without supporting NCQ autosense.
On such a drive, if the failing command has sense data, the status field in the NCQ command error log will have the ATA_SENSE bit set.
It is just that this sense data is not included in the NCQ command error log when NCQ autosense is not supported. Instead the sense data has to be fetched using the REQUEST SENSE DATA EXT command.
Therefore, we should only add the sense data if the drive supports NCQ autosense AND the ATA_SENSE bit is set in the status field.
Fix this, and at the same time, remove the duplicated ATA_DEV_ZAC check. The struct ata_taskfile supplied to ata_eh_read_log_10h() is memset:ed before calling the function, so simply checking if qc->result_tf.auxiliary is set is sufficient to tell us that the log actually contained sense data.
--- drivers/ata/libata-sata.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/ata/libata-sata.c +8 -3
@@ -1392,7 +1392,8 @@ static int ata_eh_read_log_10h(struct ata_device *dev, tf->hob_lbah = buf[10 ]; tf->nsect = buf[12 ]; tf->hob_nsect = buf[13 ]; -if (dev->class ==ATA_DEV_ZAC &&ata_id_has_ncq_autosense (dev->id)) +if (dev->class ==ATA_DEV_ZAC &&ata_id_has_ncq_autosense (dev->id) && + (tf->status &ATA_SENSE )) tf->auxiliary = buf[14 ] <<16 | buf[15 ] <<8 | buf[16 ];return 0 ;
@@ -1456,8 +1457,12 @@ void ata_eh_analyze_ncq_error(struct ata_link *link)memcpy (&qc->result_tf, &tf,sizeof (tf)); qc->result_tf.flags =ATA_TFLAG_ISADDR |ATA_TFLAG_LBA |ATA_TFLAG_LBA48 ; qc->err_mask |=AC_ERR_DEV |AC_ERR_NCQ ; -if (dev->class ==ATA_DEV_ZAC && - ((qc->result_tf.status &ATA_SENSE ) || qc->result_tf.auxiliary)) { + +/* +* If the device supports NCQ autosense, ata_eh_read_log_10h() will have +* stored the sense data in qc->result_tf.auxiliary. +*/ +if (qc->result_tf.auxiliary) {char sense_key, asc, ascq; sense_key = (qc->result_tf.auxiliary >>16 ) &0xff ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 216/1146 pinctrl: ocelot: add missing destroy_workqueue() in error path in ocelot_pinctrl_probe()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 8ada020ade3bc4125b639a1dca50a6df687dd986 ]
Using devm_add_action_or_reset() to make workqueue device-managed, so it can be destroy whenever the driver is unbound.
--- drivers/pinctrl/pinctrl-ocelot.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/pinctrl/pinctrl-ocelot.c +10 -10
@@ -2047,6 +2047,11 @@ static struct regmap *ocelot_pinctrl_create_pincfg(struct platform_device *pdev,return devm_regmap_init_mmio (&pdev->dev, base, ®map_config); } +static void ocelot_destroy_workqueue (void *data) +{ +destroy_workqueue (data); +} +static int ocelot_pinctrl_probe (struct platform_device *pdev) {const struct ocelot_match_data *data;
@@ -2078,6 +2083,11 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev)if (!info->wq)return -ENOMEM ; + ret =devm_add_action_or_reset (dev, ocelot_destroy_workqueue, + info->wq); +if (ret) +return ret; + info->pincfg_data = &data->pincfg_data; reset =devm_reset_control_get_optional_shared (dev,"switch" );
@@ -2119,15 +2129,6 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev)return 0 ; } -static int ocelot_pinctrl_remove (struct platform_device *pdev) -{ -struct ocelot_pinctrl *info =platform_get_drvdata (pdev); - -destroy_workqueue (info->wq); - -return 0 ; -} -static struct platform_driver ocelot_pinctrl_driver = { .driver = { .name ="pinctrl-ocelot" ,
@@ -2135,7 +2136,6 @@ static struct platform_driver ocelot_pinctrl_driver = { .suppress_bind_attrs = true, }, .probe = ocelot_pinctrl_probe, - .remove = ocelot_pinctrl_remove, };module_platform_driver (ocelot_pinctrl_driver);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 217/1146 ASoC: Intel: avs: Fix DMA mask assignment
In reply to Greg Kroah-HartmanFrom: Cezary Rojewski <[email protected]>
[ Upstream commit 83375566a7a7042cb34b24986d100f46bfa0c1e5 ]
Spelling error leads to incorrect behavior when setting up DMA mask.
--- sound/soc/intel/avs/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/intel/avs/core.c +1 -1
@@ -440,7 +440,7 @@ static int avs_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)if (bus->mlcap)snd_hdac_ext_bus_get_ml_capabilities (bus); -if (!dma_set_mask_and_coherent (dev,DMA_BIT_MASK (64 ))) +if (dma_set_mask_and_coherent (dev,DMA_BIT_MASK (64 )))dma_set_mask_and_coherent (dev,DMA_BIT_MASK (32 ));dma_set_max_seg_size (dev,UINT_MAX );
Signature · 5 lines
2.35.1 tion(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/rt5682.txt +1 -1
@@ -46,7 +46,7 @@ Optional properties: - realtek,dmic-clk-driving-high : Set the high driving of the DMIC clock out. -- #sound-dai-cells: Should be set to '<0>'. +- #sound-dai-cells: Should be set to '<1>'. Pins on the device (for linking into audio routes) for RT5682:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 218/1146 ASoC: Intel: avs: Fix potential RX buffer overflow
In reply to Greg Kroah-HartmanFrom: Cezary Rojewski <[email protected]>
[ Upstream commit 23ae34e033b2c0e5e88237af82b163b296fd6aa9 ]
If an event caused firmware to return invalid RX size for LARGE_CONFIG_GET, memcpy_fromio() could end up copying too many bytes. Fix by utilizing min_t().
--- sound/soc/intel/avs/ipc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/intel/avs/ipc.c +2 -1
@@ -192,7 +192,8 @@ static void avs_dsp_receive_rx(struct avs_dev *adev, u64 header)/* update size in case of LARGE_CONFIG_GET */ if (msg.msg_target ==AVS_MOD_MSG && msg.global_msg_type ==AVS_MOD_LARGE_CONFIG_GET ) - ipc->rx.size = msg.ext.large_config.data_off_size; + ipc->rx.size =min_t (u32,AVS_MAILBOX_SIZE , + msg.ext.large_config.data_off_size);memcpy_fromio (ipc->rx.data,avs_uplink_addr (adev), ipc->rx.size);trace_avs_msg_payload (ipc->rx.data, ipc->rx.size);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 219/1146 ipmi: kcs: Poll OBF briefly to reduce OBE latency
In reply to Greg Kroah-HartmanFrom: Andrew Jeffery <[email protected]>
[ Upstream commit f90bc0f97f2b65af233a37b2e32fc81871a1e3cf ]
The ASPEED KCS devices don't provide a BMC-side interrupt for the host reading the output data register (ODR). The act of the host reading ODR clears the output buffer full (OBF) flag in the status register (STR), informing the BMC it can transmit a subsequent byte.
On the BMC side the KCS client must enable the OBE event *and* perform a subsequent read of STR anyway to avoid races - the polling provides a window for the host to read ODR if data was freshly written while minimising BMC-side latency.
Message-Id: <[email protected]>
--- drivers/char/ipmi/kcs_bmc_aspeed.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
drivers/char/ipmi/kcs_bmc_aspeed.c +21 -3
@@ -406,13 +406,31 @@ static void aspeed_kcs_check_obe(struct timer_list *timer)static void aspeed_kcs_irq_mask_update (struct kcs_bmc_device *kcs_bmc,u8 mask,u8 state) {struct aspeed_kcs_bmc *priv =to_aspeed_kcs_bmc (kcs_bmc); +int rc; +u8 str;/* We don't have an OBE IRQ, emulate it */ if (mask &KCS_BMC_EVENT_TYPE_OBE ) { -if (KCS_BMC_EVENT_TYPE_OBE & state) -mod_timer (&priv->obe.timer, jiffies +OBE_POLL_PERIOD ); -else +if (KCS_BMC_EVENT_TYPE_OBE & state) { +/* +* Given we don't have an OBE IRQ, delay by polling briefly to see if we can +* observe such an event before returning to the caller. This is not +* incorrect because OBF may have already become clear before enabling the +* IRQ if we had one, under which circumstance no event will be propagated +* anyway. +* +* The onus is on the client to perform a race-free check that it hasn't +* missed the event. +*/ + rc =read_poll_timeout_atomic (aspeed_kcs_inb, str, + !(str &KCS_BMC_STR_OBF ),1 ,100 , false, + &priv->kcs_bmc, priv->kcs_bmc.ioreg.str); +/* Time for the slow path? */ +if (rc == -ETIMEDOUT ) +mod_timer (&priv->obe.timer, jiffies +OBE_POLL_PERIOD ); + }else {del_timer (&priv->obe.timer); + } }if (mask &KCS_BMC_EVENT_TYPE_IBF ) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 220/1146 drm/amdgpu: Revert "drm/amdgpu: getting fan speed pwm for vega10 properly"
In reply to Greg Kroah-HartmanFrom: Asher Song <[email protected]>
[ Upstream commit e5b781c56d46c44c52caa915f1b65064f2f7c1ba ]
This reverts commit 16fb4dca95daa9d8e037201166a58de8284f4268.
Unfortunately, that commit causes fan monitors can't be read and written properly.
--- .../amd/pm/powerplay/hwmgr/vega10_thermal.c | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_thermal.c +13 -12
@@ -67,21 +67,22 @@ int vega10_fan_ctrl_get_fan_speed_info(struct pp_hwmgr *hwmgr,int vega10_fan_ctrl_get_fan_speed_pwm (struct pp_hwmgr *hwmgr,uint32_t *speed) { -struct amdgpu_device *adev = hwmgr->adev; -uint32_t duty100, duty; -uint64_t tmp64; +uint32_t current_rpm; +uint32_t percent =0 ; - duty100 =REG_GET_FIELD (RREG32_SOC15 (THM ,0 , mmCG_FDO_CTRL1), -CG_FDO_CTRL1 ,FMAX_DUTY100 ); - duty =REG_GET_FIELD (RREG32_SOC15 (THM ,0 , mmCG_THERMAL_STATUS), -CG_THERMAL_STATUS ,FDO_PWM_DUTY ); +if (hwmgr->thermal_controller.fanInfo.bNoFan) +return 0 ; -if (!duty100) -return -EINVAL ; +if (vega10_get_current_rpm (hwmgr, ¤t_rpm)) +return -1 ; + +if (hwmgr->thermal_controller. + advanceFanControlParameters.usMaxFanRPM !=0 ) + percent = current_rpm *255 / + hwmgr->thermal_controller. + advanceFanControlParameters.usMaxFanRPM; - tmp64 = (uint64_t )duty *255 ; -do_div (tmp64, duty100); - *speed =MIN ((uint32_t )tmp64,255 ); + *speed =MIN (percent,255 );return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 221/1146 drm/amdgpu/powerplay/psm: Fix memory leak in power state init
In reply to Greg Kroah-HartmanFrom: Rafael Mendonca <[email protected]>
[ Upstream commit 8f8033d5663b18e6efb33feb61f2287a04605ab5 ]
Commit 902bc65de0b3 ("drm/amdgpu/powerplay/psm: return an error in power state init") made the power state init function return early in case of failure to get an entry from the powerplay table, but it missed to clean up the allocated memory for the current power state before returning.
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c +2 -0
@@ -75,8 +75,10 @@ int psm_init_power_state_table(struct pp_hwmgr *hwmgr)for (i =0 ; i < table_entries; i++) { result = hwmgr->hwmgr_func->get_pp_table_entry (hwmgr, i, state);if (result) { +kfree (hwmgr->current_ps);kfree (hwmgr->request_ps);kfree (hwmgr->ps); + hwmgr->current_ps =NULL ; hwmgr->request_ps =NULL ; hwmgr->ps =NULL ;return -EINVAL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 222/1146 powerpc: dts: t208x: Mark MAC1 and MAC2 as 10G
In reply to Greg Kroah-HartmanFrom: Sean Anderson <[email protected]>
[ Upstream commit 36926a7d70c2d462fca1ed85bfee000d17fd8662 ]
On the T208X SoCs, MAC1 and MAC2 support XGMII. Add some new MAC dtsi fragments, and mark the QMAN ports as 10G.
--- .../boot/dts/fsl/qoriq-fman3-0-10g-2.dtsi | 44 +++++++++++++++++++ .../boot/dts/fsl/qoriq-fman3-0-10g-3.dtsi | 44 +++++++++++++++++++ arch/powerpc/boot/dts/fsl/t2081si-post.dtsi | 4 +- 3 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-2.dtsi create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-3.dtsi
arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-2.dtsi new file +44 -0
@@ -0,0 +1,44 @@ +// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-or-later +/* + * QorIQ FMan v3 10g port #2 device tree stub [ controller @ offset 0x400000 ] + * + * Copyright 2022 Sean Anderson <[email protected]> + * Copyright 2012 - 2015 Freescale Semiconductor Inc. + */ + +fman@400000 { + fman0_rx_0x08: port@88000 { + cell-index = <0x8>; + compatible = "fsl,fman-v3-port-rx"; + reg = <0x88000 0x1000>; + fsl,fman-10g-port; + }; + + fman0_tx_0x28: port@a8000 { + cell-index = <0x28>; + compatible = "fsl,fman-v3-port-tx"; + reg = <0xa8000 0x1000>; + fsl,fman-10g-port; + }; + + ethernet@e0000 { + cell-index = <0>; + compatible = "fsl,fman-memac"; + reg = <0xe0000 0x1000>; + fsl,fman-ports = <&fman0_rx_0x08 &fman0_tx_0x28>; + ptp-timer = <&ptp_timer0>; + pcsphy-handle = <&pcsphy0>; + }; + + mdio@e1000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; + reg = <0xe1000 0x1000>; + fsl,erratum-a011043; /* must ignore read errors */ + + pcsphy0: ethernet-phy@0 { + reg = <0x0>; + }; + }; +};
arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-3.dtsi new file +44 -0
44 lines not on this page · raw message
arch/powerpc/boot/dts/fsl/t2081si-post.dtsi +2 -2
@@ -609,8 +609,8 @@ usb1: usb@211000 { /include/ "qoriq-bman1.dtsi" /include/ "qoriq-fman3-0.dtsi" -/include/ "qoriq-fman3-0-1g-0.dtsi" -/include/ "qoriq-fman3-0-1g-1.dtsi" +/include/ "qoriq-fman3-0-10g-2.dtsi" +/include/ "qoriq-fman3-0-10g-3.dtsi" /include/ "qoriq-fman3-0-1g-2.dtsi" /include/ "qoriq-fman3-0-1g-3.dtsi" /include/ "qoriq-fman3-0-1g-4.dtsi"
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 223/1146 net: ethernet: adi: adin1110: Fix SPI transfers
In reply to Greg Kroah-HartmanFrom: Alexandru Tachici <[email protected]>
[ Upstream commit a526a3cc9c8d426713f8bebc18ebbe39a8495d82 ]
No need to use more than one SPI transfer for reads. Use only one from now as ADIN1110/2111 does not tolerate CS changes during reads.
The BCM2711/2708 SPI controllers worked fine, but the NXP IMX8MM could not keep CS lowered during SPI bursts.
This change aims to make the ADIN1110/2111 driver compatible with both SPI controllers, without any loss of bandwidth/other capabilities.
--- drivers/net/ethernet/adi/adin1110.c | 37 +++++++++++++---------------- 1 file changed, 16 insertions(+), 21 deletions(-)
drivers/net/ethernet/adi/adin1110.c +16 -21
@@ -196,7 +196,7 @@ static int adin1110_read_reg(struct adin1110_priv *priv, u16 reg, u32 *val) {u32 header_len =ADIN1110_RD_HEADER_LEN ;u32 read_len =ADIN1110_REG_LEN ; -struct spi_transfer t[2 ] = {0 }; +struct spi_transfer t = {0 };int ret; priv->data[0 ] =ADIN1110_CD |FIELD_GET (GENMASK (12 ,8 ), reg);
@@ -209,17 +209,15 @@ static int adin1110_read_reg(struct adin1110_priv *priv, u16 reg, u32 *val) header_len++; } - t[0 ].tx_buf = &priv->data[0 ]; - t[0 ].len = header_len; -if (priv->append_crc) read_len++;memset (&priv->data[header_len],0 , read_len); - t[1 ].rx_buf = &priv->data[header_len]; - t[1 ].len = read_len; + t.tx_buf = &priv->data[0 ]; + t.rx_buf = &priv->data[0 ]; + t.len = read_len + header_len; - ret =spi_sync_transfer (priv->spidev, t,2 ); + ret =spi_sync_transfer (priv->spidev, &t,1 );if (ret)return ret;
@@ -296,7 +294,7 @@ static int adin1110_read_fifo(struct adin1110_port_priv *port_priv) {struct adin1110_priv *priv = port_priv->priv;u32 header_len =ADIN1110_RD_HEADER_LEN ; -struct spi_transfer t[2 ] = {0 }; +struct spi_transfer t;u32 frame_size_no_fcs;struct sk_buff *rxb;u32 frame_size;
@@ -327,12 +325,7 @@ static int adin1110_read_fifo(struct adin1110_port_priv *port_priv)return ret; frame_size_no_fcs = frame_size -ADIN1110_FRAME_HEADER_LEN -ADIN1110_FEC_LEN ; - - rxb =netdev_alloc_skb (port_priv->netdev, round_len); -if (!rxb) -return -ENOMEM ; - -memset (priv->data,0 , round_len +ADIN1110_RD_HEADER_LEN ); +memset (priv->data,0 ,ADIN1110_RD_HEADER_LEN ); priv->data[0 ] =ADIN1110_CD |FIELD_GET (GENMASK (12 ,8 ), reg); priv->data[1 ] =FIELD_GET (GENMASK (7 ,0 ), reg);
@@ -342,21 +335,23 @@ static int adin1110_read_fifo(struct adin1110_port_priv *port_priv) header_len++; } -skb_put (rxb, frame_size_no_fcs +ADIN1110_FRAME_HEADER_LEN ); + rxb =netdev_alloc_skb (port_priv->netdev, round_len + header_len); +if (!rxb) +return -ENOMEM ; - t[0 ].tx_buf = &priv->data[0 ]; - t[0 ].len = header_len; +skb_put (rxb, frame_size_no_fcs + header_len +ADIN1110_FRAME_HEADER_LEN ); - t[1 ].rx_buf = &rxb->data[0 ]; - t[1 ].len = round_len; + t.tx_buf = &priv->data[0 ]; + t.rx_buf = &rxb->data[0 ]; + t.len = header_len + round_len; - ret =spi_sync_transfer (priv->spidev, t,2 ); + ret =spi_sync_transfer (priv->spidev, &t,1 );if (ret) {kfree_skb (rxb);return ret; } -skb_pull (rxb,ADIN1110_FRAME_HEADER_LEN ); +skb_pull (rxb, header_len +ADIN1110_FRAME_HEADER_LEN ); rxb->protocol =eth_type_trans (rxb, port_priv->netdev); if ((port_priv->flags & IFF_ALLMULTI && rxb->pkt_type == PACKET_MULTICAST) ||
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 224/1146 samples/bpf: Fix map iteration in xdp1_user
In reply to Greg Kroah-HartmanFrom: Gerhard Engleder <[email protected]>
[ Upstream commit 05ee658c654bacda03f7fecef367e62aaf8e1cfe ]
BPF map iteration in xdp1_user results in endless loop without any output, because the return value of bpf_map_get_next_key() is checked against the wrong value.
Other call locations of bpf_map_get_next_key() check for equal 0 for continuing the iteration. xdp1_user checks against unequal -1. This is wrong for a function which can return arbitrary negative errno values, because a return value of e.g. -2 results in an endless loop.
With this fix xdp1_user is printing statistics again:
proto 0: 1 pkt/s proto 0: 1 pkt/s proto 17: 107383 pkt/s proto 17: 881655 pkt/s proto 17: 882083 pkt/s proto 17: 881758 pkt/s
--- samples/bpf/xdp1_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
samples/bpf/xdp1_user.c +1 -1
@@ -51,7 +51,7 @@ static void poll_stats(int map_fd, int interval)sleep (interval); -while (bpf_map_get_next_key (map_fd, &key, &key) !=-1 ) { +while (bpf_map_get_next_key (map_fd, &key, &key) ==0 ) {__u64 sum =0 ;assert (bpf_map_lookup_elem (map_fd, &key, values) ==0 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 225/1146 samples/bpf: Fix MAC address swapping in xdp2_kern
In reply to Greg Kroah-HartmanFrom: Gerhard Engleder <[email protected]>
[ Upstream commit 7a698edf954cb3f8b6e8dacdb77615355170420c ]
xdp2_kern rewrites and forwards packets out on the same interface. Forwarding still works but rewrite got broken when xdp multibuffer support has been added.
With xdp multibuffer a local copy of the packet has been introduced. The MAC address is now swapped in the local copy, but the local copy in not written back.
Fix MAC address swapping be adding write back of modified packet.
--- samples/bpf/xdp2_kern.c | 4 ++++ 1 file changed, 4 insertions(+)
samples/bpf/xdp2_kern.c +4 -0
@@ -112,6 +112,10 @@ int xdp_prog1(struct xdp_md *ctx)if (ipproto ==IPPROTO_UDP ) {swap_src_dst_mac (data); + +if (bpf_xdp_store_bytes (ctx,0 , pkt,sizeof (pkt))) +return rc; + rc =XDP_TX ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 226/1146 selftests/bpf: fix missing BPF object files
In reply to Greg Kroah-HartmanFrom: Wang Yufen <[email protected]>
[ Upstream commit 98af3746026c3eccb51b43181c41e001fe73f7af ]
After commit afef88e65554 ("selftests/bpf: Store BPF object files with .bpf.o extension"), we should use *.bpf.o instead of *.o.
In addition, use the BPF_FILE variable to save the BPF object file name, which can be better identified and modified.
--- .../selftests/bpf/test_bpftool_metadata.sh | 7 +++++-- .../selftests/bpf/test_flow_dissector.sh | 6 ++++-- .../testing/selftests/bpf/test_lwt_ip_encap.sh | 17 +++++++++-------- .../testing/selftests/bpf/test_lwt_seg6local.sh | 9 +++++---- tools/testing/selftests/bpf/test_tc_edt.sh | 3 ++- tools/testing/selftests/bpf/test_tc_tunnel.sh | 5 +++-- tools/testing/selftests/bpf/test_tunnel.sh | 5 +++-- tools/testing/selftests/bpf/test_xdp_meta.sh | 9 +++++---- tools/testing/selftests/bpf/test_xdp_vlan.sh | 8 ++++---- 9 files changed, 40 insertions(+), 29 deletions(-)
tools/testing/selftests/bpf/test_bpftool_metadata.sh +5 -2
@@ -4,6 +4,9 @@ # Kselftest framework requirement - SKIP code is 4. ksft_skip=4 +BPF_FILE_USED="metadata_used.bpf.o" +BPF_FILE_UNUSED="metadata_unused.bpf.o" + TESTNAME=bpftool_metadata BPF_FS=$(awk '$3 == "bpf" {print $2; exit}' /proc/mounts) BPF_DIR=$BPF_FS/test_$TESTNAME
@@ -55,7 +58,7 @@ mkdir $BPF_DIR trap cleanup EXIT -bpftool prog load metadata_unused.o $BPF_DIR/unused +bpftool prog load $BPF_FILE_UNUSED $BPF_DIR/unused METADATA_PLAIN="$(bpftool prog)" echo "$METADATA_PLAIN" | grep 'a = "foo"' > /dev/null
@@ -67,7 +70,7 @@ bpftool map | grep 'metadata.rodata' > /dev/null rm $BPF_DIR/unused -bpftool prog load metadata_used.o $BPF_DIR/used +bpftool prog load $BPF_FILE_USED $BPF_DIR/used METADATA_PLAIN="$(bpftool prog)" echo "$METADATA_PLAIN" | grep 'a = "bar"' > /dev/null
tools/testing/selftests/bpf/test_flow_dissector.sh +4 -2
@@ -2,6 +2,8 @@ # SPDX-License-Identifier: GPL-2.0 # # Load BPF flow dissector and verify it correctly dissects traffic + +BPF_FILE="bpf_flow.bpf.o" export TESTNAME=test_flow_dissector unmount=0
@@ -22,7 +24,7 @@ if [[ -z $(ip netns identify $$) ]]; then if bpftool="$(which bpftool)"; then echo "Testing global flow dissector..." - $bpftool prog loadall ./bpf_flow.o /sys/fs/bpf/flow \ + $bpftool prog loadall $BPF_FILE /sys/fs/bpf/flow \ type flow_dissector if ! unshare --net $bpftool prog attach pinned \
@@ -95,7 +97,7 @@ else fi # Attach BPF program -./flow_dissector_load -p bpf_flow.o -s _dissect +./flow_dissector_load -p $BPF_FILE -s _dissect # Setup tc qdisc add dev lo ingress
tools/testing/selftests/bpf/test_lwt_ip_encap.sh +9 -8
@@ -38,6 +38,7 @@ # ping: SRC->[encap at veth2:ingress]->GRE:decap->DST # ping replies go DST->SRC directly +BPF_FILE="test_lwt_ip_encap.bpf.o" if [[ $EUID -ne 0 ]]; then echo "This script must be run as root" echo "FAIL"
@@ -373,14 +374,14 @@ test_egress() # install replacement routes (LWT/eBPF), pings succeed if [ "${ENCAP}" == "IPv4" ] ; then ip -netns ${NS1} route add ${IPv4_DST} encap bpf xmit obj \ - test_lwt_ip_encap.o sec encap_gre dev veth1 ${VRF} + ${BPF_FILE} sec encap_gre dev veth1 ${VRF} ip -netns ${NS1} -6 route add ${IPv6_DST} encap bpf xmit obj \ - test_lwt_ip_encap.o sec encap_gre dev veth1 ${VRF} + ${BPF_FILE} sec encap_gre dev veth1 ${VRF} elif [ "${ENCAP}" == "IPv6" ] ; then ip -netns ${NS1} route add ${IPv4_DST} encap bpf xmit obj \ - test_lwt_ip_encap.o sec encap_gre6 dev veth1 ${VRF} + ${BPF_FILE} sec encap_gre6 dev veth1 ${VRF} ip -netns ${NS1} -6 route add ${IPv6_DST} encap bpf xmit obj \ - test_lwt_ip_encap.o sec encap_gre6 dev veth1 ${VRF} + ${BPF_FILE} sec encap_gre6 dev veth1 ${VRF} else echo " unknown encap ${ENCAP}" TEST_STATUS=1
@@ -431,14 +432,14 @@ test_ingress() # install replacement routes (LWT/eBPF), pings succeed if [ "${ENCAP}" == "IPv4" ] ; then ip -netns ${NS2} route add ${IPv4_DST} encap bpf in obj \ - test_lwt_ip_encap.o sec encap_gre dev veth2 ${VRF} + ${BPF_FILE} sec encap_gre dev veth2 ${VRF} ip -netns ${NS2} -6 route add ${IPv6_DST} encap bpf in obj \ - test_lwt_ip_encap.o sec encap_gre dev veth2 ${VRF} + ${BPF_FILE} sec encap_gre dev veth2 ${VRF} elif [ "${ENCAP}" == "IPv6" ] ; then ip -netns ${NS2} route add ${IPv4_DST} encap bpf in obj \ - test_lwt_ip_encap.o sec encap_gre6 dev veth2 ${VRF} + ${BPF_FILE} sec encap_gre6 dev veth2 ${VRF} ip -netns ${NS2} -6 route add ${IPv6_DST} encap bpf in obj \ - test_lwt_ip_encap.o sec encap_gre6 dev veth2 ${VRF} + ${BPF_FILE} sec encap_gre6 dev veth2 ${VRF} else echo "FAIL: unknown encap ${ENCAP}" TEST_STATUS=1
tools/testing/selftests/bpf/test_lwt_seg6local.sh +5 -4
@@ -23,6 +23,7 @@ # Kselftest framework requirement - SKIP code is 4. ksft_skip=4 +BPF_FILE="test_lwt_seg6local.bpf.o" readonly NS1="ns1-$(mktemp -u XXXXXX)" readonly NS2="ns2-$(mktemp -u XXXXXX)" readonly NS3="ns3-$(mktemp -u XXXXXX)"
@@ -117,18 +118,18 @@ ip netns exec ${NS6} ip -6 addr add fb00::109/16 dev veth10 scope link ip netns exec ${NS1} ip -6 addr add fb00::1/16 dev lo ip netns exec ${NS1} ip -6 route add fb00::6 dev veth1 via fb00::21 -ip netns exec ${NS2} ip -6 route add fb00::6 encap bpf in obj test_lwt_seg6local.o sec encap_srh dev veth2 +ip netns exec ${NS2} ip -6 route add fb00::6 encap bpf in obj ${BPF_FILE} sec encap_srh dev veth2 ip netns exec ${NS2} ip -6 route add fd00::1 dev veth3 via fb00::43 scope link ip netns exec ${NS3} ip -6 route add fc42::1 dev veth5 via fb00::65 -ip netns exec ${NS3} ip -6 route add fd00::1 encap seg6local action End.BPF endpoint obj test_lwt_seg6local.o sec add_egr_x dev veth4 +ip netns exec ${NS3} ip -6 route add fd00::1 encap seg6local action End.BPF endpoint obj ${BPF_FILE} sec add_egr_x dev veth4 -ip netns exec ${NS4} ip -6 route add fd00::2 encap seg6local action End.BPF endpoint obj test_lwt_seg6local.o sec pop_egr dev veth6 +ip netns exec ${NS4} ip -6 route add fd00::2 encap seg6local action End.BPF endpoint obj ${BPF_FILE} sec pop_egr dev veth6 ip netns exec ${NS4} ip -6 addr add fc42::1 dev lo ip netns exec ${NS4} ip -6 route add fd00::3 dev veth7 via fb00::87 ip netns exec ${NS5} ip -6 route add fd00::4 table 117 dev veth9 via fb00::109 -ip netns exec ${NS5} ip -6 route add fd00::3 encap seg6local action End.BPF endpoint obj test_lwt_seg6local.o sec inspect_t dev veth8 +ip netns exec ${NS5} ip -6 route add fd00::3 encap seg6local action End.BPF endpoint obj ${BPF_FILE} sec inspect_t dev veth8 ip netns exec ${NS6} ip -6 addr add fb00::6/16 dev lo ip netns exec ${NS6} ip -6 addr add fd00::4/16 dev lo
tools/testing/selftests/bpf/test_tc_edt.sh +2 -1
@@ -5,6 +5,7 @@ # with dst port = 9000 down to 5MBps. Then it measures actual # throughput of the flow. +BPF_FILE="test_tc_edt.bpf.o" if [[ $EUID -ne 0 ]]; then echo "This script must be run as root" echo "FAIL"
@@ -54,7 +55,7 @@ ip -netns ${NS_DST} route add ${IP_SRC}/32 dev veth_dst ip netns exec ${NS_SRC} tc qdisc add dev veth_src root fq ip netns exec ${NS_SRC} tc qdisc add dev veth_src clsact ip netns exec ${NS_SRC} tc filter add dev veth_src egress \ - bpf da obj test_tc_edt.o sec cls_test + bpf da obj ${BPF_FILE} sec cls_test # start the listener
tools/testing/selftests/bpf/test_tc_tunnel.sh +3 -2
@@ -3,6 +3,7 @@ # # In-place tunneling +BPF_FILE="test_tc_tunnel.bpf.o" # must match the port that the bpf program filters on readonly port=8000
@@ -196,7 +197,7 @@ verify_data # client can no longer connect ip netns exec "${ns1}" tc qdisc add dev veth1 clsact ip netns exec "${ns1}" tc filter add dev veth1 egress \ - bpf direct-action object-file ./test_tc_tunnel.o \ + bpf direct-action object-file ${BPF_FILE} \ section "encap_${tuntype}_${mac}" echo "test bpf encap without decap (expect failure)" server_listen
@@ -296,7 +297,7 @@ fi ip netns exec "${ns2}" ip link del dev testtun0 ip netns exec "${ns2}" tc qdisc add dev veth2 clsact ip netns exec "${ns2}" tc filter add dev veth2 ingress \ - bpf direct-action object-file ./test_tc_tunnel.o section decap + bpf direct-action object-file ${BPF_FILE} section decap echo "test bpf encap with bpf decap" client_connect verify_data
tools/testing/selftests/bpf/test_tunnel.sh +3 -2
@@ -45,6 +45,7 @@ # 5) Tunnel protocol handler, ex: vxlan_rcv, decap the packet # 6) Forward the packet to the overlay tnl dev +BPF_FILE="test_tunnel_kern.bpf.o" BPF_PIN_TUNNEL_DIR="/sys/fs/bpf/tc/tunnel" PING_ARG="-c 3 -w 10 -q" ret=0
@@ -545,7 +546,7 @@ test_xfrm_tunnel() > /sys/kernel/debug/tracing/trace setup_xfrm_tunnel mkdir -p ${BPF_PIN_TUNNEL_DIR} - bpftool prog loadall ./test_tunnel_kern.o ${BPF_PIN_TUNNEL_DIR} + bpftool prog loadall ${BPF_FILE} ${BPF_PIN_TUNNEL_DIR} tc qdisc add dev veth1 clsact tc filter add dev veth1 proto ip ingress bpf da object-pinned \ ${BPF_PIN_TUNNEL_DIR}/xfrm_get_state
@@ -572,7 +573,7 @@ attach_bpf() SET=$2 GET=$3 mkdir -p ${BPF_PIN_TUNNEL_DIR} - bpftool prog loadall ./test_tunnel_kern.o ${BPF_PIN_TUNNEL_DIR}/ + bpftool prog loadall ${BPF_FILE} ${BPF_PIN_TUNNEL_DIR}/ tc qdisc add dev $DEV clsact tc filter add dev $DEV egress bpf da object-pinned ${BPF_PIN_TUNNEL_DIR}/$SET tc filter add dev $DEV ingress bpf da object-pinned ${BPF_PIN_TUNNEL_DIR}/$GET
tools/testing/selftests/bpf/test_xdp_meta.sh +5 -4
@@ -1,5 +1,6 @@ #!/bin/sh +BPF_FILE="test_xdp_meta.bpf.o" # Kselftest framework requirement - SKIP code is 4. readonly KSFT_SKIP=4 readonly NS1="ns1-$(mktemp -u XXXXXX)"
@@ -42,11 +43,11 @@ ip netns exec ${NS2} ip addr add 10.1.1.22/24 dev veth2 ip netns exec ${NS1} tc qdisc add dev veth1 clsact ip netns exec ${NS2} tc qdisc add dev veth2 clsact -ip netns exec ${NS1} tc filter add dev veth1 ingress bpf da obj test_xdp_meta.o sec t -ip netns exec ${NS2} tc filter add dev veth2 ingress bpf da obj test_xdp_meta.o sec t +ip netns exec ${NS1} tc filter add dev veth1 ingress bpf da obj ${BPF_FILE} sec t +ip netns exec ${NS2} tc filter add dev veth2 ingress bpf da obj ${BPF_FILE} sec t -ip netns exec ${NS1} ip link set dev veth1 xdp obj test_xdp_meta.o sec x -ip netns exec ${NS2} ip link set dev veth2 xdp obj test_xdp_meta.o sec x +ip netns exec ${NS1} ip link set dev veth1 xdp obj ${BPF_FILE} sec x +ip netns exec ${NS2} ip link set dev veth2 xdp obj ${BPF_FILE} sec x ip netns exec ${NS1} ip link set dev veth1 up ip netns exec ${NS2} ip link set dev veth2 up
tools/testing/selftests/bpf/test_xdp_vlan.sh +4 -4
@@ -200,11 +200,11 @@ ip netns exec ${NS2} sh -c 'ping -W 1 -c 1 100.64.41.1 || echo "Success: First p # ---------------------------------------------------------------------- # In ns1: ingress use XDP to remove VLAN tags export DEVNS1=veth1 -export FILE=test_xdp_vlan.o +export BPF_FILE=test_xdp_vlan.bpf.o # First test: Remove VLAN by setting VLAN ID 0, using "xdp_vlan_change" export XDP_PROG=xdp_vlan_change -ip netns exec ${NS1} ip link set $DEVNS1 $XDP_MODE object $FILE section $XDP_PROG +ip netns exec ${NS1} ip link set $DEVNS1 $XDP_MODE object $BPF_FILE section $XDP_PROG # In ns1: egress use TC to add back VLAN tag 4011 # (del cmd)
@@ -212,7 +212,7 @@ ip netns exec ${NS1} ip link set $DEVNS1 $XDP_MODE object $FILE section $XDP_PRO # ip netns exec ${NS1} tc qdisc add dev $DEVNS1 clsact ip netns exec ${NS1} tc filter add dev $DEVNS1 egress \ - prio 1 handle 1 bpf da obj $FILE sec tc_vlan_push + prio 1 handle 1 bpf da obj $BPF_FILE sec tc_vlan_push # Now the namespaces can reach each-other, test with ping: ip netns exec ${NS2} ping -i 0.2 -W 2 -c 2 $IPADDR1
@@ -226,7 +226,7 @@ ip netns exec ${NS1} ping -i 0.2 -W 2 -c 2 $IPADDR2 # export XDP_PROG=xdp_vlan_remove_outer2 ip netns exec ${NS1} ip link set $DEVNS1 $XDP_MODE off -ip netns exec ${NS1} ip link set $DEVNS1 $XDP_MODE object $FILE section $XDP_PROG +ip netns exec ${NS1} ip link set $DEVNS1 $XDP_MODE object $BPF_FILE section $XDP_PROG # Now the namespaces should still be able reach each-other, test with ping: ip netns exec ${NS2} ping -i 0.2 -W 2 -c 2 $IPADDR1
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 227/1146 drm/bridge: it6505: Initialize AUX channel in it6505_i2c_probe
In reply to Greg Kroah-HartmanFrom: Pin-yen Lin <[email protected]>
[ Upstream commit e577d4b13064c337b83fe7edecb3f34e87144821 ]
During device boot, the HPD interrupt could be triggered before the DRM subsystem registers it6505 as a DRM bridge. In such cases, the driver tries to access AUX channel and causes NULL pointer dereference. Initializing the AUX channel earlier to prevent such error.
--- drivers/gpu/drm/bridge/ite-it6505.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/bridge/ite-it6505.c +5 -3
@@ -2860,10 +2860,7 @@ static int it6505_bridge_attach(struct drm_bridge *bridge, }/* Register aux channel */ - it6505->aux.name ="DP-AUX" ; - it6505->aux.dev = dev; it6505->aux.drm_dev = bridge->dev; - it6505->aux.transfer = it6505_aux_transfer; ret =drm_dp_aux_register (&it6505->aux);
@@ -3316,6 +3313,11 @@ static int it6505_i2c_probe(struct i2c_client *client,DRM_DEV_DEBUG_DRIVER (dev,"it6505 device name: %s" ,dev_name (dev));debugfs_init (it6505); + it6505->aux.name ="DP-AUX" ; + it6505->aux.dev = dev; + it6505->aux.transfer = it6505_aux_transfer; +drm_dp_aux_init (&it6505->aux); + it6505->bridge.funcs = &it6505_bridge_funcs; it6505->bridge.type = DRM_MODE_CONNECTOR_DisplayPort; it6505->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID |
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 228/1146 Input: iqs7222 - protect against undefined slider size
In reply to Greg Kroah-HartmanFrom: Jeff LaBundy <[email protected]>
[ Upstream commit 2f6fd232978906f6fb054529210b9faec384bd45 ]
Select variants of silicon do not define a default slider size, in which case the size must be specified in the device tree. If it is not, the axis's maximum value is reported as 65535 due to unsigned integer overflow.
To solve this problem, move the existing zero-check outside of the conditional block that checks whether the property is present.
--- drivers/input/misc/iqs7222.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/input/misc/iqs7222.c +8 -1
@@ -2066,7 +2066,7 @@ static int iqs7222_parse_sldr(struct iqs7222_private *iqs7222, int sldr_index) sldr_setup[4 + reg_offset] -=2 ;if (!fwnode_property_read_u32 (sldr_node,"azoteq,slider-size" , &val)) { -if (!val || val > dev_desc->sldr_res) { +if (val > dev_desc->sldr_res) {dev_err (&client->dev,"Invalid %s size: %u\n" ,fwnode_get_name (sldr_node), val);return -EINVAL ;
@@ -2081,6 +2081,13 @@ static int iqs7222_parse_sldr(struct iqs7222_private *iqs7222, int sldr_index) } } +if (!(reg_offset ? sldr_setup[3 ] + : sldr_setup[2 ] &IQS7222_SLDR_SETUP_2_RES_MASK )) { +dev_err (&client->dev,"Undefined %s size\n" , +fwnode_get_name (sldr_node)); +return -EINVAL ; + } +if (!fwnode_property_read_u32 (sldr_node,"azoteq,top-speed" , &val)) {if (val > (reg_offset ?U16_MAX :U8_MAX *4 )) { dev_err(&client->dev, "Invalid %s top speed: %u\n",
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 229/1146 media: v4l2-ctrls: Fix off-by-one error in integer menu control check
In reply to Greg Kroah-HartmanFrom: Laurent Pinchart <[email protected]>
[ Upstream commit b6bcdf763db1f5ea602bf876cfe91debfb3c7773 ]
The V4L2 API defines the maximum value for an integer menu control as the number of elements minus one. The v4l2_ctrl_new_std_menu() validates this constraint with an off-by-one error. Fix it.
--- drivers/media/v4l2-core/v4l2-ctrls-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-ctrls-core.c +1 -1
@@ -1827,7 +1827,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl,else if (type ==V4L2_CTRL_TYPE_INTEGER_MENU ) qmenu_int =v4l2_ctrl_get_int_menu (id, &qmenu_int_len); -if ((!qmenu && !qmenu_int) || (qmenu_int && max > qmenu_int_len)) { +if ((!qmenu && !qmenu_int) || (qmenu_int && max >= qmenu_int_len)) {handler_set_err (hdl, -EINVAL );return NULL ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 230/1146 media: coda: jpeg: Add check for kmalloc
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit f30ce3d3760b22ee33c8d9c2e223764ad30bdc5f ]
As kmalloc can return NULL pointer, it should be better to check the return value and return error, same as coda_jpeg_decode_header.
--- drivers/media/platform/chips-media/coda-jpeg.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/media/platform/chips-media/coda-jpeg.c +8 -2
@@ -1052,10 +1052,16 @@ static int coda9_jpeg_start_encoding(struct coda_ctx *ctx)v4l2_err (&dev->v4l2_dev,"error loading Huffman tables\n" );return ret; } -if (!ctx->params.jpeg_qmat_tab[0 ]) +if (!ctx->params.jpeg_qmat_tab[0 ]) { ctx->params.jpeg_qmat_tab[0 ] =kmalloc (64 ,GFP_KERNEL ); -if (!ctx->params.jpeg_qmat_tab[1 ]) +if (!ctx->params.jpeg_qmat_tab[0 ]) +return -ENOMEM ; + } +if (!ctx->params.jpeg_qmat_tab[1 ]) { ctx->params.jpeg_qmat_tab[1 ] =kmalloc (64 ,GFP_KERNEL ); +if (!ctx->params.jpeg_qmat_tab[1 ]) +return -ENOMEM ; + }coda_set_jpeg_compression_quality (ctx, ctx->params.jpeg_quality);return 0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 231/1146 media: amphion: reset instance if its aborted before codec header parsed
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit 3984ea32e83bcad06b4b034ddd4b0a934c1b2f91 ]
there is hardware limitation that if it's aborted before the first codec header parsed, the codec may be stalled unless we do reset codec.
and drop the source change event if it's triggered after reset.
--- drivers/media/platform/amphion/vdec.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/media/platform/amphion/vdec.c +10 -3
@@ -753,6 +753,9 @@ static bool vdec_check_source_change(struct vpu_inst *inst)if (!inst->fh.m2m_ctx)return false; +if (vdec->reset_codec) +return false; +if (!vb2_is_streaming (v4l2_m2m_get_dst_vq (inst->fh.m2m_ctx)))return true; fmt =vpu_helper_find_format (inst, inst->cap_format.type, vdec->codec_info.pixfmt);
@@ -1088,7 +1091,8 @@ static void vdec_event_seq_hdr(struct vpu_inst *inst, struct vpu_dec_codec_info vdec->seq_tag = vdec->codec_info.tag;if (vdec->is_source_changed) {vdec_update_state (inst,VPU_CODEC_STATE_DYAMIC_RESOLUTION_CHANGE ,0 ); -vpu_notify_source_change (inst); + vdec->source_change++; +vdec_handle_resolution_change (inst); vdec->is_source_changed = false; } }
@@ -1335,6 +1339,8 @@ static void vdec_abort(struct vpu_inst *inst) vdec->decoded_frame_count, vdec->display_frame_count, vdec->sequence); +if (!vdec->seq_hdr_found) + vdec->reset_codec = true; vdec->params.end_flag =0 ; vdec->drain =0 ; vdec->params.frame_count =0 ;
@@ -1342,6 +1348,7 @@ static void vdec_abort(struct vpu_inst *inst) vdec->display_frame_count =0 ; vdec->sequence =0 ; vdec->aborting = false; + inst->extra_size =0 ; }static void vdec_stop (struct vpu_inst *inst,bool free)
@@ -1464,8 +1471,7 @@ static int vdec_start_session(struct vpu_inst *inst, u32 type) }if (V4L2_TYPE_IS_OUTPUT (type)) { -if (inst->state ==VPU_CODEC_STATE_SEEK ) -vdec_update_state (inst, vdec->state,1 ); +vdec_update_state (inst, vdec->state,1 ); vdec->eos_received =0 ;vpu_process_output_buffer (inst); }else {
@@ -1629,6 +1635,7 @@ static int vdec_open(struct file *file)return ret; vdec->fixed_fmt = false; + vdec->state =VPU_CODEC_STATE_ACTIVE ; inst->min_buffer_cap =VDEC_MIN_BUFFER_CAP ; inst->min_buffer_out =VDEC_MIN_BUFFER_OUT ;vdec_init (file);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 232/1146 media: adv748x: afe: Select input port when initializing AFE
In reply to Greg Kroah-HartmanFrom: Niklas Söderlund <[email protected]>
[ Upstream commit 23ddb85dafefdace1ad79d1a30b0a4e7c4b5cd8d ]
When moving the input selection to adv748x_reset() it was missed that during probe the device is reset _before_ the initialization and parsing of DT by the AFE subdevice. This can lead to the wrong input port (in case it's not port 0) being selected until the device is reset for the first time.
Fix this by restoring the call to adv748x_afe_s_input() in the AFE initialization while also keeping it in the adv748x_reset().
--- drivers/media/i2c/adv748x/adv748x-afe.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/i2c/adv748x/adv748x-afe.c +4 -0
@@ -521,6 +521,10 @@ int adv748x_afe_init(struct adv748x_afe *afe) } } +adv748x_afe_s_input (afe, afe->input); + +adv_dbg (state,"AFE Default input set to %d\n" , afe->input); +/* Entity pads and sinks are 0-indexed to match the pads */ for (i =ADV748X_AFE_SINK_AIN0 ; i <=ADV748X_AFE_SINK_AIN7 ; i++) afe->pads[i].flags =MEDIA_PAD_FL_SINK ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 233/1146 media: v4l2-ioctl.c: Unify YCbCr/YUV terms in format descriptions
In reply to Greg Kroah-HartmanFrom: Jernej Skrabec <[email protected]>
[ Upstream commit 6a394d563dffb60c150d87dc6678994ef8028c53 ]
Format descriptions use YCbCr and YUV terms interchangeably. Let's unify them so they all use YUV. While YCbCr is actually correct term here, YUV is shorter and thus it also fixes too long description of P010 tiled format.
--- drivers/media/v4l2-core/v4l2-ioctl.c | 34 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-)
drivers/media/v4l2-core/v4l2-ioctl.c +17 -17
@@ -1347,23 +1347,23 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)case V4L2_PIX_FMT_YUV420 : descr ="Planar YUV 4:2:0" ;break ;case V4L2_PIX_FMT_HI240 : descr ="8-bit Dithered RGB (BTTV)" ;break ;case V4L2_PIX_FMT_M420 : descr ="YUV 4:2:0 (M420)" ;break ; -case V4L2_PIX_FMT_NV12 : descr ="Y/CbCr 4:2:0" ;break ; -case V4L2_PIX_FMT_NV21 : descr ="Y/CrCb 4:2:0" ;break ; -case V4L2_PIX_FMT_NV16 : descr ="Y/CbCr 4:2:2" ;break ; -case V4L2_PIX_FMT_NV61 : descr ="Y/CrCb 4:2:2" ;break ; -case V4L2_PIX_FMT_NV24 : descr ="Y/CbCr 4:4:4" ;break ; -case V4L2_PIX_FMT_NV42 : descr ="Y/CrCb 4:4:4" ;break ; -case V4L2_PIX_FMT_P010 : descr ="10-bit Y/CbCr 4:2:0" ;break ; -case V4L2_PIX_FMT_NV12_4L4 : descr ="Y/CbCr 4:2:0 (4x4 Linear)" ;break ; -case V4L2_PIX_FMT_NV12_16L16 : descr ="Y/CbCr 4:2:0 (16x16 Linear)" ;break ; -case V4L2_PIX_FMT_NV12_32L32 : descr ="Y/CbCr 4:2:0 (32x32 Linear)" ;break ; -case V4L2_PIX_FMT_P010_4L4 : descr ="10-bit Y/CbCr 4:2:0 (4x4 Linear)" ;break ; -case V4L2_PIX_FMT_NV12M : descr ="Y/CbCr 4:2:0 (N-C)" ;break ; -case V4L2_PIX_FMT_NV21M : descr ="Y/CrCb 4:2:0 (N-C)" ;break ; -case V4L2_PIX_FMT_NV16M : descr ="Y/CbCr 4:2:2 (N-C)" ;break ; -case V4L2_PIX_FMT_NV61M : descr ="Y/CrCb 4:2:2 (N-C)" ;break ; -case V4L2_PIX_FMT_NV12MT : descr ="Y/CbCr 4:2:0 (64x32 MB, N-C)" ;break ; -case V4L2_PIX_FMT_NV12MT_16X16 : descr ="Y/CbCr 4:2:0 (16x16 MB, N-C)" ;break ; +case V4L2_PIX_FMT_NV12 : descr ="Y/UV 4:2:0" ;break ; +case V4L2_PIX_FMT_NV21 : descr ="Y/VU 4:2:0" ;break ; +case V4L2_PIX_FMT_NV16 : descr ="Y/UV 4:2:2" ;break ; +case V4L2_PIX_FMT_NV61 : descr ="Y/VU 4:2:2" ;break ; +case V4L2_PIX_FMT_NV24 : descr ="Y/UV 4:4:4" ;break ; +case V4L2_PIX_FMT_NV42 : descr ="Y/VU 4:4:4" ;break ; +case V4L2_PIX_FMT_P010 : descr ="10-bit Y/UV 4:2:0" ;break ; +case V4L2_PIX_FMT_NV12_4L4 : descr ="Y/UV 4:2:0 (4x4 Linear)" ;break ; +case V4L2_PIX_FMT_NV12_16L16 : descr ="Y/UV 4:2:0 (16x16 Linear)" ;break ; +case V4L2_PIX_FMT_NV12_32L32 : descr ="Y/UV 4:2:0 (32x32 Linear)" ;break ; +case V4L2_PIX_FMT_P010_4L4 : descr ="10-bit Y/UV 4:2:0 (4x4 Linear)" ;break ; +case V4L2_PIX_FMT_NV12M : descr ="Y/UV 4:2:0 (N-C)" ;break ; +case V4L2_PIX_FMT_NV21M : descr ="Y/VU 4:2:0 (N-C)" ;break ; +case V4L2_PIX_FMT_NV16M : descr ="Y/UV 4:2:2 (N-C)" ;break ; +case V4L2_PIX_FMT_NV61M : descr ="Y/VU 4:2:2 (N-C)" ;break ; +case V4L2_PIX_FMT_NV12MT : descr ="Y/UV 4:2:0 (64x32 MB, N-C)" ;break ; +case V4L2_PIX_FMT_NV12MT_16X16 : descr ="Y/UV 4:2:0 (16x16 MB, N-C)" ;break ;case V4L2_PIX_FMT_YUV420M : descr ="Planar YUV 4:2:0 (N-C)" ;break ;case V4L2_PIX_FMT_YVU420M : descr ="Planar YVU 4:2:0 (N-C)" ;break ;case V4L2_PIX_FMT_YUV422M : descr ="Planar YUV 4:2:2 (N-C)" ;break ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 234/1146 media: cedrus: hevc: Fix offset adjustments
In reply to Greg Kroah-HartmanFrom: Jernej Skrabec <[email protected]>
[ Upstream commit e9120e76a6f7e19a8d26c03f2964937e4ce69784 ]
As it turns out, current padding size check works fine in theory but it doesn't in practice. Most probable reason are caching issues.
Let's rework reading data from bitstream using Cedrus engine instead of CPU. That way we avoid all cache issues and make sure that we're reading same data as Cedrus.
--- .../staging/media/sunxi/cedrus/cedrus_h265.c | 25 ++++++++++++++----- .../staging/media/sunxi/cedrus/cedrus_regs.h | 2 ++ 2 files changed, 21 insertions(+), 6 deletions(-)
drivers/staging/media/sunxi/cedrus/cedrus_h265.c +19 -6
@@ -242,6 +242,18 @@ static void cedrus_h265_skip_bits(struct cedrus_dev *dev, int num) } } +static u32 cedrus_h265_show_bits (struct cedrus_dev *dev,int num) +{ +cedrus_write (dev,VE_DEC_H265_TRIGGER , +VE_DEC_H265_TRIGGER_SHOW_BITS | +VE_DEC_H265_TRIGGER_TYPE_N_BITS (num)); + +cedrus_wait_for (dev,VE_DEC_H265_STATUS , +VE_DEC_H265_STATUS_VLD_BUSY ); + +return cedrus_read (dev,VE_DEC_H265_BITS_READ ); +} +static void cedrus_h265_write_scaling_list (struct cedrus_ctx *ctx,struct cedrus_run *run) {
@@ -406,7 +418,7 @@ static int cedrus_h265_setup(struct cedrus_ctx *ctx, struct cedrus_run *run)u32 num_entry_point_offsets;u32 output_pic_list_index;u32 pic_order_cnt[2 ]; -u8 *padding; +u8 padding;int count;u32 reg;
@@ -520,21 +532,22 @@ static int cedrus_h265_setup(struct cedrus_ctx *ctx, struct cedrus_run *run)if (slice_params->data_byte_offset ==0 )return -EOPNOTSUPP ; - padding = (u8 *)vb2_plane_vaddr (&run->src->vb2_buf,0 ) + - slice_params->data_byte_offset -1 ; +cedrus_h265_skip_bits (dev, (slice_params->data_byte_offset -1 ) *8 ); + + padding =cedrus_h265_show_bits (dev,8 );/* at least one bit must be set in that byte */ -if (*padding ==0 ) +if (padding ==0 )return -EINVAL ;for (count =0 ; count <8 ; count++) -if (*padding & (1 << count)) +if (padding & (1 << count))break ;/* Include the one bit. */ count++; -cedrus_h265_skip_bits (dev, slice_params->data_byte_offset *8 - count); +cedrus_h265_skip_bits (dev,8 - count);/* Bitstream parameters. */
drivers/staging/media/sunxi/cedrus/cedrus_regs.h +2 -0
@@ -505,6 +505,8 @@#define VE_DEC_H265_LOW_ADDR_ENTRY_POINTS_BUF (a) \ SHIFT_AND_MASK_BITS(a, 7, 0) +#define VE_DEC_H265_BITS_READ (VE_ENGINE_DEC_H265 + 0xdc) +#define VE_DEC_H265_SRAM_OFFSET (VE_ENGINE_DEC_H265 + 0xe0)#define VE_DEC_H265_SRAM_OFFSET_PRED_WEIGHT_LUMA_L0 0x00
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 235/1146 media: mediatek: vcodec: fix h264 cavlc bitstream fail
In reply to Greg Kroah-HartmanFrom: Yunfei Dong <[email protected]>
[ Upstream commit d555409dd1b7cc9e7e5b9e2924c0ef4bf23f6c9b ]
Some cavlc bistream will decode fail when the frame size is less than 20 bytes. Need to add pending data at the end of the bitstream.
For the minimum size of mapped memory is 256 bytes(16x16), adding four bytes data won't lead to access unknown virtual memory.
--- .../vcodec/vdec/vdec_h264_req_multi_if.c | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-)
drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c +29 -3
@@ -539,6 +539,29 @@ static int vdec_h264_slice_core_decode(struct vdec_lat_buf *lat_buf)return 0 ; } +static void vdec_h264_insert_startcode (struct mtk_vcodec_dev *vcodec_dev,unsigned char *buf, +size_t *bs_size,struct mtk_h264_pps_param *pps) +{ +struct device *dev = &vcodec_dev->plat_dev->dev; + +/* Need to add pending data at the end of bitstream when bs_sz is small than +* 20 bytes for cavlc bitstream, or lat will decode fail. This pending data is +* useful for mt8192 and mt8195 platform. +* +* cavlc bitstream when entropy_coding_mode_flag is false. +*/ +if (pps->entropy_coding_mode_flag || *bs_size >20 || + !(of_device_is_compatible (dev->of_node,"mediatek,mt8192-vcodec-dec" ) || +of_device_is_compatible (dev->of_node,"mediatek,mt8195-vcodec-dec" ))) +return ; + + buf[*bs_size] =0 ; + buf[*bs_size +1 ] =0 ; + buf[*bs_size +2 ] =1 ; + buf[*bs_size +3 ] =0xff ; + (*bs_size) +=4 ; +} +static int vdec_h264_slice_lat_decode (void *h_vdec,struct mtk_vcodec_mem *bs,struct vdec_fb *fb,bool *res_chg) {
@@ -582,9 +605,6 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs, } inst->vsi->dec.nal_info = buf[nal_start_idx]; - inst->vsi->dec.bs_buf_addr = (u64 )bs->dma_addr; - inst->vsi->dec.bs_buf_size = bs->size; - lat_buf->src_buf_req = src_buf_info->m2m_buf.vb.vb2_buf.req_obj.req;v4l2_m2m_buf_copy_metadata (&src_buf_info->m2m_buf.vb, &lat_buf->ts_info, true);
@@ -592,6 +612,12 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,if (err) goto err_free_fb_out; +vdec_h264_insert_startcode (inst->ctx->dev, buf, &bs->size, + &share_info->h264_slice_params.pps); + + inst->vsi->dec.bs_buf_addr = (uint64_t )bs->dma_addr; + inst->vsi->dec.bs_buf_size = bs->size; + *res_chg = inst->resolution_changed;if (inst->resolution_changed) {mtk_vcodec_debug (inst,"- resolution changed -" );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 236/1146 drm/i915/guc: Limit scheduling properties to avoid overflow
In reply to Greg Kroah-HartmanFrom: John Harrison <[email protected]>
[ Upstream commit 568944af44e7538ed5d1389dabf56e938afdaf4f ]
GuC converts the pre-emption timeout and timeslice quantum values into clock ticks internally. That significantly reduces the point of 32bit overflow. On current platforms, worst case scenario is approximately 110 seconds. Rather than allowing the user to set higher values and then get confused by early timeouts, add limits when setting these values.
v2: Add helper functions for clamping (review feedback from Tvrtko).
v3: Add a bunch of BUG_ON range checks in addition to the checks already in the clamping functions (Tvrtko)
Stable-dep-of: c3bd49cd9a10 ("drm/i915: Fix compute pre-emption w/a to apply to compute engines")
--- drivers/gpu/drm/i915/gt/intel_engine.h | 6 ++ drivers/gpu/drm/i915/gt/intel_engine_cs.c | 69 +++++++++++++++++++ drivers/gpu/drm/i915/gt/sysfs_engines.c | 25 ++++--- drivers/gpu/drm/i915/gt/uc/intel_guc_fwif.h | 21 ++++++ .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 8 +++ 5 files changed, 119 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine.h +6 -0
@@ -348,4 +348,10 @@ intel_engine_get_hung_context(struct intel_engine_cs *engine) return engine->hung_ce; } +u64 intel_clamp_heartbeat_interval_ms (struct intel_engine_cs *engine,u64 value); +u64 intel_clamp_max_busywait_duration_ns (struct intel_engine_cs *engine,u64 value); +u64 intel_clamp_preempt_timeout_ms (struct intel_engine_cs *engine,u64 value); +u64 intel_clamp_stop_timeout_ms (struct intel_engine_cs *engine,u64 value); +u64 intel_clamp_timeslice_duration_ms (struct intel_engine_cs *engine,u64 value); +#endif /* _INTEL_RINGBUFFER_H_ */
drivers/gpu/drm/i915/gt/intel_engine_cs.c +69 -0
81 lines not on this page · raw message
drivers/gpu/drm/i915/gt/sysfs_engines.c +15 -10
@@ -144,7 +144,7 @@ max_spin_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) {struct intel_engine_cs *engine =kobj_to_engine (kobj); -unsigned long long duration; +unsigned long long duration, clamped;int err;/*
@@ -168,7 +168,8 @@ max_spin_store(struct kobject *kobj, struct kobj_attribute *attr,if (err)return err; -if (duration >jiffies_to_nsecs (2 )) + clamped =intel_clamp_max_busywait_duration_ns (engine, duration); +if (duration != clamped)return -EINVAL ;WRITE_ONCE (engine->props.max_busywait_duration_ns, duration);
@@ -203,7 +204,7 @@ timeslice_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) {struct intel_engine_cs *engine =kobj_to_engine (kobj); -unsigned long long duration; +unsigned long long duration, clamped;int err;/*
@@ -218,7 +219,8 @@ timeslice_store(struct kobject *kobj, struct kobj_attribute *attr,if (err)return err; -if (duration >jiffies_to_msecs (MAX_SCHEDULE_TIMEOUT )) + clamped =intel_clamp_timeslice_duration_ms (engine, duration); +if (duration != clamped)return -EINVAL ;WRITE_ONCE (engine->props.timeslice_duration_ms, duration);
@@ -256,7 +258,7 @@ stop_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) {struct intel_engine_cs *engine =kobj_to_engine (kobj); -unsigned long long duration; +unsigned long long duration, clamped;int err;/*
@@ -272,7 +274,8 @@ stop_store(struct kobject *kobj, struct kobj_attribute *attr,if (err)return err; -if (duration >jiffies_to_msecs (MAX_SCHEDULE_TIMEOUT )) + clamped =intel_clamp_stop_timeout_ms (engine, duration); +if (duration != clamped)return -EINVAL ;WRITE_ONCE (engine->props.stop_timeout_ms, duration);
@@ -306,7 +309,7 @@ preempt_timeout_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) {struct intel_engine_cs *engine =kobj_to_engine (kobj); -unsigned long long timeout; +unsigned long long timeout, clamped;int err;/*
@@ -322,7 +325,8 @@ preempt_timeout_store(struct kobject *kobj, struct kobj_attribute *attr,if (err)return err; -if (timeout >jiffies_to_msecs (MAX_SCHEDULE_TIMEOUT )) + clamped =intel_clamp_preempt_timeout_ms (engine, timeout); +if (timeout != clamped)return -EINVAL ;WRITE_ONCE (engine->props.preempt_timeout_ms, timeout);
@@ -362,7 +366,7 @@ heartbeat_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) {struct intel_engine_cs *engine =kobj_to_engine (kobj); -unsigned long long delay; +unsigned long long delay, clamped;int err;/*
@@ -379,7 +383,8 @@ heartbeat_store(struct kobject *kobj, struct kobj_attribute *attr,if (err)return err; -if (delay >=jiffies_to_msecs (MAX_SCHEDULE_TIMEOUT )) + clamped =intel_clamp_heartbeat_interval_ms (engine, delay); +if (delay != clamped)return -EINVAL ; err =intel_engine_set_heartbeat (engine, delay);
drivers/gpu/drm/i915/gt/uc/intel_guc_fwif.h +21 -0
@@ -305,6 +305,27 @@ struct guc_update_context_policy {#define GLOBAL_POLICY_DEFAULT_DPC_PROMOTE_TIME_US 500000 +/* +* GuC converts the timeout to clock ticks internally. Different platforms have +* different GuC clocks. Thus, the maximum value before overflow is platform +* dependent. Current worst case scenario is about 110s. So, the spec says to +* limit to 100s to be safe. +*/ +#define GUC_POLICY_MAX_EXEC_QUANTUM_US (100 * 1000 * 1000UL) +#define GUC_POLICY_MAX_PREEMPT_TIMEOUT_US (100 * 1000 * 1000UL) + +static inline u32 guc_policy_max_exec_quantum_ms (void ) +{ +BUILD_BUG_ON (GUC_POLICY_MAX_EXEC_QUANTUM_US >=UINT_MAX ); +return GUC_POLICY_MAX_EXEC_QUANTUM_US /1000 ; +} + +static inline u32 guc_policy_max_preempt_timeout_ms (void ) +{ +BUILD_BUG_ON (GUC_POLICY_MAX_PREEMPT_TIMEOUT_US >=UINT_MAX ); +return GUC_POLICY_MAX_PREEMPT_TIMEOUT_US /1000 ; +} +struct guc_policies {u32 submission_queue_depth[GUC_MAX_ENGINE_CLASSES ];/* In micro seconds. How much time to allow before DPC processing is
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +8 -0
@@ -2429,6 +2429,10 @@ static int guc_context_policy_init_v70(struct intel_context *ce, bool loop)int ret;/* NB: For both of these, zero means disabled. */ +GEM_BUG_ON (overflows_type (engine->props.timeslice_duration_ms *1000 , + execution_quantum)); +GEM_BUG_ON (overflows_type (engine->props.preempt_timeout_ms *1000 , + preemption_timeout)); execution_quantum = engine->props.timeslice_duration_ms *1000 ; preemption_timeout = engine->props.preempt_timeout_ms *1000 ;
@@ -2462,6 +2466,10 @@ static void guc_context_policy_init_v69(struct intel_engine_cs *engine, desc->policy_flags |=CONTEXT_POLICY_FLAG_PREEMPT_TO_IDLE_V69 ;/* NB: For both of these, zero means disabled. */ +GEM_BUG_ON (overflows_type (engine->props.timeslice_duration_ms *1000 , + desc->execution_quantum)); +GEM_BUG_ON (overflows_type (engine->props.preempt_timeout_ms *1000 , + desc->preemption_timeout)); desc->execution_quantum = engine->props.timeslice_duration_ms *1000 ; desc->preemption_timeout = engine->props.preempt_timeout_ms *1000 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 237/1146 drm/i915: Fix compute pre-emption w/a to apply to compute engines
In reply to Greg Kroah-HartmanFrom: John Harrison <[email protected]>
[ Upstream commit c3bd49cd9a1043b963331e7fd874b380bed3f2bd ]
An earlier patch added support for compute engines. However, it missed enabling the anti-pre-emption w/a for the new engine class. So move the 'compute capable' flag earlier and use it for the pre-emption w/a test.
--- drivers/gpu/drm/i915/gt/intel_engine_cs.c | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine_cs.c +12 -12
@@ -486,6 +486,17 @@ static int intel_engine_setup(struct intel_gt *gt, enum intel_engine_id id, engine->logical_mask =BIT (logical_instance);__sprint_engine_name (engine); +if ((engine->class ==COMPUTE_CLASS && !RCS_MASK (engine->gt) && +__ffs (CCS_MASK (engine->gt)) == engine->instance) || + engine->class ==RENDER_CLASS ) + engine->flags |=I915_ENGINE_FIRST_RENDER_COMPUTE ; + +/* features common between engines sharing EUs */ +if (engine->class ==RENDER_CLASS || engine->class ==COMPUTE_CLASS ) { + engine->flags |=I915_ENGINE_HAS_RCS_REG_STATE ; + engine->flags |=I915_ENGINE_HAS_EU_PRIORITY ; + } + engine->props.heartbeat_interval_ms =CONFIG_DRM_I915_HEARTBEAT_INTERVAL ; engine->props.max_busywait_duration_ns =
@@ -498,20 +509,9 @@ static int intel_engine_setup(struct intel_gt *gt, enum intel_engine_id id,CONFIG_DRM_I915_TIMESLICE_DURATION ;/* Override to uninterruptible for OpenCL workloads. */ -if (GRAPHICS_VER (i915) ==12 && engine->class ==RENDER_CLASS ) +if (GRAPHICS_VER (i915) ==12 && (engine->flags &I915_ENGINE_HAS_RCS_REG_STATE )) engine->props.preempt_timeout_ms =0 ; -if ((engine->class ==COMPUTE_CLASS && !RCS_MASK (engine->gt) && -__ffs (CCS_MASK (engine->gt)) == engine->instance) || - engine->class ==RENDER_CLASS ) - engine->flags |=I915_ENGINE_FIRST_RENDER_COMPUTE ; - -/* features common between engines sharing EUs */ -if (engine->class ==RENDER_CLASS || engine->class ==COMPUTE_CLASS ) { - engine->flags |=I915_ENGINE_HAS_RCS_REG_STATE ; - engine->flags |=I915_ENGINE_HAS_EU_PRIORITY ; - } -/* Cap properties according to any system limits */ #define CLAMP_PROP (field) \ do { \
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 238/1146 media: i2c: hi846: Fix memory leak in hi846_parse_dt()
In reply to Greg Kroah-HartmanFrom: Rafael Mendonca <[email protected]>
[ Upstream commit 80113026d415e27483669db7a88b548d1ec3d3d1 ]
If any of the checks related to the supported link frequencies fail, then the V4L2 fwnode resources don't get released before returning, which leads to a memleak. Fix this by properly freeing the V4L2 fwnode data in a designated label.
--- drivers/media/i2c/hi846.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/media/i2c/hi846.c +10 -4
@@ -2008,22 +2008,24 @@ static int hi846_parse_dt(struct hi846 *hi846, struct device *dev) bus_cfg.bus.mipi_csi2.num_data_lanes != 4) {dev_err (dev,"number of CSI2 data lanes %d is not supported" , bus_cfg.bus.mipi_csi2.num_data_lanes); -v4l2_fwnode_endpoint_free (&bus_cfg); -return -EINVAL ; + ret = -EINVAL ; + goto check_hwcfg_error; } hi846->nr_lanes = bus_cfg.bus.mipi_csi2.num_data_lanes;if (!bus_cfg.nr_of_link_frequencies) {dev_err (dev,"link-frequency property not found in DT\n" ); -return -EINVAL ; + ret = -EINVAL ; + goto check_hwcfg_error; }/* Check that link frequences for all the modes are in device tree */ fq =hi846_check_link_freqs (hi846, &bus_cfg);if (fq) {dev_err (dev,"Link frequency of %lld is not supported\n" , fq); -return -EINVAL ; + ret = -EINVAL ; + goto check_hwcfg_error; }v4l2_fwnode_endpoint_free (&bus_cfg);
@@ -2044,6 +2046,10 @@ static int hi846_parse_dt(struct hi846 *hi846, struct device *dev) }return 0 ; + +check_hwcfg_error: +v4l2_fwnode_endpoint_free (&bus_cfg); +return ret; }static int hi846_probe (struct i2c_client *client)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 239/1146 media: i2c: ad5820: Fix error path
In reply to Greg Kroah-HartmanFrom: Ricardo Ribalda <[email protected]>
[ Upstream commit 9fce241660f37d9e95e93c0ae6fba8cfefa5797b ]
Error path seems to be swaped. Fix the order and provide some meaningful names.
--- drivers/media/i2c/ad5820.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/media/i2c/ad5820.c +5 -5
@@ -327,18 +327,18 @@ static int ad5820_probe(struct i2c_client *client, ret =media_entity_pads_init (&coil->subdev.entity,0 ,NULL );if (ret <0 ) - goto cleanup2; + goto clean_mutex; ret =v4l2_async_register_subdev (&coil->subdev);if (ret <0 ) - goto cleanup; + goto clean_entity;return ret; -cleanup2: -mutex_destroy (&coil->power_lock); -cleanup: +clean_entity:media_entity_cleanup (&coil->subdev.entity); +clean_mutex: +mutex_destroy (&coil->power_lock);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 240/1146 venus: pm_helpers: Fix error check in vcodec_domains_get()
In reply to Greg Kroah-HartmanFrom: Tang Bin <[email protected]>
[ Upstream commit 0f6e8d8c94a82e85e1b9b62a7671990740dc6f70 ]
In the function vcodec_domains_get(), dev_pm_domain_attach_by_name() may return NULL in some cases, so IS_ERR() doesn't meet the requirements. Thus fix it.
--- drivers/media/platform/qcom/venus/pm_helpers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/venus/pm_helpers.c +2 -2
@@ -869,8 +869,8 @@ static int vcodec_domains_get(struct venus_core *core)for (i =0 ; i < res->vcodec_pmdomains_num; i++) { pd =dev_pm_domain_attach_by_name (dev, res->vcodec_pmdomains[i]); -if (IS_ERR (pd)) -return PTR_ERR (pd); +if (IS_ERR_OR_NULL (pd)) +return PTR_ERR (pd) ? : -ENODATA ; core->pmdomains[i] = pd; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 241/1146 soreuseport: Fix socket selection for SO_INCOMING_CPU.
In reply to Greg Kroah-HartmanFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit b261eda84ec136240a9ca753389853a3a1bccca2 ]
Kazuho Oku reported that setsockopt(SO_INCOMING_CPU) does not work with setsockopt(SO_REUSEPORT) since v4.6.
With the combination of SO_REUSEPORT and SO_INCOMING_CPU, we could build a highly efficient server application.
setsockopt(SO_INCOMING_CPU) associates a CPU with a TCP listener or UDP socket, and then incoming packets processed on the CPU will likely be distributed to the socket. Technically, a socket could even receive packets handled on another CPU if no sockets in the reuseport group have the same CPU receiving the flow.
The logic exists in compute_score() so that a socket will get a higher score if it has the same CPU with the flow. However, the score gets ignored after the blamed two commits, which introduced a faster socket selection algorithm for SO_REUSEPORT.
This patch introduces a counter of sockets with SO_INCOMING_CPU in a reuseport group to check if we should iterate all sockets to find a proper one. We increment the counter when
* calling listen() if the socket has SO_INCOMING_CPU and SO_REUSEPORT
* enabling SO_INCOMING_CPU if the socket is in a reuseport group
Also, we decrement it when
* detaching a socket out of the group to apply SO_INCOMING_CPU to migrated TCP requests
* disabling SO_INCOMING_CPU if the socket is in a reuseport group
When the counter reaches 0, we can get back to the O(1) selection algorithm.
The overall changes are negligible for the non-SO_INCOMING_CPU case, and the only notable thing is that we have to update sk_incomnig_cpu under reuseport_lock. Otherwise, the race prevents transitioning to the O(n) algorithm and results in the wrong socket selection.
cpu1 (setsockopt) cpu2 (listen)
+-----------------+ +-------------+
lock_sock(sk1) lock_sock(sk2)
reuseport_update_incoming_cpu(sk1, val)
.
| /* set CPU as 0 */ |- WRITE_ONCE(sk1->incoming_cpu, val) | | spin_lock_bh(&reuseport_lock) | reuseport_grow(sk2, reuse) | . | |- more_socks_size = reuse->max_socks * 2U; | |- if (more_socks_size > U16_MAX && | | reuse->num_closed_socks) | | . | | |- RCU_INIT_POINTER(sk1->sk_reuseport_cb, NULL); | | `- __reuseport_detach_closed_sock(sk1, reuse) | | . | | `- reuseport_put_incoming_cpu(sk1, reuse) | | . | | | /* Read shutdown()ed sk1's sk_incoming_cpu | | | * without lock_sock(). | | | */ | | `- if (sk1->sk_incoming_cpu >= 0) | | . | | | /* decrement not-yet-incremented | | | * count, which is never incremented. | | | */ | | `- __reuseport_put_incoming_cpu(reuse); | | | `- spin_lock_bh(&reuseport_lock) | |- spin_lock_bh(&reuseport_lock) | |- reuse = rcu_dereference_protected(sk1->sk_reuseport_cb, ...) |- if (!reuse) | . | | /* Cannot increment reuse->incoming_cpu. */ | `- goto out; |
`- spin_unlock_bh(&reuseport_lock)
--- include/net/sock_reuseport.h | 2 + net/core/sock.c | 2 +- net/core/sock_reuseport.c | 94 ++++++++++++++++++++++++++++++++++-- 3 files changed, 92 insertions(+), 6 deletions(-)
include/net/sock_reuseport.h +2 -0
@@ -16,6 +16,7 @@ struct sock_reuseport {u16 max_socks;/* length of socks */ u16 num_socks;/* elements in socks */ u16 num_closed_socks;/* closed elements in socks */ +u16 incoming_cpu;/* The last synq overflow event timestamp of this * reuse->socks[] group. */
@@ -58,5 +59,6 @@ static inline bool reuseport_has_conns(struct sock *sk) }void reuseport_has_conns_set (struct sock *sk); +void reuseport_update_incoming_cpu (struct sock *sk,int val);#endif /* _SOCK_REUSEPORT_H */
net/core/sock.c +1 -1
@@ -1436,7 +1436,7 @@ int sk_setsockopt(struct sock *sk, int level, int optname,break ; }case SO_INCOMING_CPU : -WRITE_ONCE (sk->sk_incoming_cpu, val); +reuseport_update_incoming_cpu (sk, val);break ;case SO_CNX_ADVICE :
net/core/sock_reuseport.c +89 -5
149 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 242/1146 media: i2c: ov5648: Free V4L2 fwnode data on unbind
In reply to Greg Kroah-HartmanFrom: Rafael Mendonca <[email protected]>
[ Upstream commit c95770e4fc172696dcb1450893cda7d6324d96fc ]
The V4L2 fwnode data structure doesn't get freed on unbind, which leads to a memleak.
--- drivers/media/i2c/ov5648.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/i2c/ov5648.c +1 -0
@@ -2597,6 +2597,7 @@ static void ov5648_remove(struct i2c_client *client)v4l2_ctrl_handler_free (&sensor->ctrls.handler);mutex_destroy (&sensor->mutex);media_entity_cleanup (&subdev->entity); +v4l2_fwnode_endpoint_free (&sensor->endpoint); }static const struct dev_pm_ops ov5648_pm_ops = {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 243/1146 media: exynos4-is: dont rely on the v4l2_async_subdev internals
In reply to Greg Kroah-HartmanFrom: Marek Szyprowski <[email protected]>
[ Upstream commit f98a5c2e1c4396488c27274ba82afc11725a4bcc ]
Commit 1f391df44607 ("media: v4l2-async: Use endpoints in __v4l2_async_nf_add_fwnode_remote()") changed the data that is stored in the v4l2_async_subdev internals from the fwnode pointer to the parent device to the fwnode pointer to the matched endpoint. This broke the sensor matching code, which relied on the particular fwnode data in the v4l2_async_subdev internals. Fix this by simply matching the v4l2_async_subdev pointer, which is already available there.
--- drivers/media/platform/samsung/exynos4-is/media-dev.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/media/platform/samsung/exynos4-is/media-dev.c +1 -3
@@ -1380,9 +1380,7 @@ static int subdev_notifier_bound(struct v4l2_async_notifier *notifier,/* Find platform data for this sensor subdev */ for (i =0 ; i <ARRAY_SIZE (fmd->sensor); i++) -if (fmd->sensor[i].asd && - fmd->sensor[i].asd->match.fwnode == -of_fwnode_handle (subdev->dev->of_node)) +if (fmd->sensor[i].asd == asd) si = &fmd->sensor[i];if (si ==NULL )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 244/1146 libbpf: Btf dedup identical struct test needs check for nested structs/arrays
In reply to Greg Kroah-HartmanFrom: Alan Maguire <[email protected]>
[ Upstream commit f3c51fe02c55bd944662714e5b91b96dc271ad9f ]
When examining module BTF, it is common to see core kernel structures such as sk_buff, net_device duplicated in the module. After adding debug messaging to BTF it turned out that much of the problem was down to the identical struct test failing during deduplication; sometimes the compiler adds identical structs. However
it turns out sometimes that type ids of identical struct members can also differ, even when the containing structs are still identical.
To take an example, for struct sk_buff, debug messaging revealed that the identical struct matching was failing for the anon struct "headers"; specifically for the first field:
__u8 __pkt_type_offset[0]; /* 128 0 */
Looking at the code in BTF deduplication, we have code that guards against the possibility of identical struct definitions, down to type ids, and identical array definitions. However in this case we have a struct which is being defined twice but does not have identical type ids since each duplicate struct has separate type
ids for the above array member. A similar problem (though not
observed) could occur for struct-in-struct.
The solution is to make the "identical struct" test check members not just for matching ids, but to also check if they in turn are identical structs or arrays.
The results of doing this are quite dramatic (for some modules at least); I see the number of type ids drop from around 10000 to just over 1000 in one module for example.
For testing use latest pahole or apply [1], otherwise dedups can fail for the reasons described there.
Also fix return type of btf_dedup_identical_arrays() as suggested by Andrii to match boolean return type used elsewhere.
[1] https://lore.kernel.org/bpf/1666364523-9648-1-git-send-email-alan.maguire
--- tools/lib/bpf/btf.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
tools/lib/bpf/btf.c +5 -3
@@ -3887,14 +3887,14 @@ static inline __u16 btf_fwd_kind(struct btf_type *t) }/* Check if given two types are identical ARRAY definitions */ -static int btf_dedup_identical_arrays (struct btf_dedup *d,__u32 id1,__u32 id2) +static bool btf_dedup_identical_arrays (struct btf_dedup *d,__u32 id1,__u32 id2) {struct btf_type *t1, *t2; t1 =btf_type_by_id (d->btf, id1); t2 =btf_type_by_id (d->btf, id2);if (!btf_is_array (t1) || !btf_is_array (t2)) -return 0 ; +return false;return btf_equal_array (t1, t2); }
@@ -3918,7 +3918,9 @@ static bool btf_dedup_identical_structs(struct btf_dedup *d, __u32 id1, __u32 id m1 =btf_members (t1); m2 =btf_members (t2);for (i =0 , n =btf_vlen (t1); i < n; i++, m1++, m2++) { -if (m1->type != m2->type) +if (m1->type != m2->type && + !btf_dedup_identical_arrays (d, m1->type, m2->type) && + !btf_dedup_identical_structs (d, m1->type, m2->type))return false; }return true;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 245/1146 can: kvaser_usb: kvaser_usb_leaf: Get capabilities from device
In reply to Greg Kroah-HartmanFrom: Jimmy Assarsson <[email protected]>
[ Upstream commit 35364f5b41a4917fe94a3f393d149b63ec583297 ]
Use the CMD_GET_CAPABILITIES_REQ command to query the device for certain capabilities. We are only interested in LISTENONLY mode and wither the device reports CAN error counters.
--- .../net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 144 +++++++++++++++++- 1 file changed, 143 insertions(+), 1 deletion(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +143 -1
@@ -74,6 +74,8 @@#define CMD_TX_ACKNOWLEDGE 50#define CMD_CAN_ERROR_EVENT 51#define CMD_FLUSH_QUEUE_REPLY 68 +#define CMD_GET_CAPABILITIES_REQ 95 +#define CMD_GET_CAPABILITIES_RESP 96#define CMD_LEAF_LOG_MESSAGE 106
@@ -83,6 +85,8 @@#define KVASER_USB_LEAF_SWOPTION_FREQ_32_MHZ_CLK BIT(5)#define KVASER_USB_LEAF_SWOPTION_FREQ_24_MHZ_CLK BIT(6) +#define KVASER_USB_LEAF_SWOPTION_EXT_CAP BIT(12) +/* error factors */ #define M16C_EF_ACKE BIT(0)#define M16C_EF_CRCE BIT(1)
@@ -278,6 +282,28 @@ struct leaf_cmd_log_message {u8 data[8 ]; } __packed; +/* Sub commands for cap_req and cap_res */ +#define KVASER_USB_LEAF_CAP_CMD_LISTEN_MODE 0x02 +#define KVASER_USB_LEAF_CAP_CMD_ERR_REPORT 0x05 +struct kvaser_cmd_cap_req { +__le16 padding0; +__le16 cap_cmd; +__le16 padding1; +__le16 channel; +} __packed; + +/* Status codes for cap_res */ +#define KVASER_USB_LEAF_CAP_STAT_OK 0x00 +#define KVASER_USB_LEAF_CAP_STAT_NOT_IMPL 0x01 +#define KVASER_USB_LEAF_CAP_STAT_UNAVAIL 0x02 +struct kvaser_cmd_cap_res { +__le16 padding; +__le16 cap_cmd; +__le16 status; +__le32 mask; +__le32 value; +} __packed; +struct kvaser_cmd {u8 len;u8 id;
@@ -295,6 +321,8 @@ struct kvaser_cmd {struct leaf_cmd_chip_state_event chip_state_event;struct leaf_cmd_error_event error_event;struct leaf_cmd_log_message log_message; +struct kvaser_cmd_cap_req cap_req; +struct kvaser_cmd_cap_res cap_res; }__packed leaf;union {
@@ -324,6 +352,7 @@ static const u8 kvaser_usb_leaf_cmd_sizes_leaf[] = { [CMD_LEAF_LOG_MESSAGE] = kvaser_fsize(u.leaf.log_message), [CMD_CHIP_STATE_EVENT] = kvaser_fsize(u.leaf.chip_state_event), [CMD_CAN_ERROR_EVENT] = kvaser_fsize(u.leaf.error_event), + [CMD_GET_CAPABILITIES_RESP] = kvaser_fsize(u.leaf.cap_res),/* ignored events: */ [CMD_FLUSH_QUEUE_REPLY] = CMD_SIZE_ANY, };
@@ -606,6 +635,9 @@ static void kvaser_usb_leaf_get_software_info_leaf(struct kvaser_usb *dev, dev->fw_version =le32_to_cpu (softinfo->fw_version); dev->max_tx_urbs =le16_to_cpu (softinfo->max_outstanding_tx); +if (sw_options &KVASER_USB_LEAF_SWOPTION_EXT_CAP ) + dev->card_data.capabilities |=KVASER_USB_CAP_EXT_CAP ; +if (dev->driver_info->quirks &KVASER_USB_QUIRK_IGNORE_CLK_FREQ ) {/* Firmware expects bittiming parameters calculated for 16MHz * clock, regardless of the actual clock
@@ -693,6 +725,116 @@ static int kvaser_usb_leaf_get_card_info(struct kvaser_usb *dev)return 0 ; } +static int kvaser_usb_leaf_get_single_capability (struct kvaser_usb *dev, +u16 cap_cmd_req,u16 *status) +{ +struct kvaser_usb_dev_card_data *card_data = &dev->card_data; +struct kvaser_cmd *cmd; +u32 value =0 ; +u32 mask =0 ; +u16 cap_cmd_res; +int err; +int i; + + cmd =kzalloc (sizeof (*cmd),GFP_KERNEL ); +if (!cmd) +return -ENOMEM ; + + cmd->id =CMD_GET_CAPABILITIES_REQ ; + cmd->u.leaf.cap_req.cap_cmd =cpu_to_le16 (cap_cmd_req); + cmd->len =CMD_HEADER_LEN +sizeof (struct kvaser_cmd_cap_req ); + + err =kvaser_usb_send_cmd (dev, cmd, cmd->len); +if (err) + goto end; + + err =kvaser_usb_leaf_wait_cmd (dev,CMD_GET_CAPABILITIES_RESP , cmd); +if (err) + goto end; + + *status =le16_to_cpu (cmd->u.leaf.cap_res.status); + +if (*status !=KVASER_USB_LEAF_CAP_STAT_OK ) + goto end; + + cap_cmd_res =le16_to_cpu (cmd->u.leaf.cap_res.cap_cmd); +switch (cap_cmd_res) { +case KVASER_USB_LEAF_CAP_CMD_LISTEN_MODE : +case KVASER_USB_LEAF_CAP_CMD_ERR_REPORT : + value =le32_to_cpu (cmd->u.leaf.cap_res.value); + mask =le32_to_cpu (cmd->u.leaf.cap_res.mask); +break ; +default : +dev_warn (&dev->intf->dev,"Unknown capability command %u\n" , + cap_cmd_res); +break ; + } + +for (i =0 ; i < dev->nchannels; i++) { +if (BIT (i) & (value & mask)) { +switch (cap_cmd_res) { +case KVASER_USB_LEAF_CAP_CMD_LISTEN_MODE : + card_data->ctrlmode_supported |= +CAN_CTRLMODE_LISTENONLY ; +break ; +case KVASER_USB_LEAF_CAP_CMD_ERR_REPORT : + card_data->capabilities |= +KVASER_USB_CAP_BERR_CAP ; +break ; + } + } + } + +end: +kfree (cmd); + +return err; +} + +static int kvaser_usb_leaf_get_capabilities_leaf (struct kvaser_usb *dev) +{ +int err; +u16 status; + +if (!(dev->card_data.capabilities &KVASER_USB_CAP_EXT_CAP )) { +dev_info (&dev->intf->dev, +"No extended capability support. Upgrade device firmware.\n" ); +return 0 ; + } + + err =kvaser_usb_leaf_get_single_capability (dev, +KVASER_USB_LEAF_CAP_CMD_LISTEN_MODE , + &status); +if (err) +return err; +if (status) +dev_info (&dev->intf->dev, +"KVASER_USB_LEAF_CAP_CMD_LISTEN_MODE failed %u\n" , + status); + + err =kvaser_usb_leaf_get_single_capability (dev, +KVASER_USB_LEAF_CAP_CMD_ERR_REPORT , + &status); +if (err) +return err; +if (status) +dev_info (&dev->intf->dev, +"KVASER_USB_LEAF_CAP_CMD_ERR_REPORT failed %u\n" , + status); + +return 0 ; +} + +static int kvaser_usb_leaf_get_capabilities (struct kvaser_usb *dev) +{ +int err =0 ; + +if (dev->driver_info->family ==KVASER_LEAF ) + err =kvaser_usb_leaf_get_capabilities_leaf (dev); + +return err; +} +static void kvaser_usb_leaf_tx_acknowledge (const struct kvaser_usb *dev,const struct kvaser_cmd *cmd) {
@@ -1486,7 +1628,7 @@ const struct kvaser_usb_dev_ops kvaser_usb_leaf_dev_ops = { .dev_get_software_info = kvaser_usb_leaf_get_software_info, .dev_get_software_details = NULL, .dev_get_card_info = kvaser_usb_leaf_get_card_info, - .dev_get_capabilities = NULL, + .dev_get_capabilities = kvaser_usb_leaf_get_capabilities, .dev_set_opt_mode = kvaser_usb_leaf_set_opt_mode, .dev_start_chip = kvaser_usb_leaf_start_chip, .dev_stop_chip = kvaser_usb_leaf_stop_chip,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 246/1146 can: kvaser_usb: kvaser_usb_leaf: Rename {leaf,usbcan}_cmd_error_event to {leaf,usbcan}_cmd_can_error_event
In reply to Greg Kroah-HartmanFrom: Jimmy Assarsson <[email protected]>
[ Upstream commit 7ea56128dbf904a3359bcf9289cccdfa3c85c7e8 ]
Prepare for handling CMD_ERROR_EVENT. Rename struct {leaf,usbcan}_cmd_error_event to {leaf,usbcan}_cmd_can_error_event.
--- .../net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +19 -19
@@ -234,7 +234,7 @@ struct kvaser_cmd_tx_acknowledge_header {u8 tid; } __packed; -struct leaf_cmd_error_event { +struct leaf_cmd_can_error_event {u8 tid;u8 flags;__le16 time[3 ];
@@ -246,7 +246,7 @@ struct leaf_cmd_error_event {u8 error_factor; } __packed; -struct usbcan_cmd_error_event { +struct usbcan_cmd_can_error_event {u8 tid;u8 padding;u8 tx_errors_count_ch0;
@@ -319,7 +319,7 @@ struct kvaser_cmd {struct leaf_cmd_softinfo softinfo;struct leaf_cmd_rx_can rx_can;struct leaf_cmd_chip_state_event chip_state_event; -struct leaf_cmd_error_event error_event; +struct leaf_cmd_can_error_event can_error_event;struct leaf_cmd_log_message log_message;struct kvaser_cmd_cap_req cap_req;struct kvaser_cmd_cap_res cap_res;
@@ -329,7 +329,7 @@ struct kvaser_cmd {struct usbcan_cmd_softinfo softinfo;struct usbcan_cmd_rx_can rx_can;struct usbcan_cmd_chip_state_event chip_state_event; -struct usbcan_cmd_error_event error_event; +struct usbcan_cmd_can_error_event can_error_event; }__packed usbcan;struct kvaser_cmd_tx_can tx_can;
@@ -351,7 +351,7 @@ static const u8 kvaser_usb_leaf_cmd_sizes_leaf[] = { [CMD_RX_EXT_MESSAGE] = kvaser_fsize(u.leaf.rx_can), [CMD_LEAF_LOG_MESSAGE] = kvaser_fsize(u.leaf.log_message), [CMD_CHIP_STATE_EVENT] = kvaser_fsize(u.leaf.chip_state_event), - [CMD_CAN_ERROR_EVENT] = kvaser_fsize(u.leaf.error_event), + [CMD_CAN_ERROR_EVENT] = kvaser_fsize(u.leaf.can_error_event), [CMD_GET_CAPABILITIES_RESP] = kvaser_fsize(u.leaf.cap_res),/* ignored events: */ [CMD_FLUSH_QUEUE_REPLY] = CMD_SIZE_ANY,
@@ -366,7 +366,7 @@ static const u8 kvaser_usb_leaf_cmd_sizes_usbcan[] = { [CMD_RX_STD_MESSAGE] = kvaser_fsize(u.usbcan.rx_can), [CMD_RX_EXT_MESSAGE] = kvaser_fsize(u.usbcan.rx_can), [CMD_CHIP_STATE_EVENT] = kvaser_fsize(u.usbcan.chip_state_event), - [CMD_CAN_ERROR_EVENT] = kvaser_fsize(u.usbcan.error_event), + [CMD_CAN_ERROR_EVENT] = kvaser_fsize(u.usbcan.can_error_event),/* ignored events: */ [CMD_USBCAN_CLOCK_OVERFLOW_EVENT] = CMD_SIZE_ANY, };
@@ -1132,11 +1132,11 @@ static void kvaser_usb_leaf_usbcan_rx_error(const struct kvaser_usb *dev,case CMD_CAN_ERROR_EVENT : es.channel =0 ; - es.status = cmd->u.usbcan.error_event.status_ch0; - es.txerr = cmd->u.usbcan.error_event.tx_errors_count_ch0; - es.rxerr = cmd->u.usbcan.error_event.rx_errors_count_ch0; + es.status = cmd->u.usbcan.can_error_event.status_ch0; + es.txerr = cmd->u.usbcan.can_error_event.tx_errors_count_ch0; + es.rxerr = cmd->u.usbcan.can_error_event.rx_errors_count_ch0; es.usbcan.other_ch_status = - cmd->u.usbcan.error_event.status_ch1; + cmd->u.usbcan.can_error_event.status_ch1;kvaser_usb_leaf_usbcan_conditionally_rx_error (dev, &es);/* The USBCAN firmware supports up to 2 channels.
@@ -1144,13 +1144,13 @@ static void kvaser_usb_leaf_usbcan_rx_error(const struct kvaser_usb *dev,*/ if (dev->nchannels ==MAX_USBCAN_NET_DEVICES ) { es.channel =1 ; - es.status = cmd->u.usbcan.error_event.status_ch1; + es.status = cmd->u.usbcan.can_error_event.status_ch1; es.txerr = - cmd->u.usbcan.error_event.tx_errors_count_ch1; + cmd->u.usbcan.can_error_event.tx_errors_count_ch1; es.rxerr = - cmd->u.usbcan.error_event.rx_errors_count_ch1; + cmd->u.usbcan.can_error_event.rx_errors_count_ch1; es.usbcan.other_ch_status = - cmd->u.usbcan.error_event.status_ch0; + cmd->u.usbcan.can_error_event.status_ch0;kvaser_usb_leaf_usbcan_conditionally_rx_error (dev, &es); }break ;
@@ -1167,11 +1167,11 @@ static void kvaser_usb_leaf_leaf_rx_error(const struct kvaser_usb *dev,switch (cmd->id) {case CMD_CAN_ERROR_EVENT : - es.channel = cmd->u.leaf.error_event.channel; - es.status = cmd->u.leaf.error_event.status; - es.txerr = cmd->u.leaf.error_event.tx_errors_count; - es.rxerr = cmd->u.leaf.error_event.rx_errors_count; - es.leaf.error_factor = cmd->u.leaf.error_event.error_factor; + es.channel = cmd->u.leaf.can_error_event.channel; + es.status = cmd->u.leaf.can_error_event.status; + es.txerr = cmd->u.leaf.can_error_event.tx_errors_count; + es.rxerr = cmd->u.leaf.can_error_event.rx_errors_count; + es.leaf.error_factor = cmd->u.leaf.can_error_event.error_factor;break ;case CMD_LEAF_LOG_MESSAGE : es.channel = cmd->u.leaf.log_message.channel;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 247/1146 can: kvaser_usb: kvaser_usb_leaf: Handle CMD_ERROR_EVENT
In reply to Greg Kroah-HartmanFrom: Jimmy Assarsson <[email protected]>
[ Upstream commit b24cb2d169e0c9dce664a959e1f2aa9781285dc9 ]
The device will send an error event command, to indicate certain errors. This indicates a misbehaving driver, and should never occur.
--- .../net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+)
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +99 -0
@@ -70,6 +70,7 @@#define CMD_GET_CARD_INFO_REPLY 35#define CMD_GET_SOFTWARE_INFO 38#define CMD_GET_SOFTWARE_INFO_REPLY 39 +#define CMD_ERROR_EVENT 45#define CMD_FLUSH_QUEUE 48#define CMD_TX_ACKNOWLEDGE 50#define CMD_CAN_ERROR_EVENT 51
@@ -258,6 +259,28 @@ struct usbcan_cmd_can_error_event {__le16 time; } __packed; +/* CMD_ERROR_EVENT error codes */ +#define KVASER_USB_LEAF_ERROR_EVENT_TX_QUEUE_FULL 0x8 +#define KVASER_USB_LEAF_ERROR_EVENT_PARAM 0x9 + +struct leaf_cmd_error_event { +u8 tid; +u8 error_code; +__le16 timestamp[3 ]; +__le16 padding; +__le16 info1; +__le16 info2; +} __packed; + +struct usbcan_cmd_error_event { +u8 tid; +u8 error_code; +__le16 info1; +__le16 info2; +__le16 timestamp; +__le16 padding; +} __packed; +struct kvaser_cmd_ctrl_mode {u8 tid;u8 channel;
@@ -321,6 +344,7 @@ struct kvaser_cmd {struct leaf_cmd_chip_state_event chip_state_event;struct leaf_cmd_can_error_event can_error_event;struct leaf_cmd_log_message log_message; +struct leaf_cmd_error_event error_event;struct kvaser_cmd_cap_req cap_req;struct kvaser_cmd_cap_res cap_res; }__packed leaf;
@@ -330,6 +354,7 @@ struct kvaser_cmd {struct usbcan_cmd_rx_can rx_can;struct usbcan_cmd_chip_state_event chip_state_event;struct usbcan_cmd_can_error_event can_error_event; +struct usbcan_cmd_error_event error_event; }__packed usbcan;struct kvaser_cmd_tx_can tx_can;
@@ -353,6 +378,7 @@ static const u8 kvaser_usb_leaf_cmd_sizes_leaf[] = { [CMD_CHIP_STATE_EVENT] = kvaser_fsize(u.leaf.chip_state_event), [CMD_CAN_ERROR_EVENT] = kvaser_fsize(u.leaf.can_error_event), [CMD_GET_CAPABILITIES_RESP] = kvaser_fsize(u.leaf.cap_res), + [CMD_ERROR_EVENT] = kvaser_fsize(u.leaf.error_event),/* ignored events: */ [CMD_FLUSH_QUEUE_REPLY] = CMD_SIZE_ANY, };
@@ -367,6 +393,7 @@ static const u8 kvaser_usb_leaf_cmd_sizes_usbcan[] = { [CMD_RX_EXT_MESSAGE] = kvaser_fsize(u.usbcan.rx_can), [CMD_CHIP_STATE_EVENT] = kvaser_fsize(u.usbcan.chip_state_event), [CMD_CAN_ERROR_EVENT] = kvaser_fsize(u.usbcan.can_error_event), + [CMD_ERROR_EVENT] = kvaser_fsize(u.usbcan.error_event),/* ignored events: */ [CMD_USBCAN_CLOCK_OVERFLOW_EVENT] = CMD_SIZE_ANY, };
@@ -1304,6 +1331,74 @@ static void kvaser_usb_leaf_rx_can_msg(const struct kvaser_usb *dev,netif_rx (skb); } +static void kvaser_usb_leaf_error_event_parameter (const struct kvaser_usb *dev, +const struct kvaser_cmd *cmd) +{ +u16 info1 =0 ; + +switch (dev->driver_info->family) { +case KVASER_LEAF : + info1 =le16_to_cpu (cmd->u.leaf.error_event.info1); +break ; +case KVASER_USBCAN : + info1 =le16_to_cpu (cmd->u.usbcan.error_event.info1); +break ; + } + +/* info1 will contain the offending cmd_no */ +switch (info1) { +case CMD_SET_CTRL_MODE : +dev_warn (&dev->intf->dev, +"CMD_SET_CTRL_MODE error in parameter\n" ); +break ; + +case CMD_SET_BUS_PARAMS : +dev_warn (&dev->intf->dev, +"CMD_SET_BUS_PARAMS error in parameter\n" ); +break ; + +default : +dev_warn (&dev->intf->dev, +"Unhandled parameter error event cmd_no (%u)\n" , + info1); +break ; + } +} + +static void kvaser_usb_leaf_error_event (const struct kvaser_usb *dev, +const struct kvaser_cmd *cmd) +{ +u8 error_code =0 ; + +switch (dev->driver_info->family) { +case KVASER_LEAF : + error_code = cmd->u.leaf.error_event.error_code; +break ; +case KVASER_USBCAN : + error_code = cmd->u.usbcan.error_event.error_code; +break ; + } + +switch (error_code) { +case KVASER_USB_LEAF_ERROR_EVENT_TX_QUEUE_FULL : +/* Received additional CAN message, when firmware TX queue is +* already full. Something is wrong with the driver. +* This should never happen! +*/ +dev_err (&dev->intf->dev, +"Received error event TX_QUEUE_FULL\n" ); +break ; +case KVASER_USB_LEAF_ERROR_EVENT_PARAM : +kvaser_usb_leaf_error_event_parameter (dev, cmd); +break ; + +default : +dev_warn (&dev->intf->dev, +"Unhandled error event (%d)\n" , error_code); +break ; + } +} +static void kvaser_usb_leaf_start_chip_reply (const struct kvaser_usb *dev,const struct kvaser_cmd *cmd) {
@@ -1382,6 +1477,10 @@ static void kvaser_usb_leaf_handle_command(const struct kvaser_usb *dev,kvaser_usb_leaf_tx_acknowledge (dev, cmd);break ; +case CMD_ERROR_EVENT : +kvaser_usb_leaf_error_event (dev, cmd); +break ; +/* Ignored commands */ case CMD_USBCAN_CLOCK_OVERFLOW_EVENT :if (dev->driver_info->family !=KVASER_USBCAN )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 248/1146 can: kvaser_usb_leaf: Set Warning state even without bus errors
In reply to Greg Kroah-HartmanFrom: Anssi Hannula <[email protected]>
[ Upstream commit df1b7af2761b935f63b4a53e789d41ed859edf61 ]
kvaser_usb_leaf_rx_error_update_can_state() sets error state according to error counters when the hardware does not indicate a specific state directly.
However, this is currently gated behind a check for M16C_STATE_BUS_ERROR which does not always seem to be set when error counters are increasing, and may not be set when error counters are decreasing.
This causes the CAN_STATE_ERROR_WARNING state to not be set in some cases even when appropriate.
Change the code to set error state from counters even without M16C_STATE_BUS_ERROR.
The Error-Passive case seems superfluous as it is already set via M16C_STATE_BUS_PASSIVE flag above, but it is kept for now.
Tested with 0bfd:0124 Kvaser Mini PCI Express 2xHS FW 4.18.778.
--- .../net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +8 -12
@@ -961,20 +961,16 @@ kvaser_usb_leaf_rx_error_update_can_state(struct kvaser_usb_net_priv *priv, new_state =CAN_STATE_BUS_OFF ; }else if (es->status &M16C_STATE_BUS_PASSIVE ) { new_state =CAN_STATE_ERROR_PASSIVE ; - }else if (es->status &M16C_STATE_BUS_ERROR ) { + }else if ((es->status &M16C_STATE_BUS_ERROR ) && + cur_state >=CAN_STATE_BUS_OFF ) {/* Guard against spurious error events after a busoff */ -if (cur_state <CAN_STATE_BUS_OFF ) { -if (es->txerr >=128 || es->rxerr >=128 ) - new_state =CAN_STATE_ERROR_PASSIVE ; -else if (es->txerr >=96 || es->rxerr >=96 ) - new_state =CAN_STATE_ERROR_WARNING ; -else if (cur_state >CAN_STATE_ERROR_ACTIVE ) - new_state =CAN_STATE_ERROR_ACTIVE ; - } - } - -if (!es->status) + }else if (es->txerr >=128 || es->rxerr >=128 ) { + new_state =CAN_STATE_ERROR_PASSIVE ; + }else if (es->txerr >=96 || es->rxerr >=96 ) { + new_state =CAN_STATE_ERROR_WARNING ; + }else { new_state =CAN_STATE_ERROR_ACTIVE ; + }if (new_state != cur_state) { tx_state = (es->txerr >= es->rxerr) ? new_state :0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 249/1146 can: kvaser_usb_leaf: Fix improved state not being reported
In reply to Greg Kroah-HartmanFrom: Anssi Hannula <[email protected]>
[ Upstream commit 8d21f5927ae604881f98587fabf6753f88730968 ]
The tested 0bfd:0017 Kvaser Memorator Professional HS/HS FW 2.0.50 and 0bfd:0124 Kvaser Mini PCI Express 2xHS FW 4.18.778 do not seem to send any unsolicited events when error counters decrease or when the device transitions from ERROR_PASSIVE to ERROR_ACTIVE (or WARNING).
This causes the interface to e.g. indefinitely stay in the ERROR_PASSIVE state.
Fix that by asking for chip state (inc. counters) event every 0.5 secs when error counters are non-zero.
Since there are non-error-counter devices, also always poll in ERROR_PASSIVE even if the counters show zero.
--- drivers/net/can/usb/kvaser_usb/kvaser_usb.h | 7 +++ .../net/can/usb/kvaser_usb/kvaser_usb_core.c | 19 +++++- .../net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 58 +++++++++++++++++++ 3 files changed, 81 insertions(+), 3 deletions(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb.h +7 -0
@@ -104,6 +104,9 @@ struct kvaser_usb_net_priv {struct can_priv can;struct can_berr_counter bec; +/* subdriver-specific data */ +void *sub_priv; +struct kvaser_usb *dev;struct net_device *netdev;int channel;
@@ -125,6 +128,8 @@ struct kvaser_usb_net_priv {* * @dev_setup_endpoints: setup USB in and out endpoints * @dev_init_card: initialize card +* @dev_init_channel: initialize channel +* @dev_remove_channel: uninitialize channel * @dev_get_software_info: get software info * @dev_get_software_details: get software details * @dev_get_card_info: get card info
@@ -146,6 +151,8 @@ struct kvaser_usb_dev_ops { struct can_berr_counter *bec);int (*dev_setup_endpoints)(struct kvaser_usb *dev);int (*dev_init_card)(struct kvaser_usb *dev); +int (*dev_init_channel)(struct kvaser_usb_net_priv *priv); +void (*dev_remove_channel)(struct kvaser_usb_net_priv *priv);int (*dev_get_software_info)(struct kvaser_usb *dev);int (*dev_get_software_details)(struct kvaser_usb *dev);int (*dev_get_card_info)(struct kvaser_usb *dev);
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +16 -3
@@ -684,6 +684,7 @@ static const struct ethtool_ops kvaser_usb_ethtool_ops_hwts = {static void kvaser_usb_remove_interfaces (struct kvaser_usb *dev) { +const struct kvaser_usb_dev_ops *ops = dev->driver_info->ops;int i;for (i =0 ; i < dev->nchannels; i++) {
@@ -699,6 +700,9 @@ static void kvaser_usb_remove_interfaces(struct kvaser_usb *dev)if (!dev->nets[i])continue ; +if (ops->dev_remove_channel) + ops->dev_remove_channel (dev->nets[i]); +free_candev (dev->nets[i]->netdev); } }
@@ -772,17 +776,26 @@ static int kvaser_usb_init_one(struct kvaser_usb *dev, int channel) dev->nets[channel] = priv; +if (ops->dev_init_channel) { + err = ops->dev_init_channel (priv); +if (err) + goto err; + } + err =register_candev (netdev);if (err) {dev_err (&dev->intf->dev,"Failed to register CAN device\n" ); -free_candev (netdev); - dev->nets[channel] =NULL ; -return err; + goto err; }netdev_dbg (netdev,"device registered\n" );return 0 ; + +err: +free_candev (netdev); + dev->nets[channel] =NULL ; +return err; } static int kvaser_usb_probe(struct usb_interface *intf,
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +58 -0
122 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 250/1146 can: kvaser_usb_leaf: Fix wrong CAN state after stopping
In reply to Greg Kroah-HartmanFrom: Anssi Hannula <[email protected]>
[ Upstream commit a11249acf802341294557895d8e5f6aef080253f ]
0bfd:0124 Kvaser Mini PCI Express 2xHS FW 4.18.778 sends a CMD_CHIP_STATE_EVENT indicating bus-off after stopping the device, causing a stopped device to appear as CAN_STATE_BUS_OFF instead of CAN_STATE_STOPPED.
Fix that by not handling error events on stopped devices.
--- drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +4 -0
@@ -1045,6 +1045,10 @@ static void kvaser_usb_leaf_rx_error(const struct kvaser_usb *dev, leaf = priv->sub_priv; stats = &priv->netdev->stats; +/* Ignore e.g. state change to bus-off reported just after stopping */ +if (!netif_running (priv->netdev)) +return ; +/* Update all of the CAN interface's state and error counters before * trying any memory allocation that can actually fail with -ENOMEM. *
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 251/1146 can: kvaser_usb_leaf: Fix bogus restart events
In reply to Greg Kroah-HartmanFrom: Anssi Hannula <[email protected]>
[ Upstream commit 90904d326269a38fe5dd895fb2db7c03199654c4 ]
When auto-restart is enabled, the kvaser_usb_leaf driver considers transition from any state >= CAN_STATE_BUS_OFF as a bus-off recovery event (restart).
However, these events may occur at interface startup time before kvaser_usb_open() has set the state to CAN_STATE_ERROR_ACTIVE, causing restarts counter to increase and CAN_ERR_RESTARTED to be sent despite no actual restart having occurred.
Fix that by making the auto-restart condition checks more strict so that they only trigger when the interface was actually in the BUS_OFF state.
--- drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +3 -3
@@ -898,7 +898,7 @@ static void kvaser_usb_leaf_tx_acknowledge(const struct kvaser_usb *dev, context = &priv->tx_contexts[tid % dev->max_tx_urbs];/* Sometimes the state change doesn't come after a bus-off event */ -if (priv->can.restart_ms && priv->can.state >=CAN_STATE_BUS_OFF ) { +if (priv->can.restart_ms && priv->can.state ==CAN_STATE_BUS_OFF ) {struct sk_buff *skb;struct can_frame *cf;
@@ -998,7 +998,7 @@ kvaser_usb_leaf_rx_error_update_can_state(struct kvaser_usb_net_priv *priv, }if (priv->can.restart_ms && - cur_state >=CAN_STATE_BUS_OFF && + cur_state ==CAN_STATE_BUS_OFF && new_state <CAN_STATE_BUS_OFF ) priv->can.can_stats.restarts++;
@@ -1088,7 +1088,7 @@ static void kvaser_usb_leaf_rx_error(const struct kvaser_usb *dev, }if (priv->can.restart_ms && - old_state >=CAN_STATE_BUS_OFF && + old_state ==CAN_STATE_BUS_OFF && new_state <CAN_STATE_BUS_OFF ) { cf->can_id |=CAN_ERR_RESTARTED ;netif_carrier_on (priv->netdev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 252/1146 can: kvaser_usb: Add struct kvaser_usb_busparams
In reply to Greg Kroah-HartmanFrom: Jimmy Assarsson <[email protected]>
[ Upstream commit 00e5786177649c1e3110f9454fdd34e336597265 ]
Add struct kvaser_usb_busparams containing the busparameters used in CMD_{SET,GET}_BUSPARAMS* commands.
Stable-dep-of: 39d3df6b0ea8 ("can: kvaser_usb: Compare requested bittiming parameters with actual parameters in do_set_{,data}_bittiming")
--- drivers/net/can/usb/kvaser_usb/kvaser_usb.h | 8 +++++ .../net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 32 +++++++------------ .../net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 18 ++++------- 3 files changed, 27 insertions(+), 31 deletions(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb.h +8 -0
@@ -76,6 +76,14 @@ struct kvaser_usb_tx_urb_context {u32 echo_index; }; +struct kvaser_usb_busparams { +__le32 bitrate; +u8 tseg1; +u8 tseg2; +u8 sjw; +u8 nsamples; +} __packed; +struct kvaser_usb {struct usb_device *udev;struct usb_interface *intf;
drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c +12 -20
@@ -196,17 +196,9 @@ struct kvaser_cmd_chip_state_event {#define KVASER_USB_HYDRA_BUS_MODE_CANFD_ISO 0x01#define KVASER_USB_HYDRA_BUS_MODE_NONISO 0x02struct kvaser_cmd_set_busparams { -__le32 bitrate; -u8 tseg1; -u8 tseg2; -u8 sjw; -u8 nsamples; +struct kvaser_usb_busparams busparams_arb;u8 reserved0[4 ]; -__le32 bitrate_d; -u8 tseg1_d; -u8 tseg2_d; -u8 sjw_d; -u8 nsamples_d; +struct kvaser_usb_busparams busparams_data;u8 canfd_mode;u8 reserved1[7 ]; } __packed;
@@ -1538,11 +1530,11 @@ static int kvaser_usb_hydra_set_bittiming(struct net_device *netdev)return -ENOMEM ; cmd->header.cmd_no =CMD_SET_BUSPARAMS_REQ ; - cmd->set_busparams_req.bitrate =cpu_to_le32 (bt->bitrate); - cmd->set_busparams_req.sjw = (u8 )sjw; - cmd->set_busparams_req.tseg1 = (u8 )tseg1; - cmd->set_busparams_req.tseg2 = (u8 )tseg2; - cmd->set_busparams_req.nsamples =1 ; + cmd->set_busparams_req.busparams_arb.bitrate =cpu_to_le32 (bt->bitrate); + cmd->set_busparams_req.busparams_arb.sjw = (u8 )sjw; + cmd->set_busparams_req.busparams_arb.tseg1 = (u8 )tseg1; + cmd->set_busparams_req.busparams_arb.tseg2 = (u8 )tseg2; + cmd->set_busparams_req.busparams_arb.nsamples =1 ;kvaser_usb_hydra_set_cmd_dest_he (cmd, dev->card_data.hydra.channel_to_he[priv->channel]);
@@ -1572,11 +1564,11 @@ static int kvaser_usb_hydra_set_data_bittiming(struct net_device *netdev)return -ENOMEM ; cmd->header.cmd_no =CMD_SET_BUSPARAMS_FD_REQ ; - cmd->set_busparams_req.bitrate_d =cpu_to_le32 (dbt->bitrate); - cmd->set_busparams_req.sjw_d = (u8 )sjw; - cmd->set_busparams_req.tseg1_d = (u8 )tseg1; - cmd->set_busparams_req.tseg2_d = (u8 )tseg2; - cmd->set_busparams_req.nsamples_d =1 ; + cmd->set_busparams_req.busparams_data.bitrate =cpu_to_le32 (dbt->bitrate); + cmd->set_busparams_req.busparams_data.sjw = (u8 )sjw; + cmd->set_busparams_req.busparams_data.tseg1 = (u8 )tseg1; + cmd->set_busparams_req.busparams_data.tseg2 = (u8 )tseg2; + cmd->set_busparams_req.busparams_data.nsamples =1 ;if (priv->can.ctrlmode &CAN_CTRLMODE_FD ) {if (priv->can.ctrlmode &CAN_CTRLMODE_FD_NON_ISO )
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +7 -11
@@ -164,11 +164,7 @@ struct usbcan_cmd_softinfo {struct kvaser_cmd_busparams {u8 tid;u8 channel; -__le32 bitrate; -u8 tseg1; -u8 tseg2; -u8 sjw; -u8 no_samp; +struct kvaser_usb_busparams busparams; } __packed;struct kvaser_cmd_tx_can {
@@ -1699,15 +1695,15 @@ static int kvaser_usb_leaf_set_bittiming(struct net_device *netdev) cmd->len =CMD_HEADER_LEN +sizeof (struct kvaser_cmd_busparams ); cmd->u.busparams.channel = priv->channel; cmd->u.busparams.tid =0xff ; - cmd->u.busparams.bitrate =cpu_to_le32 (bt->bitrate); - cmd->u.busparams.sjw = bt->sjw; - cmd->u.busparams.tseg1 = bt->prop_seg + bt->phase_seg1; - cmd->u.busparams.tseg2 = bt->phase_seg2; + cmd->u.busparams.busparams.bitrate =cpu_to_le32 (bt->bitrate); + cmd->u.busparams.busparams.sjw = bt->sjw; + cmd->u.busparams.busparams.tseg1 = bt->prop_seg + bt->phase_seg1; + cmd->u.busparams.busparams.tseg2 = bt->phase_seg2;if (priv->can.ctrlmode &CAN_CTRLMODE_3_SAMPLES ) - cmd->u.busparams.no_samp =3 ; + cmd->u.busparams.busparams.nsamples =3 ;else - cmd->u.busparams.no_samp =1 ; + cmd->u.busparams.busparams.nsamples =1 ; rc =kvaser_usb_send_cmd (dev, cmd, cmd->len);
Signature · 1 line
2.35.1