Commit 4edea054 authored by Alex Richardson's avatar Alex Richardson
Browse files

Fix fget_only_user() to return ENOTCAPABLE on a failed capsicum check

After eaad8d13 four additional
capsicum-test tests started failing. It turns out this is because
fget_only_user() was returning EBADF on a failed capsicum check instead
of forwarding the return value of cap_check_inline() like
fget_unlocked_seq().

capsicum-test failures before this:
```
[  FAILED  ] 7 tests, listed below:
[  FAILED  ] Capability.OperationsForked
[  FAILED  ] Capability.NoBypassDAC
[  FAILED  ] Pdfork.OtherUserForked
[  FAILED  ] PipePdfork.WildcardWait
[  FAILED  ] OpenatTest.WithFlag
[  FAILED  ] ForkedOpenatTest_WithFlagInCapabilityMode._
[  FAILED  ] Select.LotsOFileDescriptorsForked
```
After:
```
[  FAILED  ] 3 tests, listed below:
[  FAILED  ] Capability.NoBypassDAC
[  FAILED  ] Pdfork.OtherUserForked
[  FAILED  ] PipePdfork.WildcardWait
```

Reviewed By:	mjg
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D28691

(cherry picked from commit 0482d7c9)
parent 8d42552e
......@@ -3214,7 +3214,7 @@ fget_only_user(struct filedesc *fdp, int fd, cap_rights_t *needrightsp,
haverights = cap_rights_fde_inline(fde);
error = cap_check_inline(haverights, needrightsp);
if (__predict_false(error != 0))
return (EBADF);
return (error);
*fpp = fp;
return (0);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment