From mboxrd@z Thu Jan 1 00:00:00 1970 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 EC47A1F9EAD for ; Mon, 21 Oct 2024 18:08:48 +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=1729534129; cv=none; b=LJl3eQL3wpYpJvfBayAn28j4wD2hwVq9XMdjWYLYIhDnW77xskKZVdlzPQMAXEt1Q9Agd8Sg1+9hjkLeZQ3yanWCvStJk+zf1KKL7rfza4kGgh7jn+FC8XBdFRkXXxaqwGL7DE/AppLTDzGsOVpo1ulEi0DXgJk5mehwrwcB8aE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729534129; c=relaxed/simple; bh=Xfdj6/ehRYBQnl7vcyagSEYi/9z5Ctbp3dn5S1bv02M=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=SJphmHG9jLC8dhz3lW+sCvQkrYf7HEu/6k2xYSJW2VevpDlK8VOwsQaGJ3X/O29d60POaFgXzjVi7qH1bYYbGAGpy8DC6ZyAkwMZpeyxakis+HEK1eyKTXAmDf3A1r698PlFzMCYnXeJ3ePt3luTWn/cLrlUS6Uc9Magei+feAs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=mBPeLxNg; 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="mBPeLxNg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72BF1C4CEC3; Mon, 21 Oct 2024 18:08:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1729534128; bh=Xfdj6/ehRYBQnl7vcyagSEYi/9z5Ctbp3dn5S1bv02M=; h=From:To:Cc:Subject:Date:Reply-to:From; b=mBPeLxNg5payLNqfNFkqp/LqYVeJNqJISyD7PDl4i0Mc2law4Y0kxVNiRAcYcR7Qi zf6asV9k064C0xUok7cW0z7VZoCsimFZ7QeR8vjFnS8dVpO7okZA53dbeB6r01qrzP HCLX0TtpCtE05dP8K5xqHGawAhck6WJh9cyLWJo8= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-49964: mm/hugetlb: fix memfd_pin_folios free_huge_pages leak Date: Mon, 21 Oct 2024 20:02:52 +0200 Message-ID: <2024102132-CVE-2024-49964-e06e@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=2416; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=Xfdj6/ehRYBQnl7vcyagSEYi/9z5Ctbp3dn5S1bv02M=; b=owGbwMvMwCRo6H6F97bub03G02pJDOli0/4IczXvCQvMvJzNvDRH7cHPHXKyc1T588VK49NbQ qdw9n7riGVhEGRikBVTZPmyjefo/opDil6Gtqdh5rAygQxh4OIUgInwFDAsaPjw98+8z+Iqruwb FN7GcMjPk753kWHBscmXf66SsG43E9K37XV8pill13cTAA== 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: mm/hugetlb: fix memfd_pin_folios free_huge_pages leak memfd_pin_folios followed by unpin_folios fails to restore free_huge_pages if the pages were not already faulted in, because the folio refcount for pages created by memfd_alloc_folio never goes to 0. memfd_pin_folios needs another folio_put to undo the folio_try_get below: memfd_alloc_folio() alloc_hugetlb_folio_nodemask() dequeue_hugetlb_folio_nodemask() dequeue_hugetlb_folio_node_exact() folio_ref_unfreeze(folio, 1); ; adds 1 refcount folio_try_get() ; adds 1 refcount hugetlb_add_to_page_cache() ; adds 512 refcount (on x86) With the fix, after memfd_pin_folios + unpin_folios, the refcount for the (unfaulted) page is 512, which is correct, as the refcount for a faulted unpinned page is 513. The Linux kernel CVE team has assigned CVE-2024-49964 to this issue. Affected and fixed versions =========================== Issue introduced in 6.11 with commit 89c1905d9c14 and fixed in 6.11.3 with commit 59e081ff2e91 Issue introduced in 6.11 with commit 89c1905d9c14 and fixed in 6.12-rc1 with commit c56b6f3d801d 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-49964 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: mm/gup.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/59e081ff2e91bbf19b8c1ecb75b031f778858383 https://git.kernel.org/stable/c/c56b6f3d801d7ec8965993342bdd9e2972b6cb8e