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 AF2BA1F5400 for ; Fri, 27 Dec 2024 15:00:15 +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=1735311615; cv=none; b=SVMMILun1MPsv9zUAl5J3FXyvIlSuTKNedDuQMpU/iBvEvBhkhwCI0a6MoZBnsvWUzo3CLQRm94hzr6L7i1Vj32A52eksb4tNDPWpregCwxTE75Xpk9lTH3oEuFRJDpN6UWYOrboTULJCvTO42ZksjVoiPGv+eNvfqsYtWqGI+c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735311615; c=relaxed/simple; bh=ziNOZKNshjkjqxZEKMRXeZCrhATEUN3Or+82CrUDwD4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=PFAsiVteHPFBRQ1pBkv99TEX70Ic6ElAbzuYvpi2IFh5AGq5VaNCQswcAC1adMTFYkkMmKHO/WzeVzVPXTWZzZph7yGlMcg/oVEBCqz+ITfQstEa67+nzN12lgZTpb7Sks9vTEolWAZNLJ3X2nr/xOWAuW717hIcyr1bQiiro/8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=vDvMW3/H; 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="vDvMW3/H" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13D3DC4CED0; Fri, 27 Dec 2024 15:00:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1735311615; bh=ziNOZKNshjkjqxZEKMRXeZCrhATEUN3Or+82CrUDwD4=; h=From:To:Cc:Subject:Date:Reply-to:From; b=vDvMW3/HSOlbBs1kU1L8Gzh/iE7FYy2lhlfse+rU1HSl0RVPh4KpZkl//V0NxdqHF s6goFwiRStp55GgAUQyNiXK1NA/C7YywZCtMxCKC88Iuspn6DO2WSPXM6XSGvC19Zk EgT/dC7aU4wcFQOwmXwpCpZC+1lUKPcvK4/IIXXg= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-56612: mm/gup: handle NULL pages in unpin_user_pages() Date: Fri, 27 Dec 2024 15:51:19 +0100 Message-ID: <2024122707-CVE-2024-56612-a24e@gregkh> X-Mailer: git-send-email 2.47.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=2990; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=ziNOZKNshjkjqxZEKMRXeZCrhATEUN3Or+82CrUDwD4=; b=owGbwMvMwCRo6H6F97bub03G02pJDOl5+27vSOu990FZV7L8wDWHiQcTmXbdeSdYeSN4xfwnR 2u8vLg/dMSyMAgyMciKKbJ82cZzdH/FIUUvQ9vTMHNYmUCGMHBxCsBExKQY5kc7q7BPMeJ1+lsX F7MgR+8P268PKQxzxf/J6jzR2H/bVbN6eWSsod4jWeZ/AA== 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/gup: handle NULL pages in unpin_user_pages() The recent addition of "pofs" (pages or folios) handling to gup has a flaw: it assumes that unpin_user_pages() handles NULL pages in the pages** array. That's not the case, as I discovered when I ran on a new configuration on my test machine. Fix this by skipping NULL pages in unpin_user_pages(), just like unpin_folios() already does. Details: when booting on x86 with "numa=fake=2 movablecore=4G" on Linux 6.12, and running this: tools/testing/selftests/mm/gup_longterm ...I get the following crash: BUG: kernel NULL pointer dereference, address: 0000000000000008 RIP: 0010:sanity_check_pinned_pages+0x3a/0x2d0 ... Call Trace: ? __die_body+0x66/0xb0 ? page_fault_oops+0x30c/0x3b0 ? do_user_addr_fault+0x6c3/0x720 ? irqentry_enter+0x34/0x60 ? exc_page_fault+0x68/0x100 ? asm_exc_page_fault+0x22/0x30 ? sanity_check_pinned_pages+0x3a/0x2d0 unpin_user_pages+0x24/0xe0 check_and_migrate_movable_pages_or_folios+0x455/0x4b0 __gup_longterm_locked+0x3bf/0x820 ? mmap_read_lock_killable+0x12/0x50 ? __pfx_mmap_read_lock_killable+0x10/0x10 pin_user_pages+0x66/0xa0 gup_test_ioctl+0x358/0xb20 __se_sys_ioctl+0x6b/0xc0 do_syscall_64+0x7b/0x150 entry_SYSCALL_64_after_hwframe+0x76/0x7e The Linux kernel CVE team has assigned CVE-2024-56612 to this issue. Affected and fixed versions =========================== Issue introduced in 6.12 with commit 94efde1d15399f5c88e576923db9bcd422d217f2 and fixed in 6.12.5 with commit 69d319450d1c651f3b05cd820ff285fdd810c032 Issue introduced in 6.12 with commit 94efde1d15399f5c88e576923db9bcd422d217f2 and fixed in 6.13-rc2 with commit a1268be280d8e484ab3606d7476edd0f14bb9961 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-56612 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/69d319450d1c651f3b05cd820ff285fdd810c032 https://git.kernel.org/stable/c/a1268be280d8e484ab3606d7476edd0f14bb9961