Skip to content

Commit 8b6046a

Browse files
GabrielLldv-alt
authored andcommitted
ioctl: allow to stop decoding number
For some ioctls, like from drm, the identification of the correct ioctl is done by custom code. Specifying IOCTL_NUMBER_STOP_LOOKUP on return of ioctl_decode_command_number() disables further calls to ioctl_lookup(). * defs.h (IOCTL_NUMBER_UNKNOWN, IOCTL_NUMBER_HANDLED, IOCTL_NUMBER_STOP_LOOKUP): Add macros representing ioctl number state decoding. * ioctl.c (SYS_FUNC(ioctl)): Skip ioctl_lookup() when ioctl_decode_command_number() returns a value with IOCTL_NUMBER_STOP_LOOKUP flag is set. Suggested-by: Patrik Jakobsson <[email protected]> Signed-off-by: Gabriel Laskar <[email protected]> Signed-off-by: Dmitry V. Levin <[email protected]>
1 parent 5421855 commit 8b6046a

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

defs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,10 @@ extern const struct xlat whence_codes[];
450450
#define STACKTRACE_CAPTURE_ON_ENTER 01000 /* Capture stacktrace on "entering" stage */
451451
#define TRACE_INDIRECT_SUBCALL 02000 /* Syscall is an indirect socket/ipc subcall. */
452452

453+
#define IOCTL_NUMBER_UNKNOWN 0
454+
#define IOCTL_NUMBER_HANDLED 1
455+
#define IOCTL_NUMBER_STOP_LOOKUP 010
456+
453457
#define indirect_ipccall(tcp) (tcp->s_ent->sys_flags & TRACE_INDIRECT_SUBCALL)
454458

455459
#if defined(ARM) || defined(AARCH64) \

ioctl.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -278,15 +278,17 @@ SYS_FUNC(ioctl)
278278
printfd(tcp, tcp->u_arg[0]);
279279
tprints(", ");
280280
ret = ioctl_decode_command_number(tcp);
281-
iop = ioctl_lookup(tcp->u_arg[1]);
282-
if (iop) {
283-
if (ret)
284-
tprints(" or ");
285-
tprints(iop->symbol);
286-
while ((iop = ioctl_next_match(iop)))
287-
tprintf(" or %s", iop->symbol);
288-
} else if (!ret) {
289-
ioctl_print_code(tcp->u_arg[1]);
281+
if (!(ret & IOCTL_NUMBER_STOP_LOOKUP)) {
282+
iop = ioctl_lookup(tcp->u_arg[1]);
283+
if (iop) {
284+
if (ret)
285+
tprints(" or ");
286+
tprints(iop->symbol);
287+
while ((iop = ioctl_next_match(iop)))
288+
tprintf(" or %s", iop->symbol);
289+
} else if (!ret) {
290+
ioctl_print_code(tcp->u_arg[1]);
291+
}
290292
}
291293
ret = ioctl_decode(tcp);
292294
} else {

0 commit comments

Comments
 (0)