From: Kees Cook <keescook@chromium.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Kees Cook" <keescook@chromium.org>,
"Jiri Slaby" <jirislaby@kernel.org>,
"Daniel Vetter" <daniel.vetter@ffwll.ch>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Helge Deller" <deller@gmx.de>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
"Yangxi Xiang" <xyangxi5@gmail.com>,
"Xuezhi Zhang" <zhangxuezhi1@coolpad.com>,
linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: [PATCH] vt: Replace 0-length array with flexible array
Date: Thu, 5 Jan 2023 14:05:54 -0800 [thread overview]
Message-ID: <20230105220549.never.529-kees@kernel.org> (raw)
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
next reply other threads:[~2023-01-05 22:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-05 22:05 Kees Cook [this message]
2023-01-09 12:03 ` [PATCH] vt: Replace 0-length array with flexible array Jiri Slaby
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230105220549.never.529-kees@kernel.org \
--to=keescook@chromium.org \
--cc=bigeasy@linutronix.de \
--cc=daniel.vetter@ffwll.ch \
--cc=deller@gmx.de \
--cc=gregkh@linuxfoundation.org \
--cc=gustavoars@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jirislaby@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xyangxi5@gmail.com \
--cc=zhangxuezhi1@coolpad.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox