CVE-2022-49394

EUVD-2022-54835
In the Linux kernel, the following vulnerability has been resolved:

blk-iolatency: Fix inflight count imbalances and IO hangs on offline

iolatency needs to track the number of inflight IOs per cgroup. As this
tracking can be expensive, it is disabled when no cgroup has iolatency
configured for the device. To ensure that the inflight counters stay
balanced, iolatency_set_limit() freezes the request_queue while manipulating
the enabled counter, which ensures that no IO is in flight and thus all
counters are zero.

Unfortunately, iolatency_set_limit() isn't the only place where the enabled
counter is manipulated. iolatency_pd_offline() can also dec the counter and
trigger disabling. As this disabling happens without freezing the q, this
can easily happen while some IOs are in flight and thus leak the counts.

This can be easily demonstrated by turning on iolatency on an one empty
cgroup while IOs are in flight in other cgroups and then removing the
cgroup. Note that iolatency shouldn't have been enabled elsewhere in the
system to ensure that removing the cgroup disables iolatency for the whole
device.

The following keeps flipping on and off iolatency on sda:

  echo +io > /sys/fs/cgroup/cgroup.subtree_control
  while true; do
      mkdir -p /sys/fs/cgroup/test
      echo '8:0 target=100000' > /sys/fs/cgroup/test/io.latency
      sleep 1
      rmdir /sys/fs/cgroup/test
      sleep 1
  done

and there's concurrent fio generating direct rand reads:

  fio --name test --filename=/dev/sda --direct=1 --rw=randread \
      --runtime=600 --time_based --iodepth=256 --numjobs=4 --bs=4k

while monitoring with the following drgn script:

  while True:
    for css in css_for_each_descendant_pre(prog['blkcg_root'].css.address_of_()):
        for pos in hlist_for_each(container_of(css, 'struct blkcg', 'css').blkg_list):
            blkg = container_of(pos, 'struct blkcg_gq', 'blkcg_node')
            pd = blkg.pd[prog['blkcg_policy_iolatency'].plid]
            if pd.value_() == 0:
                continue
            iolat = container_of(pd, 'struct iolatency_grp', 'pd')
            inflight = iolat.rq_wait.inflight.counter.value_()
            if inflight:
                print(f'inflight={inflight} {disk_name(blkg.q.disk).decode("utf-8")} '
                      f'{cgroup_path(css.cgroup).decode("utf-8")}')
    time.sleep(1)

The monitoring output looks like the following:

  inflight=1 sda /user.slice
  inflight=1 sda /user.slice
  ...
  inflight=14 sda /user.slice
  inflight=13 sda /user.slice
  inflight=17 sda /user.slice
  inflight=15 sda /user.slice
  inflight=18 sda /user.slice
  inflight=17 sda /user.slice
  inflight=20 sda /user.slice
  inflight=19 sda /user.slice <- fio stopped, inflight stuck at 19
  inflight=19 sda /user.slice
  inflight=19 sda /user.slice

If a cgroup with stuck inflight ends up getting throttled, the throttled IOs
will never get issued as there's no completion event to wake it up leading
to an indefinite hang.

This patch fixes the bug by unifying enable handling into a work item which
is automatically kicked off from iolatency_set_min_lat_nsec() which is
called from both iolatency_set_limit() and iolatency_pd_offline() paths.
Punting to a work item is necessary as iolatency_pd_offline() is called
under spinlocks while freezing a request_queue requires a sleepable context.

This also simplifies the code reducing LOC sans the comments and avoids the
unnecessary freezes which were happening whenever a cgroup's latency target
is newly set or cleared.
ProviderTypeBase ScoreAtk. VectorAtk. ComplexityPriv. RequiredVector
NISTPrimary
5.5 MEDIUM
LOCAL
LOW
LOW
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H
Base Score
CVSS 3.x
EPSS Score
Percentile: 3%
Affected Products (NVD)
VendorProductVersion
linuxlinux_kernel
4.19.29 ≤
𝑥
< 4.19.247
linuxlinux_kernel
4.20.16 ≤
𝑥
< 5.0
linuxlinux_kernel
5.0.1 ≤
𝑥
< 5.4.198
linuxlinux_kernel
5.5 ≤
𝑥
< 5.10.121
linuxlinux_kernel
5.11 ≤
𝑥
< 5.15.46
linuxlinux_kernel
5.16 ≤
𝑥
< 5.17.14
linuxlinux_kernel
5.18 ≤
𝑥
< 5.18.3
linuxlinux_kernel
5.0
linuxlinux_kernel
5.0:rc6
linuxlinux_kernel
5.0:rc7
linuxlinux_kernel
5.0:rc8
𝑥
= Vulnerable software versions
Debian logo
Debian Releases
Debian Product
Codename
linux
bookworm
6.1.123-1
fixed
bookworm (security)
6.1.128-1
fixed
bullseye
5.10.223-1
fixed
bullseye (security)
5.10.234-1
fixed
sid
6.12.16-1
fixed
trixie
6.12.12-1
fixed
openSUSE logo
openSUSE / SLES Releases
openSUSE Product
Release
cluster-md-kmp-default
suse enterprise server 15 SP5
5.14.21-150500.55.100.1
fixed
dlm-kmp-default
suse enterprise server 15 SP5
5.14.21-150500.55.100.1
fixed
gfs2-kmp-default
suse enterprise server 15 SP5
5.14.21-150500.55.100.1
fixed
kernel-64kb
suse enterprise server 15 SP3
5.3.18-150300.59.201.1
fixed
suse enterprise server 15 SP4
5.14.21-150400.24.158.1
fixed
suse enterprise server 15 SP5
5.14.21-150500.55.100.1
fixed
kernel-default
suse enterprise server 15 SP3
5.3.18-150300.59.201.1
fixed
suse enterprise server 15 SP4
5.14.21-150400.24.158.1
fixed
suse enterprise server 15 SP5
5.14.21-150500.55.100.1
fixed
kernel-default-base
suse enterprise server 15 SP3
5.3.18-150300.59.201.1.150300.18.120.1
fixed
suse enterprise server 15 SP4
5.14.21-150400.24.158.1.150400.24.78.1
fixed
suse enterprise server 15 SP5
5.14.21-150500.55.100.1.150500.6.47.1
fixed
kernel-docs
suse enterprise server 15 SP3
5.3.18-150300.59.201.1
fixed
suse enterprise server 15 SP4
5.14.21-150400.24.158.1
fixed
suse enterprise server 15 SP5
5.14.21-150500.55.100.1
fixed
kernel-macros
suse enterprise server 15 SP3
5.3.18-150300.59.201.1
fixed
suse enterprise server 15 SP4
5.14.21-150400.24.158.1
fixed
suse enterprise server 15 SP5
5.14.21-150500.55.100.1
fixed
kernel-obs-build
suse enterprise server 15 SP3
5.3.18-150300.59.201.1
fixed
suse enterprise server 15 SP4
5.14.21-150400.24.158.1
fixed
suse enterprise server 15 SP5
5.14.21-150500.55.100.1
fixed
kernel-preempt
suse enterprise server 15 SP3
5.3.18-150300.59.201.1
fixed
kernel-source
suse enterprise server 15 SP3
5.3.18-150300.59.201.1
fixed
suse enterprise server 15 SP4
5.14.21-150400.24.158.1
fixed
suse enterprise server 15 SP5
5.14.21-150500.55.100.1
fixed
kernel-syms
suse enterprise server 15 SP3
5.3.18-150300.59.201.1
fixed
suse enterprise server 15 SP4
5.14.21-150400.24.158.1
fixed
suse enterprise server 15 SP5
5.14.21-150500.55.100.1
fixed
kernel-zfcpdump
suse enterprise server 15 SP3
5.3.18-150300.59.201.1
fixed
suse enterprise server 15 SP4
5.14.21-150400.24.158.1
fixed
suse enterprise server 15 SP5
5.14.21-150500.55.100.1
fixed
ocfs2-kmp-default
suse enterprise server 15 SP5
5.14.21-150500.55.100.1
fixed
reiserfs-kmp-default
suse enterprise server 15 SP3
5.3.18-150300.59.201.1
fixed
suse enterprise server 15 SP4
5.14.21-150400.24.158.1
fixed
suse enterprise server 15 SP5
5.14.21-150500.55.100.1
fixed
Red Hat logo
Red Hat Enterprise Linux Releases
Red Hat Product
Release
bpftool
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed
kernel
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed
kernel-abi-stablelists
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed
kernel-core
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed
kernel-debug
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed
kernel-debug-core
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed
kernel-debug-devel
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed
kernel-debug-devel-matched
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed
kernel-debug-modules
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed
kernel-debug-modules-extra
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed
kernel-devel
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed
kernel-devel-matched
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed
kernel-doc
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed
kernel-modules
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed
kernel-modules-extra
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed
kernel-tools
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed
kernel-tools-libs
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed
kernel-tools-libs-devel
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed
kernel-zfcpdump
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed
kernel-zfcpdump-core
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed
kernel-zfcpdump-devel
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed
kernel-zfcpdump-devel-matched
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed
kernel-zfcpdump-modules
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed
kernel-zfcpdump-modules-extra
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed
perf
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed
python3-perf
RHEL 9
0:5.14.0-162.6.1.el9_1
fixed