qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 3/3] hw/display/artist: rewrite vram access mode handling


From: Gerd Hoffmann
Subject: Re: [PATCH 3/3] hw/display/artist: rewrite vram access mode handling
Date: Tue, 25 Jan 2022 09:25:52 +0100

  Hi,

> +static void artist_vram_write4(ARTISTState *s, struct vram_buffer *buf,
> +                               uint32_t offset, uint32_t data)

> +static int get_vram_offset(ARTISTState *s, struct vram_buffer *buf,
> +                           int pos, int posy)

> +    case 0x13a0:
> +        artist_vram_write4(s, buf, get_vram_offset(s, buf, pos >> 2, posy),
> +                           data);

That is asking for trouble.

You should pass around offsets not pointers.  An offset can trivially be
checked whenever it is within the valid range (i.e. smaller than vram
size), or it can be masked to strip off high bits when accessing virtual
vram.  You need that for robustness and security reasons (i.e. make sure
the guest can't write to host memory by tricking your get_vram_offset
calculations).

grep cirrus for 'cirrus_addr_mask' to see sample code.

take care,
  Gerd




reply via email to

[Prev in Thread] Current Thread [Next in Thread]