]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
comedi: Annotate struct comedi_lrange with __counted_by
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sat, 30 Sep 2023 09:14:47 +0000 (11:14 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Oct 2023 11:34:05 +0000 (13:34 +0200)
Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS
(for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/5c3b7459b820e22e2ac6ce892d4aadcc119cc919.1696065263.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/comedi/comedidev.h

index 0a1150900ef35cebb274f4515022b965083f9b8b..c08416a7364bc4ef12ebe3c704a7b1d794e86d16 100644 (file)
@@ -633,7 +633,7 @@ extern const struct comedi_lrange range_unknown;
  */
 struct comedi_lrange {
        int length;
-       struct comedi_krange range[];
+       struct comedi_krange range[] __counted_by(length);
 };
 
 /**