[Bug 284563] Holes in struct rtld_utrace

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 04 Feb 2025 13:49:16 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=284563

            Bug ID: 284563
           Summary: Holes in struct rtld_utrace
           Product: Base System
           Version: 14.2-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: misc
          Assignee: bugs@FreeBSD.org
          Reporter: pjfloyd@wanadoo.fr

The definition of struct rtld_utrace is

struct utrace_rtld {
        char sig[RTLD_UTRACE_SIG_SZ];
        int event;
        /* 4 byte hole */
        void *handle;
        void *mapbase;                  /* Used for 'parent' and 'init/fini' */
        size_t mapsize;
        int refcnt;                     /* Used for 'mode' */
        /* 4 byte hole */
        char name[MAXPATHLEN];
};

And the interface for utrace is

335     AUE_NULL        STD|CAPENABLED {
                int utrace(
                    _In_reads_bytes_(len) const void *addr,
                    size_t len
                );
        }

I don't know what other uses of utrace exise, but rtld ld_utrace_log does not
memset utrace_rtld  to 0 before filling the fields, leaving the holes
uninitialized.

This poses a problem for Valgrind memcheck testing the syscall parameters. At
present it just uses the pointer and length to indicate memory that will be
read in the syscall (abd should be initialized). I can fix this in Valgrind by
using struct utrace_rtld.

I think that a better fix would be on the FreeBSD side by putting the 'event'
and 'refcnt' fields together. Would that be possible without breaking backwards
compatibility?

-- 
You are receiving this mail because:
You are the assignee for the bug.