All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frederic Konrad <konrad.frederic@yahoo.fr>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: Alistair Francis <alistair@alistair23.me>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Subject: Re: [Qemu-devel] [PULL 28/30] introduce xlnx-dp
Date: Thu, 7 Apr 2022 13:28:13 +0200	[thread overview]
Message-ID: <19e26661-8fe9-0e77-d21d-91ab214af42c@yahoo.fr> (raw)
In-Reply-To: <CAFEAcA9z+BCgxa-M8EM3naC-3A4khLcS-MZCd-WjKg8JBddtTQ@mail.gmail.com>



Le 4/7/22 à 12:32, Peter Maydell a écrit :
> On Tue, 14 Jun 2016 at 15:40, Peter Maydell <peter.maydell@linaro.org> wrote:
>>
>> From: KONRAD Frederic <fred.konrad@greensocs.com>
>>
>> This is the implementation of the DisplayPort.
>> It has an aux-bus to access dpcd and edid.
>>
>> Graphic plane is connected to the channel 3.
>> Video plane is connected to the channel 0.
>> Audio stream are connected to the channels 4 and 5.
> 
> Very old patch, but Coverity has just pointed out an array
> overrun in it (CID 1487260):
> 
> We define a set of offsets for V_BLEND registers, of which
> the largest is this one:
> 
>> +#define V_BLEND_CHROMA_KEY_COMP3            (0x01DC >> 2)
> 
>> +static void xlnx_dp_vblend_write(void *opaque, hwaddr offset,
>> +                                 uint64_t value, unsigned size)
>> +{
>> +    XlnxDPState *s = XLNX_DP(opaque);
>> +    bool alpha_was_enabled;
>> +
>> +    DPRINTF("vblend: write @0x%" HWADDR_PRIX " = 0x%" PRIX32 "\n", offset,
>> +                                                               (uint32_t)value);
>> +    offset = offset >> 2;
>> +
>> +    switch (offset) {
> 
>> +    case V_BLEND_CHROMA_KEY_COMP1:
>> +    case V_BLEND_CHROMA_KEY_COMP2:
>> +    case V_BLEND_CHROMA_KEY_COMP3:
>> +        s->vblend_registers[offset] = value & 0x0FFF0FFF;
> 
> We use V_BLEND_CHROMA_KEY_COMP3 as an index into the vblend_registers array...
> 
>> +        break;
>> +    default:
>> +        s->vblend_registers[offset] = value;
>> +        break;
>> +    }
>> +}
> 
>> +#define DP_CORE_REG_ARRAY_SIZE              (0x3AF >> 2)
>> +#define DP_AVBUF_REG_ARRAY_SIZE             (0x238 >> 2)
>> +#define DP_VBLEND_REG_ARRAY_SIZE            (0x1DF >> 2)
>> +#define DP_AUDIO_REG_ARRAY_SIZE             (0x50 >> 2)
> 
>> +    uint32_t vblend_registers[DP_VBLEND_REG_ARRAY_SIZE];
> 
> ..but we have defined DP_VBLEND_REG_ARRAY_SIZE to 0x1DF >> 2,
> which is the same as 0x1DC >> 2, and so the array size is too small.
> 
> The size of the memory region is also suspicious:
> 
> +    memory_region_init_io(&s->vblend_iomem, obj, &vblend_ops, s, TYPE_XLNX_DP
> +                          ".v_blend", 0x1DF);
> 
> This is a "32-bit accesses only" region, but we have defined it with a
> size that is not a multiple of 4. That looks wrong... (It also means
> that rather than having an array overrun I think the actual effect
> is that the guest won't be able to access the last register, because
> it's not entirely within the memoryregion.)

arg, sorry for that..

I share your point, it should not be possible to access it, but using
the monitor:

(qemu) info mtree
...
00000000fd4aa000-00000000fd4aa1de (prio 0, i/o): xlnx.v-dp.v_blend
...

I can actually read that register (at least it doesn't complain, on an
older qemu version though):
(qemu) xp /w 0xfd4aa1dc
00000000fd4aa1dc: 0x00000000

So I'm not totally sure.. do you need a patch for 7.0.0?

> 
> Coverity doesn't complain about it, but the DP_CORE_REG_ARRAY_SIZE
> may also have a similar problem.

I think it doesn't complain because writing to the last register doesn't
actually write into the array but update the mask register instead:

     case DP_INT_DS:
         s->core_registers[DP_INT_MASK] |= ~value;
         xlnx_dp_update_irq(s);
         break;

> 
> thanks
> -- PMM

Best Regards,
Fred


  reply	other threads:[~2022-04-07 11:30 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-14 14:13 [Qemu-devel] [PULL 00/30] target-arm queue Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 01/30] target-arm: kvm64: set guest PMUv3 feature bit if supported Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 02/30] hw/arm/virt: Add PMU node for virt machine Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 03/30] hw/arm/virt-acpi-build: Add PMU IRQ number in ACPI table Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 04/30] target-arm: Fix reset and migration of TTBCR(S) Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 05/30] hw/arm/virt: separate versioned type-init code Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 06/30] hw/arm/virt: introduce DEFINE_VIRT_MACHINE Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 07/30] hw/arm/virt: introduce DEFINE_VIRT_MACHINE_AS_LATEST Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 08/30] hw/arm/virt: create the 2.7 machine type Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 09/30] hw/i2c: QOM'ify bitbang_i2c.c Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 10/30] hw/i2c: QOM'ify exynos4210_i2c.c Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 11/30] hw/i2c: QOM'ify omap_i2c.c Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 12/30] hw/i2c: QOM'ify versatile_i2c.c Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 13/30] hw/gpio: QOM'ify omap_gpio.c Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 14/30] hw/gpio: QOM'ify pl061.c Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 15/30] hw/gpio: QOM'ify zaurus.c Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 16/30] hw/misc: QOM'ify arm_l2x0.c Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 17/30] hw/misc: QOM'ify exynos4210_pmu.c Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 18/30] hw/misc: QOM'ify mst_fpga.c Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 19/30] hw/dma: QOM'ify pxa2xx_dma.c Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 20/30] hw/sd: QOM'ify pl181.c Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 21/30] i2cbus: remove unused dev field Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 22/30] i2c: implement broadcast write Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 23/30] i2c: Factor our send() and recv() common logic Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 24/30] introduce aux-bus Peter Maydell
2016-06-14 14:14 ` [Qemu-devel] [PULL 25/30] introduce dpcd module Peter Maydell
2016-06-14 14:14 ` [Qemu-devel] [PULL 26/30] hw/i2c-ddc.c: Implement DDC I2C slave Peter Maydell
2016-06-14 14:14 ` [Qemu-devel] [PULL 27/30] introduce xlnx-dpdma Peter Maydell
2016-06-14 14:14 ` [Qemu-devel] [PULL 28/30] introduce xlnx-dp Peter Maydell
2022-04-07 10:32   ` Peter Maydell
2022-04-07 11:28     ` Frederic Konrad [this message]
2022-04-07 12:26       ` Peter Maydell
2016-06-14 14:14 ` [Qemu-devel] [PULL 29/30] arm: xlnx-zynqmp: Add xlnx-dp and xlnx-dpdma Peter Maydell
2016-06-14 14:14 ` [Qemu-devel] [PULL 30/30] target-arm: Don't permit ARMv8-only Neon insns on ARMv7 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=19e26661-8fe9-0e77-d21d-91ab214af42c@yahoo.fr \
    --to=konrad.frederic@yahoo.fr \
    --cc=alistair@alistair23.me \
    --cc=edgar.iglesias@gmail.com \
    --cc=peter.maydell@linaro.org \
    --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 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.