Page MenuHomeFreeBSD

namei: preserve errors from fget_cap_locked
ClosedPublic

Authored by kevans on Feb 3 2020, 3:15 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 14, 7:48 PM
Unknown Object (File)
Feb 22 2024, 10:59 AM
Unknown Object (File)
Feb 7 2024, 12:53 PM
Unknown Object (File)
Jan 14 2024, 5:39 AM
Unknown Object (File)
Jan 2 2024, 11:10 AM
Unknown Object (File)
Dec 22 2023, 11:42 PM
Unknown Object (File)
Oct 3 2023, 10:06 AM
Unknown Object (File)
Jul 25 2023, 6:54 PM
Subscribers

Details

Summary

Most notably, we want to make sure we don't clobber any capabilities-related errors. This is a regression from r357412 (O_SEARCH) that was picked up from the capsicum tests.

PR: 243839

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 29128

Event Timeline

sys/kern/vfs_lookup.c
463–466

To me a nested

if (error == 0) {
        if (dfp->f_vnode == NULL)
                error = ENOTDIR;
        else
                error = EBADF;
}

is easier to follow

kib added inline comments.
sys/kern/vfs_lookup.c
463–466

I would do it diferently:

   if (error != 0) {
      /* Preserve error */
   } else if (...f_ops == &badfileops} {
     error = EBADF;
   } else if (...f_vnode == NULL) {
     error = EINVAL;
  } else {
      dp = dfp->f_vnode;
...

Note tht I restored errors from fgetvp_rights.

This revision is now accepted and ready to land.Feb 3 2020, 6:20 PM
This revision was automatically updated to reflect the committed changes.

I would do it differently

Ah yes, this is better.

(The recent OpenSMTPD vulnerability provides a good example of the need to consider this carefully and get it right from both correctness & readability.)