Bug 498143 - False positive on EVIOCGRAB ioctl.
Summary: False positive on EVIOCGRAB ioctl.
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: 3.23.0
Platform: Debian unstable Linux
: NOR minor
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-01-02 07:05 UTC by Tali Auster
Modified: 2025-01-13 02:29 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tali Auster 2025-01-02 07:05:13 UTC
The EVIOCGRAB ioctl takes as argument just one parameter and tests whether it's truthy: It does *not* dereference the argument. Valgrind, however, doesn't agree, and logs a warning like the following when one calls ioctl(fd, EVIOCGRAB, 1):

```
==6155== Thread 3:
==6155== Syscall param ioctl(generic) points to unaddressable byte(s)
==6155== at 0x4A9723B: ioctl (ioctl.c:36)
...
==6155== Address 0x1 is not stack'd, malloc'd or (recently) free'd
```

STEPS TO REPRODUCE
1.  Run valgrind on a program that calls ioctl(some_fd, EVIOCGRAB, 1); (or any other truthy value)

OBSERVED RESULT

False positive warning.


EXPECTED RESULT

No warning; this is safe code.

SOFTWARE/OS VERSIONS

This is on Debian Sid, but I've reproduced it on Fedora as well. This affects (at least) Linuxes 6.12.4 and 6.12.6. Valgrind v3.2.0 and 3.24.0.

ADDITIONAL INFORMATION

Let me know if there's any other info I can provide. Thanks :)
Comment 1 Mark Wielaard 2025-01-08 15:55:28 UTC
This was an easy fix:

commit 59eb5a4af60d4beb2c6910a1fa6cdf8d1f3a56f2 (HEAD -> master)
Author: Mark Wielaard <mark@klomp.org>
Date:   Wed Jan 8 16:52:03 2025 +0100

    linux: support EVIOCGRAB ioctl
    
    EVIOCGRAB just takes an int argument.
    
    https://bugs.kde.org/show_bug.cgi?id=498143

We do support some, but not all, input device ioctls.
Please file another report if others are missing.
Comment 2 Mark Wielaard 2025-01-12 23:23:01 UTC
Also pushed to  VALGRIND_3_24_BRANCH

commit b732f86998e39ca8714330f487804428b54c481c
Author: Mark Wielaard <mark@klomp.org>
Date:   Wed Jan 8 16:52:03 2025 +0100

    linux: support EVIOCGRAB ioctl
    
    EVIOCGRAB just takes an int argument.
    
    https://bugs.kde.org/show_bug.cgi?id=498143
    
    (cherry picked from commit 59eb5a4af60d4beb2c6910a1fa6cdf8d1f3a56f2)
Comment 3 Tali Auster 2025-01-13 02:29:46 UTC
Thanks! Glad the fix was simple :)