From owner-svn-src-stable-12@freebsd.org Fri Feb 15 11:13:41 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1698014D68C2; Fri, 15 Feb 2019 11:13:41 +0000 (UTC) (envelope-from kib@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A8D0F8BBB3; Fri, 15 Feb 2019 11:13:40 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8C56D1DD05; Fri, 15 Feb 2019 11:13:40 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x1FBDeHl049417; Fri, 15 Feb 2019 11:13:40 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x1FBDdvt049414; Fri, 15 Feb 2019 11:13:39 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201902151113.x1FBDdvt049414@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 15 Feb 2019 11:13:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r344152 - in stable/12/sys: kern sys X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/12/sys: kern sys X-SVN-Commit-Revision: 344152 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: A8D0F8BBB3 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.97)[-0.969,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-0.999,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Feb 2019 11:13:41 -0000 Author: kib Date: Fri Feb 15 11:13:39 2019 New Revision: 344152 URL: https://svnweb.freebsd.org/changeset/base/344152 Log: MFC r343891: Fix renameat(2) for CAPABILITIES kernelsi. MFC Note: Layout of the struct nameidata is changed. I specifically decided to not move the new field to the end of the new structure since it would mostly make the corruption silent. __FreeBSD_version is bumped. Modified: stable/12/sys/kern/vfs_lookup.c stable/12/sys/kern/vfs_syscalls.c stable/12/sys/sys/namei.h stable/12/sys/sys/param.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/vfs_lookup.c ============================================================================== --- stable/12/sys/kern/vfs_lookup.c Fri Feb 15 10:40:41 2019 (r344151) +++ stable/12/sys/kern/vfs_lookup.c Fri Feb 15 11:13:39 2019 (r344152) @@ -388,6 +388,7 @@ namei(struct nameidata *ndp) dp = NULL; cnp->cn_nameptr = cnp->cn_pnbuf; if (cnp->cn_pnbuf[0] == '/') { + ndp->ni_resflags |= NIRES_ABS; error = namei_handle_root(ndp, &dp); } else { if (ndp->ni_startdir != NULL) { @@ -1252,6 +1253,7 @@ NDINIT_ALL(struct nameidata *ndp, u_long op, u_long fl ndp->ni_dirp = namep; ndp->ni_dirfd = dirfd; ndp->ni_startdir = startdir; + ndp->ni_resflags = 0; if (rightsp != NULL) ndp->ni_rightsneeded = *rightsp; else Modified: stable/12/sys/kern/vfs_syscalls.c ============================================================================== --- stable/12/sys/kern/vfs_syscalls.c Fri Feb 15 10:40:41 2019 (r344151) +++ stable/12/sys/kern/vfs_syscalls.c Fri Feb 15 11:13:39 2019 (r344152) @@ -3511,10 +3511,10 @@ again: goto out; } #ifdef CAPABILITIES - if (newfd != AT_FDCWD) { + if (newfd != AT_FDCWD && (tond.ni_resflags & NIRES_ABS) == 0) { /* * If the target already exists we require CAP_UNLINKAT - * from 'newfd'. + * from 'newfd', when newfd was used for the lookup. */ error = cap_check(&tond.ni_filecaps.fc_rights, &cap_unlinkat_rights); Modified: stable/12/sys/sys/namei.h ============================================================================== --- stable/12/sys/sys/namei.h Fri Feb 15 10:40:41 2019 (r344151) +++ stable/12/sys/sys/namei.h Fri Feb 15 11:13:39 2019 (r344152) @@ -88,6 +88,10 @@ struct nameidata { struct vnode *ni_vp; /* vnode of result */ struct vnode *ni_dvp; /* vnode of intermediate directory */ /* + * Results: flags returned from namei + */ + u_int ni_resflags; + /* * Shared between namei and lookup/commit routines. */ size_t ni_pathlen; /* remaining chars in path */ @@ -156,6 +160,11 @@ struct nameidata { #define TRAILINGSLASH 0x10000000 /* path ended in a slash */ #define NOCAPCHECK 0x20000000 /* do not perform capability checks */ #define PARAMASK 0x3ffffe00 /* mask of parameter descriptors */ + +/* + * Namei results flags + */ +#define NIRES_ABS 0x00000001 /* Path was absolute */ /* * Flags in ni_lcf, valid for the duration of the namei call. Modified: stable/12/sys/sys/param.h ============================================================================== --- stable/12/sys/sys/param.h Fri Feb 15 10:40:41 2019 (r344151) +++ stable/12/sys/sys/param.h Fri Feb 15 11:13:39 2019 (r344152) @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1200502 /* Master, propagated to newvers */ +#define __FreeBSD_version 1200503 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,