Skip to content

Conversation

@chaosmamama
Copy link

update

@chaosmamama
Copy link
Author

update

fengguang pushed a commit to 0day-ci/linux that referenced this pull request Feb 16, 2020
[BUG]
When calling BTRF_IOC_GET_SUBVOL_INFO ioctl, we can easily hit the
following backtrace:
  BUG: kernel NULL pointer dereference, address: 0000000000000024
  #PF: supervisor read access in kernel mode
  #PF: error_code(0x0000) - not-present page
  PGD 0 P4D 0
  Oops: 0000 [#1] SMP PTI
  CPU: 0 PID: 27421 Comm: python3 Not tainted 5.6.0-rc1+ torvalds#539
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.0-59-gc9ba527-rebuilt.opensuse.org 04/01/2014
  RIP: 0010:btrfs_root_node+0x7/0x30 [btrfs]
  Call Trace:
   btrfs_read_lock_root_node+0x1f/0x40 [btrfs]
   btrfs_search_slot+0x60f/0xa40 [btrfs]
   btrfs_ioctl+0x11f7/0x30b0 [btrfs]
   ksys_ioctl+0x82/0xc0
   __x64_sys_ioctl+0x11/0x20
   do_syscall_64+0x43/0x130
   entry_SYSCALL_64_after_hwframe+0x44/0xa9
  RIP: 0033:0x7fcb78d43387
  ---[ end trace 1c21a7c6c0523b8c ]---

[CAUSE]
We're abusing local @root, it's originally a subvolume root, but in
root backref search, it's re-assigned to tree_root.

Then we call "btrfs_put_root(root);" when exiting.
If that @root is reassgined to tree-root, we freed the most important
tree, and cause use-after-free.

[FIX]
Don't re-assgiend @root, use fs_info->tree_root directly.

Reported-by: Marcos Paulo de Souza <mpdesouza@suse.de>
Fixes: 8c319b6 ("btrfs: hold a ref on the root in btrfs_ioctl_get_subvol_info")
[To David: please fold the fix into that commit]
Signed-off-by: Qu Wenruo <wqu@suse.com>
fengguang pushed a commit to 0day-ci/linux that referenced this pull request Mar 15, 2021
This commit fixes the following checkpatch.pl errors:

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#535: FILE: ./hal/HalBtcOutSrc.h:535:
    +void EXhalbtcoutsrc_PowerOnSetting(struct BTC_COEXIST * pBtCoexist);

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#536: FILE: ./hal/HalBtcOutSrc.h:536:
    +void EXhalbtcoutsrc_InitHwConfig(struct BTC_COEXIST * pBtCoexist, u8 bWifiOnly);

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#537: FILE: ./hal/HalBtcOutSrc.h:537:
    +void EXhalbtcoutsrc_InitCoexDm(struct BTC_COEXIST * pBtCoexist);

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#538: FILE: ./hal/HalBtcOutSrc.h:538:
    +void EXhalbtcoutsrc_IpsNotify(struct BTC_COEXIST * pBtCoexist, u8 type);

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#539: FILE: ./hal/HalBtcOutSrc.h:539:
    +void EXhalbtcoutsrc_LpsNotify(struct BTC_COEXIST * pBtCoexist, u8 type);

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#540: FILE: ./hal/HalBtcOutSrc.h:540:
    +void EXhalbtcoutsrc_ScanNotify(struct BTC_COEXIST * pBtCoexist, u8 type);

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#541: FILE: ./hal/HalBtcOutSrc.h:541:
    +void EXhalbtcoutsrc_ConnectNotify(struct BTC_COEXIST * pBtCoexist, u8 action);

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#543: FILE: ./hal/HalBtcOutSrc.h:543:
    +	struct BTC_COEXIST * pBtCoexist, enum RT_MEDIA_STATUS mediaStatus

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#545: FILE: ./hal/HalBtcOutSrc.h:545:
    +void EXhalbtcoutsrc_SpecialPacketNotify(struct BTC_COEXIST * pBtCoexist, u8 pktType);

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#547: FILE: ./hal/HalBtcOutSrc.h:547:
    +	struct BTC_COEXIST * pBtCoexist, u8 *tmpBuf, u8 length

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#549: FILE: ./hal/HalBtcOutSrc.h:549:
    +void EXhalbtcoutsrc_HaltNotify(struct BTC_COEXIST * pBtCoexist);

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#550: FILE: ./hal/HalBtcOutSrc.h:550:
    +void EXhalbtcoutsrc_PnpNotify(struct BTC_COEXIST * pBtCoexist, u8 pnpState);

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#551: FILE: ./hal/HalBtcOutSrc.h:551:
    +void EXhalbtcoutsrc_Periodical(struct BTC_COEXIST * pBtCoexist);

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#555: FILE: ./hal/HalBtcOutSrc.h:555:
    +void EXhalbtcoutsrc_DisplayBtCoexInfo(struct BTC_COEXIST * pBtCoexist);

Signed-off-by: Marco Cesati <marcocesati@gmail.com>
fengguang pushed a commit to 0day-ci/linux that referenced this pull request Mar 16, 2021
This commit fixes the following checkpatch.pl errors:

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#535: FILE: ./hal/HalBtcOutSrc.h:535:
    +void EXhalbtcoutsrc_PowerOnSetting(struct BTC_COEXIST * pBtCoexist);

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#536: FILE: ./hal/HalBtcOutSrc.h:536:
    +void EXhalbtcoutsrc_InitHwConfig(struct BTC_COEXIST * pBtCoexist, u8 bWifiOnly);

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#537: FILE: ./hal/HalBtcOutSrc.h:537:
    +void EXhalbtcoutsrc_InitCoexDm(struct BTC_COEXIST * pBtCoexist);

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#538: FILE: ./hal/HalBtcOutSrc.h:538:
    +void EXhalbtcoutsrc_IpsNotify(struct BTC_COEXIST * pBtCoexist, u8 type);

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#539: FILE: ./hal/HalBtcOutSrc.h:539:
    +void EXhalbtcoutsrc_LpsNotify(struct BTC_COEXIST * pBtCoexist, u8 type);

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#540: FILE: ./hal/HalBtcOutSrc.h:540:
    +void EXhalbtcoutsrc_ScanNotify(struct BTC_COEXIST * pBtCoexist, u8 type);

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#541: FILE: ./hal/HalBtcOutSrc.h:541:
    +void EXhalbtcoutsrc_ConnectNotify(struct BTC_COEXIST * pBtCoexist, u8 action);

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#543: FILE: ./hal/HalBtcOutSrc.h:543:
    +	struct BTC_COEXIST * pBtCoexist, enum RT_MEDIA_STATUS mediaStatus

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#545: FILE: ./hal/HalBtcOutSrc.h:545:
    +void EXhalbtcoutsrc_SpecialPacketNotify(struct BTC_COEXIST * pBtCoexist, u8 pktType);

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#547: FILE: ./hal/HalBtcOutSrc.h:547:
    +	struct BTC_COEXIST * pBtCoexist, u8 *tmpBuf, u8 length

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#549: FILE: ./hal/HalBtcOutSrc.h:549:
    +void EXhalbtcoutsrc_HaltNotify(struct BTC_COEXIST * pBtCoexist);

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#550: FILE: ./hal/HalBtcOutSrc.h:550:
    +void EXhalbtcoutsrc_PnpNotify(struct BTC_COEXIST * pBtCoexist, u8 pnpState);

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#551: FILE: ./hal/HalBtcOutSrc.h:551:
    +void EXhalbtcoutsrc_Periodical(struct BTC_COEXIST * pBtCoexist);

    ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
    torvalds#555: FILE: ./hal/HalBtcOutSrc.h:555:
    +void EXhalbtcoutsrc_DisplayBtCoexInfo(struct BTC_COEXIST * pBtCoexist);

Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Marco Cesati <marcocesati@gmail.com>
Link: https://lore.kernel.org/r/20210315170618.2566-7-marcocesati@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
ojeda added a commit to ojeda/linux that referenced this pull request Nov 11, 2021
rust: Add support for irqsave/irqrestore variant of spin lock/unlock.
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this pull request Jul 24, 2025
As arm64 JIT now supports timed may_goto instruction, make sure all
relevant tests run on this architecture. Some tests were enabled and
other required modifications to work properly on arm64.

 $ ./test_progs -a "stream*","*may_goto*",verifier_bpf_fastcall

 torvalds#404     stream_errors:OK
 [...]
 torvalds#406/2   stream_success/stream_cond_break:OK
 [...]
 torvalds#494/23  verifier_bpf_fastcall/may_goto_interaction_x86_64:SKIP
 torvalds#494/24  verifier_bpf_fastcall/may_goto_interaction_arm64:OK
 [...]
 torvalds#539/1   verifier_may_goto_1/may_goto 0:OK
 torvalds#539/2   verifier_may_goto_1/batch 2 of may_goto 0:OK
 torvalds#539/3   verifier_may_goto_1/may_goto batch with offsets 2/1/0:OK
 torvalds#539/4   verifier_may_goto_1/may_goto batch with offsets 2/0:OK
 torvalds#539     verifier_may_goto_1:OK
 torvalds#540/1   verifier_may_goto_2/C code with may_goto 0:OK
 torvalds#540     verifier_may_goto_2:OK
 Summary: 7/16 PASSED, 25 SKIPPED, 0 FAILED

Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this pull request Aug 9, 2025
As arm64 JIT now supports timed may_goto instruction, make sure all
relevant tests run on this architecture. Some tests were enabled and
other required modifications to work properly on arm64.

 $ ./test_progs -a "stream*","*may_goto*",verifier_bpf_fastcall

 torvalds#404     stream_errors:OK
 [...]
 torvalds#406/2   stream_success/stream_cond_break:OK
 [...]
 torvalds#494/23  verifier_bpf_fastcall/may_goto_interaction_x86_64:SKIP
 torvalds#494/24  verifier_bpf_fastcall/may_goto_interaction_arm64:OK
 [...]
 torvalds#539/1   verifier_may_goto_1/may_goto 0:OK
 torvalds#539/2   verifier_may_goto_1/batch 2 of may_goto 0:OK
 torvalds#539/3   verifier_may_goto_1/may_goto batch with offsets 2/1/0:OK
 torvalds#539/4   verifier_may_goto_1/may_goto batch with offsets 2/0:OK
 torvalds#539     verifier_may_goto_1:OK
 torvalds#540/1   verifier_may_goto_2/C code with may_goto 0:OK
 torvalds#540     verifier_may_goto_2:OK
 Summary: 7/16 PASSED, 25 SKIPPED, 0 FAILED

Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
guidosarducci pushed a commit to guidosarducci/linux that referenced this pull request Aug 29, 2025
As arm64 JIT now supports timed may_goto instruction, make sure all
relevant tests run on this architecture. Some tests were enabled and
other required modifications to work properly on arm64.

 $ ./test_progs -a "stream*","*may_goto*",verifier_bpf_fastcall

 torvalds#404     stream_errors:OK
 [...]
 torvalds#406/2   stream_success/stream_cond_break:OK
 [...]
 torvalds#494/23  verifier_bpf_fastcall/may_goto_interaction_x86_64:SKIP
 torvalds#494/24  verifier_bpf_fastcall/may_goto_interaction_arm64:OK
 [...]
 torvalds#539/1   verifier_may_goto_1/may_goto 0:OK
 torvalds#539/2   verifier_may_goto_1/batch 2 of may_goto 0:OK
 torvalds#539/3   verifier_may_goto_1/may_goto batch with offsets 2/1/0:OK
 torvalds#539/4   verifier_may_goto_1/may_goto batch with offsets 2/0:OK
 torvalds#539     verifier_may_goto_1:OK
 torvalds#540/1   verifier_may_goto_2/C code with may_goto 0:OK
 torvalds#540     verifier_may_goto_2:OK
 Summary: 7/16 PASSED, 25 SKIPPED, 0 FAILED

Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Acked-by: Xu Kuohai <xukuohai@huawei.com>
Link: https://lore.kernel.org/r/20250827113245.52629-3-puranjay@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
guidosarducci pushed a commit to guidosarducci/linux that referenced this pull request Aug 29, 2025
Puranjay Mohan says:

====================
bpf, arm64: support for timed may_goto

Changes in v2->v3:
v2: https://lore.kernel.org/all/20250809204833.44803-1-puranjay@kernel.org/
- Rebased on bpf-next/master
- Added Acked-by: tags from Xu and Kumar

Changes in v1->v2:
v1: https://lore.kernel.org/bpf/20250724125443.26182-1-puranjay@kernel.org/
- Added comment in arch_bpf_timed_may_goto() about BPF_REG_FP setup (Xu
  Kuohai)

This set adds support for the timed may_goto instruction for the arm64.
The timed may_goto instruction is implemented by the verifier by
reserving 2 8byte slots in the program stack and then calling
arch_bpf_timed_may_goto() in a loop with the stack offset of these two
slots in BPF_REG_AX. It expects the function to put a timestamp in the
first slot and the returned count in BPF_REG_AX is put into the second
slot by a store instruction emitted by the verifier.

arch_bpf_timed_may_goto() is special as it receives the parameter in
BPF_REG_AX and is expected to return the result in BPF_REG_AX as well.
It can't clobber any caller saved registers because verifier doesn't
save anything before emitting the call.

So, arch_bpf_timed_may_goto() is implemented in assembly so the exact
registers that are stored/restored can be controlled (BPF caller saved
registers here) and it also needs to take care of moving arguments and
return values to and from BPF_REG_AX <-> arm64 R0.

So, arch_bpf_timed_may_goto() acts as a trampoline to call
bpf_check_timed_may_goto() which does the main logic of placing the
timestamp and returning the count.

All tests that use may_goto instruction pass after the changing some of
them in patch 2

 torvalds#404     stream_errors:OK
 [...]
 torvalds#406/2   stream_success/stream_cond_break:OK
 [...]
 torvalds#494/23  verifier_bpf_fastcall/may_goto_interaction_x86_64:SKIP
 torvalds#494/24  verifier_bpf_fastcall/may_goto_interaction_arm64:OK
 [...]
 torvalds#539/1   verifier_may_goto_1/may_goto 0:OK
 torvalds#539/2   verifier_may_goto_1/batch 2 of may_goto 0:OK
 torvalds#539/3   verifier_may_goto_1/may_goto batch with offsets 2/1/0:OK
 torvalds#539/4   verifier_may_goto_1/may_goto batch with offsets 2/0:OK
 torvalds#539     verifier_may_goto_1:OK
 torvalds#540/1   verifier_may_goto_2/C code with may_goto 0:OK
 torvalds#540     verifier_may_goto_2:OK
 Summary: 7/16 PASSED, 25 SKIPPED, 0 FAILED
====================

Link: https://patch.msgid.link/20250827113245.52629-1-puranjay@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
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