Subject: CVE-2024-41077: null_blk: fix validation of block size

From: Greg Kroah-Hartman <[email-masked]>

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

null_blk: fix validation of block size

Block size should be between 512 and PAGE_SIZE and be a power of 2. The current
check does not validate this, so update the check.

Without this patch, null_blk would Oops due to a null pointer deref when
loaded with bs=1536 [1].

[axboe: remove unnecessary braces and != 0 check]

The Linux kernel CVE team has assigned CVE-2024-41077 to this issue.

Affected and fixed versions
===========================

	Fixed in 5.10.223 with commit 9625afe1dd4a
	Fixed in 5.15.164 with commit 9b873bdaae64
	Fixed in 6.1.101 with commit 2772ed2fc075
	Fixed in 6.6.42 with commit 08f03186b96e
	Fixed in 6.9.11 with commit f92409a9da02
	Fixed in 6.10 with commit c462ecd659b5

Please see https://www.kernel.org for a full list of currently supported
kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to
older supported kernel versions.  The official CVE entry at
	https://cve.org/CVERecord/?id=CVE-2024-41077
will be updated if fixes are backported, please check that for the most
up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
	drivers/block/null_blk/main.c

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest
stable kernel version for this, and many other bugfixes.  Individual
changes are never tested alone, but rather are part of a larger kernel
release.  Cherry-picking individual commits is not recommended or
supported by the Linux kernel community at all.  If however, updating to
the latest release is impossible, the individual changes to resolve this
issue can be found at these commits:
	https://git.kernel.org/stable/c/9625afe1dd4a158a14bb50f81af9e2dac634c0b1
	https://git.kernel.org/stable/c/9b873bdaae64bddade9d8c6df23c8a31948d47d0
	https://git.kernel.org/stable/c/2772ed2fc075eef7df3789906fc9dae01e4e132e
	https://git.kernel.org/stable/c/08f03186b96e25e3154916a2e70732557c770ea7
	https://git.kernel.org/stable/c/f92409a9da02f27d05d713bff5f865e386cef9b3
	https://git.kernel.org/stable/c/c462ecd659b5fce731f1d592285832fd6ad54053