Bug 488715 - support on README_MISSING_SYSCALL_OR_IOCTL for an automatic method?
Summary: support on README_MISSING_SYSCALL_OR_IOCTL for an automatic method?
Status: REPORTED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Other Other
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-19 08:21 UTC by Fred M
Modified: 2024-06-19 10:35 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fred M 2024-06-19 08:21:25 UTC
Hello,

I am wondering if there is a generic automatic method to add ioctl value to the wrapper.

For the documentation, there is PRE and POST to create :
https://valgrind.org/docs/manual/dist.readme-missing.html

But having a list of ioctl value in this format : 
#define my_ioctl "0x656460"

Is there a way to include them, to have them automatically added in the list of wrappers? 
How to avoid to create a PRE / POST method for all my new ioctls ?

Regards,
Frédéric
Comment 1 Paul Floyd 2024-06-19 10:35:03 UTC
I wish that this could be automated!

The first thing that you can do is use the lax ioctl simhint (--sim-hints=lax-ioctls). If you do that then Valgrind won't complain at all about unhandled ioctls.

The second thing that you can do is to make sure that your ioctl has size and direction (or no direction and a size of 0). You can do that using the _IOR _IOW and _IORW macros in asm-generic/ioctl.h.

That only covers the call to the ioctl. Then there is the state of the memory that the ioctl refers to. The ioctl encoding gives only a basic indication of what kinds of memory accesses to expect. Often there will be mutilple levels of indirection, numerous subcodes etc. Without all the details Memcheck won't know which memory ranges become initialized by ioctls that write to user memory. That could result in false positive "Conditional jump or move" errors.