[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC 1/5] libvhost-user: Add vu_rem_mem_reg input validation
From: |
Stefan Hajnoczi |
Subject: |
Re: [RFC 1/5] libvhost-user: Add vu_rem_mem_reg input validation |
Date: |
Wed, 5 Jan 2022 11:00:35 +0000 |
On Wed, Dec 15, 2021 at 10:29:48PM +0000, Raphael Norwitz wrote:
> Signed-off-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
> ---
> subprojects/libvhost-user/libvhost-user.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/subprojects/libvhost-user/libvhost-user.c
> b/subprojects/libvhost-user/libvhost-user.c
> index 787f4d2d4f..573212a83b 100644
> --- a/subprojects/libvhost-user/libvhost-user.c
> +++ b/subprojects/libvhost-user/libvhost-user.c
> @@ -801,6 +801,12 @@ vu_rem_mem_reg(VuDev *dev, VhostUserMsg *vmsg) {
> VuDevRegion shadow_regions[VHOST_USER_MAX_RAM_SLOTS] = {};
> VhostUserMemoryRegion m = vmsg->payload.memreg.region, *msg_region = &m;
>
> + if (vmsg->fd_num != 1 ||
> + vmsg->size != sizeof(vmsg->payload.memreg)) {
> + vu_panic(dev, "VHOST_USER_REM_MEM_REG received multiple regions");
> + return true;
Most vu_panic() callers return false to indicate that a reply does not
need to be sent. When the return value is true vu_dispatch() sends a
response, which we don't want.
Note that vu_dispatch() returns true (success) when the message handler
function returns false. The success/failure behavior should probably be
separated from the reply_requested behavior :(.
Anyway, returning false is probably appropriate here.
Stefan
signature.asc
Description: PGP signature
- Re: [RFC 1/5] libvhost-user: Add vu_rem_mem_reg input validation,
Stefan Hajnoczi <=