🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
9 messages
9 total messages Started by kernel test robot Mon, 19 Oct 2026 01:46
[linus:master] [sysctl] 8d75c338f0: BUG:KASAN:slab-use-after-free_in_touch_wq_lockdep_map
#4707
Author: kernel test robot
Date: Mon, 19 Oct 2026 01:46
186 lines
17968 bytes

Hello,

kernel test robot noticed "BUG:KASAN:slab-use-after-free_in_touch_wq_lockdep_map" on:

commit: 8d75c338f0bcecaa6c9af67f86c176b67b6acf3e ("sysctl: remove CONFIG_PROC_SYSCTL, it just mirrors CONFIG_SYSCTL") https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git master

[test failed on linux-next/master b810335a0699d1810683796b0e3ffe8827ddfe6c]

in testcase: boot

config: x86_64-randconfig-2300-20261014
compiler: gcc-14
test machine: qemu-system-x86_64 -enable-kvm -cpu Haswell-noTSX,enforce -smp 4 -m 16G

(please refer to attached dmesg/kmsg for entire log/backtrace)


If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <yi1.lai@intel.com>
| Closes: https://lore.kernel.org/oe-lkp/202610190310.9737b2e3-lkp@intel.com


[   35.688893][    T1] BUG: KASAN: slab-use-after-free in touch_wq_lockdep_map (workqueue.c:4031 (discriminator 1))
[   35.688893][    T1] Read of size 8 at addr ffff8881259a2968 by task swapper/0/1
[   35.688893][    T1]
[   35.688893][    T1] CPU: 1 UID: 0 PID: 1 Comm: swapper/0 Not tainted 7.2.0-rc2-00010-g8d75c338f0bc #1 PREEMPT
[   35.688893][    T1] Call Trace:
[   35.688893][    T1]  <TASK>
[   35.688893][    T1]  dump_stack_lvl (dump_stack.c:94 dump_stack.c:120)
[   35.688893][    T1]  ? touch_wq_lockdep_map (workqueue.c:4031 (discriminator 1))
[   35.688893][    T1]  print_address_description+0x51/0x300
[   35.688893][    T1]  ? rcu_is_watching (rcu/tree.c:753 (discriminator 3))
[   35.688893][    T1]  ? touch_wq_lockdep_map (workqueue.c:4031 (discriminator 1))
[   35.688893][    T1]  print_report (kasan/report.c:482)
[   35.688893][    T1]  ? kmem_cache_debug_flags (slab.h:503)
[   35.688893][    T1]  ? fixup_red_left (slub.c:250)
[   35.688893][    T1]  ? touch_wq_lockdep_map (workqueue.c:4031 (discriminator 1))
[   35.688893][    T1]  kasan_report (kasan/report.c:595)
[   35.688893][    T1]  ? touch_wq_lockdep_map (workqueue.c:4031 (discriminator 1))
[   35.688893][    T1]  touch_wq_lockdep_map (workqueue.c:4031 (discriminator 1))
[   35.688893][    T1]  __flush_workqueue (workqueue.c:4079)
[   35.688893][    T1]  ? xa_load (xarray.c:1621)
[   35.688893][    T1]  ? tracer_preempt_on (trace/trace_irqsoff.c:686 (discriminator 1))
[   35.688893][    T1]  ? preempt_count_sub (sched/core.c:6019)
[   35.688893][    T1]  ? rcu_is_watching (rcu/tree.c:753 (discriminator 3))
[   35.688893][    T1]  ? preempt_count_sub (sched/core.c:6019)
[   35.688893][    T1]  ? touch_wq_lockdep_map (workqueue.c:4043)
[   35.688893][    T1]  ? __up_write (locking/rwsem.c:1422 (discriminator 4))
[   35.688893][    T1]  rds_ib_init (rds/ib.c:618)
[   35.688893][    T1]  rds_rdma_init (rds/rdma_transport.c:300)
[   35.688893][    T1]  ? rds_init (af_rds.c:?)
[   35.688893][    T1]  ? __raw_spin_unlock_irqrestore (linux/spinlock_api_smp.h:179 (discriminator 4))
[   35.688893][    T1]  ? add_device_randomness (linux/spinlock.h:408 char/random.c:936)
[   35.688893][    T1]  ? random_get_entropy (x86/include/asm/timex.h:11)
[   35.688893][    T1]  ? sctp_diag_init (diag.c:?)
[   35.688893][    T1]  ? rds_init (rds/af_rds.c:977)
[   35.688893][    T1]  ? rcu_is_watching (rcu/tree.c:753 (discriminator 3))
[   35.688893][    T1]  ? rds_init (af_rds.c:?)
[   35.688893][    T1]  do_one_initcall (main.c:1347)
[   35.688893][    T1]  ? trace_initcall_finish_cb (main.c:1289 (discriminator 1))
[   35.688893][    T1]  ? __kmalloc_noprof (slub.c:5363 slub.c:5387)
[   35.688893][    T1]  ? do_initcalls (linux/slab.h:973 linux/slab.h:1290 main.c:1418)
[   35.688893][    T1]  do_initcalls (main.c:1409 (discriminator 1) main.c:1425 (discriminator 1))
[   35.688893][    T1]  kernel_init_freeable (main.c:1445 main.c:1658)
[   35.688893][    T1]  ? rest_init (main.c:717)
[   35.688893][    T1]  kernel_init (main.c:1548)
[   35.688893][    T1]  ? rest_init (main.c:717)
[   35.688893][    T1]  ret_from_fork (x86/kernel/process.c:158)
[   35.688893][    T1]  ? exit_thread (x86/kernel/process.c:138)
[   35.688893][    T1]  ? __switch_to (x86/kernel/process_64.c:674)
[   35.688893][    T1]  ? rest_init (main.c:717)
[   35.688893][    T1]  ret_from_fork_asm (x86/entry/entry_64.S:245)
[   35.688893][    T1]  </TASK>
[   35.688893][    T1]
[   35.688893][    T1] Allocated by task 1 on cpu 1 at 35.661878s:
[   35.688893][    T1]  stack_trace_save (stacktrace.c:122 (discriminator 1))
[   35.688893][    T1]  kasan_save_stack (kasan/common.c:57)
[   35.688893][    T1]  kasan_save_track (kasan/common.c:78)
[   35.688893][    T1]  __kasan_kmalloc (kasan/common.c:415)
[   35.688893][    T1]  __kmalloc_noprof (linux/kasan.h:263 slub.c:5362 slub.c:5387)
[   35.688893][    T1]  __alloc_workqueue (workqueue.c:5827)
[   35.688893][    T1]  alloc_workqueue_va (workqueue.c:5946)
[   35.688893][    T1]  alloc_workqueue_noprof (workqueue.c:5962)
[   35.688893][    T1]  rds_threads_init (rds/threads.c:259 (discriminator 2))
[   35.688893][    T1]  rds_init (rds/af_rds.c:961)
[   35.688893][    T1]  do_one_initcall (main.c:1347)
[   35.688893][    T1]  do_initcalls (main.c:1409 (discriminator 1) main.c:1425 (discriminator 1))
[   35.688893][    T1]  kernel_init_freeable (main.c:1445 main.c:1658)
[   35.688893][    T1]  kernel_init (main.c:1548)
[   35.688893][    T1]  ret_from_fork (x86/kernel/process.c:158)
[   35.688893][    T1]  ret_from_fork_asm (x86/entry/entry_64.S:245)
[   35.688893][    T1]
[   35.688893][    T1] Freed by task 0 on cpu 3 at 35.674112s:
[   35.688893][    T1]  stack_trace_save (stacktrace.c:122 (discriminator 1))
[   35.688893][    T1]  kasan_save_stack (kasan/common.c:57)
[   35.688893][    T1]  kasan_save_track (kasan/common.c:78)
[   35.688893][    T1]  kasan_save_free_info (kasan/generic.c:584)
[   35.688893][    T1]  __kasan_slab_free (kasan/common.c:285)
[   35.688893][    T1]  kfree (linux/kasan.h:235 slub.c:2705 slub.c:6405 slub.c:6720)
[   35.688893][    T1]  rcu_do_batch (rcu/tree.c:2645)
[   35.688893][    T1]  rcu_core (rcu/tree.c:2897)
[   35.688893][    T1]  handle_softirqs (softirq.c:622)
[   35.688893][    T1]  __irq_exit_rcu (softirq.c:496 softirq.c:735)
[   35.688893][    T1]  irq_exit_rcu (softirq.c:752)
[   35.688893][    T1]  sysvec_apic_timer_interrupt (x86/kernel/apic/apic.c:1062 (discriminator 35) x86/kernel/apic/apic.c:1062 (discriminator 35))
[   35.688893][    T1]  asm_sysvec_apic_timer_interrupt (x86/include/asm/idtentry.h:546)
[   35.688893][    T1]
[   35.688893][    T1] Last potentially related work creation:
[   35.688893][    T1]  stack_trace_save (stacktrace.c:122 (discriminator 1))
[   35.688893][    T1]  kasan_save_stack (kasan/common.c:57)
[   35.688893][    T1]  kasan_record_aux_stack (kasan/generic.c:556)
[   35.688893][    T1]  __call_rcu_common+0xe6/0x480
[   35.688893][    T1]  kthread_worker_fn (kthread.c:1025)
[   35.688893][    T1]  kthread (kthread.c:436)
[   35.688893][    T1]  ret_from_fork (x86/kernel/process.c:158)
[   35.688893][    T1]  ret_from_fork_asm (x86/entry/entry_64.S:245)
[   35.688893][    T1]
[   35.688893][    T1] The buggy address belongs to the object at ffff8881259a2800
[   35.688893][    T1]  which belongs to the cache kmalloc-1k of size 1024
[   35.688893][    T1] The buggy address belongs to the object at ffff8881259a2800
[   35.688893][    T1]  which belongs to the cache kmalloc-1k of size 1024
[   35.688893][    T1] The buggy address belongs to the object at ffff8881259a2800
[   35.688893][    T1]  which belongs to the cache kmalloc-1k of size 1024
[   35.688893][    T1] The buggy address is located 360 bytes inside of
[   35.688893][    T1]  freed 1024-byte region [ffff8881259a2800, ffff8881259a2c00)
[   35.688893][    T1] The buggy address is located 360 bytes inside of
[   35.688893][    T1]  freed 1024-byte region [ffff8881259a2800, ffff8881259a2c00)
[   35.688893][    T1] The buggy address is located 360 bytes inside of
[   35.688893][    T1]  freed 1024-byte region [ffff8881259a2800, ffff8881259a2c00)
[   35.688893][    T1]
[   35.688893][    T1] The buggy address belongs to the physical page:
[   35.688893][    T1] page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1259a0
[   35.688893][    T1] head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
[   35.688893][    T1] flags: 0x4000000000000040(head|zone=2)
[   35.688893][    T1] page_type: f5(slab)
[   35.688893][    T1] raw: 4000000000000040 ffff888100042dc0 dead000000000100 dead000000000122
[   35.688893][    T1] raw: 0000000000000000 0000000800100010 00000000f5000000 0000000000000000
[   35.688893][    T1] head: 4000000000000040 ffff888100042dc0 dead000000000100 dead000000000122
[   35.688893][    T1] head: 0000000000000000 0000000800100010 00000000f5000000 0000000000000000
[   35.688893][    T1] head: 4000000000000003 ffffea0004966801 00000000ffffffff 00000000ffffffff
[   35.688893][    T1] head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000008
[   35.688893][    T1] page dumped because: kasan: bad access detected
[   35.688893][    T1]
[   35.688893][    T1] Memory state around the buggy address:
[   35.688893][    T1]  ffff8881259a2800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[   35.688893][    T1]  ffff8881259a2880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[   35.688893][    T1] >ffff8881259a2900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[   35.688893][    T1]                                                           ^
[   35.688893][    T1]  ffff8881259a2980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[   35.688893][    T1]  ffff8881259a2a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[   35.688893][    T1] ==================================================================
[   35.984299][    T1] Disabling lock debugging due to kernel taint
[   35.987548][    T1] Oops: general protection fault, probably for non-canonical address 0xe0a07c0ec0000008: 0000 [#1] SMP KASAN
[   35.988482][    T1] KASAN: maybe wild-memory-access in range [0x0504007600000040-0x0504007600000047]
[   35.988482][    T1] CPU: 1 UID: 0 PID: 1 Comm: swapper/0 Tainted: G    B               7.2.0-rc2-00010-g8d75c338f0bc #1 PREEMPT
[   35.988482][    T1] Tainted: [B]=BAD_PAGE
[   35.988482][    T1] RIP: 0010:do_raw_spin_lock (locking/spinlock_debug.c:86 (discriminator 2) locking/spinlock_debug.c:115 (discriminator 2))
[   35.988482][    T1] Code: 3b 58 81 49 8d 14 04 c7 02 f1 f1 f1 f1 c7 42 04 04 f3 f3 f3 65 48 8b 15 f0 53 f7 08 48 89 54 24 60 31 d2 48 89 fa 48 c1 ea 03 <8a> 14 02 48 89 f8 83 e0 07 83 c0 03 38 d0 7c 09 84 d2 74 05 e8 39
All code
========
   0:	3b 58 81             	cmp    -0x7f(%rax),%ebx
   3:	49 8d 14 04          	lea    (%r12,%rax,1),%rdx
   7:	c7 02 f1 f1 f1 f1    	movl   $0xf1f1f1f1,(%rdx)
   d:	c7 42 04 04 f3 f3 f3 	movl   $0xf3f3f304,0x4(%rdx)
  14:	65 48 8b 15 f0 53 f7 	mov    %gs:0x8f753f0(%rip),%rdx        # 0x8f7540c
  1b:	08 
  1c:	48 89 54 24 60       	mov    %rdx,0x60(%rsp)
  21:	31 d2                	xor    %edx,%edx
  23:	48 89 fa             	mov    %rdi,%rdx
  26:	48 c1 ea 03          	shr    $0x3,%rdx
  2a:*	8a 14 02             	mov    (%rdx,%rax,1),%dl		<-- trapping instruction
  2d:	48 89 f8             	mov    %rdi,%rax
  30:	83 e0 07             	and    $0x7,%eax


The kernel config and materials to reproduce are available at:
https://download.01.org/0day-ci/archive/20261019/202610190310.9737b2e3-lkp@intel.com



--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [linus:master] [sysctl] 8d75c338f0: BUG:KASAN:slab-use-after-free_in_touch_wq_lockdep_map
#4918
Author: Joel Granados
Date: Mon, 19 Oct 2026 13:30
310 lines
20111 bytes
--gtyamw44t6vsb6kc
Content-Type: text/plain; protected-headers=v1; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Subject: Re: [linus:master] [sysctl]  8d75c338f0:
 BUG:KASAN:slab-use-after-free_in_touch_wq_lockdep_map
MIME-Version: 1.0

On Mon, Oct 19, 2026 at 01:41:05PM +0200, Oleg Nesterov wrote:
> On 10/19, kernel test robot wrote:
> >
> >
> > Hello,
> >
> > kernel test robot noticed "BUG:KASAN:slab-use-after-free_in_touch_wq_lo=
ckdep_map" on:
> >
> > commit: 8d75c338f0bcecaa6c9af67f86c176b67b6acf3e ("sysctl: remove CONFI=
G_PROC_SYSCTL, it just mirrors CONFIG_SYSCTL") https://git.kernel.org/cgit/=
linux/kernel/git/torvalds/linux.git master
>=20
> I don't think that commit could cause such a problem. Please re-check.
>=20
> Oleg.

That commit might not be the one that introduces the UAF, but it might
be the one that exposes it?

You have CONFIG_SYSCTL=3Dn & CONFIG_RDS=3Dy & CONFIG_RDS_RDMA=3Dy.
Therefore rds_sysctl_init() returns -ENOMEM  and rds_ib_sysctl_init
returns -ENOMEM.

If rds_ib_sysctl_init is called after a failed rds_sysctl_init, then
rds_ib_sysctl_init would call a flush_workqueue on a rds_wq that has
already been freed by the failed rds_sysctl_init. Right?

Please let me know if I missed anything.

Best

>=20
> > [test failed on linux-next/master b810335a0699d1810683796b0e3ffe8827ddf=
e6c]
> >
> > in testcase: boot
> >
> > config: x86_64-randconfig-2300-20261014
> > compiler: gcc-14
> > test machine: qemu-system-x86_64 -enable-kvm -cpu Haswell-noTSX,enforce=
 -smp 4 -m 16G
> >
> > (please refer to attached dmesg/kmsg for entire log/backtrace)
> >
> >
> > If you fix the issue in a separate patch/commit (i.e. not just a new ve=
rsion of the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <yi1.lai@intel.com>
> > | Closes: https://lore.kernel.org/oe-lkp/202610190310.9737b2e3-lkp@inte=
l.com
> >
> >
> > [   35.688893][    T1] BUG: KASAN: slab-use-after-free in touch_wq_lock=
dep_map (workqueue.c:4031 (discriminator 1))
> > [   35.688893][    T1] Read of size 8 at addr ffff8881259a2968 by task =
swapper/0/1
> > [   35.688893][    T1]
> > [   35.688893][    T1] CPU: 1 UID: 0 PID: 1 Comm: swapper/0 Not tainted=
 7.2.0-rc2-00010-g8d75c338f0bc #1 PREEMPT
> > [   35.688893][    T1] Call Trace:
> > [   35.688893][    T1]  <TASK>
> > [   35.688893][    T1]  dump_stack_lvl (dump_stack.c:94 dump_stack.c:12=
0)
> > [   35.688893][    T1]  ? touch_wq_lockdep_map (workqueue.c:4031 (discr=
iminator 1))
> > [   35.688893][    T1]  print_address_description+0x51/0x300
> > [   35.688893][    T1]  ? rcu_is_watching (rcu/tree.c:753 (discriminato=
r 3))
> > [   35.688893][    T1]  ? touch_wq_lockdep_map (workqueue.c:4031 (discr=
iminator 1))
> > [   35.688893][    T1]  print_report (kasan/report.c:482)
> > [   35.688893][    T1]  ? kmem_cache_debug_flags (slab.h:503)
> > [   35.688893][    T1]  ? fixup_red_left (slub.c:250)
> > [   35.688893][    T1]  ? touch_wq_lockdep_map (workqueue.c:4031 (discr=
iminator 1))
> > [   35.688893][    T1]  kasan_report (kasan/report.c:595)
> > [   35.688893][    T1]  ? touch_wq_lockdep_map (workqueue.c:4031 (discr=
iminator 1))
> > [   35.688893][    T1]  touch_wq_lockdep_map (workqueue.c:4031 (discrim=
inator 1))
> > [   35.688893][    T1]  __flush_workqueue (workqueue.c:4079)
> > [   35.688893][    T1]  ? xa_load (xarray.c:1621)
> > [   35.688893][    T1]  ? tracer_preempt_on (trace/trace_irqsoff.c:686 =
(discriminator 1))
> > [   35.688893][    T1]  ? preempt_count_sub (sched/core.c:6019)
> > [   35.688893][    T1]  ? rcu_is_watching (rcu/tree.c:753 (discriminato=
r 3))
> > [   35.688893][    T1]  ? preempt_count_sub (sched/core.c:6019)
> > [   35.688893][    T1]  ? touch_wq_lockdep_map (workqueue.c:4043)
> > [   35.688893][    T1]  ? __up_write (locking/rwsem.c:1422 (discriminat=
or 4))
> > [   35.688893][    T1]  rds_ib_init (rds/ib.c:618)
> > [   35.688893][    T1]  rds_rdma_init (rds/rdma_transport.c:300)
> > [   35.688893][    T1]  ? rds_init (af_rds.c:?)
> > [   35.688893][    T1]  ? __raw_spin_unlock_irqrestore (linux/spinlock_=
api_smp.h:179 (discriminator 4))
> > [   35.688893][    T1]  ? add_device_randomness (linux/spinlock.h:408 c=
har/random.c:936)
> > [   35.688893][    T1]  ? random_get_entropy (x86/include/asm/timex.h:1=
1)
> > [   35.688893][    T1]  ? sctp_diag_init (diag.c:?)
> > [   35.688893][    T1]  ? rds_init (rds/af_rds.c:977)
> > [   35.688893][    T1]  ? rcu_is_watching (rcu/tree.c:753 (discriminato=
r 3))
> > [   35.688893][    T1]  ? rds_init (af_rds.c:?)
> > [   35.688893][    T1]  do_one_initcall (main.c:1347)
> > [   35.688893][    T1]  ? trace_initcall_finish_cb (main.c:1289 (discri=
minator 1))
> > [   35.688893][    T1]  ? __kmalloc_noprof (slub.c:5363 slub.c:5387)
> > [   35.688893][    T1]  ? do_initcalls (linux/slab.h:973 linux/slab.h:1=
290 main.c:1418)
> > [   35.688893][    T1]  do_initcalls (main.c:1409 (discriminator 1) mai=
n.c:1425 (discriminator 1))
> > [   35.688893][    T1]  kernel_init_freeable (main.c:1445 main.c:1658)
> > [   35.688893][    T1]  ? rest_init (main.c:717)
> > [   35.688893][    T1]  kernel_init (main.c:1548)
> > [   35.688893][    T1]  ? rest_init (main.c:717)
> > [   35.688893][    T1]  ret_from_fork (x86/kernel/process.c:158)
> > [   35.688893][    T1]  ? exit_thread (x86/kernel/process.c:138)
> > [   35.688893][    T1]  ? __switch_to (x86/kernel/process_64.c:674)
> > [   35.688893][    T1]  ? rest_init (main.c:717)
> > [   35.688893][    T1]  ret_from_fork_asm (x86/entry/entry_64.S:245)
> > [   35.688893][    T1]  </TASK>
> > [   35.688893][    T1]
> > [   35.688893][    T1] Allocated by task 1 on cpu 1 at 35.661878s:
> > [   35.688893][    T1]  stack_trace_save (stacktrace.c:122 (discriminat=
or 1))
> > [   35.688893][    T1]  kasan_save_stack (kasan/common.c:57)
> > [   35.688893][    T1]  kasan_save_track (kasan/common.c:78)
> > [   35.688893][    T1]  __kasan_kmalloc (kasan/common.c:415)
> > [   35.688893][    T1]  __kmalloc_noprof (linux/kasan.h:263 slub.c:5362=
 slub.c:5387)
> > [   35.688893][    T1]  __alloc_workqueue (workqueue.c:5827)
> > [   35.688893][    T1]  alloc_workqueue_va (workqueue.c:5946)
> > [   35.688893][    T1]  alloc_workqueue_noprof (workqueue.c:5962)
> > [   35.688893][    T1]  rds_threads_init (rds/threads.c:259 (discrimina=
tor 2))
> > [   35.688893][    T1]  rds_init (rds/af_rds.c:961)
> > [   35.688893][    T1]  do_one_initcall (main.c:1347)
> > [   35.688893][    T1]  do_initcalls (main.c:1409 (discriminator 1) mai=
n.c:1425 (discriminator 1))
> > [   35.688893][    T1]  kernel_init_freeable (main.c:1445 main.c:1658)
> > [   35.688893][    T1]  kernel_init (main.c:1548)
> > [   35.688893][    T1]  ret_from_fork (x86/kernel/process.c:158)
> > [   35.688893][    T1]  ret_from_fork_asm (x86/entry/entry_64.S:245)
> > [   35.688893][    T1]
> > [   35.688893][    T1] Freed by task 0 on cpu 3 at 35.674112s:
> > [   35.688893][    T1]  stack_trace_save (stacktrace.c:122 (discriminat=
or 1))
> > [   35.688893][    T1]  kasan_save_stack (kasan/common.c:57)
> > [   35.688893][    T1]  kasan_save_track (kasan/common.c:78)
> > [   35.688893][    T1]  kasan_save_free_info (kasan/generic.c:584)
> > [   35.688893][    T1]  __kasan_slab_free (kasan/common.c:285)
> > [   35.688893][    T1]  kfree (linux/kasan.h:235 slub.c:2705 slub.c:640=
5 slub.c:6720)
> > [   35.688893][    T1]  rcu_do_batch (rcu/tree.c:2645)
> > [   35.688893][    T1]  rcu_core (rcu/tree.c:2897)
> > [   35.688893][    T1]  handle_softirqs (softirq.c:622)
> > [   35.688893][    T1]  __irq_exit_rcu (softirq.c:496 softirq.c:735)
> > [   35.688893][    T1]  irq_exit_rcu (softirq.c:752)
> > [   35.688893][    T1]  sysvec_apic_timer_interrupt (x86/kernel/apic/ap=
ic.c:1062 (discriminator 35) x86/kernel/apic/apic.c:1062 (discriminator 35))
> > [   35.688893][    T1]  asm_sysvec_apic_timer_interrupt (x86/include/as=
m/idtentry.h:546)
> > [   35.688893][    T1]
> > [   35.688893][    T1] Last potentially related work creation:
> > [   35.688893][    T1]  stack_trace_save (stacktrace.c:122 (discriminat=
or 1))
> > [   35.688893][    T1]  kasan_save_stack (kasan/common.c:57)
> > [   35.688893][    T1]  kasan_record_aux_stack (kasan/generic.c:556)
> > [   35.688893][    T1]  __call_rcu_common+0xe6/0x480
> > [   35.688893][    T1]  kthread_worker_fn (kthread.c:1025)
> > [   35.688893][    T1]  kthread (kthread.c:436)
> > [   35.688893][    T1]  ret_from_fork (x86/kernel/process.c:158)
> > [   35.688893][    T1]  ret_from_fork_asm (x86/entry/entry_64.S:245)
> > [   35.688893][    T1]
> > [   35.688893][    T1] The buggy address belongs to the object at ffff8=
881259a2800
> > [   35.688893][    T1]  which belongs to the cache kmalloc-1k of size 1=
024
> > [   35.688893][    T1] The buggy address belongs to the object at ffff8=
881259a2800
> > [   35.688893][    T1]  which belongs to the cache kmalloc-1k of size 1=
024
> > [   35.688893][    T1] The buggy address belongs to the object at ffff8=
881259a2800
> > [   35.688893][    T1]  which belongs to the cache kmalloc-1k of size 1=
024
> > [   35.688893][    T1] The buggy address is located 360 bytes inside of
> > [   35.688893][    T1]  freed 1024-byte region [ffff8881259a2800, ffff8=
881259a2c00)
> > [   35.688893][    T1] The buggy address is located 360 bytes inside of
> > [   35.688893][    T1]  freed 1024-byte region [ffff8881259a2800, ffff8=
881259a2c00)
> > [   35.688893][    T1] The buggy address is located 360 bytes inside of
> > [   35.688893][    T1]  freed 1024-byte region [ffff8881259a2800, ffff8=
881259a2c00)
> > [   35.688893][    T1]
> > [   35.688893][    T1] The buggy address belongs to the physical page:
> > [   35.688893][    T1] page: refcount:0 mapcount:0 mapping:000000000000=
0000 index:0x0 pfn:0x1259a0
> > [   35.688893][    T1] head: order:3 mapcount:0 entire_mapcount:0 nr_pa=
ges_mapped:0 pincount:0
> > [   35.688893][    T1] flags: 0x4000000000000040(head|zone=3D2)
> > [   35.688893][    T1] page_type: f5(slab)
> > [   35.688893][    T1] raw: 4000000000000040 ffff888100042dc0 dead00000=
0000100 dead000000000122
> > [   35.688893][    T1] raw: 0000000000000000 0000000800100010 00000000f=
5000000 0000000000000000
> > [   35.688893][    T1] head: 4000000000000040 ffff888100042dc0 dead0000=
00000100 dead000000000122
> > [   35.688893][    T1] head: 0000000000000000 0000000800100010 00000000=
f5000000 0000000000000000
> > [   35.688893][    T1] head: 4000000000000003 ffffea0004966801 00000000=
ffffffff 00000000ffffffff
> > [   35.688893][    T1] head: ffffffffffffffff 0000000000000000 00000000=
ffffffff 0000000000000008
> > [   35.688893][    T1] page dumped because: kasan: bad access detected
> > [   35.688893][    T1]
> > [   35.688893][    T1] Memory state around the buggy address:
> > [   35.688893][    T1]  ffff8881259a2800: fa fb fb fb fb fb fb fb fb fb=
 fb fb fb fb fb fb
> > [   35.688893][    T1]  ffff8881259a2880: fb fb fb fb fb fb fb fb fb fb=
 fb fb fb fb fb fb
> > [   35.688893][    T1] >ffff8881259a2900: fb fb fb fb fb fb fb fb fb fb=
 fb fb fb fb fb fb
> > [   35.688893][    T1]                                                 =
          ^
> > [   35.688893][    T1]  ffff8881259a2980: fb fb fb fb fb fb fb fb fb fb=
 fb fb fb fb fb fb
> > [   35.688893][    T1]  ffff8881259a2a00: fb fb fb fb fb fb fb fb fb fb=
 fb fb fb fb fb fb
> > [   35.688893][    T1] =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> > [   35.984299][    T1] Disabling lock debugging due to kernel taint
> > [   35.987548][    T1] Oops: general protection fault, probably for non=
-canonical address 0xe0a07c0ec0000008: 0000 [#1] SMP KASAN
> > [   35.988482][    T1] KASAN: maybe wild-memory-access in range [0x0504=
007600000040-0x0504007600000047]
> > [   35.988482][    T1] CPU: 1 UID: 0 PID: 1 Comm: swapper/0 Tainted: G =
   B               7.2.0-rc2-00010-g8d75c338f0bc #1 PREEMPT
> > [   35.988482][    T1] Tainted: [B]=3DBAD_PAGE
> > [   35.988482][    T1] RIP: 0010:do_raw_spin_lock (locking/spinlock_deb=
ug.c:86 (discriminator 2) locking/spinlock_debug.c:115 (discriminator 2))
> > [   35.988482][    T1] Code: 3b 58 81 49 8d 14 04 c7 02 f1 f1 f1 f1 c7 =
42 04 04 f3 f3 f3 65 48 8b 15 f0 53 f7 08 48 89 54 24 60 31 d2 48 89 fa 48 =
c1 ea 03 <8a> 14 02 48 89 f8 83 e0 07 83 c0 03 38 d0 7c 09 84 d2 74 05 e8 39
> > All code
> > =3D=3D=3D=3D=3D=3D=3D=3D
> >    0:	3b 58 81             	cmp    -0x7f(%rax),%ebx
> >    3:	49 8d 14 04          	lea    (%r12,%rax,1),%rdx
> >    7:	c7 02 f1 f1 f1 f1    	movl   $0xf1f1f1f1,(%rdx)
> >    d:	c7 42 04 04 f3 f3 f3 	movl   $0xf3f3f304,0x4(%rdx)
> >   14:	65 48 8b 15 f0 53 f7 	mov    %gs:0x8f753f0(%rip),%rdx        # 0x=
8f7540c
> >   1b:	08
> >   1c:	48 89 54 24 60       	mov    %rdx,0x60(%rsp)
> >   21:	31 d2                	xor    %edx,%edx
> >   23:	48 89 fa             	mov    %rdi,%rdx
> >   26:	48 c1 ea 03          	shr    $0x3,%rdx
> >   2a:*	8a 14 02             	mov    (%rdx,%rax,1),%dl		<-- trapping ins=
truction
> >   2d:	48 89 f8             	mov    %rdi,%rax
> >   30:	83 e0 07             	and    $0x7,%eax
> >
> >
> > The kernel config and materials to reproduce are available at:
> > https://download.01.org/0day-ci/archive/20261019/202610190310.9737b2e3-=
lkp@intel.com
> >
> >
> >
> > --
> > 0-DAY CI Kernel Test Service
> > https://github.com/intel/lkp-tests/wiki
> >
> >
>=20

--gtyamw44t6vsb6kc
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQGzBAABCgAdFiEErkcJVyXmMSXOyyeQupfNUreWQU8FAmrWG4AACgkQupfNUreW
QU8mxAv9FFUJjonmOF7nanICguFqqGq9Xg6KqQrZJ1S5TlS2EiV0RRzUUJ1ia+Ss
iSRdKbxrAQ5ZZ1zkClsu4t2veTdQdp7IFsEme/GQTYMAC43ZM6ecMBmagXqJhbex
EN8Lgxbrc10uCUJj99idhNF9RkMSs/f1LvP6aTMMKnzVbkDSvCetAMW4Rfto4JZD
baU85UcdHYsqHl17EIRfvfcIsZRU4rE6hJ+vkjnxECq/TbobGjkcTa4kqBR++99/
Jo/FNaY8jOUa/T0F2Fv1ko0nLnH2rmhPW+ZEZohJL/xDuWiWH2oB32KP39gSJw7G
r5KBPfj9z3vlo+gMEPvEzyXgDuHv+OyrEo9/oNAXyiDsz8WRqDS4Cghkg+vYClHt
NhUx1s25PDAXOSzmo63VltaNoLtOqfqBXRlPH84ZJwE+m8tvXCio27hD3WQK2oHj
py7mCApD3N8XAu1YrMxhIw8PrmyW8PD7vjYp0pn3wg45qEgQMtk8ysRnP9KknaDl
T0WKlhS9
=C1Lz
-----END PGP SIGNATURE-----

--gtyamw44t6vsb6kc--
Re: [linus:master] [sysctl] 8d75c338f0: BUG:KASAN:slab-use-after-free_in_touch_wq_lockdep_map
#5121
Author: Allison Henderson
Date: Mon, 19 Oct 2026 19:52
176 lines
12997 bytes
On Mon, 2026-10-19 at 17:35 +0200, Oleg Nesterov wrote:
> On 10/19, Oleg Nesterov wrote:

Hi Oleg, Joel,

Thanks for running this down.  Agreed we shouldn't just fail to init because
sysctl is off.  Some comments below:


> > 
> > But. rds_init() can also fail even if CONFIG_SYSCTL=y, after
> > rds_sysctl_init(), so to me this looks like a bug in net/rds/.
> > 
Yes that's a separate bug, so I'll send a separate fix for that.

> > 
> > In any case, I guess net/rds/ init paths should not fail if
> > CONFIG_SYSCTL=n ?
> 
> So I think that something like the uncompiled/untested patch below makes
> sense anyway even if doesn't fix all the potential problems with rds_wq.
> 
> What do you think?
> 
> Oleg.
> ---
> 
> diff --git a/net/rds/ib_sysctl.c b/net/rds/ib_sysctl.c
> index 2af678e71e3c..bccdb5c4df1d 100644
> --- a/net/rds/ib_sysctl.c
> +++ b/net/rds/ib_sysctl.c
> @@ -36,19 +36,10 @@
>  
>  #include "ib.h"
>  
> -static struct ctl_table_header *rds_ib_sysctl_hdr;
> -
>  unsigned long rds_ib_sysctl_max_send_wr = RDS_IB_DEFAULT_SEND_WR;
>  unsigned long rds_ib_sysctl_max_recv_wr = RDS_IB_DEFAULT_RECV_WR;
>  unsigned long rds_ib_sysctl_max_recv_allocation = (128 * 1024 * 1024) / RDS_FRAG_SIZE;
> -static unsigned long rds_ib_sysctl_max_wr_min = 1;
> -/* hardware will fail CQ creation long before this */
> -static unsigned long rds_ib_sysctl_max_wr_max = (u32)~0;
> -
>  unsigned long rds_ib_sysctl_max_unsig_wrs = 16;
> -static unsigned long rds_ib_sysctl_max_unsig_wr_min = 1;
> -static unsigned long rds_ib_sysctl_max_unsig_wr_max = 64;
> -
>  /*
>   * This sysctl does nothing.
>   *
> @@ -61,6 +52,14 @@ static unsigned long rds_ib_sysctl_max_unsig_wr_max = 64;
>   */
>  unsigned int rds_ib_sysctl_flow_control = 0;
>  
> +#ifdef CONFIG_SYSCTL
> +static unsigned long rds_ib_sysctl_max_wr_min = 1;
> +/* hardware will fail CQ creation long before this */
> +static unsigned long rds_ib_sysctl_max_wr_max = (u32)~0;
> +
> +static unsigned long rds_ib_sysctl_max_unsig_wr_min = 1;
> +static unsigned long rds_ib_sysctl_max_unsig_wr_max = 64;
> +
>  static struct ctl_table rds_ib_sysctl_table[] = {
>  	{
>  		.procname       = "max_send_wr",
> @@ -105,6 +104,8 @@ static struct ctl_table rds_ib_sysctl_table[] = {
>  	},
>  };
>  
> +static struct ctl_table_header *rds_ib_sysctl_hdr;
> +
>  void rds_ib_sysctl_exit(void)
>  {
>  	if (rds_ib_sysctl_hdr)
> @@ -118,3 +119,15 @@ int rds_ib_sysctl_init(void)
>  		return -ENOMEM;
>  	return 0;
>  }


The real rds_sysctl_init() also does the runtime setup of
rds_sysctl_reconnect_min_jiffies (msecs_to_jiffies(1)).  Without
it, the reconnect back off is lost.

Also, if register_net_sysctl_sz() returns NULL in rds_tcp_init_net(),
it fails as an -ENOMEM.  So RDS/TCP would still fail to come up with
CONFIG_SYSCTL=n.  A simpler fix might be to just handle the NULL at the
three call sites, e.g.:

        rds_sysctl_reg_table =
                register_net_sysctl(&init_net, "net/rds", rds_sysctl_rds_table);
        if (!rds_sysctl_reg_table && IS_ENABLED(CONFIG_SYSCTL))
                return -ENOMEM;

And same for rds_ib_sysctl_init() and rds_tcp_init_net().  The exit
paths are ok, since unregister_net_sysctl_table() is already a
no-op stub when sysctl is off.

Let me know if you want to respin or if you'd rather I send it.
Either way is fine with me.

Thanks
Allison

> +
> +#else
> +
> +void rds_ib_sysctl_exit(void)
> +{
> +}
> +
> +int rds_ib_sysctl_init(void)
> +{
> +	return 0;
> +}
> +#endif
> diff --git a/net/rds/sysctl.c b/net/rds/sysctl.c
> index 025f518a4349..a0673a41633a 100644
> --- a/net/rds/sysctl.c
> +++ b/net/rds/sysctl.c
> @@ -36,11 +36,6 @@
>  
>  #include "rds.h"
>  
> -static struct ctl_table_header *rds_sysctl_reg_table;
> -
> -static unsigned long rds_sysctl_reconnect_min = 1;
> -static unsigned long rds_sysctl_reconnect_max = ~0UL;
> -
>  unsigned long rds_sysctl_reconnect_min_jiffies;
>  unsigned long rds_sysctl_reconnect_max_jiffies = HZ;
>  
> @@ -49,6 +44,10 @@ unsigned int  rds_sysctl_max_unacked_bytes = (16 << 20);
>  
>  unsigned int rds_sysctl_ping_enable = 1;
>  
> +#ifdef CONFIG_SYSCTL
> +static unsigned long rds_sysctl_reconnect_min = 1;
> +static unsigned long rds_sysctl_reconnect_max = ~0UL;
> +
>  static struct ctl_table rds_sysctl_rds_table[] = {
>  	{
>  		.procname       = "reconnect_min_delay_ms",
> @@ -91,6 +90,8 @@ static struct ctl_table rds_sysctl_rds_table[] = {
>  	},
>  };
>  
> +static struct ctl_table_header *rds_sysctl_reg_table;
> +
>  void rds_sysctl_exit(void)
>  {
>  	unregister_net_sysctl_table(rds_sysctl_reg_table);
> @@ -107,3 +108,15 @@ int rds_sysctl_init(void)
>  		return -ENOMEM;
>  	return 0;
>  }
> +
> +#else
> +
> +void rds_sysctl_exit(void)
> +{
> +}
> +
> +int rds_sysctl_init(void)
> +{
> +	return 0;
> +}
> +#endif
> 
Re: [linus:master] [sysctl] 8d75c338f0: BUG:KASAN:slab-use-after-free_in_touch_wq_lockdep_map
#5350
Author: Joel Granados
Date: Tue, 20 Oct 2026 07:55
108 lines
11449 bytes
--a42qtuqnvg7yxrg6
Content-Type: text/plain; protected-headers=v1; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Subject: Re: [linus:master] [sysctl]  8d75c338f0:
 BUG:KASAN:slab-use-after-free_in_touch_wq_lockdep_map
MIME-Version: 1.0

On Mon, Oct 19, 2026 at 04:49:55PM +0200, Oleg Nesterov wrote:
> On 10/19, Joel Granados wrote:
> >
> > On Mon, Oct 19, 2026 at 01:41:05PM +0200, Oleg Nesterov wrote:
> > > On 10/19, kernel test robot wrote:
> > > >
> > > >
> > > > Hello,
> > > >
> > > > kernel test robot noticed "BUG:KASAN:slab-use-after-free_in_touch_w=
q_lockdep_map" on:
> > > >
> > > > commit: 8d75c338f0bcecaa6c9af67f86c176b67b6acf3e ("sysctl: remove C=
ONFIG_PROC_SYSCTL, it just mirrors CONFIG_SYSCTL") https://git.kernel.org/c=
git/linux/kernel/git/torvalds/linux.git master
> > >
> > > I don't think that commit could cause such a problem. Please re-check.
> > >
> > > Oleg.
> >
> > That commit might not be the one that introduces the UAF, but it might
> > be the one that exposes it?
> >
> > You have CONFIG_SYSCTL=3Dn & CONFIG_RDS=3Dy & CONFIG_RDS_RDMA=3Dy.
> > Therefore rds_sysctl_init() returns -ENOMEM  and rds_ib_sysctl_init
> > returns -ENOMEM.
> >
> > If rds_ib_sysctl_init is called after a failed rds_sysctl_init, then
> > rds_ib_sysctl_init would call a flush_workqueue on a rds_wq that has
> > already been freed by the failed rds_sysctl_init. Right?
> >
> > Please let me know if I missed anything.
>=20
> I think you are right...
>=20
> rds_init() does
>=20
> 	rds_threads_init()
> 		rds_wq =3D create_singlethread_workqueue("krdsd");
>=20
> 	rds_sysctl_init()
> 		fails due to CONFIG_SYSCTL=3Dn
>=20
> 	out_threads:
> 		destroy_workqueue(rds_wq);
>=20
> After that any access to rds_wq is wrong.
>=20
> If rds_rdma_init() runs after that, rds_ib_init() will call
> rds_ib_unregister_client() -> flush_workqueue(rds_wq).
>=20
> And this will equally happen before the blamed commit 8d75c338f0bc,
> just you need CONFIG_PROC_SYSCTL=3Dn instead of CONFIG_SYSCTL=3Dn.
>=20
>=20
> But. rds_init() can also fail even if CONFIG_SYSCTL=3Dy, after
> rds_sysctl_init(), so to me this looks like a bug in net/rds/.
>=20
>=20
> In any case, I guess net/rds/ init paths should not fail if
> CONFIG_SYSCTL=3Dn ?

That is up to net/rds.=20

The question is: do you have to fail if a sysctl registration fails? Or
another way to ask it is: Can't it (net/rds or others) run while not
being tuned or queried through sysctl?

If the answer to these questions is that the sysctl path is necessary,
then the failure is reasonable. But if they can work without the sysctl,
the failure is an overreaction (IMO).

Best


>=20
> Oleg.
>=20

--a42qtuqnvg7yxrg6
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQGzBAABCgAdFiEErkcJVyXmMSXOyyeQupfNUreWQU8FAmrXHlsACgkQupfNUreW
QU912gv/eejjrtoxUgh51UagvsJXA0SMOI6Yaa+uIBcExUpCjVRcUBjhj2jT/GV9
JRJK0zb9dOeEg4yIm/bzf4j3qYwBTqiRdVf5++8HB9yuqIx4w0NlVIbks9Q8YDQh
QRXDBUAUoP6FxYb3jE1U49avWB37mPqj986qpNiwwqXq9nIRDKDf/9sPY/b2Vvyn
RibI+hOi7hfCSUntOsrbN7NmOtV9e1FQtHZxCjHpdz51bQqn1S84/WJ0dDgy+RUT
J1sLIQsUlmxKtJ78VYmaCPUJ+owrm3mFNvzmw2ERplHoA2JqT3r6lY1jP2G5Xi8y
pRSKsCTfoRUgVrXh6yByuK/2ywuqzfTEneUTJ4F97bLgJClP+4FtYcUjnbZOvsrm
l/VWLpeaTxFHDiDWu/rJ+K9YFs8JcsnTtmJqJ/pLJAW/IjvQ5sQsT6P+d04LgWQJ
fRYc1/dcsViZ1Bz/LUpV4NWsMtqP70EPbjuvvPYA5GG5HRM1bj6x4hHL2e9gGsQ5
vMczI+dC
=OX/2
-----END PGP SIGNATURE-----

--a42qtuqnvg7yxrg6--
Re: [linus:master] [sysctl] 8d75c338f0: BUG:KASAN:slab-use-after-free_in_touch_wq_lockdep_map
#5371
Author: Joel Granados
Date: Tue, 20 Oct 2026 09:06
219 lines
14444 bytes
--pcvh7stf5trtufk4
Content-Type: text/plain; protected-headers=v1; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Subject: Re: [linus:master] [sysctl]  8d75c338f0:
 BUG:KASAN:slab-use-after-free_in_touch_wq_lockdep_map
MIME-Version: 1.0

On Mon, Oct 19, 2026 at 05:35:54PM +0200, Oleg Nesterov wrote:
> On 10/19, Oleg Nesterov wrote:
> >
> > But. rds_init() can also fail even if CONFIG_SYSCTL=3Dy, after
> > rds_sysctl_init(), so to me this looks like a bug in net/rds/.
> >
> >
> > In any case, I guess net/rds/ init paths should not fail if
> > CONFIG_SYSCTL=3Dn ?
>=20
> So I think that something like the uncompiled/untested patch below makes
> sense anyway even if doesn't fix all the potential problems with rds_wq.
>=20
> What do you think?

That is a good option. I also did not compile not test it, but guarding
the error inside an ifdef would work and is a pattern that is used
elsewhere.

You can also do this (also untested and not compiled):

diff --git i/net/rds/ib_sysctl.c w/net/rds/ib_sysctl.c
index 2af678e71e3c6..bc97a3eecad69 100644
--- i/net/rds/ib_sysctl.c
+++ w/net/rds/ib_sysctl.c
@@ -114,7 +114,7 @@ void rds_ib_sysctl_exit(void)
 int rds_ib_sysctl_init(void)
 {
        rds_ib_sysctl_hdr =3D register_net_sysctl(&init_net, "net/rds/ib", =
rds_ib_sysctl_table);
-       if (!rds_ib_sysctl_hdr)
+       if (!rds_ib_sysctl_hdr && IS_ENABLED(CONFIG_SYSCTL))
                return -ENOMEM;
        return 0;
 }
diff --git i/net/rds/sysctl.c w/net/rds/sysctl.c
index 025f518a43495..41c65b98c94bd 100644
--- i/net/rds/sysctl.c
+++ w/net/rds/sysctl.c
@@ -93,7 +93,8 @@ static struct ctl_table rds_sysctl_rds_table[] =3D {

 void rds_sysctl_exit(void)
 {
-       unregister_net_sysctl_table(rds_sysctl_reg_table);
+       if (rds_sysctl_reg_table)
+               unregister_net_sysctl_table(rds_sysctl_reg_table);
 }

 int rds_sysctl_init(void)
@@ -103,7 +104,7 @@ int rds_sysctl_init(void)

        rds_sysctl_reg_table =3D
                register_net_sysctl(&init_net, "net/rds", rds_sysctl_rds_ta=
ble);
-       if (!rds_sysctl_reg_table)
+       if (!rds_sysctl_reg_table && IS_ENABLED(CONFIG_SYSCTL))
                return -ENOMEM;
        return 0;
 }


Both are ok IMO.

Best

>=20
> Oleg.
> ---
>=20
> diff --git a/net/rds/ib_sysctl.c b/net/rds/ib_sysctl.c
> index 2af678e71e3c..bccdb5c4df1d 100644
> --- a/net/rds/ib_sysctl.c
> +++ b/net/rds/ib_sysctl.c
> @@ -36,19 +36,10 @@
> =20
>  #include "ib.h"
> =20
> -static struct ctl_table_header *rds_ib_sysctl_hdr;
> -
>  unsigned long rds_ib_sysctl_max_send_wr =3D RDS_IB_DEFAULT_SEND_WR;
>  unsigned long rds_ib_sysctl_max_recv_wr =3D RDS_IB_DEFAULT_RECV_WR;
>  unsigned long rds_ib_sysctl_max_recv_allocation =3D (128 * 1024 * 1024) =
/ RDS_FRAG_SIZE;
> -static unsigned long rds_ib_sysctl_max_wr_min =3D 1;
> -/* hardware will fail CQ creation long before this */
> -static unsigned long rds_ib_sysctl_max_wr_max =3D (u32)~0;
> -
>  unsigned long rds_ib_sysctl_max_unsig_wrs =3D 16;
> -static unsigned long rds_ib_sysctl_max_unsig_wr_min =3D 1;
> -static unsigned long rds_ib_sysctl_max_unsig_wr_max =3D 64;
> -
>  /*
>   * This sysctl does nothing.
>   *
> @@ -61,6 +52,14 @@ static unsigned long rds_ib_sysctl_max_unsig_wr_max =
=3D 64;
>   */
>  unsigned int rds_ib_sysctl_flow_control =3D 0;
> =20
> +#ifdef CONFIG_SYSCTL
> +static unsigned long rds_ib_sysctl_max_wr_min =3D 1;
> +/* hardware will fail CQ creation long before this */
> +static unsigned long rds_ib_sysctl_max_wr_max =3D (u32)~0;
> +
> +static unsigned long rds_ib_sysctl_max_unsig_wr_min =3D 1;
> +static unsigned long rds_ib_sysctl_max_unsig_wr_max =3D 64;
> +
>  static struct ctl_table rds_ib_sysctl_table[] =3D {
>  	{
>  		.procname       =3D "max_send_wr",
> @@ -105,6 +104,8 @@ static struct ctl_table rds_ib_sysctl_table[] =3D {
>  	},
>  };
> =20
> +static struct ctl_table_header *rds_ib_sysctl_hdr;
> +
>  void rds_ib_sysctl_exit(void)
>  {
>  	if (rds_ib_sysctl_hdr)
> @@ -118,3 +119,15 @@ int rds_ib_sysctl_init(void)
>  		return -ENOMEM;
>  	return 0;
>  }
> +
> +#else
> +
> +void rds_ib_sysctl_exit(void)
> +{
> +}
> +
> +int rds_ib_sysctl_init(void)
> +{
> +	return 0;
> +}
> +#endif
> diff --git a/net/rds/sysctl.c b/net/rds/sysctl.c
> index 025f518a4349..a0673a41633a 100644
> --- a/net/rds/sysctl.c
> +++ b/net/rds/sysctl.c
> @@ -36,11 +36,6 @@
> =20
>  #include "rds.h"
> =20
> -static struct ctl_table_header *rds_sysctl_reg_table;
> -
> -static unsigned long rds_sysctl_reconnect_min =3D 1;
> -static unsigned long rds_sysctl_reconnect_max =3D ~0UL;
> -
>  unsigned long rds_sysctl_reconnect_min_jiffies;
>  unsigned long rds_sysctl_reconnect_max_jiffies =3D HZ;
> =20
> @@ -49,6 +44,10 @@ unsigned int  rds_sysctl_max_unacked_bytes =3D (16 << =
20);
> =20
>  unsigned int rds_sysctl_ping_enable =3D 1;
> =20
> +#ifdef CONFIG_SYSCTL
> +static unsigned long rds_sysctl_reconnect_min =3D 1;
> +static unsigned long rds_sysctl_reconnect_max =3D ~0UL;
> +
>  static struct ctl_table rds_sysctl_rds_table[] =3D {
>  	{
>  		.procname       =3D "reconnect_min_delay_ms",
> @@ -91,6 +90,8 @@ static struct ctl_table rds_sysctl_rds_table[] =3D {
>  	},
>  };
> =20
> +static struct ctl_table_header *rds_sysctl_reg_table;
> +
>  void rds_sysctl_exit(void)
>  {
>  	unregister_net_sysctl_table(rds_sysctl_reg_table);
> @@ -107,3 +108,15 @@ int rds_sysctl_init(void)
>  		return -ENOMEM;
>  	return 0;
>  }
> +
> +#else
> +
> +void rds_sysctl_exit(void)
> +{
> +}
> +
> +int rds_sysctl_init(void)
> +{
> +	return 0;
> +}
> +#endif
>=20

--pcvh7stf5trtufk4
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQGzBAABCgAdFiEErkcJVyXmMSXOyyeQupfNUreWQU8FAmrXLwMACgkQupfNUreW
QU9Yjwv/cCHjunDrXXsuyNvatzPDExXb5X0UzfkQLy2qA3coR/DKb4c6DSrxHAXb
KpHrt6e9QT0I2SPoxXj4PltCuUz848uz0awIUBqnTzndf0VHj3hXQlnOzH0fZ65b
Wn0qAyxnEitEIbt1uSa7Xq24CfbATRcSjtPthG34yTnbF733Fz4lvwVkXbJi4TPl
uoyvrPEcXxnogCVN0W9XNu8u5UHk0CuHOFVj13NvhFcoykqRQbMQcpefAKpJzm2Y
0yUyZK+zZ2CyFchpYt4khOGyW5RLiwV0d1kER0UKqD9lnH4cznErsgqU0tb34Rn1
Xig5W0V/rLLEemKlyC6sdnq1ZeigxxSHlwcRUVMt1UOsECTmaTfaTaO79R2BVLSU
y8a8NvfPWzuASlTcNMV+AT03DA/syjvh2OihVN7ec7ExnUAdfEmpibahUar/MDZA
bBMHemB+kEmt61+nBWc6VAsa6/WJEzxKtDaaR4rMdSuyi20EQBPQsryOF1YPAYRT
Lm5E7bEc
=mg3e
-----END PGP SIGNATURE-----

--pcvh7stf5trtufk4--
Re: [linus:master] [sysctl] 8d75c338f0: BUG:KASAN:slab-use-after-free_in_touch_wq_lockdep_map
#5438
Author: Joel Granados
Date: Tue, 20 Oct 2026 10:43
211 lines
14682 bytes
--k5tdk5zotfl6lrfn
Content-Type: text/plain; protected-headers=v1; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Subject: Re: [linus:master] [sysctl]  8d75c338f0:
 BUG:KASAN:slab-use-after-free_in_touch_wq_lockdep_map
MIME-Version: 1.0

On Mon, Oct 19, 2026 at 12:52:58PM -0700, Allison Henderson wrote:
> On Mon, 2026-10-19 at 17:35 +0200, Oleg Nesterov wrote:
> > On 10/19, Oleg Nesterov wrote:
>=20
> Hi Oleg, Joel,
>=20
> Thanks for running this down.  Agreed we shouldn't just fail to init beca=
use
> sysctl is off.  Some comments below:
>=20
>=20
> > >=20
> > > But. rds_init() can also fail even if CONFIG_SYSCTL=3Dy, after
> > > rds_sysctl_init(), so to me this looks like a bug in net/rds/.
> > >=20
> Yes that's a separate bug, so I'll send a separate fix for that.
>=20
> > >=20
> > > In any case, I guess net/rds/ init paths should not fail if
> > > CONFIG_SYSCTL=3Dn ?
> >=20
> > So I think that something like the uncompiled/untested patch below makes
> > sense anyway even if doesn't fix all the potential problems with rds_wq.
> >=20
> > What do you think?
> >=20
> > Oleg.
> > ---
> >=20
> > diff --git a/net/rds/ib_sysctl.c b/net/rds/ib_sysctl.c
> > index 2af678e71e3c..bccdb5c4df1d 100644
> > --- a/net/rds/ib_sysctl.c
> > +++ b/net/rds/ib_sysctl.c
> > @@ -36,19 +36,10 @@
> > =20
> >  #include "ib.h"
> > =20
> > -static struct ctl_table_header *rds_ib_sysctl_hdr;
> > -
> >  unsigned long rds_ib_sysctl_max_send_wr =3D RDS_IB_DEFAULT_SEND_WR;
> >  unsigned long rds_ib_sysctl_max_recv_wr =3D RDS_IB_DEFAULT_RECV_WR;
> >  unsigned long rds_ib_sysctl_max_recv_allocation =3D (128 * 1024 * 1024=
) / RDS_FRAG_SIZE;
> > -static unsigned long rds_ib_sysctl_max_wr_min =3D 1;
> > -/* hardware will fail CQ creation long before this */
> > -static unsigned long rds_ib_sysctl_max_wr_max =3D (u32)~0;
> > -
> >  unsigned long rds_ib_sysctl_max_unsig_wrs =3D 16;
> > -static unsigned long rds_ib_sysctl_max_unsig_wr_min =3D 1;
> > -static unsigned long rds_ib_sysctl_max_unsig_wr_max =3D 64;
> > -
> >  /*
> >   * This sysctl does nothing.
> >   *
> > @@ -61,6 +52,14 @@ static unsigned long rds_ib_sysctl_max_unsig_wr_max =
=3D 64;
> >   */
> >  unsigned int rds_ib_sysctl_flow_control =3D 0;
> > =20
> > +#ifdef CONFIG_SYSCTL
> > +static unsigned long rds_ib_sysctl_max_wr_min =3D 1;
> > +/* hardware will fail CQ creation long before this */
> > +static unsigned long rds_ib_sysctl_max_wr_max =3D (u32)~0;
> > +
> > +static unsigned long rds_ib_sysctl_max_unsig_wr_min =3D 1;
> > +static unsigned long rds_ib_sysctl_max_unsig_wr_max =3D 64;
> > +
> >  static struct ctl_table rds_ib_sysctl_table[] =3D {
> >  	{
> >  		.procname       =3D "max_send_wr",
> > @@ -105,6 +104,8 @@ static struct ctl_table rds_ib_sysctl_table[] =3D {
> >  	},
> >  };
> > =20
> > +static struct ctl_table_header *rds_ib_sysctl_hdr;
> > +
> >  void rds_ib_sysctl_exit(void)
> >  {
> >  	if (rds_ib_sysctl_hdr)
> > @@ -118,3 +119,15 @@ int rds_ib_sysctl_init(void)
> >  		return -ENOMEM;
> >  	return 0;
> >  }
>=20
>=20
> The real rds_sysctl_init() also does the runtime setup of
> rds_sysctl_reconnect_min_jiffies (msecs_to_jiffies(1)).  Without
> it, the reconnect back off is lost.
>=20
> Also, if register_net_sysctl_sz() returns NULL in rds_tcp_init_net(),
> it fails as an -ENOMEM.  So RDS/TCP would still fail to come up with
> CONFIG_SYSCTL=3Dn.  A simpler fix might be to just handle the NULL at the
> three call sites, e.g.:
>=20
>         rds_sysctl_reg_table =3D
>                 register_net_sysctl(&init_net, "net/rds", rds_sysctl_rds_=
table);
>         if (!rds_sysctl_reg_table && IS_ENABLED(CONFIG_SYSCTL))
>                 return -ENOMEM;
>=20

Remember to NULL check rds_sysctl_reg_table in rds_sysctl_exit(). You
might hit another UAF on exit if you don't.

> And same for rds_ib_sysctl_init() and rds_tcp_init_net().  The exit
> paths are ok, since unregister_net_sysctl_table() is already a
> no-op stub when sysctl is off.
>=20
> Let me know if you want to respin or if you'd rather I send it.
> Either way is fine with me.
>=20
> Thanks
> Allison
>=20
> > +
> > +#else
> > +
> > +void rds_ib_sysctl_exit(void)
> > +{
> > +}
> > +
> > +int rds_ib_sysctl_init(void)
> > +{
> > +	return 0;
> > +}
> > +#endif
> > diff --git a/net/rds/sysctl.c b/net/rds/sysctl.c
> > index 025f518a4349..a0673a41633a 100644
> > --- a/net/rds/sysctl.c
> > +++ b/net/rds/sysctl.c
> > @@ -36,11 +36,6 @@
> > =20
> >  #include "rds.h"
> > =20
> > -static struct ctl_table_header *rds_sysctl_reg_table;
> > -
> > -static unsigned long rds_sysctl_reconnect_min =3D 1;
> > -static unsigned long rds_sysctl_reconnect_max =3D ~0UL;
> > -
> >  unsigned long rds_sysctl_reconnect_min_jiffies;
> >  unsigned long rds_sysctl_reconnect_max_jiffies =3D HZ;
> > =20
> > @@ -49,6 +44,10 @@ unsigned int  rds_sysctl_max_unacked_bytes =3D (16 <=
< 20);
> > =20
> >  unsigned int rds_sysctl_ping_enable =3D 1;
> > =20
> > +#ifdef CONFIG_SYSCTL
> > +static unsigned long rds_sysctl_reconnect_min =3D 1;
> > +static unsigned long rds_sysctl_reconnect_max =3D ~0UL;
> > +
> >  static struct ctl_table rds_sysctl_rds_table[] =3D {
> >  	{
> >  		.procname       =3D "reconnect_min_delay_ms",
> > @@ -91,6 +90,8 @@ static struct ctl_table rds_sysctl_rds_table[] =3D {
> >  	},
> >  };
> > =20
> > +static struct ctl_table_header *rds_sysctl_reg_table;
> > +
> >  void rds_sysctl_exit(void)
> >  {
> >  	unregister_net_sysctl_table(rds_sysctl_reg_table);
> > @@ -107,3 +108,15 @@ int rds_sysctl_init(void)
> >  		return -ENOMEM;
> >  	return 0;
> >  }
> > +
> > +#else
> > +
> > +void rds_sysctl_exit(void)
> > +{
> > +}
> > +
> > +int rds_sysctl_init(void)
> > +{
> > +	return 0;
> > +}
> > +#endif
> >=20
>=20

--k5tdk5zotfl6lrfn
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQGzBAABCgAdFiEErkcJVyXmMSXOyyeQupfNUreWQU8FAmrXRcEACgkQupfNUreW
QU9Vmwv+KABo8H66uC9zN+BIViG4BwkS+VmBjReZy2Xda/8BJbPnZtceZTHzD5Ah
UF/ntsWhxPNxWXpFluBxUWIbKVYnsLJ1H54JDOpS8on7zUQrAXCIB+fmHZJifIPu
dcpKfBKioVGOmFVlN/7W64s1aH/xwzxUUCAsIGPZZVdydRAhpVS6mISEhlJotNmx
dFDs9gMrdzltPNynitoyutyKYPAQh0qTnligX2Z2BXdxj8i1TCI/vzxhDD0FLtFp
zOFM5NmzrpOx9e0h3/GE42v3djnMRsgnlF45j5GTMs3udYCgPtNnqOA/MUq4fcRv
zYZgcKTrBGqqh0NMDlpXK7kB6dd25vv5a6SjyY32O+Bux12h0EF93Nk3mzFTuzZ3
zGyY13cNu5JMe2AaiZGuyKcnhZoHo5zGACHxsEWXcg69sfX98L/ubPy0w0Gj12sq
Alg/jYPMLj9LF+fA4qJNzY1oyNNBdWLpBRw/kUu4pB3LjvjZ5bVrobXcQmR2XvPQ
TNlrjkC5
=a2kQ
-----END PGP SIGNATURE-----

--k5tdk5zotfl6lrfn--
Re: [linus:master] [sysctl] 8d75c338f0: BUG:KASAN:slab-use-after-free_in_touch_wq_lockdep_map
#5455
Author: Joel Granados
Date: Tue, 20 Oct 2026 10:51
523 lines
24432 bytes
--2q5pjfxl3jaesakr
Content-Type: text/plain; protected-headers=v1; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Subject: Re: [linus:master] [sysctl]  8d75c338f0:
 BUG:KASAN:slab-use-after-free_in_touch_wq_lockdep_map
MIME-Version: 1.0

On Tue, Oct 20, 2026 at 11:12:21AM +0200, Oleg Nesterov wrote:
> Hi Allison,
>=20
> On 10/19, Allison Henderson wrote:
> >
> > The real rds_sysctl_init() also does the runtime setup of
> > rds_sysctl_reconnect_min_jiffies (msecs_to_jiffies(1)).  Without
> > it, the reconnect back off is lost.
>=20
> Yes, thanks, I missed that.
>=20
> > Also, if register_net_sysctl_sz() returns NULL in rds_tcp_init_net(),
> > it fails as an -ENOMEM.  So RDS/TCP would still fail to come up with
> > CONFIG_SYSCTL=3Dn.
>=20
> Yes, I didn't even try to grep other files.
>=20
> Hmm. I am m just curious how difficult it is to create a "complete" patch
> which puts all the sysctl-related code under ifdef(SYSCTL)... May be some=
thing
> like below but I don't understand net/rds, most probably it is wrong and =
I am
> not sure it makes a lot of sense. Plus I have not idea how to test it.
>=20
> > A simpler fix might be to just handle the NULL at the
> > three call sites, e.g.:
> >
> >         rds_sysctl_reg_table =3D
> >                 register_net_sysctl(&init_net, "net/rds", rds_sysctl_rd=
s_table);
> >         if (!rds_sysctl_reg_table && IS_ENABLED(CONFIG_SYSCTL))
> >                 return -ENOMEM;
>=20
> Yes, I thought about a simpler patch too. Perhaps just
>=20
> 	--- x/net/rds/Kconfig
> 	+++ x/net/rds/Kconfig
> 	@@ -2,7 +2,7 @@
> 	=20
> 	 config RDS
> 		tristate "The Reliable Datagram Sockets Protocol"
> 	-	depends on INET
> 	+	depends on INET && SYSCTL
> 		help
> 		  The RDS (Reliable Datagram Sockets) protocol provides reliable,
> 		  sequenced delivery of datagrams over Infiniband or TCP.
>=20
> for the start? CONFIG_SYSCTL=3Dn is not a common case.
Indeed CONFIG_SYSCTL=3Dn is not common. On the other hand why would RDS
depend on SYSCTL being configured in? Shouldn't RDS just work with
default values when CONFIG_SYSCTL=3Dn?

Best

>=20
> > Let me know if you want to respin or if you'd rather I send it.
> > Either way is fine with me.
>=20
> Allison, up to you. Whatever you prefer.
>=20
> Oleg.
> ---
>=20
>=20
> diff --git a/net/rds/ib_sysctl.c b/net/rds/ib_sysctl.c
> index 2af678e71e3c..bccdb5c4df1d 100644
> --- a/net/rds/ib_sysctl.c
> +++ b/net/rds/ib_sysctl.c
> @@ -36,19 +36,10 @@
> =20
>  #include "ib.h"
> =20
> -static struct ctl_table_header *rds_ib_sysctl_hdr;
> -
>  unsigned long rds_ib_sysctl_max_send_wr =3D RDS_IB_DEFAULT_SEND_WR;
>  unsigned long rds_ib_sysctl_max_recv_wr =3D RDS_IB_DEFAULT_RECV_WR;
>  unsigned long rds_ib_sysctl_max_recv_allocation =3D (128 * 1024 * 1024) =
/ RDS_FRAG_SIZE;
> -static unsigned long rds_ib_sysctl_max_wr_min =3D 1;
> -/* hardware will fail CQ creation long before this */
> -static unsigned long rds_ib_sysctl_max_wr_max =3D (u32)~0;
> -
>  unsigned long rds_ib_sysctl_max_unsig_wrs =3D 16;
> -static unsigned long rds_ib_sysctl_max_unsig_wr_min =3D 1;
> -static unsigned long rds_ib_sysctl_max_unsig_wr_max =3D 64;
> -
>  /*
>   * This sysctl does nothing.
>   *
> @@ -61,6 +52,14 @@ static unsigned long rds_ib_sysctl_max_unsig_wr_max =
=3D 64;
>   */
>  unsigned int rds_ib_sysctl_flow_control =3D 0;
> =20
> +#ifdef CONFIG_SYSCTL
> +static unsigned long rds_ib_sysctl_max_wr_min =3D 1;
> +/* hardware will fail CQ creation long before this */
> +static unsigned long rds_ib_sysctl_max_wr_max =3D (u32)~0;
> +
> +static unsigned long rds_ib_sysctl_max_unsig_wr_min =3D 1;
> +static unsigned long rds_ib_sysctl_max_unsig_wr_max =3D 64;
> +
>  static struct ctl_table rds_ib_sysctl_table[] =3D {
>  	{
>  		.procname       =3D "max_send_wr",
> @@ -105,6 +104,8 @@ static struct ctl_table rds_ib_sysctl_table[] =3D {
>  	},
>  };
> =20
> +static struct ctl_table_header *rds_ib_sysctl_hdr;
> +
>  void rds_ib_sysctl_exit(void)
>  {
>  	if (rds_ib_sysctl_hdr)
> @@ -118,3 +119,15 @@ int rds_ib_sysctl_init(void)
>  		return -ENOMEM;
>  	return 0;
>  }
> +
> +#else
> +
> +void rds_ib_sysctl_exit(void)
> +{
> +}
> +
> +int rds_ib_sysctl_init(void)
> +{
> +	return 0;
> +}
> +#endif
> diff --git a/net/rds/sysctl.c b/net/rds/sysctl.c
> index 025f518a4349..47e8782b1aa3 100644
> --- a/net/rds/sysctl.c
> +++ b/net/rds/sysctl.c
> @@ -36,11 +36,6 @@
> =20
>  #include "rds.h"
> =20
> -static struct ctl_table_header *rds_sysctl_reg_table;
> -
> -static unsigned long rds_sysctl_reconnect_min =3D 1;
> -static unsigned long rds_sysctl_reconnect_max =3D ~0UL;
> -
>  unsigned long rds_sysctl_reconnect_min_jiffies;
>  unsigned long rds_sysctl_reconnect_max_jiffies =3D HZ;
> =20
> @@ -49,6 +44,10 @@ unsigned int  rds_sysctl_max_unacked_bytes =3D (16 << =
20);
> =20
>  unsigned int rds_sysctl_ping_enable =3D 1;
> =20
> +#ifdef CONFIG_SYSCTL
> +static unsigned long rds_sysctl_reconnect_min =3D 1;
> +static unsigned long rds_sysctl_reconnect_max =3D ~0UL;
> +
>  static struct ctl_table rds_sysctl_rds_table[] =3D {
>  	{
>  		.procname       =3D "reconnect_min_delay_ms",
> @@ -91,6 +90,8 @@ static struct ctl_table rds_sysctl_rds_table[] =3D {
>  	},
>  };
> =20
> +static struct ctl_table_header *rds_sysctl_reg_table;
> +
>  void rds_sysctl_exit(void)
>  {
>  	unregister_net_sysctl_table(rds_sysctl_reg_table);
> @@ -107,3 +108,16 @@ int rds_sysctl_init(void)
>  		return -ENOMEM;
>  	return 0;
>  }
> +
> +#else
> +
> +int rds_sysctl_init(void)
> +{
> +	rds_sysctl_reconnect_min_jiffies =3D msecs_to_jiffies(1);
> +	return 0;
> +}
> +
> +void rds_sysctl_exit(void)
> +{
> +}
> +#endif
> diff --git a/net/rds/tcp.c b/net/rds/tcp.c
> index 774a71f88d37..372899a2ec81 100644
> --- a/net/rds/tcp.c
> +++ b/net/rds/tcp.c
> @@ -53,13 +53,71 @@ static atomic_t rds_tcp_unloading =3D ATOMIC_INIT(0);
> =20
>  static struct kmem_cache *rds_tcp_conn_slab;
> =20
> +#ifdef CONFIG_SYSCTL
> +static int rds_tcp_min_sndbuf =3D SOCK_MIN_SNDBUF;
> +static int rds_tcp_min_rcvbuf =3D SOCK_MIN_RCVBUF;
> +
> +/* when sysctl is used to modify some kernel socket parameters,this
> + * function  resets the RDS connections in that netns  so that we can
> + * restart with new parameters.  The assumption is that such reset
> + * events are few and far-between.
> + */
> +static void rds_tcp_sysctl_reset(struct net *net)
> +{
> +	struct rds_tcp_connection *tc, *_tc;
> +
> +	spin_lock_irq(&rds_tcp_conn_lock);
> +	list_for_each_entry_safe(tc, _tc, &rds_tcp_conn_list, t_tcp_node) {
> +		struct net *c_net =3D read_pnet(&tc->t_cpath->cp_conn->c_net);
> +
> +		if (net !=3D c_net || !tc->t_sock)
> +			continue;
> +
> +		/* reconnect with new parameters */
> +		rds_conn_path_drop(tc->t_cpath, false);
> +	}
> +	spin_unlock_irq(&rds_tcp_conn_lock);
> +}
> +
> +static int rds_tcp_skbuf_handler(struct rds_tcp_net *rtn,
> +				 const struct ctl_table *ctl, int write,
> +				 void *buffer, size_t *lenp, loff_t *fpos)
> +{
> +	int err;
> +
> +	err =3D proc_dointvec_minmax(ctl, write, buffer, lenp, fpos);
> +	if (err < 0) {
> +		pr_warn("Invalid input. Must be >=3D %d\n",
> +			*(int *)(ctl->extra1));
> +		return err;
> +	}
> +
> +	if (write && rtn->rds_tcp_listen_sock && rtn->rds_tcp_listen_sock->sk) {
> +		struct net *net =3D sock_net(rtn->rds_tcp_listen_sock->sk);
> +
> +		rds_tcp_sysctl_reset(net);
> +	}
> +
> +	return 0;
> +}
> +
>  static int rds_tcp_sndbuf_handler(const struct ctl_table *ctl, int write,
> -				  void *buffer, size_t *lenp, loff_t *fpos);
> +				  void *buffer, size_t *lenp, loff_t *fpos)
> +{
> +	struct rds_tcp_net *rtn =3D container_of(ctl->data, struct rds_tcp_net,
> +					       sndbuf_size);
> +
> +	return rds_tcp_skbuf_handler(rtn, ctl, write, buffer, lenp, fpos);
> +}
> +
>  static int rds_tcp_rcvbuf_handler(const struct ctl_table *ctl, int write,
> -				  void *buffer, size_t *lenp, loff_t *fpos);
> +				  void *buffer, size_t *lenp, loff_t *fpos)
> +{
> +	struct rds_tcp_net *rtn =3D container_of(ctl->data, struct rds_tcp_net,
> +					       rcvbuf_size);
> =20
> -static int rds_tcp_min_sndbuf =3D SOCK_MIN_SNDBUF;
> -static int rds_tcp_min_rcvbuf =3D SOCK_MIN_RCVBUF;
> +	return rds_tcp_skbuf_handler(rtn, ctl, write, buffer, lenp, fpos);
> +}
> =20
>  static struct ctl_table rds_tcp_sysctl_table[] =3D {
>  #define	RDS_TCP_SNDBUF	0
> @@ -82,6 +140,61 @@ static struct ctl_table rds_tcp_sysctl_table[] =3D {
>  	},
>  };
> =20
> +static __net_init int rds_tcp_init_net_sysctl(struct net *net)
> +{
> +	struct rds_tcp_net *rtn =3D net_generic(net, rds_tcp_netid);
> +	struct ctl_table *tbl;
> +
> +	/* {snd, rcv}buf_size default to 0, which implies we let the
> +	 * stack pick the value, and permit auto-tuning of buffer size.
> +	 */
> +	if (net =3D=3D &init_net) {
> +		tbl =3D rds_tcp_sysctl_table;
> +	} else {
> +		tbl =3D kmemdup(rds_tcp_sysctl_table,
> +			      sizeof(rds_tcp_sysctl_table), GFP_KERNEL);
> +		if (!tbl) {
> +			pr_warn("could not set allocate sysctl table\n");
> +			return -ENOMEM;
> +		}
> +		rtn->ctl_table =3D tbl;
> +	}
> +	tbl[RDS_TCP_SNDBUF].data =3D &rtn->sndbuf_size;
> +	tbl[RDS_TCP_RCVBUF].data =3D &rtn->rcvbuf_size;
> +	rtn->rds_tcp_sysctl =3D register_net_sysctl_sz(net, "net/rds/tcp", tbl,
> +						     ARRAY_SIZE(rds_tcp_sysctl_table));
> +	if (!rtn->rds_tcp_sysctl) {
> +		pr_warn("could not register sysctl\n");
> +		if (net !=3D &init_net)
> +			kfree(tbl);
> +		return -ENOMEM;
> +	}
> +
> +	return 0;
> +}
> +
> +static void __net_exit rds_tcp_exit_net_sysctl(struct net *net)
> +{
> +	struct rds_tcp_net *rtn =3D net_generic(net, rds_tcp_netid);
> +
> +	if (rtn->rds_tcp_sysctl) {
> +		unregister_net_sysctl_table(rtn->rds_tcp_sysctl);
> +		rtn->rds_tcp_sysctl =3D NULL;
> +	}
> +
> +	if (net !=3D &init_net)
> +		kfree(rtn->ctl_table);
> +}
> +#else
> +static inline int rds_tcp_init_net_sysctl(struct net *net)
> +{
> +	return 0;
> +}
> +static inline void rds_tcp_exit_net_sysctl(struct net *net)
> +{
> +}
> +#endif
> +
>  u32 rds_tcp_write_seq(struct rds_tcp_connection *tc)
>  {
>  	/* seq# of the last byte of data in tcp send buffer */
> @@ -612,36 +725,15 @@ void rds_tcp_accept_work(struct rds_tcp_net *rtn)
>  static __net_init int rds_tcp_init_net(struct net *net)
>  {
>  	struct rds_tcp_net *rtn =3D net_generic(net, rds_tcp_netid);
> -	struct ctl_table *tbl;
>  	int err =3D 0;
> =20
>  	memset(rtn, 0, sizeof(*rtn));
> =20
>  	mutex_init(&rtn->rds_tcp_accept_lock);
> =20
> -	/* {snd, rcv}buf_size default to 0, which implies we let the
> -	 * stack pick the value, and permit auto-tuning of buffer size.
> -	 */
> -	if (net =3D=3D &init_net) {
> -		tbl =3D rds_tcp_sysctl_table;
> -	} else {
> -		tbl =3D kmemdup(rds_tcp_sysctl_table,
> -			      sizeof(rds_tcp_sysctl_table), GFP_KERNEL);
> -		if (!tbl) {
> -			pr_warn("could not set allocate sysctl table\n");
> -			return -ENOMEM;
> -		}
> -		rtn->ctl_table =3D tbl;
> -	}
> -	tbl[RDS_TCP_SNDBUF].data =3D &rtn->sndbuf_size;
> -	tbl[RDS_TCP_RCVBUF].data =3D &rtn->rcvbuf_size;
> -	rtn->rds_tcp_sysctl =3D register_net_sysctl_sz(net, "net/rds/tcp", tbl,
> -						     ARRAY_SIZE(rds_tcp_sysctl_table));
> -	if (!rtn->rds_tcp_sysctl) {
> -		pr_warn("could not register sysctl\n");
> -		err =3D -ENOMEM;
> -		goto fail;
> -	}
> +	err =3D rds_tcp_init_net_sysctl(net);
> +	if (err)
> +		return err;
> =20
>  #if IS_ENABLED(CONFIG_IPV6)
>  	rtn->rds_tcp_listen_sock =3D rds_tcp_listen_init(net, true);
> @@ -656,21 +748,14 @@ static __net_init int rds_tcp_init_net(struct net *=
net)
>  		rtn->rds_tcp_listen_sock =3D rds_tcp_listen_init(net, false);
>  		if (!rtn->rds_tcp_listen_sock) {
>  #endif
> -			unregister_net_sysctl_table(rtn->rds_tcp_sysctl);
> -			rtn->rds_tcp_sysctl =3D NULL;
> -			err =3D -EAFNOSUPPORT;
> -			goto fail;
> +			rds_tcp_exit_net_sysctl(net);
> +			return -EAFNOSUPPORT;
>  #if IS_ENABLED(CONFIG_IPV6)
>  		}
>  #endif
>  	}
>  	INIT_WORK(&rtn->rds_tcp_accept_w, rds_tcp_accept_worker);
>  	return 0;
> -
> -fail:
> -	if (net !=3D &init_net)
> -		kfree(tbl);
> -	return err;
>  }
> =20
>  static void rds_tcp_kill_sock(struct net *net)
> @@ -704,14 +789,7 @@ static void rds_tcp_kill_sock(struct net *net)
> =20
>  static void __net_exit rds_tcp_exit_net(struct net *net)
>  {
> -	struct rds_tcp_net *rtn =3D net_generic(net, rds_tcp_netid);
> -
> -	if (rtn->rds_tcp_sysctl)
> -		unregister_net_sysctl_table(rtn->rds_tcp_sysctl);
> -
> -	if (net !=3D &init_net)
> -		kfree(rtn->ctl_table);
> -
> +	rds_tcp_exit_net_sysctl(net);
>  	rds_tcp_kill_sock(net);
>  }
> =20
> @@ -733,68 +811,6 @@ void *rds_tcp_listen_sock_def_readable(struct net *n=
et)
>  	return lsock->sk->sk_user_data;
>  }
> =20
> -/* when sysctl is used to modify some kernel socket parameters,this
> - * function  resets the RDS connections in that netns  so that we can
> - * restart with new parameters.  The assumption is that such reset
> - * events are few and far-between.
> - */
> -static void rds_tcp_sysctl_reset(struct net *net)
> -{
> -	struct rds_tcp_connection *tc, *_tc;
> -
> -	spin_lock_irq(&rds_tcp_conn_lock);
> -	list_for_each_entry_safe(tc, _tc, &rds_tcp_conn_list, t_tcp_node) {
> -		struct net *c_net =3D read_pnet(&tc->t_cpath->cp_conn->c_net);
> -
> -		if (net !=3D c_net || !tc->t_sock)
> -			continue;
> -
> -		/* reconnect with new parameters */
> -		rds_conn_path_drop(tc->t_cpath, false);
> -	}
> -	spin_unlock_irq(&rds_tcp_conn_lock);
> -}
> -
> -static int rds_tcp_skbuf_handler(struct rds_tcp_net *rtn,
> -				 const struct ctl_table *ctl, int write,
> -				 void *buffer, size_t *lenp, loff_t *fpos)
> -{
> -	int err;
> -
> -	err =3D proc_dointvec_minmax(ctl, write, buffer, lenp, fpos);
> -	if (err < 0) {
> -		pr_warn("Invalid input. Must be >=3D %d\n",
> -			*(int *)(ctl->extra1));
> -		return err;
> -	}
> -
> -	if (write && rtn->rds_tcp_listen_sock && rtn->rds_tcp_listen_sock->sk) {
> -		struct net *net =3D sock_net(rtn->rds_tcp_listen_sock->sk);
> -
> -		rds_tcp_sysctl_reset(net);
> -	}
> -
> -	return 0;
> -}
> -
> -static int rds_tcp_sndbuf_handler(const struct ctl_table *ctl, int write,
> -				  void *buffer, size_t *lenp, loff_t *fpos)
> -{
> -	struct rds_tcp_net *rtn =3D container_of(ctl->data, struct rds_tcp_net,
> -					       sndbuf_size);
> -
> -	return rds_tcp_skbuf_handler(rtn, ctl, write, buffer, lenp, fpos);
> -}
> -
> -static int rds_tcp_rcvbuf_handler(const struct ctl_table *ctl, int write,
> -				  void *buffer, size_t *lenp, loff_t *fpos)
> -{
> -	struct rds_tcp_net *rtn =3D container_of(ctl->data, struct rds_tcp_net,
> -					       rcvbuf_size);
> -
> -	return rds_tcp_skbuf_handler(rtn, ctl, write, buffer, lenp, fpos);
> -}
> -
>  static void rds_tcp_exit(void)
>  {
>  	rds_tcp_set_unloading();
> diff --git a/net/rds/tcp.h b/net/rds/tcp.h
> index 39c86347188c..12b58d76c089 100644
> --- a/net/rds/tcp.h
> +++ b/net/rds/tcp.h
> @@ -13,8 +13,10 @@ struct rds_tcp_net {
>  	struct socket		*rds_tcp_listen_sock;
>  	struct socket		*rds_tcp_accepted_sock;
>  	struct work_struct	rds_tcp_accept_w;
> +#ifdef CONFIG_SYSCTL
>  	struct ctl_table_header	*rds_tcp_sysctl;
>  	const struct ctl_table	*ctl_table;
> +#endif
>  	int			sndbuf_size;
>  	int			rcvbuf_size;
>  };
>=20

--2q5pjfxl3jaesakr
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQGzBAABCgAdFiEErkcJVyXmMSXOyyeQupfNUreWQU8FAmrXR8IACgkQupfNUreW
QU/uDgv+KFCXUulytQ2K8Ag0x3y6yIgJ4nYYp56qqb8GygnrPiJoLZJ05miyKb7f
GuENMH5LNUZ2vVtEUU76w/+At/I1EmZBdmllvnZXdlHBnk5g3BUfeKXWH2xVnNmi
vOUZkvt9hiUpNDgcUy342V3FBfmbgZiRrdV3uKKW678eOhfOci7v19TYYUBp28o+
7pOIIm0MIH9lz9Ge5J6D4puaAZDklF3qPPC65Dk3KW8Ynb+ROKPuZ1yUAgeD/dSJ
Jjl9XDAcP76iNl6UbMooRad8tK39e9/p3ZEm076A6wG5j/Nm5W+QCuU8ySfYRU8M
NrmL1xN3GhMF76HK2b+nipNFZOdP39+O9wHGC8UN7Dq+e5xnU7bfNhdPZyCWwdAy
GLUFyYbWDsJaxP0gd6yj5JMZi7m9YrYkpAG8mBAQ3h15YXqA/kxOkc4n/57Uw9RW
TKTB1aqZ0l8Sov5ELGi273MxUj4VTGHtLPgUpHZUrQdNQ4hPUaQI3+F3DaACnHPQ
qqo8+RAA
=4/wU
-----END PGP SIGNATURE-----

--2q5pjfxl3jaesakr--
Re: rds_wq UAF
#5920
Author: Allison Henderson
Date: Wed, 21 Oct 2026 08:36
87 lines
10891 bytes
On Tue, 2026-10-20 at 15:09 +0200, Oleg Nesterov wrote:
> (change subject)
> 
> On 10/19, Allison Henderson wrote:
> > 
> > On Mon, 2026-10-19 at 17:35 +0200, Oleg Nesterov wrote:
> > > > 
> > > > But. rds_init() can also fail even if CONFIG_SYSCTL=y, after
> > > > rds_sysctl_init(), so to me this looks like a bug in net/rds/.
> > > > 
> > 
> > Yes that's a separate bug, so I'll send a separate fix for that.
> 
> Let me try to summarize.
> 
> If rds_init() fails after rds_threads_init() for any reason,
> rds_threads_exit() will destroy/free rds_wq.
> 
> If rds_rdma_init() is called after that, and rds_ib_init() fails
> after rds_ib_mr_init(), rds_ib_unregister_client() will try to
> flush the already freed rds_wq.
> 
> But we have
> 
> 	module_init(rds_init);		// net/rds/af_rds.c
> 	module_init(rds_rdma_init);	// net/rds/rdma_transport.c
> 
> and IIUC the order of these initcalls is not defined. So if
> rds_rdma_init() -> rds_ib_init() is called before rds_init(), it
> can do flush_workqueue(rds_wq) when rds_wq == NULL on failure.
It is sort of defined.  When built as modules the order is enforced by
symbol dependencies. rds_rdma and rds_tcp need symbols exported by rds
(rds_wq itself is one of them), so they can't be loaded unless rds_init()
succeeded.  So the rds_wq == NULL case can't happen.

What can happen is what was reported: built in, rds_init() fails,
do_initcalls() keeps going, and rds_rdma_init()/rds_tcp_init() run against
a core that has already been torn down.


> 
> With or without CONFIG_SYSCTL. Right?
> 
> But it seems that rds_ib_init() doesn't need to flush rds_wq on failure,
> so how about the patch below? Of course, I have no idea if net/rds has
> more similar issues with rds_wq.
> 
> Oleg.
> ---
> 
> diff --git a/net/rds/ib.c b/net/rds/ib.c
> index 786f39169bc1..cde2d1bfabbd 100644
> --- a/net/rds/ib.c
> +++ b/net/rds/ib.c
> @@ -619,7 +619,7 @@ int rds_ib_init(void)
>  out_sysctl:
>  	rds_ib_sysctl_exit();
>  out_ibreg:
> -	rds_ib_unregister_client();
> +	ib_unregister_client(&rds_ib_client);

This works for when there are no IB devices, as in the report, but the flush
is what ensures rds_ib_dev_free() has finished before rds_rdma.ko's text goes away.  

If there is a device,  ib_register_client() has already called rds_ib_add_one().
Then ib_unregister_client() calls rds_ib_remove_one(), which drops the last
reference.  And then rds_ib_dev_put() does queue_work(rds_wq, ...) on the
freed workqueue anyway.  

So I think the fix belongs at the transport init: if the core didn't
come up, rds_rdma_init() and rds_tcp_init() should return early,
before they register anything.  I can send that along with the
sysctl change tomorrow.

Thanks for working on this!
Allison



>  out_mr_exit:
>  	rds_ib_mr_exit();
>  out:
> 
Re: [linus:master] [sysctl] 8d75c338f0: BUG:KASAN:slab-use-after-free_in_touch_wq_lockdep_map
#5926
Author: Joel Granados
Date: Wed, 21 Oct 2026 08:57
54 lines
9972 bytes
--bt355i3q7cyhktpe
Content-Type: text/plain; protected-headers=v1; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Subject: Re: [linus:master] [sysctl]  8d75c338f0:
 BUG:KASAN:slab-use-after-free_in_touch_wq_lockdep_map
MIME-Version: 1.0

On Tue, Oct 20, 2026 at 01:05:01PM +0200, Oleg Nesterov wrote:
> On 10/20, Joel Granados wrote:
> >
> > On Mon, Oct 19, 2026 at 12:52:58PM -0700, Allison Henderson wrote:
> > >
> > > CONFIG_SYSCTL=3Dn.  A simpler fix might be to just handle the NULL at=
 the
> > > three call sites, e.g.:
> > >
> > >         rds_sysctl_reg_table =3D
> > >                 register_net_sysctl(&init_net, "net/rds", rds_sysctl_=
rds_table);
> > >         if (!rds_sysctl_reg_table && IS_ENABLED(CONFIG_SYSCTL))
> > >                 return -ENOMEM;
> > >
> >
> > Remember to NULL check rds_sysctl_reg_table in rds_sysctl_exit(). You
> > might hit another UAF on exit if you don't.
>=20
> Why? unregister_sysctl_table(header) does nothing if header =3D=3D NULL.
Nice catch! You can forgo the check as it is the first thing that
happens in unregister_sysctl_table.

Best

--bt355i3q7cyhktpe
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQGzBAABCgAdFiEErkcJVyXmMSXOyyeQupfNUreWQU8FAmrYfooACgkQupfNUreW
QU/WnAv/YVbhwQnlgm1v0MJMVqJO5TZOJ+RcOu/m4rFbvIPU8twKRupXLpWiQn/b
ICa4TdGkh96N3eS3UkV+Iiv9cSUVYgRBt1AXsJZ+JHRaufbZJIVIPhejQnxhjJe9
IQp55/hIG3MqlAbVIJBOgMKo5F7PbnElO2mRDkCXoc9KJ1wxvrjVCZodr+J6RWtt
e5OdPT9V1YmTuf37xRxpDWt4VRAtIrKIGMg3IqxHPPhFQlvepKVGLzgJYLNy/Ovt
vQkSONcvJhN1xkgKv+L+9cvlixaZaechi9psoCxWnDH0fxQBxamwcWmIKewNeoza
0W1An6oKC7did7l+hnLFAHKkt/8ePeddQM6ImdSmgAXueiCJ/Nr6hnI21D8eKQoA
U0n/7WU6S4/E7warmYG64iiAzKsI76Jd5nFYQY1feOLgQdMaa9RbcBFVqEAAoCQz
HvCPKex1+h1Ah/HxuC2wrvmUI3dX9AxrSo7NpuhKtPTzgXaLEfaAfW8tINh4pRXR
ZrHBWkU5
=s4u6
-----END PGP SIGNATURE-----

--bt355i3q7cyhktpe--
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads