lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID:
 <SY8P300MB04214534155F05358161B402A1D92@SY8P300MB0421.AUSP300.PROD.OUTLOOK.COM>
Date: Wed, 19 Mar 2025 08:26:20 +0000
From: YAN KANG <kangyan91@...look.com>
To: "David S. Miller" <davem@...emloft.net>, Eric Dumazet
	<edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni
	<pabeni@...hat.com>, Simon Horman <horms@...nel.org>, Simon Horman
	<horms@...nel.org>, "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: general protection fault in llc_conn_state_process 

Dear maintainers,

I found a new kernel bug titiled "general protection fault in llc_conn_state_process" while using modified syzkaller fuzzing tool. I tested it on the Linux upstream version (6.13.0-rc7) . Although I don't have repro, the crash log is sufficient to describe the cause of the bug.

RootCause Analysis:
function llc_conn_state_process in /net/llc/llc_conn.c  
    	case LLC_CONN_PRIM:
		if (sk->sk_type == SOCK_STREAM &&
		    sk->sk_state == TCP_SYN_SENT) {
			if (ev->status) {
				sk->sk_socket->state = SS_UNCONNECTED; //crash, sk->sk_socket == NULL
				sk->sk_state         = TCP_CLOSE;
			} else {
				sk->sk_socket->state = SS_CONNECTED;
				sk->sk_state         = TCP_ESTABLISHED;
			}
			sk->sk_state_change(sk);
		}
		break;

Bug occurs:

  Thread A                                                  Thread B
   ----------------------                         ----------------------
   call_timer_fn                                          sock_close
      - llc_conn_tmr_common_cb                    - llc_ui_release
          - llc_process_tmr_ev                                |- lock_sock
              -llc_conn_state_process                      |- release_sock
                   |                                                      |-sock_orphan(sk)
                   |                                                                |-sk_set_socket(sk, NULL); [1]
                   case LLC_CONN_PRIM:
                       sk->sk_socket->state = SS_UNCONNECTED;    [2] crash ,NPD!!

Fix Suggestion:
Using lock_sock & release_sock in  case LLC_CONN_PRIM and putting sock_orphan in lock windows.
BTW: in case LLC_CONN_PRIM , Is it necessary to add sock_hold and sock_put? 


If you fix this issue, please add the following tag to the commit:
Reported-by: yan kang <kangyan91@...look.com>
Reported-by: yue sun <samsun1006219@...il.com>


I hope it helps.
Best regards
yan kang


Kernel crash log is below.
==================================================================
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] PREEMPT SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
CPU: 1 UID: 0 PID: 27544 Comm: syz.7.2138 Not tainted 6.13.0-rc7-00006-g7122647c49bb-dirty #112
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
RIP: 0010:llc_conn_state_process+0x9f0/0x1870 net/llc/llc_conn.c:141
Code: 8b 98 b0 01 00 00 e8 0f f1 79 f8 40 84 ed 0f 84 b0 0b 00 00 e8 71 fb 79 f8 48 89 da 48 b8 00 00 00 00 00 fc ff df 48 c1 ea 03 <0f> b6 04 02 84 c0 74 08 3c 03 0f 8e 6a 0d 00 00 48 8b 44 24 08 c7
RSP: 0018:ffffc900001e8ca0 EFLAGS: 00010246
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff891f2831
RDX: 0000000000000000 RSI: ffffffff891f283f RDI: 0000000000000001
RBP: 0000000000000002 R08: 0000000000000001 R09: ffffed1024df062a
R10: 0000000000000002 R11: 0000000000000000 R12: ffff888121e90600
R13: 0000000000000000 R14: dffffc0000000000 R15: ffff888126f83000
FS:  0000000000000000(0000) GS:ffff888135e00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000110c4052be CR3: 000000004f53a000 CR4: 0000000000752ef0
PKRU: 80000008
Call Trace:
 <IRQ>
 llc_process_tmr_ev net/llc/llc_c_ac.c:1445 [inline]
 llc_conn_tmr_common_cb+0x44e/0x8e0 net/llc/llc_c_ac.c:1331
 call_timer_fn+0x1a6/0x620 kernel/time/timer.c:1793
 expire_timers kernel/time/timer.c:1844 [inline]
 __run_timers+0x659/0x8f0 kernel/time/timer.c:2418
 __run_timer_base kernel/time/timer.c:2430 [inline]
 __run_timer_base kernel/time/timer.c:2422 [inline]
 run_timer_base+0xc5/0x120 kernel/time/timer.c:2439
 run_timer_softirq+0x1a/0x40 kernel/time/timer.c:2449
 handle_softirqs+0x1bf/0x850 kernel/softirq.c:561
 do_softirq kernel/softirq.c:462 [inline]
 do_softirq+0xac/0xe0 kernel/softirq.c:449
 </IRQ>
 <TASK>
 __local_bh_enable_ip+0x100/0x120 kernel/softirq.c:389
 sock_orphan include/net/sock.h:2029 [inline]
 llc_ui_release+0x411/0x8f0 net/llc/af_llc.c:229
 __sock_release+0xb0/0x270 net/socket.c:640
 sock_close+0x1c/0x30 net/socket.c:1408
 __fput+0x3f8/0xb40 fs/file_table.c:450
 task_work_run+0x169/0x260 kernel/task_work.c:239
 exit_task_work include/linux/task_work.h:43 [inline]
 do_exit+0xacc/0x2ce0 kernel/exit.c:938
 do_group_exit+0xd3/0x2a0 kernel/exit.c:1087
 get_signal+0x222c/0x2500 kernel/signal.c:3017
 arch_do_signal_or_restart+0x81/0x7d0 arch/x86/kernel/signal.c:337
 exit_to_user_mode_loop kernel/entry/common.c:111 [inline]
 exit_to_user_mode_prepare include/linux/entry-common.h:329 [inline]
 __syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline]
 syscall_exit_to_user_mode+0x150/0x2a0 kernel/entry/common.c:218
 do_syscall_64+0xd8/0x250 arch/x86/entry/common.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f189f5a6a2d
Code: Unable to access opcode bytes at 0x7f189f5a6a03.
RSP: 002b:00007f18a0330f98 EFLAGS: 00000246 ORIG_RAX: 000000000000002a
RAX: fffffffffffffe00 RBX: 00007f189f7b5fa0 RCX: 00007f189f5a6a2d
RDX: 0000000000000010 RSI: 0000000020000000 RDI: 0000000000000006
RBP: 00007f189f639f8e R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f189f7b5fac R14: 00007f189f7b5fa0 R15: 00007f18a0311000
 </TASK>
Modules linked in:
hpet: Lost 3 RTC interrupts
---[ end trace 0000000000000000 ]---
RIP: 0010:llc_conn_state_process+0x9f0/0x1870 net/llc/llc_conn.c:141
Code: 8b 98 b0 01 00 00 e8 0f f1 79 f8 40 84 ed 0f 84 b0 0b 00 00 e8 71 fb 79 f8 48 89 da 48 b8 00 00 00 00 00 fc ff df 48 c1 ea 03 <0f> b6 04 02 84 c0 74 08 3c 03 0f 8e 6a 0d 00 00 48 8b 44 24 08 c7
RSP: 0018:ffffc900001e8ca0 EFLAGS: 00010246
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff891f2831
RDX: 0000000000000000 RSI: ffffffff891f283f RDI: 0000000000000001
RBP: 0000000000000002 R08: 0000000000000001 R09: ffffed1024df062a
R10: 0000000000000002 R11: 0000000000000000 R12: ffff888121e90600
R13: 0000000000000000 R14: dffffc0000000000 R15: ffff888126f83000
FS:  0000000000000000(0000) GS:ffff888135e00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000110c4052be CR3: 000000004f53a000 CR4: 0000000000752ef0
PKRU: 80000008
----------------
Code disassembly (best guess):
   0:	8b 98 b0 01 00 00    	mov    0x1b0(%rax),%ebx
   6:	e8 0f f1 79 f8       	call   0xf879f11a
   b:	40 84 ed             	test   %bpl,%bpl
   e:	0f 84 b0 0b 00 00    	je     0xbc4
  14:	e8 71 fb 79 f8       	call   0xf879fb8a
  19:	48 89 da             	mov    %rbx,%rdx
  1c:	48 b8 00 00 00 00 00 	movabs $0xdffffc0000000000,%rax
  23:	fc ff df
  26:	48 c1 ea 03          	shr    $0x3,%rdx
* 2a:	0f b6 04 02          	movzbl (%rdx,%rax,1),%eax <-- trapping instruction
  2e:	84 c0                	test   %al,%al
  30:	74 08                	je     0x3a
  32:	3c 03                	cmp    $0x3,%al
  34:	0f 8e 6a 0d 00 00    	jle    0xda4
  3a:	48 8b 44 24 08       	mov    0x8(%rsp),%rax
  3f:	c7                   	.byte 0xc7

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ