[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fb081dd1-dfdc-4826-9f83-49a0e5e3db84@kernel.org>
Date: Thu, 20 Nov 2025 08:23:22 +0100
From: Jiri Slaby <jirislaby@...nel.org>
To: david.laight.linux@...il.com, linux-kernel@...r.kernel.org,
linux-serial@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: Re: [PATCH 27/44] drivers/tty/vt: use umin() instead of min_t(u16,
...) for row/col limits
On 19. 11. 25, 23:41, david.laight.linux@...il.com wrote:
> From: David Laight <david.laight.linux@...il.com>
>
> The row/column bounds (for a screen window box) are changed from
> 'offset one' to 'offset zero' and bound to the screen size using:
> v->xs = min_t(u16, v->xs - 1, vc->vc_cols - 1);
> This has the side effect of converting zero to the limit.
>
> A check I'm adding to min_t() reports that (u16)(v->xs - 1) (etc)
> discards signiticant bits (because v->xs is promoted to 'int' before
> the addition).
> If v->xs is zero (it comes from userspace) it converts -1 to 0xffff.
> This is then bounded to 'vc->vc_cols - 1' which will be fine.
>
> Replace with:
> v->xs = umin(v->xs - 1, vc->vc_cols - 1);
> which again converts a -1 to unsigned - this time to 0xffffffff,
> with the same overall effect.
LGTM:
Reviewed-by: Jiri Slaby <jirislaby@...nel.org>
> Whether zero is meant to mean the 'maximum size' is unknown.
> I can't find any documentation for the ioctl and it pre-dates git.
Behavior of zero is unspecified AFAICT (the impl can do whatever is easy
:)).
thanks,
--
js
suse labs
Powered by blists - more mailing lists