Skip to content

update for deepin kernel build #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 12, 2024

Conversation

matrix-wsk
Copy link
Contributor

Add defconfig file and update scripts to build deepin kernel.

Add defconfig file and update scripts to build deepin kernel.

Signed-off-by: Lugang He <[email protected]>
@matrix-wsk matrix-wsk merged commit d1358cc into deepin-community:linux-6.6.y Jan 12, 2024
matrix-wsk pushed a commit to matrix-wsk/kernel-6.6 that referenced this pull request Jan 18, 2024
[ Upstream commit 9dbe086 ]

A crash was found when dumping SMC-R connections. It can be reproduced
by following steps:

- environment: two RNICs on both sides.
- run SMC-R between two sides, now a SMC_LGR_SYMMETRIC type link group
  will be created.
- set the first RNIC down on either side and link group will turn to
  SMC_LGR_ASYMMETRIC_LOCAL then.
- run 'smcss -R' and the crash will be triggered.

 BUG: kernel NULL pointer dereference, address: 0000000000000010
 #PF: supervisor read access in kernel mode
 #PF: error_code(0x0000) - not-present page
 PGD 8000000101fdd067 P4D 8000000101fdd067 PUD 10ce46067 PMD 0
 Oops: 0000 [deepin-community#1] PREEMPT SMP PTI
 CPU: 3 PID: 1810 Comm: smcss Kdump: loaded Tainted: G W   E      6.7.0-rc6+ deepin-community#51
 RIP: 0010:__smc_diag_dump.constprop.0+0x36e/0x620 [smc_diag]
 Call Trace:
  <TASK>
  ? __die+0x24/0x70
  ? page_fault_oops+0x66/0x150
  ? exc_page_fault+0x69/0x140
  ? asm_exc_page_fault+0x26/0x30
  ? __smc_diag_dump.constprop.0+0x36e/0x620 [smc_diag]
  smc_diag_dump_proto+0xd0/0xf0 [smc_diag]
  smc_diag_dump+0x26/0x60 [smc_diag]
  netlink_dump+0x19f/0x320
  __netlink_dump_start+0x1dc/0x300
  smc_diag_handler_dump+0x6a/0x80 [smc_diag]
  ? __pfx_smc_diag_dump+0x10/0x10 [smc_diag]
  sock_diag_rcv_msg+0x121/0x140
  ? __pfx_sock_diag_rcv_msg+0x10/0x10
  netlink_rcv_skb+0x5a/0x110
  sock_diag_rcv+0x28/0x40
  netlink_unicast+0x22a/0x330
  netlink_sendmsg+0x240/0x4a0
  __sock_sendmsg+0xb0/0xc0
  ____sys_sendmsg+0x24e/0x300
  ? copy_msghdr_from_user+0x62/0x80
  ___sys_sendmsg+0x7c/0xd0
  ? __do_fault+0x34/0x1a0
  ? do_read_fault+0x5f/0x100
  ? do_fault+0xb0/0x110
  __sys_sendmsg+0x4d/0x80
  do_syscall_64+0x45/0xf0
  entry_SYSCALL_64_after_hwframe+0x6e/0x76

When the first RNIC is set down, the lgr->lnk[0] will be cleared and an
asymmetric link will be allocated in lgr->link[SMC_LINKS_PER_LGR_MAX - 1]
by smc_llc_alloc_alt_link(). Then when we try to dump SMC-R connections
in __smc_diag_dump(), the invalid lgr->lnk[0] will be accessed, resulting
in this issue. So fix it by accessing the right link.

Fixes: f16a7dd ("smc: netlink interface for SMC sockets")
Reported-by: henaumars <[email protected]>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=7616
Signed-off-by: Wen Gu <[email protected]>
Reviewed-by: Tony Lu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
opsiff pushed a commit to opsiff/UOS-kernel that referenced this pull request Apr 28, 2024
[ Upstream commit 5d47ec2 ]

The `cls_redirect` test triggers a kernel panic like:

  # ./test_progs -t cls_redirect
  Can't find bpf_testmod.ko kernel module: -2
  WARNING! Selftests relying on bpf_testmod.ko will be skipped.
  [   30.938489] CPU 3 Unable to handle kernel paging request at virtual address fffffffffd814de0, era == ffff800002009fb8, ra == ffff800002009f9c
  [   30.939331] Oops[#1]:
  [   30.939513] CPU: 3 PID: 1260 Comm: test_progs Not tainted 6.7.0-rc2-loong-devel-g2f56bb0d2327 deepin-community#35 a896aca3f4164f09cc346f89f2e09832e07be5f6
  [   30.939732] Hardware name: QEMU QEMU Virtual Machine, BIOS unknown 2/2/2022
  [   30.939901] pc ffff800002009fb8 ra ffff800002009f9c tp 9000000104da4000 sp 9000000104da7ab0
  [   30.940038] a0 fffffffffd814de0 a1 9000000104da7a68 a2 0000000000000000 a3 9000000104da7c10
  [   30.940183] a4 9000000104da7c14 a5 0000000000000002 a6 0000000000000021 a7 00005555904d7f90
  [   30.940321] t0 0000000000000110 t1 0000000000000000 t2 fffffffffd814de0 t3 0004c4b400000000
  [   30.940456] t4 ffffffffffffffff t5 00000000c3f63600 t6 0000000000000000 t7 0000000000000000
  [   30.940590] t8 000000000006d803 u0 0000000000000020 s9 9000000104da7b10 s0 900000010504c200
  [   30.940727] s1 fffffffffd814de0 s2 900000010504c200 s3 9000000104da7c10 s4 9000000104da7ad0
  [   30.940866] s5 0000000000000000 s6 90000000030e65bc s7 9000000104da7b44 s8 90000000044f6fc0
  [   30.941015]    ra: ffff800002009f9c bpf_prog_846803e5ae81417f_cls_redirect+0xa0/0x590
  [   30.941535]   ERA: ffff800002009fb8 bpf_prog_846803e5ae81417f_cls_redirect+0xbc/0x590
  [   30.941696]  CRMD: 000000b0 (PLV0 -IE -DA +PG DACF=CC DACM=CC -WE)
  [   30.942224]  PRMD: 00000004 (PPLV0 +PIE -PWE)
  [   30.942330]  EUEN: 00000003 (+FPE +SXE -ASXE -BTE)
  [   30.942453]  ECFG: 00071c1c (LIE=2-4,10-12 VS=7)
  [   30.942612] ESTAT: 00010000 [PIL] (IS= ECode=1 EsubCode=0)
  [   30.942764]  BADV: fffffffffd814de0
  [   30.942854]  PRID: 0014c010 (Loongson-64bit, Loongson-3A5000)
  [   30.942974] Modules linked in:
  [   30.943078] Process test_progs (pid: 1260, threadinfo=00000000ce303226, task=000000007d10bb76)
  [   30.943306] Stack : 900000010a064000 90000000044f6fc0 9000000104da7b48 0000000000000000
  [   30.943495]         0000000000000000 9000000104da7c14 9000000104da7c10 900000010504c200
  [   30.943626]         0000000000000001 ffff80001b88c000 9000000104da7b70 90000000030e6668
  [   30.943785]         0000000000000000 9000000104da7b58 ffff80001b88c048 9000000003d05000
  [   30.943936]         900000000303ac88 0000000000000000 0000000000000000 9000000104da7b70
  [   30.944091]         0000000000000000 0000000000000001 0000000731eeab00 0000000000000000
  [   30.944245]         ffff80001b88c000 0000000000000000 0000000000000000 54b99959429f83b8
  [   30.944402]         ffff80001b88c000 90000000044f6fc0 9000000101d70000 ffff80001b88c000
  [   30.944538]         000000000000005a 900000010504c200 900000010a064000 900000010a067000
  [   30.944697]         9000000104da7d88 0000000000000000 9000000003d05000 90000000030e794c
  [   30.944852]         ...
  [   30.944924] Call Trace:
  [   30.945120] [<ffff800002009fb8>] bpf_prog_846803e5ae81417f_cls_redirect+0xbc/0x590
  [   30.945650] [<90000000030e6668>] bpf_test_run+0x1ec/0x2f8
  [   30.945958] [<90000000030e794c>] bpf_prog_test_run_skb+0x31c/0x684
  [   30.946065] [<90000000026d4f68>] __sys_bpf+0x678/0x2724
  [   30.946159] [<90000000026d7288>] sys_bpf+0x20/0x2c
  [   30.946253] [<90000000032dd224>] do_syscall+0x7c/0x94
  [   30.946343] [<9000000002541c5c>] handle_syscall+0xbc/0x158
  [   30.946492]
  [   30.946549] Code: 0015030e  5c0009c0  5001d000 <28c00304> 02c00484  29c00304  00150009  2a42d2e4  0280200d
  [   30.946793]
  [   30.946971] ---[ end trace 0000000000000000 ]---
  [   32.093225] Kernel panic - not syncing: Fatal exception in interrupt
  [   32.093526] Kernel relocated by 0x2320000
  [   32.093630]  .text @ 0x9000000002520000
  [   32.093725]  .data @ 0x9000000003400000
  [   32.093792]  .bss  @ 0x9000000004413200
  [   34.971998] ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]---

This is because we signed-extend function return values. When subprog
mode is enabled, we have:

  cls_redirect()
    -> get_global_metrics() returns pcpu ptr 0xfffffefffc00b480

The pointer returned is later signed-extended to 0xfffffffffc00b480 at
`BPF_JMP | BPF_EXIT`. During BPF prog run, this triggers unhandled page
fault and a kernel panic.

Drop the unnecessary signed-extension on return values like other
architectures do.

With this change, we have:

  # ./test_progs -t cls_redirect
  Can't find bpf_testmod.ko kernel module: -2
  WARNING! Selftests relying on bpf_testmod.ko will be skipped.
  deepin-community#51/1    cls_redirect/cls_redirect_inlined:OK
  deepin-community#51/2    cls_redirect/IPv4 TCP accept unknown (no hops, flags: SYN):OK
  deepin-community#51/3    cls_redirect/IPv6 TCP accept unknown (no hops, flags: SYN):OK
  deepin-community#51/4    cls_redirect/IPv4 TCP accept unknown (no hops, flags: ACK):OK
  deepin-community#51/5    cls_redirect/IPv6 TCP accept unknown (no hops, flags: ACK):OK
  deepin-community#51/6    cls_redirect/IPv4 TCP forward unknown (one hop, flags: ACK):OK
  deepin-community#51/7    cls_redirect/IPv6 TCP forward unknown (one hop, flags: ACK):OK
  deepin-community#51/8    cls_redirect/IPv4 TCP accept known (one hop, flags: ACK):OK
  deepin-community#51/9    cls_redirect/IPv6 TCP accept known (one hop, flags: ACK):OK
  deepin-community#51/10   cls_redirect/IPv4 UDP accept unknown (no hops, flags: none):OK
  deepin-community#51/11   cls_redirect/IPv6 UDP accept unknown (no hops, flags: none):OK
  deepin-community#51/12   cls_redirect/IPv4 UDP forward unknown (one hop, flags: none):OK
  deepin-community#51/13   cls_redirect/IPv6 UDP forward unknown (one hop, flags: none):OK
  deepin-community#51/14   cls_redirect/IPv4 UDP accept known (one hop, flags: none):OK
  deepin-community#51/15   cls_redirect/IPv6 UDP accept known (one hop, flags: none):OK
  deepin-community#51/16   cls_redirect/cls_redirect_subprogs:OK
  deepin-community#51/17   cls_redirect/IPv4 TCP accept unknown (no hops, flags: SYN):OK
  deepin-community#51/18   cls_redirect/IPv6 TCP accept unknown (no hops, flags: SYN):OK
  deepin-community#51/19   cls_redirect/IPv4 TCP accept unknown (no hops, flags: ACK):OK
  deepin-community#51/20   cls_redirect/IPv6 TCP accept unknown (no hops, flags: ACK):OK
  deepin-community#51/21   cls_redirect/IPv4 TCP forward unknown (one hop, flags: ACK):OK
  deepin-community#51/22   cls_redirect/IPv6 TCP forward unknown (one hop, flags: ACK):OK
  deepin-community#51/23   cls_redirect/IPv4 TCP accept known (one hop, flags: ACK):OK
  deepin-community#51/24   cls_redirect/IPv6 TCP accept known (one hop, flags: ACK):OK
  deepin-community#51/25   cls_redirect/IPv4 UDP accept unknown (no hops, flags: none):OK
  deepin-community#51/26   cls_redirect/IPv6 UDP accept unknown (no hops, flags: none):OK
  deepin-community#51/27   cls_redirect/IPv4 UDP forward unknown (one hop, flags: none):OK
  deepin-community#51/28   cls_redirect/IPv6 UDP forward unknown (one hop, flags: none):OK
  deepin-community#51/29   cls_redirect/IPv4 UDP accept known (one hop, flags: none):OK
  deepin-community#51/30   cls_redirect/IPv6 UDP accept known (one hop, flags: none):OK
  deepin-community#51/31   cls_redirect/cls_redirect_dynptr:OK
  deepin-community#51/32   cls_redirect/IPv4 TCP accept unknown (no hops, flags: SYN):OK
  deepin-community#51/33   cls_redirect/IPv6 TCP accept unknown (no hops, flags: SYN):OK
  deepin-community#51/34   cls_redirect/IPv4 TCP accept unknown (no hops, flags: ACK):OK
  deepin-community#51/35   cls_redirect/IPv6 TCP accept unknown (no hops, flags: ACK):OK
  deepin-community#51/36   cls_redirect/IPv4 TCP forward unknown (one hop, flags: ACK):OK
  deepin-community#51/37   cls_redirect/IPv6 TCP forward unknown (one hop, flags: ACK):OK
  deepin-community#51/38   cls_redirect/IPv4 TCP accept known (one hop, flags: ACK):OK
  deepin-community#51/39   cls_redirect/IPv6 TCP accept known (one hop, flags: ACK):OK
  deepin-community#51/40   cls_redirect/IPv4 UDP accept unknown (no hops, flags: none):OK
  deepin-community#51/41   cls_redirect/IPv6 UDP accept unknown (no hops, flags: none):OK
  deepin-community#51/42   cls_redirect/IPv4 UDP forward unknown (one hop, flags: none):OK
  deepin-community#51/43   cls_redirect/IPv6 UDP forward unknown (one hop, flags: none):OK
  deepin-community#51/44   cls_redirect/IPv4 UDP accept known (one hop, flags: none):OK
  deepin-community#51/45   cls_redirect/IPv6 UDP accept known (one hop, flags: none):OK
  deepin-community#51      cls_redirect:OK
  Summary: 1/45 PASSED, 0 SKIPPED, 0 FAILED

Fixes: 5dc6155 ("LoongArch: Add BPF JIT support")
Signed-off-by: Hengqi Chen <[email protected]>
Signed-off-by: Huacai Chen <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant