Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Mar 2021 10:27:25 GMT
From:      Alex Richardson <arichardson@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 4edea0540344 - stable/13 - Fix fget_only_user() to return ENOTCAPABLE on a failed capsicum check
Message-ID:  <202103171027.12HARPH6095742@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by arichardson:

URL: https://cgit.FreeBSD.org/src/commit/?id=4edea05403443d8804155d8e3fd7ac460f491cd4

commit 4edea05403443d8804155d8e3fd7ac460f491cd4
Author:     Alex Richardson <arichardson@FreeBSD.org>
AuthorDate: 2021-02-15 22:09:33 +0000
Commit:     Alex Richardson <arichardson@FreeBSD.org>
CommitDate: 2021-03-17 09:44:17 +0000

    Fix fget_only_user() to return ENOTCAPABLE on a failed capsicum check
    
    After eaad8d1303da500ed691bd774742a4555a05e729 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 0482d7c9e944433abc98fc27a265ae762abce9a0)
---
 sys/kern/kern_descrip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 31c7d3bf2188..0813b6c8f3b8 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202103171027.12HARPH6095742>