lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 22 Sep 2023 18:25:05 +0000
From:   "Verma, Vishal L" <vishal.l.verma@...el.com>
To:     "keescook@...omium.org" <keescook@...omium.org>,
        "dave@...olabs.net" <dave@...olabs.net>
CC:     "Jiang, Dave" <dave.jiang@...el.com>,
        "Schofield, Alison" <alison.schofield@...el.com>,
        "linux-cxl@...r.kernel.org" <linux-cxl@...r.kernel.org>,
        "jonathan.cameron@...wei.com" <jonathan.cameron@...wei.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "Williams, Dan J" <dan.j.williams@...el.com>,
        "Weiny, Ira" <ira.weiny@...el.com>, "Rix, Tom" <trix@...hat.com>,
        "ndesaulniers@...gle.com" <ndesaulniers@...gle.com>,
        "linux-hardening@...r.kernel.org" <linux-hardening@...r.kernel.org>,
        "nathan@...nel.org" <nathan@...nel.org>,
        "llvm@...ts.linux.dev" <llvm@...ts.linux.dev>
Subject: Re: [PATCH] cxl/acpi: Annotate struct cxl_cxims_data with
 __counted_by

On Fri, 2023-09-22 at 10:53 -0700, Kees Cook 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 checking via CONFIG_UBSAN_BOUNDS
> (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
> functions).
> 
> As found with Coccinelle[1], add __counted_by for struct cxl_cxims_data.
> Additionally, since the element count member must be set before accessing
> the annotated flexible array member, move its initialization earlier.
> 
> [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
> 
> Cc: Davidlohr Bueso <dave@...olabs.net>
> Cc: Jonathan Cameron <jonathan.cameron@...wei.com>
> Cc: Dave Jiang <dave.jiang@...el.com>
> Cc: Alison Schofield <alison.schofield@...el.com>
> Cc: Vishal Verma <vishal.l.verma@...el.com>
> Cc: Ira Weiny <ira.weiny@...el.com>
> Cc: Dan Williams <dan.j.williams@...el.com>
> Cc: linux-cxl@...r.kernel.org
> Signed-off-by: Kees Cook <keescook@...omium.org>
> ---
>  drivers/cxl/acpi.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Vishal Verma <vishal.l.verma@...el.com>

> 
> diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c
> index d1c559879dcc..40d055560e52 100644
> --- a/drivers/cxl/acpi.c
> +++ b/drivers/cxl/acpi.c
> @@ -14,7 +14,7 @@
>  
>  struct cxl_cxims_data {
>         int nr_maps;
> -       u64 xormaps[];
> +       u64 xormaps[] __counted_by(nr_maps);
>  };
>  
>  /*
> @@ -112,9 +112,9 @@ static int cxl_parse_cxims(union acpi_subtable_headers *header, void *arg,
>                               GFP_KERNEL);
>         if (!cximsd)
>                 return -ENOMEM;
> +       cximsd->nr_maps = nr_maps;
>         memcpy(cximsd->xormaps, cxims->xormap_list,
>                nr_maps * sizeof(*cximsd->xormaps));
> -       cximsd->nr_maps = nr_maps;
>         cxlrd->platform_data = cximsd;
>  
>         return 0;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ