From: "Cédric Le Goater" <clg@kaod.org>
To: Laurent Vivier <lvivier@redhat.com>, P J P <ppandit@redhat.com>,
Qemu Developers <qemu-devel@nongnu.org>
Cc: Prasad J Pandit <pjp@fedoraproject.org>,
Alexander Graf <agraf@suse.de>, Moguofang <moguofang@huawei.com>,
David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [Qemu-devel] [PATCH v2] ppc/pnv: check size before data buffer access
Date: Thu, 8 Nov 2018 17:51:09 +0100 [thread overview]
Message-ID: <21ed9d28-9153-266c-5190-8c17aadff78e@kaod.org> (raw)
In-Reply-To: <12cdcb7d-9566-4eb6-52b3-94dc97ea408c@redhat.com>
Hello Laurent,
On 11/8/18 10:10 AM, Laurent Vivier wrote:
> On 26/10/2018 14:33, P J P wrote:
>> From: Prasad J Pandit <pjp@fedoraproject.org>
>>
>> While performing PowerNV memory r/w operations, the access length
>> 'sz' could exceed the data[4] buffer size. Add check to avoid OOB
>> access.
>>
>> Reported-by: Moguofang <moguofang@huawei.com>
>> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
>> ---
>> hw/ppc/pnv_lpc.c | 8 +++++++-
>> 1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> Update v2: add error log message
>> -> https://lists.gnu.org/archive/html/qemu-devel/2018-10/msg05750.html
>>
>> diff --git a/hw/ppc/pnv_lpc.c b/hw/ppc/pnv_lpc.c
>> index d7721320a2..172a915cfc 100644
>> --- a/hw/ppc/pnv_lpc.c
>> +++ b/hw/ppc/pnv_lpc.c
>> @@ -155,9 +155,15 @@ static void pnv_lpc_do_eccb(PnvLpcController *lpc, uint64_t cmd)
>> /* XXX Check for magic bits at the top, addr size etc... */
>> unsigned int sz = (cmd & ECCB_CTL_SZ_MASK) >> ECCB_CTL_SZ_LSH;
>> uint32_t opb_addr = cmd & ECCB_CTL_ADDR_MASK;
>> - uint8_t data[4];
>> + uint8_t data[8];
>> bool success;
>
> I'm not sure 8 is enough.
>
> ECCB_CTL_SZ_MASK is PPC_BITMASK(4, 7), and ECCB_CTL_SZ_LSH is (63 - 7).
> So the bitmask is 4 bits wide, and thus sz can be 0 to 15.
> I think data[] size should be 16.
The bitmask allows more that 8 but the specs says that 1, 2, 4, 8 are the
possible value size. So We should be fine.
C.
>
> Thanks,
> Laurent
>
prev parent reply other threads:[~2018-11-08 16:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-26 12:33 [Qemu-devel] [PATCH v2] ppc/pnv: check size before data buffer access P J P
2018-10-26 16:40 ` Cédric Le Goater
2018-11-03 13:28 ` David Gibson
2018-11-08 9:10 ` Laurent Vivier
2018-11-08 16:51 ` Cédric Le Goater [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=21ed9d28-9153-266c-5190-8c17aadff78e@kaod.org \
--to=clg@kaod.org \
--cc=agraf@suse.de \
--cc=david@gibson.dropbear.id.au \
--cc=lvivier@redhat.com \
--cc=moguofang@huawei.com \
--cc=pjp@fedoraproject.org \
--cc=ppandit@redhat.com \
--cc=qemu-devel@nongnu.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).