stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Martin K. Petersen" <martin.petersen@oracle.com>
To: Bart Van Assche <bvanassche@acm.org>, Kees Cook <keescook@chromium.org>
Cc: "Martin K . Petersen" <martin.petersen@oracle.com>,
	Hannes Reinecke <hare@suse.de>,
	Himanshu Madhani <himanshu.madhani@oracle.com>,
	Adaptec OEM Raid Solutions <aacraid@microsemi.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	linux-scsi@vger.kernel.org, stable@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH] scsi: aacraid: Allocate cmd_priv with scsicmd
Date: Tue, 14 Feb 2023 11:57:33 -0500	[thread overview]
Message-ID: <167639371107.486235.10067171407828975609.b4-ty@oracle.com> (raw)
In-Reply-To: <20230128000409.never.976-kees@kernel.org>

On Fri, 27 Jan 2023 16:04:13 -0800, Kees Cook wrote:

> The aac_priv() helper assumes that the private cmd area immediately
> follows struct scsi_cmnd. Allocate this space as part of scsicmd,
> else there is a risk of heap overflow. Seen with GCC 13:
> 
> ../drivers/scsi/aacraid/aachba.c: In function 'aac_probe_container':
> ../drivers/scsi/aacraid/aachba.c:841:26: warning: array subscript 16 is outside array bounds of 'void[392]' [-Warray-bounds=]
>   841 |         status = cmd_priv->status;
>       |                          ^~
> In file included from ../include/linux/resource_ext.h:11,
>                  from ../include/linux/pci.h:40,
>                  from ../drivers/scsi/aacraid/aachba.c:22:
> In function 'kmalloc',
>     inlined from 'kzalloc' at ../include/linux/slab.h:720:9,
>     inlined from 'aac_probe_container' at ../drivers/scsi/aacraid/aachba.c:821:30:
> ../include/linux/slab.h:580:24: note: at offset 392 into object of size 392 allocated by 'kmalloc_trace'
>   580 |                 return kmalloc_trace(
>       |                        ^~~~~~~~~~~~~~
>   581 |                                 kmalloc_caches[kmalloc_type(flags)][index],
>       |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   582 |                                 flags, size);
>       |                                 ~~~~~~~~~~~~
> 
> [...]

Applied to 6.3/scsi-queue, thanks!

[1/1] scsi: aacraid: Allocate cmd_priv with scsicmd
      https://git.kernel.org/mkp/scsi/c/7ab734fc7598

-- 
Martin K. Petersen	Oracle Linux Engineering

      parent reply	other threads:[~2023-02-14 16:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-28  0:04 [PATCH] scsi: aacraid: Allocate cmd_priv with scsicmd Kees Cook
2023-01-28 18:40 ` Vegard Nossum
2023-01-31  9:02   ` John Garry
2023-01-30 18:14 ` Hannes Reinecke
2023-01-30 18:19 ` Bart Van Assche
2023-02-08 23:16 ` Martin K. Petersen
2023-02-14 16:57 ` Martin K. Petersen [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=167639371107.486235.10067171407828975609.b4-ty@oracle.com \
    --to=martin.petersen@oracle.com \
    --cc=aacraid@microsemi.com \
    --cc=bvanassche@acm.org \
    --cc=hare@suse.de \
    --cc=himanshu.madhani@oracle.com \
    --cc=jejb@linux.ibm.com \
    --cc=keescook@chromium.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).