[PATCH 3/6] Use fd_info structure to arbitrate overwrapped IOCTL command assignments between PTS and SND

Dmitry V. Levin ldv at altlinux.org
Thu Mar 10 22:43:57 UTC 2022


On Thu, Mar 10, 2022 at 09:01:03PM +0900, Masatake YAMATO wrote:
> IOCTL command assignments are overwrapped.
> We could observe the overwrapping when running vi under strace:
> 
>   ioctl(0, SNDCTL_TMR_START or TCSETS, {B38400 ...
> 
> If a fd opens /dev/pts/*, strace with this patch can decode
> the same ioctl invocation like:
> 
>   ioctl(0, TCSETS, {B38400 ...
[...]
> +extern int
> +term_ioctl_decode_command_number(int code,
> +				 struct tcb *tcp, struct fd_info *fd_info)
> +{
> +	/* See Documentation/admin-guide/devices.txt of
> +	 * Linux kernel source tree about the number 136 ~ 143.
> +	 */
> +	if (fd_info
> +	    && fd_info->type == fd_info_dev_chr
> +	    && 136 <= fd_info->major && fd_info->major <= 143) {

There are other terminal types besides /dev/pts/.
According to the same documentation, other major numbers are:
   3 char       Pseudo-TTY slaves
   4 char       TTY devices
   5 char       Alternate TTY devices


-- 
ldv


More information about the Strace-devel mailing list