Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2073F1E9067 for ; Mon, 21 Oct 2024 12:03:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729512193; cv=none; b=AWlTcBHCrrFAl1Tky6lSMTW5clIP9ckLECmJ3v4XW/4v+8Qozs9eM9DomZZ8RABV4Yp0BgN7SBArjRhngKNAyw8Fg+VqgFr5/TisLTyUwLzKZy9go1GVZiCbd2FXV70g9HWz//O+rPuWRJexwcddc0x6DZn5sGE3CwjUnkvTjJc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729512193; c=relaxed/simple; bh=syKb2OnsSWsKapOlkYqS9oUt0ICris+Qe3YFjj1Dhgc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=F/0QdYporKT+4/0BY5NBUC60R+bdTaTizZMp0Cu9iEVWA5ecE5VdSeDridYsaZAGFH501/jmlWnusQDzX4G5bGkxwAna+s2PwpdFun2080TX9g3eG2N0uftsptFbKD6qOc5UfOk+Bn4PeA1duTXi6N7sqxBmmo0ZcJvhb+oxvQU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=GFhojHFu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="GFhojHFu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A2B3C4CEC3; Mon, 21 Oct 2024 12:03:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1729512192; bh=syKb2OnsSWsKapOlkYqS9oUt0ICris+Qe3YFjj1Dhgc=; h=From:To:Cc:Subject:Date:Reply-to:From; b=GFhojHFuQ0KjuFlJe7xavKXU/KYrvuhNRuxRrQTPZfiQD2Ou1hes4WOcezac0MHn3 DHxCBCwIdeeBSYSnUF+HPxnxrzdeuCSqQ6N85Bw2fHkItZd6fVVdugmMN5p8+NOc9q R2XtvmJYRjP54kmrmbwcprixK9y6zKKpRrb/KaXQ= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-47680: f2fs: check discard support for conventional zones Date: Mon, 21 Oct 2024 14:00:08 +0200 Message-ID: <2024102107-CVE-2024-47680-194f@gregkh> X-Mailer: git-send-email 2.47.0 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=3527; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=syKb2OnsSWsKapOlkYqS9oUt0ICris+Qe3YFjj1Dhgc=; b=kA0DAAIRMUfUDdst+ykByyZiAGcWQkeiJurR2qzFGtpk2+z3DZpXTews7wlCUHVwy6uFdhJf+ YhdBAARAgAdFiEE9LYMxb94wiFKMT3LMUfUDdst+ykFAmcWQkcACgkQMUfUDdst+ymQuQCgmkVK NFvHr8x5ecgcir00Iwzfk6MAoJC7NZdRt4SUB5KCqwrteIOupnWk X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: f2fs: check discard support for conventional zones As the helper function f2fs_bdev_support_discard() shows, f2fs checks if the target block devices support discard by calling bdev_max_discard_sectors() and bdev_is_zoned(). This check works well for most cases, but it does not work for conventional zones on zoned block devices. F2fs assumes that zoned block devices support discard, and calls __submit_discard_cmd(). When __submit_discard_cmd() is called for sequential write required zones, it works fine since __submit_discard_cmd() issues zone reset commands instead of discard commands. However, when __submit_discard_cmd() is called for conventional zones, __blkdev_issue_discard() is called even when the devices do not support discard. The inappropriate __blkdev_issue_discard() call was not a problem before the commit 30f1e7241422 ("block: move discard checks into the ioctl handler") because __blkdev_issue_discard() checked if the target devices support discard or not. If not, it returned EOPNOTSUPP. After the commit, __blkdev_issue_discard() no longer checks it. It always returns zero and sets NULL to the given bio pointer. This NULL pointer triggers f2fs_bug_on() in __submit_discard_cmd(). The BUG is recreated with the commands below at the umount step, where /dev/nullb0 is a zoned null_blk with 5GB total size, 128MB zone size and 10 conventional zones. $ mkfs.f2fs -f -m /dev/nullb0 $ mount /dev/nullb0 /mnt $ for ((i=0;i<5;i++)); do dd if=/dev/zero of=/mnt/test bs=65536 count=1600 conv=fsync; done $ umount /mnt To fix the BUG, avoid the inappropriate __blkdev_issue_discard() call. When discard is requested for conventional zones, check if the device supports discard or not. If not, return EOPNOTSUPP. The Linux kernel CVE team has assigned CVE-2024-47680 to this issue. Affected and fixed versions =========================== Issue introduced in 6.10 with commit 30f1e7241422 and fixed in 6.10.13 with commit 7bd7ce68ddad Issue introduced in 6.10 with commit 30f1e7241422 and fixed in 6.11.2 with commit d2352b57897f Issue introduced in 6.10 with commit 30f1e7241422 and fixed in 6.12-rc1 with commit 43aec4d01bd2 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-47680 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: fs/f2fs/segment.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/7bd7ce68ddad5a28565e42ef21cacaff113773a9 https://git.kernel.org/stable/c/d2352b57897f6a3349666fc318dcbec99092c6a5 https://git.kernel.org/stable/c/43aec4d01bd2ce961817a777b3846f8318f398e4