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 0FD7C335BAF for ; Mon, 15 Sep 2025 14:52:03 +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=1757947923; cv=none; b=BR+zJ/3GrrniX3Hc+QO43teEGfvZKbrMGJgfLYeMptOppZlGTQo2rSxcqhsrE/3Ofl9VmWYAG3Mkj8KSM7QntcOIkf2GvGeECHk/3z9T1llXH6SKfyBX7orOiFlJDd5NOBdMrImOXBbYjpKQfoYjUm/8NiZmVV7npNmOHxbWATo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757947923; c=relaxed/simple; bh=y9X5/B1Hz6+Sp+ouOC4I+e8d0FDQjbzwbnRDeAKH5iQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=gsAJ6vVth5g4DnEW7h0JJRxf0AxdGi76rB1zNLJGeyRa7hyxM+ydApGHpq0PdGfQzJ51ZXPWo2FXV0zN6zNLId+TrSIoJyVmK7VBq4nsZmlgGRh763Pk6DOnSIUs5bADsLiNKrTSztEZ8/vDu6o+pjx2JicQ5e5D2+WEpDmL+wA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=h6tD6FGE; 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="h6tD6FGE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09DE0C4CEF7; Mon, 15 Sep 2025 14:52:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1757947922; bh=y9X5/B1Hz6+Sp+ouOC4I+e8d0FDQjbzwbnRDeAKH5iQ=; h=From:To:Cc:Subject:Date:Reply-to:From; b=h6tD6FGEPPKLSjjhI2hDjsOmxWumLp7HjBMoiA4y+RudYmYoTlj5Dbfdeo/l0wftS E+Be2fQG8wvwPJvwNPyA3xEP49OcheWdI8wvwnCREEAGYyAif1IbmM8wr7y/HUW5Xe wa8JIGtd/idvpYJxLlfOn7cvyRPqisydSpgzBjp8= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-50335: 9p: set req refcount to zero to avoid uninitialized usage Date: Mon, 15 Sep 2025 16:49:12 +0200 Message-ID: <2025091556-CVE-2022-50335-141b@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=4911; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=qUH2BQ76AWrfrqLoDO9VR6weznFs5m20Y90ynkW1VnQ=; b=owGbwMvMwCRo6H6F97bub03G02pJDBkn1CP2MToLiPfftOO3evV5VovXFYvC0x9ig50fSlqbe 3oknWnriGVhEGRikBVTZPmyjefo/opDil6Gtqdh5rAygQxh4OIUgImoL2RYsP2yqejyuYUHE/b9 5vT6u5zB+SU/B8OCgwWWkooXbhU8evHhoVXSTXnvt1/XAAA= 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: 9p: set req refcount to zero to avoid uninitialized usage When a new request is allocated, the refcount will be zero if it is reused, but if the request is newly allocated from slab, it is not fully initialized before being added to idr. If the p9_read_work got a response before the refcount initiated. It will use a uninitialized req, which will result in a bad request data struct. Here is the logs from syzbot. Corrupted memory at 0xffff88807eade00b [ 0xff 0x07 0x00 0x00 0x00 0x00 0x00 0x00 . . . . . . . . ] (in kfence-#110): p9_fcall_fini net/9p/client.c:248 [inline] p9_req_put net/9p/client.c:396 [inline] p9_req_put+0x208/0x250 net/9p/client.c:390 p9_client_walk+0x247/0x540 net/9p/client.c:1165 clone_fid fs/9p/fid.h:21 [inline] v9fs_fid_xattr_set+0xe4/0x2b0 fs/9p/xattr.c:118 v9fs_xattr_set fs/9p/xattr.c:100 [inline] v9fs_xattr_handler_set+0x6f/0x120 fs/9p/xattr.c:159 __vfs_setxattr+0x119/0x180 fs/xattr.c:182 __vfs_setxattr_noperm+0x129/0x5f0 fs/xattr.c:216 __vfs_setxattr_locked+0x1d3/0x260 fs/xattr.c:277 vfs_setxattr+0x143/0x340 fs/xattr.c:309 setxattr+0x146/0x160 fs/xattr.c:617 path_setxattr+0x197/0x1c0 fs/xattr.c:636 __do_sys_setxattr fs/xattr.c:652 [inline] __se_sys_setxattr fs/xattr.c:648 [inline] __ia32_sys_setxattr+0xc0/0x160 fs/xattr.c:648 do_syscall_32_irqs_on arch/x86/entry/common.c:112 [inline] __do_fast_syscall_32+0x65/0xf0 arch/x86/entry/common.c:178 do_fast_syscall_32+0x33/0x70 arch/x86/entry/common.c:203 entry_SYSENTER_compat_after_hwframe+0x70/0x82 Below is a similar scenario, the scenario in the syzbot log looks more complicated than this one, but this patch can fix it. T21124 p9_read_work ======================== second trans ================================= p9_client_walk p9_client_rpc p9_client_prepare_req p9_tag_alloc req = kmem_cache_alloc(p9_req_cache, GFP_NOFS); tag = idr_alloc << preempted >> req->tc.tag = tag; /* req->[refcount/tag] == uninitialized */ m->rreq = p9_tag_lookup(m->client, m->rc.tag); /* increments uninitalized refcount */ refcount_set(&req->refcount, 2); /* cb drops one ref */ p9_client_cb(req) /* reader thread drops its ref: request is incorrectly freed */ p9_req_put(req) /* use after free and ref underflow */ p9_req_put(req) To fix it, we can initialize the refcount to zero before add to idr. The Linux kernel CVE team has assigned CVE-2022-50335 to this issue. Affected and fixed versions =========================== Issue introduced in 4.20 with commit 728356dedeff8ef999cb436c71333ef4ac51a81c and fixed in 5.15.86 with commit 1cabce56626a61f4f02452cba61ad4332a4b73f8 Issue introduced in 4.20 with commit 728356dedeff8ef999cb436c71333ef4ac51a81c and fixed in 6.0.16 with commit 73c47b3123b351de2d3714a72a336c0f72f203af Issue introduced in 4.20 with commit 728356dedeff8ef999cb436c71333ef4ac51a81c and fixed in 6.1.2 with commit 967fc34f297e40fd2e068cf6b0c3eb4916228539 Issue introduced in 4.20 with commit 728356dedeff8ef999cb436c71333ef4ac51a81c and fixed in 6.2 with commit 26273ade77f54716e30dfd40ac6e85ceb54ac0f9 Issue introduced in 4.19.57 with commit 3665a4d9dca1bd06bc34afb72e637fe01b2776ee 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-50335 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: net/9p/client.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/1cabce56626a61f4f02452cba61ad4332a4b73f8 https://git.kernel.org/stable/c/73c47b3123b351de2d3714a72a336c0f72f203af https://git.kernel.org/stable/c/967fc34f297e40fd2e068cf6b0c3eb4916228539 https://git.kernel.org/stable/c/26273ade77f54716e30dfd40ac6e85ceb54ac0f9