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 D774675809 for ; Mon, 15 Sep 2025 14:46:51 +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=1757947611; cv=none; b=OB3nbznP+J4m0dqy+ikNaq0p9+2TmnZcxaXI+0GJU7IRb60NuinQAc87QcQtWZgl64SHl66p6NM0zJQg6yQLe/uOa00jQjE7zIjbBlobkcM/tSRc25A3XY/efhLIfJQ+VO0lh2KrVfwSqHxxzvjlWQDdkTd5EF4YfJOJlNMoYzo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757947611; c=relaxed/simple; bh=oS60IJQnIV/N1stZwMBNNsu7ru0z3ujFe4MoirADWlA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=pyButfN7sOI3vkv3ejBCp5VrJUgMlFmB5BcG8Epa0QqOSZghBo3SdpVyZs9XizhURR9CIVaoohYhQT3KBGGDtWTgkOgKxvXOSG69v6t3AW/yQ+Dmk3IwoTvqInkQTMqObswFmhSiCPnVaQNHlrfQPco5AASNvibZ9m40942zFIs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=NyWM9rPc; 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="NyWM9rPc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE500C4CEF1; Mon, 15 Sep 2025 14:46:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1757947611; bh=oS60IJQnIV/N1stZwMBNNsu7ru0z3ujFe4MoirADWlA=; h=From:To:Cc:Subject:Date:Reply-to:From; b=NyWM9rPcvzSEuJ44xlCYr+su5V81xO0k0uqIxIpAQ014BaZDAHo5lqXiPKe/+4SM3 wIQ0N5vbecF0uxl4prbnomltaKSZhnSEiu2ARWenxYc3OwjPKpu2mLjKnm4p0qZ9zj mGA1bHLzClfo0ExxAM+n3Jy6voSRJdV6JYYBhkd4= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-50304: mtd: core: fix possible resource leak in init_mtd() Date: Mon, 15 Sep 2025 16:46:06 +0200 Message-ID: <2025091558-CVE-2022-50304-4b20@gregkh> X-Mailer: git-send-email 2.51.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=3024; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=f0eg/uGXAfoM0kr8PkrBCG81ddRWuTpZr6jnTNDHVpY=; b=owGbwMvMwCRo6H6F97bub03G02pJDBkn1JalT3i+9O9bCT7OModMtWcmhlpKMiH5a24UdwQ89 CzYu82rI5aFQZCJQVZMkeXLNp6j+ysOKXoZ2p6GmcPKBDKEgYtTACbC4MKw4NpN00W7+bxEti9Y ZvtiZZxa6ROmYIYFl7en/7qw8UNi4I3WqWHLkjrlSjJ2AQA= 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: mtd: core: fix possible resource leak in init_mtd() I got the error report while inject fault in init_mtd(): sysfs: cannot create duplicate filename '/devices/virtual/bdi/mtd-0' Call Trace: dump_stack_lvl+0x67/0x83 sysfs_warn_dup+0x60/0x70 sysfs_create_dir_ns+0x109/0x120 kobject_add_internal+0xce/0x2f0 kobject_add+0x98/0x110 device_add+0x179/0xc00 device_create_groups_vargs+0xf4/0x100 device_create+0x7b/0xb0 bdi_register_va.part.13+0x58/0x2d0 bdi_register+0x9b/0xb0 init_mtd+0x62/0x171 [mtd] do_one_initcall+0x6c/0x3c0 do_init_module+0x58/0x222 load_module+0x268e/0x27d0 __do_sys_finit_module+0xd5/0x140 do_syscall_64+0x37/0x90 entry_SYSCALL_64_after_hwframe+0x63/0xcd kobject_add_internal failed for mtd-0 with -EEXIST, don't try to register things with the same name in the same directory. Error registering mtd class or bdi: -17 If init_mtdchar() fails in init_mtd(), mtd_bdi will not be unregistered, as a result, we can't load the mtd module again, to fix this by calling bdi_unregister(mtd_bdi) after out_procfs label. The Linux kernel CVE team has assigned CVE-2022-50304 to this issue. Affected and fixed versions =========================== Issue introduced in 4.10 with commit 445caaa20c4d6da74f426464f90513b81157ad77 and fixed in 6.0.16 with commit 78816504100cbd8e6836df9f58cc4fbb8b262f1c Issue introduced in 4.10 with commit 445caaa20c4d6da74f426464f90513b81157ad77 and fixed in 6.1.2 with commit 26c304a3f136009c5a2a04e2bf3ac6aa25aabcb4 Issue introduced in 4.10 with commit 445caaa20c4d6da74f426464f90513b81157ad77 and fixed in 6.2 with commit 1aadf01e5076b9ab6bf294b9622335c651314895 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-50304 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/mtd/mtdcore.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/78816504100cbd8e6836df9f58cc4fbb8b262f1c https://git.kernel.org/stable/c/26c304a3f136009c5a2a04e2bf3ac6aa25aabcb4 https://git.kernel.org/stable/c/1aadf01e5076b9ab6bf294b9622335c651314895