5.15.221-rc1 review
Subsystems (6)
Greg Kroah-Hartman
maintainerPATCH 678/935 perf thread-stack: Fix heap buffer overflow on branch stack wrap copy
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit ab9c84d1cd59e6b3b73de34982a35a76e3a9b032 ]
thread_stack__br_sample() copies the wrap-around portion of the branch stack ring buffer with:
nr = min(ts->br_stack_pos, sz); memcpy(be, &src->entries[0], bsz * ts->br_stack_pos);
'nr' is correctly bounded to min(br_stack_pos, sz) but the memcpy uses the unbounded ts->br_stack_pos directly. When br_stack_pos exceeds the remaining destination space 'sz', this writes past the destination buffer.
Use 'nr' (the bounded value) in the memcpy size, matching the pattern of the first memcpy in the same function.
--- tools/perf/util/thread-stack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/thread-stack.c +1 -1
@@ -641,7 +641,7 @@ void thread_stack__br_sample(struct thread *thread, int cpu, sz -= nr; be = &dst->entries[nr]; nr =min (ts->br_stack_pos, sz); -memcpy (be, &src->entries[0 ], bsz * ts->br_stack_pos); +memcpy (be, &src->entries[0 ], bsz * nr); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 679/935 perf auxtrace: Fix queue grow overflow and old array leak
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 96fcc9ea5f18c083a1fa73da23afef7e953f7dca ]
auxtrace_queues__grow() has two bugs:
1. When idx is UINT_MAX, the caller passes new_nr_queues = idx + 1 = 0. The function skips growing (since any nr_queues >= 0), returns success, and the caller accesses queue_array[UINT_MAX] — an OOB heap write. Fix by rejecting new_nr_queues == 0 up front.
2. The function allocates a new queue_array via calloc and copies elements from the old array, but never frees the old array. Fix by saving the old pointer and freeing it after the copy.
--- tools/perf/util/auxtrace.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
tools/perf/util/auxtrace.c +10 -5
@@ -222,8 +222,12 @@ static int auxtrace_queues__grow(struct auxtrace_queues *queues, {unsigned int nr_queues = queues->nr_queues;struct auxtrace_queue *queue_array; +struct auxtrace_queue *old_array = queues->queue_array;unsigned int i; +if (!new_nr_queues) +return -EINVAL ; +if (!nr_queues) nr_queues =AUXTRACE_INIT_NR_QUEUES ;
@@ -238,16 +242,17 @@ static int auxtrace_queues__grow(struct auxtrace_queues *queues,return -ENOMEM ;for (i =0 ; i < queues->nr_queues; i++) { -list_splice_tail (&queues->queue_array[i].head, +list_splice_tail (&old_array[i].head, &queue_array[i].head); - queue_array[i].tid = queues->queue_array[i].tid; - queue_array[i].cpu = queues->queue_array[i].cpu; - queue_array[i].set = queues->queue_array[i].set; - queue_array[i].priv = queues->queue_array[i].priv; + queue_array[i].tid = old_array[i].tid; + queue_array[i].cpu = old_array[i].cpu; + queue_array[i].set = old_array[i].set; + queue_array[i].priv = old_array[i].priv; } queues->nr_queues = nr_queues; queues->queue_array = queue_array; +free (old_array);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 680/935 perf intel-pt: Fix off-by-one in auxtrace_info minimum size check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit c4362d5e1a5ed4ce2098798f655a636c4340fa20 ]
min_sz is set to sizeof(u64) * INTEL_PT_PER_CPU_MMAPS, but the code accesses auxtrace_info->priv[INTEL_PT_PER_CPU_MMAPS], which requires at least INTEL_PT_PER_CPU_MMAPS + 1 elements. A file with exactly min_sz bytes of priv data passes the size check but the access reads one u64 past the validated region.
Use (INTEL_PT_PER_CPU_MMAPS + 1) to ensure the highest accessed index is within bounds.
--- tools/perf/util/intel-pt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/intel-pt.c +1 -1
@@ -3669,7 +3669,7 @@ int intel_pt_process_auxtrace_info(union perf_event *event, struct perf_session *session) {struct perf_record_auxtrace_info *auxtrace_info = &event->auxtrace_info; -size_t min_sz =sizeof (u64) *INTEL_PT_PER_CPU_MMAPS ; +size_t min_sz =sizeof (u64) * (INTEL_PT_PER_CPU_MMAPS +1 );struct intel_pt *pt;void *info_end;__u64 *info;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 681/935 perf intel-bts: Fix off-by-one in auxtrace_info minimum size check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit b9fb8225951ce27e62a2235a71f3ab01137aaec3 ]
Same pattern as the Intel PT fix: min_sz is set to sizeof(u64) * INTEL_BTS_SNAPSHOT_MODE, but the code accesses auxtrace_info->priv[INTEL_BTS_SNAPSHOT_MODE], which requires at least INTEL_BTS_SNAPSHOT_MODE + 1 elements.
Use (INTEL_BTS_SNAPSHOT_MODE + 1) to ensure the highest accessed index is within bounds.
--- tools/perf/util/intel-bts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/intel-bts.c +1 -1
@@ -858,7 +858,7 @@ int intel_bts_process_auxtrace_info(union perf_event *event, struct perf_session *session) {struct perf_record_auxtrace_info *auxtrace_info = &event->auxtrace_info; -size_t min_sz =sizeof (u64) *INTEL_BTS_SNAPSHOT_MODE ; +size_t min_sz =sizeof (u64) * (INTEL_BTS_SNAPSHOT_MODE +1 );struct intel_bts *bts;int err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 682/935 iio: light: tsl2772: fix ALS calibscale readback
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuanshen Cao <[email protected]>
[ Upstream commit ac75550ab5b5d73649bffea245c2075fd9249bd0 ]
The read_raw() implementation uses IIO_LIGHT to distinguish between the ambient light and proximity channels when handling IIO_CHAN_INFO_CALIBSCALE.
However, the ALS channel is registered as IIO_INTENSITY, while write_raw() correctly writes to IIO_INTENSITY. As a result, reading in_intensity0_calibscale incorrectly returns the proximity gain instead of the ALS gain.
This causes the following user-visible behavior:
- Writing in_intensity0_calibscale appears to have no effect because the readback reports the proximity gain.
- Writing in_proximity0_calibscale causes both in_proximity0_calibscale and in_intensity0_calibscale to report the same value.
Fix this by checking for IIO_INTENSITY in read_raw(), matching the channel definition and the existing write_raw() implementation.
--- drivers/iio/light/tsl2772.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/light/tsl2772.c +1 -1
@@ -1268,7 +1268,7 @@ static int tsl2772_read_raw(struct iio_dev *indio_dev, }break ;case IIO_CHAN_INFO_CALIBSCALE : -if (chan->type ==IIO_LIGHT ) +if (chan->type ==IIO_INTENSITY ) *val = tsl2772_als_gain[chip->settings.als_gain];else *val = tsl2772_prox_gain[chip->settings.prox_gain];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 683/935 iio: light: isl29028: return zero in write_raw() on success
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sang-Heon Jeon <[email protected]>
[ Upstream commit 55b75622829779223b9e32aa9600a8651d3e2df4 ]
isl29028_write_raw() returns the value of pm_runtime_put_autosuspend(), which is 1 if the device is already runtime suspended.
In that case write() on the sysfs attribute returns 1 instead of the number of bytes written. Make isl29028_write_raw() always return zero on success.
--- drivers/iio/light/isl29028.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/light/isl29028.c +1 -1
@@ -414,7 +414,7 @@ static int isl29028_write_raw(struct iio_dev *indio_dev,if (ret <0 )return ret; -return ret; +return 0 ; } static int isl29028_read_raw(struct iio_dev *indio_dev,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 684/935 iio: light: tsl2583: return zero in write_raw() on success
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sang-Heon Jeon <[email protected]>
[ Upstream commit 42e8791841e0677418a3ccc97fa5c22a1455f417 ]
tsl2583_write_raw() returns the value of pm_runtime_put_autosuspend(), which is 1 if the device is already runtime suspended.
In that case write() on the sysfs attribute returns 1 instead of the number of bytes written. Make tsl2583_write_raw() always return zero on success.
--- drivers/iio/light/tsl2583.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/light/tsl2583.c +1 -1
@@ -800,7 +800,7 @@ static int tsl2583_write_raw(struct iio_dev *indio_dev,if (ret <0 )return ret; -return ret; +return 0 ; }static const struct iio_info tsl2583_info = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 685/935 phonet: pep: do not write beyond optlen in getsockopt
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit 77e5eb0e192aec6710c03ca8144582fd2af36ca4 ]
pep_getsockopt() clamps the reported length to the caller's buffer with min_t(), but then stores the value with put_user(val, (int __user *) optval), which always writes sizeof(int) bytes. A getsockopt() call with an optlen smaller than sizeof(int) thus reports the clamped length yet writes a full int, one to three bytes past the user buffer.
Write the value with copy_to_user() bounded by len, so at most optlen bytes are copied, matching the length reported back to userspace.
--- net/phonet/pep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/phonet/pep.c +1 -1
@@ -1116,7 +1116,7 @@ static int pep_getsockopt(struct sock *sk, int level, int optname, len = min_t(unsigned int, sizeof(int), len);if (put_user (len, optlen))return -EFAULT ; -if (put_user (val, (int __user *) optval)) +if (copy_to_user (optval, &val, len))return -EFAULT ;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 686/935 block/blk-stat: drain per-cpu callback stats over possible CPUs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tao Cui <[email protected]>
[ Upstream commit 9d617828cfc4d9a4d385daa2cd61f9db0592c53f ]
blk_stat_timer_fn() sums and resets a callback's per-cpu buckets using for_each_online_cpu(). A CPU that goes offline with pending samples is skipped, so its samples are neither accumulated into the window nor cleared; they sit in the bucket until the CPU comes back online, at which point the stale values are flushed into whatever window is then running.
This silently corrupts the latency picture that consumers (notably writeback throttling via wbt, and blk-mq latency tracking) base decisions on around CPU hotplug: under-counting while the CPU is offline, then a burst of stale data on re-online.
--- block/blk-stat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-stat.c +1 -1
@@ -86,7 +86,7 @@ static void blk_stat_timer_fn(struct timer_list *t)for (bucket =0 ; bucket < cb->buckets; bucket++)blk_rq_stat_init (&cb->stat[bucket]); -for_each_online_cpu (cpu) { +for_each_possible_cpu (cpu) {struct blk_rq_stat *cpu_stat; cpu_stat =per_cpu_ptr (cb->cpu_stat, cpu);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 687/935 block/blk-iocost: collect per-cpu latency stats over possible CPUs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tao Cui <[email protected]>
[ Upstream commit 4e050c5b92c1600415b2cd452583e543036f3d73 ]
ioc_lat_stat() walks ioc->pcpu_stat with for_each_online_cpu() to compute missed-ppm and rq_wait deltas. An offlined CPU is skipped, so its delta is dropped from the period and its last_* watermark is not advanced; on re-online the next collection sees a delta spanning the whole offline interval, corrupting the latency/vrate picture.
--- block/blk-iocost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-iocost.c +1 -1
@@ -1592,7 +1592,7 @@ static void ioc_lat_stat(struct ioc *ioc, u32 *missed_ppm_ar, u32 *rq_wait_pct_pu64 rq_wait_ns =0 ;int cpu, rw; -for_each_online_cpu (cpu) { +for_each_possible_cpu (cpu) {struct ioc_pcpu_stat *stat =per_cpu_ptr (ioc->pcpu_stat, cpu);u64 this_rq_wait_ns;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 688/935 block/kyber-iosched: flush per-cpu latency buckets over possible CPUs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tao Cui <[email protected]>
[ Upstream commit 482fc257de95ab181688e9d1dfcc6b6a58857b1e ]
kyber_timer_fn() sums the per-cpu latency histograms with for_each_online_cpu(). A CPU that goes offline mid-interval leaves its bucket un-flushed; the samples are lost from the current decision and re-appear (stale) when the CPU is onlined again.
--- block/kyber-iosched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/kyber-iosched.c +1 -1
@@ -284,7 +284,7 @@ static void kyber_timer_fn(struct timer_list *t)bool bad = false;/* Sum all of the per-cpu latency histograms. */ -for_each_online_cpu (cpu) { +for_each_possible_cpu (cpu) {struct kyber_cpu_latency *cpu_latency; cpu_latency =per_cpu_ptr (kqd->cpu_latency, cpu);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 689/935 lib/string: fix memchr_inv() for large ranges
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bradley Morgan <[email protected]>
[ Upstream commit c04cffb8c51618538f0c05c478a931eb6e1a806b ]
memchr_inv() takes a size_t length but counts 8 byte words in an unsigned int. At 32GiB that count wraps, so the scan can quietly miss most of the range.
Use size_t for the word count.
--- lib/string.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/string.c +2 -1
@@ -1115,7 +1115,8 @@ void *memchr_inv(const void *start, int c, size_t bytes) {u8 value = c;u64 value64; -unsigned int words, prefix; +size_t words; +unsigned int prefix;if (bytes <=16 )return check_bytes8 (start, value, bytes);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 690/935 pps: dont try to wait for negative timeouts in PPS_FETCH
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Calvin Owens <[email protected]>
[ Upstream commit 45217e98987a87ff2372386dbf82fd5325db28ea ]
If userspace passes a negative timeout to PPS_FETCH, it triggers a kernel splat from schedule_timeout():
schedule_timeout: wrong timeout value fffffffffff0bfb4
CPU: 17 UID: 0 PID: 4720 Comm: a.out Not tainted 7.1.0-rc5-x86-kvm-00150-g331d97e36b37 #1 PREEMPT_RT
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-20240910_120124-localhost 04/01/2014
Call Trace:
<TASK>
dump_stack_lvl+0x4b/0x70
schedule_timeout+0xb7/0xe0
pps_cdev_pps_fetch.isra.0+0x93/0x150
pps_cdev_ioctl+0x70/0x310
__x64_sys_ioctl+0x7b/0xc0
do_syscall_64+0xb6/0xfc0
entry_SYSCALL_64_after_hwframe+0x4b/0x53Here is a trivial reproducer that works with the PPS_CLIENT_KTIMER test device enabled in the kernel:
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <linux/pps.h>
#include <err.h>
int main() {
struct pps_fdata fdata;
int fd;
fd = open("/dev/pps0", O_RDWR);
if (fd == -1)
err(1, "Failed to open /dev/pps0");
fdata.timeout.sec = -1;
fdata.timeout.nsec = 0;
if (ioctl(fd, PPS_FETCH, &fdata))
err(2, "PPS_FETCH failed");
close(fd);
return 0;
}Sashiko imagines this to be some sort of security problem, which is obviously really silly. But I think it is still worth fixing, so buggy userspace code can't trigger the splat.
Silence the splat by using timespec64_to_jiffies(), which hard limits the timeout to LONG_MAX jiffies. To be safe, explicitly preserve the -ETIMEDOUT return value userspace sees today if it passes a negative timeout.
If you really squint, this is still a slight behavior change in that there are "denormalized" combinations of tv_sec and tv_nsec which used to work but will now return -ETIMEDOUT. I can't imagine anybody will care about that...
--- drivers/pps/pps.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/pps/pps.c +8 -2
@@ -63,13 +63,19 @@ static int pps_cdev_pps_fetch(struct pps_device *pps, struct pps_fdata *fdata) err =wait_event_interruptible (pps->queue, ev != pps->last_ev); else { +struct timespec64 ts;unsigned long ticks;dev_dbg (&pps->dev,"timeout %lld.%09d\n" , (long long ) fdata->timeout.sec, fdata->timeout.nsec); - ticks = fdata->timeout.sec *HZ ; - ticks += fdata->timeout.nsec / (NSEC_PER_SEC /HZ ); + +if (fdata->timeout.sec <0 ) +return -ETIMEDOUT ; + + ts.tv_sec = fdata->timeout.sec; + ts.tv_nsec = fdata->timeout.nsec; + ticks =timespec64_to_jiffies (&ts);if (ticks !=0 ) { err = wait_event_interruptible_timeout(
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 691/935 pps: clients: gpio: Bypass edges direction check when not needed
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bastien Curutchet <[email protected]>
[ Upstream commit a01f6287c244f35eeec11ca932d09061181eed8c ]
In the IRQ handler, the GPIO's state is read to verify the direction of the edge that triggered the interruption before generating the PPS event. If a pulse is too short, the GPIO line can reach back its original state before this verification and the PPS event is lost.
This check is needed when info->capture_clear is set because it needs interruptions on both rising and falling edges. When info->capture_clear is not set, interruption is triggered by one edge only so this check can be omitted.
Add a warning if irq_handler is left without triggering any PPS event. Bypass the edge's direction verification when info->capture_clear is not set.
Stable-dep-of: b899e0279f90 ("pps-gpio: remove dead capture_clear code")
--- drivers/pps/clients/pps-gpio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/pps/clients/pps-gpio.c +5 -1
@@ -52,7 +52,9 @@ static irqreturn_t pps_gpio_irq_handler(int irq, void *data) info = data; - rising_edge =gpiod_get_value (info->gpio_pin); +/* Small trick to bypass the check on edge's direction when capture_clear is unset */ + rising_edge = info->capture_clear ? +gpiod_get_value (info->gpio_pin) : !info->assert_falling_edge;if ((rising_edge && !info->assert_falling_edge) || (!rising_edge && info->assert_falling_edge))pps_event (info->pps, &ts,PPS_CAPTUREASSERT , data);
@@ -60,6 +62,8 @@ static irqreturn_t pps_gpio_irq_handler(int irq, void *data) ((rising_edge && info->assert_falling_edge) || (!rising_edge && !info->assert_falling_edge)))pps_event (info->pps, &ts,PPS_CAPTURECLEAR , data); + else + dev_warn_ratelimited(&info->pps->dev, "IRQ did not trigger any PPS event\n");return IRQ_HANDLED ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 692/935 pps: pps-gpio: split IRQ handler into hardirq timestamper + threaded handler
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Byczkowski <[email protected]>
[ Upstream commit 93781560b2fdd26fa8499d64db8a95a07e1dc902 ]
Split the pps-gpio interrupt handler into a primary (hardirq) handler that captures the PPS timestamp at interrupt entry, and a threaded handler that processes the event. This produces the same two-part handler structure on both PREEMPT_RT and non-RT kernels.
On non-RT kernels the threaded portion runs immediately after the primary, with no behavioral change compared to the previous single-handler implementation.
On PREEMPT_RT, where interrupt handlers are force-threaded by default, the previous single-handler implementation captured the timestamp inside the threaded portion, after IRQ-thread scheduling delay. With the split, the timestamp is captured in true hardirq context as it is on non-RT kernels, eliminating a significant source of PPS jitter on RT systems.
Stable-dep-of: b899e0279f90 ("pps-gpio: remove dead capture_clear code")
--- drivers/pps/clients/pps-gpio.c | 37 +++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 12 deletions(-)
drivers/pps/clients/pps-gpio.c +25 -12
@@ -35,33 +35,44 @@ struct pps_gpio_device_data {bool capture_clear;unsigned int echo_active_ms;/* PPS echo active duration */ unsigned long echo_timeout;/* timer timeout value in jiffies */ +struct pps_event_time ts;/* timestamp captured in hardirq */ };/* * Report the PPS event */ -static irqreturn_t pps_gpio_irq_handler (int irq,void *data) +/* +* Primary hardirq handler -- runs in hardirq context even on PREEMPT_RT. +* Only captures the timestamp; all other work is deferred to the thread. +*/ +static irqreturn_t pps_gpio_irq_hardirq (int irq,void *data) { -const struct pps_gpio_device_data *info; -struct pps_event_time ts; -int rising_edge; +struct pps_gpio_device_data *info = data; + +pps_get_ts (&info->ts); -/* Get the time stamp first */ -pps_get_ts (&ts); +return IRQ_WAKE_THREAD ; +} - info = data; +/* +* Threaded handler -- processes the PPS event using the timestamp +* captured in hardirq context above. +*/ +static irqreturn_t pps_gpio_irq_thread (int irq,void *data) +{ +struct pps_gpio_device_data *info = data; +int rising_edge; -/* Small trick to bypass the check on edge's direction when capture_clear is unset */ rising_edge = info->capture_clear ?gpiod_get_value (info->gpio_pin) : !info->assert_falling_edge;if ((rising_edge && !info->assert_falling_edge) || (!rising_edge && info->assert_falling_edge)) -pps_event (info->pps, &ts,PPS_CAPTUREASSERT , data); +pps_event (info->pps, &info->ts,PPS_CAPTUREASSERT , data);else if (info->capture_clear && ((rising_edge && info->assert_falling_edge) || (!rising_edge && !info->assert_falling_edge))) -pps_event (info->pps, &ts,PPS_CAPTURECLEAR , data); +pps_event (info->pps, &info->ts,PPS_CAPTURECLEAR , data);else dev_warn_ratelimited (&info->pps->dev,"IRQ did not trigger any PPS event\n" );
@@ -210,8 +221,10 @@ static int pps_gpio_probe(struct platform_device *pdev) }/* register IRQ interrupt handler */ - ret =request_irq (data->irq, pps_gpio_irq_handler, -get_irqf_trigger_flags (data), data->info.name, data); + ret =request_threaded_irq (data->irq, + pps_gpio_irq_hardirq, pps_gpio_irq_thread, +get_irqf_trigger_flags (data) |IRQF_ONESHOT , + data->info.name, data);if (ret) {pps_unregister_source (data->pps);dev_err (dev,"failed to acquire IRQ %d\n" , data->irq);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 693/935 pps-gpio: remove dead capture_clear code
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Calvin Owens <[email protected]>
[ Upstream commit b899e0279f90c3ce4099d68b989dd27861cc5c4f ]
The capture_clear field is never set, and all code conditional on it being set has been unreachable since the platform data logic was removed from pps-gpio in ee89646619ba ("pps: clients: gpio: Get rid of legacy platform data").
I think the only logical thing to do here is to remove it all, since no in-tree code ever actually used it in the first place, and it has been completely dead code for over five years (since v5.13).
Sashiko asked some questions about the gpiod_get_value() call which caused me to look deeper and figure this out, but it did not actually notice capture_clear is never set.
--- drivers/pps/clients/pps-gpio.c | 37 ++++------------------------------ 1 file changed, 4 insertions(+), 33 deletions(-)
drivers/pps/clients/pps-gpio.c +4 -33
@@ -32,7 +32,6 @@ struct pps_gpio_device_data {struct gpio_desc *echo_pin;struct timer_list echo_timer;/* timer to reset echo active state */ bool assert_falling_edge; -bool capture_clear;unsigned int echo_active_ms;/* PPS echo active duration */ unsigned long echo_timeout;/* timer timeout value in jiffies */ struct pps_event_time ts;/* timestamp captured in hardirq */
@@ -62,19 +61,8 @@ static irqreturn_t pps_gpio_irq_hardirq(int irq, void *data)static irqreturn_t pps_gpio_irq_thread (int irq,void *data) {struct pps_gpio_device_data *info = data; -int rising_edge; - - rising_edge = info->capture_clear ? -gpiod_get_value (info->gpio_pin) : !info->assert_falling_edge; -if ((rising_edge && !info->assert_falling_edge) || - (!rising_edge && info->assert_falling_edge)) -pps_event (info->pps, &info->ts,PPS_CAPTUREASSERT , data); -else if (info->capture_clear && - ((rising_edge && info->assert_falling_edge) || - (!rising_edge && !info->assert_falling_edge))) -pps_event (info->pps, &info->ts,PPS_CAPTURECLEAR , data); -else -dev_warn_ratelimited (&info->pps->dev,"IRQ did not trigger any PPS event\n" ); + +pps_event (info->pps, &info->ts,PPS_CAPTUREASSERT , data);return IRQ_HANDLED ; }
@@ -90,11 +78,6 @@ static void pps_gpio_echo(struct pps_device *pps, int event, void *data)if (pps->params.mode &PPS_ECHOASSERT )gpiod_set_value (info->echo_pin,1 );break ; - -case PPS_CAPTURECLEAR : -if (pps->params.mode &PPS_ECHOCLEAR ) -gpiod_set_value (info->echo_pin,1 ); -break ; }/* fire the timer */
@@ -156,15 +139,8 @@ static int pps_gpio_setup(struct device *dev)static unsigned long get_irqf_trigger_flags (const struct pps_gpio_device_data *data) { -unsigned long flags = data->assert_falling_edge ? -IRQF_TRIGGER_FALLING :IRQF_TRIGGER_RISING ; - -if (data->capture_clear) { - flags |= ((flags &IRQF_TRIGGER_RISING ) ? -IRQF_TRIGGER_FALLING :IRQF_TRIGGER_RISING ); - } - -return flags; +return data->assert_falling_edge ?IRQF_TRIGGER_FALLING : +IRQF_TRIGGER_RISING ; }static int pps_gpio_probe (struct platform_device *pdev)
@@ -197,9 +173,6 @@ static int pps_gpio_probe(struct platform_device *pdev)/* initialize PPS specific parts of the bookkeeping data structure. */ data->info.mode =PPS_CAPTUREASSERT |PPS_OFFSETASSERT |PPS_ECHOASSERT |PPS_CANWAIT |PPS_TSFMT_TSPEC ; -if (data->capture_clear) - data->info.mode |=PPS_CAPTURECLEAR |PPS_OFFSETCLEAR | -PPS_ECHOCLEAR ; data->info.owner =THIS_MODULE ;snprintf (data->info.name,PPS_MAX_NAME_LEN -1 ,"%s.%d" , pdev->name, pdev->id);
@@ -211,8 +184,6 @@ static int pps_gpio_probe(struct platform_device *pdev)/* register PPS source */ pps_default_params =PPS_CAPTUREASSERT |PPS_OFFSETASSERT ; -if (data->capture_clear) - pps_default_params |=PPS_CAPTURECLEAR |PPS_OFFSETCLEAR ; data->pps =pps_register_source (&data->info, pps_default_params);if (IS_ERR (data->pps)) { dev_err(dev, "failed to register IRQ %d as PPS source\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 694/935 rapidio: clear mport->net when rio_add_net() fails
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit b74030fbf187b43c1f85b66a7082e9946511cb5d ]
rio_alloc_net() stores the newly allocated rio_net in mport->net before rio_scan_alloc_net() registers the device.
If rio_add_net() fails, rio_scan_alloc_net() drops the device reference with put_device(), which releases the rio_net through the device release callback. However, mport->net is left pointing at the freed object.
A later mport unregister path can then dereference the dangling mport->net pointer and may try to free the same rio_net again.
Clear mport->net in the rio_add_net() failure path, matching the cleanup done for the destID table allocation failure path.
--- drivers/rapidio/rio-scan.c | 1 + 1 file changed, 1 insertion(+)
drivers/rapidio/rio-scan.c +1 -0
@@ -874,6 +874,7 @@ static struct rio_net *rio_scan_alloc_net(struct rio_mport *mport, net->dev.release = rio_scan_release_dev;if (rio_add_net (net)) {put_device (&net->dev); + mport->net =NULL ; net =NULL ; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 695/935 fat: release buffer head after rebuilding parent
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yichong Chen <[email protected]>
[ Upstream commit 83e98dbf19ab64e8528e101e20f8d50e1aaa68a8 ]
fat_scan_logstart() leaves the matching directory entry's buffer head in sinfo.bh for the caller to release, just like fat_scan().
fat_rebuild_parent() uses the directory entry to rebuild the parent inode for the nostale_ro NFS export path, but does not release sinfo.bh after a successful scan. Release it once fat_build_inode() has consumed the directory entry data.
--- fs/fat/nfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/fat/nfs.c +3 -1
@@ -250,8 +250,10 @@ struct inode *fat_rebuild_parent(struct super_block *sb, int parent_logstart)MSDOS_I (dummy_grand_parent)->i_pos =-1 ; } -if (!fat_scan_logstart (dummy_grand_parent, clus_to_match, &sinfo)) +if (!fat_scan_logstart (dummy_grand_parent, clus_to_match, &sinfo)) { parent =fat_build_inode (sb, sinfo.de, sinfo.i_pos); +brelse (sinfo.bh); + }brelse (parent_bh);iput (dummy_grand_parent);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 696/935 drm/omap: dsi: Do not copy isr table
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Kemnade <[email protected]>
[ Upstream commit 97c03b32b28a9f7f13f768f2b06e1eaafe850e66 ]
To be able to unregister stuff from isrs, the corresponding table was copied. Nobody seems to unregister stuff that way, so it does not help. But there are stack-allocated objects passed to these isrs giving chances of UAF of these objects if irqs are unregistered while they are handled, so better do not copy that table.
--- drivers/gpu/drm/omapdrm/dss/dsi.c | 7 +------ drivers/gpu/drm/omapdrm/dss/dsi.h | 2 -- 2 files changed, 1 insertion(+), 8 deletions(-)
drivers/gpu/drm/omapdrm/dss/dsi.c +1 -6
@@ -455,15 +455,10 @@ static irqreturn_t omap_dsi_irq_handler(int irq, void *arg)del_timer (&dsi->te_timer);#endif -/* make a copy and unlock, so that isrs can unregister -* themselves */ -memcpy (&dsi->isr_tables_copy, &dsi->isr_tables, -sizeof (dsi->isr_tables)); +dsi_handle_isrs (&dsi->isr_tables, irqstatus, vcstatus, ciostatus);spin_unlock (&dsi->irq_lock); -dsi_handle_isrs (&dsi->isr_tables_copy, irqstatus, vcstatus, ciostatus); -dsi_handle_irq_errors (dsi, irqstatus, vcstatus, ciostatus);dsi_collect_irq_stats (dsi, irqstatus, vcstatus, ciostatus);
drivers/gpu/drm/omapdrm/dss/dsi.h +0 -2
@@ -379,8 +379,6 @@ struct dsi_data {spinlock_t irq_lock;struct dsi_isr_tables isr_tables; -/* space for a copy used by the interrupt handler */ -struct dsi_isr_tables isr_tables_copy;int update_vc;#ifdef DSI_PERF_MEASURE
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 697/935 PCI/sysfs: Add static PCI resource attribute macros
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Wilczyński <[email protected]>
[ Upstream commit b15ac7e008bf0039f981da21e983b2df130152ff ]
Add three macros for declaring static binary attributes for PCI resource files:
- pci_dev_resource_io_attr(), for I/O BAR resources (read/write)
- pci_dev_resource_uc_attr(), for memory BAR resources (mmap uncached)
- pci_dev_resource_wc_attr(), for write-combine resources (mmap WC)
Each macro only sets the callbacks its resource type needs. The I/O macro conditionally includes mmap support via __PCI_RESOURCE_IO_MMAP_ATTRS on architectures where arch_can_pci_mmap_io() is true at compile time (such as PowerPC, SPARC, and Xtensa).
Stable-dep-of: bad94d3d18c6 ("PCI/sysfs: Return -EINVAL for unsupported I/O BAR mmap")
--- drivers/pci/pci-sysfs.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
drivers/pci/pci-sysfs.c +41 -0
@@ -1181,6 +1181,47 @@ static ssize_t pci_write_resource_io(struct file *filp, struct kobject *kobj,return pci_resource_io (filp, kobj, attr, buf, off, count, true); } +/* +* generic_file_llseek() consults f_mapping->host to determine +* the file size. As iomem_inode knows nothing about the +* attribute, it's not going to work, so override it as well. +*/ +#if arch_can_pci_mmap_io () +# define __PCI_RESOURCE_IO_MMAP_ATTRS \ + .f_mapping = iomem_get_mapping, \ + .llseek = pci_llseek_resource, \ + .mmap = pci_mmap_resource_uc, +#else +# define __PCI_RESOURCE_IO_MMAP_ATTRS +#endif + +#define pci_dev_resource_io_attr (_bar) \ +static const struct bin_attribute dev_resource##_bar##_io_attr = { \ + .attr = { .name = "resource" __stringify(_bar), .mode = 0600 }, \ + .private = (void *)(unsigned long)(_bar), \ + .read = pci_read_resource_io, \ + .write = pci_write_resource_io, \ + __PCI_RESOURCE_IO_MMAP_ATTRS \ +} + +#define pci_dev_resource_uc_attr (_bar) \ +static const struct bin_attribute dev_resource##_bar##_uc_attr = { \ + .attr = { .name = "resource" __stringify(_bar), .mode = 0600 }, \ + .private = (void *)(unsigned long)(_bar), \ + .f_mapping = iomem_get_mapping, \ + .llseek = pci_llseek_resource, \ + .mmap = pci_mmap_resource_uc, \ +} + +#define pci_dev_resource_wc_attr (_bar) \ +static const struct bin_attribute dev_resource##_bar##_wc_attr = { \ + .attr = { .name = "resource" __stringify(_bar) "_wc", .mode = 0600 }, \ + .private = (void *)(unsigned long)(_bar), \ + .f_mapping = iomem_get_mapping, \ + .llseek = pci_llseek_resource, \ + .mmap = pci_mmap_resource_wc, \ +} +/** * pci_remove_resource_files - cleanup resource files * @pdev: dev to cleanup
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 698/935 remoteproc: Move resource table data structure to its own header
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mukesh Ojha <[email protected]>
[ Upstream commit 0590420c2f90de497d342c9a41a618f46f4d09ab ]
The resource table data structure has traditionally been associated with the remoteproc framework, where the resource table is included as a section within the remote processor firmware binary. However, it is also possible to obtain the resource table through other means—such as from a reserved memory region populated by the boot firmware, statically maintained driver data, or via a secure SMC call—when it is not embedded in the firmware.
There are multiple Qualcomm remote processors (e.g., Venus, Iris, GPU, etc.) in the upstream kernel that do not use the remoteproc framework to manage their lifecycle for various reasons.
When Linux is running at EL2, similar to the Qualcomm PAS driver (qcom_q6v5_pas.c), client drivers for subsystems like video and GPU may also want to use the resource table SMC call to retrieve and map resources before they are used by the remote processor.
In such cases, the resource table data structure is no longer tightly coupled with the remoteproc headers. Client drivers that do not use the remoteproc framework should still be able to parse the resource table obtained through alternative means. Therefore, there is a need to decouple the resource table definitions from the remoteproc headers.
Stable-dep-of: bb840ea69347 ("remoteproc: fix OOB read via signed offset in rsc_table_for_each_entry()")
--- include/linux/remoteproc.h | 269 +------------------------------- include/linux/rsc_table.h | 306 +++++++++++++++++++++++++++++++++++++ 2 files changed, 307 insertions(+), 268 deletions(-) create mode 100644 include/linux/rsc_table.h
include/linux/remoteproc.h +1 -268
@@ -43,274 +43,7 @@#include <linux/completion.h> #include <linux/idr.h> #include <linux/of.h> - -/** -* struct resource_table - firmware resource table header -* @ver: version number -* @num: number of resource entries -* @reserved: reserved (must be zero) -* @offset: array of offsets pointing at the various resource entries -* -* A resource table is essentially a list of system resources required -* by the remote processor. It may also include configuration entries. -* If needed, the remote processor firmware should contain this table -* as a dedicated ".resource_table" ELF section. -* -* Some resources entries are mere announcements, where the host is informed -* of specific remoteproc configuration. Other entries require the host to -* do something (e.g. allocate a system resource). Sometimes a negotiation -* is expected, where the firmware requests a resource, and once allocated, -* the host should provide back its details (e.g. address of an allocated -* memory region). -* -* The header of the resource table, as expressed by this structure, -* contains a version number (should we need to change this format in the -* future), the number of available resource entries, and their offsets -* in the table. -* -* Immediately following this header are the resource entries themselves, -* each of which begins with a resource entry header (as described below). -*/ -struct resource_table { -u32 ver; -u32 num; -u32 reserved[2 ]; -u32 offset[]; -} __packed; - -/** -* struct fw_rsc_hdr - firmware resource entry header -* @type: resource type -* @data: resource data -* -* Every resource entry begins with a 'struct fw_rsc_hdr' header providing -* its @type. The content of the entry itself will immediately follow -* this header, and it should be parsed according to the resource type. -*/ -struct fw_rsc_hdr { -u32 type; -u8 data[]; -} __packed; - -/** -* enum fw_resource_type - types of resource entries -* -* @RSC_CARVEOUT: request for allocation of a physically contiguous -* memory region. -* @RSC_DEVMEM: request to iommu_map a memory-based peripheral. -* @RSC_TRACE: announces the availability of a trace buffer into which -* the remote processor will be writing logs. -* @RSC_VDEV: declare support for a virtio device, and serve as its -* virtio header. -* @RSC_LAST: just keep this one at the end of standard resources -* @RSC_VENDOR_START: start of the vendor specific resource types range -* @RSC_VENDOR_END: end of the vendor specific resource types range -* -* For more details regarding a specific resource type, please see its -* dedicated structure below. -* -* Please note that these values are used as indices to the rproc_handle_rsc -* lookup table, so please keep them sane. Moreover, @RSC_LAST is used to -* check the validity of an index before the lookup table is accessed, so -* please update it as needed. -*/ -enum fw_resource_type { -RSC_CARVEOUT =0 , -RSC_DEVMEM =1 , -RSC_TRACE =2 , -RSC_VDEV =3 , -RSC_LAST =4 , -RSC_VENDOR_START =128 , -RSC_VENDOR_END =512 , -}; - -#define FW_RSC_ADDR_ANY (-1) - -/** -* struct fw_rsc_carveout - physically contiguous memory request -* @da: device address -* @pa: physical address -* @len: length (in bytes) -* @flags: iommu protection flags -* @reserved: reserved (must be zero) -* @name: human-readable name of the requested memory region -* -* This resource entry requests the host to allocate a physically contiguous -* memory region. -* -* These request entries should precede other firmware resource entries, -* as other entries might request placing other data objects inside -* these memory regions (e.g. data/code segments, trace resource entries, ...). -* -* Allocating memory this way helps utilizing the reserved physical memory -* (e.g. CMA) more efficiently, and also minimizes the number of TLB entries -* needed to map it (in case @rproc is using an IOMMU). Reducing the TLB -* pressure is important; it may have a substantial impact on performance. -* -* If the firmware is compiled with static addresses, then @da should specify -* the expected device address of this memory region. If @da is set to -* FW_RSC_ADDR_ANY, then the host will dynamically allocate it, and then -* overwrite @da with the dynamically allocated address. -* -* We will always use @da to negotiate the device addresses, even if it -* isn't using an iommu. In that case, though, it will obviously contain -* physical addresses. -* -* Some remote processors needs to know the allocated physical address -* even if they do use an iommu. This is needed, e.g., if they control -* hardware accelerators which access the physical memory directly (this -* is the case with OMAP4 for instance). In that case, the host will -* overwrite @pa with the dynamically allocated physical address. -* Generally we don't want to expose physical addresses if we don't have to -* (remote processors are generally _not_ trusted), so we might want to -* change this to happen _only_ when explicitly required by the hardware. -* -* @flags is used to provide IOMMU protection flags, and @name should -* (optionally) contain a human readable name of this carveout region -* (mainly for debugging purposes). -*/ -struct fw_rsc_carveout { -u32 da; -u32 pa; -u32 len; -u32 flags; -u32 reserved; -u8 name[32 ]; -} __packed; - -/** -* struct fw_rsc_devmem - iommu mapping request -* @da: device address -* @pa: physical address -* @len: length (in bytes) -* @flags: iommu protection flags -* @reserved: reserved (must be zero) -* @name: human-readable name of the requested region to be mapped -* -* This resource entry requests the host to iommu map a physically contiguous -* memory region. This is needed in case the remote processor requires -* access to certain memory-based peripherals; _never_ use it to access -* regular memory. -* -* This is obviously only needed if the remote processor is accessing memory -* via an iommu. -* -* @da should specify the required device address, @pa should specify -* the physical address we want to map, @len should specify the size of -* the mapping and @flags is the IOMMU protection flags. As always, @name may -* (optionally) contain a human readable name of this mapping (mainly for -* debugging purposes). -* -* Note: at this point we just "trust" those devmem entries to contain valid -* physical addresses, but this isn't safe and will be changed: eventually we -* want remoteproc implementations to provide us ranges of physical addresses -* the firmware is allowed to request, and not allow firmwares to request -* access to physical addresses that are outside those ranges. -*/ -struct fw_rsc_devmem { -u32 da; -u32 pa; -u32 len; -u32 flags; -u32 reserved; -u8 name[32 ]; -} __packed; - -/** -* struct fw_rsc_trace - trace buffer declaration -* @da: device address -* @len: length (in bytes) -* @reserved: reserved (must be zero) -* @name: human-readable name of the trace buffer -* -* This resource entry provides the host information about a trace buffer -* into which the remote processor will write log messages. -* -* @da specifies the device address of the buffer, @len specifies -* its size, and @name may contain a human readable name of the trace buffer. -* -* After booting the remote processor, the trace buffers are exposed to the -* user via debugfs entries (called trace0, trace1, etc..). -*/ -struct fw_rsc_trace { -u32 da; -u32 len; -u32 reserved; -u8 name[32 ]; -} __packed; - -/** -* struct fw_rsc_vdev_vring - vring descriptor entry -* @da: device address -* @align: the alignment between the consumer and producer parts of the vring -* @num: num of buffers supported by this vring (must be power of two) -* @notifyid: a unique rproc-wide notify index for this vring. This notify -* index is used when kicking a remote processor, to let it know that this -* vring is triggered. -* @pa: physical address -* -* This descriptor is not a resource entry by itself; it is part of the -* vdev resource type (see below). -* -* Note that @da should either contain the device address where -* the remote processor is expecting the vring, or indicate that -* dynamically allocation of the vring's device address is supported. -*/ -struct fw_rsc_vdev_vring { -u32 da; -u32 align; -u32 num; -u32 notifyid; -u32 pa; -} __packed; - -/** -* struct fw_rsc_vdev - virtio device header -* @id: virtio device id (as in virtio_ids.h) -* @notifyid: a unique rproc-wide notify index for this vdev. This notify -* index is used when kicking a remote processor, to let it know that the -* status/features of this vdev have changes. -* @dfeatures: specifies the virtio device features supported by the firmware -* @gfeatures: a place holder used by the host to write back the -* negotiated features that are supported by both sides. -* @config_len: the size of the virtio config space of this vdev. The config -* space lies in the resource table immediate after this vdev header. -* @status: a place holder where the host will indicate its virtio progress. -* @num_of_vrings: indicates how many vrings are described in this vdev header -* @reserved: reserved (must be zero) -* @vring: an array of @num_of_vrings entries of 'struct fw_rsc_vdev_vring'. -* -* This resource is a virtio device header: it provides information about -* the vdev, and is then used by the host and its peer remote processors -* to negotiate and share certain virtio properties. -* -* By providing this resource entry, the firmware essentially asks remoteproc -* to statically allocate a vdev upon registration of the rproc (dynamic vdev -* allocation is not yet supported). -* -* Note: -* 1. unlike virtualization systems, the term 'host' here means -* the Linux side which is running remoteproc to control the remote -* processors. We use the name 'gfeatures' to comply with virtio's terms, -* though there isn't really any virtualized guest OS here: it's the host -* which is responsible for negotiating the final features. -* Yeah, it's a bit confusing. -* -* 2. immediately following this structure is the virtio config space for -* this vdev (which is specific to the vdev; for more info, read the virtio -* spec). The size of the config space is specified by @config_len. -*/ -struct fw_rsc_vdev { -u32 id; -u32 notifyid; -u32 dfeatures; -u32 gfeatures; -u32 config_len; -u8 status; -u8 num_of_vrings; -u8 reserved[2 ]; -struct fw_rsc_vdev_vring vring[]; -} __packed; +#include <linux/rsc_table.h> struct rproc ;
include/linux/rsc_table.h new file +306 -0
306 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 699/935 remoteproc: use rsc_table_for_each_entry() in rproc_handle_resources()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mukesh Ojha <[email protected]>
[ Upstream commit 49abb5d6e1ac8169cdfc0c3aa4408e0d90ee5696 ]
Replace the open-coded resource table iteration loop in rproc_handle_resources() with the rsc_table_for_each_entry() helper.
The remoteproc-specific dispatch logic (vendor resource handling via rproc_handle_rsc(), RSC_LAST bounds check, handler table lookup) is moved into a local callback rproc_handle_rsc_entry(), keeping the iteration mechanics in one canonical place.
The callback receives the payload offset within the table so that handlers which write back into the resource table (e.g. rproc_handle_carveout() recording a dynamically allocated address via rsc_offset) continue to work correctly.
No functional change.
Stable-dep-of: bb840ea69347 ("remoteproc: fix OOB read via signed offset in rsc_table_for_each_entry()")
--- drivers/remoteproc/remoteproc_core.c | 81 +++++++++++++--------------- include/linux/rsc_table.h | 53 ++++++++++++++++++ 2 files changed, 91 insertions(+), 43 deletions(-)
drivers/remoteproc/remoteproc_core.c +38 -43
@@ -1126,60 +1126,55 @@ static rproc_handle_resource_t rproc_loading_handlers[RSC_LAST] = { [RSC_VDEV] = rproc_handle_vdev, }; -/* handle firmware resource entries before booting the remote processor */ -static int rproc_handle_resources (struct rproc *rproc, -rproc_handle_resource_t handlers[RSC_LAST ]) +struct rproc_rsc_cb_data { +struct rproc *rproc; +rproc_handle_resource_t *handlers; +}; + +static int rproc_handle_rsc_entry (u32 type,void *rsc,int offset, +int avail,void *data) { +struct rproc_rsc_cb_data *d = data; +struct rproc *rproc = d->rproc;struct device *dev = &rproc->dev;rproc_handle_resource_t handler; -int ret =0 , i; - -if (!rproc->table_ptr) -return 0 ; +int ret; -for (i =0 ; i < rproc->table_ptr->num; i++) { -int offset = rproc->table_ptr->offset[i]; -struct fw_rsc_hdr *hdr = (void *)rproc->table_ptr + offset; -int avail = rproc->table_sz - offset -sizeof (*hdr); -void *rsc = (void *)hdr +sizeof (*hdr); +dev_dbg (dev,"rsc: type %d\n" , type); -/* make sure table isn't truncated */ -if (avail <0 ) { -dev_err (dev,"rsc table is truncated\n" ); -return -EINVAL ; - } - -dev_dbg (dev,"rsc: type %d\n" , hdr->type); +if (type >=RSC_VENDOR_START && type <=RSC_VENDOR_END ) { + ret =rproc_handle_rsc (rproc, type, rsc, offset, avail); +if (ret ==RSC_HANDLED ) +return 0 ; +if (ret <0 ) +return ret; +dev_warn (dev,"unsupported vendor resource %d\n" , type); +return 0 ; + } -if (hdr->type >=RSC_VENDOR_START && - hdr->type <=RSC_VENDOR_END ) { - ret =rproc_handle_rsc (rproc, hdr->type, rsc, - offset +sizeof (*hdr), avail); -if (ret ==RSC_HANDLED ) -continue ; -else if (ret <0 ) -break ; +if (type >=RSC_LAST ) { +dev_warn (dev,"unsupported resource %d\n" , type); +return 0 ; + } -dev_warn (dev,"unsupported vendor resource %d\n" , - hdr->type); -continue ; - } + handler = d->handlers[type]; +if (!handler) +return 0 ; -if (hdr->type >=RSC_LAST ) { -dev_warn (dev,"unsupported resource %d\n" , hdr->type); -continue ; - } +return handler (rproc, rsc, offset, avail); +} - handler = handlers[hdr->type]; -if (!handler) -continue ; +/* handle firmware resource entries before booting the remote processor */ +static int rproc_handle_resources (struct rproc *rproc, +rproc_handle_resource_t handlers[RSC_LAST ]) +{ +struct rproc_rsc_cb_data d = { .rproc = rproc, .handlers = handlers }; - ret =handler (rproc, rsc, offset +sizeof (*hdr), avail); -if (ret) -break ; - } +if (!rproc->table_ptr) +return 0 ; -return ret; +return rsc_table_for_each_entry (rproc->table_ptr, rproc->table_sz, + &rproc->dev, rproc_handle_rsc_entry, &d); }static int rproc_prepare_subdevices (struct rproc *rproc)
include/linux/rsc_table.h +53 -0
57 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 700/935 remoteproc: fix OOB read via signed offset in rsc_table_for_each_entry()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mukesh Ojha <[email protected]>
[ Upstream commit bb840ea69347aff7bde5a208e7b5b180669a7656 ]
table->offset[i] is a u32 from firmware, but was stored into a signed int. A crafted offset like 0xFFFFFFF0 becomes -16, placing hdr 16 bytes before the table buffer. The subsequent avail check was bypassed because the negative int was promoted to a large size_t in the expression "table_sz - offset - sizeof(*hdr)", yielding a large positive avail and letting the out-of-bounds hdr->type read proceed undetected.
Store the offset as u32 and validate it with unsigned comparisons before any pointer arithmetic.
--- include/linux/rsc_table.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
include/linux/rsc_table.h +11 -6
@@ -337,17 +337,22 @@ static inline int rsc_table_for_each_entry(struct resource_table *table,int i, ret;for (i =0 ; i < table->num; i++) { -int offset = table->offset[i]; -struct fw_rsc_hdr *hdr = (void *)table + offset; -int avail = table_sz - offset -sizeof (*hdr); -int rsc_offset = offset +sizeof (*hdr); -void *rsc = (void *)hdr +sizeof (*hdr); +u32 offset = table->offset[i]; +struct fw_rsc_hdr *hdr; +int avail, rsc_offset; +void *rsc; -if (avail <0 ) { +if (offset <sizeof (*table) || offset >= table_sz || + table_sz - offset <sizeof (*hdr)) {dev_err (dev,"rsc table is truncated\n" );return -EINVAL ; } + hdr = (void *)table + offset; + avail = table_sz - offset -sizeof (*hdr); + rsc_offset = offset +sizeof (*hdr); + rsc = (void *)hdr +sizeof (*hdr); + ret =cb (hdr->type, rsc, rsc_offset, avail, data);if (ret)return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 701/935 scripts/tags.sh: improve compiled sources generation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jialu Xu <[email protected]>
[ Upstream commit 82089b00ae026f638277c51bf3f36c68ed4021c7 ]
Use grep instead of sed for all compiled sources generation, it is three times more efficient.
Stable-dep-of: a9b93c34625a ("scripts/tags.sh: Prevent binary files appearing in cscope.files")
--- scripts/tags.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/tags.sh +1 -1
@@ -105,7 +105,7 @@ all_compiled_sources() { echo include/generated/autoconf.h find $ignore -name "*.cmd" -exec \ - sed -n -E 's/^source_.* (.*)/\1/p; s/^ (\S.*) \\/\1/p' {} \+ | + grep -Poh '(?<=^ )\S+|(?<== )\S+[^\\](?=$)' {} \+ | awk '!a[$0]++' } | xargs realpath -es $([ -z "$KBUILD_ABS_SRCTREE" ] && echo --relative-to=.) | sort -u
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 702/935 scripts/tags.sh: Prevent binary files appearing in cscope.files
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergei Litvin <[email protected]>
[ Upstream commit a9b93c34625a27bed5dc0f80ee2a359ceb955172 ]
When executing the command make COMPILED_SOURCE=1 cscope, the resulting cscope.files file contains filenames with the extensions *.rlib, *.rmeta, and *.so.
To fix this, modify the regular expression in the all_compiled_sources() function so that only files with the extensions *.h, *.c, *.S, and *.rs are accepted.
The issue has been introduced by commit 4f491bb6ea2a ("scripts/tags.sh:
collect compiled source precisely") which implemented the parsing of compiled sources from *.cmd files instead of using the "find" command.
--- scripts/tags.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/tags.sh +1 -1
@@ -105,7 +105,7 @@ all_compiled_sources() { echo include/generated/autoconf.h find $ignore -name "*.cmd" -exec \ - grep -Poh '(?<=^ )\S+|(?<== )\S+[^\\](?=$)' {} \+ | + grep -Poh '(?<=^ )\S+\.([chS]|rs)(?=\s)|(?<== )\S+\.(?1)(?=$)' {} \+ | awk '!a[$0]++' } | xargs realpath -es $([ -z "$KBUILD_ABS_SRCTREE" ] && echo --relative-to=.) | sort -u
Signature · 1 line
2.53.0
Re: [PATCH 5.15 702/935] scripts/tags.sh: Prevent binary files appearing in cscope.files
Quoted 21 lines · Greg Kroah-Hartman
5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergei Litvin <[email protected]>
[ Upstream commit
a9b93c34625a27bed5dc0f80ee2a359ceb955172]When executing the command
make COMPILED_SOURCE=1 cscope, the resultingcscope.filesfile contains filenames with the extensions *.rlib, *.rmeta, and *.so.To fix this, modify the regular expression in the
all_compiled_sources()function so that only files with the extensions *.h, *.c, *.S, and *.rs are accepted.The issue has been introduced by commit
4f491bb6ea2a("scripts/tags.sh:
collect compiled source precisely") which implemented the parsing of compiled sources from *.cmd files instead of using the "find" command.
Quoted 9 lines
Fixes 4f491bb6ea2a ("scripts/tags.sh: collect compiled source precisely")Signed-off-by Sergei Litvin <[email protected]>Acked-by Miguel Ojeda <[email protected]>Tested-by Nicolas Schier <[email protected]>Reviewed-by Nicolas Schier <[email protected]>[nsc: cleaned-up commit message line breaks and removed cc trailers]Signed-off-by Nicolas Schier <[email protected]>Signed-off-by Sasha Levin <[email protected]>
(Same comment as for 5.10.y) Before 6.1 there was no Rust, so in principle this may not be needed (at least for the *.rlib, *.rmeta and the Rust *.sos from proc macros), but it shouldn't hurt.
Cheers,
Miguel
Greg Kroah-Hartman
maintainerRe: [PATCH 5.15 702/935] scripts/tags.sh: Prevent binary files appearing in cscope.files
Quoted 33 lines · Miguel Ojeda
Quoted 21 lines · Greg Kroah-Hartman
5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergei Litvin <[email protected]>
[ Upstream commit
a9b93c34625a27bed5dc0f80ee2a359ceb955172]When executing the command
make COMPILED_SOURCE=1 cscope, the resultingcscope.filesfile contains filenames with the extensions *.rlib, *.rmeta, and *.so.To fix this, modify the regular expression in the
all_compiled_sources()function so that only files with the extensions *.h, *.c, *.S, and *.rs are accepted.The issue has been introduced by commit
4f491bb6ea2a("scripts/tags.sh:
collect compiled source precisely") which implemented the parsing of compiled sources from *.cmd files instead of using the "find" command.Quoted 9 lines
Fixes 4f491bb6ea2a ("scripts/tags.sh: collect compiled source precisely")Signed-off-by Sergei Litvin <[email protected]>Acked-by Miguel Ojeda <[email protected]>Tested-by Nicolas Schier <[email protected]>Reviewed-by Nicolas Schier <[email protected]>[nsc: cleaned-up commit message line breaks and removed cc trailers]Signed-off-by Nicolas Schier <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Quoted 3 lines
(Same comment as for 5.10.y) Before 6.1 there was no Rust, so in principle this may not be needed (at least for the
*.rlib,*.rmetaand the Rust*.sos from proc macros), but it shouldn't hurt.
Thanks for the review, I'll just leave it as is :)
greg k-h
Greg Kroah-Hartman
maintainerPATCH 703/935 RDMA/srp: fix heap information leak on a truncated SRP_CRED_REQ
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yehyeong Lee <[email protected]>
[ Upstream commit 961ac0f0c5e414abdd6b33fae84b311d9fde0bd0 ]
srp_recv_done() passes wc->byte_len to srp_process_rsp(). It passes nothing to srp_process_cred_req() and srp_process_aer_req(), which read fixed-size fields from the receive buffer without checking that those fields were received.
The buffer size is max_ti_iu_len, which comes from the login response and is not validated. A target that advertises 8 and then sends an 8-byte SRP_CRED_REQ makes the initiator read req->tag from beyond the end of the buffer. req->tag is copied into the SRP_CRED_RSP and sent back, so those bytes reach the target. SRP_AER_REQ behaves the same way and also reads req->lun.
The leak is 8 bytes per response. max_ti_iu_len also decides which slab cache the buffer comes from. With 8 the buffer is a kmalloc-8 object and the read is entirely outside it:
BUG: KASAN: slab-out-of-bounds in srp_recv_done+0x172b/0x1aa0 Read of size 8 at addr ffff888104714da8 by task kworker/u8:3/50 which belongs to the cache kmalloc-8 of size 8 The buggy address is located 0 bytes to the right of allocated 8-byte region [ffff888104714da0, ffff888104714da8)
Without KASAN the returned bytes are whatever is next in the slab. One run returned ".strtab".
rsp->data[3] in srp_process_rsp() has the same problem: only resp_data_len is checked before it is read.
Drop a request that is shorter than the structure being parsed, and check byte_len before the tsk_mgmt read.
--- drivers/infiniband/ulp/srp/ib_srp.c | 45 +++++++++++++++++++---------- 1 file changed, 30 insertions(+), 15 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +30 -15
@@ -1942,7 +1942,8 @@ static void srp_process_rsp(struct srp_rdma_ch *ch, struct srp_rsp *rsp, ch->req_lim +=be32_to_cpu (rsp->req_lim_delta);if (rsp->tag == ch->tsk_mgmt_tag) { ch->tsk_mgmt_status =-1 ; -if (be32_to_cpu (rsp->resp_data_len) >=4 ) +if (be32_to_cpu (rsp->resp_data_len) >=4 && + byte_len >=sizeof (*rsp) +4 ) ch->tsk_mgmt_status = rsp->data[3 ];complete (&ch->tsk_mgmt_done); }else {
@@ -2042,13 +2043,20 @@ static int srp_response_common(struct srp_rdma_ch *ch, s32 req_delta, }static void srp_process_cred_req (struct srp_rdma_ch *ch, -struct srp_cred_req *req) +struct srp_cred_req *req,u32 byte_len) { -struct srp_cred_rsp rsp = { - .opcode =SRP_CRED_RSP , - .tag = req->tag, - }; -s32 delta =be32_to_cpu (req->req_lim_delta); +struct srp_cred_rsp rsp = { .opcode =SRP_CRED_RSP }; +s32 delta; + +if (byte_len <sizeof (*req)) { +shost_printk (KERN_ERR , ch->target->scsi_host,PFX +"dropping truncated SRP_CRED_REQ (%u bytes received, %zu expected)\n" , + byte_len,sizeof (*req)); +return ; + } + + rsp.tag = req->tag; + delta =be32_to_cpu (req->req_lim_delta);if (srp_response_common (ch, delta, &rsp,sizeof (rsp))) shost_printk(KERN_ERR, ch->target->scsi_host, PFX
@@ -2056,14 +2064,21 @@ static void srp_process_cred_req(struct srp_rdma_ch *ch, }static void srp_process_aer_req (struct srp_rdma_ch *ch, -struct srp_aer_req *req) +struct srp_aer_req *req,u32 byte_len) {struct srp_target_port *target = ch->target; -struct srp_aer_rsp rsp = { - .opcode =SRP_AER_RSP , - .tag = req->tag, - }; -s32 delta =be32_to_cpu (req->req_lim_delta); +struct srp_aer_rsp rsp = { .opcode =SRP_AER_RSP }; +s32 delta; + +if (byte_len <sizeof (*req)) { +shost_printk (KERN_ERR , target->scsi_host,PFX +"dropping truncated SRP_AER_REQ (%u bytes received, %zu expected)\n" , + byte_len,sizeof (*req)); +return ; + } + + rsp.tag = req->tag; + delta =be32_to_cpu (req->req_lim_delta);shost_printk (KERN_ERR , target->scsi_host,PFX "ignoring AER for LUN %llu\n" ,scsilun_to_int (&req->lun));
@@ -2105,11 +2120,11 @@ static void srp_recv_done(struct ib_cq *cq, struct ib_wc *wc)break ;case SRP_CRED_REQ : -srp_process_cred_req (ch, iu->buf); +srp_process_cred_req (ch, iu->buf, wc->byte_len);break ;case SRP_AER_REQ : -srp_process_aer_req (ch, iu->buf); +srp_process_aer_req (ch, iu->buf, wc->byte_len);break ;case SRP_T_LOGOUT :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 704/935 ARM: 9485/1: mm: acquire mmap write lock around show_pte() for user faults
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xie Yuanbin <[email protected]>
[ Upstream commit 1039bffd6ae9c75b42b7d148d6c1106134107b66 ]
When CONFIG_DEBUG_USER=y, and cmdline "user_debug=31" is set, a user fault may trigger show_pte() without any lock.
If another thread in the same process concurrently calls munmap(), the page table pages may be freed while show_pte() is still traversing them, causing a use-after-free in show_pte().
If CONFIG_ARM_LPAE=y, this may cause a kernel panic if the pages table of PMD are freed when show_pte() is running.
Acquire mmap_write_lock() around show_pte() for user faults to fix the contention.
For user faults, additionally restrict that show_pte() is called only when the addr is a user-space address (addr < TASK_SIZE). This is because the lock of tsk->mm only protects the virtual memory of user address space, furthermore, dumping the page tables of a kernel-space address for user faults is unnecessary and may have security implications.
Keep everything unchanged for kernel faults, because the kernel is already in the "oops" state, acquiring a lock may risk a deadlock.
--- arch/arm/mm/fault.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
arch/arm/mm/fault.c +14 -2
@@ -154,7 +154,11 @@ __do_user_fault(unsigned long addr, unsigned int fsr, unsigned int sig,pr_err ("8<--- cut here ---\n" );pr_err ("%s: unhandled page fault (%d) at 0x%08lx, code 0x%03x\n" , tsk->comm, sig, addr, fsr); -show_pte (KERN_ERR , tsk->mm, addr); +if (likely (addr <TASK_SIZE )) { +mmap_write_lock (tsk->mm); +show_pte (KERN_ERR , tsk->mm, addr); +mmap_write_unlock (tsk->mm); + } show_regs(regs); }#endif
@@ -532,7 +536,15 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)pr_alert ("8<--- cut here ---\n" );pr_alert ("Unhandled fault: %s (0x%03x) at 0x%08lx\n" , inf->name, fsr, addr); -show_pte (KERN_ALERT , current->mm, addr); +if (likely (user_mode (regs))) { +if (addr <TASK_SIZE ) { +mmap_write_lock (current->mm); +show_pte (KERN_ALERT , current->mm, addr); +mmap_write_unlock (current->mm); + } + }else { +show_pte (KERN_ALERT , current->mm, addr); + }arm_notify_die ("" , regs, inf->sig, inf->code, (void __user *)addr, fsr,0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 705/935 ocfs2: use bitmap API in fill_node_map
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit 6d4a93b6809270e5c7d7216b20f4ef2e88213eb3 ]
Pass bits directly into fill_node_map helper and use bitmap API directly to simplify code.
Stable-dep-of: 3e326f3bf165 ("ocfs2: synchronize heartbeat callbacks with o2net teardown")
--- fs/ocfs2/cluster/heartbeat.c | 18 ++++++++---------- fs/ocfs2/cluster/heartbeat.h | 2 +- fs/ocfs2/cluster/netdebug.c | 2 +- fs/ocfs2/cluster/tcp.c | 6 ++---- fs/ocfs2/dlm/dlmdomain.c | 2 +- fs/ocfs2/stack_o2cb.c | 6 +++--- 6 files changed, 16 insertions(+), 20 deletions(-)
fs/ocfs2/cluster/heartbeat.c +8 -10
@@ -385,7 +385,7 @@ static void o2hb_nego_timeout(struct work_struct *work)if (reg->hr_last_hb_status)return ; -o2hb_fill_node_map (live_node_bitmap,sizeof (live_node_bitmap)); +o2hb_fill_node_map (live_node_bitmap,O2NM_MAX_NODES );/* lowest node as master node to make negotiate decision. */ master_node =find_next_bit (live_node_bitmap,O2NM_MAX_NODES ,0 );
@@ -1100,7 +1100,7 @@ static int o2hb_do_disk_heartbeat(struct o2hb_region *reg)* If a node is not configured but is in the livemap, we still need * to read the slot so as to be able to remove it from the livemap. */ -o2hb_fill_node_map (live_node_bitmap,sizeof (live_node_bitmap)); +o2hb_fill_node_map (live_node_bitmap,O2NM_MAX_NODES ); i =-1 ;while ((i =find_next_bit (live_node_bitmap,O2NM_MAX_NODES , i +1 )) <O2NM_MAX_NODES ) {
@@ -1463,23 +1463,21 @@ void o2hb_init(void)/* if we're already in a callback then we're already serialized by the sem */ static void o2hb_fill_node_map_from_callback (unsigned long *map, -unsigned bytes) +unsigned int bits) { -BUG_ON (bytes < (BITS_TO_LONGS (O2NM_MAX_NODES ) *sizeof (unsigned long ))); - -memcpy (map, &o2hb_live_node_bitmap, bytes); +bitmap_copy (map, o2hb_live_node_bitmap, bits); }/* * get a map of all nodes that are heartbeating in any regions */ -void o2hb_fill_node_map (unsigned long *map,unsigned bytes) +void o2hb_fill_node_map (unsigned long *map,unsigned int bits) {/* callers want to serialize this map and callbacks so that they * can trust that they don't miss nodes coming to the party */ down_read (&o2hb_callback_sem);spin_lock (&o2hb_live_lock); -o2hb_fill_node_map_from_callback (map, bytes); +o2hb_fill_node_map_from_callback (map, bits);spin_unlock (&o2hb_live_lock);up_read (&o2hb_callback_sem); }
@@ -2551,7 +2549,7 @@ int o2hb_check_node_heartbeating_no_sem(u8 node_num)unsigned long testing_map[BITS_TO_LONGS (O2NM_MAX_NODES )];spin_lock (&o2hb_live_lock); -o2hb_fill_node_map_from_callback (testing_map,sizeof (testing_map)); +o2hb_fill_node_map_from_callback (testing_map,O2NM_MAX_NODES );spin_unlock (&o2hb_live_lock);if (!test_bit (node_num, testing_map)) { mlog(ML_HEARTBEAT,
@@ -2568,7 +2566,7 @@ int o2hb_check_node_heartbeating_from_callback(u8 node_num) {unsigned long testing_map[BITS_TO_LONGS (O2NM_MAX_NODES )]; -o2hb_fill_node_map_from_callback (testing_map,sizeof (testing_map)); +o2hb_fill_node_map_from_callback (testing_map,O2NM_MAX_NODES );if (!test_bit (node_num, testing_map)) { mlog(ML_HEARTBEAT, "node (%u) does not have heartbeating enabled.\n",
fs/ocfs2/cluster/heartbeat.h +1 -1
@@ -59,7 +59,7 @@ int o2hb_register_callback(const char *region_uuid,void o2hb_unregister_callback (const char *region_uuid,struct o2hb_callback_func *hc);void o2hb_fill_node_map (unsigned long *map, -unsigned bytes); +unsigned int bits);void o2hb_exit (void );void o2hb_init (void );int o2hb_check_node_heartbeating_no_sem (u8 node_num);
fs/ocfs2/cluster/netdebug.c +1 -1
@@ -438,7 +438,7 @@ static int o2net_fill_bitmap(char *buf, int len)unsigned long map[BITS_TO_LONGS (O2NM_MAX_NODES )];int i =-1 , out =0 ; -o2net_fill_node_map (map,sizeof (map)); +o2net_fill_node_map (map,O2NM_MAX_NODES );while ((i =find_next_bit (map,O2NM_MAX_NODES , i +1 )) <O2NM_MAX_NODES ) out +=scnprintf (buf + out,PAGE_SIZE - out,"%d " , i);
fs/ocfs2/cluster/tcp.c +2 -4
@@ -990,14 +990,12 @@ static int o2net_tx_can_proceed(struct o2net_node *nn, }/* Get a map of all nodes to which this node is currently connected to */ -void o2net_fill_node_map (unsigned long *map,unsigned bytes) +void o2net_fill_node_map (unsigned long *map,unsigned int bits) {struct o2net_sock_container *sc;int node, ret; -BUG_ON (bytes < (BITS_TO_LONGS (O2NM_MAX_NODES ) *sizeof (unsigned long ))); - -memset (map,0 , bytes); +bitmap_zero (map, bits);for (node =0 ; node <O2NM_MAX_NODES ; ++node) {if (!o2net_tx_can_proceed (o2net_nn_from_num (node), &sc, &ret))continue ;
fs/ocfs2/dlm/dlmdomain.c +1 -1
@@ -1612,7 +1612,7 @@ static int dlm_try_to_join_domain(struct dlm_ctxt *dlm)/* group sem locking should work for us here -- we're already * registered for heartbeat events so filling this should be * atomic wrt getting those handlers called. */ -o2hb_fill_node_map (dlm->live_nodes_map,sizeof (dlm->live_nodes_map)); +o2hb_fill_node_map (dlm->live_nodes_map,O2NM_MAX_NODES );spin_lock (&dlm->spinlock);memcpy (ctxt->live_map, dlm->live_nodes_map,sizeof (ctxt->live_map));
fs/ocfs2/stack_o2cb.c +3 -3
@@ -273,17 +273,17 @@ static int o2cb_cluster_check(void)*/ #define O2CB_MAP_STABILIZE_COUNT 60for (i =0 ; i <O2CB_MAP_STABILIZE_COUNT ; ++i) { -o2hb_fill_node_map (hbmap,sizeof (hbmap)); +o2hb_fill_node_map (hbmap,O2NM_MAX_NODES );if (!test_bit (node_num, hbmap)) {printk (KERN_ERR "o2cb: %s heartbeat has not been " "started.\n" , (o2hb_global_heartbeat_active () ?"Global" :"Local" ));return -EINVAL ; } -o2net_fill_node_map (netmap,sizeof (netmap)); +o2net_fill_node_map (netmap,O2NM_MAX_NODES );/* Force set the current node to allow easy compare */ set_bit (node_num, netmap); -if (!memcmp (hbmap, netmap,sizeof (hbmap))) +if (bitmap_equal (hbmap, netmap,O2NM_MAX_NODES ))return 0 ;if (i <O2CB_MAP_STABILIZE_COUNT -1 )msleep (1000 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 706/935 ocfs2: synchronize heartbeat callbacks with o2net teardown
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 3e326f3bf16506873777444608e8b715aab74a7a ]
Patch series "ocfs2: harden heartbeat teardown races".
This series fixes two OCFS2 heartbeat/o2net teardown races found by KASAN.
This patch (of 2):
Heartbeat callbacks stay registered while configfs local-node teardown enters o2net_stop_listening(). A node-down event can still run through o2net_disconnect_node() and o2net_set_nn_state() while teardown is destroying o2net_wq, so the later queue/flush operations can hit a dead workqueue. KASAN has caught this as a slab-use-after-free in __queue_work() with the call chain:
KASAN slab-use-after-free in __queue_work+0x56/0xa90
Read of size 4 Call trace: dump_stack_lvl+0x66/0xa0 print_report+0xce/0x630 __queue_work+0x56/0xa90 srso_alias_return_thunk+0x5/0xfbef5 __virt_addr_valid+0x19f/0x330 kasan_report+0xe0/0x110 __queue_delayed_work+0x58/0x1e0 queue_delayed_work_on+0xb4/0xc0 o2net_set_nn_state+0x467/0x840 o2net_disconnect_node+0x7b/0xe0 o2net_hb_node_down_cb+0x54/0x60 o2hb_run_event_list+0x236/0x2d0 o2hb_check_slot+0xad4/0xbc0 lock_release+0xc8/0x290 o2hb_check_slot+0x9ea/0xbc0 trace_hardirqs_on+0x18/0x130 o2hb_do_disk_heartbeat+0x646/0xb30 (fs/ocfs2/cluster/heartbeat.c:1079) __lock_acquire+0x466/0x2260 lockdep_hardirqs_on_prepare+0xea/0x1a0 ktime_get_with_offset+0xe9/0x230 o2hb_thread+0x14e/0x770 kthread+0x1ad/0x1f0 ret_from_fork+0x3c9/0x540 __switch_to+0x2e9/0x730 ret_from_fork_asm+0x1a/0x30 Allocated by task stack: kasan_save_stack+0x33/0x60 kasan_save_track+0x14/0x30 __kasan_kmalloc+0xaa/0xb0 __kmalloc_noprof+0x292/0x760 __alloc_workqueue+0x736/0xc60 alloc_workqueue_noprof+0xb1/0x110 o2net_start_listening+0xe5/0x430 o2nm_node_local_store+0x184/0x310 configfs_write_iter+0x18a/0x210 vfs_write+0x469/0x810 ksys_write+0xd2/0x170 do_syscall_64+0x115/0x6a0 (arch/x86/entry/syscall_64.c:87) entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task stack: kasan_save_stack+0x33/0x60 kasan_save_track+0x14/0x30 kasan_save_free_info+0x3b/0x60 __kasan_slab_free+0x5f/0x80 kfree+0x313/0x590 rcu_core+0x4f4/0x1320 handle_softirqs+0x156/0x660
queue_delayed_work_ono2net_set_nn_stateo2net_disconnect_nodeo2net_hb_node_down_cbo2hb_run_event_list
Keep heartbeat callbacks registered so quorum state still tracks node state, but stop them from driving o2net reconnect/disconnect work once local teardown starts. Mark the transport offline before destroying o2net_wq, wait for any in-flight heartbeat callback to finish, and delay bring-up replay until the new local node is published through o2nm_this_node().
The replay also has to stay serialized with heartbeat callback delivery. Otherwise a live-node snapshot can be copied, a real hb_down callback can install -ENOTCONN for a peer, and the stale replay can call o2net_hb_node_up() for that same peer and queue reconnect work even though heartbeat is already down.
The buggy scenario involves two paths, with each column showing the order within that path:
local-node teardown: heartbeat node-down callback:
1. configfs local-off enters 1. o2hb_run_event_list() invokes
o2net_stop_listening(). o2net_hb_node_down_cb().
2. teardown heads for 2. the callback reaches
destroy_workqueue(o2net_wq). o2net_disconnect_node() and
o2net_set_nn_state().
3. teardown destroys and NULLs 3. the callback flushes or queues
o2net_wq. work through o2net_wq.
--- fs/ocfs2/cluster/heartbeat.c | 43 ++++++++++++++---- fs/ocfs2/cluster/heartbeat.h | 5 ++ fs/ocfs2/cluster/nodemanager.c | 4 ++ fs/ocfs2/cluster/tcp.c | 83 +++++++++++++++++++++++++++------- fs/ocfs2/cluster/tcp.h | 1 + 5 files changed, 109 insertions(+), 27 deletions(-)
fs/ocfs2/cluster/heartbeat.c +33 -10
@@ -1461,13 +1461,38 @@ void o2hb_init(void)o2hb_debug_init (); } -/* if we're already in a callback then we're already serialized by the sem */ -static void o2hb_fill_node_map_from_callback (unsigned long *map, -unsigned int bits) +static void __o2hb_fill_node_map (unsigned long *map,unsigned int bits) {bitmap_copy (map, o2hb_live_node_bitmap, bits); } +void o2hb_callback_read_lock (void ) +{ +down_read (&o2hb_callback_sem); +} + +void o2hb_callback_read_unlock (void ) +{ +up_read (&o2hb_callback_sem); +} + +void o2hb_synchronize_callbacks (void ) +{ +down_write (&o2hb_callback_sem); +up_write (&o2hb_callback_sem); +} + +/* +* Callers must already hold o2hb_callback_sem for read or write so the copy +* stays serialized with callback delivery. +*/ +void o2hb_fill_node_map_locked (unsigned long *map,unsigned int bits) +{ +spin_lock (&o2hb_live_lock); +__o2hb_fill_node_map (map, bits); +spin_unlock (&o2hb_live_lock); +} +/* * get a map of all nodes that are heartbeating in any regions */
@@ -1475,11 +1500,9 @@ void o2hb_fill_node_map(unsigned long *map, unsigned int bits) {/* callers want to serialize this map and callbacks so that they * can trust that they don't miss nodes coming to the party */ -down_read (&o2hb_callback_sem); -spin_lock (&o2hb_live_lock); -o2hb_fill_node_map_from_callback (map, bits); -spin_unlock (&o2hb_live_lock); -up_read (&o2hb_callback_sem); +o2hb_callback_read_lock (); +o2hb_fill_node_map_locked (map, bits); +o2hb_callback_read_unlock (); }EXPORT_SYMBOL_GPL (o2hb_fill_node_map);
@@ -2549,7 +2572,7 @@ int o2hb_check_node_heartbeating_no_sem(u8 node_num)unsigned long testing_map[BITS_TO_LONGS (O2NM_MAX_NODES )];spin_lock (&o2hb_live_lock); -o2hb_fill_node_map_from_callback (testing_map,O2NM_MAX_NODES ); +__o2hb_fill_node_map (testing_map,O2NM_MAX_NODES );spin_unlock (&o2hb_live_lock);if (!test_bit (node_num, testing_map)) { mlog(ML_HEARTBEAT,
@@ -2566,7 +2589,7 @@ int o2hb_check_node_heartbeating_from_callback(u8 node_num) {unsigned long testing_map[BITS_TO_LONGS (O2NM_MAX_NODES )]; -o2hb_fill_node_map_from_callback (testing_map,O2NM_MAX_NODES ); +o2hb_fill_node_map_locked (testing_map,O2NM_MAX_NODES );if (!test_bit (node_num, testing_map)) { mlog(ML_HEARTBEAT, "node (%u) does not have heartbeating enabled.\n",
fs/ocfs2/cluster/heartbeat.h +5 -0
@@ -58,6 +58,11 @@ int o2hb_register_callback(const char *region_uuid, struct o2hb_callback_func *hc);void o2hb_unregister_callback (const char *region_uuid,struct o2hb_callback_func *hc); +void o2hb_callback_read_lock (void ); +void o2hb_callback_read_unlock (void ); +void o2hb_synchronize_callbacks (void ); +void o2hb_fill_node_map_locked (unsigned long *map, +unsigned int bits);void o2hb_fill_node_map (unsigned long *map,unsigned int bits);void o2hb_exit (void );
fs/ocfs2/cluster/nodemanager.c +4 -0
@@ -325,6 +325,7 @@ static ssize_t o2nm_node_local_store(struct config_item *item, const char *page,struct o2nm_node *node =to_o2nm_node (item);struct o2nm_cluster *cluster;unsigned long tmp; +bool starting = false;char *p = (char *)page;ssize_t ret;
@@ -361,6 +362,7 @@ static ssize_t o2nm_node_local_store(struct config_item *item, const char *page, ret =o2net_start_listening (node);if (ret) goto out; + starting = true; } if (!tmp && cluster->cl_has_local &&
@@ -373,6 +375,8 @@ static ssize_t o2nm_node_local_store(struct config_item *item, const char *page,if (node->nd_local) { cluster->cl_has_local = tmp; cluster->cl_local_node = node->nd_num; +if (starting) +o2net_complete_start_listening (node); } ret = count;
fs/ocfs2/cluster/tcp.c +66 -17
137 lines not on this page · raw message
fs/ocfs2/cluster/tcp.h +1 -0
@@ -96,6 +96,7 @@ struct o2nm_node;int o2net_register_hb_callbacks (void );void o2net_unregister_hb_callbacks (void );int o2net_start_listening (struct o2nm_node *node); +void o2net_complete_start_listening (struct o2nm_node *node);void o2net_stop_listening (struct o2nm_node *node);void o2net_disconnect_node (struct o2nm_node *node);int o2net_num_connected_peers (void );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 707/935 drm/sun4i: vi scaler: Fix coefficient selection
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jernej Skrabec <[email protected]>
[ Upstream commit 5c31990b21f0b535732deb2b658b78b07464f56c ]
Currently, vertical coefficients are selected based on horizontal scaling, which is wrong. Additionally, chroma coefficients should be selected based on format subsampling.
Fix all that.
--- drivers/gpu/drm/sun4i/sun8i_vi_scaler.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/gpu/drm/sun4i/sun8i_vi_scaler.c +12 -6
@@ -891,20 +891,26 @@ static void sun8i_vi_scaler_set_coeff(struct regmap *map, u32 base, lan3coefftab32_left[offset + i]);regmap_write (map,SUN8I_SCALER_VSU_YHCOEFF1 (base, i), lan3coefftab32_right[offset + i]); + } + offset =sun8i_vi_scaler_coef_index (vstep) * +SUN8I_VI_SCALER_COEFF_COUNT ; +for (i =0 ; i <SUN8I_VI_SCALER_COEFF_COUNT ; i++) +regmap_write (map,SUN8I_SCALER_VSU_YVCOEFF (base, i), + lan2coefftab32[offset + i]); + + offset =sun8i_vi_scaler_coef_index (hstep / format->hsub) * +SUN8I_VI_SCALER_COEFF_COUNT ; +for (i =0 ; i <SUN8I_VI_SCALER_COEFF_COUNT ; i++) {regmap_write (map,SUN8I_SCALER_VSU_CHCOEFF0 (base, i), ch_left[offset + i]);regmap_write (map,SUN8I_SCALER_VSU_CHCOEFF1 (base, i), ch_right[offset + i]); } - - offset =sun8i_vi_scaler_coef_index (hstep) * + offset =sun8i_vi_scaler_coef_index (vstep / format->vsub) *SUN8I_VI_SCALER_COEFF_COUNT ; -for (i =0 ; i <SUN8I_VI_SCALER_COEFF_COUNT ; i++) { -regmap_write (map,SUN8I_SCALER_VSU_YVCOEFF (base, i), - lan2coefftab32[offset + i]); +for (i =0 ; i <SUN8I_VI_SCALER_COEFF_COUNT ; i++)regmap_write (map,SUN8I_SCALER_VSU_CVCOEFF (base, i), cy[offset + i]); - } }void sun8i_vi_scaler_enable (struct sun8i_mixer *mixer,int layer,bool enable)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 708/935 of: property: add missing kerneldoc for of_graph_get_endpoint_count()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuninori Morimoto <[email protected]>
[ Upstream commit 4c3b386c46065c0d26ae5503e73d6634f24e2d36 ]
of_graph_get_endpoint_count() doesn't have kerneldoc. Add it.
Stable-dep-of: 62bac3202042 ("drm/sun4i: tcon-top: Keep mixer routes distinct")
--- drivers/of/property.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/of/property.c +6 -0
@@ -807,6 +807,12 @@ struct device_node *of_graph_get_remote_port(const struct device_node *node) }EXPORT_SYMBOL (of_graph_get_remote_port); +/** +* of_graph_get_endpoint_count() - get the number of endpoints in a device node +* @np: parent device node containing ports and endpoints +* +* Return: count of endpoint of this device node +*/ int of_graph_get_endpoint_count (const struct device_node *np) {struct device_node *endpoint;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 709/935 of: property: use unsigned int return on of_graph_get_endpoint_count()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuninori Morimoto <[email protected]>
[ Upstream commit 574849054d97cee5be78d6c149d84685647fe774 ]
Because of of_graph_get_endpoint_count() doesn't report error, just return count of endpoint, the return type should be unsigned. Tidyup it.
Stable-dep-of: 62bac3202042 ("drm/sun4i: tcon-top: Keep mixer routes distinct")
--- drivers/of/property.c | 4 ++-- include/linux/of_graph.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/of/property.c +2 -2
@@ -813,10 +813,10 @@ EXPORT_SYMBOL(of_graph_get_remote_port);* * Return: count of endpoint of this device node */ -int of_graph_get_endpoint_count (const struct device_node *np) +unsigned int of_graph_get_endpoint_count (const struct device_node *np) {struct device_node *endpoint; -int num =0 ; +unsigned int num =0 ;for_each_endpoint_of_node (np, endpoint) num++;
include/linux/of_graph.h +2 -2
@@ -41,7 +41,7 @@ struct of_endpoint {bool of_graph_is_present (const struct device_node *node);int of_graph_parse_endpoint (const struct device_node *node,struct of_endpoint *endpoint); -int of_graph_get_endpoint_count (const struct device_node *np); +unsigned int of_graph_get_endpoint_count (const struct device_node *np);struct device_node *of_graph_get_port_by_id (struct device_node *node,u32 id);struct device_node *of_graph_get_next_endpoint (const struct device_node *parent,struct device_node *previous);
@@ -68,7 +68,7 @@ static inline int of_graph_parse_endpoint(const struct device_node *node,return -ENOSYS ; } -static inline int of_graph_get_endpoint_count (const struct device_node *np) +static inline unsigned int of_graph_get_endpoint_count (const struct device_node *np) {return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 710/935 bitfield: Add less-checking __FIELD_{GET,PREP}()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit 2a6c045640c38a407a39cd40c3c4d8dd2fd89aa8 ]
The BUILD_BUG_ON_MSG() check against "~0ull" works only with "unsigned (long) long" _mask types. For constant masks, that condition is usually met, as GENMASK() yields an UL value. The few places where the constant mask is stored in an intermediate variable were fixed by changing the variable type to u64 (see e.g. [1] and [2]).
However, for non-constant masks, smaller unsigned types should be valid, too, but currently lead to "result of comparison of constant 18446744073709551615 with expression of type ... is always false"-warnings with clang and W=1.
Hence refactor the __BF_FIELD_CHECK() helper, and factor out __FIELD_{GET,PREP}(). The later lack the single problematic check, but are otherwise identical to FIELD_{GET,PREP}(), and are intended to be used in the fully non-const variants later.
[1] commit 5c667d5a5a3ec166 ("clk: sp7021: Adjust width of _m in
HWM_FIELD_PREP()")
[2] commit cfd6fb45cfaf46fa ("crypto: ccree - avoid out-of-range warnings from clang")
Stable-dep-of: 62bac3202042 ("drm/sun4i: tcon-top: Keep mixer routes distinct")
--- include/linux/bitfield.h | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-)
include/linux/bitfield.h +28 -8
@@ -57,7 +57,7 @@#define __bf_cast_unsigned (type, x) ((__unsigned_scalar_typeof(type))(x)) -#define __BF_FIELD_CHECK (_mask, _reg, _val, _pfx) \ +#define __BF_FIELD_CHECK_MASK (_mask, _val, _pfx) \ ({ \ BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask), \ _pfx "mask is not constant"); \
@@ -65,13 +65,33 @@BUILD_BUG_ON_MSG (__builtin_constant_p (_val) ? \ ~((_mask) >>__bf_shf (_mask)) & (_val) :0 , \ _pfx"value too large for the field" ); \ -BUILD_BUG_ON_MSG (__bf_cast_unsigned (_mask, _mask) > \ -__bf_cast_unsigned (_reg, ~0ull ), \ - _pfx"type of reg too small for mask" ); \__BUILD_BUG_ON_NOT_POWER_OF_2 ((_mask) + \ (1ULL <<__bf_shf (_mask))); \ }) +#define __BF_FIELD_CHECK_REG (mask, reg, pfx) \ + BUILD_BUG_ON_MSG(__bf_cast_unsigned(mask, mask) > \ + __bf_cast_unsigned(reg, ~0ull), \ + pfx "type of reg too small for mask") + +#define __BF_FIELD_CHECK (mask, reg, val, pfx) \ + ({ \ + __BF_FIELD_CHECK_MASK(mask, val, pfx); \ + __BF_FIELD_CHECK_REG(mask, reg, pfx); \ + }) + +#define __FIELD_PREP (mask, val, pfx) \ + ({ \ + __BF_FIELD_CHECK_MASK(mask, val, pfx); \ + ((typeof(mask))(val) << __bf_shf(mask)) & (mask); \ + }) + +#define __FIELD_GET (mask, reg, pfx) \ + ({ \ + __BF_FIELD_CHECK_MASK(mask, 0U, pfx); \ + (typeof(mask))(((reg) & (mask)) >> __bf_shf(mask)); \ + }) +/** * FIELD_MAX() - produce the maximum value representable by a field * @_mask: shifted mask defining the field's length and position
@@ -108,8 +128,8 @@*/ #define FIELD_PREP (_mask, _val) \ ({ \ - __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \ - ((typeof(_mask))(_val) << __bf_shf(_mask)) & (_mask); \ + __BF_FIELD_CHECK_REG(_mask, 0ULL, "FIELD_PREP: "); \ + __FIELD_PREP(_mask, _val, "FIELD_PREP: "); \ })/**
@@ -122,8 +142,8 @@*/ #define FIELD_GET (_mask, _reg) \ ({ \ - __BF_FIELD_CHECK(_mask, _reg, 0U, "FIELD_GET: "); \ - (typeof(_mask))(((_reg) & (_mask)) >> __bf_shf(_mask)); \ + __BF_FIELD_CHECK_REG(_mask, _reg, "FIELD_GET: "); \ + __FIELD_GET(_mask, _reg, "FIELD_GET: "); \ }) extern void __compiletime_error("value doesn't fit into mask")
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 711/935 bitfield: Add non-constant field_{prep,get}() helpers
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit c1c6ab80b25c8db1e2ef5ae3ac8075d2c242ae13 ]
The existing FIELD_{GET,PREP}() macros are limited to compile-time constants. However, it is very common to prepare or extract bitfield elements where the bitfield mask is not a compile-time constant.
To avoid this limitation, the AT91 clock driver and several other drivers already have their own non-const field_{prep,get}() macros. Make them available for general use by adding them to <linux/bitfield.h>, and improve them slightly:
1. Avoid evaluating macro parameters more than once,
2. Replace "ffs() - 1" by "__ffs()",
3. Support 64-bit use on 32-bit architectures,
4. Wire field_{get,prep}() to FIELD_{GET,PREP}() when mask is actually constant.
This is deliberately not merged into the existing FIELD_{GET,PREP}() macros, as people expressed the desire to keep stricter variants for increased safety, or for performance critical paths.
Yury: use __mask withing new macros.
Stable-dep-of: 62bac3202042 ("drm/sun4i: tcon-top: Keep mixer routes distinct")
--- include/linux/bitfield.h | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+)
include/linux/bitfield.h +59 -0
@@ -16,6 +16,7 @@* FIELD_{GET,PREP} macros take as first parameter shifted mask * from which they extract the base mask and shift amount. * Mask must be a compilation time constant. +* field_{get,prep} are variants that take a non-const mask. * * Example: *
@@ -193,4 +194,62 @@ __MAKE_OP(64)#undef __MAKE_OP#undef ____MAKE_OP +#define __field_prep (mask, val) \ + ({ \ + __auto_type __mask = (mask); \ + typeof(__mask) __val = (val); \ + unsigned int __shift = BITS_PER_TYPE(__mask) <= 32 ? \ + __ffs(__mask) : __ffs64(__mask); \ + (__val << __shift) & __mask; \ + }) + +#define __field_get (mask, reg) \ + ({ \ + __auto_type __mask = (mask); \ + typeof(__mask) __reg = (reg); \ + unsigned int __shift = BITS_PER_TYPE(__mask) <= 32 ? \ + __ffs(__mask) : __ffs64(__mask); \ + (__reg & __mask) >> __shift; \ + }) + +/** +* field_prep() - prepare a bitfield element +* @mask: shifted mask defining the field's length and position, must be +* non-zero +* @val: value to put in the field +* +* Return: field value masked and shifted to its final destination +* +* field_prep() masks and shifts up the value. The result should be +* combined with other fields of the bitfield using logical OR. +* Unlike FIELD_PREP(), @mask is not limited to a compile-time constant. +* Typical usage patterns are a value stored in a table, or calculated by +* shifting a constant by a variable number of bits. +* If you want to ensure that @mask is a compile-time constant, please use +* FIELD_PREP() directly instead. +*/ +#define field_prep (mask, val) \ + (__builtin_constant_p(mask) ? __FIELD_PREP(mask, val, "field_prep: ") \ + : __field_prep(mask, val)) + +/** +* field_get() - extract a bitfield element +* @mask: shifted mask defining the field's length and position, must be +* non-zero +* @reg: value of entire bitfield +* +* Return: extracted field value +* +* field_get() extracts the field specified by @mask from the +* bitfield passed in as @reg by masking and shifting it down. +* Unlike FIELD_GET(), @mask is not limited to a compile-time constant. +* Typical usage patterns are a value stored in a table, or calculated by +* shifting a constant by a variable number of bits. +* If you want to ensure that @mask is a compile-time constant, please use +* FIELD_GET() directly instead. +*/ +#define field_get (mask, reg) \ + (__builtin_constant_p(mask) ? __FIELD_GET(mask, reg, "field_get: ") \ + : __field_get(mask, reg)) +#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 712/935 drm/sun4i: tcon: Drop TCON TOP device reference
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jernej Skrabec <[email protected]>
[ Upstream commit 8208832a38ff3d2560eb8a77a9d7a2f17d8ebcdc ]
of_find_device_by_node() takes a device reference. Drop it after mux configuration succeeds.
--- drivers/gpu/drm/sun4i/sun4i_tcon.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/gpu/drm/sun4i/sun4i_tcon.c +9 -10
@@ -1404,7 +1404,7 @@ static int sun8i_r40_tcon_tv_set_mux(struct sun4i_tcon *tcon, {struct device_node *port, *remote;struct platform_device *pdev; -int id, ret; +int id, ret =0 ;/* find TCON TOP platform device and TCON id */
@@ -1427,21 +1427,20 @@ static int sun8i_r40_tcon_tv_set_mux(struct sun4i_tcon *tcon,if (IS_ENABLED (CONFIG_DRM_SUN8I_TCON_TOP ) && encoder->encoder_type ==DRM_MODE_ENCODER_TMDS ) { ret =sun8i_tcon_top_set_hdmi_src (&pdev->dev, id); -if (ret) { -put_device (&pdev->dev); -return ret; - } +if (ret) + goto out_put_device; }if (IS_ENABLED (CONFIG_DRM_SUN8I_TCON_TOP )) { ret =sun8i_tcon_top_de_config (&pdev->dev, tcon->id, id); -if (ret) { -put_device (&pdev->dev); -return ret; - } +if (ret) + goto out_put_device; } -return 0 ; +out_put_device: +put_device (&pdev->dev); + +return ret; }static const struct sun4i_tcon_quirks sun4i_a10_quirks = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 713/935 drm/sun4i: crtc: Propagate layer initialization error
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jernej Skrabec <[email protected]>
[ Upstream commit 7061ff05ed4a3cf16e83f7e3ad09cbd212508a32 ]
sun4i_crtc_init() returns plain NULL when layer initialization fails, while all its other error paths return an error pointer. The only caller, sun4i_tcon_bind(), checks the result with IS_ERR() and happily continues with tcon->crtc set to NULL. sun4i_rgb_init() and sun4i_lvds_init() then dereference it in drm_crtc_mask(), which oopses.
Return the error pointer instead.
--- drivers/gpu/drm/sun4i/sun4i_crtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/sun4i/sun4i_crtc.c +1 -1
@@ -207,7 +207,7 @@ struct sun4i_crtc *sun4i_crtc_init(struct drm_device *drm, planes =sunxi_engine_layers_init (drm, engine);if (IS_ERR (planes)) {dev_err (drm->dev,"Couldn't create the planes\n" ); -return NULL ; +return ERR_CAST (planes); }/* find primary and cursor planes for drm_crtc_init_with_planes */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 714/935 drm/sun4i: tcon: Drop remote endpoint reference
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jernej Skrabec <[email protected]>
[ Upstream commit 3f77e4072630e2301efdbe521e7fca10311043ec ]
sun4i_tcon_of_get_id_from_port() never drops the reference taken by of_graph_get_remote_endpoint(). The function is not only called during bind, but also on every mode set through sun8i_r40_tcon_tv_set_mux(), so the leak accumulates.
--- drivers/gpu/drm/sun4i/sun4i_tcon.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/sun4i/sun4i_tcon.c +1 -0
@@ -965,6 +965,7 @@ static int sun4i_tcon_of_get_id_from_port(struct device_node *port)continue ; ret =of_property_read_u32 (remote,"reg" , ®); +of_node_put (remote);if (ret)continue ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 715/935 drm/sun4i: dw-hdmi: Drop TCON TOP port reference
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jernej Skrabec <[email protected]>
[ Upstream commit d2a242e5688a17b79c89cd966cd31820c5096d80 ]
When the HDMI controller is fed by TCON TOP, the port node used to enumerate the possible CRTCs is never released.
--- drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c +2 -0
@@ -83,6 +83,8 @@ static u32 sun8i_dw_hdmi_find_possible_crtcs(struct drm_device *drm,of_node_put (remote_port); } } + +of_node_put (port); }else { crtcs =drm_of_find_possible_crtcs (drm, node); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 716/935 drm/sun4i: hdmi-phy: Fix H6 8-bit MPLL config at 594 MHz
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jernej Skrabec <[email protected]>
[ Upstream commit 0ba6deddaae74f0539c0303bfb5f860adbe1a68b ]
The 8-bit entry of the last MPLL row (594 MHz) doesn't lock reliably on H6. 4K@60 RGB/YUV444, which is the mode that reaches this entry, doesn't come up.
Align the value with the vendor driver. Other entries are left alone, they are used by lower pixel clocks which work fine.
Tested with 4K@60 on a LG TV.
--- drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c +1 -1
@@ -90,7 +90,7 @@ static const struct dw_hdmi_mpll_config sun50i_h6_mpll_cfg[] = { }, }, { 594000000, { - { 0x1a40, 0x0003 }, + { 0x1a7c, 0x0003 }, { 0x3b4c, 0x0003 }, { 0x5a64, 0x0003 }, },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 717/935 cpufreq: imx6q: fix devres accumulation across driver rebind
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 22c23c72c3b21fa3ec3db5070dfc0582794e0ef9 ]
imx6_soc_volt is allocated with devm_kcalloc(cpu_dev, ...), where cpu_dev is the CPU device from get_cpu_device(0). That device is never unbound, so its devres list is never released, and imx6q_cpufreq_remove() does not free the array either. Every probe therefore adds an allocation that stays for the lifetime of the system.
Allocate against the platform device instead. Its devres is released when the driver is unbound, which is exactly the lifetime the array wants:imx6q_set_target() reads it, and nothing may reach that after cpufreq_unregister_driver().
That makes the array actually go away on unbind, so also clear the file-scope pointer in remove and on the failed-probe path, rather than leave it pointing at memory devres is about to release.
Tested by rebinding the driver on qemu's mcimx6ul-evk.
--- drivers/cpufreq/imx6q-cpufreq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/cpufreq/imx6q-cpufreq.c +3 -1
@@ -418,7 +418,7 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) }/* Make imx6_soc_volt array's size same as arm opp number */ - imx6_soc_volt =devm_kcalloc (cpu_dev, num,sizeof (*imx6_soc_volt), + imx6_soc_volt =devm_kcalloc (&pdev->dev, num,sizeof (*imx6_soc_volt),GFP_KERNEL );if (imx6_soc_volt ==NULL ) { ret = -ENOMEM ;
@@ -503,6 +503,7 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)return 0 ; free_freq_table: + imx6_soc_volt =NULL ;dev_pm_opp_free_cpufreq_table (cpu_dev, &freq_table); out_free_opp:dev_pm_opp_of_remove_table (cpu_dev);
@@ -524,6 +525,7 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)static int imx6q_cpufreq_remove (struct platform_device *pdev) {cpufreq_unregister_driver (&imx6q_cpufreq_driver); + imx6_soc_volt =NULL ;dev_pm_opp_free_cpufreq_table (cpu_dev, &freq_table);dev_pm_opp_of_remove_table (cpu_dev);regulator_put (arm_reg);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 718/935 cpufreq: imx6q: fix out-of-bounds write when probed more than once
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 8c3afcf27fa4582c1ab912503dc8a4ebb8dc0f82 ]
imx6_soc_volt is allocated fresh on every probe, sized to the number of ARM OPPs:
imx6_soc_volt = devm_kcalloc(cpu_dev, num, sizeof(*imx6_soc_volt), GFP_KERNEL);
but it is filled through soc_opp_count, which has static storage and is never reset. A second bind after an unbind keeps indexing from where the first one stopped, and writes past the end of the new array.
Unbinding and rebinding the driver on qemu's mcimx6ul-evk, under KASAN:
BUG: KASAN: slab-out-of-bounds in imx6q_cpufreq_probe+0x3b0/0xa34 Write of size 4 at addr c5e90480 by task binder/73 imx6q_cpufreq_probe from platform_probe+0x88/0xe4 platform_probe from really_probe+0x108/0x384 bind_store from kernfs_fop_write_iter+0x1b4/0x28c
The write lands one u32 past the end of the allocation.
soc_opp_count is only read a few lines below the loop that fills it, so it never needed static storage. Make it a local.
--- drivers/cpufreq/imx6q-cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/imx6q-cpufreq.c +1 -1
@@ -53,7 +53,6 @@ static unsigned int max_freq;static unsigned int transition_latency;static u32 *imx6_soc_volt; -static u32 soc_opp_count;static int imx6q_set_target (struct cpufreq_policy *policy,unsigned int index) {
@@ -346,6 +345,7 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)const struct property *prop;const __be32 *val;u32 nr, i, j; +u32 soc_opp_count =0 ; cpu_dev =get_cpu_device (0 );if (!cpu_dev) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 719/935 IB/isert: delay the final Login Response until the session is registered
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yehyeong Lee <[email protected]>
[ Upstream commit 464f5afa92d071a226f88424803b0fcf88093ede ]
isert_put_login_tx() puts the final Login Response on the wire before __transport_register_session(), which iscsi_post_login_handler() reaches only after iscsi_target_do_login() returns. An initiator that issues a SCSI command as soon as it sees that response can have it executed against an se_session whose se_tpg is still NULL, and the ib-comp-wq worker oopses on the NULL dereference.
Oops: general protection fault, probably for non-canonical address 0xdffffc000000000f: 0000 [#1] SMP KASAN NOPTI KASAN: null-ptr-deref in range [0x0000000000000078-0x000000000000007f] CPU: 0 UID: 0 PID: 178 Comm: kworker/0:1H Not tainted 7.2.0-rc5-V2CTL-gf5098b6bae76 #10 PREEMPT(lazy) Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 Workqueue: ib-comp-wq ib_cq_poll_work RIP: 0010:target_submit+0xbe/0x390 Code: fa 48 c1 ea 03 80 3c 02 00 0f 85 89 02 00 00 48 b8 00 00 00 00 00 fc ff df 4d 8b 64 24 18 49 8d 7c 24 78 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 5a 02 00 00 48 8d 7b 78 4d 8b 6c 24 78 48 b8 00 RSP: 0018:ffff8881058cfa78 EFLAGS: 00010206 RAX: dffffc0000000000 RBX: ffff88810c78c6f0 RCX: ffffffff964bb363 RDX: 000000000000000f RSI: 00000000fffffe00 RDI: 0000000000000078 RBP: 1ffff11020b19f52 R08: 0000000000000001 R09: ffffed1020b19f52 R10: 0000000000000003 R11: ffff88810596c000 R12: 0000000000000000 R13: ffff88810c61b000 R14: ffff88810c6a3400 R15: ffff88810c61b044 FS: 0000000000000000(0000) GS:ffff8881822b2000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f1f1b83c000 CR3: 000000006fe72001 CR4: 0000000000770ef0 PKRU: 55555554 Call Trace: <TASK> ? __pfx__raw_spin_lock_bh+0x10/0x10 ? __pfx_target_submit+0x10/0x10 ? mutex_lock+0x81/0xe0 ? __pfx_mutex_lock+0x10/0x10 ? iscsit_execute_cmd+0x650/0x850 iscsit_sequence_cmd+0x186/0x3d0 iscsit_process_scsi_cmd+0x87/0x300 isert_recv_done+0x1002/0x2390 ? __pfx_isert_recv_done+0x10/0x10 ? rxe_poll_cq+0x253/0x3d0 ? finish_task_switch.isra.0+0x1dc/0xa70 __ib_process_cq+0xe1/0x390 ib_cq_poll_work+0x46/0x150 process_one_work+0x633/0x1030 ? assign_work+0x11d/0x370 worker_thread+0x45b/0xd10 ? __pfx_worker_thread+0x10/0x10 ? __pfx_worker_thread+0x10/0x10 kthread+0x2c6/0x3b0 ? recalc_sigpending+0x15c/0x1e0 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x36e/0x5a0 ? __pfx_ret_from_fork+0x10/0x10 ? __switch_to+0x572/0xdd0 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1a/0x30 </TASK> Modules linked in: ---[ end trace 0000000000000000 ]---
Delay the final Login Response instead. isert_get_rx_pdu() runs from iscsi_target_rx_thread() after conn->rx_login_comp, completed by iscsi_post_login_handler() after __transport_register_session(); iscsi-TCP and cxgbit already take PDUs from that thread, isert alone does not. The buffers are still posted first, so the initiator's first command does not meet an empty receive queue and nothing depends on RNR flow control, and the header and payload live in isert_conn, not in the struct iscsi_login that iscsi_target_nego_release() frees first.
Over rxe, 400 login cycles per run, the oops appeared in 10 of 20 unpatched runs and in none of 20 runs with this patch. An initiator that never waits is handled by the next patch.
Not tested: iWARP, discovery sessions over iSER, and real HCAs.
--- drivers/infiniband/ulp/isert/ib_isert.c | 20 ++++++++++++++++++-- drivers/infiniband/ulp/isert/ib_isert.h | 1 + 2 files changed, 19 insertions(+), 2 deletions(-)
drivers/infiniband/ulp/isert/ib_isert.c +18 -2
@@ -58,6 +58,8 @@ static void isert_recv_done(struct ib_cq *cq, struct ib_wc *wc);static void isert_send_done (struct ib_cq *cq,struct ib_wc *wc);static void isert_login_recv_done (struct ib_cq *cq,struct ib_wc *wc);static void isert_login_send_done (struct ib_cq *cq,struct ib_wc *wc); +static void isert_unmap_tx_desc (struct iser_tx_desc *tx_desc, +struct ib_device *ib_dev);static int isert_sg_tablesize_set (const char *val,const struct kernel_param *kp) {
@@ -500,6 +502,8 @@ isert_connect_release(struct isert_conn *isert_conn)if (isert_conn->qp)isert_destroy_qp (isert_conn); +isert_unmap_tx_desc (&isert_conn->login_tx_desc, device->ib_device); +if (isert_conn->login_desc)isert_free_login_buf (isert_conn);
@@ -960,14 +964,17 @@ isert_put_login_tx(struct iscsi_conn *conn, struct iscsi_login *login,mutex_lock (&isert_conn->mutex); isert_conn->state =ISER_CONN_FULL_FEATURE ;mutex_unlock (&isert_conn->mutex); - goto post_send; + +/* Sent from isert_get_rx_pdu() after registration. */ + isert_conn->login_rsp_pending = true; +return 0 ; } ret =isert_login_post_recv (isert_conn);if (ret)return ret; } -post_send: + ret =isert_login_post_send (isert_conn, tx_desc);if (ret)return ret;
@@ -2628,8 +2635,17 @@ static void isert_free_conn(struct iscsi_conn *conn)static void isert_get_rx_pdu (struct iscsi_conn *conn) { +struct isert_conn *isert_conn = conn->context;struct completion comp; +/* The session is registered by now; see isert_put_login_tx(). */ +if (isert_conn->login_rsp_pending) { + isert_conn->login_rsp_pending = false; +if (isert_login_post_send (isert_conn, + &isert_conn->login_tx_desc)) +return ; + } +init_completion (&comp);wait_for_completion_interruptible (&comp);
drivers/infiniband/ulp/isert/ib_isert.h +1 -0
@@ -178,6 +178,7 @@ struct isert_conn {struct completion login_comp;struct completion login_req_comp;struct iser_tx_desc login_tx_desc; +bool login_rsp_pending;struct rdma_cm_id *cm_id;struct ib_qp *qp;struct ib_cq *cq;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 720/935 IB/isert: post the full-feature receive buffers after session registration
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yehyeong Lee <[email protected]>
[ Upstream commit 5247dde9daac7e107853b6fea043f7f47be033f7 ]
isert_put_login_tx() posts the full-feature receive buffers before __transport_register_session() runs, so an initiator that does not wait for the final Login Response can still have a SCSI command executed against an se_session whose se_tpg is NULL - the same oops as the previous patch, at target_submit+0xbe.
Post them from isert_get_rx_pdu(), which the previous patch already uses to send that response, and post them before that send: the receive queue is filled at the moment the initiator is told it may use it. Allocating there keeps the existing property that a memory allocation failure cannot happen once the final Login Response is on the wire.
The receive queue is already empty between the final Login Request and isert_post_recvm(); this moves the second point later, from a median of 92 us to 172 us over 1200 logins. Only an initiator that sends before it has been told to can reach that window, and on IB and RoCE its send is retried there until the buffers appear - isert_rdma_accept() asks for rnr_retry_count = 7. iWARP has no RNR flow control, so there the same send terminates the connection instead.
Measured over rxe, 400 login cycles per run, with an initiator that does not wait: an instrumented build counted no entries to isert_recv_done() before the buffers are posted in 10 runs, where that initiator oopsed 8 of 10 unpatched runs and 5 of 10 with only the previous patch.
Not tested: iWARP, discovery sessions over iSER, and real HCAs.
--- drivers/infiniband/ulp/isert/ib_isert.c | 41 ++++++++++++------------- 1 file changed, 20 insertions(+), 21 deletions(-)
drivers/infiniband/ulp/isert/ib_isert.c +20 -21
@@ -951,21 +951,7 @@ isert_put_login_tx(struct iscsi_conn *conn, struct iscsi_login *login, }if (!login->login_failed) {if (login->login_complete) { - ret =isert_alloc_rx_descriptors (isert_conn); -if (ret) -return ret; - - ret =isert_post_recvm (isert_conn, -ISERT_QP_MAX_RECV_DTOS ); -if (ret) -return ret; - -/* Now we are in FULL_FEATURE phase */ -mutex_lock (&isert_conn->mutex); - isert_conn->state =ISER_CONN_FULL_FEATURE ; -mutex_unlock (&isert_conn->mutex); - -/* Sent from isert_get_rx_pdu() after registration. */ +/* Posted and sent from isert_get_rx_pdu(). */ isert_conn->login_rsp_pending = true;return 0 ; }
@@ -2638,13 +2624,26 @@ static void isert_get_rx_pdu(struct iscsi_conn *conn)struct isert_conn *isert_conn = conn->context;struct completion comp; +/* The login timeout timer can fail the login after isert_put_login_tx(). */ +if (!isert_conn->login_rsp_pending) +return ; + + isert_conn->login_rsp_pending = false; +/* The session is registered by now; see isert_put_login_tx(). */ -if (isert_conn->login_rsp_pending) { - isert_conn->login_rsp_pending = false; -if (isert_login_post_send (isert_conn, - &isert_conn->login_tx_desc)) -return ; - } +if (isert_alloc_rx_descriptors (isert_conn)) +return ; + +if (isert_post_recvm (isert_conn,ISERT_QP_MAX_RECV_DTOS )) +return ; + +/* Now we are in FULL_FEATURE phase */ +mutex_lock (&isert_conn->mutex); + isert_conn->state =ISER_CONN_FULL_FEATURE ; +mutex_unlock (&isert_conn->mutex); + +if (isert_login_post_send (isert_conn, &isert_conn->login_tx_desc)) +return ;init_completion (&comp);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 721/935 RDMA/siw: Introduce siw_free_cm_id
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guoqing Jiang <[email protected]>
[ Upstream commit 08456d4db73bbb3fcaa0d63252ea2399c65297a4 ]
Factor out a helper to simplify code.
Stable-dep-of: a93949718259 ("RDMA/siw: Fix use-after-free in siw_accept()")
--- drivers/infiniband/sw/siw/siw_cm.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-)
drivers/infiniband/sw/siw/siw_cm.c +14 -16
@@ -361,6 +361,15 @@ static int siw_cm_upcall(struct siw_cep *cep, enum iw_cm_event_type reason,return id->event_handler (id, &event); } +static void siw_free_cm_id (struct siw_cep *cep) +{ +if (!cep->cm_id) +return ; + + cep->cm_id->rem_ref (cep->cm_id); + cep->cm_id =NULL ; +} +/* * siw_qp_cm_drop() *
@@ -413,8 +422,7 @@ void siw_qp_cm_drop(struct siw_qp *qp, int schedule)default :break ; } - cep->cm_id->rem_ref (cep->cm_id); - cep->cm_id =NULL ; +siw_free_cm_id (cep);siw_cep_put (cep); } cep->state =SIW_EPSTATE_CLOSED ;
@@ -1172,8 +1180,7 @@ static void siw_cm_work_handler(struct work_struct *w) cep->sock =NULL ; }if (cep->cm_id) { - cep->cm_id->rem_ref (cep->cm_id); - cep->cm_id =NULL ; +siw_free_cm_id (cep);siw_cep_put (cep); } }
@@ -1704,10 +1711,7 @@ int siw_accept(struct iw_cm_id *id, struct iw_cm_conn_param *params) cep->state =SIW_EPSTATE_CLOSED ; -if (cep->cm_id) { - cep->cm_id->rem_ref (id); - cep->cm_id =NULL ; - } +siw_free_cm_id (cep);if (qp->cep) {siw_cep_put (cep); qp->cep =NULL ;
@@ -1885,10 +1889,7 @@ int siw_create_listen(struct iw_cm_id *id, int backlog)if (cep) {siw_cep_set_inuse (cep); -if (cep->cm_id) { - cep->cm_id->rem_ref (cep->cm_id); - cep->cm_id =NULL ; - } +siw_free_cm_id (cep); cep->sock =NULL ;siw_socket_disassoc (s); cep->state =SIW_EPSTATE_CLOSED ;
@@ -1918,10 +1919,7 @@ static void siw_drop_listeners(struct iw_cm_id *id)siw_cep_set_inuse (cep); -if (cep->cm_id) { - cep->cm_id->rem_ref (cep->cm_id); - cep->cm_id =NULL ; - } +siw_free_cm_id (cep);if (cep->sock) {siw_socket_disassoc (cep->sock);sock_release (cep->sock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 722/935 RDMA/siw: Fix use-after-free in siw_accept()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuangpeng Bai <[email protected]>
[ Upstream commit a9394971825933074032794a5feee5211509c774 ]
siw_accept() looks up the QP supplied by userspace. If that QP is already in RTS, the function jumps to error cleanup before associating the incoming CEP with it.
The cleanup tests whether qp->cep is non-NULL and assumes the current call installed the association. However, qp->cep can point to the CEP of an existing connection. The cleanup then drops a reference from the incoming cep, not qp->cep. Once the incoming endpoint loses its remaining references, this can free it before the subsequent cep->qp store, causing a use-after-free. It also clears the existing QP association.
Only release the association reference when qp->cep is the incoming CEP. This preserves an existing association and avoids accessing the freed endpoint.
--- drivers/infiniband/sw/siw/siw_cm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/siw/siw_cm.c +1 -1
@@ -1712,7 +1712,7 @@ int siw_accept(struct iw_cm_id *id, struct iw_cm_conn_param *params) cep->state =SIW_EPSTATE_CLOSED ;siw_free_cm_id (cep); -if (qp->cep) { +if (qp->cep == cep) {siw_cep_put (cep); qp->cep =NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 723/935 arm64: hibernate: mask DAIF before restoring hibernated kernel
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ada Couprie Diaz <[email protected]>
[ Upstream commit 684bde100117931f4c51c644a95f42f2dab041bc ]
The arm64 hibernate code manages the exception masking in an unsound way, leading to potential crashes and/or warnings during resume.
When a hibernation image is saved in swsusp_arch_suspend(), all DAIF exceptions are masked (by virtue of local_daif_save()), and the suspended image is saved assuming that all DAIF exceptions will remain masked when the image is restored.
When a hibernation image is resumed by swsusp_arch_resume(), only interrupts are masked (by virtue of local_irq_disable() in resume_target_kernel()). When pseudo-NMI is enabled the DAIF.IF bits will be clear, and regardless of pseudo-NMI the DAIF.DA bits will be clear.
This means that there are two problems:
(1) It is possible to take Debug, SError, or pseudo-NMI exceptions during the resume process. This is unsafe, as during the resume process both the old ane new kernels will tranisently be in an inconsistent state, and swsusp_arch_suspend_exit() won't retain an executable mapping of any exception vectors.
Any exception taken here will be fatal and silent.
(2) When re-entering the resumed kernel, some DAIF bits will be clear unexpectedly. This permits Debug, SError, or pseudo-NMI exceptions to be taken for a short period while the resumed kernel is not yet in a consistent state.
This is detected by CONFIG_ARM64_DEBUG_PRIORITY_MASKING.
Avoid these issues by masking all DAIF exceptions during resume.
--- arch/arm64/kernel/hibernate.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/arm64/kernel/hibernate.c +12 -0
@@ -494,9 +494,21 @@ int __nocfi swsusp_arch_resume(void)__hyp_set_vectors (el2_vectors); } +/* +* It is necessary to mask all DAIF exceptions here as: +* +* - The copy of swsusp_arch_suspend_exit() in the hibernation +* text cannot handle taking any exceptions. +* +* - The suspended kernel masked all DAIF exceptions in +* swsusp_arch_resume(), and expects to be re-entered in the +* same state : with all DAIF exceptions masked. +*/ +local_daif_save ();hibernate_exit (virt_to_phys (tmp_pg_dir), resume_hdr.ttbr1_el1, resume_hdr.reenter_kernel, restore_pblist, resume_hdr.__hyp_stub_vectors,virt_to_phys (zero_page)); +unreachable ();return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 724/935 arm64: hibernate: Restore DAIF state on error
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Murzin <[email protected]>
[ Upstream commit 541549827889d0380fd73f8aacb5de6ef7a5a1ac ]
Sashiko AI has reported that if swsusp_mte_save_tags() for some reason fails we return from swsusp_arch_suspend() with DAIF being masked - that is not what we'd expect. Restore the saved DAIF state before returning from the error path.
--- arch/arm64/kernel/hibernate.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm64/kernel/hibernate.c +3 -1
@@ -374,8 +374,10 @@ int swsusp_arch_suspend(void)crash_prepare_suspend (); ret =swsusp_mte_save_tags (); -if (ret) +if (ret) { +local_daif_restore (flags);return ret; + } sleep_cpu =smp_processor_id (); ret =swsusp_save ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 725/935 mfd: rave-sp: validate received frame payload lengths
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 0be718b5451bd83865d6e2a8d750ca7886c4772a ]
A received RAVE-SP frame contains protocol data followed by a variant-specific one- or two-byte checksum. rave_sp_receive_frame() derives a checksum pointer before proving that the frame contains the checksum, then passes the checksum-inclusive length to handlers that index the command, acknowledgment ID and event-data bytes or derive a reply payload length.
Name those protocol field offsets, prove the checksum extent before deriving the protocol-data length, pass only that data length to the handlers, and require the complete event or reply prefix before consuming it.
--- drivers/mfd/rave-sp.c | 64 +++++++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 20 deletions(-)
drivers/mfd/rave-sp.c +44 -20
@@ -63,6 +63,12 @@#define RAVE_SP_TX_BUFFER_SIZE \ (RAVE_SP_STX_ETX_SIZE + 2 * RAVE_SP_RX_BUFFER_SIZE) +enum rave_sp_frame_offset { +RAVE_SP_FRAME_CODE_OFFSET , +RAVE_SP_FRAME_ACK_ID_OFFSET , +RAVE_SP_FRAME_DATA_OFFSET , +}; +/** * enum rave_sp_deframer_state - Possible state for de-framer *
@@ -352,7 +358,7 @@ int rave_sp_exec(struct rave_sp *sp,int command, ret =0 ;u8 ackid; - command = sp->variant->cmd.translate (data[0 ]); + command = sp->variant->cmd.translate (data[RAVE_SP_FRAME_CODE_OFFSET ]);if (command <0 )return command;
@@ -366,8 +372,8 @@ int rave_sp_exec(struct rave_sp *sp, sp->reply = &reply;mutex_unlock (&sp->reply_lock); - data[0 ] = command; - data[1 ] = ackid; + data[RAVE_SP_FRAME_CODE_OFFSET ] = command; + data[RAVE_SP_FRAME_ACK_ID_OFFSET ] = ackid;rave_sp_write (sp, data, data_size);
@@ -388,16 +394,23 @@ EXPORT_SYMBOL_GPL(rave_sp_exec);static void rave_sp_receive_event (struct rave_sp *sp,const unsigned char *data,size_t length) { -u8 cmd[] = { - [0 ] =rave_sp_reply_code (data[0 ]), - [1 ] = data[1 ], - }; +unsigned long action; +u8 cmd[RAVE_SP_FRAME_DATA_OFFSET ]; + +if (length <RAVE_SP_FRAME_DATA_OFFSET +1 ) { +dev_warn (&sp->serdev->dev,"Dropping short event frame\n" ); +return ; + } + + cmd[RAVE_SP_FRAME_CODE_OFFSET ] = +rave_sp_reply_code (data[RAVE_SP_FRAME_CODE_OFFSET ]); + cmd[RAVE_SP_FRAME_ACK_ID_OFFSET ] = data[RAVE_SP_FRAME_ACK_ID_OFFSET ];rave_sp_write (sp, cmd,sizeof (cmd)); -blocking_notifier_call_chain (&sp->event_notifier_list, -rave_sp_action_pack (data[0 ], data[2 ]), -NULL ); + action =rave_sp_action_pack (data[RAVE_SP_FRAME_CODE_OFFSET ], + data[RAVE_SP_FRAME_DATA_OFFSET ]); +blocking_notifier_call_chain (&sp->event_notifier_list, action,NULL ); } static void rave_sp_receive_reply(struct rave_sp *sp,
@@ -405,27 +418,35 @@ static void rave_sp_receive_reply(struct rave_sp *sp, {struct device *dev = &sp->serdev->dev;struct rave_sp_reply *reply; -const size_t payload_length = length -2 ; +size_t payload_length; + +if (length <RAVE_SP_FRAME_DATA_OFFSET ) { +dev_warn (dev,"Dropping short reply frame\n" ); +return ; + } + payload_length = length -RAVE_SP_FRAME_DATA_OFFSET ;mutex_lock (&sp->reply_lock); reply = sp->reply;if (reply) { -if (reply->code == data[0 ] && reply->ackid == data[1 ] && +if (reply->code == data[RAVE_SP_FRAME_CODE_OFFSET ] && + reply->ackid == data[RAVE_SP_FRAME_ACK_ID_OFFSET ] && payload_length >= reply->length) {/* * We are relying on memcpy(dst, src, 0) to be a no-op * when handling commands that have a no-payload reply */ -memcpy (reply->data, &data[2 ], reply->length); +memcpy (reply->data, &data[RAVE_SP_FRAME_DATA_OFFSET ], + reply->length);complete (&reply->received); sp->reply =NULL ; }else {dev_err (dev,"Ignoring incorrect reply\n" );dev_dbg (dev,"Code: expected = 0x%08x received = 0x%08x\n" , - reply->code, data[0 ]); + reply->code, data[RAVE_SP_FRAME_CODE_OFFSET ]);dev_dbg (dev,"ACK ID: expected = 0x%08x received = 0x%08x\n" , - reply->ackid, data[1 ]); + reply->ackid, data[RAVE_SP_FRAME_ACK_ID_OFFSET ]);dev_dbg (dev,"Length: expected = %zu received = %zu\n" , reply->length, payload_length); }
@@ -439,10 +460,10 @@ static void rave_sp_receive_frame(struct rave_sp *sp, size_t length) {const size_t checksum_length = sp->variant->checksum->length; -const size_t payload_length = length - checksum_length; -const u8 *crc_reported = &data[payload_length];struct device *dev = &sp->serdev->dev;u8 crc_calculated[RAVE_SP_CHECKSUM_SIZE ]; +const u8 *crc_reported; +size_t payload_length;if (unlikely (checksum_length >sizeof (crc_calculated))) {dev_warn (dev,"Checksum too long, dropping\n" );
@@ -457,6 +478,9 @@ static void rave_sp_receive_frame(struct rave_sp *sp,return ; } + payload_length = length - checksum_length; + crc_reported = &data[payload_length]; + sp->variant->checksum->subroutine (data, payload_length, crc_calculated);
@@ -465,10 +489,10 @@ static void rave_sp_receive_frame(struct rave_sp *sp,return ; } -if (rave_sp_id_is_event (data[0 ])) -rave_sp_receive_event (sp, data, length); +if (rave_sp_id_is_event (data[RAVE_SP_FRAME_CODE_OFFSET ])) +rave_sp_receive_event (sp, data, payload_length);else -rave_sp_receive_reply (sp, data, length); +rave_sp_receive_reply (sp, data, payload_length); } static int rave_sp_receive_buf(struct serdev_device *serdev,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 726/935 mfd: iqs62x: Reject zero-length firmware records
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 08ea045e0b82cbcadb7a2efc43a23561489a00f2 ]
struct iqs62x_fw_rec includes the first data byte in its fixed-size header, so the parser advances by len - 1 bytes after that header. A zero len makes the size_t cursor update move back by one byte, so the next record overlaps the current record instead of following a valid declared extent.
Reject zero-length records and express the remaining-size check without an offset addition.
--- drivers/mfd/iqs62x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/iqs62x.c +1 -1
@@ -237,7 +237,7 @@ static int iqs62x_firmware_parse(struct iqs62x_core *iqs62x, fw_rec = (struct iqs62x_fw_rec *)(fw->data + pos); pos +=sizeof (*fw_rec); -if (pos + fw_rec->len -1 > fw->size) { +if (!fw_rec->len || fw_rec->len -1 > fw->size - pos) { ret = -EINVAL ;break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 727/935 drm/amdgpu/gfx6: Fixup emit_cntxcntl()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit 1edb323406aaf05739804d2faa2561f2d43bcd09 ]
Set bits on dword 2 like GFX7-8 except load_global_uconfig which doesn't exist on GFX6.
Emit VS_PARTIAL_FLUSH before VGT_FLUSH like GFX7-8.
For reference see old PAL which explains the bit fields in this register and that load_global_uconfig doesn't exist on GFX6 and also see gfx_v7_ring_emit_cntxcntl() for the GFX7 code which this commit follows.
--- drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | 28 ++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c +21 -7
@@ -1890,11 +1890,13 @@ static int gfx_v6_0_ring_test_ring(struct amdgpu_ring *ring)return r; } -static void gfx_v6_0_ring_emit_vgt_flush (struct amdgpu_ring *ring) +static void gfx_v6_0_ring_emit_event_write (struct amdgpu_ring *ring, +uint32_t event_type, +uint32_t event_index) {amdgpu_ring_write (ring,PACKET3 (PACKET3_EVENT_WRITE ,0 )); -amdgpu_ring_write (ring,EVENT_TYPE (VGT_FLUSH ) | -EVENT_INDEX (0 )); +amdgpu_ring_write (ring,EVENT_TYPE (event_type) | +EVENT_INDEX (event_index)); } static void gfx_v6_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr,
@@ -3036,10 +3038,22 @@ static uint64_t gfx_v6_0_get_gpu_clock_counter(struct amdgpu_device *adev)static void gfx_v6_ring_emit_cntxcntl (struct amdgpu_ring *ring,uint32_t flags) { -if (flags &AMDGPU_HAVE_CTX_SWITCH ) -gfx_v6_0_ring_emit_vgt_flush (ring); +u32 dw2 =0x80000000 ;/* set load_enable otherwise this package is just NOPs */ + +if (flags &AMDGPU_HAVE_CTX_SWITCH ) { +gfx_v6_0_ring_emit_event_write (ring,VS_PARTIAL_FLUSH ,4 ); +gfx_v6_0_ring_emit_event_write (ring,VGT_FLUSH ,0 ); + +/* set load_global_config (load_global_uconfig doesn't exist on GFX6) */ + dw2 |=0x1 ; +/* set load_cs_sh_regs */ + dw2 |=0x01000000 ; +/* set load_per_context_state & load_gfx_sh_regs */ + dw2 |=0x10002 ; + } +amdgpu_ring_write (ring,PACKET3 (PACKET3_CONTEXT_CONTROL ,1 )); -amdgpu_ring_write (ring,0x80000000 ); +amdgpu_ring_write (ring, dw2);amdgpu_ring_write (ring,0 ); }
@@ -3574,7 +3588,7 @@ static const struct amdgpu_ring_funcs gfx_v6_0_ring_funcs_gfx = {14 +14 +14 +/* gfx_v6_0_ring_emit_fence x3 for user fence, vm fence */ 7 +4 +/* gfx_v6_0_ring_emit_pipeline_sync */ SI_FLUSH_GPU_TLB_NUM_WREG *5 +7 +6 +/* gfx_v6_0_ring_emit_vm_flush */ -3 +2 +/* gfx_v6_ring_emit_cntxcntl including vgt flush */ +3 +2 +2 +/* gfx_v6_ring_emit_cntxcntl including VGT flush */ 5, /* SURFACE_SYNC */ .emit_ib_size = 6, /* gfx_v6_0_ring_emit_ib */ .emit_ib = gfx_v6_0_ring_emit_ib,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 728/935 ext4: fix spurious message about orphan cleanup on RO fs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
[ Upstream commit 5aa98f874c013bcce9bb84ffded2f0ef886e4e33 ]
When orphan_file feature is enabled, ext4_orphan_cleanup() was always walking through the orphan file looking for orphan inodes. This is mostly harmless but for read-only filesystem it results in spurious "orphan cleanup on readonly fs" message and in other cornercases it could result in similar somewhat misleading messages. Skip orphan cleanup if the orphan file is empty to avoid confusing messages.
--- fs/ext4/orphan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/orphan.c +1 -1
@@ -388,7 +388,7 @@ void ext4_orphan_cleanup(struct super_block *sb, struct ext4_super_block *es)struct ext4_orphan_info *oi = &EXT4_SB (sb)->s_orphan_info;int inodes_per_ob =ext4_inodes_per_orphan_block (sb); -if (!es->s_last_orphan && !oi->of_blocks) { +if (!es->s_last_orphan &&ext4_orphan_file_empty (sb)) {ext4_debug ("no orphan inodes to clean up\n" );return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 729/935 phy: rockchip: phy-rockchip-inno-csidphy: fix rk1808 hsfreq table
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gerald Loacker <[email protected]>
[ Upstream commit 4fae43e33a7c10951fbdc6baf409d51bd66aaefb ]
The rk1808 hsfreq table capped at 2499 Mbps, preventing a data rate of exactly 2500 Mbps. Extend the final entry to 2500 Mbps to support this rate.
This is essential for RK3588 reusing this array and fully supporting rates up to 2500 Mbps.
--- drivers/phy/rockchip/phy-rockchip-inno-csidphy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/rockchip/phy-rockchip-inno-csidphy.c +1 -1
@@ -146,7 +146,7 @@ static const struct hsfreq_range rk1808_mipidphy_hsfreq_ranges[] = { { 299, 0x06}, { 399, 0x08}, { 499, 0x0b}, { 599, 0x0e}, { 699, 0x10}, { 799, 0x12}, { 999, 0x16}, {1199, 0x1e}, {1399, 0x23}, {1599, 0x2d}, {1799, 0x32}, {1999, 0x37}, - {2199, 0x3c}, {2399, 0x41}, {2499, 0x46} + {2199, 0x3c}, {2399, 0x41}, {2500, 0x46} }; static const struct hsfreq_range rk3326_mipidphy_hsfreq_ranges[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 730/935 perf trace-event: Fix buffer overflow in read_string()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tanushree Shah <[email protected]>
[ Upstream commit 1121a7af1833f8b5723f1e32685b461614353d5d ]
read_string() writes into buf[BUFSIZ] one byte at a time without checking 'size' against the buffer bound before each write. A string longer than BUFSIZ in the input overflows the stack buffer.
Add a bounds check before each write to prevent overflow. On overflow the function returns NULL, matching its other error paths.
--- tools/perf/util/trace-event-read.c | 5 +++++ 1 file changed, 5 insertions(+)
tools/perf/util/trace-event-read.c +5 -0
@@ -125,6 +125,11 @@ static char *read_string(void) } } +if (size >= (int )sizeof (buf) -1 ) { +pr_debug ("string too long (max %zu bytes)" ,sizeof (buf) -1 ); + goto out; + } + buf[size++] = c;if (!c)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 731/935 drm/amdgpu/gfx6: Fixup emitting SWITCH_BUFFER packets
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit 7aac4242a11991d530eee3e141d6e445d5f11c22 ]
Implement the emit_switch_buffer() function instead of emitting them duing emit_ib, emit_pipeline_sync and emit_vm_flush.
Note that it isn't necessary to emit these in both emit_pipeline_sync() and emit_vm_flush() because amdgpu_vm_flush() already calls these when calling either of those functions.
--- drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | 38 ++++++++++----------------- 1 file changed, 14 insertions(+), 24 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c +14 -24
@@ -1935,12 +1935,6 @@ static void gfx_v6_0_ring_emit_ib(struct amdgpu_ring *ring,unsigned vmid =AMDGPU_JOB_GET_VMID (job);u32 header, control =0 ; -/* insert SWITCH_BUFFER packet before first IB in the ring frame */ -if (flags &AMDGPU_HAVE_CTX_SWITCH ) { -amdgpu_ring_write (ring,PACKET3 (PACKET3_SWITCH_BUFFER ,0 )); -amdgpu_ring_write (ring,0 ); - } -if (ib->flags &AMDGPU_IB_FLAG_CE ) header =PACKET3 (PACKET3_INDIRECT_BUFFER_CONST ,2 );else
@@ -2383,14 +2377,6 @@ static void gfx_v6_0_ring_emit_pipeline_sync(struct amdgpu_ring *ring)amdgpu_ring_write (ring, seq);amdgpu_ring_write (ring,0xffffffff );amdgpu_ring_write (ring,4 );/* poll interval */ - -if (usepfp) { -/* synce CE with ME to prevent CE fetch CEIB before context switch done */ -amdgpu_ring_write (ring,PACKET3 (PACKET3_SWITCH_BUFFER ,0 )); -amdgpu_ring_write (ring,0 ); -amdgpu_ring_write (ring,PACKET3 (PACKET3_SWITCH_BUFFER ,0 )); -amdgpu_ring_write (ring,0 ); - } } static void gfx_v6_0_ring_emit_vm_flush(struct amdgpu_ring *ring,
@@ -2414,12 +2400,6 @@ static void gfx_v6_0_ring_emit_vm_flush(struct amdgpu_ring *ring,/* sync PFP to ME, otherwise we might get invalid PFP reads */ amdgpu_ring_write (ring,PACKET3 (PACKET3_PFP_SYNC_ME ,0 ));amdgpu_ring_write (ring,0x0 ); - -/* synce CE with ME to prevent CE fetch CEIB before context switch done */ -amdgpu_ring_write (ring,PACKET3 (PACKET3_SWITCH_BUFFER ,0 )); -amdgpu_ring_write (ring,0 ); -amdgpu_ring_write (ring,PACKET3 (PACKET3_SWITCH_BUFFER ,0 )); -amdgpu_ring_write (ring,0 ); } }
@@ -3036,6 +3016,12 @@ static uint64_t gfx_v6_0_get_gpu_clock_counter(struct amdgpu_device *adev)return clock; } +static void gfx_v6_0_ring_emit_sb (struct amdgpu_ring *ring) +{ +amdgpu_ring_write (ring,PACKET3 (PACKET3_SWITCH_BUFFER ,0 )); +amdgpu_ring_write (ring,0 ); +} +static void gfx_v6_ring_emit_cntxcntl (struct amdgpu_ring *ring,uint32_t flags) {u32 dw2 =0x80000000 ;/* set load_enable otherwise this package is just NOPs */
@@ -3586,11 +3572,12 @@ static const struct amdgpu_ring_funcs gfx_v6_0_ring_funcs_gfx = { .emit_frame_size =5 +5 +/* hdp flush / invalidate */ 14 +14 +14 +/* gfx_v6_0_ring_emit_fence x3 for user fence, vm fence */ -7 +4 +/* gfx_v6_0_ring_emit_pipeline_sync */ -SI_FLUSH_GPU_TLB_NUM_WREG *5 +7 +6 +/* gfx_v6_0_ring_emit_vm_flush */ +7 +/* gfx_v6_0_ring_emit_pipeline_sync */ +SI_FLUSH_GPU_TLB_NUM_WREG *5 +7 +2 +/* gfx_v6_0_ring_emit_vm_flush */ +3 *2 +/* gfx_v6_0_ring_emit_sb x3 (from amdgpu_vm_flush, amdgpu_ib_schedule) */ 3 +2 +2 +/* gfx_v6_ring_emit_cntxcntl including VGT flush */ 5, /* SURFACE_SYNC */ - .emit_ib_size = 6, /* gfx_v6_0_ring_emit_ib */ + .emit_ib_size = 4, /* gfx_v6_0_ring_emit_ib */ .emit_ib = gfx_v6_0_ring_emit_ib, .emit_fence = gfx_v6_0_ring_emit_fence, .emit_pipeline_sync = gfx_v6_0_ring_emit_pipeline_sync,
@@ -3598,6 +3585,7 @@ static const struct amdgpu_ring_funcs gfx_v6_0_ring_funcs_gfx = { .test_ring = gfx_v6_0_ring_test_ring, .test_ib = gfx_v6_0_ring_test_ib, .insert_nop = amdgpu_ring_insert_nop, + .emit_switch_buffer = gfx_v6_0_ring_emit_sb, .emit_cntxcntl = gfx_v6_ring_emit_cntxcntl, .emit_wreg = gfx_v6_0_ring_emit_wreg, .emit_mem_sync = gfx_v6_0_emit_mem_sync,
@@ -3615,8 +3603,9 @@ static const struct amdgpu_ring_funcs gfx_v6_0_ring_funcs_compute = {7 +/* gfx_v6_0_ring_emit_pipeline_sync */ SI_FLUSH_GPU_TLB_NUM_WREG *5 +7 +/* gfx_v6_0_ring_emit_vm_flush */ 14 +14 +14 +/* gfx_v6_0_ring_emit_fence x3 for user fence, vm fence */ +3 *2 +/* gfx_v6_0_ring_emit_sb x3 (from amdgpu_vm_flush, amdgpu_ib_schedule) */ 5, /* SURFACE_SYNC */ - .emit_ib_size = 6, /* gfx_v6_0_ring_emit_ib */ + .emit_ib_size = 4, /* gfx_v6_0_ring_emit_ib */ .emit_ib = gfx_v6_0_ring_emit_ib, .emit_fence = gfx_v6_0_ring_emit_fence, .emit_pipeline_sync = gfx_v6_0_ring_emit_pipeline_sync,
@@ -3624,6 +3613,7 @@ static const struct amdgpu_ring_funcs gfx_v6_0_ring_funcs_compute = { .test_ring = gfx_v6_0_ring_test_ring, .test_ib = gfx_v6_0_ring_test_ib, .insert_nop = amdgpu_ring_insert_nop, + .emit_switch_buffer = gfx_v6_0_ring_emit_sb, .emit_wreg = gfx_v6_0_ring_emit_wreg, .emit_mem_sync = gfx_v6_0_emit_mem_sync, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 732/935 drm/amdgpu/gfx6: Use PFP on the compute queues too
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit 60f20946cd318518ddc2c0da12103c666b2b9564 ]
On GFX6, the compute rings use the same CP path as the graphics ring. The only difference is that they don't support draw commands. (As opposed to GFX7 and newer which have a separate command parser that is called MEC for compute queues.)
This means that we have to take into consideration that the PFP also exists on compute queues on GFX6:
Use PFP for register writes on both graphics and compute queues.
In the pipeline sync, use the PFP to wait for the previous fence (and not the ME) to prevent the PFP from starting to execute the next submission while the ME is still in the previous submission.
After a VM flush, emit PFP_SYNC_ME on compute queues as well.
--- drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c +4 -4
@@ -2364,7 +2364,7 @@ static int gfx_v6_0_cp_resume(struct amdgpu_device *adev)static void gfx_v6_0_ring_emit_pipeline_sync (struct amdgpu_ring *ring) { -int usepfp = (ring->funcs->type ==AMDGPU_RING_TYPE_GFX ); +int usepfp =1 ;uint32_t seq = ring->fence_drv.sync_seq;uint64_t addr = ring->fence_drv.gpu_addr;
@@ -2382,7 +2382,7 @@ static void gfx_v6_0_ring_emit_pipeline_sync(struct amdgpu_ring *ring)static void gfx_v6_0_ring_emit_vm_flush (struct amdgpu_ring *ring,unsigned vmid,uint64_t pd_addr) { -int usepfp = (ring->funcs->type ==AMDGPU_RING_TYPE_GFX ); +int usepfp =1 ;amdgpu_gmc_emit_flush_gpu_tlb (ring, vmid, pd_addr);
@@ -2406,7 +2406,7 @@ static void gfx_v6_0_ring_emit_vm_flush(struct amdgpu_ring *ring,static void gfx_v6_0_ring_emit_wreg (struct amdgpu_ring *ring,uint32_t reg,uint32_t val) { -int usepfp = (ring->funcs->type ==AMDGPU_RING_TYPE_GFX ); +int usepfp =1 ;amdgpu_ring_write (ring,PACKET3 (PACKET3_WRITE_DATA ,3 )); amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(usepfp) |
@@ -3601,7 +3601,7 @@ static const struct amdgpu_ring_funcs gfx_v6_0_ring_funcs_compute = { .emit_frame_size =5 +5 +/* hdp flush / invalidate */ 7 +/* gfx_v6_0_ring_emit_pipeline_sync */ -SI_FLUSH_GPU_TLB_NUM_WREG *5 +7 +/* gfx_v6_0_ring_emit_vm_flush */ +SI_FLUSH_GPU_TLB_NUM_WREG *5 +7 +2 +/* gfx_v6_0_ring_emit_vm_flush */ 14 +14 +14 +/* gfx_v6_0_ring_emit_fence x3 for user fence, vm fence */ 3 *2 +/* gfx_v6_0_ring_emit_sb x3 (from amdgpu_vm_flush, amdgpu_ib_schedule) */ 5, /* SURFACE_SYNC */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 733/935 scsi: qla2xxx: Remove redundant VPD flash read in sysfs read path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manish Rangankar <[email protected]>
[ Upstream commit 5cbc49d5c4cd20c18041e86958103045216d2190 ]
qla2x00_sysfs_read_vpd() called ha->isp_ops->read_optrom() a second time after releasing optrom_mutex. The repeated read is redundant and, unlike the first, runs without optrom_mutex held, exposing flash access to concurrent optrom operations. Drop the duplicate call.
--- drivers/scsi/qla2xxx/qla_attr.c | 1 - 1 file changed, 1 deletion(-)
drivers/scsi/qla2xxx/qla_attr.c +0 -1
@@ -580,7 +580,6 @@ qla2x00_sysfs_read_vpd(struct file *filp, struct kobject *kobj, ha->isp_ops->read_optrom (vha, ha->vpd, faddr, ha->vpd_size);mutex_unlock (&ha->optrom_mutex); - ha->isp_ops->read_optrom (vha, ha->vpd, faddr, ha->vpd_size); skip:return memory_read_from_buffer (buf, count, &off, ha->vpd, ha->vpd_size); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 734/935 firmware_loader: Check fw_state_is_done in loading_store
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Russ Weight <[email protected]>
[ Upstream commit 736da0b657f615db7e29606eb8818871534a8943 ]
Rename fw_sysfs_done() and fw_sysfs_loading() to fw_state_is_done() and fw_state_is_loading() respectively, and place them along side companion functions in drivers/base/firmware_loader/firmware.h.
Use the fw_state_is_done() function to exit early from firmware_loading_store() if the state is already "done". This is being done in preparation for supporting persistent sysfs nodes to allow userspace to upload firmware to a device, potentially reusing the sysfs loading and data files multiple times.
Stable-dep-of: b48373c90195 ("firmware_loader: do not queue completed sysfs fallback requests")
--- drivers/base/firmware_loader/fallback.c | 28 +++++++------------------ drivers/base/firmware_loader/firmware.h | 10 +++++++++ 2 files changed, 18 insertions(+), 20 deletions(-)
drivers/base/firmware_loader/fallback.c +8 -20
@@ -58,16 +58,6 @@ static long firmware_loading_timeout(void) __firmware_loading_timeout() * HZ : MAX_JIFFY_OFFSET; } -static inline bool fw_sysfs_done (struct fw_priv *fw_priv) -{ -return __fw_state_check (fw_priv,FW_STATUS_DONE ); -} - -static inline bool fw_sysfs_loading (struct fw_priv *fw_priv) -{ -return __fw_state_check (fw_priv,FW_STATUS_LOADING ); -} -static inline int fw_sysfs_wait_timeout (struct fw_priv *fw_priv,long timeout) {return __fw_state_wait_common (fw_priv, timeout);
@@ -91,7 +81,7 @@ static void __fw_load_abort(struct fw_priv *fw_priv)* There is a small window in which user can write to 'loading' * between loading done/aborted and disappearance of 'loading' */ -if (fw_state_is_aborted (fw_priv) ||fw_sysfs_done (fw_priv)) +if (fw_state_is_aborted (fw_priv) ||fw_state_is_done (fw_priv))return ;fw_state_aborted (fw_priv);
@@ -215,7 +205,7 @@ static ssize_t firmware_loading_show(struct device *dev,mutex_lock (&fw_lock);if (fw_sysfs->fw_priv) - loading =fw_sysfs_loading (fw_sysfs->fw_priv); + loading =fw_state_is_loading (fw_sysfs->fw_priv);mutex_unlock (&fw_lock);return sysfs_emit (buf,"%d\n" , loading);
@@ -245,19 +235,17 @@ static ssize_t firmware_loading_store(struct device *dev,mutex_lock (&fw_lock); fw_priv = fw_sysfs->fw_priv; -if (fw_state_is_aborted (fw_priv)) +if (fw_state_is_aborted (fw_priv) ||fw_state_is_done (fw_priv)) goto out;switch (loading) {case 1 :/* discarding any previous partial load */ -if (!fw_sysfs_done (fw_priv)) { -fw_free_paged_buf (fw_priv); -fw_state_start (fw_priv); - } +fw_free_paged_buf (fw_priv); +fw_state_start (fw_priv);break ;case 0 : -if (fw_sysfs_loading (fw_priv)) { +if (fw_state_is_loading (fw_priv)) {int rc;/*
@@ -345,7 +333,7 @@ static ssize_t firmware_data_read(struct file *filp, struct kobject *kobj,mutex_lock (&fw_lock); fw_priv = fw_sysfs->fw_priv; -if (!fw_priv ||fw_sysfs_done (fw_priv)) { +if (!fw_priv ||fw_state_is_done (fw_priv)) { ret_count = -ENODEV ; goto out; }
@@ -405,7 +393,7 @@ static ssize_t firmware_data_write(struct file *filp, struct kobject *kobj,mutex_lock (&fw_lock); fw_priv = fw_sysfs->fw_priv; -if (!fw_priv ||fw_sysfs_done (fw_priv)) { +if (!fw_priv ||fw_state_is_done (fw_priv)) { retval = -ENODEV ; goto out; }
drivers/base/firmware_loader/firmware.h +10 -0
@@ -149,6 +149,16 @@ static inline void fw_state_done(struct fw_priv *fw_priv)__fw_state_set (fw_priv,FW_STATUS_DONE ); } +static inline bool fw_state_is_done (struct fw_priv *fw_priv) +{ +return __fw_state_check (fw_priv,FW_STATUS_DONE ); +} + +static inline bool fw_state_is_loading (struct fw_priv *fw_priv) +{ +return __fw_state_check (fw_priv,FW_STATUS_LOADING ); +} +int assign_fw (struct firmware *fw,struct device *device);#ifdef CONFIG_FW_LOADER_PAGED_BUF
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 735/935 firmware_loader: do not queue completed sysfs fallback requests
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mukesh Ojha <[email protected]>
[ Upstream commit b48373c901951fad1a26bd7c33ad91172b3945b5 ]
fw_load_sysfs_fallback() calls device_add() before adding the fw_priv to pending_fw_head. device_add() publishes the fallback loading interface, so a userspace helper which discovers the device by scanning sysfs can write 0 to the loading attribute and complete the request before it is queued as pending.
In that interleaving firmware_loading_store() calls fw_state_done() while pending_list still points to itself, so it cannot remove an entry from pending_fw_head. The subsequent unconditional list_add() then queues an already-completed fw_priv. Once the request is released, pending_fw_head can retain a pointer to freed memory and the next fallback request can fault while validating the list.
Only in-flight fallback requests need suspend or reboot abort handling. If the request is already DONE after device_add(), return success from the fallback path without sending another uevent, waiting again, or queueing it as pending. This preserves the invariant that pending_fw_head contains only active fallback requests.
--- drivers/base/firmware_loader/fallback.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/base/firmware_loader/fallback.c +10 -0
@@ -504,6 +504,16 @@ static int fw_load_sysfs_fallback(struct fw_sysfs *fw_sysfs, long timeout) retval = -EINTR ; goto out; } + +/* +* device_add() exposes the loading interface before pending_list is +* linked into pending_fw_head, so fw_state_done() may run first. +*/ +if (fw_state_is_done (fw_priv)) { +mutex_unlock (&fw_lock); + goto out; + } +list_add (&fw_priv->pending_list, &pending_fw_head);mutex_unlock (&fw_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 736/935 pinctrl: rockchip: Reset the pin count when recalculating SoC data
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Simon Glass <[email protected]>
[ Upstream commit 5b695c191cc85f0fd62eec885b55d01468dc9f2c ]
rockchip_pinctrl_get_soc_data() mutates the static per-SoC data. The iomux and drive offsets are recalculated idempotently, since a rerun anchors at the values calculated before, but the total pin count only
accumulates: each run adds every bank's pins again. When the probe is deferred and runs a second time, nr_pins doubles and every bank's pin_base shifts, so later pin lookups resolve to the wrong bank and the wrong registers.
Reset the pin count at the start of the calculation, so that a rerun produces the same values.
This is verified on a Luckfox Pico Mini B (RV1103, with the pending RV1106 series applied) by forcing the probe to defer once: without this patch the second probe calculates nr_pins=304 instead of 152 and no GPIO bank comes up; with it the recalculation matches the first run and all banks work.
--- drivers/pinctrl/pinctrl-rockchip.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/pinctrl/pinctrl-rockchip.c +10 -0
@@ -2693,6 +2693,16 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data( pmu_offs = ctrl->pmu_mux_offset; drv_pmu_offs = ctrl->pmu_drv_offset; drv_grf_offs = ctrl->grf_drv_offset; + +/* +* This function mutates the static per-SoC data. Most of it is +* idempotent: recalculated iomux and drv offsets anchor at the +* values calculated by a previous run. The pin count is not, so +* reset it here; otherwise it accumulates when the probe runs +* again after a probe deferral, shifting every bank's pin_base. +*/ + ctrl->nr_pins =0 ; + bank = ctrl->pin_banks;for (i =0 ; i < ctrl->nr_banks; ++i, ++bank) {int bank_pins =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 737/935 hugetlbfs: release subpool on fill_super failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yichong Chen <[email protected]>
[ Upstream commit 308ab73e97c87bd0e142b11758faab7f88d82854 ]
hugetlbfs_fill_super() allocates a hugepage subpool when size or min_size mount options are specified. hugepage_new_subpool() may also reserve huge pages for min_size.
If root dentry creation fails after the subpool is created, the failure path frees the subpool with kfree(). This bypasses hugepage_put_subpool() and can leave min_size reservations charged.
Use hugepage_put_subpool() on the failure path, matching the normal put_super path.
--- fs/hugetlbfs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/hugetlbfs/inode.c +2 -1
@@ -1382,7 +1382,8 @@ hugetlbfs_fill_super(struct super_block *sb, struct fs_context *fc) goto out_free;return 0 ; out_free: -kfree (sbinfo->spool); +if (sbinfo->spool) +hugepage_put_subpool (sbinfo->spool);kfree (sbinfo);return -ENOMEM ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 738/935 soc: fsl: qe: check platform_driver_register() in qe_ic_of_init()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linkai Gong <[email protected]>
[ Upstream commit fbdba2a67fa7c0e7570bcbf9f28b782d6100270d ]
qe_ic_of_init() ignored the return value of platform_driver_register() and always returned success. Propagate the error to the initcall.
--- drivers/soc/fsl/qe/qe_ic.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/soc/fsl/qe/qe_ic.c +1 -2
@@ -481,7 +481,6 @@ static struct platform_driver qe_ic_driver =static int __init qe_ic_of_init (void ) { -platform_driver_register (&qe_ic_driver); -return 0 ; +return platform_driver_register (&qe_ic_driver); }subsys_initcall (qe_ic_of_init);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 739/935 phy: qcom: snps-femto-v2: Fix possible NULL-deref on early runtime suspend
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Loic Poulain <[email protected]>
[ Upstream commit c271a6926ea7d3c9566b033d63fd4e8c488dc860 ]
Runtime PM must be enabled before creating the PHY, since phy_create() only enables runtime PM on the PHY device if it is already enabled on this parent device. However, the runtime PM callbacks dereference the hsphy instance, which is not yet ready, leaving a window where a suspend callback may trigger a NULL pointer dereference.
Take a runtime PM usage reference with pm_runtime_get_noresume() before enabling runtime PM and release it once the PHY has been created, so that no runtime suspend can run before the PHY is ready. This also prevents a short window where an unnecessary runtime suspend can occur.
Use the devres-managed version to ensure PM runtime is symmetrically disabled during driver removal for proper cleanup.
--- drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-)
drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c +20 -6
@@ -345,8 +345,18 @@ static int qcom_snps_hsphy_probe(struct platform_device *pdev)return dev_err_probe (dev, ret,"failed to get regulator supplies\n" ); +/* +* Enable runtime PM before creating the PHY, phy_create() only enables +* it on the PHY device if already enabled on the parent. Hold a usage +* reference so callbacks cannot run before the PHY is ready. +*/ +pm_runtime_get_noresume (dev);pm_runtime_set_active (dev); -pm_runtime_enable (dev); + ret =devm_pm_runtime_enable (dev); +if (ret) { +pm_runtime_put_noidle (dev); +return ret; + }/* * Prevent runtime pm from being ON by default. Users can enable * it using power/control in sysfs.
@@ -357,6 +367,7 @@ static int qcom_snps_hsphy_probe(struct platform_device *pdev)if (IS_ERR (generic_phy)) { ret =PTR_ERR (generic_phy);dev_err (dev,"failed to create phy, %d\n" , ret); +pm_runtime_put_noidle (dev);return ret; } hsphy->phy = generic_phy;
@@ -365,12 +376,15 @@ static int qcom_snps_hsphy_probe(struct platform_device *pdev)phy_set_drvdata (generic_phy, hsphy); phy_provider =devm_of_phy_provider_register (dev, of_phy_simple_xlate); -if (!IS_ERR (phy_provider)) -dev_dbg (dev,"Registered Qcom-SNPS HS phy\n" ); -else -pm_runtime_disable (dev); +if (IS_ERR (phy_provider)) { +pm_runtime_put_noidle (dev); +return PTR_ERR (phy_provider); + } -return PTR_ERR_OR_ZERO (phy_provider); +dev_dbg (dev,"Registered Qcom-SNPS HS phy\n" ); +pm_runtime_put (dev); + +return 0 ; }static struct platform_driver qcom_snps_hsphy_driver = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 740/935 coresight: etm4x: fix wrong check of etm4x_sspcicrn_present()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yeoreum Yun <[email protected]>
[ Upstream commit 0e1cd4270b42a257c139165622091e1e8c7104a7 ]
According to Embedded Trace Macrocell Architecture Specification ETMv4.0 to ETM4.6 [0], TRCSSPCICR<n> is present only if all of the following are true:
- TRCIDR4.NUMSSCC > n.
- TRCIDR4.NUMPC > 0b0000.
- TRCSSCSR<n>.PC == 0b1.
Comment for etm4x_sspcicrn_present() is align with the specification. However, the check should use drvdata->nr_pe_cmp to check TRCIDR4.NUMPC not nr_pe.
--- drivers/hwtracing/coresight/coresight-etm4x-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight-etm4x-core.c +1 -1
@@ -82,7 +82,7 @@ struct etm4_init_arg {static inline bool etm4x_sspcicrn_present (struct etmv4_drvdata *drvdata,int n) {return (n < drvdata->nr_ss_cmp) && - drvdata->nr_pe && + drvdata->nr_pe_cmp && (drvdata->config.ss_status[n] & TRCSSCSRn_PC); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 741/935 coresight: etm4x: Cleanup TRCIDR2 register accesses
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Clark <[email protected]>
[ Upstream commit cf0c7f18d30eb9bba44ac04a87fef5035953b283 ]
This is a no-op change for style and consistency and has no effect on the binary output by the compiler. In sysreg.h fields are defined as the register name followed by the field name and then _MASK. This allows for grepping for fields by name rather than using magic numbers.
Stable-dep-of: 1674d9bff807 ("coresight: etm4x: fix underflow for usage of (nrseqstate - 1)")
--- drivers/hwtracing/coresight/coresight-etm4x-core.c | 6 +++--- drivers/hwtracing/coresight/coresight-etm4x.h | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/hwtracing/coresight/coresight-etm4x-core.c +3 -3
@@ -1179,11 +1179,11 @@ static void etm4_init_arch_data(void *info)/* maximum size of resources */ etmidr2 =etm4x_relaxed_read32 (csa,TRCIDR2 );/* CIDSIZE, bits[9:5] Indicates the Context ID size */ - drvdata->ctxid_size =BMVAL (etmidr2,5 ,9 ); + drvdata->ctxid_size =FIELD_GET (TRCIDR2_CIDSIZE_MASK , etmidr2);/* VMIDSIZE, bits[14:10] Indicates the VMID size */ - drvdata->vmid_size =BMVAL (etmidr2,10 ,14 ); + drvdata->vmid_size =FIELD_GET (TRCIDR2_VMIDSIZE_MASK , etmidr2);/* CCSIZE, bits[28:25] size of the cycle counter in bits minus 12 */ - drvdata->ccsize =BMVAL (etmidr2,25 ,28 ); + drvdata->ccsize =FIELD_GET (TRCIDR2_CCSIZE_MASK , etmidr2); etmidr3 =etm4x_relaxed_read32 (csa,TRCIDR3 );/* CCITMIN, bits[11:0] minimum threshold value that can be programmed */
drivers/hwtracing/coresight/coresight-etm4x.h +4 -0
@@ -139,6 +139,10 @@#define TRCIDR0_QSUPP_MASK GENMASK(16, 15)#define TRCIDR0_TSSIZE_MASK GENMASK(28, 24) +#define TRCIDR2_CIDSIZE_MASK GENMASK(9, 5) +#define TRCIDR2_VMIDSIZE_MASK GENMASK(14, 10) +#define TRCIDR2_CCSIZE_MASK GENMASK(28, 25) +/* * System instructions to access ETM registers. * See ETMv4.4 spec ARM IHI0064F section 4.3.6 System instructions
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 742/935 coresight: etm4x: Cleanup TRCIDR3 register accesses
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Clark <[email protected]>
[ Upstream commit f4d1f2142a608667a1849894b48b9c6e3343210c ]
This is a no-op change for style and consistency and has no effect on the binary output by the compiler. In sysreg.h fields are defined as the register name followed by the field name and then _MASK. This allows for grepping for fields by name rather than using magic numbers.
Stable-dep-of: 1674d9bff807 ("coresight: etm4x: fix underflow for usage of (nrseqstate - 1)")
--- .../coresight/coresight-etm4x-core.c | 40 +++++-------------- drivers/hwtracing/coresight/coresight-etm4x.h | 10 +++++ 2 files changed, 20 insertions(+), 30 deletions(-)
drivers/hwtracing/coresight/coresight-etm4x-core.c +10 -30
@@ -1187,53 +1187,33 @@ static void etm4_init_arch_data(void *info) etmidr3 =etm4x_relaxed_read32 (csa,TRCIDR3 );/* CCITMIN, bits[11:0] minimum threshold value that can be programmed */ - drvdata->ccitmin =BMVAL (etmidr3,0 ,11 ); + drvdata->ccitmin =FIELD_GET (TRCIDR3_CCITMIN_MASK , etmidr3);/* EXLEVEL_S, bits[19:16] Secure state instruction tracing */ - drvdata->s_ex_level =BMVAL (etmidr3,16 ,19 ); + drvdata->s_ex_level =FIELD_GET (TRCIDR3_EXLEVEL_S_MASK , etmidr3); drvdata->config.s_ex_level = drvdata->s_ex_level;/* EXLEVEL_NS, bits[23:20] Non-secure state instruction tracing */ - drvdata->ns_ex_level =BMVAL (etmidr3,20 ,23 ); - + drvdata->ns_ex_level =FIELD_GET (TRCIDR3_EXLEVEL_NS_MASK , etmidr3);/* * TRCERR, bit[24] whether a trace unit can trace a * system error exception. */ -if (BMVAL (etmidr3,24 ,24 )) - drvdata->trc_error = true; -else - drvdata->trc_error = false; - + drvdata->trc_error = !!(etmidr3 &TRCIDR3_TRCERR );/* SYNCPR, bit[25] implementation has a fixed synchronization period? */ -if (BMVAL (etmidr3,25 ,25 )) - drvdata->syncpr = true; -else - drvdata->syncpr = false; - + drvdata->syncpr = !!(etmidr3 &TRCIDR3_SYNCPR );/* STALLCTL, bit[26] is stall control implemented? */ -if (BMVAL (etmidr3,26 ,26 )) - drvdata->stallctl = true; -else - drvdata->stallctl = false; - + drvdata->stallctl = !!(etmidr3 &TRCIDR3_STALLCTL );/* SYSSTALL, bit[27] implementation can support stall control? */ -if (BMVAL (etmidr3,27 ,27 )) - drvdata->sysstall = true; -else - drvdata->sysstall = false; - + drvdata->sysstall = !!(etmidr3 &TRCIDR3_SYSSTALL );/* * NUMPROC - the number of PEs available for tracing, 5bits * = TRCIDR3.bits[13:12]bits[30:28] * bits[4:3] = TRCIDR3.bits[13:12] (since etm-v4.2, otherwise RES0) * bits[3:0] = TRCIDR3.bits[30:28] */ - drvdata->nr_pe = (BMVAL (etmidr3,12 ,13 ) <<3 ) |BMVAL (etmidr3,28 ,30 ); - + drvdata->nr_pe = (FIELD_GET (TRCIDR3_NUMPROC_HI_MASK , etmidr3) <<3 ) | +FIELD_GET (TRCIDR3_NUMPROC_LO_MASK , etmidr3);/* NOOVERFLOW, bit[31] is trace overflow prevention supported */ -if (BMVAL (etmidr3,31 ,31 )) - drvdata->nooverflow = true; -else - drvdata->nooverflow = false; + drvdata->nooverflow = !!(etmidr3 &TRCIDR3_NOOVERFLOW );/* number of resources trace unit supports */ etmidr4 =etm4x_relaxed_read32 (csa,TRCIDR4 );
drivers/hwtracing/coresight/coresight-etm4x.h +10 -0
@@ -143,6 +143,16 @@#define TRCIDR2_VMIDSIZE_MASK GENMASK(14, 10)#define TRCIDR2_CCSIZE_MASK GENMASK(28, 25) +#define TRCIDR3_CCITMIN_MASK GENMASK(11, 0) +#define TRCIDR3_EXLEVEL_S_MASK GENMASK(19, 16) +#define TRCIDR3_EXLEVEL_NS_MASK GENMASK(23, 20) +#define TRCIDR3_TRCERR BIT(24) +#define TRCIDR3_SYNCPR BIT(25) +#define TRCIDR3_STALLCTL BIT(26) +#define TRCIDR3_SYSSTALL BIT(27) +#define TRCIDR3_NUMPROC_LO_MASK GENMASK(30, 28) +#define TRCIDR3_NUMPROC_HI_MASK GENMASK(13, 12) +#define TRCIDR3_NOOVERFLOW BIT(31)/* * System instructions to access ETM registers. * See ETMv4.4 spec ARM IHI0064F section 4.3.6 System instructions
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 743/935 coresight: etm4x: Cleanup TRCIDR4 register accesses
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Clark <[email protected]>
[ Upstream commit ea69dbb893d9f4446c2c66ebb11081af9269721f ]
This is a no-op change for style and consistency and has no effect on the binary output by the compiler. In sysreg.h fields are defined as the register name followed by the field name and then _MASK. This allows for grepping for fields by name rather than using magic numbers.
Stable-dep-of: 1674d9bff807 ("coresight: etm4x: fix underflow for usage of (nrseqstate - 1)")
--- drivers/hwtracing/coresight/coresight-etm4x-core.c | 12 ++++++------ drivers/hwtracing/coresight/coresight-etm4x.h | 8 ++++++++ 2 files changed, 14 insertions(+), 6 deletions(-)
drivers/hwtracing/coresight/coresight-etm4x-core.c +6 -6
@@ -1218,9 +1218,9 @@ static void etm4_init_arch_data(void *info)/* number of resources trace unit supports */ etmidr4 =etm4x_relaxed_read32 (csa,TRCIDR4 );/* NUMACPAIRS, bits[0:3] number of addr comparator pairs for tracing */ - drvdata->nr_addr_cmp =BMVAL (etmidr4,0 ,3 ); + drvdata->nr_addr_cmp =FIELD_GET (TRCIDR4_NUMACPAIRS_MASK , etmidr4);/* NUMPC, bits[15:12] number of PE comparator inputs for tracing */ - drvdata->nr_pe_cmp =BMVAL (etmidr4,12 ,15 ); + drvdata->nr_pe_cmp =FIELD_GET (TRCIDR4_NUMPC_MASK , etmidr4);/* * NUMRSPAIR, bits[19:16] * The number of resource pairs conveyed by the HW starts at 0, i.e a
@@ -1231,7 +1231,7 @@ static void etm4_init_arch_data(void *info)* the default TRUE and FALSE resource selectors are omitted. * Otherwise for values 0x1 and above the number is N + 1 as per v4.2. */ - drvdata->nr_resource =BMVAL (etmidr4,16 ,19 ); + drvdata->nr_resource =FIELD_GET (TRCIDR4_NUMRSPAIR_MASK , etmidr4);if ((drvdata->arch <ETM_ARCH_V4_3 ) || (drvdata->nr_resource >0 )) drvdata->nr_resource +=1 ;/*
@@ -1239,15 +1239,15 @@ static void etm4_init_arch_data(void *info)* comparator control for tracing. Read any status regs as these * also contain RO capability data. */ - drvdata->nr_ss_cmp =BMVAL (etmidr4,20 ,23 ); + drvdata->nr_ss_cmp =FIELD_GET (TRCIDR4_NUMSSCC_MASK , etmidr4);for (i =0 ; i < drvdata->nr_ss_cmp; i++) { drvdata->config.ss_status[i] =etm4x_relaxed_read32 (csa,TRCSSCSRn (i)); }/* NUMCIDC, bits[27:24] number of Context ID comparators for tracing */ - drvdata->numcidc =BMVAL (etmidr4,24 ,27 ); + drvdata->numcidc =FIELD_GET (TRCIDR4_NUMCIDC_MASK , etmidr4);/* NUMVMIDC, bits[31:28] number of VMID comparators for tracing */ - drvdata->numvmidc =BMVAL (etmidr4,28 ,31 ); + drvdata->numvmidc =FIELD_GET (TRCIDR4_NUMVMIDC_MASK , etmidr4); etmidr5 =etm4x_relaxed_read32 (csa,TRCIDR5 );/* NUMEXTIN, bits[8:0] number of external inputs implemented */
drivers/hwtracing/coresight/coresight-etm4x.h +8 -0
@@ -153,6 +153,14 @@#define TRCIDR3_NUMPROC_LO_MASK GENMASK(30, 28)#define TRCIDR3_NUMPROC_HI_MASK GENMASK(13, 12)#define TRCIDR3_NOOVERFLOW BIT(31) + +#define TRCIDR4_NUMACPAIRS_MASK GENMASK(3, 0) +#define TRCIDR4_NUMPC_MASK GENMASK(15, 12) +#define TRCIDR4_NUMRSPAIR_MASK GENMASK(19, 16) +#define TRCIDR4_NUMSSCC_MASK GENMASK(23, 20) +#define TRCIDR4_NUMCIDC_MASK GENMASK(27, 24) +#define TRCIDR4_NUMVMIDC_MASK GENMASK(31, 28) +/* * System instructions to access ETM registers. * See ETMv4.4 spec ARM IHI0064F section 4.3.6 System instructions
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 744/935 coresight: etm4x: Cleanup TRCIDR5 register accesses
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Clark <[email protected]>
[ Upstream commit 028e5460915afd4a3067e380eb4d03cb4500acdc ]
This is a no-op change for style and consistency and has no effect on the binary output by the compiler. In sysreg.h fields are defined as the register name followed by the field name and then _MASK. This allows for grepping for fields by name rather than using magic numbers.
Stable-dep-of: 1674d9bff807 ("coresight: etm4x: fix underflow for usage of (nrseqstate - 1)")
--- .../hwtracing/coresight/coresight-etm4x-core.c | 18 ++++++------------ drivers/hwtracing/coresight/coresight-etm4x.h | 7 +++++++ 2 files changed, 13 insertions(+), 12 deletions(-)
drivers/hwtracing/coresight/coresight-etm4x-core.c +6 -12
@@ -1251,26 +1251,20 @@ static void etm4_init_arch_data(void *info) etmidr5 =etm4x_relaxed_read32 (csa,TRCIDR5 );/* NUMEXTIN, bits[8:0] number of external inputs implemented */ - drvdata->nr_ext_inp =BMVAL (etmidr5,0 ,8 ); + drvdata->nr_ext_inp =FIELD_GET (TRCIDR5_NUMEXTIN_MASK , etmidr5);/* TRACEIDSIZE, bits[21:16] indicates the trace ID width */ - drvdata->trcid_size =BMVAL (etmidr5,16 ,21 ); + drvdata->trcid_size =FIELD_GET (TRCIDR5_TRACEIDSIZE_MASK , etmidr5);/* ATBTRIG, bit[22] implementation can support ATB triggers? */ -if (BMVAL (etmidr5,22 ,22 )) - drvdata->atbtrig = true; -else - drvdata->atbtrig = false; + drvdata->atbtrig = !!(etmidr5 &TRCIDR5_ATBTRIG );/* * LPOVERRIDE, bit[23] implementation supports * low-power state override */ -if (BMVAL (etmidr5,23 ,23 ) && (!drvdata->skip_power_up)) - drvdata->lpoverride = true; -else - drvdata->lpoverride = false; + drvdata->lpoverride = (etmidr5 &TRCIDR5_LPOVERRIDE ) && (!drvdata->skip_power_up);/* NUMSEQSTATE, bits[27:25] number of sequencer states implemented */ - drvdata->nrseqstate =BMVAL (etmidr5,25 ,27 ); + drvdata->nrseqstate =FIELD_GET (TRCIDR5_NUMSEQSTATE_MASK , etmidr5);/* NUMCNTR, bits[30:28] number of counters available for tracing */ - drvdata->nr_cntr =BMVAL (etmidr5,28 ,30 ); + drvdata->nr_cntr =FIELD_GET (TRCIDR5_NUMCNTR_MASK , etmidr5);etm4_cs_lock (drvdata, csa);cpu_detect_trace_filtering (drvdata); }
drivers/hwtracing/coresight/coresight-etm4x.h +7 -0
@@ -161,6 +161,13 @@#define TRCIDR4_NUMCIDC_MASK GENMASK(27, 24)#define TRCIDR4_NUMVMIDC_MASK GENMASK(31, 28) +#define TRCIDR5_NUMEXTIN_MASK GENMASK(8, 0) +#define TRCIDR5_TRACEIDSIZE_MASK GENMASK(21, 16) +#define TRCIDR5_ATBTRIG BIT(22) +#define TRCIDR5_LPOVERRIDE BIT(23) +#define TRCIDR5_NUMSEQSTATE_MASK GENMASK(27, 25) +#define TRCIDR5_NUMCNTR_MASK GENMASK(30, 28) +/* * System instructions to access ETM registers. * See ETMv4.4 spec ARM IHI0064F section 4.3.6 System instructions
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 745/935 coresight: Change syncfreq to be a u8
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Clark <[email protected]>
[ Upstream commit 10d4dbdc8fbce586b17be07b8138e025381453dd ]
TRCSYNCPR.PERIOD is the only functional part of TRCSYNCPR and it only has 5 valid bits so it can be stored in a u8.
Stable-dep-of: 1674d9bff807 ("coresight: etm4x: fix underflow for usage of (nrseqstate - 1)")
--- drivers/hwtracing/coresight/coresight-etm4x.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight-etm4x.h +1 -1
@@ -780,7 +780,6 @@ struct etmv4_config {u32 eventctrl1;u32 stall_ctrl;u32 ts_ctrl; -u32 syncfreq;u32 ccctlr;u32 bb_ctrl;u32 vinst_ctrl;
@@ -788,6 +787,7 @@ struct etmv4_config {u32 vissctlr;u32 vipcssctlr;u8 seq_idx; +u8 syncfreq;u32 seq_ctrl[ETM_MAX_SEQ_STATES ];u32 seq_rst;u32 seq_state;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 746/935 coresight: etm4x: fix underflow for usage of (nrseqstate - 1)
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yeoreum Yun <[email protected]>
[ Upstream commit 1674d9bff8073bdee5dbc200f56fc3caa28d0566 ]
According to IHI006H Embedded Trace Macrocell Architecture Specification[0], TRCSEQEVR<n> is implemented only when TRCIDR5.NUMSEQSTATE is 0b100, in which case n ranges from 0 to 2; otherwise, TRCIDR5.NUMSEQSTATE is 0b000.
IOW, the number of usage in the initialisation or setting TRCSEQEVR<n> with drvdata->nrseqstate - 1 in the loop could make underflow issue when TRCIDR5.NUMSEQSTATE is 0b000.
Therefore, introduce nr_seq_ctrls field and untie it from nrseqstate. As part of this introduce ETM_MAX_SEQ_TRANSITIONS macro and apply nr_seq_ctrls and above macro to TRCSEQEVR<n> relevant fields setup.
--- drivers/hwtracing/coresight/coresight-etm4x-cfg.c | 2 +- drivers/hwtracing/coresight/coresight-etm4x-core.c | 9 ++++++--- drivers/hwtracing/coresight/coresight-etm4x-sysfs.c | 6 ++++-- drivers/hwtracing/coresight/coresight-etm4x.h | 7 +++++-- 4 files changed, 16 insertions(+), 8 deletions(-)
drivers/hwtracing/coresight/coresight-etm4x-cfg.c +1 -1
@@ -76,7 +76,7 @@ static int etm4_cfg_map_reg_offset(struct etmv4_drvdata *drvdata, }else if ((offset &GENMASK (11 ,4 )) ==TRCSEQEVRn (0 )) {/* sequencer state control registers */ idx = (offset &GENMASK (3 ,0 )) /4 ; -if (idx <ETM_MAX_SEQ_STATES ) { +if (idx <ETM_MAX_SEQ_TRANSITIONS ) { reg_csdev->driver_regval = &drvcfg->seq_ctrl[idx]; err =0 ; }
drivers/hwtracing/coresight/coresight-etm4x-core.c +6 -3
@@ -497,7 +497,8 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata)etm4x_relaxed_write32 (csa, config->vissctlr,TRCVISSCTLR );if (drvdata->nr_pe_cmp)etm4x_relaxed_write32 (csa, config->vipcssctlr,TRCVIPCSSCTLR ); -for (i =0 ; i < drvdata->nrseqstate -1 ; i++) + +for (i =0 ; i < drvdata->nr_seq_ctrls; i++)etm4x_relaxed_write32 (csa, config->seq_ctrl[i],TRCSEQEVRn (i));if (drvdata->nrseqstate) {etm4x_relaxed_write32 (csa, config->seq_rst,TRCSEQRSTEVR );
@@ -1263,6 +1264,8 @@ static void etm4_init_arch_data(void *info) drvdata->lpoverride = (etmidr5 &TRCIDR5_LPOVERRIDE ) && (!drvdata->skip_power_up);/* NUMSEQSTATE, bits[27:25] number of sequencer states implemented */ drvdata->nrseqstate =FIELD_GET (TRCIDR5_NUMSEQSTATE_MASK , etmidr5); +if (drvdata->nrseqstate) + drvdata->nr_seq_ctrls =ETM_MAX_SEQ_TRANSITIONS ;/* NUMCNTR, bits[30:28] number of counters available for tracing */ drvdata->nr_cntr =FIELD_GET (TRCIDR5_NUMCNTR_MASK , etmidr5);etm4_cs_lock (drvdata, csa);
@@ -1677,7 +1680,7 @@ static int __etm4_cpu_save(struct etmv4_drvdata *drvdata)if (drvdata->nr_pe_cmp) state->trcvipcssctlr =etm4x_read32 (csa,TRCVIPCSSCTLR ); -for (i =0 ; i < drvdata->nrseqstate -1 ; i++) +for (i =0 ; i < drvdata->nr_seq_ctrls; i++) state->trcseqevr[i] =etm4x_read32 (csa,TRCSEQEVRn (i));if (drvdata->nrseqstate) {
@@ -1809,7 +1812,7 @@ static void __etm4_cpu_restore(struct etmv4_drvdata *drvdata)if (drvdata->nr_pe_cmp)etm4x_relaxed_write32 (csa, state->trcvipcssctlr,TRCVIPCSSCTLR ); -for (i =0 ; i < drvdata->nrseqstate -1 ; i++) +for (i =0 ; i < drvdata->nr_seq_ctrls; i++)etm4x_relaxed_write32 (csa, state->trcseqevr[i],TRCSEQEVRn (i));if (drvdata->nrseqstate) {
drivers/hwtracing/coresight/coresight-etm4x-sysfs.c +4 -2
@@ -221,7 +221,7 @@ static ssize_t reset_store(struct device *dev, config->vipcssctlr =0x0 ;/* Disable seq events */ -for (i =0 ; i < drvdata->nrseqstate-1 ; i++) +for (i =0 ; i < drvdata->nr_seq_ctrls; i++) config->seq_ctrl[i] =0x0 ; config->seq_rst =0x0 ; config->seq_state =0x0 ;
@@ -1387,9 +1387,11 @@ static ssize_t seq_idx_store(struct device *dev,struct etmv4_drvdata *drvdata =dev_get_drvdata (dev->parent);struct etmv4_config *config = &drvdata->config; +if (!drvdata->nr_seq_ctrls) +return -ENOTSUPP ;if (kstrtoul (buf,16 , &val))return -EINVAL ; -if (val >= drvdata->nrseqstate -1 ) +if (val >= drvdata->nr_seq_ctrls)return -EINVAL ;/*
drivers/hwtracing/coresight/coresight-etm4x.h +5 -2
@@ -513,6 +513,7 @@#define ETM_MAX_NR_PE 8#define ETMv4_MAX_CNTR 4#define ETM_MAX_SEQ_STATES 4 +#define ETM_MAX_SEQ_TRANSITIONS 3#define ETM_MAX_EXT_INP_SEL 4#define ETM_MAX_EXT_INP 256#define ETM_MAX_EXT_OUT 4
@@ -788,7 +789,7 @@ struct etmv4_config {u32 vipcssctlr;u8 seq_idx;u8 syncfreq; -u32 seq_ctrl[ETM_MAX_SEQ_STATES ]; +u32 seq_ctrl[ETM_MAX_SEQ_TRANSITIONS ];u32 seq_rst;u32 seq_state;u8 cntr_idx;
@@ -840,7 +841,7 @@ struct etmv4_save_state {u32 trcvissctlr;u32 trcvipcssctlr; -u32 trcseqevr[ETM_MAX_SEQ_STATES ]; +u32 trcseqevr[ETM_MAX_SEQ_TRANSITIONS ];u32 trcseqrstevr;u32 trcseqstr;u32 trcextinselr;
@@ -891,6 +892,7 @@ struct etmv4_save_state {* @numcidc: Number of contextID comparators. * @numvmidc: Number of VMID comparators. * @nrseqstate: The number of sequencer states that are implemented. +* @nr_seq_ctrls: The number of sequence state transition control registers. * @nr_event: Indicates how many events the trace unit support. * @nr_resource:The number of resource selection pairs available for tracing. * @nr_ss_cmp: Number of single-shot comparator controls that are available.
@@ -955,6 +957,7 @@ struct etmv4_drvdata {u8 numcidc;u8 numvmidc;u8 nrseqstate; +u8 nr_seq_ctrls;u8 nr_event;u8 nr_resource;u8 nr_ss_cmp;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 747/935 regulator: qcom-rpmh: Fix PMIC5 BOB bypass mode handling
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kamal Wadhwa <[email protected]>
[ Upstream commit abd14bebb87e0fa2749371272c8b31d6ee5f0a36 ]
Currently, when rpmh_regulator_set_mode_bypass() helper function is called to set bypass mode, it sends PMIC4's BOB bypass mode value for even if its a PMIC5 BOB.
To fix this, introduce new hw_data parameterpmic_bypass_mode to store bypass mode value. Use it to send correct PMIC bypass mode value that corresponds to PMIC4/5 BOB regulators from the helper function.
--- drivers/regulator/qcom-rpmh-regulator.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/regulator/qcom-rpmh-regulator.c +5 -1
@@ -76,6 +76,7 @@ enum rpmh_regulator_type {* @hpm_min_load_uA: Minimum load current in microamps that requires * high power mode (HPM) operation. This is used * for LDO hardware type regulators only. +* @pmic_bypass_mode: The PMIC bypass mode value. * @pmic_mode_map: Array indexed by regulator framework mode * containing PMIC hardware modes. Must be large * enough to index all framework modes supported
@@ -89,6 +90,7 @@ struct rpmh_vreg_hw_data {const struct linear_range voltage_range;int n_voltages;int hpm_min_load_uA; +int pmic_bypass_mode;const int *pmic_mode_map;unsigned int (*of_map_mode)(unsigned int mode); };
@@ -275,7 +277,7 @@ static int rpmh_regulator_vrm_set_mode_bypass(struct rpmh_vreg *vreg,return pmic_mode;if (bypassed) - cmd.data =PMIC4_BOB_MODE_PASS ; + cmd.data = vreg->hw_data->pmic_bypass_mode;else cmd.data = pmic_mode;
@@ -665,6 +667,7 @@ static const struct rpmh_vreg_hw_data pmic4_bob = { .ops = &rpmh_regulator_vrm_bypass_ops, .voltage_range = REGULATOR_LINEAR_RANGE(1824000, 0, 83, 32000), .n_voltages = 84, + .pmic_bypass_mode = PMIC4_BOB_MODE_PASS, .pmic_mode_map = pmic_mode_map_pmic4_bob, .of_map_mode = rpmh_regulator_pmic4_bob_of_map_mode, };
@@ -755,6 +758,7 @@ static const struct rpmh_vreg_hw_data pmic5_bob = { .ops = &rpmh_regulator_vrm_bypass_ops, .voltage_range = REGULATOR_LINEAR_RANGE(3000000, 0, 31, 32000), .n_voltages = 32, + .pmic_bypass_mode = PMIC5_BOB_MODE_PASS, .pmic_mode_map = pmic_mode_map_pmic5_bob, .of_map_mode = rpmh_regulator_pmic4_bob_of_map_mode, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 748/935 sched/fair: Check CPU capacity before comparing group types during load balance
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo Neri <[email protected]>
[ Upstream commit 50b101f6e586b4417d060a976fd831cd87e86e2b ]
update_sd_pick_busiest() may incorrectly select a fully_busy group as the busiest group when its per-CPU capacity exceeds that of the destination CPU. This happens because the type of busiest group is initialized to group_has_spare and allows the fully_busy group to win the type comparison.
update_sd_pick_busiest() should not choose a candidate scheduling group with at most one runnable task if its per-CPU capacity is greater than that of the destination CPU. Such a check already exists, but it is done too
late: after the type comparison, preventing a subsequent fully_busy group of equal per-CPU capacity from being correctly selected.
Move this check to occur before comparing group types.
--- kernel/sched/fair.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
kernel/sched/fair.c +11 -11
@@ -9026,6 +9026,17 @@ static bool update_sd_pick_busiest(struct lb_env *env, sds->local_stat.group_type != group_has_spare))return false; +/* +* Candidate sg has no more than one task per CPU and has higher +* per-CPU capacity. Migrating tasks to less capable CPUs may harm +* throughput. Maximize throughput, power/energy consequences are not +* considered. +*/ +if ((env->sd->flags &SD_ASYM_CPUCAPACITY ) && + (sgs->group_type <= group_fully_busy) && + (capacity_greater (sg->sgc->min_capacity,capacity_of (env->dst_cpu)))) +return false; +if (sgs->group_type > busiest->group_type)return true;
@@ -9098,17 +9109,6 @@ static bool update_sd_pick_busiest(struct lb_env *env,break ; } -/* -* Candidate sg has no more than one task per CPU and has higher -* per-CPU capacity. Migrating tasks to less capable CPUs may harm -* throughput. Maximize throughput, power/energy consequences are not -* considered. -*/ -if ((env->sd->flags &SD_ASYM_CPUCAPACITY ) && - (sgs->group_type <= group_fully_busy) && - (capacity_greater (sg->sgc->min_capacity,capacity_of (env->dst_cpu)))) -return false; -return true; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 749/935 Bluetooth: btusb: Fix BD_ADDR byte order in btusb_set_bdaddr_wcn6855()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit d0b15d812688d3f0f3fe1c4426e12814d0c294dc ]
btusb_set_bdaddr_wcn6855() sends the address without swapping byte order for VSC 0xFC14, but the command expects the address in reversed byte order compared to other HCI commands like HCI_Create_Connection, resulting in a wrong BD_ADDR being set.
btmon log on WCN6855 shows VSC 0xFC14 is sent with swapped bytes 11 22 33 44 55 66, and Read BD ADDR returns the expected address 11:22:33:44:55:66:
< HCI Command: Vendor (0x3f|0x0014) plen 6 #3 [hci0]
11 22 33 44 55 66
Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 4 #4 [hci0]
Vendor (0x3f|0x0014) ncmd 1
Status: Success (0x00)< HCI Command: Read BD ADDR (0x04|0x0009) plen 0 #11 [hci0]
Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 10 #12 [hci0]
Read BD ADDR (0x04|0x0009) ncmd 1
Status: Success (0x00)
Address: 11:22:33:44:55:66 (OUI 11-22-33)Fix by swapping the input address before issuing the command.
--- drivers/bluetooth/btusb.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/bluetooth/btusb.c +5 -4
@@ -3259,14 +3259,15 @@ static int btusb_set_bdaddr_ath3012(struct hci_dev *hdev,static int btusb_set_bdaddr_wcn6855 (struct hci_dev *hdev,const bdaddr_t *bdaddr) { +bdaddr_t bdaddr_swapped;struct sk_buff *skb; -u8 buf[6 ];long ret; -memcpy (buf, bdaddr,sizeof (bdaddr_t)); +baswap (&bdaddr_swapped, bdaddr); - skb =__hci_cmd_sync_ev (hdev,0xfc14 ,sizeof (buf), buf, -HCI_EV_CMD_COMPLETE ,HCI_INIT_TIMEOUT ); + skb =__hci_cmd_sync_ev (hdev,0xfc14 ,sizeof (bdaddr_swapped), + &bdaddr_swapped,HCI_EV_CMD_COMPLETE , +HCI_INIT_TIMEOUT );if (IS_ERR (skb)) { ret =PTR_ERR (skb);bt_dev_err (hdev,"Change address command failed (%ld)" , ret);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 750/935 perf trace-event: Fix integer truncation in do_read() and skip()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tanushree Shah <[email protected]>
[ Upstream commit c108c1391be0826920991d24532fbae8f6373ddc ]
The do_read() and skip() functions use 'int' for size parameters, truncating 64-bit sizes from callers. This causes two issues:
1. Uninitialized memory dump: do_read() reads fewer bytes than allocated, leaving uninitialized heap memory that gets written to output files.
2. Out-of-bounds read: Parsing functions process the full 64-bit size while only partial data was read into the buffer.
Change do_read(), __do_read(), and skip() to use size_t for size parameters and ssize_t for return values (where applicable), matching read()/write() system calls.
Update callers to use ssize_t for storing return values.
--- tools/perf/util/trace-event-read.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
tools/perf/util/trace-event-read.c +14 -14
@@ -23,18 +23,18 @@ static int input_fd;static ssize_t trace_data_size;static bool repipe; -static int __do_read (int fd,void *buf,int size) +static ssize_t __do_read (int fd,void *buf,size_t size) { -int rsize = size; +size_t rsize = size;while (size) { -int ret =read (fd, buf, size); +ssize_t ret =read (fd, buf, size);if (ret <=0 )return -1 ;if (repipe) { -int retw =write (STDOUT_FILENO , buf, ret); +ssize_t retw =write (STDOUT_FILENO , buf, ret);if (retw <=0 || retw != ret) {pr_debug ("repiping input file" );
@@ -49,13 +49,13 @@ static int __do_read(int fd, void *buf, int size)return rsize; } -static int do_read (void *data,int size) +static ssize_t do_read (void *data,size_t size) { -int r; +ssize_t r; r =__do_read (input_fd, data, size);if (r <=0 ) { -pr_debug ("reading input file (size expected=%d received=%d)" , +pr_debug ("reading input file (size expected=%zu received=%zd)" , size, r);return -1 ; }
@@ -66,10 +66,10 @@ static int do_read(void *data, int size) }/* If it fails, the next read will report it */ -static void skip (int size) +static void skip (size_t size) {char buf[BUFSIZ ]; -int r; +size_t r;while (size) { r = size >BUFSIZ ?BUFSIZ : size;
@@ -200,7 +200,7 @@ static int read_header_files(struct tep_handle *pevent)unsigned long long size;char *header_page;char buf[BUFSIZ ]; -int ret =0 ; +ssize_t ret =0 ;if (do_read (buf,12 ) <0 )return -1 ;
@@ -248,7 +248,7 @@ static int read_header_files(struct tep_handle *pevent)static int read_ftrace_file (struct tep_handle *pevent,unsigned long long size) { -int ret; +ssize_t ret;char *buf; buf =malloc (size);
@@ -274,7 +274,7 @@ static int read_ftrace_file(struct tep_handle *pevent, unsigned long long size)static int read_event_file (struct tep_handle *pevent,char *sys,unsigned long long size) { -int ret; +ssize_t ret;char *buf; buf =malloc (size);
@@ -320,7 +320,7 @@ static int read_event_files(struct tep_handle *pevent)int systems;int count;int i,x; -int ret; +ssize_t ret; systems =read4 (pevent);
@@ -348,7 +348,7 @@ static int read_saved_cmdline(struct tep_handle *pevent) {unsigned long long size;char *buf; -int ret; +ssize_t ret;/* it can have 0 size */ size =read8 (pevent);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 751/935 scsi: sd: Fix sd_done() sense handling condition
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Xiuwei <[email protected]>
[ Upstream commit a640d4546b11be5709a82bdc63d7dafd8ddc6c9e ]
Only enter the sense_key switch when the command returned CHECK CONDITION with valid, non-deferred sense. The old condition let deferred or invalid sense fall through and mis-handle the I/O.
--- drivers/scsi/sd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/sd.c +2 -2
@@ -2042,8 +2042,8 @@ static int sd_done(struct scsi_cmnd *SCpnt) } sdkp->medium_access_timed_out =0 ; -if (!scsi_status_is_check_condition (result) && - (!sense_valid || sense_deferred)) +if (!scsi_status_is_check_condition (result) || + !sense_valid || sense_deferred) goto out;switch (sshdr.sense_key) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 752/935 Bluetooth: virtio_bt: avoid OOB read of build info string
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 502adc06ba76dee19c292ae4a07d74d202fe734d ]
The virtbt_setup_zephyr() sends the Zephyr vendor command 0xfc08 (Read Build Information) and hands the response to bt_dev_info() and hci_set_fw_info() as a "%s" string starting at skb->data + 1, without checking the length. A backend that answers with status only leaves that pointer past the end of the received data, so the walk reads adjacent slab memory until it meets a NUL. Those bytes reach the kernel log and the firmware-info debugfs file.
To fix this, print the string with a bounded "%.*s" limited to skb->len - 1. A short or unterminated response then prints as much as arrived instead of failing setup.
This mirrors commit dd068ef04412 ("Bluetooth: bpa10x: avoid OOB read of revision string in bpa10x_setup()"), which fixed the identical pattern.
--- drivers/bluetooth/virtio_bt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/bluetooth/virtio_bt.c +6 -2
@@ -112,9 +112,13 @@ static int virtbt_setup_zephyr(struct hci_dev *hdev)if (IS_ERR (skb))return PTR_ERR (skb); -bt_dev_info (hdev,"%s" , (char *)(skb->data +1 )); +/* Bounded print: the backend controls skb->len. */ +if (skb->len >1 ) { +int len = skb->len -1 ; -hci_set_fw_info (hdev,"%s" , skb->data +1 ); +bt_dev_info (hdev,"%.*s" , len, (char *)(skb->data +1 )); +hci_set_fw_info (hdev,"%.*s" , len, skb->data +1 ); + }kfree_skb (skb);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 753/935 Bluetooth: MSFT: validate evt_prefix_len against the response length
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ali Ahmet Memis <[email protected]>
[ Upstream commit 0079e1a944634ab2dc1c7cdec1144486d096407e ]
read_supported_features() only checks that the response covers the fixed part of struct msft_rp_read_supported_features, which is 11 bytes:
if (skb->len < sizeof(*rp)) {
bt_dev_err(hdev, "MSFT supported features length mismatch");
goto failed;
}evt_prefix[] is a flexible array member and rp->evt_prefix_len is an unvalidated u8 taken straight out of that response, so
msft->evt_prefix = kmemdup(rp->evt_prefix, rp->evt_prefix_len, GFP_KERNEL);
copies up to 255 bytes from a reply that may have carried none of them. What is copied is data the controller never sent, and it is then used to match incoming vendor events in msft_vendor_evt().
This is not an out-of-bounds access. An skb data allocation always has at least SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) bytes past the payload, which is more than the 255 byte maximum, so the read stays inside the allocation and KASAN does not report it. It is still a read of bytes the host was never given, with the length fully controlled by the controller.
Reject a response that is too short for the prefix it declares.
Verified with an emulated controller over /dev/vhci on a KASAN kernel, with vhci made to advertise an MSFT opcode the way btintel, btqca, btmtk and btrtl do unconditionally. A reply of exactly 11 bytes declaring evt_prefix_len = 255 reaches kmemdup and copies 255 bytes ("skb->len=11 evt_prefix_len=255", with the copied buffer dumped); since the reply ends at the fixed part, all 255 come from past the end of the response. No KASAN report is produced, as expected from the allocation slack described above. With this patch the response is rejected with "MSFT event prefix length mismatch" and msft->evt_prefix is left unset.
--- net/bluetooth/msft.c | 5 +++++ 1 file changed, 5 insertions(+)
net/bluetooth/msft.c +5 -0
@@ -132,6 +132,11 @@ static bool read_supported_features(struct hci_dev *hdev,if (rp->sub_opcode !=MSFT_OP_READ_SUPPORTED_FEATURES ) goto failed; +if (skb->len <sizeof (*rp) + rp->evt_prefix_len) { +bt_dev_err (hdev,"MSFT event prefix length mismatch" ); + goto failed; + } +if (rp->evt_prefix_len >0 ) { msft->evt_prefix =kmemdup (rp->evt_prefix, rp->evt_prefix_len,GFP_KERNEL );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 754/935 iio: light: gp2ap002: Fix unbalanced runtime PM on repeated event writes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikhil Gautam <[email protected]>
[ Upstream commit 579c049b4cb6fc72ce2c505fc5334540be0efcd3 ]
The IIO core does not filter duplicate writes to the event enable attribute, so writing the same value twice invokes write_event_config() twice. Enabling twice leaks a runtime PM reference, preventing the device from ever suspending again; disabling twice underflows the usage count and triggers a "Runtime PM usage count underflow" warning.
Bail out early when the requested state matches the current state. While at it, switch to pm_runtime_resume_and_get() so a failed resume is propagated to userspace instead of silently marking the event enabled.
--- drivers/iio/light/gp2ap002.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/iio/light/gp2ap002.c +10 -3
@@ -343,6 +343,10 @@ static int gp2ap002_write_event_config(struct iio_dev *indio_dev, int state) {struct gp2ap002 *gp2ap002 =iio_priv (indio_dev); +int ret; + +if (state == gp2ap002->enabled) +return 0 ;if (state) {/*
@@ -350,14 +354,17 @@ static int gp2ap002_write_event_config(struct iio_dev *indio_dev,* already) and reintialize the sensor by using runtime_pm * callbacks. */ -pm_runtime_get_sync (gp2ap002->dev); - gp2ap002->enabled = true; + ret =pm_runtime_resume_and_get (gp2ap002->dev); +if (ret) +return ret; + }else {pm_runtime_mark_last_busy (gp2ap002->dev);pm_runtime_put_autosuspend (gp2ap002->dev); - gp2ap002->enabled = false; } + gp2ap002->enabled = state; +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 755/935 iio: light: gp2ap002: re-enable irq if runtime suspend fails
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikhil Gautam <[email protected]>
[ Upstream commit 5d89e7cbac40057f5241a0832a86ce0fe97e4818 ]
gp2ap002_runtime_suspend() disables the irq before writing OPMOD. If the write fails, the callback returns an error with the irq still disabled while the PM core marks the device active again.
re-enable the irq before returning the error so the irq state matches the active state the PM core restores.
--- drivers/iio/light/gp2ap002.c | 1 + 1 file changed, 1 insertion(+)
drivers/iio/light/gp2ap002.c +1 -0
@@ -658,6 +658,7 @@ static int __maybe_unused gp2ap002_runtime_suspend(struct device *dev)/* Disable chip and IRQ, everything off */ ret =regmap_write (gp2ap002->map,GP2AP002_OPMOD ,0x00 );if (ret) { +enable_irq (gp2ap002->irq);dev_err (gp2ap002->dev,"error setting up operation mode\n" );return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 756/935 flow_offload: rename offload functions with offload instead of flow
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baowen Zheng <[email protected]>
[ Upstream commit 9c1c0e124ca25589e6cf040e105ab0857f9e9c3e ]
To improves readability, we rename offload functions with offload instead of flow.
The term flow is related to exact matches, so we rename these functions with offload.
We make this change to facilitate single action offload functions naming.
Stable-dep-of: d4e359b3608a ("net/sched: cls_api: fix teardown of an adopted proto on insert-race loss")
--- include/net/pkt_cls.h | 6 +++--- net/sched/cls_api.c | 12 ++++++------ net/sched/cls_flower.c | 8 ++++---- net/sched/cls_matchall.c | 8 ++++---- 4 files changed, 17 insertions(+), 17 deletions(-)
include/net/pkt_cls.h +3 -3
@@ -532,9 +532,9 @@ tcf_match_indev(struct sk_buff *skb, int ifindex)return ifindex == skb->skb_iif; } -int tc_setup_flow_action (struct flow_action *flow_action, -const struct tcf_exts *exts); -void tc_cleanup_flow_action (struct flow_action *flow_action); +int tc_setup_offload_action (struct flow_action *flow_action, +const struct tcf_exts *exts); +void tc_cleanup_offload_action (struct flow_action *flow_action);int tc_setup_cb_call (struct tcf_block *block,enum tc_setup_type type,void *type_data,bool err_stop,bool rtnl_held);
net/sched/cls_api.c +6 -6
@@ -3480,7 +3480,7 @@ static void tcf_act_put_cookie(struct flow_action_entry *entry)flow_action_cookie_destroy (entry->cookie); } -void tc_cleanup_flow_action (struct flow_action *flow_action) +void tc_cleanup_offload_action (struct flow_action *flow_action) {struct flow_action_entry *entry;int i;
@@ -3491,7 +3491,7 @@ void tc_cleanup_flow_action(struct flow_action *flow_action) entry->destructor (entry->destructor_priv); } } -EXPORT_SYMBOL (tc_cleanup_flow_action); +EXPORT_SYMBOL (tc_cleanup_offload_action);static void tcf_mirred_get_dev (struct flow_action_entry *entry,const struct tc_action *act)
@@ -3563,8 +3563,8 @@ static enum flow_action_hw_stats tc_act_hw_stats(u8 hw_stats)return hw_stats; } -int tc_setup_flow_action (struct flow_action *flow_action, -const struct tcf_exts *exts) +int tc_setup_offload_action (struct flow_action *flow_action, +const struct tcf_exts *exts) {struct tc_action *act;int i, j, k, err =0 ;
@@ -3738,14 +3738,14 @@ int tc_setup_flow_action(struct flow_action *flow_action, err_out:if (err) -tc_cleanup_flow_action (flow_action); +tc_cleanup_offload_action (flow_action);return err; err_out_locked:spin_unlock_bh (&act->tcfa_lock); goto err_out; } -EXPORT_SYMBOL (tc_setup_flow_action); +EXPORT_SYMBOL (tc_setup_offload_action);unsigned int tcf_exts_num_actions (struct tcf_exts *exts) {
net/sched/cls_flower.c +4 -4
@@ -456,7 +456,7 @@ static int fl_hw_replace_filter(struct tcf_proto *tp, cls_flower.rule->match.key = &f->mkey; cls_flower.classid = f->res.classid; - err =tc_setup_flow_action (&cls_flower.rule->action, &f->exts); + err =tc_setup_offload_action (&cls_flower.rule->action, &f->exts);if (err) {kfree (cls_flower.rule);if (skip_sw) {
@@ -468,7 +468,7 @@ static int fl_hw_replace_filter(struct tcf_proto *tp, err =tc_setup_cb_add (block, tp,TC_SETUP_CLSFLOWER , &cls_flower, skip_sw, &f->flags, &f->in_hw_count, rtnl_held); -tc_cleanup_flow_action (&cls_flower.rule->action); +tc_cleanup_offload_action (&cls_flower.rule->action);kfree (cls_flower.rule);if (err) {
@@ -2283,7 +2283,7 @@ static int fl_reoffload(struct tcf_proto *tp, bool add, flow_setup_cb_t *cb, cls_flower.rule->match.mask = &f->mask->key; cls_flower.rule->match.key = &f->mkey; - err =tc_setup_flow_action (&cls_flower.rule->action, &f->exts); + err =tc_setup_offload_action (&cls_flower.rule->action, &f->exts);if (err) {kfree (cls_flower.rule);if (tc_skip_sw (f->flags)) {
@@ -2300,7 +2300,7 @@ static int fl_reoffload(struct tcf_proto *tp, bool add, flow_setup_cb_t *cb,TC_SETUP_CLSFLOWER , &cls_flower, cb_priv, &f->flags, &f->in_hw_count); -tc_cleanup_flow_action (&cls_flower.rule->action); +tc_cleanup_offload_action (&cls_flower.rule->action);kfree (cls_flower.rule);if (err) {
net/sched/cls_matchall.c +4 -4
@@ -97,7 +97,7 @@ static int mall_replace_hw_filter(struct tcf_proto *tp, cls_mall.command =TC_CLSMATCHALL_REPLACE ; cls_mall.cookie = cookie; - err =tc_setup_flow_action (&cls_mall.rule->action, &head->exts); + err =tc_setup_offload_action (&cls_mall.rule->action, &head->exts);if (err) {kfree (cls_mall.rule);mall_destroy_hw_filter (tp, head, cookie,NULL );
@@ -111,7 +111,7 @@ static int mall_replace_hw_filter(struct tcf_proto *tp, err =tc_setup_cb_add (block, tp,TC_SETUP_CLSMATCHALL , &cls_mall, skip_sw, &head->flags, &head->in_hw_count, true); -tc_cleanup_flow_action (&cls_mall.rule->action); +tc_cleanup_offload_action (&cls_mall.rule->action);kfree (cls_mall.rule);if (err) {
@@ -301,7 +301,7 @@ static int mall_reoffload(struct tcf_proto *tp, bool add, flow_setup_cb_t *cb, TC_CLSMATCHALL_REPLACE :TC_CLSMATCHALL_DESTROY ; cls_mall.cookie = (unsigned long )head; - err =tc_setup_flow_action (&cls_mall.rule->action, &head->exts); + err =tc_setup_offload_action (&cls_mall.rule->action, &head->exts);if (err) {kfree (cls_mall.rule);if (add &&tc_skip_sw (head->flags)) {
@@ -314,7 +314,7 @@ static int mall_reoffload(struct tcf_proto *tp, bool add, flow_setup_cb_t *cb, err =tc_setup_cb_reoffload (block, tp, add, cb,TC_SETUP_CLSMATCHALL , &cls_mall, cb_priv, &head->flags, &head->in_hw_count); -tc_cleanup_flow_action (&cls_mall.rule->action); +tc_cleanup_offload_action (&cls_mall.rule->action);kfree (cls_mall.rule);if (err)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 757/935 net/sched: cls_api: fix teardown of an adopted proto on insert-race loss
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit d4e359b3608a0e184bbe8d61a5c3b50d0831c44a ]
In tc_new_tfilter() the create branch sets tp_created = 1 before calling tcf_chain_tp_insert_unique(). When the caller loses the race (another request inserted a proto at the same chain/prio first), insert_unique() destroys the caller's own tp_new and returns the winner's proto with an extra reference. tp_created was never cleared, so the loser's errout path treated the winner's live proto as its own and called tcf_chain_tp_delete_empty() on it, silently unlinking an active classifier that the winning request already advertised via RTM_NEWTFILTER.
Track the outcome of the insert step in a single tri-state variable so each errout path reacts correctly:
- TP_NOT_CREATED: no proto created; pursue the old path.
- TP_CREATED: proto inserted successfully; same code path as before.
- TP_NOT_OWNED: New - lost the insert race; tp is another request's proto (chain ref already released by tp_new's destroy)
Both errout reactions are single expressions derived from the state.
This fix is motivated by the Sashiko's automated review of Patch (net/sched: cls_api: Always acquire rtnl_lock when destroying locked classifiers) [1][2]. The review identified the silent-unlink behaviour of an adopted proto's teardown when a request loses the tcf_chain_tp_insert_unique() race.
[1] https://sashiko.dev/#/patchset/20260801125632.360365-1-jhs%40mojatatu.com
[2] https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260801125632.360365-1-jhs%40mojatatu.com
--- net/sched/cls_api.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
net/sched/cls_api.c +13 -5
@@ -1939,6 +1939,12 @@ static bool is_ingress_or_clsact(struct tcf_block *block, struct Qdisc *q)return tcf_block_shared (block) || (q && !!(q->flags &TCQ_F_INGRESS )); } +enum tcf_tp_insert_state { +TP_NOT_CREATED =0 ,/* did not create and insert a new tp */ +TP_CREATED ,/* created and inserted a new tp */ +TP_NOT_OWNED ,/* created a proto but failed to insert */ +}; +static int tc_new_tfilter (struct sk_buff *skb,struct nlmsghdr *n,struct netlink_ext_ack *extack) {
@@ -1959,7 +1965,7 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n,unsigned long cl;void *fh;int err; -int tp_created; +enum tcf_tp_insert_state tp_state;bool rtnl_held = false;u32 flags;
@@ -1967,7 +1973,7 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n,return -EPERM ; replay: - tp_created =0 ; + tp_state =TP_NOT_CREATED ; err =nlmsg_parse_deprecated (n,sizeof (*t), tca,TCA_MAX , rtm_tca_policy, extack);
@@ -2090,13 +2096,15 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n, goto errout_tp; } - tp_created =1 ; + tp_state =TP_CREATED ; tp =tcf_chain_tp_insert_unique (chain, tp_new, protocol, prio, rtnl_held);if (IS_ERR (tp)) { err =PTR_ERR (tp); goto errout_tp; } +if (tp != tp_new) + tp_state =TP_NOT_OWNED ; }else {mutex_unlock (&chain->filter_chain_lock); }
@@ -2147,13 +2155,13 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n, } errout: -if (err && tp_created) +if (err && tp_state ==TP_CREATED )tcf_chain_tp_delete_empty (chain, tp, rtnl_held,NULL ); errout_tp:if (chain) {if (tp && !IS_ERR (tp))tcf_proto_put (tp, rtnl_held,NULL ); -if (!tp_created) +if (tp_state ==TP_NOT_CREATED )tcf_chain_put (chain); }tcf_block_release (q, block, rtnl_held);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 758/935 arm64: dts: turris-mox: fix usb3 phys
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomáš Macholda <[email protected]>
[ Upstream commit 0c2a8eed95160e41b367a1fa605a2c1b24a9639a ]
After commit 00e6d608fe80b0f6 ("arm64: dts: marvell: armada-37xx: swap PHYs' order in USB3 controller node") swapped USB3 PHY order, USB initialization breaks on Turris MOX.
This regression was exposed by commit 91ddf6f722084383 ("phy: marvell:
mvebu-a3700-utmi: fix incorrect USB2_PHY_CTRL register access") which made USB2 devices not work at all.
Fix the issue by explicitly adding all USB3 PHYs and PHY names to Turris MOX device-tree.
--- arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts +2 -1
@@ -291,7 +291,8 @@ connector { &usb3 { status = "okay"; - phys = <&comphy2 0>; + phys = <&usb2_utmi_otg_phy>, <&comphy2 0>; + phy-names = "usb2-phy", "usb3-phy"; }; &mdio {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 759/935 ARM: dts: helios4: add vcc-supply to EEPROM
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit ef65cf08bd1aa723de2854d02fb8eb8cca273c90 ]
The at24 driver requests a 'vcc' supply for the EEPROM, producing 'supply vcc not found, using dummy regulator' at boot when the property is missing.
The EEPROM sits on the Helios 4 and is powered by the same always-on 3.3V rail used by other on-board I2C devices. Add vcc-supply = <®_3p3v> to silence the warning.
--- arch/arm/boot/dts/armada-388-helios4.dts | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/boot/dts/armada-388-helios4.dts +4 -0
@@ -201,6 +201,10 @@ temp_sensor: temp@4c { reg = <0x4c>; vcc-supply = <®_3p3v>; }; + + eeprom@53 { + vcc-supply = <®_3p3v>; + }; }; i2c@11100 {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 760/935 ARM: dts: helios4: add vcc-supply to GPIO expander
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit c23988f84496e937dd255564cb30bec67608dcc6 ]
The pca953x driver requests a 'vcc' supply, producing:
pca953x 0-0020: supply vcc not found, using dummy regulator
The PCA9655 (PCA9555-compatible) expander is powered by the same always-on 3.3V rail as the other I2C devices on the bus. Add vcc-supply = <®_3p3v> to silence the warning.
--- arch/arm/boot/dts/armada-388-helios4.dts | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/armada-388-helios4.dts +1 -0
@@ -169,6 +169,7 @@ expander0: gpio-expander@20 { gpio-controller; #gpio-cells = <2>; reg = <0x20>; + vcc-supply = <®_3p3v>; pinctrl-names = "default"; pinctrl-0 = <&pca0_pins>; interrupt-parent = <&gpio0>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 761/935 ARM: dts: helios4: add SATA regulator supplies
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 7a90520e8c9a8f48fe6f3e741cf34d8c2b6dbc61 ]
The ahci-mvebu driver and libahci_platform request three supplies on SATA controller and port nodes:
- ahci-supply (controller power)
- phy-supply (PHY power)
- target-supply (disk power per port)
Without them the regulator core prints notices at boot, e.g.:
supply ahci not found, using dummy regulator supply phy not found, using dummy regulator supply target not found, using dummy regulator
The SATA controller and PHY inside the Armada 388 SoC are powered by the 3.3V I/O rail; the four disk bays are powered by the 5V HDD rail. Wire the existing fixed regulators accordingly.
--- arch/arm/boot/dts/armada-388-helios4.dts | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm/boot/dts/armada-388-helios4.dts +8 -0
@@ -222,13 +222,17 @@ sata@a8000 { status = "okay"; #address-cells = <1>; #size-cells = <0>; + ahci-supply = <®_3p3v>; + phy-supply = <®_3p3v>; sata0: sata-port@0 { reg = <0>; + target-supply = <®_5p0v_hdd>; }; sata1: sata-port@1 { reg = <1>; + target-supply = <®_5p0v_hdd>; }; };
@@ -236,13 +240,17 @@ sata@e0000 { status = "okay"; #address-cells = <1>; #size-cells = <0>; + ahci-supply = <®_3p3v>; + phy-supply = <®_3p3v>; sata2: sata-port@0 { reg = <0>; + target-supply = <®_5p0v_hdd>; }; sata3: sata-port@1 { reg = <1>; + target-supply = <®_5p0v_hdd>; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 762/935 perf stat: Clear screen only if output file is a tty
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namhyung Kim <[email protected]>
[ Upstream commit 81a02c6577ecfee7056ccafbd028984d0d670c0c ]
The --interval-clear option makes perf stat to clear the terminal at each interval. But it doesn't need to clear the screen when it saves to a file.
to a file. Make it fail when it's enabled with the output options.
$ perf stat -I 1 --interval-clear -o myfile true --interval-clear does not work with output
Usage: perf stat [<options>] [<command>]
-o, --output <file> output file name
--log-fd <n> log output to fd, instead of stderr
--interval-clear clear screen in between new intervalStable-dep-of: 340641a4b5ff ("perf stat: Fix evsel_list leak in cmd_stat")
--- tools/perf/builtin-stat.c | 8 ++++++++ 1 file changed, 8 insertions(+)
tools/perf/builtin-stat.c +8 -0
@@ -2303,6 +2303,14 @@ int cmd_stat(int argc, const char **argv) } } +if (stat_config.interval_clear && !isatty (fileno (output))) { +fprintf (stderr,"--interval-clear does not work with output\n" ); +parse_options_usage (stat_usage, stat_options,"o" ,1 ); +parse_options_usage (NULL , stat_options,"log-fd" ,0 ); +parse_options_usage (NULL , stat_options,"interval-clear" ,0 ); +return -1 ; + } + stat_config.output = output;/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 763/935 perf stat: Fix evsel_list leak in cmd_stat
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 340641a4b5fff4f4b12261c9d92169f6e2ea11f4 ]
Fix a memory leak in cmd_stat() where evsel_list is leaked if an error occurs while opening the output file.
--- tools/perf/builtin-stat.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
tools/perf/builtin-stat.c +6 -3
@@ -2290,7 +2290,8 @@ int cmd_stat(int argc, const char **argv) output =fopen (output_name, mode);if (!output) {perror ("failed to create output file" ); -return -1 ; + status =-1 ; + goto out; }clock_gettime (CLOCK_REALTIME , &tm);fprintf (output,"# started on %s\n" ,ctime (&tm.tv_sec));
@@ -2299,7 +2300,8 @@ int cmd_stat(int argc, const char **argv) output =fdopen (output_fd, mode);if (!output) {perror ("Failed opening logfd" ); -return -errno; + status = -errno; + goto out; } }
@@ -2308,7 +2310,8 @@ int cmd_stat(int argc, const char **argv)parse_options_usage (stat_usage, stat_options,"o" ,1 );parse_options_usage (NULL , stat_options,"log-fd" ,0 );parse_options_usage (NULL , stat_options,"interval-clear" ,0 ); -return -1 ; + status =-1 ; + goto out; } stat_config.output = output;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 764/935 perf synthetic-events: Fix uninitialized pthread_join
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 54ba44db4dddc4ca06b49bae0f9d6c5861430b18 ]
In perf_event__synthesize_threads(), fix an uninitialized pthread_join() call when thread creation fails by only joining the successfully created threads.
--- tools/perf/util/synthetic-events.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/synthetic-events.c +2 -2
@@ -1047,8 +1047,8 @@ int perf_event__synthesize_threads(struct perf_tool *tool, } err =0 ; out_join: -for (i =0 ; i < thread_nr; i++) -pthread_join (synthesize_threads[i],NULL ); +for (j =0 ; j < i; j++) +pthread_join (synthesize_threads[j],NULL );free (args); free_threads:free (synthesize_threads);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 765/935 perf synthetic-events: Fix divide by zero in perf_event__synthesize_threads
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 16a12a54e9a1151a37aab74914a51b86f7f58d0e ]
If scandir() finds no matching tasks in /proc, n is 0. If thread_nr is > 1, we bypass the single-thread fast path and then clamp thread_nr to n, making it 0. This results in a divide by zero when calculating num_per_thread.
Handle n <= 1 early to use the single-thread fast path and prevent the crash.
--- tools/perf/util/synthetic-events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/synthetic-events.c +1 -1
@@ -1003,7 +1003,7 @@ int perf_event__synthesize_threads(struct perf_tool *tool,else thread_nr = nr_threads_synthesize; -if (thread_nr <=1 ) { +if (thread_nr <=1 || n <=1 ) { err =__perf_event__synthesize_threads (tool, process, machine, mmap_data, dirent, base, n);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 766/935 fbdev: kyro: Validate overlay viewport coordinates
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Danila Chernetsov <[email protected]>
[ Upstream commit 7b5c7bc55e13e7f5ac7b1eaf5c6d690389ea5ee3 ]
The overlay viewport end coordinates are computed from the viewport origin and dimensions using 32-bit unsigned arithmetic. Large input values can cause these calculations to wrap around before the resulting coordinates are passed to SetOverlayViewPort().
SetOverlayViewPort() packs the viewport coordinates into 16-bit register fields. The X coordinates are additionally adjusted by +2 and +1 before being written. Validate the coordinate calculations for 32-bit wraparound and ensure that the adjusted coordinates fit within their 16-bit register fields before calling SetOverlayViewPort().
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/video/fbdev/kyro/fbdev.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
drivers/video/fbdev/kyro/fbdev.c +23 -1
@@ -368,6 +368,9 @@ static int kyro_dev_overlay_create(u32 ulWidth,static int kyro_dev_overlay_viewport_set (u32 x,u32 y,u32 ulWidth,u32 ulHeight) { +u32 right; +u32 bottom; +if (deviceInfo.ulOverlayOffset ==0 )/* probably haven't called CreateOverlay yet */ return -EINVAL ;
@@ -377,11 +380,30 @@ static int kyro_dev_overlay_viewport_set(u32 x, u32 y, u32 ulWidth, u32 ulHeight (x < 2 && ulWidth + 2 == 0))return -EINVAL ; +/* +* SetOverlayViewPort() adjusts X coordinates by +2 (left) and +1 +* (right) before packing them into 16-bit register fields. +*/ +if (x >U16_MAX -2 || y >U16_MAX ) +return -EINVAL ; + + right = x + ulWidth; + bottom = y + ulHeight; + +if (right < x || bottom < y) +return -EINVAL ; + + right--; + bottom--; + +if (right >U16_MAX -1 || bottom >U16_MAX ) +return -EINVAL ; +/* Stop Ramdac Output */ DisableRamdacOutput (deviceInfo.pSTGReg);SetOverlayViewPort (deviceInfo.pSTGReg, - x, y, x + ulWidth -1 , y + ulHeight -1 ); + x, y, right, bottom);EnableOverlayPlane (deviceInfo.pSTGReg);/* Start Ramdac Output */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 767/935 iommu/vt-d: Fix UCTP context table slot when copying root entries
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Desnes Nunes <[email protected]>
[ Upstream commit c6e63fc8e8fcefa5c32145dc0a3c82975b0ce152 ]
When translation is already enabled at boot (e.g. kdump), the vt-d driver copies context tables from the previous kernel's root table. In scalable mode, buses that only populate the upper root half (UCTP, devfn >= 0x80) should be written to ctxt_tbls[tbl_idx + 1] through copy_context_table(). However, the current copy path always uses tbl[tbl_idx + 0] in this situa- tion. Since idx wraps to 0 at devfn 0x80 due to a zeroed LCTP, new_ce for LCTP will be NULL and keep pos equals to 0. Thus, UCTP entries will be co- pied into tbl[tbl_idx + 0] instead of tbl[tbl_idx + 1], and written after- wards to root_entry[bus].lo instead of .hi in copy_translation_tables().
In short, devices on bus 0x80 with devfn >= 0x80 fail DMA with fault 0x39, which will break drivers running in kernels with translation pre-enabled. This fixes NO_PASID DMAR faults for UCTP-only buses such as:
DMAR: [DMA Read NO_PASID] Request device [80:14.0] fault addr 0xe81759000
[fault reason 0x39] SM: Present bit in Root Entry is clear
For instance, this fault yielded to locking issues between systemd and xHCI, blocking a system's reboot after a vmcore was captured with kdump:
systemd-udevd[246]: usb3: Worker [255] processing SEQNUM=2193 is taking a long time dracut-initqueue[277]: Timed out while waiting for udev queue to empty. systemd-udevd[246]: usb3: Worker [255] processing SEQNUM=2193 killed systemd-udevd[246]: usb3: Worker [255] terminated by signal 9 (KILL).
...
kdump[569]: saving vmcore complete
...
systemd-shutdown[1]: Rebooting.
INFO: task kworker/0:1:11 blocked for more than 122 seconds.
Not tainted 7.0.0-clean #1
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:kworker/0:1 state:D stack:0 pid:11 tgid:11 ppid:2 task_flags:0x4208160 flags:0x00080000
Workqueue: usb_hub_wq hub_event
Call Trace:
<TASK>
__schedule+0x299/0x5c0
schedule+0x27/0x80
schedule_timeout+0xbd/0x100
__wait_for_common+0x97/0x1b0
? __pfx_schedule_timeout+0x10/0x10
xhci_alloc_dev+0x9e/0x2b0
usb_alloc_dev+0x7a/0x3b0
hub_port_connect+0x285/0x960
hub_port_connect_change+0x94/0x290
port_event+0x4bb/0x840
hub_event+0x141/0x460
process_one_work+0x196/0x390
worker_thread+0x1af/0x320
? __pfx_worker_thread+0x10/0x10
kthread+0xe3/0x120
? __pfx_kthread+0x10/0x10
ret_from_fork+0x199/0x260
? __pfx_kthread+0x10/0x10
ret_from_fork_asm+0x1a/0x30
</TASK>
INFO: task systemd-shutdow:1 blocked for more than 122 seconds.
Not tainted 7.0.0-clean #1
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:systemd-shutdow state:D stack:0 pid:1 tgid:1 ppid:0 task_flags:0x400100 flags:0x00080000
Call Trace:
<TASK>
__schedule+0x299/0x5c0
schedule+0x27/0x80
schedule_preempt_disabled+0x15/0x30
__mutex_lock.constprop.0+0x547/0xac0
device_shutdown+0xac/0x1b0
kernel_restart+0x3a/0x70
__do_sys_reboot+0x147/0x240
do_syscall_64+0x11b/0x6a0
? handle_mm_fault+0x110/0x350
? do_user_addr_fault+0x206/0x680
? irqentry_exit+0x7a/0x4d0
entry_SYSCALL_64_after_hwframe+0x76/0x7e
RIP: 0033:0x7fe2958da917
RSP: 002b:00007ffc5c458618 EFLAGS: 00000206 ORIG_RAX: 00000000000000a9
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fe2958da917
RDX: 0000000001234567 RSI: 0000000028121969 RDI: 00000000fee1dead
RBP: 00007ffc5c458790 R08: 0000000000000069 R09: 00000000ffffffff
R10: 0000000000000000 R11: 0000000000000206 R12: 0000000000000000
R13: 0000000000000000 R14: 00007ffc5c4588b8 R15: 0000000000000000
</TASK>
INFO: task systemd-shutdow:1 is blocked on a mutex likely owned by task kworker/0:1:11.--- drivers/iommu/intel/iommu.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/iommu/intel/iommu.c +6 -4
@@ -2976,7 +2976,7 @@ static int copy_context_table(struct intel_iommu *iommu,struct context_entry **tbl, int bus, bool ext) { - int tbl_idx, pos = 0, idx, devfn, ret = 0, did; + int tbl_idx, tbl_slot = 0, idx, devfn, ret = 0, did;struct context_entry *new_ce =NULL , ce;struct context_entry *old_ce =NULL ;struct root_entry re;
@@ -2992,10 +2992,9 @@ static int copy_context_table(struct intel_iommu *iommu,if (idx ==0 ) {/* First save what we may have and clean up */ if (new_ce) { - tbl[tbl_idx] = new_ce; + tbl[tbl_idx + tbl_slot] = new_ce;__iommu_flush_cache (iommu, new_ce,VTD_PAGE_SIZE ); - pos =1 ; }if (old_ce)
@@ -3017,6 +3016,9 @@ static int copy_context_table(struct intel_iommu *iommu, } } +/* Track if saving UCTP or LCTP entries in scalable mode */ + tbl_slot = ext && devfn >=0x80 ?1 :0 ; + ret = -ENOMEM ; old_ce =memremap (old_ce_phys,PAGE_SIZE ,MEMREMAP_WB );
@@ -3044,7 +3046,7 @@ static int copy_context_table(struct intel_iommu *iommu, new_ce[idx] = ce; } - tbl[tbl_idx + pos] = new_ce; + tbl[tbl_idx + tbl_slot] = new_ce;__iommu_flush_cache (iommu, new_ce,VTD_PAGE_SIZE );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 768/935 m68k: Fix backtraces for non-running tasks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 09f71dbeb287e367beea56d9ac8a3d356ef5e02a ]
When no stack pointer is supplied, show_stack() starts at thread.esp0. This is the saved userspace register frame, not where a task was switched out. For kernel threads it points to the zeroed frame created by copy_thread(), so sched_show_task() prints no useful backtrace.
Use thread.ksp for non-current tasks. It is saved by switch_to() and is already used by __get_wchan(). For current, start at the current stack frame, as is already done when no task is supplied.
Tested on qemu-system-m68k -M virt using SysRq-t. All task dumps contained resolved frames.
--- arch/m68k/kernel/traps.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/m68k/kernel/traps.c +2 -2
@@ -936,8 +936,8 @@ void show_stack(struct task_struct *task, unsigned long *stack,int i;if (!stack) { -if (task) - stack = (unsigned long *)task->thread.esp0; +if (task && task != current) + stack = (unsigned long *)task->thread.ksp;else stack = (unsigned long *)&stack; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 769/935 SUNRPC: check rpc_sockaddr2uaddr() return value in rpcb_register_inet4/6
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit fd22370226a0d8109045d0831fd5aaadee921693 ]
rpcb_register_inet4() and rpcb_register_inet6() store the result of rpc_sockaddr2uaddr() into map->r_addr without checking it for NULL. rpc_sockaddr2uaddr() returns NULL when its final kstrdup() fails, and the unchecked NULL is then carried into the synchronous RPCBPROC_SET encode path: rpcb_register_call() -> rpc_call_sync() -> rpcb_enc_getaddr() -> encode_rpcb_string(), whose first statement is strlen(string), dereferencing NULL and oopsing the kernel.
The crash reproduces under failslab on v6.12; with KASAN the NULL dereference surfaces as a fault on the shadow of address zero:
Oops: general protection fault, probably for non-canonical address
0xdffffc0000000000 [#1] PREEMPT SMP KASAN
RIP: 0010:strlen (lib/string.c:409)
Call Trace:
encode_rpcb_string (net/sunrpc/rpcb_clnt.c:890)
rpcb_enc_getaddr (net/sunrpc/rpcb_clnt.c:910)
rpcauth_wrap_req_encode (net/sunrpc/auth.c:745)
call_encode (net/sunrpc/clnt.c:1966)
__rpc_execute (net/sunrpc/sched.c:952)
rpc_run_task (net/sunrpc/clnt.c:1243)
rpc_call_sync (net/sunrpc/clnt.c:1272)
rpcb_v4_register (net/sunrpc/rpcb_clnt.c:500)
svc_generic_rpcbind_set
nfsd_rpcbind_set
svc_register
svc_setup_socket
svc_addsock
write_ports
nfsctl_transaction_write
vfs_writeThe crash is reachable when an in-kernel RPC service (nfsd, lockd, nfs-callback) registers with the local rpcbind under enough memory pressure for the small GFP_KERNEL kstrdup() in rpc_sockaddr2uaddr() to fail. The asynchronous getport path already handles this exact failure mode by returning -ENOMEM; only the two register helpers omit the check.
Mirror that handling: bail out with -ENOMEM when rpc_sockaddr2uaddr() returns NULL, before the address is fed into the encoder.
--- net/sunrpc/rpcb_clnt.c | 4 ++++ 1 file changed, 4 insertions(+)
net/sunrpc/rpcb_clnt.c +4 -0
@@ -467,6 +467,8 @@ static int rpcb_register_inet4(struct sunrpc_net *sn,int result; map->r_addr =rpc_sockaddr2uaddr (sap,GFP_KERNEL ); +if (!map->r_addr) +return -ENOMEM ; msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET ];if (port !=0 ) {
@@ -493,6 +495,8 @@ static int rpcb_register_inet6(struct sunrpc_net *sn,int result; map->r_addr =rpc_sockaddr2uaddr (sap,GFP_KERNEL ); +if (!map->r_addr) +return -ENOMEM ; msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET ];if (port !=0 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 770/935 powerpc/configs: enable CONFIG_RAS to fix EDAC support
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Walle <[email protected]>
[ Upstream commit 3921cfc2e8155a767235801be88cbd0e4c73508d ]
Before commit e3c4ff6d8c94 ("EDAC: Remove EDAC_MM_EDAC") EDAC_MM_EDAC selected RAS, after that commit, EDAC depends on RAS, but nobody enables it. Enable it in the config again.
--- arch/powerpc/configs/85xx-hw.config | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/configs/85xx-hw.config +1 -0
@@ -90,6 +90,7 @@ CONFIG_PPC_EPAPR_HV_BYTECHAN=y CONFIG_QE_GPIO=y CONFIG_QUICC_ENGINE=y CONFIG_RAPIDIO=y +CONFIG_RAS=y CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_CMOS=y CONFIG_RTC_DRV_DS1307=y
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 771/935 spi: sprd-adi: Fix probe succeeding without registering the controller
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Babanpreet Singh <[email protected]>
[ Upstream commit f092e1c935015ee0a0fea1a0374f4cab7b71953c ]
With CONFIG_HWSPINLOCK=n the of_hwspin_lock_get_id() stub returns 0 unconditionally. In sprd_adi_probe() the guard
if (ret > 0 || (IS_ENABLED(CONFIG_HWSPINLOCK) && ret == 0))
is false for that 0, so it takes the else branch, where the switch has no case for 0 and lands in
default: return dev_err_probe(&pdev->dev, ret, "failed to find hwlock id\n");
dev_err_probe() returns its err argument unchanged, so probe logs "failed to find hwlock id" and then returns 0, reporting success. sprd_adi_hw_init(), the restart handler and devm_spi_register_controller() are all skipped: the device binds but no SPI controller is ever registered.
The hardware spinlock is optional for this controller and the -ENOENT arm already covers "no hardware spinlock supplied". Treat the stub's 0 the same way and continue without a lock; all four users of sadi->hwlock already test it for NULL.
This is not reachable on production kernels. Kconfig has
depends on HWSPINLOCK || (COMPILE_TEST && !HWSPINLOCK)
so the affected configuration exists only under COMPILE_TEST, where no real hardware is present.
Found by smatch:drivers/spi/spi-sprd-adi.c:560 sprd_adi_probe() warn: passing zero to 'dev_err_probe'
--- drivers/spi/spi-sprd-adi.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/spi/spi-sprd-adi.c +6 -0
@@ -564,6 +564,12 @@ static int sprd_adi_probe(struct platform_device *pdev) } }else {switch (ret) { +case 0 : +/* +* Only reachable with CONFIG_HWSPINLOCK=n, where the +* of_hwspin_lock_get_id() stub returns 0. +*/ + fallthrough;case -ENOENT :dev_info (&pdev->dev,"no hardware spinlock supplied\n" );break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 772/935 nvmet: fix NULL pointer dereference in nvmet_execute_identify_ns_zns()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
[ Upstream commit f594863967d87b7fcbff6e724d51135fd701a13d ]
When a host issues an Identify command with CNS 05h (I/O Command Set specific Identify Namespace) and CSI 02h (ZNS) targeting a file-backed namespace, nvmet_execute_identify_ns_zns() calls bdev_is_zoned() on req->ns->bdev. A file-backed namespace has no block device, so req->ns->bdev is NULL and bdev_is_zoned() dereferences it, oopsing.
The I/O command set is selected by the host-supplied CSI field and the command is routed here whenever CONFIG_BLK_DEV_ZONED is enabled, independent of the namespace backing type, so any file-backed namespace is exposed.
Reject the command with Invalid Field when the namespace is not backed by a block device.
--- drivers/nvme/target/zns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/zns.c +1 -1
@@ -124,7 +124,7 @@ void nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req)mutex_unlock (&req->ns->subsys->lock); } -if (!bdev_is_zoned (req->ns->bdev)) { +if (!req->ns->bdev || !bdev_is_zoned (req->ns->bdev)) { status =NVME_SC_INVALID_FIELD |NVME_STATUS_DNR ; req->error_loc = offsetof(struct nvme_identify , nsid); goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 773/935 nfc: llcp: avoid userspace overflow on invalid optlen
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit 99985bfa8336fadcc69190ba2dcbd5386af3d661 ]
nfc_llcp_getsockopt() casts optval to (u32 __user *) for put_user(), so the kernel always stores 4 bytes regardless of the caller-supplied optlen. The existing min_t(u32, len, sizeof(u32)) only clamps the length reported back to userspace; it does not constrain the store. A call with optlen < 4 therefore writes past the user buffer, violating the getsockopt(2) contract for all five supported optnames.
Reject any call with optlen < sizeof(u32) up front. 'len' is int, so a plain size comparison would promote a negative optlen to size_t and slip past the check; an explicit 'len < 0' test is added first to catch negative values before the size compare.
--- net/nfc/llcp_sock.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/nfc/llcp_sock.c +6 -0
@@ -314,6 +314,12 @@ static int nfc_llcp_getsockopt(struct socket *sock, int level, int optname,if (get_user (len, optlen))return -EFAULT ; +if (len <0 ) +return -EINVAL ; + +if (len <sizeof (u32)) +return -EINVAL ; + local = llcp_sock->local;if (!local)return -ENODEV ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 774/935 nfc: llcp: read llcp_sock->local under the socket lock in getsockopt
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit 36812527052c5bfb1ec6c1e292d67a5bf76b750f ]
nfc_llcp_getsockopt() read llcp_sock->local before lock_sock(sk) and then dereferenced the cached pointer inside the locked region. llcp_sock_bind() assigns and clears llcp_sock->local under the same socket lock, dropping the last reference on its error path. A getsockopt() racing an in-flight bind() can observe the pointer, block on lock_sock(), and then dereference a freed nfc_llcp_local once bind() has unwound.
Move the llcp_sock->local read and the NULL check inside the lock_sock(sk) region so bind() cannot mutate or free the pointer between the load and the use.
--- net/nfc/llcp_sock.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
net/nfc/llcp_sock.c +6 -4
@@ -320,14 +320,16 @@ static int nfc_llcp_getsockopt(struct socket *sock, int level, int optname,if (len <sizeof (u32))return -EINVAL ; - local = llcp_sock->local; -if (!local) -return -ENODEV ; - len =min_t (u32, len,sizeof (u32));lock_sock (sk); + local = llcp_sock->local; +if (!local) { +release_sock (sk); +return -ENODEV ; + } +switch (optname) {case NFC_LLCP_RW : rw = llcp_sock->rw >LLCP_MAX_RW ? local->rw : llcp_sock->rw;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 775/935 nfc: nci: fix double completion race in nci_data_exchange_complete
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhenghang Xiao <[email protected]>
[ Upstream commit 8265a626cc14a48e46e6dc8c47667e72b4232ac2 ]
nci_close_device() and nci_rx_work can both call nci_data_exchange_complete() concurrently. After commit 4527025d440ce8 ("nfc: nci: fix circular locking dependency in nci_close_device") moved flush_workqueue(ndev->rx_wq) after mutex_unlock(&ndev->req_lock), rx_work is no longer serialized with the explicit completion call in the close path. Both callers read the non-NULL callback pointer and invoke rawsock_data_exchange_complete(), which calls sock_put() -- but only one sock_hold() was taken, so the second sock_put() underflows the refcount and frees the socket while it is still in use.
Replace the bare clear_bit(NCI_DATA_EXCHANGE) with test_and_clear_bit() so that only the first caller proceeds to invoke the callback.
--- net/nfc/nci/data.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
net/nfc/nci/data.c +5 -5
@@ -46,11 +46,11 @@ void nci_data_exchange_complete(struct nci_dev *ndev, struct sk_buff *skb,del_timer_sync (&ndev->data_timer);clear_bit (NCI_DATA_EXCHANGE_TO , &ndev->flags); -/* Mark the exchange as done before calling the callback. -* The callback (e.g. rawsock_data_exchange_complete) may -* want to immediately queue another data exchange. -*/ -clear_bit (NCI_DATA_EXCHANGE , &ndev->flags); +/* Claim completion atomically -- both close and rx_work may race here */ +if (!test_and_clear_bit (NCI_DATA_EXCHANGE , &ndev->flags)) { +kfree_skb (skb); +return ; + }if (cb) {/* forward skb to nfc core */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 776/935 nfc: llcp: bound SNL TLV parsing to the skb and add length checks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Doruk Tan Ozturk <[email protected]>
[ Upstream commit f4c7f37f0ab990952539dc68d931d65c3657600a ]
nfc_llcp_recv_snl() walked the SNL TLV list using a u16 offset/length pair derived from skb->len, without bounding reads to the actual skb data. Three problems followed:
- For a short frame (skb->len < LLCP_HEADER_SIZE), tlv_len underflowed.
- The per-TLV header (type, length) was read without checking that two bytes remained.
- A declared TLV length could run past the end of the buffer, and an SDREQ with length == 0 made "service_name_len = length - 1" underflow (size_t), driving an out-of-bounds read in the following strncmp() / nfc_llcp_sock_from_sn(). The SDRES case likewise read tlv[2]/tlv[3] without a length check.
A nearby NFC device can reach this without authentication; LLCP link activation happens automatically after NFC-DEP.
Walk the TLV list by pointer, bounded by skb_tail_pointer() over the linear skb data, and validate each TLV declared length before use. Add explicit length checks for SDREQ (>= 1) and SDRES (exactly 2).
Found by 0sec automated security-research tooling (https://0sec.ai).
--- net/nfc/llcp_core.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-)
net/nfc/llcp_core.c +21 -8
@@ -1295,10 +1295,9 @@ static void nfc_llcp_recv_snl(struct nfc_llcp_local *local, {struct nfc_llcp_sock *llcp_sock;u8 dsap, ssap, type, length, tid, sap; -const u8 *tlv; -u16 tlv_len, offset; +const u8 *tlv, *tlv_end;const char *service_name; -size_t service_name_len; +int service_name_len;struct nfc_llcp_sdp_tlv *sdp;HLIST_HEAD (llc_sdres_list);size_t sdres_tlvs_len;
@@ -1314,22 +1313,34 @@ static void nfc_llcp_recv_snl(struct nfc_llcp_local *local, return; } + /* + * Walk the SNL TLV list in the linear part of the skb only, + * bounded by skb_tail_pointer(). Each TLV needs a two-byte + * header (type, length) and its declared length must fit before + * the end; this also keeps the walk safe for very short frames. + */ tlv = &skb->data[LLCP_HEADER_SIZE]; - tlv_len = skb->len - LLCP_HEADER_SIZE; - offset = 0; + tlv_end = skb_tail_pointer(skb); sdres_tlvs_len = 0; - while (offset < tlv_len) { + while (tlv + 2 < tlv_end) { type = tlv[0]; length = tlv[1]; + if (tlv + 2 + length > tlv_end) + break; + switch (type) { case LLCP_TLV_SDREQ: + if (length < 1) + break; + tid = tlv[2]; service_name = (char *) &tlv[3]; service_name_len = length - 1; - pr_debug("Looking for %.16s\n", service_name); + pr_debug("Looking for %.*s\n", service_name_len, + service_name); if (service_name_len == strlen("urn:nfc:sn:sdp") && !strncmp(service_name, "urn:nfc:sn:sdp",
@@ -1389,6 +1400,9 @@ static void nfc_llcp_recv_snl(struct nfc_llcp_local *local,break ;case LLCP_TLV_SDRES : +if (length !=2 ) +break ; +mutex_lock (&local->sdreq_lock);pr_debug ("LLCP_TLV_SDRES: searching tid %d\n" , tlv[2 ]);
@@ -1417,7 +1431,6 @@ static void nfc_llcp_recv_snl(struct nfc_llcp_local *local,break ; } - offset += length +2 ; tlv += length +2 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 777/935 nfc: pn533: hold a reference to the request skb during send_frame
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yinhao Hu <[email protected]>
[ Upstream commit 47792358a624ea066455ef86b744159928cd7716 ]
__pn533_send_async() publishes the command and then calls dev->phy_ops->send_frame(). Once dev->cmd is set, an incoming frame can be matched to this command: the I2C threaded IRQ runs pn533_recv_frame(), which queues cmd_complete_work, and pn533_send_async_complete() frees cmd->req with consume_skb().
On the I2C transport, pn533_i2c_send_frame() still dereferences the same skb after i2c_master_send() returns, so a completion that races the send can free the skb while the transport is still using it.
The request skb is owned by the command object and may be freed by command completion at any time after dev->cmd is published, so the transport send path must not assume it stays alive. Hold a temporary reference to the request skb across the send_frame() call so the transport always sees a live skb even if completion races the send. Add a pn533_send_cmd_frame() helper and use it from all three send paths.
--- drivers/nfc/pn533/pn533.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/nfc/pn533/pn533.c +15 -6
@@ -434,6 +434,18 @@ static int pn533_send_async_complete(struct pn533 *dev)return rc; } +static int pn533_send_cmd_frame (struct pn533 *dev,struct pn533_cmd *cmd) +{ +struct sk_buff *req = cmd->req; +int rc; + +skb_get (req); + dev->cmd = cmd; + rc = dev->phy_ops->send_frame (dev, req); +dev_kfree_skb (req); +return rc; +} + static int __pn533_send_async(struct pn533 *dev, u8 cmd_code, struct sk_buff *req, pn533_send_async_complete_t complete_cb,
@@ -458,8 +470,7 @@ static int __pn533_send_async(struct pn533 *dev, u8 cmd_code,mutex_lock (&dev->cmd_lock);if (!dev->cmd_pending) { - dev->cmd = cmd; - rc = dev->phy_ops->send_frame (dev, req); + rc =pn533_send_cmd_frame (dev, cmd);if (rc) { dev->cmd =NULL ; goto error;
@@ -529,8 +540,7 @@ static int pn533_send_cmd_direct_async(struct pn533 *dev, u8 cmd_code,pn533_build_cmd_frame (dev, cmd_code, req); - dev->cmd = cmd; - rc = dev->phy_ops->send_frame (dev, req); + rc =pn533_send_cmd_frame (dev, cmd);if (rc <0 ) { dev->cmd =NULL ;kfree (cmd);
@@ -569,8 +579,7 @@ static void pn533_wq_cmd(struct work_struct *work)mutex_unlock (&dev->cmd_lock); - dev->cmd = cmd; - rc = dev->phy_ops->send_frame (dev, cmd->req); + rc =pn533_send_cmd_frame (dev, cmd);if (rc <0 ) { dev->cmd =NULL ;dev_kfree_skb (cmd->req);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 778/935 nfc: digital: Do not dump a NULL response in command completion
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit 1c7dd70c0adfa58fd66b5cbd03efb747ad6d8d8d ]
digital_wq_cmd_complete() dumps the response data whenever cmd->resp is not an error pointer. However, a driver can legitimately complete a command with no response skb at all.
digital_tg_send_psl_res() is the only caller that passes timeout=0, meaning no response is expected once the command has been transmitted. On that path trf7970a completes the command with
trf->rx_skb = ERR_PTR(0);
which evaluates to NULL. IS_ERR(NULL) is false, so the NULL response passes the !IS_ERR() check and cmd->resp->data and cmd->resp->len are dereferenced whenever the debug print site is enabled. The driver guards its own dump with "trf->rx_skb && !IS_ERR(trf->rx_skb)"; the digital layer is missing the NULL half of that test.
Use IS_ERR_OR_NULL() so that NULL responses are skipped as well. The callback on that path, digital_tg_send_psl_res_complete(), never dereferences resp and dev_kfree_skb() accepts NULL, so only the debug dump needs fixing.
--- net/nfc/digital_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/nfc/digital_core.c +1 -1
@@ -127,7 +127,7 @@ static void digital_wq_cmd_complete(struct work_struct *work)mutex_unlock (&ddev->cmd_lock); -if (!IS_ERR (cmd->resp)) +if (!IS_ERR_OR_NULL (cmd->resp))print_hex_dump_debug ("DIGITAL RX: " ,DUMP_PREFIX_NONE ,16 ,1 , cmd->resp->data, cmd->resp->len, false);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 779/935 nfc: nci: fix use of uninitialized memory in CORE_INIT_RSP parsing
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yun Zhou <[email protected]>
[ Upstream commit d56575a2595ee1f597f39e8a1cfb67ed3501678d ]
nci_core_init_rsp_packet_v1() and nci_core_init_rsp_packet_v2() parse the CORE_INIT_RSP packet without validating that the skb contains enough data. A malformed response (e.g. injected via virtual_ncidev) can declare a large num_supported_rf_interfaces while providing insufficient data, causing reads of uninitialized slab memory. This is later used in nci_init_complete_req(), triggering a KMSAN uninit-value warning.
Add skb length checks before accessing packet fields:
- Validate the skb has at least 1 byte for the status field.
- Validate the skb can hold the fixed-size header before parsing.
- In v2, bounds-check each variable-length rf_interface entry and its extension parameters within the parsing loop.
- In v1, verify the skb is large enough for both the variable-length rf_interfaces array and the trailing rsp_2 structure.
--- net/nfc/nci/rsp.c | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-)
net/nfc/nci/rsp.c +38 -3
@@ -50,11 +50,27 @@ static u8 nci_core_init_rsp_packet_v1(struct nci_dev *ndev,const struct nci_core_init_rsp_1 *rsp_1 = (void *)skb->data;const struct nci_core_init_rsp_2 *rsp_2; +/* Ensure that the status field can be accessed. */ +if (skb_headlen (skb) <1 ) +return NCI_STATUS_SYNTAX_ERROR ; +pr_debug ("status 0x%x\n" , rsp_1->status);if (rsp_1->status !=NCI_STATUS_OK )return rsp_1->status; +/* Success response must contain the full fixed-size header */ +if (skb_headlen (skb) <sizeof (*rsp_1)) +return NCI_STATUS_SYNTAX_ERROR ; + +/* Ensure the variable-length rf_interfaces array and trailing +* rsp_2 structure are fully contained within the skb. +*/ +if (skb_headlen (skb) <sizeof (*rsp_1) + + rsp_1->num_supported_rf_interfaces + +sizeof (*rsp_2)) +return NCI_STATUS_SYNTAX_ERROR ; + ndev->nfcc_features =__le32_to_cpu (rsp_1->nfcc_features); ndev->num_supported_rf_interfaces = rsp_1->num_supported_rf_interfaces;
@@ -87,15 +103,25 @@ static u8 nci_core_init_rsp_packet_v2(struct nci_dev *ndev, const struct sk_buff *skb) {const struct nci_core_init_rsp_nci_ver2 *rsp = (void *)skb->data; -const u8 *supported_rf_interface = rsp->supported_rf_interfaces; +const u8 *supported_rf_interface;u8 rf_interface_idx =0 ;u8 rf_extension_cnt =0 ; +/* Ensure that the status field can be accessed. */ +if (skb_headlen (skb) <1 ) +return NCI_STATUS_SYNTAX_ERROR ; +pr_debug ("status %x\n" , rsp->status);if (rsp->status !=NCI_STATUS_OK )return rsp->status; +/* Success response must contain the full fixed-size header */ +if (skb_headlen (skb) <sizeof (*rsp)) +return NCI_STATUS_SYNTAX_ERROR ; + + supported_rf_interface = rsp->supported_rf_interfaces; + ndev->nfcc_features =__le32_to_cpu (rsp->nfcc_features); ndev->num_supported_rf_interfaces = rsp->num_supported_rf_interfaces;
@@ -104,13 +130,22 @@ static u8 nci_core_init_rsp_packet_v2(struct nci_dev *ndev, NCI_MAX_SUPPORTED_RF_INTERFACES);while (rf_interface_idx < ndev->num_supported_rf_interfaces) { - ndev->supported_rf_interfaces[rf_interface_idx++] = *supported_rf_interface++; +/* Each entry: [rf_interface_type (1B)] [ext_count (1B)] [ext...] */ +if (supported_rf_interface +2 >skb_tail_pointer (skb)) +break ; + ndev->supported_rf_interfaces[rf_interface_idx] = *supported_rf_interface++; -/* skip rf extension parameters */ rf_extension_cnt = *supported_rf_interface++; +if (supported_rf_interface + rf_extension_cnt >skb_tail_pointer (skb)) +break ; + +/* Only count the entry after full validation */ + rf_interface_idx++; supported_rf_interface += rf_extension_cnt; } + ndev->num_supported_rf_interfaces = rf_interface_idx; + ndev->max_logical_connections = rsp->max_logical_connections; ndev->max_routing_table_size =__le16_to_cpu (rsp->max_routing_table_size);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 780/935 dmaengine: qcom-bam-dma: fix autosuspend cleanup during removal
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit a50184171235045d96104811414b25cf5338cf86 ]
bam_dma_probe() calls pm_runtime_use_autosuspend(), but bam_dma_remove() does not call the matching pm_runtime_dont_use_autosuspend() when removing the device.
If the autosuspend delay is set to a negative value while autosuspend is enabled, the runtime PM core increments usage_count to prevent runtime suspend. Without calling pm_runtime_dont_use_autosuspend() during teardown, this reference is not dropped and usage_count remains unbalanced.
Add the missing pm_runtime_dont_use_autosuspend() call before forcing the device into runtime suspend during removal.
This issue was found by manual code inspection.
--- drivers/dma/qcom/bam_dma.c | 1 + 1 file changed, 1 insertion(+)
drivers/dma/qcom/bam_dma.c +1 -0
@@ -1373,6 +1373,7 @@ static int bam_dma_remove(struct platform_device *pdev)struct bam_device *bdev =platform_get_drvdata (pdev);u32 i; +pm_runtime_dont_use_autosuspend (&pdev->dev);pm_runtime_force_suspend (&pdev->dev);of_dma_controller_free (pdev->dev.of_node);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 781/935 RDMA/cxgb4: Free debugfs on registration failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
[ Upstream commit fe5c16bb6252dea6025b748257ddc3b2665495b0 ]
c4iw_alloc() creates the per-device debugfs tree (dev->debugfs_root via setup_debugfs()), but it is removed only in c4iw_remove(), not in c4iw_dealloc(). When RDMA device registration fails, the registration worker's err_dealloc_ctx path calls c4iw_dealloc() directly, bypassing c4iw_remove(), so the debugfs dentries leak and outlive the freed c4iw_dev.
Move debugfs_remove_recursive() into c4iw_dealloc() so every path that frees ctx->dev also removes its debugfs tree.
--- drivers/infiniband/hw/cxgb4/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/cxgb4/device.c +1 -1
@@ -935,6 +935,7 @@ static void c4iw_rdev_close(struct c4iw_rdev *rdev)void c4iw_dealloc (struct uld_ctx *ctx) { +debugfs_remove_recursive (ctx->dev->debugfs_root);c4iw_rdev_close (&ctx->dev->rdev);WARN_ON (!xa_empty (&ctx->dev->cqs));WARN_ON (!xa_empty (&ctx->dev->qps));
@@ -959,7 +960,6 @@ static void c4iw_remove(struct uld_ctx *ctx)if (!ctx->dev)return ; -debugfs_remove_recursive (ctx->dev->debugfs_root);c4iw_unregister_device (ctx->dev);c4iw_dealloc (ctx); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 782/935 RDMA/cma: Fix WARNING in res_to_rt
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhu Yanjun <[email protected]>
[ Upstream commit c6d1ec4fbe56492bb88987d577f04a5fb6955f26 ]
syzbot reported a WARN_ON(!res->dev) in res_to_rt() triggered via addr_handler() during asynchronous address resolution:
"
WARNING: drivers/infiniband/core/restrack.c:138 at res_to_rt+0x1c4/0x230 CPU#1: kworker/u8:4/59 Modules linked in: CPU: 1 UID: 0 PID: 59 Comm: kworker/u8:4 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Compute Engine, BIOS Google 07/24/2026 Workqueue: ib_addr process_one_req RIP: 0010:res_to_rt+0x1c4/0x230 drivers/infiniband/core/restrack.c:138 RSP: 0018:ffffc9000201f850 EFLAGS: 00010293 RAX: ffffffff88d00ce5 RBX: ffff88807f0fd4f8 RCX: ffff88801e6e0000 RDX: 0000000000000000 RSI: ffffffff8fd996f0 RDI: 0000000000000003 RBP: 0000000000000000 R08: ffff88801e6e0000 R09: 000000000000000a R10: 0000000000000009 R11: 0000000000000000 R12: dffffc0000000000 R13: 1ffff1100fe1fa9f R14: 0000000000000000 R15: 0000000000000003 FS: 0000000000000000(0000) GS:ffff888125012000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00001d559c3d2000 CR3: 0000000077c4c000 CR4: 00000000003526f0 Call Trace: <TASK> rdma_restrack_add+0x5a/0x8a0 drivers/infiniband/core/restrack.c:236 addr_handler+0x41a/0x5a0 drivers/infiniband/core/cma.c:3534 process_one_req+0x2eb/0x540 drivers/infiniband/core/addr.c:624 process_one_work kernel/workqueue.c:3375 [inline] process_scheduled_works+0xc4e/0x1630 kernel/workqueue.c:3458 worker_thread+0xa47/0xfb0 kernel/workqueue.c:3539 kthread+0x388/0x470 kernel/kthread.c:436 ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 </TASK>
"
In addr_handler(), cma_acquire_dev_by_src_ip() is called to populate id_priv->cma_dev and bind the associated ib_device to id_priv->id.device. If cma_acquire_dev_by_src_ip() returns an error (non-zero status), the ID remains unassociated with any RDMA device.
Previously, rdma_restrack_add(&id_priv->res) was invoked unconditionally even when cma_acquire_dev_by_src_ip() failed, passing a resource with a NULL dev pointer and triggering the WARN_ON assertion in res_to_rt().
Fix this by only adding the resource to restrack when acquiring the device succeeds.
--- drivers/infiniband/core/cma.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/infiniband/core/cma.c +4 -2
@@ -3289,10 +3289,12 @@ static void addr_handler(int status, struct sockaddr *src_addr,memcpy (addr, src_addr,rdma_addr_size (src_addr));if (!status && !id_priv->cma_dev) { status =cma_acquire_dev_by_src_ip (id_priv); -if (status) +if (status) {pr_debug_ratelimited ("RDMA CM: ADDR_ERROR: failed to acquire device. status %d\n" , status); -rdma_restrack_add (&id_priv->res); + }else { +rdma_restrack_add (&id_priv->res); + } }else if (status) {pr_debug_ratelimited ("RDMA CM: ADDR_ERROR: failed to resolve IP. status %d\n" , status); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 783/935 ASoC: pxa: Use devm_clk_get_optional() for extclk clock
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 6ec64d757af9b75a3c64f9f7dad76bdc1efc06ca ]
The Device Tree binding defines the extclk clock as an optional property, but the driver currently uses devm_clk_get() and manually handles the absence of the clock.
Use devm_clk_get_optional() to match the binding and simplify the optional clock handling. This also propagates errors other than the absence of the optional clock, including -EPROBE_DEFER.
This changes the existing behavior for errors other than -EPROBE_DEFER. RFC to discuss whether these errors should cause probe to fail rather than being treated as an unavailable optional clock.
--- sound/soc/pxa/pxa-ssp.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
sound/soc/pxa/pxa-ssp.c +2 -5
@@ -775,13 +775,10 @@ static int pxa_ssp_probe(struct snd_soc_dai *dai) goto err_priv; } - priv->extclk =devm_clk_get (dev,"extclk" ); + priv->extclk =devm_clk_get_optional (dev,"extclk" );if (IS_ERR (priv->extclk)) { ret =PTR_ERR (priv->extclk); -if (ret == -EPROBE_DEFER ) - goto err_priv; - - priv->extclk =NULL ; + goto err_priv; } }else { priv->ssp =pxa_ssp_request (dai->id +1 ,"SoC audio" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 784/935 ASoC: fsl-asoc-card: defer probe when the CPU DAI device is not ready
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: LiangCheng Wang <[email protected]>
[ Upstream commit 0286324da660875dc504fd65b3be87e9c8b9a547 ]
fsl_asoc_card_probe() hard-fails with -EINVAL when the CPU DAI (SAI) platform device is not found. Like the codec, the CPU DAI may just be probed later than the machine driver; the order is not guaranteed and varies across kernel versions, so a permanent -EINVAL leaves the card unregistered with no analog playback or capture.
Defer probe instead, mirroring commit e396dec46c56 ("ASoC:
fsl-asoc-card: Defer probe when fail to find codec device").
Tested on i.MX8MP with an ALC5672 on SAI3: the card that failed to register on v6.18 now comes up during boot.
--- sound/soc/fsl/fsl-asoc-card.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/fsl/fsl-asoc-card.c +2 -2
@@ -562,8 +562,8 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) cpu_pdev =of_find_device_by_node (cpu_np);if (!cpu_pdev) { -dev_err (&pdev->dev,"failed to find CPU DAI device\n" ); - ret = -EINVAL ; + ret =dev_err_probe (&pdev->dev, -EPROBE_DEFER , +"failed to find CPU DAI device\n" ); goto fail; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 785/935 ubi: Fix repeated words in comments
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jilin Yuan <[email protected]>
[ Upstream commit ec1f97f501a746403990515bbefcaecd7562b042 ]
Delete the redundant word 'a'.
Delete the redundant word 'the'.
Stable-dep-of: 420477a84f1e ("UBI: Preserve torture flag when rescheduling failed erasures")
--- drivers/mtd/ubi/cdev.c | 2 +- drivers/mtd/ubi/eba.c | 2 +- drivers/mtd/ubi/io.c | 2 +- drivers/mtd/ubi/ubi.h | 6 +++--- drivers/mtd/ubi/wl.c | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-)
drivers/mtd/ubi/cdev.c +1 -1
@@ -672,7 +672,7 @@ static int verify_rsvol_req(const struct ubi_device *ubi,* @req: volumes re-name request * * This is a helper function for the volume re-name IOCTL which validates the -* the request, opens the volume and calls corresponding volumes management +* request, opens the volume and calls corresponding volumes management * function. Returns zero in case of success and a negative error code in case * of failure. */
drivers/mtd/ubi/eba.c +1 -1
@@ -377,7 +377,7 @@ static int leb_write_lock(struct ubi_device *ubi, int vol_id, int lnum)* * This function locks a logical eraseblock for writing if there is no * contention and does nothing if there is contention. Returns %0 in case of -* success, %1 in case of contention, and and a negative error code in case of +* success, %1 in case of contention, and a negative error code in case of * failure. */ static int leb_write_trylock (struct ubi_device *ubi,int vol_id,int lnum)
drivers/mtd/ubi/io.c +1 -1
@@ -1147,7 +1147,7 @@ static int self_check_ec_hdr(const struct ubi_device *ubi, int pnum,* @ubi: UBI device description object * @pnum: the physical eraseblock number to check * -* This function returns zero if the erase counter header is all right and and +* This function returns zero if the erase counter header is all right and * a negative error code if not or if an error occurred. */ static int self_check_peb_ec_hdr (const struct ubi_device *ubi,int pnum)
drivers/mtd/ubi/ubi.h +3 -3
@@ -86,7 +86,7 @@ void ubi_err(const struct ubi_device *ubi, const char *fmt, ...);* Error codes returned by the I/O sub-system. * * UBI_IO_FF: the read region of flash contains only 0xFFs -* UBI_IO_FF_BITFLIPS: the same as %UBI_IO_FF, but also also there was a data +* UBI_IO_FF_BITFLIPS: the same as %UBI_IO_FF, but also there was a data * integrity error reported by the MTD driver * (uncorrectable ECC error in case of NAND) * UBI_IO_BAD_HDR: the EC or VID header is corrupted (bad magic or CRC)
@@ -281,7 +281,7 @@ struct ubi_eba_leb_desc {/** * struct ubi_volume - UBI volume description data structure. -* @dev: device object to make use of the the Linux device model +* @dev: device object to make use of the Linux device model * @cdev: character device object to create character device * @ubi: reference to the UBI device description object * @vol_id: volume ID
@@ -439,7 +439,7 @@ struct ubi_debug_info {/** * struct ubi_device - UBI device description structure -* @dev: UBI device object to use the the Linux device model +* @dev: UBI device object to use the Linux device model * @cdev: character device object to create character device * @ubi_num: UBI device number * @ubi_name: UBI device name
drivers/mtd/ubi/wl.c +3 -3
@@ -376,7 +376,7 @@ static struct ubi_wl_entry *find_mean_wl_entry(struct ubi_device *ubi,* refill_wl_user_pool(). * @ubi: UBI device description object * -* This function returns a a wear leveling entry in case of success and +* This function returns a wear leveling entry in case of success and * NULL in case of failure. */ static struct ubi_wl_entry *wl_get_wle (struct ubi_device *ubi)
@@ -429,7 +429,7 @@ static int prot_queue_del(struct ubi_device *ubi, int pnum)/** * sync_erase - synchronously erase a physical eraseblock. * @ubi: UBI device description object -* @e: the the physical eraseblock to erase +* @e: the physical eraseblock to erase * @torture: if the physical eraseblock has to be tortured * * This function returns zero in case of success and a negative error code in
@@ -1024,7 +1024,7 @@ static int ensure_wear_leveling(struct ubi_device *ubi, int nested)/* * If the ubi->scrub tree is not empty, scrubbing is needed, and the -* the WL worker has to be scheduled anyway. +* WL worker has to be scheduled anyway. */ if (!ubi->scrub.rb_node) {if (!ubi->used.rb_node || !ubi->free.rb_node)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 786/935 ubi: fastmap: Use the bitmap API to allocate bitmaps
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe JAILLET <[email protected]>
[ Upstream commit e7f35da21f6f8c6a8c7d262dd4e4bd32e3083f79 ]
Use bitmap_zalloc()/bitmap_free() instead of hand-writing them.
It is less verbose and it improves the semantic.
Stable-dep-of: 420477a84f1e ("UBI: Preserve torture flag when rescheduling failed erasures")
--- drivers/mtd/ubi/fastmap.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/mtd/ubi/fastmap.c +4 -6
@@ -20,8 +20,7 @@ static inline unsigned long *init_seen(struct ubi_device *ubi)if (!ubi_dbg_chk_fastmap (ubi))return NULL ; - ret =kcalloc (BITS_TO_LONGS (ubi->peb_count),sizeof (unsigned long ), -GFP_KERNEL ); + ret =bitmap_zalloc (ubi->peb_count,GFP_KERNEL );if (!ret)return ERR_PTR (-ENOMEM );
@@ -34,7 +33,7 @@ static inline unsigned long *init_seen(struct ubi_device *ubi)*/ static inline void free_seen (unsigned long *seen) { -kfree (seen); +bitmap_free (seen); }/**
@@ -1109,8 +1108,7 @@ int ubi_fastmap_init_checkmap(struct ubi_volume *vol, int leb_count)if (!ubi->fast_attach)return 0 ; - vol->checkmap =kcalloc (BITS_TO_LONGS (leb_count),sizeof (unsigned long ), -GFP_KERNEL ); + vol->checkmap =bitmap_zalloc (leb_count,GFP_KERNEL );if (!vol->checkmap)return -ENOMEM ;
@@ -1119,7 +1117,7 @@ int ubi_fastmap_init_checkmap(struct ubi_volume *vol, int leb_count)void ubi_fastmap_destroy_checkmap (struct ubi_volume *vol) { -kfree (vol->checkmap); +bitmap_free (vol->checkmap); }/**
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 787/935 ubi: fastmap: Fix missed ec updating after erasing old fastmap data block
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhihao Cheng <[email protected]>
[ Upstream commit 4d18b5a57b16c21cf868369ca555068722c32b2d ]
After running fsstress on ubifs for a long time, UBI(16384 blocks, fastmap takes 2 blocks) has an erase block with different erase counters displayed from two views:
Quoted 1 line
From ubiscan view: PEB 8031 has erase counter 31581
=========================================================
from to count min avg max
---------------------------------------------------------
0 .. 9: 0 0 0 0 10 .. 99: 0 0 0 0 100 .. 999: 16383 290 315 781 1000 .. 9999: 0 0 0 0 10000 .. 99999: 1 31581 31581 31581 100000 .. inf: 0 0 0 0
---------------------------------------------------------
Total : 16384 290 317 31581
Quoted 1 line
From
detailed_erase_block_infoview: PEB 8031 has erase counter 7
physical_block_number erase_count 8030 421 8031 7 # mem info is different from disk info 8032 434 8033 425 8034 431
Following process missed updating erase counter in wl_entry(in memory):ubi_update_fastmap
for (i = 1; i < new_fm->used_blocks; i++) // update fastmap data
if (!tmp_e)
if (old_fm && old_fm->e[i])
erase_block(ubi, old_fm->e[i]->pnum)
ret = ubi_io_sync_erase(ubi, pnum, 0)
ec = be64_to_cpu(ec_hdr->ec)
ec += ret
ec_hdr->ec = cpu_to_be64(ec)
ubi_io_write_ec_hdr(ubi, pnum, ec_hdr) // ec is updated on flash// ec is not updated in old_fm->e[i] (in memory)
Fix it by passing wl_enter into erase_block() and updating erase counter in erase_block().
Stable-dep-of: 420477a84f1e ("UBI: Preserve torture flag when rescheduling failed erasures")
--- drivers/mtd/ubi/fastmap.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
drivers/mtd/ubi/fastmap.c +15 -10
@@ -1393,11 +1393,12 @@ static int ubi_write_fastmap(struct ubi_device *ubi,/** * erase_block - Manually erase a PEB. * @ubi: UBI device object -* @pnum: PEB to be erased +* @e: the physical eraseblock to erase * -* Returns the new EC value on success, < 0 indicates an internal error. +* This function returns zero in case of success and a negative error code in +* case of failure. */ -static int erase_block (struct ubi_device *ubi,int pnum) +static int erase_block (struct ubi_device *ubi,struct ubi_wl_entry *e) {int ret;struct ubi_ec_hdr *ec_hdr;
@@ -1407,7 +1408,7 @@ static int erase_block(struct ubi_device *ubi, int pnum)if (!ec_hdr)return -ENOMEM ; - ret =ubi_io_read_ec_hdr (ubi, pnum, ec_hdr,0 ); + ret =ubi_io_read_ec_hdr (ubi, e->pnum, ec_hdr,0 );if (ret <0 ) goto out;else if (ret && ret !=UBI_IO_BITFLIPS ) {
@@ -1415,7 +1416,7 @@ static int erase_block(struct ubi_device *ubi, int pnum) goto out; } - ret =ubi_io_sync_erase (ubi, pnum,0 ); + ret =ubi_io_sync_erase (ubi, e->pnum,0 );if (ret <0 ) goto out;
@@ -1427,11 +1428,16 @@ static int erase_block(struct ubi_device *ubi, int pnum) } ec_hdr->ec =cpu_to_be64 (ec); - ret =ubi_io_write_ec_hdr (ubi, pnum, ec_hdr); + ret =ubi_io_write_ec_hdr (ubi, e->pnum, ec_hdr);if (ret <0 ) goto out; - ret = ec; + e->ec = ec; +spin_lock (&ubi->wl_lock); +if (e->ec > ubi->max_ec) + ubi->max_ec = e->ec; +spin_unlock (&ubi->wl_lock); + out:kfree (ec_hdr);return ret;
@@ -1577,7 +1583,7 @@ int ubi_update_fastmap(struct ubi_device *ubi)if (!tmp_e) {if (old_fm && old_fm->e[i]) { - ret =erase_block (ubi, old_fm->e[i]->pnum); + ret =erase_block (ubi, old_fm->e[i]);if (ret <0 ) {ubi_err (ubi,"could not erase old fastmap PEB" );
@@ -1629,7 +1635,7 @@ int ubi_update_fastmap(struct ubi_device *ubi)if (old_fm) {/* no fresh anchor PEB was found, reuse the old one */ if (!tmp_e) { - ret =erase_block (ubi, old_fm->e[0 ]->pnum); + ret =erase_block (ubi, old_fm->e[0 ]);if (ret <0 ) {ubi_err (ubi,"could not erase old anchor PEB" );
@@ -1641,7 +1647,6 @@ int ubi_update_fastmap(struct ubi_device *ubi) goto err; } new_fm->e[0 ] = old_fm->e[0 ]; - new_fm->e[0 ]->ec = ret; old_fm->e[0 ] =NULL ; }else {/* we've got a new anchor PEB, return the old one */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 788/935 ubi: fastmap: erase_block: Get erase counter from wl_entry rather than flash
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhihao Cheng <[email protected]>
[ Upstream commit 08a4267874164b2e9c8c50831acd466f47208acc ]
Just like sync_erase() does, getting erase counter from wl_entry is faster than reading from flash.
Stable-dep-of: 420477a84f1e ("UBI: Preserve torture flag when rescheduling failed erasures")
--- drivers/mtd/ubi/fastmap.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-)
drivers/mtd/ubi/fastmap.c +9 -18
@@ -1400,36 +1400,27 @@ static int ubi_write_fastmap(struct ubi_device *ubi,*/ static int erase_block (struct ubi_device *ubi,struct ubi_wl_entry *e) { -int ret; +int err;struct ubi_ec_hdr *ec_hdr; -long long ec; +long long ec = e->ec; ec_hdr =kzalloc (ubi->ec_hdr_alsize,GFP_KERNEL );if (!ec_hdr)return -ENOMEM ; - ret =ubi_io_read_ec_hdr (ubi, e->pnum, ec_hdr,0 ); -if (ret <0 ) - goto out; -else if (ret && ret !=UBI_IO_BITFLIPS ) { - ret = -EINVAL ; - goto out; - } - - ret =ubi_io_sync_erase (ubi, e->pnum,0 ); -if (ret <0 ) + err =ubi_io_sync_erase (ubi, e->pnum,0 ); +if (err <0 ) goto out; - ec =be64_to_cpu (ec_hdr->ec); - ec += ret; + ec += err;if (ec >UBI_MAX_ERASECOUNTER ) { - ret = -EINVAL ; + err = -EINVAL ; goto out; } ec_hdr->ec =cpu_to_be64 (ec); - ret =ubi_io_write_ec_hdr (ubi, e->pnum, ec_hdr); -if (ret <0 ) + err =ubi_io_write_ec_hdr (ubi, e->pnum, ec_hdr); +if (err <0 ) goto out; e->ec = ec;
@@ -1440,7 +1431,7 @@ static int erase_block(struct ubi_device *ubi, struct ubi_wl_entry *e) out:kfree (ec_hdr); -return ret; +return err; }/**
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 789/935 ubi: fastmap: Allocate memory with GFP_NOFS in ubi_update_fastmap
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhihao Cheng <[email protected]>
[ Upstream commit a033ab4fec5fd9194d1b6c0306efbdc75f70b142 ]
Function ubi_update_fastmap could be called in IO context, for example:
ubifs_writepage
do_writepage
ubifs_jnl_write_data
write_head
ubifs_wbuf_write_nolock
ubifs_leb_write
ubi_leb_write
ubi_eba_write_leb
try_write_vid_and_data
ubi_wl_get_peb
ubi_update_fastmap
erase_block
So it's better to allocate memory with GFP_NOFS mode, in case waiting page writeback(dead loop).
Stable-dep-of: 420477a84f1e ("UBI: Preserve torture flag when rescheduling failed erasures")
--- drivers/mtd/ubi/fastmap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/mtd/ubi/fastmap.c +5 -5
@@ -20,7 +20,7 @@ static inline unsigned long *init_seen(struct ubi_device *ubi)if (!ubi_dbg_chk_fastmap (ubi))return NULL ; - ret =bitmap_zalloc (ubi->peb_count,GFP_KERNEL ); + ret =bitmap_zalloc (ubi->peb_count,GFP_NOFS );if (!ret)return ERR_PTR (-ENOMEM );
@@ -106,7 +106,7 @@ static struct ubi_vid_io_buf *new_fm_vbuf(struct ubi_device *ubi, int vol_id)struct ubi_vid_io_buf *new;struct ubi_vid_hdr *vh; - new =ubi_alloc_vid_buf (ubi,GFP_KERNEL ); + new =ubi_alloc_vid_buf (ubi,GFP_NOFS );if (!new) goto out;
@@ -1404,7 +1404,7 @@ static int erase_block(struct ubi_device *ubi, struct ubi_wl_entry *e)struct ubi_ec_hdr *ec_hdr;long long ec = e->ec; - ec_hdr =kzalloc (ubi->ec_hdr_alsize,GFP_KERNEL ); + ec_hdr =kzalloc (ubi->ec_hdr_alsize,GFP_NOFS );if (!ec_hdr)return -ENOMEM ;
@@ -1460,7 +1460,7 @@ static int invalidate_fastmap(struct ubi_device *ubi) ubi->fm =NULL ; ret = -ENOMEM ; - fm =kzalloc (sizeof (*fm),GFP_KERNEL ); + fm =kzalloc (sizeof (*fm),GFP_NOFS );if (!fm) goto out;
@@ -1549,7 +1549,7 @@ int ubi_update_fastmap(struct ubi_device *ubi)return 0 ; } - new_fm =kzalloc (sizeof (*new_fm),GFP_KERNEL ); + new_fm =kzalloc (sizeof (*new_fm),GFP_NOFS );if (!new_fm) {up_write (&ubi->fm_eba_sem);up_write (&ubi->work_sem);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 790/935 ubi: Replace erase_block() with sync_erase()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhihao Cheng <[email protected]>
[ Upstream commit c19286d70aaa361cdb073a68a1f66232c359e2fd ]
Since erase_block() has same logic with sync_erase(), just replace it with sync_erase(), also rename 'sync_erase()' to 'ubi_sync_erase()'.
Stable-dep-of: 420477a84f1e ("UBI: Preserve torture flag when rescheduling failed erasures")
--- drivers/mtd/ubi/fastmap.c | 48 ++------------------------------------- drivers/mtd/ubi/ubi.h | 1 + drivers/mtd/ubi/wl.c | 9 ++++---- 3 files changed, 7 insertions(+), 51 deletions(-)
drivers/mtd/ubi/fastmap.c +2 -46
@@ -1390,50 +1390,6 @@ static int ubi_write_fastmap(struct ubi_device *ubi,return ret; } -/** -* erase_block - Manually erase a PEB. -* @ubi: UBI device object -* @e: the physical eraseblock to erase -* -* This function returns zero in case of success and a negative error code in -* case of failure. -*/ -static int erase_block (struct ubi_device *ubi,struct ubi_wl_entry *e) -{ -int err; -struct ubi_ec_hdr *ec_hdr; -long long ec = e->ec; - - ec_hdr =kzalloc (ubi->ec_hdr_alsize,GFP_NOFS ); -if (!ec_hdr) -return -ENOMEM ; - - err =ubi_io_sync_erase (ubi, e->pnum,0 ); -if (err <0 ) - goto out; - - ec += err; -if (ec >UBI_MAX_ERASECOUNTER ) { - err = -EINVAL ; - goto out; - } - - ec_hdr->ec =cpu_to_be64 (ec); - err =ubi_io_write_ec_hdr (ubi, e->pnum, ec_hdr); -if (err <0 ) - goto out; - - e->ec = ec; -spin_lock (&ubi->wl_lock); -if (e->ec > ubi->max_ec) - ubi->max_ec = e->ec; -spin_unlock (&ubi->wl_lock); - -out: -kfree (ec_hdr); -return err; -} -/** * invalidate_fastmap - destroys a fastmap. * @ubi: UBI device object
@@ -1574,7 +1530,7 @@ int ubi_update_fastmap(struct ubi_device *ubi)if (!tmp_e) {if (old_fm && old_fm->e[i]) { - ret =erase_block (ubi, old_fm->e[i]); + ret =ubi_sync_erase (ubi, old_fm->e[i],0 );if (ret <0 ) {ubi_err (ubi,"could not erase old fastmap PEB" );
@@ -1626,7 +1582,7 @@ int ubi_update_fastmap(struct ubi_device *ubi)if (old_fm) {/* no fresh anchor PEB was found, reuse the old one */ if (!tmp_e) { - ret =erase_block (ubi, old_fm->e[0 ]); + ret =ubi_sync_erase (ubi, old_fm->e[0 ],0 );if (ret <0 ) {ubi_err (ubi,"could not erase old anchor PEB" );
drivers/mtd/ubi/ubi.h +1 -0
@@ -902,6 +902,7 @@ int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap, struct ubi_attach_info *ai_scan);/* wl.c */ +int ubi_sync_erase (struct ubi_device *ubi,struct ubi_wl_entry *e,int torture);int ubi_wl_get_peb (struct ubi_device *ubi);int ubi_wl_put_peb (struct ubi_device *ubi,int vol_id,int lnum,int pnum,int torture);
drivers/mtd/ubi/wl.c +4 -5
@@ -427,7 +427,7 @@ static int prot_queue_del(struct ubi_device *ubi, int pnum) }/** -* sync_erase - synchronously erase a physical eraseblock. +* ubi_sync_erase - synchronously erase a physical eraseblock. * @ubi: UBI device description object * @e: the physical eraseblock to erase * @torture: if the physical eraseblock has to be tortured
@@ -435,8 +435,7 @@ static int prot_queue_del(struct ubi_device *ubi, int pnum)* This function returns zero in case of success and a negative error code in * case of failure. */ -static int sync_erase (struct ubi_device *ubi,struct ubi_wl_entry *e, -int torture) +int ubi_sync_erase (struct ubi_device *ubi,struct ubi_wl_entry *e,int torture) {int err;struct ubi_ec_hdr *ec_hdr;
@@ -1091,7 +1090,7 @@ static int __erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk)dbg_wl ("erase PEB %d EC %d LEB %d:%d" , pnum, e->ec, wl_wrk->vol_id, wl_wrk->lnum); - err =sync_erase (ubi, e, wl_wrk->torture); + err =ubi_sync_erase (ubi, e, wl_wrk->torture);if (!err) {spin_lock (&ubi->wl_lock);
@@ -1746,7 +1745,7 @@ static int erase_aeb(struct ubi_device *ubi, struct ubi_ainf_peb *aeb, bool sync ubi->lookuptbl[e->pnum] = e;if (sync) { - err =sync_erase (ubi, e, false); + err =ubi_sync_erase (ubi, e, false);if (err) goto out_free;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 791/935 UBI: Preserve torture flag when rescheduling failed erasures
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhihao Cheng <[email protected]>
[ Upstream commit 420477a84f1e52babfe60a43dbdd0988ed956845 ]
In __erase_worker(), when ubi_sync_erase() returns -EINTR, -ENOMEM, -EAGAIN, or -EBUSY, the physical eraseblock is rescheduled for erasure via schedule_erase() with the torture flag hardcoded to 0. This unconditionally drops the torture request.
If the error occurred before torture_peb() completed (e.g., -ENOMEM from the ec_hdr allocation in ubi_sync_erase(), errors from self_check_not_bad()/nor_erase_prepare() in ubi_io_sync_erase(), or torture_peb() failing mid-test because its internal do_sync_erase()/ ubi_io_read()/ubi_io_write() returned one of the above error codes), the torture test was never finished. Such a PEB may reach the free pool without being tortured, defeating the purpose of the torture test for detecting marginally-bad eraseblocks.
If the error occurred after torture_peb() succeeded (the final do_sync_erase() in ubi_io_sync_erase() or ubi_io_write_ec_hdr() in ubi_sync_erase() failed), the torture has already been done and need not be repeated.
Pass the torture flag by pointer to ubi_sync_erase() and ubi_io_sync_erase(), and clear it to zero once torture_peb() has completed successfully. __erase_worker() then forwards the updated wl_wrk->torture to schedule_erase(): torture already done is dropped, torture not completed is preserved across the reschedule.
--- drivers/mtd/ubi/attach.c | 4 ++-- drivers/mtd/ubi/fastmap.c | 6 +++--- drivers/mtd/ubi/io.c | 11 +++++++---- drivers/mtd/ubi/ubi.h | 4 ++-- drivers/mtd/ubi/wl.c | 15 +++++++++------ 5 files changed, 23 insertions(+), 17 deletions(-)
drivers/mtd/ubi/attach.c +2 -2
@@ -771,7 +771,7 @@ void ubi_remove_av(struct ubi_attach_info *ai, struct ubi_ainf_volume *av)static int early_erase_peb (struct ubi_device *ubi,const struct ubi_attach_info *ai,int pnum,int ec) { -int err; +int err, torture =0 ;struct ubi_ec_hdr *ec_hdr;if ((long long )ec >=UBI_MAX_ERASECOUNTER ) {
@@ -790,7 +790,7 @@ static int early_erase_peb(struct ubi_device *ubi, ec_hdr->ec =cpu_to_be64 (ec); - err =ubi_io_sync_erase (ubi, pnum,0 ); + err =ubi_io_sync_erase (ubi, pnum, &torture);if (err <0 ) goto out_free;
drivers/mtd/ubi/fastmap.c +3 -3
@@ -1488,7 +1488,7 @@ static void return_fm_pebs(struct ubi_device *ubi,*/ int ubi_update_fastmap (struct ubi_device *ubi) { -int ret, i, j; +int ret, i, j, torture =0 ;struct ubi_fastmap_layout *new_fm, *old_fm;struct ubi_wl_entry *tmp_e;
@@ -1530,7 +1530,7 @@ int ubi_update_fastmap(struct ubi_device *ubi)if (!tmp_e) {if (old_fm && old_fm->e[i]) { - ret =ubi_sync_erase (ubi, old_fm->e[i],0 ); + ret =ubi_sync_erase (ubi, old_fm->e[i], &torture);if (ret <0 ) {ubi_err (ubi,"could not erase old fastmap PEB" );
@@ -1582,7 +1582,7 @@ int ubi_update_fastmap(struct ubi_device *ubi)if (old_fm) {/* no fresh anchor PEB was found, reuse the old one */ if (!tmp_e) { - ret =ubi_sync_erase (ubi, old_fm->e[0 ],0 ); + ret =ubi_sync_erase (ubi, old_fm->e[0 ], &torture);if (ret <0 ) {ubi_err (ubi,"could not erase old anchor PEB" );
drivers/mtd/ubi/io.c +7 -4
@@ -507,8 +507,10 @@ static int nor_erase_prepare(struct ubi_device *ubi, int pnum)/** * ubi_io_sync_erase - synchronously erase a physical eraseblock. * @ubi: UBI device description object -* @pnum: physical eraseblock number to erase -* @torture: if this physical eraseblock has to be tortured +* @pnum: the physical eraseblock number to erase +* @torture: if this physical eraseblock has to be tortured; cleared to zero +* once the torture test has completed successfully so that a retry +* of the erase does not torture the physical eraseblock again * * This function synchronously erases physical eraseblock @pnum. If @torture * flag is not zero, the physical eraseblock is checked by means of writing
@@ -520,7 +522,7 @@ static int nor_erase_prepare(struct ubi_device *ubi, int pnum)* codes in case of other errors. Note, %-EIO means that the physical * eraseblock is bad. */ -int ubi_io_sync_erase (struct ubi_device *ubi,int pnum,int torture) +int ubi_io_sync_erase (struct ubi_device *ubi,int pnum,int *torture) {int err, ret =0 ;
@@ -548,10 +550,11 @@ int ubi_io_sync_erase(struct ubi_device *ubi, int pnum, int torture)return err; } -if (torture) { +if (*torture) { ret =torture_peb (ubi, pnum);if (ret <0 )return ret; + *torture =0 ; } err =do_sync_erase (ubi, pnum);
drivers/mtd/ubi/ubi.h +2 -2
@@ -902,7 +902,7 @@ int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap, struct ubi_attach_info *ai_scan);/* wl.c */ -int ubi_sync_erase (struct ubi_device *ubi,struct ubi_wl_entry *e,int torture); +int ubi_sync_erase (struct ubi_device *ubi,struct ubi_wl_entry *e,int *torture);int ubi_wl_get_peb (struct ubi_device *ubi);int ubi_wl_put_peb (struct ubi_device *ubi,int vol_id,int lnum,int pnum,int torture);
@@ -924,7 +924,7 @@ int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset, int len);int ubi_io_write (struct ubi_device *ubi,const void *buf,int pnum,int offset,int len); -int ubi_io_sync_erase (struct ubi_device *ubi,int pnum,int torture); +int ubi_io_sync_erase (struct ubi_device *ubi,int pnum,int *torture);int ubi_io_is_bad (const struct ubi_device *ubi,int pnum);int ubi_io_mark_bad (const struct ubi_device *ubi,int pnum); int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
drivers/mtd/ubi/wl.c +9 -6
@@ -430,12 +430,14 @@ static int prot_queue_del(struct ubi_device *ubi, int pnum)* ubi_sync_erase - synchronously erase a physical eraseblock. * @ubi: UBI device description object * @e: the physical eraseblock to erase -* @torture: if the physical eraseblock has to be tortured +* @torture: if the physical eraseblock has to be tortured; cleared to zero +* once the torture test has completed successfully so that a retry +* of the erase does not torture the physical eraseblock again * * This function returns zero in case of success and a negative error code in * case of failure. */ -int ubi_sync_erase (struct ubi_device *ubi,struct ubi_wl_entry *e,int torture) +int ubi_sync_erase (struct ubi_device *ubi,struct ubi_wl_entry *e,int *torture) {int err;struct ubi_ec_hdr *ec_hdr;
@@ -1090,7 +1092,7 @@ static int __erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk)dbg_wl ("erase PEB %d EC %d LEB %d:%d" , pnum, e->ec, wl_wrk->vol_id, wl_wrk->lnum); - err =ubi_sync_erase (ubi, e, wl_wrk->torture); + err =ubi_sync_erase (ubi, e, &wl_wrk->torture);if (!err) {spin_lock (&ubi->wl_lock);
@@ -1127,7 +1129,8 @@ static int __erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk)int err1;/* Re-schedule the LEB for erasure */ - err1 =schedule_erase (ubi, e, vol_id, lnum,0 , true); + err1 =schedule_erase (ubi, e, vol_id, lnum, wl_wrk->torture, + true);if (err1) {spin_lock (&ubi->wl_lock);wl_entry_destroy (ubi, e);
@@ -1734,7 +1737,7 @@ static void shutdown_work(struct ubi_device *ubi)static int erase_aeb (struct ubi_device *ubi,struct ubi_ainf_peb *aeb,bool sync) {struct ubi_wl_entry *e; -int err; +int err, torture =0 ; e =kmem_cache_alloc (ubi_wl_entry_slab,GFP_KERNEL );if (!e)
@@ -1745,7 +1748,7 @@ static int erase_aeb(struct ubi_device *ubi, struct ubi_ainf_peb *aeb, bool sync ubi->lookuptbl[e->pnum] = e;if (sync) { - err =ubi_sync_erase (ubi, e, false); + err =ubi_sync_erase (ubi, e, &torture);if (err) goto out_free;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 792/935 UBI: fastmap: Pass to_be_tortured when reusing old fastmap PEBs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhihao Cheng <[email protected]>
[ Upstream commit be04fce9945aac2a843f5d16725391eb80d948ef ]
In ubi_update_fastmap(), when no fresh PEB is available to replace an old fastmap PEB, the old PEB is reused by erasing it synchronously via ubi_sync_erase() with the torture flag hardcoded to zero.
However, old_fm->to_be_tortured[] may be non-zero: it is set during fastmap scanning when ubi_io_read_data()/ubi_io_read_ec_hdr() reports UBI_IO_BITFLIPS, meaning the PEB showed signs of bit decay and should be tortured to verify it is still reliable.
When the old PEB is instead returned to the WL sub-system via ubi_wl_put_fm_peb(), the to_be_tortured flag is honored. The synchronous reuse path is inconsistent: it silently skips the torture test for PEBs that exhibited bit-flips.
Fix it by passing &old_fm->to_be_tortured[i] to ubi_sync_erase().
--- drivers/mtd/ubi/fastmap.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/mtd/ubi/fastmap.c +5 -3
@@ -1488,7 +1488,7 @@ static void return_fm_pebs(struct ubi_device *ubi,*/ int ubi_update_fastmap (struct ubi_device *ubi) { -int ret, i, j, torture =0 ; +int ret, i, j;struct ubi_fastmap_layout *new_fm, *old_fm;struct ubi_wl_entry *tmp_e;
@@ -1530,7 +1530,8 @@ int ubi_update_fastmap(struct ubi_device *ubi)if (!tmp_e) {if (old_fm && old_fm->e[i]) { - ret =ubi_sync_erase (ubi, old_fm->e[i], &torture); + ret =ubi_sync_erase (ubi, old_fm->e[i], + &old_fm->to_be_tortured[i]);if (ret <0 ) {ubi_err (ubi,"could not erase old fastmap PEB" );
@@ -1582,7 +1583,8 @@ int ubi_update_fastmap(struct ubi_device *ubi)if (old_fm) {/* no fresh anchor PEB was found, reuse the old one */ if (!tmp_e) { - ret =ubi_sync_erase (ubi, old_fm->e[0 ], &torture); + ret =ubi_sync_erase (ubi, old_fm->e[0 ], + &old_fm->to_be_tortured[0 ]);if (ret <0 ) {ubi_err (ubi,"could not erase old anchor PEB" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 793/935 ubi: fastmap: Add fastmap control support for UBI_IOCATT ioctl
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhihao Cheng <[email protected]>
[ Upstream commit 669d204469c46e91d99da24914130f78277a71d3 ]
[1] suggests that fastmap is suitable for large flash devices. Module parameter 'fm_autoconvert' is a coarse grained switch to enable all ubi devices to generate fastmap, which may turn on fastmap even for small flash devices.
This patch imports a new field 'disable_fm' in struct 'ubi_attach_req' to support following situations by ioctl 'UBI_IOCATT'.
[old functions]
A. Disable 'fm_autoconvert': Disbable fastmap for all ubi devices B. Enable 'fm_autoconvert': Enable fastmap for all ubi devices [new function]
C. Enable 'fm_autoconvert', set 'disable_fm' for given device: Don't
create new fastmap and do full scan (existed fastmap will be destroyed) for the given ubi device.
A simple test case in [2].
[1] http://www.linux-mtd.infradead.org/doc/ubi.html#L_fastmap
[2] https://bugzilla.kernel.org/show_bug.cgi?id=216278
Stable-dep-of: 5b0a6b554e12 ("ubi: Fix rollback for explicit UBI device numbers")
--- drivers/mtd/ubi/build.c | 14 ++++++++++---- drivers/mtd/ubi/cdev.c | 2 +- drivers/mtd/ubi/ubi.h | 3 ++- include/uapi/mtd/ubi-user.h | 8 +++++++- 4 files changed, 20 insertions(+), 7 deletions(-)
drivers/mtd/ubi/build.c +10 -4
@@ -823,6 +823,7 @@ static int autoresize(struct ubi_device *ubi, int vol_id)* @ubi_num: number to assign to the new UBI device * @vid_hdr_offset: VID header offset * @max_beb_per1024: maximum expected number of bad PEB per 1024 PEBs +* @disable_fm: whether disable fastmap * * This function attaches MTD device @mtd_dev to UBI and assign @ubi_num number * to the newly created UBI device, unless @ubi_num is %UBI_DEV_NUM_AUTO, in
@@ -830,11 +831,15 @@ static int autoresize(struct ubi_device *ubi, int vol_id)* automatically. Returns the new UBI device number in case of success and a * negative error code in case of failure. * +* If @disable_fm is true, ubi doesn't create new fastmap even the module param +* 'fm_autoconvert' is set, and existed old fastmap will be destroyed after +* doing full scanning. +* * Note, the invocations of this function has to be serialized by the * @ubi_devices_mutex. */ int ubi_attach_mtd_dev (struct mtd_info *mtd,int ubi_num, -int vid_hdr_offset,int max_beb_per1024) +int vid_hdr_offset,int max_beb_per1024,bool disable_fm) {struct ubi_device *ubi;int i, err;
@@ -944,7 +949,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, UBI_FM_MIN_POOL_SIZE); ubi->fm_wl_pool.max_size = ubi->fm_pool.max_size /2 ; - ubi->fm_disabled = !fm_autoconvert; + ubi->fm_disabled = (!fm_autoconvert || disable_fm) ?1 :0 ;if (fm_debug)ubi_enable_dbg_chk_fastmap (ubi);
@@ -985,7 +990,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,if (!ubi->fm_buf) goto out_free;#endif - err =ubi_attach (ubi,0 ); + err =ubi_attach (ubi, disable_fm ?1 :0 );if (err) {ubi_err (ubi,"failed to attach mtd%d, error %d" , mtd->index, err);
@@ -1265,7 +1270,8 @@ static int __init ubi_init(void)mutex_lock (&ubi_devices_mutex); err =ubi_attach_mtd_dev (mtd, p->ubi_num, - p->vid_hdr_offs, p->max_beb_per1024); + p->vid_hdr_offs, p->max_beb_per1024, + false);mutex_unlock (&ubi_devices_mutex);if (err <0 ) { pr_err("UBI error: cannot attach mtd%d\n",
drivers/mtd/ubi/cdev.c +1 -1
@@ -1041,7 +1041,7 @@ static long ctrl_cdev_ioctl(struct file *file, unsigned int cmd,*/ mutex_lock (&ubi_devices_mutex); err =ubi_attach_mtd_dev (mtd, req.ubi_num, req.vid_hdr_offset, - req.max_beb_per1024); + req.max_beb_per1024, !!req.disable_fm);mutex_unlock (&ubi_devices_mutex);if (err <0 )put_mtd_device (mtd);
drivers/mtd/ubi/ubi.h +2 -1
@@ -938,7 +938,8 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum,/* build.c */ int ubi_attach_mtd_dev (struct mtd_info *mtd,int ubi_num, -int vid_hdr_offset,int max_beb_per1024); +int vid_hdr_offset,int max_beb_per1024, +bool disable_fm);int ubi_detach_mtd_dev (int ubi_num,int anyway);struct ubi_device *ubi_get_device (int ubi_num);void ubi_put_device (struct ubi_device *ubi);
include/uapi/mtd/ubi-user.h +7 -1
@@ -247,6 +247,7 @@ enum {* @vid_hdr_offset: VID header offset (use defaults if %0) * @max_beb_per1024: maximum expected number of bad PEB per 1024 PEBs * @padding: reserved for future, not used, has to be zeroed +* @disable_fm: whether disable fastmap * * This data structure is used to specify MTD device UBI has to attach and the * parameters it has to use. The number which should be assigned to the new UBI
@@ -281,13 +282,18 @@ enum {* eraseblocks for new bad eraseblocks, but attempts to use available * eraseblocks (if any). The accepted range is 0-768. If 0 is given, the * default kernel value of %CONFIG_MTD_UBI_BEB_LIMIT will be used. +* +* If @disable_fm is not zero, ubi doesn't create new fastmap even the module +* param 'fm_autoconvert' is set, and existed old fastmap will be destroyed +* after doing full scanning. */ struct ubi_attach_req {__s32 ubi_num;__s32 mtd_num;__s32 vid_hdr_offset;__s16 max_beb_per1024; -__s8 padding[10 ]; +__s8 disable_fm; +__s8 padding[9 ]; };/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 794/935 ubi: fastmap: Add fastmap control support for module parameter
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: ZhaoLong Wang <[email protected]>
[ Upstream commit 7af73882dd1cea5d32ac0cc9eda263635295de50 ]
The UBI driver can use the IOCTL to disable the fastmap after the mainline 669d204469c4 ("ubi: fastmap: Add fastmap control support for 'UBI_IOCATT' ioctl"). To destroy the fastmap on a old image, we need to reattach the device in user space.
However, if the UBI driver build in kernel and the UBI volume is the root partition, the UBI device cannot be reattached in user space. To disable fastmap in this case, the UBI must provide the kernel cmdline parameters to disable fastmap during attach.
This patch add 'enable_fm' as 5th module init parameter of mtd=xx to control fastmap enable or not. When the value is 0, fastmap will not create and existed fastmap will destroyed for the given ubi device. Default value is 0.
To enable or disable fastmap during module loading, fm_autoconvert must be set to non-zero.
+-----------------+---------------+---------------------------+ | \ | enable_fm=0 | enable_fm=1 | +-----------------+---------------+---------------------------+ |fm_autoconvert=Y | disable fm | enable fm | +---------------------------------+---------------------------+ |fm_autoconvert=N | disable fm | Enable fastmap if fastmap | | | | exists on the old image | +-------------------------------------------------------------+
Example:
# - Attach mtd1 to ubi1, disable fastmap, mtd2 to ubi2, enable
fastmap.
# modprobe ubi mtd=1,0,0,1,0 mtd=2,0,0,2,1 fm_autoconvert=1
# - If 5th parameter is not specified, the value is 0, fastmap is
disable
# modprobe ubi mtd=1 fm_autoconvert=1
Stable-dep-of: 5b0a6b554e12 ("ubi: Fix rollback for explicit UBI device numbers")
--- drivers/mtd/ubi/build.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
drivers/mtd/ubi/build.c +20 -4
@@ -35,7 +35,7 @@#define MTD_PARAM_LEN_MAX 64/* Maximum number of comma-separated items in the 'mtd=' parameter */ -#define MTD_PARAM_MAX_COUNT 4 +#define MTD_PARAM_MAX_COUNT 5/* Maximum value for the number of bad PEBs per 1024 PEBs */ #define MAX_MTD_UBI_BEB_LIMIT 768
@@ -53,12 +53,14 @@* @ubi_num: UBI number * @vid_hdr_offs: VID header offset * @max_beb_per1024: maximum expected number of bad PEBs per 1024 PEBs +* @enable_fm: enable fastmap when value is non-zero */ struct mtd_dev_param {char name[MTD_PARAM_LEN_MAX ];int ubi_num;int vid_hdr_offs;int max_beb_per1024; +int enable_fm; };/* Numbers of elements set in the @mtd_dev_param array */
@@ -1271,7 +1273,7 @@ static int __init ubi_init(void)mutex_lock (&ubi_devices_mutex); err =ubi_attach_mtd_dev (mtd, p->ubi_num, p->vid_hdr_offs, p->max_beb_per1024, - false); + p->enable_fm ==0 ? true : false);mutex_unlock (&ubi_devices_mutex);if (err <0 ) { pr_err("UBI error: cannot attach mtd%d\n",
@@ -1450,7 +1452,7 @@ static int ubi_mtd_param_parse(const char *val, const struct kernel_param *kp)int err =kstrtoint (token,10 , &p->max_beb_per1024);if (err) { -pr_err ("UBI error: bad value for max_beb_per1024 parameter: %s" , +pr_err ("UBI error: bad value for max_beb_per1024 parameter: %s\n" , token);return -EINVAL ; }
@@ -1461,13 +1463,25 @@ static int ubi_mtd_param_parse(const char *val, const struct kernel_param *kp)int err =kstrtoint (token,10 , &p->ubi_num);if (err) { -pr_err ("UBI error: bad value for ubi_num parameter: %s" , +pr_err ("UBI error: bad value for ubi_num parameter: %s\n" , token);return -EINVAL ; } }else p->ubi_num =UBI_DEV_NUM_AUTO ; + token = tokens[4 ]; +if (token) { +int err =kstrtoint (token,10 , &p->enable_fm); + +if (err) { +pr_err ("UBI error: bad value for enable_fm parameter: %s\n" , + token); +return -EINVAL ; + } + }else + p->enable_fm =0 ; + mtd_devs +=1 ;return 0 ; }
@@ -1480,11 +1494,13 @@ MODULE_PARM_DESC(mtd, "MTD devices to attach. Parameter format: mtd=<name|num|pa"Optional \"max_beb_per1024\" parameter specifies the maximum expected bad eraseblock per 1024 eraseblocks. (default value (" __stringify(CONFIG_MTD_UBI_BEB_LIMIT) ") if 0)\n""Optional \"ubi_num\" parameter specifies UBI device number which have to be assigned to the newly created UBI device (assigned automatically by default)\n" +"Optional \"enable_fm\" parameter determines whether to enable fastmap during attach. If the value is non-zero, fastmap is enabled. Default value is 0.\n" "\n" "Example 1: mtd=/dev/mtd0 - attach MTD device /dev/mtd0.\n" "Example 2: mtd=content,1984 mtd=4 - attach MTD device with name \"content\" using VID header offset 1984, and MTD device number 4 with default VID header offset.\n" "Example 3: mtd=/dev/mtd1,0,25 - attach MTD device /dev/mtd1 using default VID header offset and reserve 25*nand_size_in_blocks/1024 erase blocks for bad block handling.\n" "Example 4: mtd=/dev/mtd1,0,0,5 - attach MTD device /dev/mtd1 to UBI 5 and using default values for the other fields.\n" +"example 5: mtd=1,0,0,5 mtd=2,0,0,6,1 - attach MTD device /dev/mtd1 to UBI 5 and disable fastmap; attach MTD device /dev/mtd2 to UBI 6 and enable fastmap.(only works when fastmap is enabled and fm_autoconvert=Y).\n" "\t(e.g. if the NAND *chipset* has 4096 PEB, 100 will be reserved for this UBI device).");#ifdef CONFIG_MTD_UBI_FASTMAP module_param (fm_autoconvert, bool,0644 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 795/935 ubi: Simplify bool conversion
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Li <[email protected]>
[ Upstream commit ef5031137b90c5338792f7073ba3bf38d14c8cf1 ]
./drivers/mtd/ubi/build.c:1261:33-38: WARNING: conversion to bool not needed here
Stable-dep-of: 5b0a6b554e12 ("ubi: Fix rollback for explicit UBI device numbers")
--- drivers/mtd/ubi/build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/ubi/build.c +1 -1
@@ -1273,7 +1273,7 @@ static int __init ubi_init(void)mutex_lock (&ubi_devices_mutex); err =ubi_attach_mtd_dev (mtd, p->ubi_num, p->vid_hdr_offs, p->max_beb_per1024, - p->enable_fm ==0 ? true : false); + p->enable_fm ==0 );mutex_unlock (&ubi_devices_mutex);if (err <0 ) { pr_err("UBI error: cannot attach mtd%d\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 796/935 ubi: fastmap: Wait until there are enough free PEBs before filling pools
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhihao Cheng <[email protected]>
[ Upstream commit a2ea69dac674df0fba59c66146a21145108a85ed ]
Wait until there are enough free PEBs before filling pool/wl_pool, sometimes erase_worker is not scheduled in time, which causes two situations:
A. There are few PEBs filled in pool, which makes ubi_update_fastmap
is frequently called and leads first 64 PEBs are erased more times than other PEBs. So waiting free PEBs before filling pool reduces fastmap updating frequency and prolongs flash service life.
B. In situation that space is nearly running out, ubi_refill_pools()
cannot make sure pool and wl_pool are filled with free PEBs, caused by the delay of erase_worker. After this patch applied, there must exist free PEBs in pool after one call of ubi_update_fastmap.
Besides, this patch is a preparetion for fixing large erase counter in fastmap data block and fixing lapsed wear leveling for first 64 PEBs.
Stable-dep-of: 5b0a6b554e12 ("ubi: Fix rollback for explicit UBI device numbers")
--- drivers/mtd/ubi/eba.c | 3 -- drivers/mtd/ubi/fastmap-wl.c | 53 ++++++++++++++++++++++++++++++++++-- drivers/mtd/ubi/fastmap.c | 6 +--- drivers/mtd/ubi/ubi.h | 5 +++- drivers/mtd/ubi/wl.c | 14 +++++++--- 5 files changed, 65 insertions(+), 16 deletions(-)
drivers/mtd/ubi/eba.c +0 -3
@@ -33,9 +33,6 @@#include <linux/err.h> #include "ubi.h" -/* Number of physical eraseblocks reserved for atomic LEB change operation */ -#define EBA_RESERVED_PEBS 1 -/** * struct ubi_eba_entry - structure encoding a single LEB -> PEB association * @pnum: the physical eraseblock number attached to the LEB
drivers/mtd/ubi/fastmap-wl.c +50 -3
79 lines not on this page · raw message
drivers/mtd/ubi/fastmap.c +1 -5
@@ -1492,11 +1492,7 @@ int ubi_update_fastmap(struct ubi_device *ubi)struct ubi_fastmap_layout *new_fm, *old_fm;struct ubi_wl_entry *tmp_e; -down_write (&ubi->fm_protect); -down_write (&ubi->work_sem); -down_write (&ubi->fm_eba_sem); - -ubi_refill_pools (ubi); +ubi_refill_pools_and_lock (ubi);if (ubi->ro_mode || ubi->fm_disabled) {up_write (&ubi->fm_eba_sem);
drivers/mtd/ubi/ubi.h +4 -1
@@ -82,6 +82,9 @@ void ubi_err(const struct ubi_device *ubi, const char *fmt, ...);#define UBI_DFS_DIR_NAME "ubi%d"#define UBI_DFS_DIR_LEN (3 + 2 + 1) +/* Number of physical eraseblocks reserved for atomic LEB change operation */ +#define EBA_RESERVED_PEBS 1 +/* * Error codes returned by the I/O sub-system. *
@@ -915,7 +918,7 @@ struct ubi_wl_entry *ubi_wl_get_fm_peb(struct ubi_device *ubi, int anchor);int ubi_wl_put_fm_peb (struct ubi_device *ubi,struct ubi_wl_entry *used_e,int lnum,int torture);int ubi_is_erase_work (struct ubi_work *wrk); -void ubi_refill_pools (struct ubi_device *ubi); +void ubi_refill_pools_and_lock (struct ubi_device *ubi);int ubi_ensure_anchor_pebs (struct ubi_device *ubi);int ubi_bitflip_check (struct ubi_device *ubi,int pnum,int force_scrub);
drivers/mtd/ubi/wl.c +10 -4
@@ -181,11 +181,13 @@ static void wl_entry_destroy(struct ubi_device *ubi, struct ubi_wl_entry *e)/** * do_work - do one pending work. * @ubi: UBI device description object +* @executed: whether there is one work is executed * * This function returns zero in case of success and a negative error code in -* case of failure. +* case of failure. If @executed is not NULL and there is one work executed, +* @executed is set as %1, otherwise @executed is set as %0. */ -static int do_work (struct ubi_device *ubi) +static int do_work (struct ubi_device *ubi,int *executed) {int err;struct ubi_work *wrk;
@@ -203,9 +205,13 @@ static int do_work(struct ubi_device *ubi)if (list_empty (&ubi->works)) {spin_unlock (&ubi->wl_lock);up_read (&ubi->work_sem); +if (executed) + *executed =0 ;return 0 ; } +if (executed) + *executed =1 ; wrk = list_entry(ubi->works.next, struct ubi_work, list);list_del (&wrk->list); ubi->works_count -=1 ;
@@ -1685,7 +1691,7 @@ int ubi_thread(void *u) }spin_unlock (&ubi->wl_lock); - err =do_work (ubi); + err =do_work (ubi,NULL );if (err) {ubi_err (ubi,"%s: work failed with error code %d" , ubi->bgt_name, err);
@@ -2096,7 +2102,7 @@ static int produce_free_peb(struct ubi_device *ubi)spin_unlock (&ubi->wl_lock);dbg_wl ("do one work synchronously" ); - err =do_work (ubi); + err =do_work (ubi,NULL );spin_lock (&ubi->wl_lock);if (err)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 797/935 ubi: fastmap: Fix lapsed wear leveling for first 64 PEBs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhihao Cheng <[email protected]>
[ Upstream commit 90e0be56144b064be1a816cbdd184d2a8be7061b ]
The anchor PEB must be picked from first 64 PEBs, these PEBs could have large erase counter greater than other PEBs especially when free space is nearly running out.
The ubi_update_fastmap will be called as long as pool/wl_pool is empty, old anchor PEB is erased when updating fastmap. Given an UBI device with N PEBs, free PEBs is nearly running out and pool will be filled with 1 PEB every time ubi_update_fastmap invoked. So t=N/POOL_SIZE[1]/64 means that in worst case the erase counter of first 64 PEBs is t times greater than other PEBs in theory.
After running fsstress for 24h, the erase counter statistics for two UBI devices shown as follow(CONFIG_MTD_UBI_WL_THRESHOLD=128):
Device A(1024 PEBs, pool=50, wl_pool=25):
=========================================================
from to count min avg max
---------------------------------------------------------
0 .. 9: 0 0 0 0 10 .. 99: 0 0 0 0 100 .. 999: 0 0 0 0 1000 .. 9999: 0 0 0 0 10000 .. 99999: 960 29224 29282 29362 100000 .. inf: 64 117897 117934 117940
---------------------------------------------------------
Total : 1024 29224 34822 117940
Device B(8192 PEBs, pool=256, wl_pool=128):
=========================================================
from to count min avg max
---------------------------------------------------------
0 .. 9: 0 0 0 0 10 .. 99: 0 0 0 0 100 .. 999: 0 0 0 0 1000 .. 9999: 8128 2253 2321 2387 10000 .. 99999: 64 35387 35387 35388 100000 .. inf: 0 0 0 0
---------------------------------------------------------
Total : 8192 2253 2579 35388
The key point is reducing fastmap updating frequency by enlarging POOL_SIZE, so let UBI reserve ubi->fm_pool.max_size PEBs during attaching. Then POOL_SIZE will become ubi->fm_pool.max_size/2 even in free space running out case.
Given an UBI device with 8192 PEBs(16384\8192\4096 is common large-capacity flash), t=8192/128/64=1. The fastmap updating will happen in either wl_pool or pool is empty, so setting fm_pool_rsv_cnt as ubi->fm_pool.max_size can fill wl_pool in full state.
After pool reservation, running fsstress for 24h:
Device A(1024 PEBs, pool=50, wl_pool=25):
=========================================================
from to count min avg max
---------------------------------------------------------
0 .. 9: 0 0 0 0 10 .. 99: 0 0 0 0 100 .. 999: 0 0 0 0 1000 .. 9999: 0 0 0 0 10000 .. 99999: 1024 33801 33997 34056 100000 .. inf: 0 0 0 0
---------------------------------------------------------
Total : 1024 33801 33997 34056
Device B(8192 PEBs, pool=256, wl_pool=128):
=========================================================
from to count min avg max
---------------------------------------------------------
0 .. 9: 0 0 0 0 10 .. 99: 0 0 0 0 100 .. 999: 0 0 0 0 1000 .. 9999: 8192 2205 2397 2460 10000 .. 99999: 0 0 0 0 100000 .. inf: 0 0 0 0
---------------------------------------------------------
Total : 8192 2205 2397 2460
The difference of erase counter between first 64 PEBs and others is under WL_FREE_MAX_DIFF(2*UBI_WL_THRESHOLD=2*128=256).
Device A: 34056 - 33801 = 255
Device B: 2460 - 2205 = 255
Next patch will add a switch to control whether UBI needs to reserve PEBs for filling pool.
Stable-dep-of: 5b0a6b554e12 ("ubi: Fix rollback for explicit UBI device numbers")
--- drivers/mtd/ubi/build.c | 1 + drivers/mtd/ubi/fastmap-wl.c | 2 +- drivers/mtd/ubi/ubi.h | 2 ++ drivers/mtd/ubi/wl.h | 6 ++++-- 4 files changed, 8 insertions(+), 3 deletions(-)
drivers/mtd/ubi/build.c +1 -0
@@ -951,6 +951,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, UBI_FM_MIN_POOL_SIZE); ubi->fm_wl_pool.max_size = ubi->fm_pool.max_size /2 ; + ubi->fm_pool_rsv_cnt = ubi->fm_pool.max_size; ubi->fm_disabled = (!fm_autoconvert || disable_fm) ?1 :0 ;if (fm_debug)ubi_enable_dbg_chk_fastmap (ubi);
drivers/mtd/ubi/fastmap-wl.c +1 -1
@@ -118,7 +118,7 @@ static void wait_free_pebs_for_pool(struct ubi_device *ubi)* 4. beb_rsvd_pebs: This value should be get under lock ubi->wl_lock */ int reserved =WL_RESERVED_PEBS +EBA_RESERVED_PEBS + - ubi->fm_size / ubi->leb_size -1 ; + ubi->fm_size / ubi->leb_size -1 + ubi->fm_pool_rsv_cnt; do { spin_lock(&ubi->wl_lock);
drivers/mtd/ubi/ubi.h +2 -0
@@ -494,6 +494,7 @@ struct ubi_debug_info {* @fast_attach: non-zero if UBI was attached by fastmap * @fm_anchor: The next anchor PEB to use for fastmap * @fm_do_produce_anchor: If true produce an anchor PEB in wl +* @fm_pool_rsv_cnt: Number of reserved PEBs for filling pool/wl_pool * * @used: RB-tree of used physical eraseblocks * @erroneous: RB-tree of erroneous used physical eraseblocks
@@ -604,6 +605,7 @@ struct ubi_device {int fast_attach;struct ubi_wl_entry *fm_anchor;int fm_do_produce_anchor; +int fm_pool_rsv_cnt;/* Wear-leveling sub-system's stuff */ struct rb_root used;
drivers/mtd/ubi/wl.h +4 -2
@@ -8,8 +8,10 @@ static struct ubi_wl_entry *get_peb_for_wl(struct ubi_device *ubi);static void ubi_fastmap_close (struct ubi_device *ubi);static inline void ubi_fastmap_init (struct ubi_device *ubi,int *count) { -/* Reserve enough LEBs to store two fastmaps. */ - *count += (ubi->fm_size / ubi->leb_size) *2 ; +if (ubi->fm_disabled) + ubi->fm_pool_rsv_cnt =0 ; +/* Reserve enough LEBs to store two fastmaps and to fill pools. */ + *count += (ubi->fm_size / ubi->leb_size) *2 + ubi->fm_pool_rsv_cnt;INIT_WORK (&ubi->fm_work, update_fastmap_work_fn); } static struct ubi_wl_entry *may_reserve_for_fm(struct ubi_device *ubi,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 798/935 ubi: fastmap: Add module parameter to control reserving filling pool PEBs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhihao Cheng <[email protected]>
[ Upstream commit d4c48e5b58f12835de779f5425ef741c4d0fb53e ]
Adding 6th module parameter in 'mtd=xxx' to control whether or not reserving PEBs for filling pool/wl_pool.
Stable-dep-of: 5b0a6b554e12 ("ubi: Fix rollback for explicit UBI device numbers")
--- drivers/mtd/ubi/build.c | 26 ++++++++++++++++++++++---- drivers/mtd/ubi/cdev.c | 3 ++- drivers/mtd/ubi/ubi.h | 2 +- 3 files changed, 25 insertions(+), 6 deletions(-)
drivers/mtd/ubi/build.c +22 -4
@@ -35,7 +35,7 @@#define MTD_PARAM_LEN_MAX 64/* Maximum number of comma-separated items in the 'mtd=' parameter */ -#define MTD_PARAM_MAX_COUNT 5 +#define MTD_PARAM_MAX_COUNT 6/* Maximum value for the number of bad PEBs per 1024 PEBs */ #define MAX_MTD_UBI_BEB_LIMIT 768
@@ -54,6 +54,7 @@* @vid_hdr_offs: VID header offset * @max_beb_per1024: maximum expected number of bad PEBs per 1024 PEBs * @enable_fm: enable fastmap when value is non-zero +* @need_resv_pool: reserve pool->max_size pebs when value is none-zero */ struct mtd_dev_param {char name[MTD_PARAM_LEN_MAX ];
@@ -61,6 +62,7 @@ struct mtd_dev_param {int vid_hdr_offs;int max_beb_per1024;int enable_fm; +int need_resv_pool; };/* Numbers of elements set in the @mtd_dev_param array */
@@ -826,6 +828,7 @@ static int autoresize(struct ubi_device *ubi, int vol_id)* @vid_hdr_offset: VID header offset * @max_beb_per1024: maximum expected number of bad PEB per 1024 PEBs * @disable_fm: whether disable fastmap +* @need_resv_pool: whether reserve pebs to fill fm_pool * * This function attaches MTD device @mtd_dev to UBI and assign @ubi_num number * to the newly created UBI device, unless @ubi_num is %UBI_DEV_NUM_AUTO, in
@@ -841,7 +844,8 @@ static int autoresize(struct ubi_device *ubi, int vol_id)* @ubi_devices_mutex. */ int ubi_attach_mtd_dev (struct mtd_info *mtd,int ubi_num, -int vid_hdr_offset,int max_beb_per1024,bool disable_fm) +int vid_hdr_offset,int max_beb_per1024,bool disable_fm, +bool need_resv_pool) {struct ubi_device *ubi;int i, err;
@@ -951,7 +955,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, UBI_FM_MIN_POOL_SIZE); ubi->fm_wl_pool.max_size = ubi->fm_pool.max_size /2 ; - ubi->fm_pool_rsv_cnt = ubi->fm_pool.max_size; + ubi->fm_pool_rsv_cnt = need_resv_pool ? ubi->fm_pool.max_size :0 ; ubi->fm_disabled = (!fm_autoconvert || disable_fm) ?1 :0 ;if (fm_debug)ubi_enable_dbg_chk_fastmap (ubi);
@@ -1274,7 +1278,8 @@ static int __init ubi_init(void)mutex_lock (&ubi_devices_mutex); err =ubi_attach_mtd_dev (mtd, p->ubi_num, p->vid_hdr_offs, p->max_beb_per1024, - p->enable_fm ==0 ); + p->enable_fm ==0 , + p->need_resv_pool !=0 );mutex_unlock (&ubi_devices_mutex);if (err <0 ) { pr_err("UBI error: cannot attach mtd%d\n",
@@ -1483,6 +1488,18 @@ static int ubi_mtd_param_parse(const char *val, const struct kernel_param *kp) }else p->enable_fm =0 ; + token = tokens[5 ]; +if (token) { +int err =kstrtoint (token,10 , &p->need_resv_pool); + +if (err) { +pr_err ("UBI error: bad value for need_resv_pool parameter: %s\n" , + token); +return -EINVAL ; + } + }else + p->need_resv_pool =0 ; + mtd_devs +=1 ;return 0 ; }
@@ -1496,6 +1513,7 @@ MODULE_PARM_DESC(mtd, "MTD devices to attach. Parameter format: mtd=<name|num|pa __stringify(CONFIG_MTD_UBI_BEB_LIMIT) ") if 0)\n""Optional \"ubi_num\" parameter specifies UBI device number which have to be assigned to the newly created UBI device (assigned automatically by default)\n" "Optional \"enable_fm\" parameter determines whether to enable fastmap during attach. If the value is non-zero, fastmap is enabled. Default value is 0.\n" +"Optional \"need_resv_pool\" parameter determines whether to reserve pool->max_size pebs during attach. If the value is non-zero, peb reservation is enabled. Default value is 0.\n" "\n" "Example 1: mtd=/dev/mtd0 - attach MTD device /dev/mtd0.\n" "Example 2: mtd=content,1984 mtd=4 - attach MTD device with name \"content\" using VID header offset 1984, and MTD device number 4 with default VID header offset.\n"
drivers/mtd/ubi/cdev.c +2 -1
@@ -1041,7 +1041,8 @@ static long ctrl_cdev_ioctl(struct file *file, unsigned int cmd,*/ mutex_lock (&ubi_devices_mutex); err =ubi_attach_mtd_dev (mtd, req.ubi_num, req.vid_hdr_offset, - req.max_beb_per1024, !!req.disable_fm); + req.max_beb_per1024, !!req.disable_fm, + false);mutex_unlock (&ubi_devices_mutex);if (err <0 )put_mtd_device (mtd);
drivers/mtd/ubi/ubi.h +1 -1
@@ -944,7 +944,7 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum,/* build.c */ int ubi_attach_mtd_dev (struct mtd_info *mtd,int ubi_num,int vid_hdr_offset,int max_beb_per1024, -bool disable_fm); +bool disable_fm,bool need_resv_pool);int ubi_detach_mtd_dev (int ubi_num,int anyway);struct ubi_device *ubi_get_device (int ubi_num);void ubi_put_device (struct ubi_device *ubi);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 799/935 ubi: Fix rollback for explicit UBI device numbers
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 5b0a6b554e12a97f9771a9a9f4ea1f5457373c73 ]
ubi_init_attach() rolls back module initialization failures by scanning ubi_devices[0..i-1], where i is the mtd= parameter index. That assumes the parameter index matches the UBI device number.
That assumption is not true when mtd= specifies an explicit ubi_num. A successfully attached device can be stored at a higher ubi_devices[] slot, and a later failure can miss it during rollback.
Scan the full ubi_devices[] array and detach by the actual array index, matching the way UBI devices are stored.
--- drivers/mtd/ubi/build.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/ubi/build.c +2 -2
@@ -1316,10 +1316,10 @@ static int __init ubi_init(void)return 0 ; out_detach: -for (k =0 ; k < i; k++) +for (k =0 ; k <UBI_MAX_DEVICES ; k++)if (ubi_devices[k]) {mutex_lock (&ubi_devices_mutex); -ubi_detach_mtd_dev (ubi_devices[k]->ubi_num,1 ); +ubi_detach_mtd_dev (k,1 );mutex_unlock (&ubi_devices_mutex); }ubi_debugfs_exit ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 800/935 ASoC: xilinx: formatter_pcm: fix stream_data leak on open error
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit b992511180e126150c6ad3580a6fd568c385f4c6 ]
In xlnx_formatter_pcm_open(), stream_data is allocated and adata->play_stream or adata->capture_stream is assigned early. If a later step, such as snd_pcm_hw_constraint_step() or snd_pcm_hw_constraint_integer(), fails, the function returns the error immediately. ALSA does not call the close callback when open fails, so stream_data is leaked and the stream pointer is left dangling, pointing to a substream that ALSA frees. A later interrupt would then call snd_pcm_period_elapsed() on the freed substream.
Free stream_data and clear the stream pointer on the error paths.
--- sound/soc/xilinx/xlnx_formatter_pcm.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
sound/soc/xilinx/xlnx_formatter_pcm.c +11 -3
@@ -384,7 +384,7 @@ static int xlnx_formatter_pcm_open(struct snd_soc_component *component,if (err) {dev_err (component->dev,"Unable to set constraint on period bytes\n" ); -return err; + goto error; }/* Resize the buffer bytes as divisible by 64 */
@@ -394,7 +394,7 @@ static int xlnx_formatter_pcm_open(struct snd_soc_component *component,if (err) {dev_err (component->dev,"Unable to set constraint on buffer bytes\n" ); -return err; + goto error; }/* Set periods as integer multiple */
@@ -403,7 +403,7 @@ static int xlnx_formatter_pcm_open(struct snd_soc_component *component,if (err <0 ) {dev_err (component->dev,"Unable to set constraint on periods to be integer\n" ); -return err; + goto error; }/* enable DMA IOC irq */
@@ -412,6 +412,14 @@ static int xlnx_formatter_pcm_open(struct snd_soc_component *component,writel (val, stream_data->mmio +XLNX_AUD_CTRL );return 0 ; + +error: +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) + adata->play_stream =NULL ; +else + adata->capture_stream =NULL ; +kfree (stream_data); +return err; } static int xlnx_formatter_pcm_close(struct snd_soc_component *component,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 801/935 UBI: fix two issues in the ubi.mtd MODULE_PARM_DESC
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ran Hongyun <[email protected]>
[ Upstream commit ff7937d14f5333ec7e6fb50d00a152d7974f4105 ]
Fix two issues introduced before:
- The parameter format string was missing the enable_fm and need_resv_pool tokens introduced in an earlier commit.
- The bad-block reservation note was misplaced after Example 5 instead of after Example 3. It was misplaced due to an earlier patch.
--- drivers/mtd/ubi/build.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mtd/ubi/build.c +3 -3
@@ -1505,7 +1505,7 @@ static int ubi_mtd_param_parse(const char *val, const struct kernel_param *kp) }module_param_call (mtd, ubi_mtd_param_parse,NULL ,NULL ,0400 ); -MODULE_PARM_DESC (mtd,"MTD devices to attach. Parameter format: mtd=<name|num|path>[,<vid_hdr_offs>[,max_beb_per1024[,ubi_num]]].\n" +MODULE_PARM_DESC (mtd,"MTD devices to attach. Parameter format: mtd=<name|num|path>[,<vid_hdr_offs>[,max_beb_per1024[,ubi_num[,enable_fm[,need_resv_pool]]]]].\n" "Multiple \"mtd\" parameters may be specified.\n" "MTD devices may be specified by their number, name, or path to the MTD character device node.\n" "Optional \"vid_hdr_offs\" parameter specifies UBI VID header position to be used by UBI. (default value if 0)\n"
@@ -1518,9 +1518,9 @@ MODULE_PARM_DESC(mtd, "MTD devices to attach. Parameter format: mtd=<name|num|pa"Example 1: mtd=/dev/mtd0 - attach MTD device /dev/mtd0.\n" "Example 2: mtd=content,1984 mtd=4 - attach MTD device with name \"content\" using VID header offset 1984, and MTD device number 4 with default VID header offset.\n" "Example 3: mtd=/dev/mtd1,0,25 - attach MTD device /dev/mtd1 using default VID header offset and reserve 25*nand_size_in_blocks/1024 erase blocks for bad block handling.\n" +"\t(e.g. if the NAND *chipset* has 4096 PEB, 100 will be reserved for this UBI device).\n" "Example 4: mtd=/dev/mtd1,0,0,5 - attach MTD device /dev/mtd1 to UBI 5 and using default values for the other fields.\n" -"example 5: mtd=1,0,0,5 mtd=2,0,0,6,1 - attach MTD device /dev/mtd1 to UBI 5 and disable fastmap; attach MTD device /dev/mtd2 to UBI 6 and enable fastmap.(only works when fastmap is enabled and fm_autoconvert=Y).\n" - "\t(e.g. if the NAND *chipset* has 4096 PEB, 100 will be reserved for this UBI device)."); + "example 5: mtd=1,0,0,5 mtd=2,0,0,6,1 - attach MTD device /dev/mtd1 to UBI 5 and disable fastmap; attach MTD device /dev/mtd2 to UBI 6 and enable fastmap.(only works when fastmap is enabled and fm_autoconvert=Y).\n");#ifdef CONFIG_MTD_UBI_FASTMAP module_param (fm_autoconvert, bool,0644 );MODULE_PARM_DESC (fm_autoconvert,"Set this parameter to enable fastmap automatically on images without a fastmap." );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 802/935 selfetests/bpf: Update vmtest.sh defaults
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yucong Sun <[email protected]>
[ Upstream commit 547208a386fa2066fa2d6d48bda145f78c38604f ]
Increase memory to 4G, 8 SMP core with host cpu passthrough. This make it run faster in parallel mode and more likely to succeed.
Stable-dep-of: 3a59f11e0f98 ("selftests/bpf: vmtest.sh: Preserve command quoting when running in the VM")
--- tools/testing/selftests/bpf/vmtest.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/vmtest.sh +3 -3
@@ -224,10 +224,10 @@ EOF -nodefaults \ -display none \ -serial mon:stdio \ - -cpu kvm64 \ + -cpu host \ -enable-kvm \ - -smp 4 \ - -m 2G \ + -smp 8 \ + -m 4G \ -drive file="${rootfs_img}",format=raw,index=1,media=disk,if=virtio,cache=none \ -kernel "${kernel_bzimage}" \ -append "root=/dev/vda rw console=ttyS0,115200"
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 803/935 selfetests/bpf: Adapt vmtest.sh to s390 libbpf CI changes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Leoshkevich <[email protected]>
[ Upstream commit 29ad850a5cae84757bcd4c60e0d74232ef8c5157 ]
[1] added s390 support to libbpf CI and added an ${ARCH} prefix to a number of paths and identifiers in libbpf GitHub repo, which vmtest.sh relies upon. Update these and make use of the new s390 support.
[1] https://github.com/libbpf/libbpf/pull/204
Stable-dep-of: 3a59f11e0f98 ("selftests/bpf: vmtest.sh: Preserve command quoting when running in the VM")
--- tools/testing/selftests/bpf/vmtest.sh | 46 ++++++++++++++++++--------- 1 file changed, 31 insertions(+), 15 deletions(-)
tools/testing/selftests/bpf/vmtest.sh +31 -15
@@ -4,17 +4,34 @@ set -u set -e -# This script currently only works for x86_64, as -# it is based on the VM image used by the BPF CI which is -# x86_64. -QEMU_BINARY="${QEMU_BINARY:="qemu-system-x86_64"}" -X86_BZIMAGE="arch/x86/boot/bzImage" +# This script currently only works for x86_64 and s390x, as +# it is based on the VM image used by the BPF CI, which is +# available only for these architectures. +ARCH="$(uname -m)" +case "${ARCH}" in +s390x) + QEMU_BINARY=qemu-system-s390x + QEMU_CONSOLE="ttyS1" + QEMU_FLAGS=(-smp 2) + BZIMAGE="arch/s390/boot/compressed/vmlinux" + ;; +x86_64) + QEMU_BINARY=qemu-system-x86_64 + QEMU_CONSOLE="ttyS0,115200" + QEMU_FLAGS=(-cpu host -smp 8) + BZIMAGE="arch/x86/boot/bzImage" + ;; +*) + echo "Unsupported architecture" + exit 1 + ;; +esac DEFAULT_COMMAND="./test_progs" MOUNT_DIR="mnt" ROOTFS_IMAGE="root.img" OUTPUT_DIR="$HOME/.bpf_selftests" -KCONFIG_URL="https://raw.githubusercontent.com/libbpf/libbpf/master/travis-ci/vmtest/configs/latest.config" -KCONFIG_API_URL="https://api.github.com/repos/libbpf/libbpf/contents/travis-ci/vmtest/configs/latest.config" +KCONFIG_URL="https://raw.githubusercontent.com/libbpf/libbpf/master/travis-ci/vmtest/configs/config-latest.${ARCH}" +KCONFIG_API_URL="https://api.github.com/repos/libbpf/libbpf/contents/travis-ci/vmtest/configs/config-latest.${ARCH}" INDEX_URL="https://raw.githubusercontent.com/libbpf/libbpf/master/travis-ci/vmtest/configs/INDEX" NUM_COMPILE_JOBS="$(nproc)" LOG_FILE_BASE="$(date +"bpf_selftests.%Y-%m-%d_%H-%M-%S")"
@@ -85,7 +102,7 @@ newest_rootfs_version() { { for file in "${!URLS[@]}"; do - if [[ $file =~ ^libbpf-vmtest-rootfs-(.*)\.tar\.zst$ ]]; then + if [[ $file =~ ^"${ARCH}"/libbpf-vmtest-rootfs-(.*)\.tar\.zst$ ]]; then echo "${BASH_REMATCH[1]}" fi done
@@ -102,7 +119,7 @@ download_rootfs() exit 1 fi - download "libbpf-vmtest-rootfs-$rootfsversion.tar.zst" | + download "${ARCH}/libbpf-vmtest-rootfs-$rootfsversion.tar.zst" | zstd -d | sudo tar -C "$dir" -x }
@@ -224,13 +241,12 @@ EOF -nodefaults \ -display none \ -serial mon:stdio \ - -cpu host \ + "${qemu_flags[@]}" \ -enable-kvm \ - -smp 8 \ -m 4G \ -drive file="${rootfs_img}",format=raw,index=1,media=disk,if=virtio,cache=none \ -kernel "${kernel_bzimage}" \ - -append "root=/dev/vda rw console=ttyS0,115200" + -append "root=/dev/vda rw console=${QEMU_CONSOLE}" } copy_logs()
@@ -282,7 +298,7 @@ main() local kernel_checkout=$(realpath "${script_dir}"/../../../../) # By default the script searches for the kernel in the checkout directory but # it also obeys environment variables O= and KBUILD_OUTPUT= - local kernel_bzimage="${kernel_checkout}/${X86_BZIMAGE}" + local kernel_bzimage="${kernel_checkout}/${BZIMAGE}" local command="${DEFAULT_COMMAND}" local update_image="no" local exit_command="poweroff -f"
@@ -337,13 +353,13 @@ main() if is_rel_path "${O}"; then O="$(realpath "${PWD}/${O}")" fi - kernel_bzimage="${O}/${X86_BZIMAGE}" + kernel_bzimage="${O}/${BZIMAGE}" make_command="${make_command} O=${O}" elif [[ "${KBUILD_OUTPUT:=""}" != "" ]]; then if is_rel_path "${KBUILD_OUTPUT}"; then KBUILD_OUTPUT="$(realpath "${PWD}/${KBUILD_OUTPUT}")" fi - kernel_bzimage="${KBUILD_OUTPUT}/${X86_BZIMAGE}" + kernel_bzimage="${KBUILD_OUTPUT}/${BZIMAGE}" make_command="${make_command} KBUILD_OUTPUT=${KBUILD_OUTPUT}" fi
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 804/935 bpf/docs: Update list of architectures supported.
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: KP Singh <[email protected]>
[ Upstream commit e878ae2d1df5de4ea36e6d96c7d3ebe789aab9a5 ]
vmtest.sh also supports s390x now.
Stable-dep-of: 3a59f11e0f98 ("selftests/bpf: vmtest.sh: Preserve command quoting when running in the VM")
--- tools/testing/selftests/bpf/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/README.rst +1 -1
@@ -36,7 +36,7 @@ For more information on about using the script, run: If you want to change pahole and llvm, you can change `PATH` environment variable in the beginning of script. -.. note:: The script currently only supports x86_64. +.. note:: The script currently only supports x86_64 and s390x architectures. Additional information about selftest failures are documented here.
Signature · 1 line
2.53.0