[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <65DBE926-C9B0-4394-ACD8-D3C71AABD064@oracle.com>
Date: Wed, 5 Mar 2025 17:31:13 +0000
From: Qing Zhao <qing.zhao@...cle.com>
To: Kees Cook <kees@...nel.org>
CC: Thorsten Blum <thorsten.blum@...ux.dev>, Bill Wendling <morbo@...gle.com>,
Peter Rosin <peda@...ntia.se>,
"Gustavo A. R. Silva" <gustavoars@...nel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-hardening@...r.kernel.org" <linux-hardening@...r.kernel.org>
Subject: Re: [RESEND PATCH] mux: Convert mux_control_ops to a flex array
member in mux_chip
> On Mar 4, 2025, at 23:57, Kees Cook <kees@...nel.org> wrote:
>
> #include <stdlib.h>
> #include <stdio.h>
>
> struct foo {
> int count;
> int array[] __attribute__((__counted_by__(count)));
> };
>
> int main(int argc, char *argv[]) {
> int num_elems = 2 + argc;
>
> struct foo *p = malloc(sizeof(*p) + num_elems * sizeof(*p->array) + sizeof(int));
> p->count = num_elems;
>
> // this correctly trips sanitizer:
> int val = p->array[num_elems];
> printf("%d\n", val);
>
> // this does not?!
> int *valp = &p->array[num_elems];
> printf("%p %d\n", valp, *valp);
>
> return 0;
> }
Powered by blists - more mailing lists