Skip to content

Commit 1732956

Browse files
ebiggersgregkh
authored andcommitted
tty: fix compat TIOCGSERIAL leaking uninitialized memory
Commit 7765435 ("take compat TIOC[SG]SERIAL treatment into tty_compat_ioctl()") changed the compat version of TIOCGSERIAL to start copying a whole 'serial_struct32' to userspace rather than individual fields, but failed to initialize all padding and fields -- namely the hole after the 'iomem_reg_shift' field, and the 'reserved' field. Fix this by initializing the struct to zero. [v2: use sizeof, and convert the adjacent line for consistency.] Reported-by: [email protected] Fixes: 7765435 ("take compat TIOC[SG]SERIAL treatment into tty_compat_ioctl()") Cc: <[email protected]> # v4.20+ Signed-off-by: Eric Biggers <[email protected]> Acked-by: Jiri Slaby <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ed06982 commit 1732956

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/tty/tty_io.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2730,7 +2730,9 @@ static int compat_tty_tiocgserial(struct tty_struct *tty,
27302730
struct serial_struct32 v32;
27312731
struct serial_struct v;
27322732
int err;
2733-
memset(&v, 0, sizeof(struct serial_struct));
2733+
2734+
memset(&v, 0, sizeof(v));
2735+
memset(&v32, 0, sizeof(v32));
27342736

27352737
if (!tty->ops->set_serial)
27362738
return -ENOTTY;

0 commit comments

Comments
 (0)