Add NIRES_STRICTREL.
Stop abusing internal namei flag NI_LCF_STRICTRELATIVE as indicator of cap-restricted lookup. Add designated returned flag NIRES_STRICTREL to inform kern_openat() that lookup was restricted. Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D25886
This commit is contained in:
parent
f9e46c9bf1
commit
c7de3d6f0b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=366017
@ -322,6 +322,7 @@ namei_setup(struct nameidata *ndp, struct vnode **dpp, struct pwd **pwdp)
|
||||
*/
|
||||
if (IN_CAPABILITY_MODE(td) && (cnp->cn_flags & NOCAPCHECK) == 0) {
|
||||
ndp->ni_lcf |= NI_LCF_STRICTRELATIVE;
|
||||
ndp->ni_resflags |= NIRES_STRICTREL;
|
||||
if (ndp->ni_dirfd == AT_FDCWD) {
|
||||
#ifdef KTRACE
|
||||
if (KTRPOINT(td, KTR_CAPFAIL))
|
||||
@ -400,6 +401,7 @@ namei_setup(struct nameidata *ndp, struct vnode **dpp, struct pwd **pwdp)
|
||||
ndp->ni_filecaps.fc_fcntls != CAP_FCNTL_ALL ||
|
||||
ndp->ni_filecaps.fc_nioctls != -1) {
|
||||
ndp->ni_lcf |= NI_LCF_STRICTRELATIVE;
|
||||
ndp->ni_resflags |= NIRES_STRICTREL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -1136,7 +1136,7 @@ kern_openat(struct thread *td, int fd, const char *path, enum uio_seg pathseg,
|
||||
* understand exactly what would happen, and we don't think
|
||||
* that it ever should.
|
||||
*/
|
||||
if ((nd.ni_lcf & NI_LCF_STRICTRELATIVE) == 0 &&
|
||||
if ((nd.ni_resflags & NIRES_STRICTREL) == 0 &&
|
||||
(error == ENODEV || error == ENXIO) &&
|
||||
td->td_dupfd >= 0) {
|
||||
error = dupfdopen(td, fdp, td->td_dupfd, flags, error,
|
||||
@ -1180,7 +1180,7 @@ kern_openat(struct thread *td, int fd, const char *path, enum uio_seg pathseg,
|
||||
struct filecaps *fcaps;
|
||||
|
||||
#ifdef CAPABILITIES
|
||||
if ((nd.ni_lcf & NI_LCF_STRICTRELATIVE) != 0)
|
||||
if ((nd.ni_resflags & NIRES_STRICTREL) != 0)
|
||||
fcaps = &nd.ni_filecaps;
|
||||
else
|
||||
#endif
|
||||
|
@ -183,6 +183,7 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status,
|
||||
* Namei results flags
|
||||
*/
|
||||
#define NIRES_ABS 0x00000001 /* Path was absolute */
|
||||
#define NIRES_STRICTREL 0x00000002 /* Restricted lookup result */
|
||||
|
||||
/*
|
||||
* Flags in ni_lcf, valid for the duration of the namei call.
|
||||
|
Loading…
Reference in New Issue
Block a user