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 9FA5C2857C9 for ; Wed, 18 Jun 2025 10:55:17 +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=1750244117; cv=none; b=VK5aeNcm+M8FZAfhdj8mcab4F5oCTwrxkf5RJHyCmoInI6N1WJA0K/mf09oDmleSMIp4zAKUBfk/QTvOwqZvzNW7MhGr2B+SkbX74yj3Qm1C73V97CR5tJ3JeT/Gh+1eQLrlIUV+1tGw5PqEXPjVCckrdFDpb1yblOA28jRABPQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750244117; c=relaxed/simple; bh=FB/l3YX8ATfCUa/w8KhrhtHNHsE/+jT3t48qVbrYyBU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=fSre7XUGxDCN74OOsY8QI9XlBfAqh/N1EZq+8YmbtYgR1+qm9C8xUxpDOxHLqfcs/ljIosr/CFYY4gqN91ZbpyNlrVefujh9W4zKIwIeq+OdiHdh91OKl31ZNI9C56eAn8FtyiDQwlNGxCpcKai5oNROULjRm/VNaFWs70X6kys= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=p3U6NnvG; 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="p3U6NnvG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17F5AC4CEE7; Wed, 18 Jun 2025 10:55:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750244117; bh=FB/l3YX8ATfCUa/w8KhrhtHNHsE/+jT3t48qVbrYyBU=; h=From:To:Cc:Subject:Date:Reply-to:From; b=p3U6NnvGvoIO6m7878tsyFsbkJtfbfS0acLZhfyq8OM5RFETAAkYN1KGXUFdwnSd1 KuyvmA4S4VVjmkjlImYJzEtSj231ZHEQP6SlVmeoEAr2m+wPvRZzDCUaQARNIEL75j QwWvIyA5lrAxTg5rIkvxHi/mB8b8t5AuvsiAKW6c= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-49941: tty: n_gsm: avoid call of sleeping functions from atomic context Date: Wed, 18 Jun 2025 12:54:52 +0200 Message-ID: <2025061849-CVE-2022-49941-b536@gregkh> X-Mailer: git-send-email 2.49.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=5206; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=kRK/tidIAMr2VYej6Ns0Qq8/o/JJzxgY8LymXqin81w=; b=owGbwMvMwCRo6H6F97bub03G02pJDBlBs346zVH/FaG/bMrchaGmP/8eLb3xSPryqmU3JBKuv 3M1eHCHrSOWhUGQiUFWTJHlyzaeo/srDil6GdqehpnDygQyhIGLUwAmUlrJMD/82xz9d2da5gnd y13PaT45Z2l6ewDDgp2nDjHLsf615yz9qll/8vWnWU8tIgA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== In the Linux kernel, the following vulnerability has been resolved: tty: n_gsm: avoid call of sleeping functions from atomic context Syzkaller reports the following problem: BUG: sleeping function called from invalid context at kernel/printk/printk.c:2347 in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 1105, name: syz-executor423 3 locks held by syz-executor423/1105: #0: ffff8881468b9098 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref_wait+0x22/0x90 drivers/tty/tty_ldisc.c:266 #1: ffff8881468b9130 (&tty->atomic_write_lock){+.+.}-{3:3}, at: tty_write_lock drivers/tty/tty_io.c:952 [inline] #1: ffff8881468b9130 (&tty->atomic_write_lock){+.+.}-{3:3}, at: do_tty_write drivers/tty/tty_io.c:975 [inline] #1: ffff8881468b9130 (&tty->atomic_write_lock){+.+.}-{3:3}, at: file_tty_write.constprop.0+0x2a8/0x8e0 drivers/tty/tty_io.c:1118 #2: ffff88801b06c398 (&gsm->tx_lock){....}-{2:2}, at: gsmld_write+0x5e/0x150 drivers/tty/n_gsm.c:2717 irq event stamp: 3482 hardirqs last enabled at (3481): [] __get_reqs_available+0x143/0x2f0 fs/aio.c:946 hardirqs last disabled at (3482): [] __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:108 [inline] hardirqs last disabled at (3482): [] _raw_spin_lock_irqsave+0x52/0x60 kernel/locking/spinlock.c:159 softirqs last enabled at (3408): [] asm_call_irq_on_stack+0x12/0x20 softirqs last disabled at (3401): [] asm_call_irq_on_stack+0x12/0x20 Preemption disabled at: [<0000000000000000>] 0x0 CPU: 2 PID: 1105 Comm: syz-executor423 Not tainted 5.10.137-syzkaller #0 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x107/0x167 lib/dump_stack.c:118 ___might_sleep.cold+0x1e8/0x22e kernel/sched/core.c:7304 console_lock+0x19/0x80 kernel/printk/printk.c:2347 do_con_write+0x113/0x1de0 drivers/tty/vt/vt.c:2909 con_write+0x22/0xc0 drivers/tty/vt/vt.c:3296 gsmld_write+0xd0/0x150 drivers/tty/n_gsm.c:2720 do_tty_write drivers/tty/tty_io.c:1028 [inline] file_tty_write.constprop.0+0x502/0x8e0 drivers/tty/tty_io.c:1118 call_write_iter include/linux/fs.h:1903 [inline] aio_write+0x355/0x7b0 fs/aio.c:1580 __io_submit_one fs/aio.c:1952 [inline] io_submit_one+0xf45/0x1a90 fs/aio.c:1999 __do_sys_io_submit fs/aio.c:2058 [inline] __se_sys_io_submit fs/aio.c:2028 [inline] __x64_sys_io_submit+0x18c/0x2f0 fs/aio.c:2028 do_syscall_64+0x33/0x40 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x61/0xc6 The problem happens in the following control flow: gsmld_write(...) spin_lock_irqsave(&gsm->tx_lock, flags) // taken a spinlock on TX data con_write(...) do_con_write(...) console_lock() might_sleep() // -> bug As far as console_lock() might sleep it should not be called with spinlock held. The patch replaces tx_lock spinlock with mutex in order to avoid the problem. Found by Linux Verification Center (linuxtesting.org) with Syzkaller. The Linux kernel CVE team has assigned CVE-2022-49941 to this issue. Affected and fixed versions =========================== Issue introduced in 5.10.137 with commit 273d412177216c7712fb08f2b914ef7f4d8a9ed7 and fixed in 5.10.143 with commit eb75efdec8dd0f01ac85c88feafa6e63b34a2521 Issue introduced in 5.19.2 with commit 5320aa45f526ddd3374e6226842467b788894b34 and fixed in 5.19.8 with commit 132331c1f605eb5911795a6b9115114575594d0a Issue introduced in 4.14.291 with commit e1e3b6517ddbb0e9934785d3bd94e61fde05c6ec Issue introduced in 4.19.256 with commit c530595b28effe99d99041e7f57371e046535007 Issue introduced in 5.4.211 with commit fbf979564682edf1b727d4b6620ca70c59f4ee62 Issue introduced in 5.15.61 with commit c9754e10f1a57c1be24f6fb0cade58253e05a109 Issue introduced in 5.18.18 with commit b9a1395783a0ae488a7a74e4d97b43322067f200 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-49941 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: drivers/tty/n_gsm.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/eb75efdec8dd0f01ac85c88feafa6e63b34a2521 https://git.kernel.org/stable/c/132331c1f605eb5911795a6b9115114575594d0a https://git.kernel.org/stable/c/902e02ea9385373ce4b142576eef41c642703955