* [PATCH] vt: Replace 0-length array with flexible array
@ 2023-01-05 22:05 Kees Cook
2023-01-09 12:03 ` Jiri Slaby
0 siblings, 1 reply; 2+ messages in thread
From: Kees Cook @ 2023-01-05 22:05 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Kees Cook, Jiri Slaby, Daniel Vetter, Ilpo Järvinen,
Helge Deller, Gustavo A. R. Silva, Sebastian Andrzej Siewior,
Yangxi Xiang, Xuezhi Zhang, linux-kernel, linux-hardening
Zero-length arrays are deprecated[1]. Replace struct uni_screen's
"lines" 0-length array with a flexible array. Detected with GCC 13,
using -fstrict-flex-arrays=3:
../drivers/tty/vt/vt.c: In function 'vc_uniscr_copy_area':
../drivers/tty/vt/vt.c:488:48: warning: array subscript dst_row is outside array bounds of 'char32_t *[0]' {aka 'unsigned int *[]'} [-Warray-bounds=]
488 | char32_t *dst_line = dst->lines[dst_row];
| ~~~~~~~~~~^~~~~~~~~
../drivers/tty/vt/vt.c:335:19: note: while referencing 'lines'
335 | char32_t *lines[0];
| ^~~~~
[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jirislaby@kernel.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: Helge Deller <deller@gmx.de>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
drivers/tty/vt/vt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 981d2bfcf9a5..b1445f00f616 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -332,7 +332,7 @@ typedef uint32_t char32_t;
* scrolling only implies some pointer shuffling.
*/
struct uni_screen {
- char32_t *lines[0];
+ DECLARE_FLEX_ARRAY(char32_t *, lines);
};
static struct uni_screen *vc_uniscr_alloc(unsigned int cols, unsigned int rows)
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] vt: Replace 0-length array with flexible array
2023-01-05 22:05 [PATCH] vt: Replace 0-length array with flexible array Kees Cook
@ 2023-01-09 12:03 ` Jiri Slaby
0 siblings, 0 replies; 2+ messages in thread
From: Jiri Slaby @ 2023-01-09 12:03 UTC (permalink / raw)
To: Kees Cook, Greg Kroah-Hartman
Cc: Daniel Vetter, Ilpo Järvinen, Helge Deller,
Gustavo A. R. Silva, Sebastian Andrzej Siewior, Yangxi Xiang,
Xuezhi Zhang, linux-kernel, linux-hardening
On 05. 01. 23, 23:05, Kees Cook wrote:
> Zero-length arrays are deprecated[1]. Replace struct uni_screen's
> "lines" 0-length array with a flexible array. Detected with GCC 13,
> using -fstrict-flex-arrays=3:
>
> ../drivers/tty/vt/vt.c: In function 'vc_uniscr_copy_area':
> ../drivers/tty/vt/vt.c:488:48: warning: array subscript dst_row is outside array bounds of 'char32_t *[0]' {aka 'unsigned int *[]'} [-Warray-bounds=]
> 488 | char32_t *dst_line = dst->lines[dst_row];
> | ~~~~~~~~~~^~~~~~~~~
> ../drivers/tty/vt/vt.c:335:19: note: while referencing 'lines'
> 335 | char32_t *lines[0];
> | ^~~~~
>
> [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays
>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Jiri Slaby <jirislaby@kernel.org>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
> Cc: Helge Deller <deller@gmx.de>
> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
> drivers/tty/vt/vt.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
> index 981d2bfcf9a5..b1445f00f616 100644
> --- a/drivers/tty/vt/vt.c
> +++ b/drivers/tty/vt/vt.c
> @@ -332,7 +332,7 @@ typedef uint32_t char32_t;
> * scrolling only implies some pointer shuffling.
> */
> struct uni_screen {
> - char32_t *lines[0];
> + DECLARE_FLEX_ARRAY(char32_t *, lines);
> };
Perhaps I am missing something, but why don't we simply have:
char32_t **uni_screen_lines;
? And even if we don't, we should likely convert to array_size() on the
alloc site.
And a side note: what's actually the purpose of all that
NO_VC_UNI_SCREEN and closely connected get_vc_uniscr()?
thanks,
--
js
suse labs
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-09 12:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-05 22:05 [PATCH] vt: Replace 0-length array with flexible array Kees Cook
2023-01-09 12:03 ` Jiri Slaby
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox