From: Dave Jiang <dave.jiang@intel.com>
To: Keith Busch <keith.busch@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
linux-nvdimm@lists.01.org
Subject: Re: [ndctl PATCH] ndctl: Work around kernel memory corruption
Date: Mon, 13 Aug 2018 13:32:35 -0700 [thread overview]
Message-ID: <25d9b47d-0010-9f6a-2780-b0bae649bade@intel.com> (raw)
In-Reply-To: <20180813203153.562-1-keith.busch@intel.com>
On 08/13/2018 01:31 PM, Keith Busch wrote:
> Kernel commit efda1b5d87cb ("acpi, nfit, libnvdimm: fix / harden
> ars_status output length handling") contained an incorrect ars status
> output size calculation and may overrun the buffer provided by 4
> bytes. This patch adds 4 bytes to the buffer the user space allocates
> so that the kernel's overrun doesn't corrupt the application's heap.
>
> See kernel patch for more details:
>
> https://patchwork.kernel.org/patch/10563103/
>
> Signed-off-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
> ndctl/lib/ars.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/ndctl/lib/ars.c b/ndctl/lib/ars.c
> index c78e3bf..bd75131 100644
> --- a/ndctl/lib/ars.c
> +++ b/ndctl/lib/ars.c
> @@ -133,7 +133,16 @@ NDCTL_EXPORT struct ndctl_cmd *ndctl_bus_cmd_new_ars_status(struct ndctl_cmd *ar
> }
>
> size = sizeof(*cmd) + ars_cap_cmd->max_ars_out;
> - cmd = calloc(1, size);
> +
> + /*
> + * Older kernels have a bug that miscalculates the output length of the
> + * ars status and will overrun the provided buffer by 4 bytes,
> + * corrupting the memory. Add an additional 4 bytes in the allocation
> + * size to prevent that corruption. See kernel patch for more details:
> + *
> + * https://patchwork.kernel.org/patch/10563103/
> + */
> + cmd = calloc(1, size + 4);
> if (!cmd)
> return NULL;
>
>
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
prev parent reply other threads:[~2018-08-13 20:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-13 20:31 [ndctl PATCH] ndctl: Work around kernel memory corruption Keith Busch
2018-08-13 20:32 ` Dave Jiang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=25d9b47d-0010-9f6a-2780-b0bae649bade@intel.com \
--to=dave.jiang@intel.com \
--cc=keith.busch@intel.com \
--cc=linux-nvdimm@lists.01.org \
--cc=vishal.l.verma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox