Bug 444925 - fexecve syscall wrapper not properly implemented
Summary: fexecve syscall wrapper not properly implemented
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: unspecified
Platform: FreeBSD Ports FreeBSD
: NOR normal
Target Milestone: ---
Assignee: Paul Floyd
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-04 08:38 UTC by Paul Floyd
Modified: 2021-11-14 21:11 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
fexecve wrapper that checks something (20.22 KB, patch)
2021-11-14 17:19 UTC, Paul Floyd
Details
fexecve wrapper that checks something (20.15 KB, patch)
2021-11-14 18:40 UTC, Paul Floyd
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Floyd 2021-11-04 08:38:33 UTC
Currently the wrapper is just doing some minimal checking on the args.

Solaris also has fexecve but it seems to just overload execve. That should do as a starting point, but on FreeBSD there isn't the extra complexity of determining if ARG1 is an fd or a path.

Short summary of what I think needs doing
1. Perform sanity checking on the fd
2. Get the flags and filename from the fd (will need a new function to get the flags)
3. Perform sanity checking on the flags
4. If all is OK, call handle_pre_sys_execve with check_pathptr False
5. Modify handle_pre_sys_execve  slightly, changing Bool is_execveat to be something like enum ExecveType { EXECVE, EXECVEAT, FEXECVE }; and in the body of the function set 'str' accordingly.
Comment 1 Paul Floyd 2021-11-14 17:19:42 UTC
Created attachment 143550 [details]
fexecve wrapper that checks something

Check the fd then calls handle_pre_sys_execve
Lots of tests cos fexecve doesn't return when it succeeds :-(
Small change to handle_pre_sys_execve so thatit can print fexecve as well as exeve and execveat.
Comment 2 Paul Floyd 2021-11-14 18:40:27 UTC
Created attachment 143551 [details]
fexecve wrapper that checks something

This time with diff from the branch to master
Comment 3 Mark Wielaard 2021-11-14 18:50:37 UTC
The attached patch is reversed, but looking with patch -p1 -R it seems OK.
Some nitpicks:
- priv_syswrap-generic.h handle_sys_pwritev, please rename the argument is_execveType -> execveType.
- Should resolve_filemode be in coregrind/m_syswrap/syswrap-freebsd.c since that is the only user?
Comment 4 Paul Floyd 2021-11-14 21:11:38 UTC
Fixed with

commit 83dda2b71a75bd0058ed50a32ec871b083a96f91 (HEAD -> master, origin/master, origin/HEAD)
Author: Paul Floyd <pjfloyd@wanadoo.fr>
Date:   Sun Nov 14 22:06:14 2021 +0100

    Bug 444925 fexecve syscall wrapper not properly implemented
    
    Implement fexecve and a few testcases on FreeBSD.