Go to file
Tejun Heo 223164bd80 blk-iocost: fix NULL iocg deref from racing against initialization
ANBZ: #10868

commit d16baa3f14 upstream.

When initializing iocost for a queue, its rqos should be registered before
the blkcg policy is activated to allow policy data initiailization to lookup
the associated ioc. This unfortunately means that the rqos methods can be
called on bios before iocgs are attached to all existing blkgs.

While the race is theoretically possible on ioc_rqos_throttle(), it mostly
happened in ioc_rqos_merge() due to the difference in how they lookup ioc.
The former determines it from the passed in @rqos and then bails before
dereferencing iocg if the looked up ioc is disabled, which most likely is
the case if initialization is still in progress. The latter looked up ioc by
dereferencing the possibly NULL iocg making it a lot more prone to actually
triggering the bug.

* Make ioc_rqos_merge() use the same method as ioc_rqos_throttle() to look
  up ioc for consistency.

* Make ioc_rqos_throttle() and ioc_rqos_merge() test for NULL iocg before
  dereferencing it.

* Explain the danger of NULL iocgs in blk_iocost_init().

[backport note]
fix conflict caused by "alinux: iocost: fix NULL pointer dereference in
ioc_rqos_throttle".

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Jonathan Lemon <bsd@fb.com>
Cc: stable@vger.kernel.org # v5.4+
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Ferry Meng <mengferry@linux.alibaba.com>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3840
2024-09-18 14:59:22 +08:00
Documentation anolis: iommu/vt-d: add kh40000_iommu_dma_ops for KH-40000 2024-08-08 17:15:42 +08:00
LICENSES
arch anolis: x86/hpet: Read HPET directly if panic in progress 2024-09-05 11:20:36 +00:00
block blk-iocost: fix NULL iocg deref from racing against initialization 2024-09-18 14:59:22 +08:00
certs .gitignore: add SPDX License Identifier 2020-09-02 17:52:15 +08:00
crypto anolis: crypto: x86/sm4 - add support for Zhaoxin GMI SM4 Block Cipher Algorithm 2024-08-07 05:52:26 +00:00
drivers anolis: iommu/vt-d: add kh40000_iommu_dma_ops for KH-40000 2024-08-08 17:15:42 +08:00
firmware .gitignore: add SPDX License Identifier 2020-09-02 17:52:15 +08:00
fs erofs: avoid allocating DEFLATE streams before mounting 2024-06-05 03:09:49 +00:00
include anolis: x86/amd_nb: Add support for Hygon family 18h model 10h 2024-06-26 02:42:00 -04:00
init bpf, x86, arm64: Enable jit by default when not built as always-on 2024-02-29 20:47:29 +08:00
ipc memcg: enable accounting of ipc resources 2023-03-18 02:22:30 +00:00
kernel anolis: iommu/vt-d: add kh40000_swiotlb_dma_ops for KH-40000 2024-08-08 17:24:47 +08:00
lib lib/xz, lib/decompress_unxz.c: Fix spelling in comments 2024-03-18 18:03:46 +08:00
mm anolis: check cgroup v1 for memcg_blkcg_tree operations 2024-05-09 15:54:37 +08:00
net netfilter: nftables: exthdr: fix 4-byte stack OOB write 2024-06-27 10:49:18 +00:00
samples anolis: add ./ to the executable file in test_cgrp2_sock.sh 2024-03-15 16:34:22 +08:00
scripts bpf: Support llvm-objcopy for vmlinux BTF 2024-03-25 03:47:25 +00:00
security tpm: use u32 instead of int for PCR index 2023-09-05 16:55:06 +08:00
sound anolis: ALSA: hda: Add support for Hygon family 18h model 10h HD-Audio 2024-06-26 02:47:04 -04:00
tools selftest/bpf: Verifier tests for var-off access 2024-03-25 03:47:25 +00:00
usr .gitignore: add SPDX License Identifier 2020-09-02 17:52:15 +08:00
virt KVM: x86: Fix APIC page invalidation race 2024-01-25 02:10:56 +00:00
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore .gitignore: add SPDX License Identifier 2020-09-02 17:52:15 +08:00
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS anolis: net: txgbevf: Add build support for txgbevf 2024-05-27 07:30:09 +00:00
Makefile kbuild: Unify options for BTF generation for vmlinux and modules 2024-02-01 16:16:31 +08:00
README

README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.
See Documentation/00-INDEX for a list of what is contained in each file.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.