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 C6B6A45BF1 for ; Mon, 20 May 2024 09:48:58 +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=1716198538; cv=none; b=NYlGc2ZQbZmjg2Z/DrSTHcBF6eOVuQALgKAZeFmsJ2N/gf3WLur6YdSNtpEOKCNBNcUazr3b4iZ1b1VwQl14usft604rTmuNakfkX6M5j+2IxFMOjlV5E1C0TcEXGwmqtaPI607yiwPNBe1bJKizGWvR2CS3JIvgtX76fPQ3sCM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716198538; c=relaxed/simple; bh=tpY9bo7gb8j8oBcvo+aIuOt1GZg2qvX/xOxebt9iPbc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=n8GMGKdPjvq5AUFQAXMhtLQhtnokW8VKA1K2TrKIHAJI3s6tzFhnVCOXjp6BmVvcRJVLtz8VXq9b+8uGEqQUTtajDqpewcQkBZJtXneN1SfmYbJFDkrG22Ziz4tL8ojScUe66SDfK/OAJcOm1Hww/gJcaK3wnQJ9trv94vUsOyI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=a7znAePn; 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="a7znAePn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46BDBC2BD10; Mon, 20 May 2024 09:48:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1716198538; bh=tpY9bo7gb8j8oBcvo+aIuOt1GZg2qvX/xOxebt9iPbc=; h=From:To:Cc:Subject:Date:Reply-to:From; b=a7znAePnfwypJS35eNPavqnh62jt5vrAUM1gcxTaIKDQuSvg2G6lo5cy5ijkjvgJD nonmN2oxZ6Dmd/gG6nsO4EtaIZaSdXL4sPJAKV1C6i20P171n8CVF9KRP8qPenA0hg x9555AU6NthxniWNQtNUALN1iVugwzIE3uxxOpWo= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-36001: netfs: Fix the pre-flush when appending to a file in writethrough mode Date: Mon, 20 May 2024 11:48:37 +0200 Message-ID: <2024052023-CVE-2024-36001-e6a9@gregkh> X-Mailer: git-send-email 2.45.1 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=3159; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=tpY9bo7gb8j8oBcvo+aIuOt1GZg2qvX/xOxebt9iPbc=; b=owGbwMvMwCRo6H6F97bub03G02pJDGneMunTz/HP5RBUuLLr9CSGu45PX3atZ43IPf1VIfChv 0Whfkp1RywLgyATg6yYIsuXbTxH91ccUvQytD0NM4eVCWQIAxenAExEehfDbFbl0ODzN1PXZcoH H7sRrPi/S/pEB8NceeGVQm+y7wu/1Y1pcNph8ys7sUUGAA== 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: netfs: Fix the pre-flush when appending to a file in writethrough mode In netfs_perform_write(), when the file is marked NETFS_ICTX_WRITETHROUGH or O_*SYNC or RWF_*SYNC was specified, write-through caching is performed on a buffered file. When setting up for write-through, we flush any conflicting writes in the region and wait for the write to complete, failing if there's a write error to return. The issue arises if we're writing at or above the EOF position because we skip the flush and - more importantly - the wait. This becomes a problem if there's a partial folio at the end of the file that is being written out and we want to make a write to it too. Both the already-running write and the write we start both want to clear the writeback mark, but whoever is second causes a warning looking something like: ------------[ cut here ]------------ R=00000012: folio 11 is not under writeback WARNING: CPU: 34 PID: 654 at fs/netfs/write_collect.c:105 ... CPU: 34 PID: 654 Comm: kworker/u386:27 Tainted: G S ... ... Workqueue: events_unbound netfs_write_collection_worker ... RIP: 0010:netfs_writeback_lookup_folio Fix this by making the flush-and-wait unconditional. It will do nothing if there are no folios in the pagecache and will return quickly if there are no folios in the region specified. Further, move the WBC attachment above the flush call as the flush is going to attach a WBC and detach it again if it is not present - and since we need one anyway we might as well share it. The Linux kernel CVE team has assigned CVE-2024-36001 to this issue. Affected and fixed versions =========================== Issue introduced in 6.8 with commit 41d8e7673a77 and fixed in 6.8.9 with commit 5eaf23b2e813 Issue introduced in 6.8 with commit 41d8e7673a77 and fixed in 6.9 with commit c97f59e276d4 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-36001 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/netfs/buffered_write.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/5eaf23b2e81349f6614f88396dc468fda89fc0b9 https://git.kernel.org/stable/c/c97f59e276d4e93480f29a70accbd0d7273cf3f5