qiling
qiling copied to clipboard
Hook ioctl in QlFsMappedObject
Is your feature request related to a problem? Please describe.
Hi,
I am trying to implement a custom QlFsMappedObject with ioctl support.
Looking at the class, it seems that I need to override the ioctl method.
https://github.com/qilingframework/qiling/blob/f3e66ec290b8c7a0ee60bc2f2715ddc6e9389216/qiling/os/mapper.py#L44-L45
However, my handler is never called, and the "strace" output shows a -EPERM result when the ioctl syscall is made.
From what I see, the ioctl calls ends up in ql_syscall_ioctl, which only handles a few ioctl commands, and returns -1 (aka -EPERM) if the ioctl is not in the whitelist.
Contrary to other methods like ql_syscall_read, it does not seem to call the handler method.
Describe the solution you'd like
Did I miss something, or is the ioctl not currently implemented ?
@Tim--- Did you ever find a fix for this?
Well, it's been a while, so I don't remember what I did. But the code has barely changed since then. Apparently, the hook is only called for specific network interface ioctls here:
https://github.com/qilingframework/qiling/blob/f3e66ec290b8c7a0ee60bc2f2715ddc6e9389216/qiling/os/posix/syscall/ioctl.py#L94
I guess you have to modify the code of ql_syscall_ioctl if you want it to call your hook.
Hi there,
Qiling is flexible enough to let you add your own customized handling. Here you could hook ioctl on exit to let your custom handler review the given parameters and take action for a certain set of values.
@Tim--- , @elicn Thanks for the tips. I'll give them a go