From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Matthew Rosato <mjrosato@linux.ibm.com>,
Peter Maydell <peter.maydell@linaro.org>,
qemu-devel@nongnu.org
Cc: qemu-s390x@nongnu.org, Eric Farman <farman@linux.ibm.com>,
Thomas Huth <thuth@redhat.com>
Subject: Re: [PATCH] hw/s390x/s390-pci-bus.c: Use g_assert_not_reached() in functions taking an ett
Date: Fri, 11 Jul 2025 12:21:59 +0200 [thread overview]
Message-ID: <eb62a1c3-1aab-4398-831b-1fb82402d67d@linaro.org> (raw)
In-Reply-To: <36819228-b4c2-44a7-bc85-f5630c8412b5@linux.ibm.com>
Hi Matthew,
On 10/7/25 23:20, Matthew Rosato wrote:
> On 7/10/25 12:15 PM, Peter Maydell wrote:
>> The s390-pci-bus.c code, Coverity complains about a possible overflow
>> because get_table_index() can return -1 if the ett value passed in is
>> not one of the three permitted ZPCI_ETT_PT, ZPCI_ETT_ST, ZPCI_ETT_RT,
>> but the caller in table_translate() doesn't check this and instead
>> uses the return value directly in a calculation of the guest address
>> to read from.
>>
>> In fact this case cannot happen, because:
>> * get_table_index() is called only from table_translate()
>> * the only caller of table_translate() loops through the ett values
>> in the order RT, ST, PT until table_translate() returns 0
>> * table_translate() will return 0 for the error cases and when
>> translate_iscomplete() returns true
>> * translate_iscomplete() is always true for ZPCI_ETT_PT
>>
>> So table_translate() is always called with a valid ett value.
>>
>> Instead of having the various functions called from table_translate()
>> return a default or dummy value when the ett argument is out of range,
>> use g_assert_not_reached() to indicate that this is impossible.
>>
>> Coverity: CID 1547609
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>> Disclaimer: only tested with 'make check/make check-functional'
>
> Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
>
> Also to sanity check I ran various tests with s390x guests and a few different PCI passthrough devices using a guest IOMMU to drive table_translate frequently.
Does that mean we can include your Tested-by: tag?
prev parent reply other threads:[~2025-07-11 10:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-10 16:15 [PATCH] hw/s390x/s390-pci-bus.c: Use g_assert_not_reached() in functions taking an ett Peter Maydell
2025-07-10 19:36 ` Halil Pasic
2025-07-10 21:20 ` Matthew Rosato
2025-07-11 10:21 ` 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=eb62a1c3-1aab-4398-831b-1fb82402d67d@linaro.org \
--to=philmd@linaro.org \
--cc=farman@linux.ibm.com \
--cc=mjrosato@linux.ibm.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--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 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).