Page MenuHomeFreeBSD

audit_canon_path_vp: don't panic if cdir == NULL
ClosedPublic

Authored by kevans on Apr 16 2020, 5:21 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 27, 5:03 AM
Unknown Object (File)
Nov 24 2024, 12:16 PM
Unknown Object (File)
Nov 22 2024, 2:24 PM
Unknown Object (File)
Nov 20 2024, 2:52 AM
Unknown Object (File)
Nov 19 2024, 8:49 AM
Unknown Object (File)
Nov 19 2024, 8:06 AM
Unknown Object (File)
Nov 19 2024, 3:13 AM
Unknown Object (File)
Nov 15 2024, 1:45 AM
Subscribers

Details

Summary

cdir may have simply failed to resolve (e.g. fget_cap failure in namei leading to NULL dp passed to AUDIT_ARG_UPATH*_VP); restore the pre-rS358191 behavior of setting cpath[0] = '\0' and bailing out instead of panicking.

This was found by inadvertently running the libc/c063 tests with auditing enabled.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.Apr 16 2020, 7:07 PM
mjg requested changes to this revision.Apr 16 2020, 7:16 PM

I would prefer extending if-else on *path but I'm not going to insist.

This revision now requires changes to proceed.Apr 16 2020, 7:16 PM
This revision is now accepted and ready to land.Apr 16 2020, 7:16 PM

I'm largely indifferent:

diff --git a/sys/security/audit/audit_bsm_klib.c b/sys/security/audit/audit_bsm_klib.c
index 64b7a344a60..71e326ee8ae 100644
--- a/sys/security/audit/audit_bsm_klib.c
+++ b/sys/security/audit/audit_bsm_klib.c
@@ -433,10 +433,14 @@ audit_canon_path_vp(struct thread *td, struct vnode *rdir, struct vnode *cdir,
            __func__,  __FILE__, __LINE__);

        copy = path;
-       if (*path == '/')
+       if (*path == '/') {
                vp = rdir;
-       else
+       } else if (cdir != NULL) {
                vp = cdir;
+       } else {
+               cpath[0] = '\0';
+               return;
+       }
        MPASS(vp != NULL);
        /*
         * NB: We require that the supplied array be at least MAXPATHLEN bytes

This, roughly?

diff --git a/sys/security/audit/audit_bsm_klib.c b/sys/security/audit/audit_bsm_klib.c
index 64b7a344a60..c8d602fb692 100644
--- a/sys/security/audit/audit_bsm_klib.c
+++ b/sys/security/audit/audit_bsm_klib.c
@@ -433,10 +433,15 @@ audit_canon_path_vp(struct thread *td, struct vnode *rdir, struct vnode *cdir,
            __func__,  __FILE__, __LINE__);
 
        copy = path;
-       if (*path == '/')
+       if (*path == '/') {
                vp = rdir;
-       else
+       } else {
+               if (cdir == NULL) {
+                       cpath[0] = '\0';
+                       return;
+               }
                vp = cdir;
+       }
        MPASS(vp != NULL);
        /*
         * NB: We require that the supplied array be at least MAXPATHLEN bytes
This revision was automatically updated to reflect the committed changes.