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 CD21116D4D4 for ; Wed, 21 Aug 2024 06:13:40 +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=1724220820; cv=none; b=lA6imohCZdRI6Sa81ssG/W+dJCKvegZ+zzwN2D/GlsTvdVvPUtM31jAQPpBWrJ9VFGrDJdpA9ypniuuoU4DoDpp63XA54HUCHEHBrQw/fi5qbFUskjZoAMWjQN+G9XLNoK0oSrsVG6YoflgT008YaS9rwREsriXwaNMJFjgS10M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724220820; c=relaxed/simple; bh=CrMckTMoDj6MelrkZYYdONH6STrIu5m1/fMpYhr28tg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=M8Ygux+4rNX3YdiWaw06wPd85vopCnmPBDyhrglZmsGo9T6qL36mGvhhCCvp19ZQNQbvGplywkvUjPTPPGYC13zsJ2wNcU0aTqhPoiPJ5MSgtExeUFxINPorkHCIFsZUpt6YuDifRYmOYMXjoy/dQnBfcxYn+qahfI99RuPTOn8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=BmV4PaNf; 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="BmV4PaNf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E781C32786; Wed, 21 Aug 2024 06:13:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1724220820; bh=CrMckTMoDj6MelrkZYYdONH6STrIu5m1/fMpYhr28tg=; h=From:To:Cc:Subject:Date:Reply-to:From; b=BmV4PaNfrKbFzUNR/mU9aFsARd6R78KNMTv8PBM/2KcTGfGDmkunell3vWtHdvDNP /RNz0bvwgXMr0FlWCj0KEAtg/eyHAbfUd+AomL3izJ51895WXpS5QrLQaBZTAk4oCC tdQku7HNFzkLRszRgK8sxUwTtm1L0lhj4OsTo1eE= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-48892: sched/core: Fix use-after-free bug in dup_user_cpus_ptr() Date: Wed, 21 Aug 2024 14:11:26 +0800 Message-ID: <2024082110-CVE-2022-48892-3458@gregkh> X-Mailer: git-send-email 2.46.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=3102; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=CrMckTMoDj6MelrkZYYdONH6STrIu5m1/fMpYhr28tg=; b=owGbwMvMwCRo6H6F97bub03G02pJDGlHW/792z9z7/orn/NCa73llMVFjrawf2LYL17Pd9VHe UvZzNfHOmJZGASZGGTFFFm+bOM5ur/ikKKXoe1pmDmsTCBDGLg4BWAiT2MZ5kfqBzzkO1yQu9u8 7Yq+a4vDg2vrljLMFbeUTnEymLEnbmJV17KcF4wXXjwOAwA= 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: sched/core: Fix use-after-free bug in dup_user_cpus_ptr() Since commit 07ec77a1d4e8 ("sched: Allow task CPU affinity to be restricted on asymmetric systems"), the setting and clearing of user_cpus_ptr are done under pi_lock for arm64 architecture. However, dup_user_cpus_ptr() accesses user_cpus_ptr without any lock protection. Since sched_setaffinity() can be invoked from another process, the process being modified may be undergoing fork() at the same time. When racing with the clearing of user_cpus_ptr in __set_cpus_allowed_ptr_locked(), it can lead to user-after-free and possibly double-free in arm64 kernel. Commit 8f9ea86fdf99 ("sched: Always preserve the user requested cpumask") fixes this problem as user_cpus_ptr, once set, will never be cleared in a task's lifetime. However, this bug was re-introduced in commit 851a723e45d1 ("sched: Always clear user_cpus_ptr in do_set_cpus_allowed()") which allows the clearing of user_cpus_ptr in do_set_cpus_allowed(). This time, it will affect all arches. Fix this bug by always clearing the user_cpus_ptr of the newly cloned/forked task before the copying process starts and check the user_cpus_ptr state of the source task under pi_lock. Note to stable, this patch won't be applicable to stable releases. Just copy the new dup_user_cpus_ptr() function over. The Linux kernel CVE team has assigned CVE-2022-48892 to this issue. Affected and fixed versions =========================== Issue introduced in 5.15 with commit 07ec77a1d4e8 and fixed in 5.15.89 with commit b22faa21b623 Issue introduced in 5.15 with commit 07ec77a1d4e8 and fixed in 6.1.7 with commit 7b5cc7fd1789 Issue introduced in 5.15 with commit 07ec77a1d4e8 and fixed in 6.2 with commit 87ca4f9efbd7 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-2022-48892 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: kernel/sched/core.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/b22faa21b6230d5eccd233e1b7e0026a5002b287 https://git.kernel.org/stable/c/7b5cc7fd1789ea5dbb942c9f8207b076d365badc https://git.kernel.org/stable/c/87ca4f9efbd7cc649ff43b87970888f2812945b8