Commit Graph

41307 Commits

Author SHA1 Message Date
Bruce Ashfield
a8889f753c This is the 6.1.141 stable release
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmhAPsAACgkQONu9yGCS
 aT5bsA/9GAXiE7V78xym1UyF8Rib0vcQ2vQuilw+kzGr8UJyg9bBO5+H3j3W8stu
 TrFMYk3mFDdfJ/ozKSQkFlVPI7XFfz8x7T1/3+ytqf90TLe9hBfx4WsDMA+OCz7K
 GJqPMCmfb6yZi/Jp0Cotqd7cRmLisNvvPl2k+8QO2PbNnsZOJPYNy7XsS5WCNY81
 r27Lu/eyPYdb4CRuxWDLBjeFkC+npVsUxbVUaUgODwlJwmg3z5G+vhMhsw5roZlN
 IXxnDnVorIK/q9Cfw5AK89kIQzL5PQE9EAUBS+mKaGYvU8I4uvttA2ebkosQV+xW
 ahMX4TZldSWYC5fsfL57MnHdWGQ4c/+RTKUBhEqwKALu4bv8bavC1XQ3vv5GiD0A
 f83Km2dq4+bOIyLCXhx2m1b983eGVC9t4s1OacqlKfupmt0H6NhtRlBPTLCRMajG
 njHPoaHdPXTq1EjCpu7m4d7tyFSK/oGiWeWSCEdQciAzT6ET9FEGErr9UG5auVz4
 NSHZq1I7WtZbRGz6RmcwdgGpPLD+Q5+wWkqaaezCzrfsqgtmxwXp7LmM5yVkvEYq
 0HitEOcaHCT1Cl+VFsClFbsrad98KAcDV6wIfTgSbL9GjBG7kW8vgZaFbir+XG4j
 5yqdj8lo+DiXtK+JXibfcAVQufciOZzuWhiDnV/nD+qVKOdqcvI=
 =O5on
 -----END PGP SIGNATURE-----

Merge tag 'v6.1.141' into v6.1/standard/base

This is the 6.1.141 stable release

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmhAPsAACgkQONu9yGCS
# aT5bsA/9GAXiE7V78xym1UyF8Rib0vcQ2vQuilw+kzGr8UJyg9bBO5+H3j3W8stu
# TrFMYk3mFDdfJ/ozKSQkFlVPI7XFfz8x7T1/3+ytqf90TLe9hBfx4WsDMA+OCz7K
# GJqPMCmfb6yZi/Jp0Cotqd7cRmLisNvvPl2k+8QO2PbNnsZOJPYNy7XsS5WCNY81
# r27Lu/eyPYdb4CRuxWDLBjeFkC+npVsUxbVUaUgODwlJwmg3z5G+vhMhsw5roZlN
# IXxnDnVorIK/q9Cfw5AK89kIQzL5PQE9EAUBS+mKaGYvU8I4uvttA2ebkosQV+xW
# ahMX4TZldSWYC5fsfL57MnHdWGQ4c/+RTKUBhEqwKALu4bv8bavC1XQ3vv5GiD0A
# f83Km2dq4+bOIyLCXhx2m1b983eGVC9t4s1OacqlKfupmt0H6NhtRlBPTLCRMajG
# njHPoaHdPXTq1EjCpu7m4d7tyFSK/oGiWeWSCEdQciAzT6ET9FEGErr9UG5auVz4
# NSHZq1I7WtZbRGz6RmcwdgGpPLD+Q5+wWkqaaezCzrfsqgtmxwXp7LmM5yVkvEYq
# 0HitEOcaHCT1Cl+VFsClFbsrad98KAcDV6wIfTgSbL9GjBG7kW8vgZaFbir+XG4j
# 5yqdj8lo+DiXtK+JXibfcAVQufciOZzuWhiDnV/nD+qVKOdqcvI=
# =O5on
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 04 Jun 2025 08:40:32 AM EDT
# gpg:                using RSA key 647F28654894E3BD457199BE38DBBDC86092693E
# gpg: Can't check signature: No public key
2025-06-06 11:04:27 -04:00
Christian Brauner
b2a5bf1cf4 fork: use pidfd_prepare()
commit ca7707f543 upstream.

Stop open-coding get_unused_fd_flags() and anon_inode_getfile(). That's
brittle just for keeping the flags between both calls in sync. Use the
dedicated helper.

Message-Id: <20230327-pidfd-file-api-v1-2-5c0e9a3158e4@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-06-04 14:40:25 +02:00
Christian Brauner
1ced79b25f pid: add pidfd_prepare()
commit 6ae930d9db upstream.

Add a new helper that allows to reserve a pidfd and allocates a new
pidfd file that stashes the provided struct pid. This will allow us to
remove places that either open code this function or that call
pidfd_create() but then have to call close_fd() because there are still
failure points after pidfd_create() has been called.

Reviewed-by: Jan Kara <jack@suse.cz>
Message-Id: <20230327-pidfd-file-api-v1-1-5c0e9a3158e4@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-06-04 14:40:25 +02:00
Frederic Weisbecker
82ac6adbbb hrtimers: Force migrate away hrtimers queued after CPUHP_AP_HRTIMERS_DYING
commit 53dac345395c0d2493cbc2f4c85fe38aef5b63f5 upstream.

hrtimers are migrated away from the dying CPU to any online target at
the CPUHP_AP_HRTIMERS_DYING stage in order not to delay bandwidth timers
handling tasks involved in the CPU hotplug forward progress.

However wakeups can still be performed by the outgoing CPU after
CPUHP_AP_HRTIMERS_DYING. Those can result again in bandwidth timers being
armed. Depending on several considerations (crystal ball power management
based election, earliest timer already enqueued, timer migration enabled or
not), the target may eventually be the current CPU even if offline. If that
happens, the timer is eventually ignored.

The most notable example is RCU which had to deal with each and every of
those wake-ups by deferring them to an online CPU, along with related
workarounds:

_ e787644caf (rcu: Defer RCU kthreads wakeup when CPU is dying)
_ 9139f93209 (rcu/nocb: Fix RT throttling hrtimer armed from offline CPU)
_ f7345ccc62 (rcu/nocb: Fix rcuog wake-up from offline softirq)

The problem isn't confined to RCU though as the stop machine kthread
(which runs CPUHP_AP_HRTIMERS_DYING) reports its completion at the end
of its work through cpu_stop_signal_done() and performs a wake up that
eventually arms the deadline server timer:

   WARNING: CPU: 94 PID: 588 at kernel/time/hrtimer.c:1086 hrtimer_start_range_ns+0x289/0x2d0
   CPU: 94 UID: 0 PID: 588 Comm: migration/94 Not tainted
   Stopper: multi_cpu_stop+0x0/0x120 <- stop_machine_cpuslocked+0x66/0xc0
   RIP: 0010:hrtimer_start_range_ns+0x289/0x2d0
   Call Trace:
   <TASK>
     start_dl_timer
     enqueue_dl_entity
     dl_server_start
     enqueue_task_fair
     enqueue_task
     ttwu_do_activate
     try_to_wake_up
     complete
     cpu_stopper_thread

Instead of providing yet another bandaid to work around the situation, fix
it in the hrtimers infrastructure instead: always migrate away a timer to
an online target whenever it is enqueued from an offline CPU.

This will also allow to revert all the above RCU disgraceful hacks.

Fixes: 5c0930ccaa ("hrtimers: Push pending hrtimers away from outgoing CPU earlier")
Reported-by: Vlad Poenaru <vlad.wing@gmail.com>
Reported-by: Usama Arif <usamaarif642@gmail.com>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Tested-by: Paul E. McKenney <paulmck@kernel.org>
Link: https://lore.kernel.org/all/20250117232433.24027-1-frederic@kernel.org
Closes: 20241213203739.1519801-1-usamaarif642@gmail.com
Signed-off-by: Zhaoyang Li <lizy04@hust.edu.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-06-04 14:40:22 +02:00
Dominik Grzegorzek
cceb15864e padata: do not leak refcount in reorder_work
commit d6ebcde6d4ecf34f8495fb30516645db3aea8993 upstream.

A recent patch that addressed a UAF introduced a reference count leak:
the parallel_data refcount is incremented unconditionally, regardless
of the return value of queue_work(). If the work item is already queued,
the incremented refcount is never decremented.

Fix this by checking the return value of queue_work() and decrementing
the refcount when necessary.

Resolves:

Unreferenced object 0xffff9d9f421e3d80 (size 192):
  comm "cryptomgr_probe", pid 157, jiffies 4294694003
  hex dump (first 32 bytes):
    80 8b cf 41 9f 9d ff ff b8 97 e0 89 ff ff ff ff  ...A............
    d0 97 e0 89 ff ff ff ff 19 00 00 00 1f 88 23 00  ..............#.
  backtrace (crc 838fb36):
    __kmalloc_cache_noprof+0x284/0x320
    padata_alloc_pd+0x20/0x1e0
    padata_alloc_shell+0x3b/0xa0
    0xffffffffc040a54d
    cryptomgr_probe+0x43/0xc0
    kthread+0xf6/0x1f0
    ret_from_fork+0x2f/0x50
    ret_from_fork_asm+0x1a/0x30

Fixes: dd7d37ccf6b1 ("padata: avoid UAF for reorder_work")
Cc: <stable@vger.kernel.org>
Signed-off-by: Dominik Grzegorzek <dominik.grzegorzek@oracle.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-06-04 14:40:20 +02:00
Peter Zijlstra (Intel)
e1c3bfe365 perf: Avoid the read if the count is already updated
[ Upstream commit 8ce939a0fa194939cc1f92dbd8bc1a7806e7d40a ]

The event may have been updated in the PMU-specific implementation,
e.g., Intel PEBS counters snapshotting. The common code should not
read and overwrite the value.

The PERF_SAMPLE_READ in the data->sample_type can be used to detect
whether the PMU-specific value is available. If yes, avoid the
pmu->read() in the common code. Add a new flag, skip_read, to track the
case.

Factor out a perf_pmu_read() to clean up the code.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20250121152303.3128733-3-kan.liang@linux.intel.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-06-04 14:40:16 +02:00
Ankur Arora
e2df1936c1 rcu: handle unstable rdp in rcu_read_unlock_strict()
[ Upstream commit fcf0e25ad4c8d14d2faab4d9a17040f31efce205 ]

rcu_read_unlock_strict() can be called with preemption enabled
which can make for an unstable rdp and a racy norm value.

Fix this by dropping the preempt-count in __rcu_read_unlock()
after the call to rcu_read_unlock_strict(), adjusting the
preempt-count check appropriately.

Suggested-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Ankur Arora <ankur.a.arora@oracle.com>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-06-04 14:40:16 +02:00
Ankur Arora
6090e60428 rcu: handle quiescent states for PREEMPT_RCU=n, PREEMPT_COUNT=y
[ Upstream commit 83b28cfe796464ebbde1cf7916c126da6d572685 ]

With PREEMPT_RCU=n, cond_resched() provides urgently needed quiescent
states for read-side critical sections via rcu_all_qs().
One reason why this was needed: lacking preempt-count, the tick
handler has no way of knowing whether it is executing in a
read-side critical section or not.

With (PREEMPT_LAZY=y, PREEMPT_DYNAMIC=n), we get (PREEMPT_COUNT=y,
PREEMPT_RCU=n). In this configuration cond_resched() is a stub and
does not provide quiescent states via rcu_all_qs().
(PREEMPT_RCU=y provides this information via rcu_read_unlock() and
its nesting counter.)

So, use the availability of preempt_count() to report quiescent states
in rcu_flavor_sched_clock_irq().

Suggested-by: Paul E. McKenney <paulmck@kernel.org>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Ankur Arora <ankur.a.arora@oracle.com>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-06-04 14:40:16 +02:00
Saket Kumar Bhaskar
628ff556e4 perf/hw_breakpoint: Return EOPNOTSUPP for unsupported breakpoint type
[ Upstream commit 061c991697062f3bf87b72ed553d1d33a0e370dd ]

Currently, __reserve_bp_slot() returns -ENOSPC for unsupported
breakpoint types on the architecture. For example, powerpc
does not support hardware instruction breakpoints. This causes
the perf_skip BPF selftest to fail, as neither ENOENT nor
EOPNOTSUPP is returned by perf_event_open for unsupported
breakpoint types. As a result, the test that should be skipped
for this arch is not correctly identified.

To resolve this, hw_breakpoint_event_init() should exit early by
checking for unsupported breakpoint types using
hw_breakpoint_slots_cached() and return the appropriate error
(-EOPNOTSUPP).

Signed-off-by: Saket Kumar Bhaskar <skb99@linux.ibm.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Marco Elver <elver@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Link: https://lore.kernel.org/r/20250303092451.1862862-1-skb99@linux.ibm.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-06-04 14:40:09 +02:00
Thomas Weißschuh
e563401934 timer_list: Don't use %pK through printk()
[ Upstream commit a52067c24ccf6ee4c85acffa0f155e9714f9adce ]

This reverts commit f590308536 ("timer debug: Hide kernel addresses via
%pK in /proc/timer_list")

The timer list helper SEQ_printf() uses either the real seq_printf() for
procfs output or vprintk() to print to the kernel log, when invoked from
SysRq-q. It uses %pK for printing pointers.

In the past %pK was prefered over %p as it would not leak raw pointer
values into the kernel log. Since commit ad67b74d24 ("printk: hash
addresses printed with %p") the regular %p has been improved to avoid this
issue.

Furthermore, restricted pointers ("%pK") were never meant to be used
through printk(). They can still unintentionally leak raw pointers or
acquire sleeping looks in atomic contexts.

Switch to the regular pointer formatting which is safer, easier to reason
about and sufficient here.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/lkml/20250113171731-dc10e3c1-da64-4af0-b767-7c7070468023@linutronix.de/
Link: https://lore.kernel.org/all/20250311-restricted-pointers-timer-v1-1-6626b91e54ab@linutronix.de
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-06-04 14:40:07 +02:00
Eric Dumazet
209f290b4f posix-timers: Add cond_resched() to posix_timer_add() search loop
[ Upstream commit 5f2909c6cd13564a07ae692a95457f52295c4f22 ]

With a large number of POSIX timers the search for a valid ID might cause a
soft lockup on PREEMPT_NONE/VOLUNTARY kernels.

Add cond_resched() to the loop to prevent that.

[ tglx: Split out from Eric's series ]

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Link: https://lore.kernel.org/all/20250214135911.2037402-2-edumazet@google.com
Link: https://lore.kernel.org/all/20250308155623.635612865@linutronix.de
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-06-04 14:40:06 +02:00
Mykyta Yatsenko
a73f1ba994 bpf: Return prog btf_id without capable check
[ Upstream commit 07651ccda9ff10a8ca427670cdd06ce2c8e4269c ]

Return prog's btf_id from bpf_prog_get_info_by_fd regardless of capable
check. This patch enables scenario, when freplace program, running
from user namespace, requires to query target prog's btf.

Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/bpf/20250317174039.161275-3-mykyta.yatsenko5@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-06-04 14:40:05 +02:00
Ryo Takakura
2896063907 lockdep: Fix wait context check on softirq for PREEMPT_RT
[ Upstream commit 61c39d8c83e2077f33e0a2c8980a76a7f323f0ce ]

Since:

  0c1d7a2c2d ("lockdep: Remove softirq accounting on PREEMPT_RT.")

the wait context test for mutex usage within "in softirq context" fails
as it references @softirq_context:

    | wait context tests |
    --------------------------------------------------------------------------
                                   | rcu  | raw  | spin |mutex |
    --------------------------------------------------------------------------
                 in hardirq context:  ok  |  ok  |  ok  |  ok  |
  in hardirq context (not threaded):  ok  |  ok  |  ok  |  ok  |
                 in softirq context:  ok  |  ok  |  ok  |FAILED|

As a fix, add lockdep map for BH disabled section. This fixes the
issue by letting us catch cases when local_bh_disable() gets called
with preemption disabled where local_lock doesn't get acquired.
In the case of "in softirq context" selftest, local_bh_disable() was
being called with preemption disable as it's early in the boot.

[ boqun: Move the lockdep annotations into __local_bh_*() to avoid false
         positives because of unpaired local_bh_disable() reported by
	 Borislav Petkov and Peter Zijlstra, and make bh_lock_map
	 only exist for PREEMPT_RT. ]

[ mingo: Restored authorship and improved the bh_lock_map definition. ]

Signed-off-by: Ryo Takakura <ryotkkr98@gmail.com>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20250321143322.79651-1-boqun.feng@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-06-04 14:40:03 +02:00
Andy Shevchenko
6707f9749d tracing: Mark binary printing functions with __printf() attribute
[ Upstream commit 196a062641fe68d9bfe0ad36b6cd7628c99ad22c ]

Binary printing functions are using printf() type of format, and compiler
is not happy about them as is:

kernel/trace/trace.c:3292:9: error: function ‘trace_vbprintk’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
kernel/trace/trace_seq.c:182:9: error: function ‘trace_seq_bprintf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]

Fix the compilation errors by adding __printf() attribute.

While at it, move existing __printf() attributes from the implementations
to the declarations. IT also fixes incorrect attribute parameters that are
used for trace_array_printk().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Kees Cook <kees@kernel.org>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20250321144822.324050-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-06-04 14:40:03 +02:00
Brandon Kammerdiener
0953353269 bpf: fix possible endless loop in BPF map iteration
[ Upstream commit 75673fda0c557ae26078177dd14d4857afbf128d ]

The _safe variant used here gets the next element before running the callback,
avoiding the endless loop condition.

Signed-off-by: Brandon Kammerdiener <brandon.kammerdiener@intel.com>
Link: https://lore.kernel.org/r/20250424153246.141677-2-brandon.kammerdiener@intel.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Hou Tao <houtao1@huawei.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-06-04 14:40:02 +02:00
gaoxu
91fe35809e cgroup: Fix compilation issue due to cgroup_mutex not being exported
[ Upstream commit 87c259a7a359e73e6c52c68fcbec79988999b4e6 ]

When adding folio_memcg function call in the zram module for
Android16-6.12, the following error occurs during compilation:
ERROR: modpost: "cgroup_mutex" [../soc-repo/zram.ko] undefined!

This error is caused by the indirect call to lockdep_is_held(&cgroup_mutex)
within folio_memcg. The export setting for cgroup_mutex is controlled by
the CONFIG_PROVE_RCU macro. If CONFIG_LOCKDEP is enabled while
CONFIG_PROVE_RCU is not, this compilation error will occur.

To resolve this issue, add a parallel macro CONFIG_LOCKDEP control to
ensure cgroup_mutex is properly exported when needed.

Signed-off-by: gao xu <gaoxu2@honor.com>
Acked-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-06-04 14:40:01 +02:00
Bruce Ashfield
2c1b513331 This is the 6.1.140 stable release
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmgvFEIACgkQONu9yGCS
 aT7LPRAAxgs5BKEZroYzUn6ve72yi8QPiTn+GERb7/qkjGfsS2AGWwGra3CJu5eo
 DQjKguGZY8DW8niwFGDGOfpUnoa8KJQvxakPBw79jM2LFL/XOVBJtbkUZ1NMiRdI
 QAs85JYgFcDmBSVi8t+E32LmoUTSf9mB5Vr6Ic8l23ylBkElmh5ABcsBwAAfFpgf
 g5yYHMy3QTEnddGDa8xAUzy+eHCPOeVyTH8Ha8HvUlj3tHjopTo8AzlveIOj+iOw
 luoSxUzUkY6+UgJAo6Gkgn3h734plLNoGlnSjtMVj5dFN78/r/ss13YJxdG0WAHY
 pEFiQBB8cXzzpbKw6hDZ9pjrx4+S4Yw5gL2E8iCnzkpkQ/0ydD8nnI3c4qnxA24N
 UGZJkRLJAvjd8GdB+WOEsOHidbhMMuj7fTRgLim5bo1A0MjgfA7PPHDW9rXiRDgG
 g9Kn1lyVsc4I5MnwY2ro3B6kQYEm52vKCKYavAaUohj39oA9aJ967p5X6I+kvrlq
 HnnJaF/MbmjN8Bfv1b5Y7TqfhI4nkKDdnCvVcFNRsmktdJLRRDoq4bfpZaZa1uCY
 XeQzFlThM4/IqFeCudJv2Dmf8GqS1tAiMe2pdrHf2YpGeNI0Ldea1uxBstv2EpSd
 ml+Skla6E0tdnvT5YUhZarLTCpGvQ97VpJ9eImLvh0XQalImL44=
 =0mSP
 -----END PGP SIGNATURE-----

Merge tag 'v6.1.140' into v6.1/standard/base

This is the 6.1.140 stable release

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmgvFEIACgkQONu9yGCS
# aT7LPRAAxgs5BKEZroYzUn6ve72yi8QPiTn+GERb7/qkjGfsS2AGWwGra3CJu5eo
# DQjKguGZY8DW8niwFGDGOfpUnoa8KJQvxakPBw79jM2LFL/XOVBJtbkUZ1NMiRdI
# QAs85JYgFcDmBSVi8t+E32LmoUTSf9mB5Vr6Ic8l23ylBkElmh5ABcsBwAAfFpgf
# g5yYHMy3QTEnddGDa8xAUzy+eHCPOeVyTH8Ha8HvUlj3tHjopTo8AzlveIOj+iOw
# luoSxUzUkY6+UgJAo6Gkgn3h734plLNoGlnSjtMVj5dFN78/r/ss13YJxdG0WAHY
# pEFiQBB8cXzzpbKw6hDZ9pjrx4+S4Yw5gL2E8iCnzkpkQ/0ydD8nnI3c4qnxA24N
# UGZJkRLJAvjd8GdB+WOEsOHidbhMMuj7fTRgLim5bo1A0MjgfA7PPHDW9rXiRDgG
# g9Kn1lyVsc4I5MnwY2ro3B6kQYEm52vKCKYavAaUohj39oA9aJ967p5X6I+kvrlq
# HnnJaF/MbmjN8Bfv1b5Y7TqfhI4nkKDdnCvVcFNRsmktdJLRRDoq4bfpZaZa1uCY
# XeQzFlThM4/IqFeCudJv2Dmf8GqS1tAiMe2pdrHf2YpGeNI0Ldea1uxBstv2EpSd
# ml+Skla6E0tdnvT5YUhZarLTCpGvQ97VpJ9eImLvh0XQalImL44=
# =0mSP
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 22 May 2025 08:10:42 AM EDT
# gpg:                using RSA key 647F28654894E3BD457199BE38DBBDC86092693E
# gpg: Can't check signature: No public key
2025-05-28 13:38:18 -04:00
pengdonglin
cbe20c2c83 ftrace: Fix preemption accounting for stacktrace filter command
commit 11aff32439df6ca5b3b891b43032faf88f4a6a29 upstream.

The preemption count of the stacktrace filter command to trace ksys_read
is consistently incorrect:

$ echo ksys_read:stacktrace > set_ftrace_filter

   <...>-453     [004] ...1.    38.308956: <stack trace>
=> ksys_read
=> do_syscall_64
=> entry_SYSCALL_64_after_hwframe

The root cause is that the trace framework disables preemption when
invoking the filter command callback in function_trace_probe_call:

   preempt_disable_notrace();
   probe_ops->func(ip, parent_ip, probe_opsbe->tr, probe_ops, probe->data);
   preempt_enable_notrace();

Use tracing_gen_ctx_dec() to account for the preempt_disable_notrace(),
which will output the correct preemption count:

$ echo ksys_read:stacktrace > set_ftrace_filter

   <...>-410     [006] .....    31.420396: <stack trace>
=> ksys_read
=> do_syscall_64
=> entry_SYSCALL_64_after_hwframe

Cc: stable@vger.kernel.org
Fixes: 36590c50b2 ("tracing: Merge irqflags + preempt counter.")
Link: https://lore.kernel.org/20250512094246.1167956-2-dolinux.peng@gmail.com
Signed-off-by: pengdonglin <dolinux.peng@gmail.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-05-22 14:10:05 +02:00
pengdonglin
c4edc834d2 ftrace: Fix preemption accounting for stacktrace trigger command
commit e333332657f615ac2b55aa35565c4a882018bbe9 upstream.

When using the stacktrace trigger command to trace syscalls, the
preemption count was consistently reported as 1 when the system call
event itself had 0 (".").

For example:

root@ubuntu22-vm:/sys/kernel/tracing/events/syscalls/sys_enter_read
$ echo stacktrace > trigger
$ echo 1 > enable

    sshd-416     [002] .....   232.864910: sys_read(fd: a, buf: 556b1f3221d0, count: 8000)
    sshd-416     [002] ...1.   232.864913: <stack trace>
 => ftrace_syscall_enter
 => syscall_trace_enter
 => do_syscall_64
 => entry_SYSCALL_64_after_hwframe

The root cause is that the trace framework disables preemption in __DO_TRACE before
invoking the trigger callback.

Use the tracing_gen_ctx_dec() that will accommodate for the increase of
the preemption count in __DO_TRACE when calling the callback. The result
is the accurate reporting of:

    sshd-410     [004] .....   210.117660: sys_read(fd: 4, buf: 559b725ba130, count: 40000)
    sshd-410     [004] .....   210.117662: <stack trace>
 => ftrace_syscall_enter
 => syscall_trace_enter
 => do_syscall_64
 => entry_SYSCALL_64_after_hwframe

Cc: stable@vger.kernel.org
Fixes: ce33c845b0 ("tracing: Dump stacktrace trigger to the corresponding instance")
Link: https://lore.kernel.org/20250512094246.1167956-1-dolinux.peng@gmail.com
Signed-off-by: pengdonglin <dolinux.peng@gmail.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-05-22 14:10:05 +02:00
Masami Hiramatsu (Google)
2f81039276 tracing: probes: Fix a possible race in trace_probe_log APIs
[ Upstream commit fd837de3c9cb1a162c69bc1fb1f438467fe7f2f5 ]

Since the shared trace_probe_log variable can be accessed and
modified via probe event create operation of kprobe_events,
uprobe_events, and dynamic_events, it should be protected.
In the dynamic_events, all operations are serialized by
`dyn_event_ops_mutex`. But kprobe_events and uprobe_events
interfaces are not serialized.

To solve this issue, introduces dyn_event_create(), which runs
create() operation under the mutex, for kprobe_events and
uprobe_events. This also uses lockdep to check the mutex is
held when using trace_probe_log* APIs.

Link: https://lore.kernel.org/all/174684868120.551552.3068655787654268804.stgit@devnote2/

Reported-by: Paul Cacheux <paulcacheux@gmail.com>
Closes: https://lore.kernel.org/all/20250510074456.805a16872b591e2971a4d221@kernel.org/
Fixes: ab105a4fb8 ("tracing: Use tracing error_log with probe events")
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-05-22 14:09:59 +02:00
Bruce Ashfield
289c3a681f This is the 6.1.139 stable release
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmgpfIMACgkQONu9yGCS
 aT6vWA/9GzqIJ9C16diuPmNIkftswKaEEtbrphLvHgYstEplIUhzc6CTgTcyUguG
 tvAMeDXZAyjB6OsjpvRfLhiVUrgT39WQcznbikLKjmOxIvmKw3nUqTWXN9e66JKG
 JkNzhbBUNiDAy7RBps7jmHu38apt09B3ygQouz31x3LmdZNAOziAzxXrLLQyoiQJ
 cYNkcV5Etj2c/DE/6lLZmNohzQzD2szI8UZBJNIT+e5HT0YsZ6dVdTOeTj4mj8qb
 5GMHnWQsoYKA4YDaPPWtzKh+LtFPsRo+dq6r40Efc5M0AWK+yrIcN7LGgwbMxgre
 xdejLZMk40tQDkEbCFBKgV3gpiyEszQ7SDa8DR9J7K7m12T9/4HgyHfNMp2lk1oM
 +/sQf+RDBdaSlQQYEBRbhlvSPhdrECzjs/rfVsv6R3mKvvgBQe5MeixIBeOPXIXC
 oG3U1kbsNssXoZau392j3S0muySIzQTwWtybWYyFI+HW24UViybTHzM1IX+A8My9
 zrPVmOSzPAQa0FDS+llsQcchK4G7UFE+jn5fH8CbJB6y6hsMIlBNBsgeMEknLTJN
 Wv9kd4ZPaxTc6Zx+0WmXACPjY12Wl8GmGu8nhw0GHY8YlbHhV1W8P/CzIn1mlSfl
 hVsbdJ2RX5YEPq+2Hx40Gpzb6lFrWI6qlNO1lVwQ8A/2MNy+RqA=
 =ig8D
 -----END PGP SIGNATURE-----

Merge tag 'v6.1.139' into v6.1/standard/base

This is the 6.1.139 stable release

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmgpfIMACgkQONu9yGCS
# aT6vWA/9GzqIJ9C16diuPmNIkftswKaEEtbrphLvHgYstEplIUhzc6CTgTcyUguG
# tvAMeDXZAyjB6OsjpvRfLhiVUrgT39WQcznbikLKjmOxIvmKw3nUqTWXN9e66JKG
# JkNzhbBUNiDAy7RBps7jmHu38apt09B3ygQouz31x3LmdZNAOziAzxXrLLQyoiQJ
# cYNkcV5Etj2c/DE/6lLZmNohzQzD2szI8UZBJNIT+e5HT0YsZ6dVdTOeTj4mj8qb
# 5GMHnWQsoYKA4YDaPPWtzKh+LtFPsRo+dq6r40Efc5M0AWK+yrIcN7LGgwbMxgre
# xdejLZMk40tQDkEbCFBKgV3gpiyEszQ7SDa8DR9J7K7m12T9/4HgyHfNMp2lk1oM
# +/sQf+RDBdaSlQQYEBRbhlvSPhdrECzjs/rfVsv6R3mKvvgBQe5MeixIBeOPXIXC
# oG3U1kbsNssXoZau392j3S0muySIzQTwWtybWYyFI+HW24UViybTHzM1IX+A8My9
# zrPVmOSzPAQa0FDS+llsQcchK4G7UFE+jn5fH8CbJB6y6hsMIlBNBsgeMEknLTJN
# Wv9kd4ZPaxTc6Zx+0WmXACPjY12Wl8GmGu8nhw0GHY8YlbHhV1W8P/CzIn1mlSfl
# hVsbdJ2RX5YEPq+2Hx40Gpzb6lFrWI6qlNO1lVwQ8A/2MNy+RqA=
# =ig8D
# -----END PGP SIGNATURE-----
# gpg: Signature made Sun 18 May 2025 02:21:55 AM EDT
# gpg:                using RSA key 647F28654894E3BD457199BE38DBBDC86092693E
# gpg: Can't check signature: No public key
2025-05-19 23:15:48 -04:00
Dmitry Antipov
9e7b49ce4f module: ensure that kobject_put() is safe for module type kobjects
commit a6aeb739974ec73e5217c75a7c008a688d3d5cf1 upstream.

In 'lookup_or_create_module_kobject()', an internal kobject is created
using 'module_ktype'. So call to 'kobject_put()' on error handling
path causes an attempt to use an uninitialized completion pointer in
'module_kobject_release()'. In this scenario, we just want to release
kobject without an extra synchronization required for a regular module
unloading process, so adding an extra check whether 'complete()' is
actually required makes 'kobject_put()' safe.

Reported-by: syzbot+7fb8a372e1f6add936dd@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=7fb8a372e1f6add936dd
Fixes: 942e443127 ("module: Fix mod->mkobj.kobj potentially freed too early")
Cc: stable@vger.kernel.org
Suggested-by: Petr Pavlu <petr.pavlu@suse.com>
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Link: https://lore.kernel.org/r/20250507065044.86529-1-dmantipov@yandex.ru
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-05-18 08:21:23 +02:00
Bruce Ashfield
6859883bdc This is the 6.1.138 stable release
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmgdse0ACgkQONu9yGCS
 aT5oUxAA0pyBMcYRzOUXp9VjtssDlEGv8V1FHJfUt6faamhMbUPPOjdDcS76Xm3Z
 FtXnXhaMOd7IGEc6HBWK36RNOKemgbSFsSX9V+kCCdlGWjTMGOEoBwHW+YGqN07y
 9q6K9HVUB/g0o8qbr9J8s27o1tCkDuCm9ks+XE2k7a71wMFP/menGtI0jwXbYMRv
 1BWcTaVAI6stCN4IukWwtkP/cGpT4fA1I68ds3s3r8HAreFyBJaAboXSJdthfEGr
 0HzgOm6JWQrrvUCzcOduI5DltZqmOWavRofvGjC+URp2Tpjbi+vgKLlHYxkaEwGd
 Mr2Bx1Fr5rgf9lHn7Sy9fE91OZXc8IOpwrF85zBclXABFLSkZ2lkXDAA3TmgZSrp
 erAZhR6dHfKrjTbJbxAdnhK14Jrfb/aZ4KdlzhQeCzJudtsraFx5px5y42C1s+TT
 rqr8q4xKRoQaGtvG6iaRUXaQuubAAi9b0lPvxyY3s8jFj8Aq4MbHb8xlnADAMQSc
 WWLKVrlWp1AM+nmEVtFQAil+zLd5pGY+rExFkcCYHkxUSJD/UbCD+b4wU4eQtPOz
 nUpzuYuhqXxICAPC7scyHQjn/WBwama+4x4QrJGefQ7onS9UZLxMqFooe5OxlUTW
 zTPHZh8QGVyRoEsiINJWHq52Y9rr4/8Y5eiZF3LEDjjfiLUWqSk=
 =I3EE
 -----END PGP SIGNATURE-----

Merge tag 'v6.1.138' into v6.1/standard/base

This is the 6.1.138 stable release

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmgdse0ACgkQONu9yGCS
# aT5oUxAA0pyBMcYRzOUXp9VjtssDlEGv8V1FHJfUt6faamhMbUPPOjdDcS76Xm3Z
# FtXnXhaMOd7IGEc6HBWK36RNOKemgbSFsSX9V+kCCdlGWjTMGOEoBwHW+YGqN07y
# 9q6K9HVUB/g0o8qbr9J8s27o1tCkDuCm9ks+XE2k7a71wMFP/menGtI0jwXbYMRv
# 1BWcTaVAI6stCN4IukWwtkP/cGpT4fA1I68ds3s3r8HAreFyBJaAboXSJdthfEGr
# 0HzgOm6JWQrrvUCzcOduI5DltZqmOWavRofvGjC+URp2Tpjbi+vgKLlHYxkaEwGd
# Mr2Bx1Fr5rgf9lHn7Sy9fE91OZXc8IOpwrF85zBclXABFLSkZ2lkXDAA3TmgZSrp
# erAZhR6dHfKrjTbJbxAdnhK14Jrfb/aZ4KdlzhQeCzJudtsraFx5px5y42C1s+TT
# rqr8q4xKRoQaGtvG6iaRUXaQuubAAi9b0lPvxyY3s8jFj8Aq4MbHb8xlnADAMQSc
# WWLKVrlWp1AM+nmEVtFQAil+zLd5pGY+rExFkcCYHkxUSJD/UbCD+b4wU4eQtPOz
# nUpzuYuhqXxICAPC7scyHQjn/WBwama+4x4QrJGefQ7onS9UZLxMqFooe5OxlUTW
# zTPHZh8QGVyRoEsiINJWHq52Y9rr4/8Y5eiZF3LEDjjfiLUWqSk=
# =I3EE
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri 09 May 2025 03:42:37 AM EDT
# gpg:                using RSA key 647F28654894E3BD457199BE38DBBDC86092693E
# gpg: Can't check signature: No public key
2025-05-12 16:57:10 -04:00
Jeongjun Park
441021e5b3 tracing: Fix oob write in trace_seq_to_buffer()
commit f5178c41bb43444a6008150fe6094497135d07cb upstream.

syzbot reported this bug:
==================================================================
BUG: KASAN: slab-out-of-bounds in trace_seq_to_buffer kernel/trace/trace.c:1830 [inline]
BUG: KASAN: slab-out-of-bounds in tracing_splice_read_pipe+0x6be/0xdd0 kernel/trace/trace.c:6822
Write of size 4507 at addr ffff888032b6b000 by task syz.2.320/7260

CPU: 1 UID: 0 PID: 7260 Comm: syz.2.320 Not tainted 6.15.0-rc1-syzkaller-00301-g3bde70a2c827 #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:408 [inline]
 print_report+0xc3/0x670 mm/kasan/report.c:521
 kasan_report+0xe0/0x110 mm/kasan/report.c:634
 check_region_inline mm/kasan/generic.c:183 [inline]
 kasan_check_range+0xef/0x1a0 mm/kasan/generic.c:189
 __asan_memcpy+0x3c/0x60 mm/kasan/shadow.c:106
 trace_seq_to_buffer kernel/trace/trace.c:1830 [inline]
 tracing_splice_read_pipe+0x6be/0xdd0 kernel/trace/trace.c:6822
 ....
==================================================================

It has been reported that trace_seq_to_buffer() tries to copy more data
than PAGE_SIZE to buf. Therefore, to prevent this, we should use the
smaller of trace_seq_used(&iter->seq) and PAGE_SIZE as an argument.

Link: https://lore.kernel.org/20250422113026.13308-1-aha310510@gmail.com
Reported-by: syzbot+c8cd2d2c412b868263fb@syzkaller.appspotmail.com
Fixes: 3c56819b14 ("tracing: splice support for tracing_pipe")
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Jeongjun Park <aha310510@gmail.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-05-09 09:41:36 +02:00
Bruce Ashfield
ad0735b373 This is the 6.1.136 stable release
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmgUXOIACgkQONu9yGCS
 aT4S5Q/+PSzuOyoNc1BNUJq+KbcyEY69xhYEMoq+iKE0oWLpHULcDG6u5ZZ0wzIe
 B9cwvl7HBxji3qwdyVmrE/f6mOtl0NkEAyZCKF7dPFNLcbWfiTliN0OxE2f3muwV
 0PvsdfdRF49XjyfHyoHrc7yctfQkYUAATlMQNoruyywgKwE5lqIxcTwvhkyL8Rt2
 wu4ZSR0il/GG7iYxnusGBP8hX3ovmviTgpxEcIsL5pnG6+PCuOdVP9tYYxXCvQHk
 SS6QhV3XKmldDS9uVQh1US6JZI9XWx28Ejww4+58RiMWZSBKsVtvEGUro2oCuSzF
 w+KYRI44aFBpjovASER5XkSEwGGgunT9dITRcLVvXT7YUMJ65C+LWRdh5R3hn+pj
 +ktKVgNjQ0oa9eyfH+2v5i+QBpTER/R658sdyUdrQh0lykculbFBKnpVS9r4k7KT
 9TRcBleXM4mJY2mNFPaRO1vESb/WXnArimWRg/hni4geQbkPWRjl2XOQ59DRgNgQ
 RXuglff/d3mXbez6dlKyOz3SY6GOeEMA3FvXkjmGBfldVyTrPw/HlgXYbRxHxejJ
 586gC7WoQrDAioTn9YHho8YMgZFL7Cf++oz6rEk22vOaJONDz4DY30FI5J9lMmrL
 F3HwZ/gVm84GkyCTX0lOYPalWNlYvBBoQ+goTdH5Wy8k0z2kU5M=
 =Hq+U
 -----END PGP SIGNATURE-----

Merge tag 'v6.1.136' into v6.1/standard/base

This is the 6.1.136 stable release

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmgUXOIACgkQONu9yGCS
# aT4S5Q/+PSzuOyoNc1BNUJq+KbcyEY69xhYEMoq+iKE0oWLpHULcDG6u5ZZ0wzIe
# B9cwvl7HBxji3qwdyVmrE/f6mOtl0NkEAyZCKF7dPFNLcbWfiTliN0OxE2f3muwV
# 0PvsdfdRF49XjyfHyoHrc7yctfQkYUAATlMQNoruyywgKwE5lqIxcTwvhkyL8Rt2
# wu4ZSR0il/GG7iYxnusGBP8hX3ovmviTgpxEcIsL5pnG6+PCuOdVP9tYYxXCvQHk
# SS6QhV3XKmldDS9uVQh1US6JZI9XWx28Ejww4+58RiMWZSBKsVtvEGUro2oCuSzF
# w+KYRI44aFBpjovASER5XkSEwGGgunT9dITRcLVvXT7YUMJ65C+LWRdh5R3hn+pj
# +ktKVgNjQ0oa9eyfH+2v5i+QBpTER/R658sdyUdrQh0lykculbFBKnpVS9r4k7KT
# 9TRcBleXM4mJY2mNFPaRO1vESb/WXnArimWRg/hni4geQbkPWRjl2XOQ59DRgNgQ
# RXuglff/d3mXbez6dlKyOz3SY6GOeEMA3FvXkjmGBfldVyTrPw/HlgXYbRxHxejJ
# 586gC7WoQrDAioTn9YHho8YMgZFL7Cf++oz6rEk22vOaJONDz4DY30FI5J9lMmrL
# F3HwZ/gVm84GkyCTX0lOYPalWNlYvBBoQ+goTdH5Wy8k0z2kU5M=
# =Hq+U
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri 02 May 2025 01:49:22 AM EDT
# gpg:                using RSA key 647F28654894E3BD457199BE38DBBDC86092693E
# gpg: Can't check signature: No public key
2025-05-06 11:14:05 -04:00
Alexei Starovoitov
255cbc9db7 bpf: Fix deadlock between rcu_tasks_trace and event_mutex.
[ Upstream commit 4580f4e0ebdf8dc8d506ae926b88510395a0c1d1 ]

Fix the following deadlock:
CPU A
_free_event()
  perf_kprobe_destroy()
    mutex_lock(&event_mutex)
      perf_trace_event_unreg()
        synchronize_rcu_tasks_trace()

There are several paths where _free_event() grabs event_mutex
and calls sync_rcu_tasks_trace. Above is one such case.

CPU B
bpf_prog_test_run_syscall()
  rcu_read_lock_trace()
    bpf_prog_run_pin_on_cpu()
      bpf_prog_load()
        bpf_tracing_func_proto()
          trace_set_clr_event()
            mutex_lock(&event_mutex)

Delegate trace_set_clr_event() to workqueue to avoid
such lock dependency.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20250224221637.4780-1-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-05-02 07:47:01 +02:00
Arnd Bergmann
4bf6d7defb dma/contiguous: avoid warning about unused size_bytes
[ Upstream commit d7b98ae5221007d3f202746903d4c21c7caf7ea9 ]

When building with W=1, this variable is unused for configs with
CONFIG_CMA_SIZE_SEL_PERCENTAGE=y:

kernel/dma/contiguous.c:67:26: error: 'size_bytes' defined but not used [-Werror=unused-const-variable=]

Change this to a macro to avoid the warning.

Fixes: c64be2bb1c ("drivers: add Contiguous Memory Allocator")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Link: https://lore.kernel.org/r/20250409151557.3890443-1-arnd@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-05-02 07:46:53 +02:00
Steven Rostedt
6854c87ac8 tracing: Verify event formats that have "%*p.."
[ Upstream commit ea8d7647f9ddf1f81e2027ed305299797299aa03 ]

The trace event verifier checks the formats of trace events to make sure
that they do not point at memory that is not in the trace event itself or
in data that will never be freed. If an event references data that was
allocated when the event triggered and that same data is freed before the
event is read, then the kernel can crash by reading freed memory.

The verifier runs at boot up (or module load) and scans the print formats
of the events and checks their arguments to make sure that dereferenced
pointers are safe. If the format uses "%*p.." the verifier will ignore it,
and that could be dangerous. Cover this case as well.

Also add to the sample code a use case of "%*pbl".

Link: https://lore.kernel.org/all/bcba4d76-2c3f-4d11-baf0-02905db953dd@oracle.com/

Cc: stable@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fixes: 5013f454a3 ("tracing: Add check of trace event print fmts for dereferencing pointers")
Link: https://lore.kernel.org/20250327195311.2d89ec66@gandalf.local.home
Reported-by: Libo Chen <libo.chen@oracle.com>
Reviewed-by: Libo Chen <libo.chen@oracle.com>
Tested-by: Libo Chen <libo.chen@oracle.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-05-02 07:46:49 +02:00
Thorsten Leemhuis
7c2f874c63 module: sign with sha512 instead of sha1 by default
commit f3b93547b91ad849b58eb5ab2dd070950ad7beb3 upstream.

Switch away from using sha1 for module signing by default and use the
more modern sha512 instead, which is what among others Arch, Fedora,
RHEL, and Ubuntu are currently using for their kernels.

Sha1 has not been considered secure against well-funded opponents since
2005[1]; since 2011 the NIST and other organizations furthermore
recommended its replacement[2]. This is why OpenSSL on RHEL9, Fedora
Linux 41+[3], and likely some other current and future distributions
reject the creation of sha1 signatures, which leads to a build error of
allmodconfig configurations:

  80A20474797F0000:error:03000098:digital envelope routines:do_sigver_init:invalid digest:crypto/evp/m_sigver.c:342:
  make[4]: *** [.../certs/Makefile:53: certs/signing_key.pem] Error 1
  make[4]: *** Deleting file 'certs/signing_key.pem'
  make[4]: *** Waiting for unfinished jobs....
  make[3]: *** [.../scripts/Makefile.build:478: certs] Error 2
  make[2]: *** [.../Makefile:1936: .] Error 2
  make[1]: *** [.../Makefile:224: __sub-make] Error 2
  make[1]: Leaving directory '...'
  make: *** [Makefile:224: __sub-make] Error 2

This change makes allmodconfig work again and sets a default that is
more appropriate for current and future users, too.

Link: https://www.schneier.com/blog/archives/2005/02/cryptanalysis_o.html [1]
Link: https://csrc.nist.gov/projects/hash-functions [2]
Link: https://fedoraproject.org/wiki/Changes/OpenSSLDistrustsha1SigVer [3]
Signed-off-by: Thorsten Leemhuis <linux@leemhuis.info>
Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Tested-by: kdevops <kdevops@lists.linux.dev> [0]
Link: https://github.com/linux-kdevops/linux-modules-kpd/actions/runs/11420092929/job/31775404330 [0]
Link: https://lore.kernel.org/r/52ee32c0c92afc4d3263cea1f8a1cdc809728aff.1729088288.git.linux@leemhuis.info
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-05-02 07:46:49 +02:00
Bruce Ashfield
ee3c71357c This is the 6.1.135 stable release
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmgLS1sACgkQONu9yGCS
 aT64dRAAuNws/uf11y3lncjb9gzPE0MZOuTnCrcuqxiSFYatngH3lqFhtqW6o3n/
 4izvRlH245yQsRitFZBiu06I1XiluTc7vPxCLQJuI3pa4W2DpGLv7FilFhmRVrrS
 7ehjlLD5JcHudmscV2LK7Gru1ClQwRH2eBOndNA2bVijWCXPM9ohE88ovPeogmVh
 oOnwkPWcsrsVRocTdu4SrjCGL9UZTv7QDPurEC81LHLtoIB8vK11QYsW4zf9rhDa
 TpSOGtkSSFSpuT/ZXhYesBdDwYibeC+drb2WszSPaSpFAXDuWddnOFVbSCe/im2e
 f/MhPDBfZ+c871sHWGUGCJA3otNOapO7STGD3G0dsKbS2stxmFU+HBnmY5v3WKEC
 lRwnE2OVZ6FrQ3q/aziYfyv1W6MdY2hZSUaHb77YiYUwEDDJjGYviHNtJCFP4VbD
 +wnTjI9WTH6LMM44h/XpAYDnMMPC5uou77GLir3l5hSYpjj5LrkphX+VYsobs6rB
 ShXUAux4go/+SQKETerw7M7mhnso7ghKZ7Clr87aginYYuZLTnAzwRi+1ZUbHqSd
 AjLIcXCR52qM9qE7PO4r1RkCqrgsPX1pgxZOyvfRoe/aA3iyvF1LaZS7nGKMu9g5
 5T/nnDY+BDdVmK9peXunL/2Qtafl9kwKVJ1AT+NAwTwLYR0L4AM=
 =kLlg
 -----END PGP SIGNATURE-----

Merge tag 'v6.1.135' into v6.1/standard/base

This is the 6.1.135 stable release

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmgLS1sACgkQONu9yGCS
# aT64dRAAuNws/uf11y3lncjb9gzPE0MZOuTnCrcuqxiSFYatngH3lqFhtqW6o3n/
# 4izvRlH245yQsRitFZBiu06I1XiluTc7vPxCLQJuI3pa4W2DpGLv7FilFhmRVrrS
# 7ehjlLD5JcHudmscV2LK7Gru1ClQwRH2eBOndNA2bVijWCXPM9ohE88ovPeogmVh
# oOnwkPWcsrsVRocTdu4SrjCGL9UZTv7QDPurEC81LHLtoIB8vK11QYsW4zf9rhDa
# TpSOGtkSSFSpuT/ZXhYesBdDwYibeC+drb2WszSPaSpFAXDuWddnOFVbSCe/im2e
# f/MhPDBfZ+c871sHWGUGCJA3otNOapO7STGD3G0dsKbS2stxmFU+HBnmY5v3WKEC
# lRwnE2OVZ6FrQ3q/aziYfyv1W6MdY2hZSUaHb77YiYUwEDDJjGYviHNtJCFP4VbD
# +wnTjI9WTH6LMM44h/XpAYDnMMPC5uou77GLir3l5hSYpjj5LrkphX+VYsobs6rB
# ShXUAux4go/+SQKETerw7M7mhnso7ghKZ7Clr87aginYYuZLTnAzwRi+1ZUbHqSd
# AjLIcXCR52qM9qE7PO4r1RkCqrgsPX1pgxZOyvfRoe/aA3iyvF1LaZS7nGKMu9g5
# 5T/nnDY+BDdVmK9peXunL/2Qtafl9kwKVJ1AT+NAwTwLYR0L4AM=
# =kLlg
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri 25 Apr 2025 04:44:11 AM EDT
# gpg:                using RSA key 647F28654894E3BD457199BE38DBBDC86092693E
# gpg: Can't check signature: No public key
2025-05-01 22:49:06 -04:00
Xu Kuohai
d9a807fb7c bpf: Prevent tail call between progs attached to different hooks
commit 28ead3eaab upstream.

bpf progs can be attached to kernel functions, and the attached functions
can take different parameters or return different return values. If
prog attached to one kernel function tail calls prog attached to another
kernel function, the ctx access or return value verification could be
bypassed.

For example, if prog1 is attached to func1 which takes only 1 parameter
and prog2 is attached to func2 which takes two parameters. Since verifier
assumes the bpf ctx passed to prog2 is constructed based on func2's
prototype, verifier allows prog2 to access the second parameter from
the bpf ctx passed to it. The problem is that verifier does not prevent
prog1 from passing its bpf ctx to prog2 via tail call. In this case,
the bpf ctx passed to prog2 is constructed from func1 instead of func2,
that is, the assumption for ctx access verification is bypassed.

Another example, if BPF LSM prog1 is attached to hook file_alloc_security,
and BPF LSM prog2 is attached to hook bpf_lsm_audit_rule_known. Verifier
knows the return value rules for these two hooks, e.g. it is legal for
bpf_lsm_audit_rule_known to return positive number 1, and it is illegal
for file_alloc_security to return positive number. So verifier allows
prog2 to return positive number 1, but does not allow prog1 to return
positive number. The problem is that verifier does not prevent prog1
from calling prog2 via tail call. In this case, prog2's return value 1
will be used as the return value for prog1's hook file_alloc_security.
That is, the return value rule is bypassed.

This patch adds restriction for tail call to prevent such bypasses.

Signed-off-by: Xu Kuohai <xukuohai@huawei.com>
Link: https://lore.kernel.org/r/20240719110059.797546-4-xukuohai@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
[Minor conflict resolved due to code context change.]
Signed-off-by: Jianqi Ren <jianqi.ren.cn@windriver.com>
Signed-off-by: He Zhe <zhe.he@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-04-25 10:44:03 +02:00
Andrii Nakryiko
4759acbd44 bpf: avoid holding freeze_mutex during mmap operation
commit bc27c52eea189e8f7492d40739b7746d67b65beb upstream.

We use map->freeze_mutex to prevent races between map_freeze() and
memory mapping BPF map contents with writable permissions. The way we
naively do this means we'll hold freeze_mutex for entire duration of all
the mm and VMA manipulations, which is completely unnecessary. This can
potentially also lead to deadlocks, as reported by syzbot in [0].

So, instead, hold freeze_mutex only during writeability checks, bump
(proactively) "write active" count for the map, unlock the mutex and
proceed with mmap logic. And only if something went wrong during mmap
logic, then undo that "write active" counter increment.

  [0] https://lore.kernel.org/bpf/678dcbc9.050a0220.303755.0066.GAE@google.com/

Fixes: fc9702273e ("bpf: Add mmap() support for BPF_MAP_TYPE_ARRAY")
Reported-by: syzbot+4dc041c686b7c816a71e@syzkaller.appspotmail.com
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20250129012246.1515826-2-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David Sauerwein <dssauerw@amazon.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-04-25 10:44:03 +02:00
Steven Rostedt
b4a9e164dd tracing: Fix filter string testing
commit a8c5b0ed89a3f2c81c6ae0b041394e6eea0e7024 upstream.

The filter string testing uses strncpy_from_kernel/user_nofault() to
retrieve the string to test the filter against. The if() statement was
incorrect as it considered 0 as a fault, when it is only negative that it
faulted.

Running the following commands:

  # cd /sys/kernel/tracing
  # echo "filename.ustring ~ \"/proc*\"" > events/syscalls/sys_enter_openat/filter
  # echo 1 > events/syscalls/sys_enter_openat/enable
  # ls /proc/$$/maps
  # cat trace

Would produce nothing, but with the fix it will produce something like:

      ls-1192    [007] .....  8169.828333: sys_openat(dfd: ffffffffffffff9c, filename: 7efc18359904, flags: 80000, mode: 0)

Link: https://lore.kernel.org/all/CAEf4BzbVPQ=BjWztmEwBPRKHUwNfKBkS3kce-Rzka6zvbQeVpg@mail.gmail.com/

Cc: stable@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: https://lore.kernel.org/20250417183003.505835fb@gandalf.local.home
Fixes: 77360f9bbc ("tracing: Add test for user space strings when filtering on string pointers")
Reported-by: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Reported-by: Mykyta Yatsenko <mykyta.yatsenko5@gmail.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-04-25 10:43:55 +02:00
Rafael J. Wysocki
0819b7c062 cpufreq/sched: Fix the usage of CPUFREQ_NEED_UPDATE_LIMITS
[ Upstream commit cfde542df7dd51d26cf667f4af497878ddffd85a ]

Commit 8e461a1cb43d ("cpufreq: schedutil: Fix superfluous updates caused
by need_freq_update") modified sugov_should_update_freq() to set the
need_freq_update flag only for drivers with CPUFREQ_NEED_UPDATE_LIMITS
set, but that flag generally needs to be set when the policy limits
change because the driver callback may need to be invoked for the new
limits to take effect.

However, if the return value of cpufreq_driver_resolve_freq() after
applying the new limits is still equal to the previously selected
frequency, the driver callback needs to be invoked only in the case
when CPUFREQ_NEED_UPDATE_LIMITS is set (which means that the driver
specifically wants its callback to be invoked every time the policy
limits change).

Update the code accordingly to avoid missing policy limits changes for
drivers without CPUFREQ_NEED_UPDATE_LIMITS.

Fixes: 8e461a1cb43d ("cpufreq: schedutil: Fix superfluous updates caused by need_freq_update")
Closes: https://lore.kernel.org/lkml/Z_Tlc6Qs-tYpxWYb@linaro.org/
Reported-by: Stephan Gerhold <stephan.gerhold@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Christian Loehle <christian.loehle@arm.com>
Link: https://patch.msgid.link/3010358.e9J7NaK4W3@rjwysocki.net
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-04-25 10:43:51 +02:00
zhoumin
8dd7d72803 ftrace: Add cond_resched() to ftrace_graph_set_hash()
commit 42ea22e754ba4f2b86f8760ca27f6f71da2d982c upstream.

When the kernel contains a large number of functions that can be traced,
the loop in ftrace_graph_set_hash() may take a lot of time to execute.
This may trigger the softlockup watchdog.

Add cond_resched() within the loop to allow the kernel to remain
responsive even when processing a large number of functions.

This matches the cond_resched() that is used in other locations of the
code that iterates over all functions that can be traced.

Cc: stable@vger.kernel.org
Fixes: b9b0c831be ("ftrace: Convert graph filter to use hash tables")
Link: https://lore.kernel.org/tencent_3E06CE338692017B5809534B9C5C03DA7705@qq.com
Signed-off-by: zhoumin <teczm@foxmail.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-04-25 10:43:44 +02:00
Boqun Feng
a9e4bebec6 locking/lockdep: Decrease nr_unused_locks if lock unused in zap_class()
commit 495f53d5cca0f939eaed9dca90b67e7e6fb0e30c upstream.

Currently, when a lock class is allocated, nr_unused_locks will be
increased by 1, until it gets used: nr_unused_locks will be decreased by
1 in mark_lock(). However, one scenario is missed: a lock class may be
zapped without even being used once. This could result into a situation
that nr_unused_locks != 0 but no unused lock class is active in the
system, and when `cat /proc/lockdep_stats`, a WARN_ON() will
be triggered in a CONFIG_DEBUG_LOCKDEP=y kernel:

  [...] DEBUG_LOCKS_WARN_ON(debug_atomic_read(nr_unused_locks) != nr_unused)
  [...] WARNING: CPU: 41 PID: 1121 at kernel/locking/lockdep_proc.c:283 lockdep_stats_show+0xba9/0xbd0

And as a result, lockdep will be disabled after this.

Therefore, nr_unused_locks needs to be accounted correctly at
zap_class() time.

Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Waiman Long <longman@redhat.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20250326180831.510348-1-boqun.feng@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-04-25 10:43:41 +02:00
Gabriele Paoloni
1b1828b42f tracing: fix return value in __ftrace_event_enable_disable for TRACE_REG_UNREGISTER
[ Upstream commit 0c588ac0ca6c22b774d9ad4a6594681fdfa57d9d ]

When __ftrace_event_enable_disable invokes the class callback to
unregister the event, the return value is not reported up to the
caller, hence leading to event unregister failures being silently
ignored.

This patch assigns the ret variable to the invocation of the
event unregister callback, so that its return value is stored
and reported to the caller, and it raises a warning in case
of error.

Link: https://lore.kernel.org/20250321170821.101403-1-gpaoloni@redhat.com
Signed-off-by: Gabriele Paoloni <gpaoloni@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-04-25 10:43:31 +02:00
Bruce Ashfield
64d60a5106 This is the 6.1.134 stable release
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmf3urEACgkQONu9yGCS
 aT4kow//Tfu9TmbWlqSEAsNurqAkidgAtxBghHBSDtPkr7WScCrSOK8njrK/Dt1l
 vqJn3Kp5YtU77V3Y9sJCjULzuH0fBmwYi5TU4Z0okH7kGPKwtsDkHhI5qRELUldg
 dkGSc8zwiX5Ity3G0itB7lhBK2v6Mf7lxFwIQqtQgbGGgF21MG1BgYKDYVJYU5W1
 FGlYQkITmfiw9KYlEXdjH2LsWuZc57+BE030F1mIHyl/PajqbTzdocg/IKrbaJSo
 XOeXSgfESEhj2/rl813Z1PiFsNloiPdN9DGN5v412MWq4J+qJSw++GhEUh9tS6n2
 T9L6VV+3xOeOdGuwpZ6diiE79kT1SNZofwv8Byr0AlbOrTbmOHrVz8C+OnbXGVpI
 3L6pL124OgBPwKGG+yI3y6xcUupBrsN5upHhAroHRYxwvDZZHHmf6h2EB6wSF8yA
 B0PAWY0bwZ6OeYKYovoQp9PZ0ERRgDo+w2AKronWVdMqoO1HQW61JLBB/qfTBgDc
 +de4+jBTTgm9vUNNvY/w7wo9MPyFWA5cHB4yhiTTFqrEySgeFm5ru5yHDIcLDR1a
 woVDbq2ajwWVYR5C6YdphI91Z4G2dixNXMJTsyh6LhZVGAsvBiwlehUQanPBF8zm
 GeGNTom2/Qpom8Nyd/LM4PwJXBVIBRDAgzXP+OoMryvyu/nXsms=
 =dfvE
 -----END PGP SIGNATURE-----

Merge tag 'v6.1.134' into v6.1/standard/base

This is the 6.1.134 stable release

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmf3urEACgkQONu9yGCS
# aT4kow//Tfu9TmbWlqSEAsNurqAkidgAtxBghHBSDtPkr7WScCrSOK8njrK/Dt1l
# vqJn3Kp5YtU77V3Y9sJCjULzuH0fBmwYi5TU4Z0okH7kGPKwtsDkHhI5qRELUldg
# dkGSc8zwiX5Ity3G0itB7lhBK2v6Mf7lxFwIQqtQgbGGgF21MG1BgYKDYVJYU5W1
# FGlYQkITmfiw9KYlEXdjH2LsWuZc57+BE030F1mIHyl/PajqbTzdocg/IKrbaJSo
# XOeXSgfESEhj2/rl813Z1PiFsNloiPdN9DGN5v412MWq4J+qJSw++GhEUh9tS6n2
# T9L6VV+3xOeOdGuwpZ6diiE79kT1SNZofwv8Byr0AlbOrTbmOHrVz8C+OnbXGVpI
# 3L6pL124OgBPwKGG+yI3y6xcUupBrsN5upHhAroHRYxwvDZZHHmf6h2EB6wSF8yA
# B0PAWY0bwZ6OeYKYovoQp9PZ0ERRgDo+w2AKronWVdMqoO1HQW61JLBB/qfTBgDc
# +de4+jBTTgm9vUNNvY/w7wo9MPyFWA5cHB4yhiTTFqrEySgeFm5ru5yHDIcLDR1a
# woVDbq2ajwWVYR5C6YdphI91Z4G2dixNXMJTsyh6LhZVGAsvBiwlehUQanPBF8zm
# GeGNTom2/Qpom8Nyd/LM4PwJXBVIBRDAgzXP+OoMryvyu/nXsms=
# =dfvE
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 10 Apr 2025 08:33:53 AM EDT
# gpg:                using RSA key 647F28654894E3BD457199BE38DBBDC86092693E
# gpg: Can't check signature: No public key
2025-04-13 23:10:40 -04:00
Steven Rostedt
1a84c0be74 tracing: Do not use PERF enums when perf is not defined
commit 8eb1518642738c6892bd629b46043513a3bf1a6a upstream.

An update was made to up the module ref count when a synthetic event is
registered for both trace and perf events. But if perf is not configured
in, the perf enums used will cause the kernel to fail to build.

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Douglas Raillard <douglas.raillard@arm.com>
Link: https://lore.kernel.org/20250323152151.528b5ced@batman.local.home
Fixes: 21581dd4e7ff ("tracing: Ensure module defining synth event cannot be unloaded while tracing")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202503232230.TeREVy8R-lkp@intel.com/
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-04-10 14:33:43 +02:00
Ran Xiaokai
8f4d099504 tracing/osnoise: Fix possible recursive locking for cpus_read_lock()
commit 7e6b3fcc9c5294aeafed0dbe1a09a1bc899bd0f2 upstream.

Lockdep reports this deadlock log:

osnoise: could not start sampling thread
============================================
WARNING: possible recursive locking detected
--------------------------------------------
       CPU0
       ----
  lock(cpu_hotplug_lock);
  lock(cpu_hotplug_lock);

 Call Trace:
  <TASK>
  print_deadlock_bug+0x282/0x3c0
  __lock_acquire+0x1610/0x29a0
  lock_acquire+0xcb/0x2d0
  cpus_read_lock+0x49/0x120
  stop_per_cpu_kthreads+0x7/0x60
  start_kthread+0x103/0x120
  osnoise_hotplug_workfn+0x5e/0x90
  process_one_work+0x44f/0xb30
  worker_thread+0x33e/0x5e0
  kthread+0x206/0x3b0
  ret_from_fork+0x31/0x50
  ret_from_fork_asm+0x11/0x20
  </TASK>

This is the deadlock scenario:
osnoise_hotplug_workfn()
  guard(cpus_read_lock)();      // first lock call
  start_kthread(cpu)
    if (IS_ERR(kthread)) {
      stop_per_cpu_kthreads(); {
        cpus_read_lock();      // second lock call. Cause the AA deadlock
      }
    }

It is not necessary to call stop_per_cpu_kthreads() which stops osnoise
kthread for every other CPUs in the system if a failure occurs during
hotplug of a certain CPU.
For start_per_cpu_kthreads(), if the start_kthread() call fails,
this function calls stop_per_cpu_kthreads() to handle the error.
Therefore, similarly, there is no need to call stop_per_cpu_kthreads()
again within start_kthread().
So just remove stop_per_cpu_kthreads() from start_kthread to solve this issue.

Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/20250321095249.2739397-1-ranxiaokai627@163.com
Fixes: c8895e271f ("trace/osnoise: Support hotplug operations")
Signed-off-by: Ran Xiaokai <ran.xiaokai@zte.com.cn>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-04-10 14:33:43 +02:00
Douglas Raillard
e9564aa7b8 tracing: Fix synth event printk format for str fields
commit 4d38328eb442dc06aec4350fd9594ffa6488af02 upstream.

The printk format for synth event uses "%.*s" to print string fields,
but then only passes the pointer part as var arg.

Replace %.*s with %s as the C string is guaranteed to be null-terminated.

The output in print fmt should never have been updated as __get_str()
handles the string limit because it can access the length of the string in
the string meta data that is saved in the ring buffer.

Cc: stable@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fixes: 8db4d6bfbb ("tracing: Change synthetic event string format to limit printed length")
Link: https://lore.kernel.org/20250325165202.541088-1-douglas.raillard@arm.com
Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-04-10 14:33:43 +02:00
Douglas Raillard
bb9616ba5b tracing: Ensure module defining synth event cannot be unloaded while tracing
commit 21581dd4e7ff6c07d0ab577e3c32b13a74b31522 upstream.

Currently, using synth_event_delete() will fail if the event is being
used (tracing in progress), but that is normally done in the module exit
function. At that stage, failing is problematic as returning a non-zero
status means the module will become locked (impossible to unload or
reload again).

Instead, ensure the module exit function does not get called in the
first place by increasing the module refcnt when the event is enabled.

Cc: stable@vger.kernel.org
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fixes: 35ca5207c2 ("tracing: Add synthetic event command generation functions")
Link: https://lore.kernel.org/20250318180906.226841-1-douglas.raillard@arm.com
Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-04-10 14:33:43 +02:00
Tengda Wu
a2cce54c17 tracing: Fix use-after-free in print_graph_function_flags during tracer switching
commit 7f81f27b1093e4895e87b74143c59c055c3b1906 upstream.

Kairui reported a UAF issue in print_graph_function_flags() during
ftrace stress testing [1]. This issue can be reproduced if puting a
'mdelay(10)' after 'mutex_unlock(&trace_types_lock)' in s_start(),
and executing the following script:

  $ echo function_graph > current_tracer
  $ cat trace > /dev/null &
  $ sleep 5  # Ensure the 'cat' reaches the 'mdelay(10)' point
  $ echo timerlat > current_tracer

The root cause lies in the two calls to print_graph_function_flags
within print_trace_line during each s_show():

  * One through 'iter->trace->print_line()';
  * Another through 'event->funcs->trace()', which is hidden in
    print_trace_fmt() before print_trace_line returns.

Tracer switching only updates the former, while the latter continues
to use the print_line function of the old tracer, which in the script
above is print_graph_function_flags.

Moreover, when switching from the 'function_graph' tracer to the
'timerlat' tracer, s_start only calls graph_trace_close of the
'function_graph' tracer to free 'iter->private', but does not set
it to NULL. This provides an opportunity for 'event->funcs->trace()'
to use an invalid 'iter->private'.

To fix this issue, set 'iter->private' to NULL immediately after
freeing it in graph_trace_close(), ensuring that an invalid pointer
is not passed to other tracers. Additionally, clean up the unnecessary
'iter->private = NULL' during each 'cat trace' when using wakeup and
irqsoff tracers.

 [1] https://lore.kernel.org/all/20231112150030.84609-1-ryncsn@gmail.com/

Cc: stable@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Zheng Yejian <zhengyejian1@huawei.com>
Link: https://lore.kernel.org/20250320122137.23635-1-wutengda@huaweicloud.com
Fixes: eecb91b9f9 ("tracing: Fix memleak due to race between current_tracer and trace")
Closes: https://lore.kernel.org/all/CAMgjq7BW79KDSCyp+tZHjShSzHsScSiJxn5ffskp-QzVM06fxw@mail.gmail.com/
Reported-by: Kairui Song <kasong@tencent.com>
Signed-off-by: Tengda Wu <wutengda@huaweicloud.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-04-10 14:33:43 +02:00
Waiman Long
8630709ebd locking/semaphore: Use wake_q to wake up processes outside lock critical section
[ Upstream commit 85b2b9c16d053364e2004883140538e73b333cdb ]

A circular lock dependency splat has been seen involving down_trylock():

  ======================================================
  WARNING: possible circular locking dependency detected
  6.12.0-41.el10.s390x+debug
  ------------------------------------------------------
  dd/32479 is trying to acquire lock:
  0015a20accd0d4f8 ((console_sem).lock){-.-.}-{2:2}, at: down_trylock+0x26/0x90

  but task is already holding lock:
  000000017e461698 (&zone->lock){-.-.}-{2:2}, at: rmqueue_bulk+0xac/0x8f0

  the existing dependency chain (in reverse order) is:
  -> #4 (&zone->lock){-.-.}-{2:2}:
  -> #3 (hrtimer_bases.lock){-.-.}-{2:2}:
  -> #2 (&rq->__lock){-.-.}-{2:2}:
  -> #1 (&p->pi_lock){-.-.}-{2:2}:
  -> #0 ((console_sem).lock){-.-.}-{2:2}:

The console_sem -> pi_lock dependency is due to calling try_to_wake_up()
while holding the console_sem raw_spinlock. This dependency can be broken
by using wake_q to do the wakeup instead of calling try_to_wake_up()
under the console_sem lock. This will also make the semaphore's
raw_spinlock become a terminal lock without taking any further locks
underneath it.

The hrtimer_bases.lock is a raw_spinlock while zone->lock is a
spinlock. The hrtimer_bases.lock -> zone->lock dependency happens via
the debug_objects_fill_pool() helper function in the debugobjects code.

  -> #4 (&zone->lock){-.-.}-{2:2}:
         __lock_acquire+0xe86/0x1cc0
         lock_acquire.part.0+0x258/0x630
         lock_acquire+0xb8/0xe0
         _raw_spin_lock_irqsave+0xb4/0x120
         rmqueue_bulk+0xac/0x8f0
         __rmqueue_pcplist+0x580/0x830
         rmqueue_pcplist+0xfc/0x470
         rmqueue.isra.0+0xdec/0x11b0
         get_page_from_freelist+0x2ee/0xeb0
         __alloc_pages_noprof+0x2c2/0x520
         alloc_pages_mpol_noprof+0x1fc/0x4d0
         alloc_pages_noprof+0x8c/0xe0
         allocate_slab+0x320/0x460
         ___slab_alloc+0xa58/0x12b0
         __slab_alloc.isra.0+0x42/0x60
         kmem_cache_alloc_noprof+0x304/0x350
         fill_pool+0xf6/0x450
         debug_object_activate+0xfe/0x360
         enqueue_hrtimer+0x34/0x190
         __run_hrtimer+0x3c8/0x4c0
         __hrtimer_run_queues+0x1b2/0x260
         hrtimer_interrupt+0x316/0x760
         do_IRQ+0x9a/0xe0
         do_irq_async+0xf6/0x160

Normally a raw_spinlock to spinlock dependency is not legitimate
and will be warned if CONFIG_PROVE_RAW_LOCK_NESTING is enabled,
but debug_objects_fill_pool() is an exception as it explicitly
allows this dependency for non-PREEMPT_RT kernel without causing
PROVE_RAW_LOCK_NESTING lockdep splat. As a result, this dependency is
legitimate and not a bug.

Anyway, semaphore is the only locking primitive left that is still
using try_to_wake_up() to do wakeup inside critical section, all the
other locking primitives had been migrated to use wake_q to do wakeup
outside of the critical section. It is also possible that there are
other circular locking dependencies involving printk/console_sem or
other existing/new semaphores lurking somewhere which may show up in
the future. Let just do the migration now to wake_q to avoid headache
like this.

Reported-by: yzbot+ed801a886dfdbfe7136d@syzkaller.appspotmail.com
Signed-off-by: Waiman Long <longman@redhat.com>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/20250307232717.1759087-3-boqun.feng@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-04-10 14:33:39 +02:00
Shrikanth Hegde
e73917f9e0 sched/deadline: Use online cpus for validating runtime
[ Upstream commit 14672f059d83f591afb2ee1fff56858efe055e5a ]

The ftrace selftest reported a failure because writing -1 to
sched_rt_runtime_us returns -EBUSY. This happens when the possible
CPUs are different from active CPUs.

Active CPUs are part of one root domain, while remaining CPUs are part
of def_root_domain. Since active cpumask is being used, this results in
cpus=0 when a non active CPUs is used in the loop.

Fix it by looping over the online CPUs instead for validating the
bandwidth calculations.

Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Juri Lelli <juri.lelli@redhat.com>
Link: https://lore.kernel.org/r/20250306052954.452005-2-sshegde@linux.ibm.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-04-10 14:33:39 +02:00
Feng Yang
6fc6fa800e ring-buffer: Fix bytes_dropped calculation issue
[ Upstream commit c73f0b69648501978e8b3e8fa7eef7f4197d0481 ]

The calculation of bytes-dropped and bytes_dropped_nested is reversed.
Although it does not affect the final calculation of total_dropped,
it should still be modified.

Link: https://lore.kernel.org/20250223070106.6781-1-yangfeng59949@163.com
Fixes: 6c43e554a2 ("ring-buffer: Add ring buffer startup selftest")
Signed-off-by: Feng Yang <yangfeng@kylinos.cn>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-04-10 14:33:37 +02:00
Sourabh Jain
7b9d5f73e7 kexec: initialize ELF lowest address to ULONG_MAX
[ Upstream commit 9986fb5164c8b21f6439cfd45ba36d8cc80c9710 ]

Patch series "powerpc/crash: use generic crashkernel reservation", v3.

Commit 0ab97169aa ("crash_core: add generic function to do reservation")
added a generic function to reserve crashkernel memory.  So let's use the
same function on powerpc and remove the architecture-specific code that
essentially does the same thing.

The generic crashkernel reservation also provides a way to split the
crashkernel reservation into high and low memory reservations, which can
be enabled for powerpc in the future.

Additionally move powerpc to use generic APIs to locate memory hole for
kexec segments while loading kdump kernel.

This patch (of 7):

kexec_elf_load() loads an ELF executable and sets the address of the
lowest PT_LOAD section to the address held by the lowest_load_addr
function argument.

To determine the lowest PT_LOAD address, a local variable lowest_addr
(type unsigned long) is initialized to UINT_MAX.  After loading each
PT_LOAD, its address is compared to lowest_addr.  If a loaded PT_LOAD
address is lower, lowest_addr is updated.  However, setting lowest_addr to
UINT_MAX won't work when the kernel image is loaded above 4G, as the
returned lowest PT_LOAD address would be invalid.  This is resolved by
initializing lowest_addr to ULONG_MAX instead.

This issue was discovered while implementing crashkernel high/low
reservation on the PowerPC architecture.

Link: https://lkml.kernel.org/r/20250131113830.925179-1-sourabhjain@linux.ibm.com
Link: https://lkml.kernel.org/r/20250131113830.925179-2-sourabhjain@linux.ibm.com
Fixes: a0458284f0 ("powerpc: Add support code for kexec_file_load()")
Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
Acked-by: Hari Bathini <hbathini@linux.ibm.com>
Acked-by: Baoquan He <bhe@redhat.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-04-10 14:33:36 +02:00
Hou Tao
8c6980c96d bpf: Use preempt_count() directly in bpf_send_signal_common()
[ Upstream commit b4a8b5bba712a711d8ca1f7d04646db63f9c88f5 ]

bpf_send_signal_common() uses preemptible() to check whether or not the
current context is preemptible. If it is preemptible, it will use
irq_work to send the signal asynchronously instead of trying to hold a
spin-lock, because spin-lock is sleepable under PREEMPT_RT.

However, preemptible() depends on CONFIG_PREEMPT_COUNT. When
CONFIG_PREEMPT_COUNT is turned off (e.g., CONFIG_PREEMPT_VOLUNTARY=y),
!preemptible() will be evaluated as 1 and bpf_send_signal_common() will
use irq_work unconditionally.

Fix it by unfolding "!preemptible()" and using "preempt_count() != 0 ||
irqs_disabled()" instead.

Fixes: 87c544108b61 ("bpf: Send signals asynchronously if !preemptible")
Signed-off-by: Hou Tao <houtao1@huawei.com>
Link: https://lore.kernel.org/r/20250220042259.1583319-1-houtao@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-04-10 14:33:34 +02:00
Tao Chen
214965d1a6 perf/ring_buffer: Allow the EPOLLRDNORM flag for poll
[ Upstream commit c96fff391c095c11dc87dab35be72dee7d217cde ]

The poll man page says POLLRDNORM is equivalent to POLLIN. For poll(),
it seems that if user sets pollfd with POLLRDNORM in userspace, perf_poll
will not return until timeout even if perf_output_wakeup called,
whereas POLLIN returns.

Fixes: 76369139ce ("perf: Split up buffer handling from core code")
Signed-off-by: Tao Chen <chen.dylane@linux.dev>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/20250314030036.2543180-1-chen.dylane@linux.dev
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-04-10 14:33:31 +02:00
Eric Sandeen
d40e353726 watch_queue: fix pipe accounting mismatch
[ Upstream commit f13abc1e8e1a3b7455511c4e122750127f6bc9b0 ]

Currently, watch_queue_set_size() modifies the pipe buffers charged to
user->pipe_bufs without updating the pipe->nr_accounted on the pipe
itself, due to the if (!pipe_has_watch_queue()) test in
pipe_resize_ring(). This means that when the pipe is ultimately freed,
we decrement user->pipe_bufs by something other than what than we had
charged to it, potentially leading to an underflow. This in turn can
cause subsequent too_many_pipe_buffers_soft() tests to fail with -EPERM.

To remedy this, explicitly account for the pipe usage in
watch_queue_set_size() to match the number set via account_pipe_buffers()

(It's unclear why watch_queue_set_size() does not update nr_accounted;
it may be due to intentional overprovisioning in watch_queue_set_size()?)

Fixes: e95aada4cb ("pipe: wakeup wr_wait after setting max_usage")
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Link: https://lore.kernel.org/r/206682a8-0604-49e5-8224-fdbe0c12b460@redhat.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-04-10 14:33:30 +02:00