From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Mauro Matteo Cascella <mcascell@redhat.com>, qemu-devel@nongnu.org
Cc: Fam Zheng <fam@euphon.net>,
Darren Kenny <darren.kenny@oracle.com>,
Li Qiang <liq3ea@gmail.com>,
qiuhao.li@outlook.com, Alexander Bulekov <alxndr@bu.edu>,
pbonzini@redhat.com
Subject: Re: [PATCH] hw/scsi/scsi-disk: MODE_PAGE_ALLS not allowed in MODE SELECT commands
Date: Fri, 5 Nov 2021 12:42:26 +0100 [thread overview]
Message-ID: <8e8d660f-6710-e389-8b2b-16afca44f274@redhat.com> (raw)
In-Reply-To: <20211105113729.530200-1-mcascell@redhat.com>
On 11/5/21 12:37, Mauro Matteo Cascella wrote:
> MODE_PAGE_ALLS causes an off-by-one error in mode_sense_page() when accessing
> the stack-allocated mode_sense_valid buffer. MODE_PAGE_ALLS is only valid for
> MODE SENSE commands. Do not process it in MODE SELECT commands.
>
Cc: qemu-stable@nongnu.org
> Fixes: CVE-2021-3930
> RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=2020588
> Signed-off-by: Mauro Matteo Cascella <mcascell@redhat.com>
> Reported-by: Qiuhao Li <qiuhao.li@outlook.com>
See also:
https://lore.kernel.org/qemu-devel/20210204225041.1822673-1-philmd@redhat.com/
> ---
> hw/scsi/scsi-disk.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
> index e8a547dbb7..5852e8dcfd 100644
> --- a/hw/scsi/scsi-disk.c
> +++ b/hw/scsi/scsi-disk.c
> @@ -1087,6 +1087,7 @@ static int mode_sense_page(SCSIDiskState *s, int page, uint8_t **p_outbuf,
> uint8_t *p = *p_outbuf + 2;
> int length;
>
> + assert(page != MODE_PAGE_ALLS);
> if ((mode_sense_valid[page] & (1 << s->qdev.type)) == 0) {
> return -1;
> }
> @@ -1428,6 +1429,11 @@ static int scsi_disk_check_mode_select(SCSIDiskState *s, int page,
> return -1;
> }
>
> + /* MODE_PAGE_ALLS is only valid for MODE SENSE commands */
> + if (page == MODE_PAGE_ALLS) {
> + return -1;
> + }
> +
> p = mode_current;
> memset(mode_current, 0, inlen + 2);
> len = mode_sense_page(s, page, &p, 0);
>
prev parent reply other threads:[~2021-11-05 11:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-05 11:37 [PATCH] hw/scsi/scsi-disk: MODE_PAGE_ALLS not allowed in MODE SELECT commands Mauro Matteo Cascella
2021-11-05 11:42 ` Philippe Mathieu-Daudé [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=8e8d660f-6710-e389-8b2b-16afca44f274@redhat.com \
--to=philmd@redhat.com \
--cc=alxndr@bu.edu \
--cc=darren.kenny@oracle.com \
--cc=fam@euphon.net \
--cc=liq3ea@gmail.com \
--cc=mcascell@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qiuhao.li@outlook.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;
as well as URLs for NNTP newsgroup(s).