* [PATCH] sctp: annotate struct sctp_assoc_ids with __counted_by()
@ 2024-05-01 17:01 Erick Archer
2024-05-01 20:04 ` Justin Stitt
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Erick Archer @ 2024-05-01 17:01 UTC (permalink / raw)
To: Marcelo Ricardo Leitner, Xin Long, Kees Cook, Gustavo A. R. Silva,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt
Cc: Erick Archer, linux-sctp, linux-kernel, linux-hardening, llvm
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 via
CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE
(for strcpy/memcpy-family functions).
Suggested-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Erick Archer <erick.archer@outlook.com>
---
include/uapi/linux/sctp.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/uapi/linux/sctp.h b/include/uapi/linux/sctp.h
index b7d91d4cf0db..836173e73401 100644
--- a/include/uapi/linux/sctp.h
+++ b/include/uapi/linux/sctp.h
@@ -1007,7 +1007,7 @@ enum sctp_sstat_state {
*/
struct sctp_assoc_ids {
__u32 gaids_number_of_ids;
- sctp_assoc_t gaids_assoc_id[];
+ sctp_assoc_t gaids_assoc_id[] __counted_by(gaids_number_of_ids);
};
/*
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] sctp: annotate struct sctp_assoc_ids with __counted_by()
2024-05-01 17:01 [PATCH] sctp: annotate struct sctp_assoc_ids with __counted_by() Erick Archer
@ 2024-05-01 20:04 ` Justin Stitt
2024-05-01 20:06 ` Kees Cook
2024-06-01 14:02 ` Erick Archer
2 siblings, 0 replies; 4+ messages in thread
From: Justin Stitt @ 2024-05-01 20:04 UTC (permalink / raw)
To: Erick Archer
Cc: Marcelo Ricardo Leitner, Xin Long, Kees Cook, Gustavo A. R. Silva,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, linux-sctp,
linux-kernel, linux-hardening, llvm
Hi,
On Wed, May 01, 2024 at 07:01:22PM +0200, Erick Archer wrote:
> 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 via
> CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE
> (for strcpy/memcpy-family functions).
>
> Suggested-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: Erick Archer <erick.archer@outlook.com>
> ---
> include/uapi/linux/sctp.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/uapi/linux/sctp.h b/include/uapi/linux/sctp.h
> index b7d91d4cf0db..836173e73401 100644
> --- a/include/uapi/linux/sctp.h
> +++ b/include/uapi/linux/sctp.h
> @@ -1007,7 +1007,7 @@ enum sctp_sstat_state {
> */
> struct sctp_assoc_ids {
> __u32 gaids_number_of_ids;
> - sctp_assoc_t gaids_assoc_id[];
> + sctp_assoc_t gaids_assoc_id[] __counted_by(gaids_number_of_ids);
Crucially, gaids_number_of_ids is assigned before any accesses to
gaids_assoc_id[] are made.
| ids->gaids_number_of_ids = num;
| num = 0;
| list_for_each_entry(asoc, &(sp->ep->asocs), asocs) {
| ids->gaids_assoc_id[num++] = asoc->assoc_id;
| }
So this looks good to me.
Reviewed-by: Justin Stitt <justinstitt@google.com>
> };
>
> /*
> --
> 2.25.1
>
Thanks
Justin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] sctp: annotate struct sctp_assoc_ids with __counted_by()
2024-05-01 17:01 [PATCH] sctp: annotate struct sctp_assoc_ids with __counted_by() Erick Archer
2024-05-01 20:04 ` Justin Stitt
@ 2024-05-01 20:06 ` Kees Cook
2024-06-01 14:02 ` Erick Archer
2 siblings, 0 replies; 4+ messages in thread
From: Kees Cook @ 2024-05-01 20:06 UTC (permalink / raw)
To: Erick Archer
Cc: Marcelo Ricardo Leitner, Xin Long, Gustavo A. R. Silva,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
linux-sctp, linux-kernel, linux-hardening, llvm
On Wed, May 01, 2024 at 07:01:22PM +0200, Erick Archer wrote:
> 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 via
> CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE
> (for strcpy/memcpy-family functions).
>
> Suggested-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: Erick Archer <erick.archer@outlook.com>
Thanks!
Reviewed-by: Kees Cook <keescook@chromium.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] sctp: annotate struct sctp_assoc_ids with __counted_by()
2024-05-01 17:01 [PATCH] sctp: annotate struct sctp_assoc_ids with __counted_by() Erick Archer
2024-05-01 20:04 ` Justin Stitt
2024-05-01 20:06 ` Kees Cook
@ 2024-06-01 14:02 ` Erick Archer
2 siblings, 0 replies; 4+ messages in thread
From: Erick Archer @ 2024-06-01 14:02 UTC (permalink / raw)
To: Marcelo Ricardo Leitner, Xin Long, Kees Cook,
Gustavo A. R. Silva, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt
Cc: Erick Archer, linux-sctp, linux-kernel, linux-hardening, llvm
Hi,
On Wed, May 01, 2024 at 07:01:22PM +0200, Erick Archer wrote:
> 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 via
> CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE
> (for strcpy/memcpy-family functions).
>
> Suggested-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: Erick Archer <erick.archer@outlook.com>
> ---
> include/uapi/linux/sctp.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/uapi/linux/sctp.h b/include/uapi/linux/sctp.h
> index b7d91d4cf0db..836173e73401 100644
> --- a/include/uapi/linux/sctp.h
> +++ b/include/uapi/linux/sctp.h
> @@ -1007,7 +1007,7 @@ enum sctp_sstat_state {
> */
> struct sctp_assoc_ids {
> __u32 gaids_number_of_ids;
> - sctp_assoc_t gaids_assoc_id[];
> + sctp_assoc_t gaids_assoc_id[] __counted_by(gaids_number_of_ids);
> };
>
> /*
Friendly ping: who can take this, please?
Regards,
Erick
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-06-01 14:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-01 17:01 [PATCH] sctp: annotate struct sctp_assoc_ids with __counted_by() Erick Archer
2024-05-01 20:04 ` Justin Stitt
2024-05-01 20:06 ` Kees Cook
2024-06-01 14:02 ` Erick Archer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox