From nobody Fri Jun 23 15:09:54 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QngdZ5x9Hz4gjgs; Fri, 23 Jun 2023 15:09:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QngdZ5FBPz3PTx; Fri, 23 Jun 2023 15:09:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687532994; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=WH77SUZNGdIy6NiTGnue/kg5lPfrP0/Fi4LvGUzaI2c=; b=l3xe6sTaPyOzH5sqoTzXDjWgDVycXpGbPTlyW8PMm7lG6s4rXYsq9xYxsH6SB7+825FfsT OSo9pNamw2hbmJX1RLrQdJk3pZajLQJwZU8pq5D6U/yD23IoL+B03OIKFzTdpTLfp55CgY fuu4R3uOqOl3oTOK4R7LGYO1E5dY9Oako6iv8BfEDSQ1IR92c1Y0/oZyMxBcczqz1PzIpx mDdoiqdA1wj86GHAxRQytCq8IkrPe/4Qbs2/vWaC8kcZhzzJKTFIg0VCN54JHT7wGxuMT+ FPRuEj9aFuAxPu+X5FIymoOjBFmirgpMZOHYoCW5QTAgbYS2SBesS/0aAuLBCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687532994; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=WH77SUZNGdIy6NiTGnue/kg5lPfrP0/Fi4LvGUzaI2c=; b=wRNQYxVwfHmR/TfkKMh/oj2+N1591wbMuzaOieBlY6hwv6zrSyJMm10qgYk9Fszr3094xX foIux9ITVWiSUfFg5hb1GMq56xNDLLkuw7fILWfHxf/aQQ/3CeR8sFRz84CjJTKt9WcaiU DLGug1dR1/Ks63DnTs+pxe+iIm7xz1oSBPk+0Nz3Ihjvr9ferQrcP3elUhMiiVNIOovUBK /mXN9QLQVNEg6IO6nqZghOjZG2wKHoEqV287eY3p5jW92aEgP3G/Qxu6SPub1jct03iuZJ SGmcUsVHaW59AnKt2VtwKBuIswT3hT5eBTvzHr1vye6FSQoCYV0NGNBCidTiVA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1687532994; a=rsa-sha256; cv=none; b=WSVLUMQwCBNmKBOohhzcKmm265ZuUXTFjjzU8NZ+WsWMdp1I28iHdOW2bqIjmV9HfI42k6 ZcVNwvnHjn99Xp4/kOwsnKAPZdByDMcTKiryg5VdClA9yuqKu8tMTft6QkZly9C/FIp3z0 ekut5pBi+1ApchPSprntcew/dU6pP1KjCshhOd/3d5/f22cxMWDVD7u0usI5Sk5EEL3Nnr 3z5ddHAHgDvD5Jzi2Y6/iBmWYO2cn5fkK2LGQQjW1UZ1c+s7yyXSyOWwTmQf8rQLO26A+Q 4lmNdWOVe++Gbt5ZapVptADsT/1yMyafu9korq9LoSSu1n16PSoM/n0AxdMD0g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QngdZ4GZfz18CM; Fri, 23 Jun 2023 15:09:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 35NF9s3C037727; Fri, 23 Jun 2023 15:09:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35NF9sAk037726; Fri, 23 Jun 2023 15:09:54 GMT (envelope-from git) Date: Fri, 23 Jun 2023 15:09:54 GMT Message-Id: <202306231509.35NF9sAk037726@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: fc915f1be145 - main - pseudofs: Fix a potential out-of-bounds access in pfs_lookup() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fc915f1be145a52c53f6f1c37525043216e32bb8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=fc915f1be145a52c53f6f1c37525043216e32bb8 commit fc915f1be145a52c53f6f1c37525043216e32bb8 Author: Mark Johnston AuthorDate: 2023-06-23 13:54:39 +0000 Commit: Mark Johnston CommitDate: 2023-06-23 13:54:39 +0000 pseudofs: Fix a potential out-of-bounds access in pfs_lookup() pseudofs nodes store their name in a flexible array member, so the node allocation is sized using the length of the name, including a nul terminator. pfs_lookup() scans a directory of nodes, comparing names to find a match. The comparison was incorrect and assumed that all node names were at least as long as the name being looked up, which of course isn't true. I believe the bug is mostly harmless since it cannot result in false positive or negative matches from the lookup, but it triggers a KASAN check. Reported by: pho Reviewed by: kib, Olivier Certner MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D40692 --- sys/fs/pseudofs/pseudofs_vnops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/fs/pseudofs/pseudofs_vnops.c b/sys/fs/pseudofs/pseudofs_vnops.c index 53e4c2b6b85c..bf423f0ad4db 100644 --- a/sys/fs/pseudofs/pseudofs_vnops.c +++ b/sys/fs/pseudofs/pseudofs_vnops.c @@ -537,8 +537,8 @@ pfs_lookup(struct vop_cachedlookup_args *va) for (pn = pd->pn_nodes; pn != NULL; pn = pn->pn_next) if (pn->pn_type == pfstype_procdir) pdn = pn; - else if (pn->pn_name[namelen] == '\0' && - bcmp(pname, pn->pn_name, namelen) == 0) { + else if (strncmp(pname, pn->pn_name, namelen) == 0 && + pn->pn_name[namelen] == '\0') { pfs_unlock(pd); goto got_pnode; }