From: Halil Pasic <pasic@linux.ibm.com>
To: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
Thomas Huth <thuth@redhat.com>,
Janosch Frank <frankja@linux.ibm.com>,
David Hildenbrand <david@redhat.com>,
Cornelia Huck <cohuck@redhat.com>,
qemu-devel <qemu-devel@nongnu.org>,
qemu-s390x <qemu-s390x@nongnu.org>,
Marc Hartmayer <mhartmay@linux.ibm.com>,
Viktor Mihajlovski <mihajlov@linux.ibm.com>,
Richard Henderson <rth@twiddle.net>
Subject: Re: [PULL 3/4] s390/ipl: sync back loadparm
Date: Fri, 20 Mar 2020 15:02:00 +0100 [thread overview]
Message-ID: <20200320150200.1aeed403.pasic@linux.ibm.com> (raw)
In-Reply-To: <bcd562a0-272a-57e3-d8b7-fbc19ebc75bb@de.ibm.com>
On Fri, 20 Mar 2020 10:23:03 +0100
Christian Borntraeger <borntraeger@de.ibm.com> wrote:
>
>
> On 19.03.20 21:31, Peter Maydell wrote:
> > On Tue, 10 Mar 2020 at 15:09, Christian Borntraeger
> > <borntraeger@de.ibm.com> wrote:
> >>
> >> From: Halil Pasic <pasic@linux.ibm.com>
> >>
> >> We expose loadparm as a r/w machine property, but if loadparm is set by
> >> the guest via DIAG 308, we don't update the property. Having a
> >> disconnect between the guest view and the QEMU property is not nice in
> >> itself, but things get even worse for SCSI, where under certain
> >> circumstances (see 789b5a401b "s390: Ensure IPL from SCSI works as
> >> expected" for details) we call s390_gen_initial_iplb() on resets
> >> effectively overwriting the guest/user supplied loadparm with the stale
> >> value.
> >
> > Hi; Coverity points out (CID 1421966) that you have a buffer overrun here:
> >
> >> +static void update_machine_ipl_properties(IplParameterBlock *iplb)
> >> +{
> >> + Object *machine = qdev_get_machine();
> >> + Error *err = NULL;
> >> +
> >> + /* Sync loadparm */
> >> + if (iplb->flags & DIAG308_FLAGS_LP_VALID) {
> >> + uint8_t *ebcdic_loadparm = iplb->loadparm;
> >> + char ascii_loadparm[8];
> >
> > This array is 8 bytes...
> >
> >> + int i;
> >> +
> >> + for (i = 0; i < 8 && ebcdic_loadparm[i]; i++) {
> >> + ascii_loadparm[i] = ebcdic2ascii[(uint8_t) ebcdic_loadparm[i]];
> >> + }
> >> + ascii_loadparm[i] = 0;
> >
> > ...but you can write 9 bytes into it (8 from the guest-controlled
> > iplb_loadparm buffer plus one for the trailing NUL).
>
> Right, so ascii_loadparm needs to be 9 bytes as this needs the trailing 0.
> Halil, can you spin up a fix patch?
Sure!
Regards,
Halil
next prev parent reply other threads:[~2020-03-20 14:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-10 15:09 [PULL 0/4] s390x/ipl: Fixes for ipl and bios Christian Borntraeger
2020-03-10 15:09 ` [PULL 1/4] pc-bios: s390x: Save iplb location in lowcore Christian Borntraeger
2020-03-10 15:09 ` [PULL 2/4] s390x/bios: rebuild s390-ccw.img Christian Borntraeger
2020-03-10 15:09 ` [PULL 3/4] s390/ipl: sync back loadparm Christian Borntraeger
2020-03-19 20:31 ` Peter Maydell
2020-03-20 9:23 ` Christian Borntraeger
2020-03-20 14:02 ` Halil Pasic [this message]
2020-03-10 15:09 ` [PULL 4/4] s390x: ipl: Consolidate iplb validity check into one function Christian Borntraeger
2020-03-10 17:13 ` [PULL 0/4] s390x/ipl: Fixes for ipl and bios no-reply
2020-03-10 20:04 ` Peter Maydell
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=20200320150200.1aeed403.pasic@linux.ibm.com \
--to=pasic@linux.ibm.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=mhartmay@linux.ibm.com \
--cc=mihajlov@linux.ibm.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=rth@twiddle.net \
--cc=thuth@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.