HomeFreeBSD

Fix renameat(2) for CAPABILITIES kernels.

Description

Fix renameat(2) for CAPABILITIES kernels.

When renameat(2) is used with:

  • absolute path for to;
  • tofd not set to AT_FDCWD;
  • the target exists

kern_renameat() requires CAP_UNLINK capability on tofd, but
corresponding namei ni_filecap is not initialized at all because the
lookup is absolute. As result, the check was done against empty filecap
and syscall fails erronously.

Fix it by creating a return flags namei member and reporting if the
lookup was absolute, then do not touch to.ni_filecaps at all.

PR: 222258
Reviewed by: jilles, ngie
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
X-MFC-note: KBI breakage
Differential revision: https://reviews.freebsd.org/D19096

Details

Provenance
kibAuthored on
Reviewer
jilles
Differential Revision
D19096: Fix renameat(2) for CAPABILITIES kernels.
Parents
rS343890: do_execve(): lock vnode when needed.
Branches
Unknown
Tags
Unknown