[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPcyv4gQzTZHX+fO45V+U4onhOA-H-U6E+GeqySdxHvNcqYeUg@mail.gmail.com>
Date: Wed, 24 Mar 2021 11:54:59 -0700
From: Dan Williams <dan.j.williams@...el.com>
To: Robert Richter <rrichter@....com>
Cc: Alison Schofield <alison.schofield@...el.com>,
Vishal Verma <vishal.l.verma@...el.com>,
Ira Weiny <ira.weiny@...el.com>,
Ben Widawsky <ben.widawsky@...el.com>,
linux-cxl@...r.kernel.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] cxl/mem: Force array size of mem_commands[] to CXL_MEM_COMMAND_ID_MAX
On Wed, Mar 24, 2021 at 7:17 AM Robert Richter <rrichter@....com> wrote:
>
> Typically the mem_commands[] array is in sync with 'enum { CXL_CMDS }'.
> Current code works well.
>
> However, the array size of mem_commands[] may not strictly be the same
> as CXL_MEM_COMMAND_ID_MAX. E.g. if a new CXL_CMD() is added that is
> guarded by #ifdefs, the array could be shorter. This could lead then
> further to an out-of-bounds array access in cxl_validate_cmd_from_user().
Good catch.
>
> Fix this by forcing the array size to CXL_MEM_COMMAND_ID_MAX. This
> also adds range checks for array items in mem_commands[] at compile
> time.
>
> Signed-off-by: Robert Richter <rrichter@....com>
Thanks, applied.
Powered by blists - more mailing lists