From nobody Mon Apr 24 21:32:29 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 4Q4yyj6z9vz47NNl; Mon, 24 Apr 2023 21:32:29 +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 4Q4yyj6DPfz3qpx; Mon, 24 Apr 2023 21:32:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682371949; 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=GtW59GqAUjbqZgVC3PPx3YUt+tsqPi/olaPOlyMqgto=; b=yBvWfpQfRQPPHbdxZi+65r5j6+EvMBJm9XnPHWAnoyVSaZaMmEWZVjQfLod86zJ8bXOc/8 /t9HxOzWijrWUHLbqRln6wJuFzIYd28fTZ6myd9FHmt6Szp25wA0CoMlNW8rLhK72EBsX7 xY0eTl0Lm9qypJvq07jFEkWW2UJxavHhh8GIsAlm1kYpWR6325mS/PacutzUFBJco7J72h r3SmbfYqfUQFlRuWO7x0C4rx3taCtHm1YszWfAUyJ7COQibuTvrG0/WjznRJeiLrvAW+Lb NYmq80+CTNAJtjeoZvmAYNWXXWKr+pMG2U9a7ddronkbYRAtR9bkzFY1F4ATUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682371949; 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=GtW59GqAUjbqZgVC3PPx3YUt+tsqPi/olaPOlyMqgto=; b=FeKhrG7SM7o5sk969/FJvaBB9WKv0jBcyPxqFqPCd90s8fFdbGRjX2nFxQasipGFoudub3 xGq/fn41Ym//lH0W/U0ryM1X0tcaddYVNXy5zh/lBRJdiLBtrT9nulOIsdY2s03Yq3lVSJ UrsvAwoDOiKGjfU+Q5TDTCLpkfyQ5km0ovKEcof5tJTeeo/Ck8Z2WrS03dzV4RxSeMGuHh iiQxQ1gprdqnCUah1IId82x933QxZgEzzNtOJlqyAXt5dDRJs5RtFMA69sWoHoZnftcFUl P1fUQ1uZeabi0nsyBu9/B9YL4QPABvnRhWv4yTHxmhvlAVzDUAgpx4yl90suDw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1682371949; a=rsa-sha256; cv=none; b=bAfFRwfngjKYxTFwfJsYNHRC/yaV9/06uu7b6tkS7IvplqW+m9Nbo8ZpNzKOYWaYW9PJwy TCbUNiSb4y+t0qqLuCOx21jTS/H3tKMzmC/wjoKj68/gR2DVtjCx6V0gL0fGofHq37tE4L oQymfzN8+3fS1BlUZjdiwM+6Y8uIYOXsnMCHQBzJ7L8Ocd5yhYKTssDT9gb+X30kcZWyx0 KyZdQwIOsYJf1tZR7LALko8iS1QLmnHdo8HT0qxxe4J64oZK42L6hFDBDuCm7zhP0+r5GA CgC6gnec8X+OW/BvJXQq9U6odIztDua6Io48qIvkmATS9L3sgGSaHziGURyNHw== 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 4Q4yyj5H7hzgt5; Mon, 24 Apr 2023 21:32:29 +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 33OLWTo7060853; Mon, 24 Apr 2023 21:32:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33OLWTCn060852; Mon, 24 Apr 2023 21:32:29 GMT (envelope-from git) Date: Mon, 24 Apr 2023 21:32:29 GMT Message-Id: <202304242132.33OLWTCn060852@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: a718431c30a5 - main - lookup(): ensure that openat("/", "..", O_RESOLVE_BENEATH) fails 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a718431c30a57226bc7c1a9181fc84bab00641a1 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a718431c30a57226bc7c1a9181fc84bab00641a1 commit a718431c30a57226bc7c1a9181fc84bab00641a1 Author: Konstantin Belousov AuthorDate: 2023-04-23 23:21:42 +0000 Commit: Konstantin Belousov CommitDate: 2023-04-24 21:32:10 +0000 lookup(): ensure that openat("/", "..", O_RESOLVE_BENEATH) fails PR: 269780 Reported by: Dan Gohman Reviewed by: emaste, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D39773 --- sys/kern/vfs_lookup.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index d9a9cabde177..66a8b267f346 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -1083,12 +1083,16 @@ dirloop: pr = pr->pr_parent) if (dp == pr->pr_root) break; - if (dp == ndp->ni_rootdir || - dp == ndp->ni_topdir || - dp == rootvnode || - pr != NULL || - ((dp->v_vflag & VV_ROOT) != 0 && - (cnp->cn_flags & NOCROSSMOUNT) != 0)) { + bool isroot = dp == ndp->ni_rootdir || + dp == ndp->ni_topdir || dp == rootvnode || + pr != NULL; + if (isroot && (ndp->ni_lcf & + NI_LCF_STRICTRELATIVE) != 0) { + error = ENOTCAPABLE; + goto capdotdot; + } + if (isroot || ((dp->v_vflag & VV_ROOT) != 0 && + (cnp->cn_flags & NOCROSSMOUNT) != 0)) { ndp->ni_dvp = dp; ndp->ni_vp = dp; VREF(dp); @@ -1109,6 +1113,7 @@ dirloop: LK_RETRY, ISDOTDOT)); error = nameicap_check_dotdot(ndp, dp); if (error != 0) { +capdotdot: #ifdef KTRACE if (KTRPOINT(curthread, KTR_CAPFAIL)) ktrcapfail(CAPFAIL_LOOKUP, NULL, NULL);