From nobody Sat Apr 02 18:50:53 2022 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 D0E901A50F1B; Sat, 2 Apr 2022 18:50:53 +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 4KW5hs58rGz4cRp; Sat, 2 Apr 2022 18:50:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648925453; 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=5sbLvzOqBJLcx6pkGU85J/wxoc9xSjHuD9/0dYRp6Ds=; b=SGvXv9ObE08vCMsN3eV3dMO7EHodwtZn1Pl3ysk7hhnSsgGksVGWiE01iIBehljIf4qIBB KIdW6P00/Aj+rir3HOZjAh1sgr0qU+rrdrMEf55+R9Eaq8DYtVa+fbztLKJfzfe8G5BRJu 4Kt/x1z42NGIrHel+J2MRpiSqAEn0zZuKf4sbAQMtSFPkHzx++l9CJXbJhMzOKQ96FP5wB 0yZnnn730Y0WYZhOP5YCTQUg1QcITUmF/K6+yeq8qQTfrOx5oah5POPrsFCQqr5ksAKpBB 4b5E2nNZruP+6dxbJ4oI0exn6kN25+mPVqVg6pwJ8sg0TUw64oRo3lGTV33iSg== 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 81F145F7E; Sat, 2 Apr 2022 18:50:53 +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 232IorWu035706; Sat, 2 Apr 2022 18:50:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 232Ioruj035686; Sat, 2 Apr 2022 18:50:53 GMT (envelope-from git) Date: Sat, 2 Apr 2022 18:50:53 GMT Message-Id: <202204021850.232Ioruj035686@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: b7262756e2f4 - main - vfs: fixup WANTIOCTLCAPS on open 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: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b7262756e2f471f6481070e2473af7853506b150 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648925453; 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=5sbLvzOqBJLcx6pkGU85J/wxoc9xSjHuD9/0dYRp6Ds=; b=XN9CE+E5Jf36Nsbn43mIFkiN/Elz3ppkqXumQGF/gWWbZLM0Cw8mjokjp9LfG7bZ1G8RCR B/+izHxhcCj10WhBikQim3hGQYry1Mb1ZPlym7esg3IsVoSwRSa6ij8AKPhu8pt602JGva 3tti+QQZ8+vY+Wtv1+jCWFO1GdWbhUzAEO04h1xSmFGkUu7BCpZOeUtQX/0Vk1///jMZxP +9nsZyPs3atZNDDKu+xWdW6DCl2Y3HW0SE0JJk0qzzkZ+sT2v8HajmBxZG/s60JIrT6nC0 hhelStLqg2C/ZaZoXTYG6lzm+WRMRHFdUkM45mAJjMszcRkPJYCgRW1MwrZZLw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648925453; a=rsa-sha256; cv=none; b=ItGsGmyv4FcfZDYACn4MYcLDDJte/vehKMm3VkhYTanFCxSZrmShFWlQ5kbT4pH+1gTyPt 9V+3B5g/dJzh8Ja9p57L6hVxwZdlxpoaiYUg4H8ym54cjws5/zxoJEzgAskIMYUwLsK2NL EarX9udJcsrK70TBjKK/jDcNvh5iP23R1F+nHAz/kA5kZ7Gd0gJ02YLCAT4Pj20f768mo/ O8STUna52nCBrmzg7jA1odfn/TyzS26oxI2Mfr9mKklhtt+9p87Q2X/9hD8nUe1TSnMcVL 6SvMK7OFu8XJ28vcB9QhhDo/x9oBpQA/89jel7Ye68bahXz21jfALkknjLMC7Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=b7262756e2f471f6481070e2473af7853506b150 commit b7262756e2f471f6481070e2473af7853506b150 Author: Mateusz Guzik AuthorDate: 2022-04-02 18:35:58 +0000 Commit: Mateusz Guzik CommitDate: 2022-04-02 18:49:01 +0000 vfs: fixup WANTIOCTLCAPS on open In some cases vn_open_cred overwrites cn_flags, effectively nullifying initialisation done in NDINIT. This will have to be fixed. In the meantime make sure the flag is passed. Reported by: jenkins Noted by: Mathieu --- sys/kern/kern_descrip.c | 5 +++++ sys/kern/vfs_syscalls.c | 3 ++- sys/kern/vfs_vnops.c | 2 ++ sys/sys/vnode.h | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index dd510cfd23f9..d88263ddeedb 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1852,9 +1852,14 @@ filecaps_validate(const struct filecaps *fcaps, const char *func) KASSERT(fcaps->fc_fcntls == 0 || cap_rights_is_set(&fcaps->fc_rights, CAP_FCNTL), ("%s: fcntls without CAP_FCNTL", func)); + /* + * open calls without WANTIOCTLCAPS free caps but leave the counter + */ +#if 0 KASSERT(fcaps->fc_ioctls != NULL ? fcaps->fc_nioctls > 0 : (fcaps->fc_nioctls == -1 || fcaps->fc_nioctls == 0), ("%s: invalid ioctls", func)); +#endif KASSERT(fcaps->fc_nioctls == 0 || cap_rights_is_set(&fcaps->fc_rights, CAP_IOCTL), ("%s: ioctls without CAP_IOCTL", func)); diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index dec7fdca92f2..87bf0a9d866b 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1167,7 +1167,8 @@ kern_openat(struct thread *td, int fd, const char *path, enum uio_seg pathseg, NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | AUDITVNODE1 | WANTIOCTLCAPS, pathseg, path, fd, &rights); td->td_dupfd = -1; /* XXX check for fdopen */ - error = vn_open(&nd, &flags, cmode, fp); + error = vn_open_cred(&nd, &flags, cmode, VN_OPEN_WANTIOCTLCAPS, + td->td_ucred, fp); if (error != 0) { /* * If the vn_open replaced the method vector, something diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 4d75c53a701b..d5234b44e5eb 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -213,6 +213,8 @@ open2nameif(int fmode, u_int vn_open_flags) res |= AUDITVNODE1; if ((vn_open_flags & VN_OPEN_NOCAPCHECK) != 0) res |= NOCAPCHECK; + if ((vn_open_flags & VN_OPEN_WANTIOCTLCAPS) != 0) + res |= WANTIOCTLCAPS; return (res); } diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 7bd483d2e17c..0ff7501837c7 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -616,6 +616,7 @@ typedef void vop_getpages_iodone_t(void *, vm_page_t *, int, int); #define VN_OPEN_NOCAPCHECK 0x00000002 #define VN_OPEN_NAMECACHE 0x00000004 #define VN_OPEN_INVFS 0x00000008 +#define VN_OPEN_WANTIOCTLCAPS 0x00000010 /* copy_file_range kernel flags */ #define COPY_FILE_RANGE_KFLAGS 0xff000000