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

RE: [PATCH] Fail XS_DIRECTORY for paths with no children



> -----Original Message-----
> From: win-pv-devel <win-pv-devel-bounces@xxxxxxxxxxxxxxxxxxxx> On Behalf Of 
> Owen Smith
> Sent: 06 January 2021 16:18
> To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
> Cc: Owen Smith <owen.smith@xxxxxxxxxx>
> Subject: [PATCH] Fail XS_DIRECTORY for paths with no children
> 
> When a xenstore path has no children, a response is generated which
> contians only the double null terminator. Detect a 0-length response

s/contains/contains... I'll fix on commit

> payload and return STATUS_OBJECT_PATH_NOT_FOUND to indicate that this
> path does not have any children
> 

STATUS_OBJECT_PATH_NOT_FOUND is what we use for ENOENT in xen-erro.h so that's 
the right choice :-)

> Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>

Acked-by: Paul Durrant <paul@xxxxxxx>

> ---
>  src/xenbus/store.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/src/xenbus/store.c b/src/xenbus/store.c
> index cbc442e..570b8b5 100644
> --- a/src/xenbus/store.c
> +++ b/src/xenbus/store.c
> @@ -115,6 +115,7 @@ typedef struct _XENBUS_STORE_REQUEST {
>  typedef struct _XENBUS_STORE_BUFFER {
>      LIST_ENTRY  ListEntry;
>      ULONG       Magic;
> +    ULONG       Length;
>      PVOID       Caller;
>      CHAR        Data[1];
>  } XENBUS_STORE_BUFFER, *PXENBUS_STORE_BUFFER;
> @@ -1036,6 +1037,7 @@ StoreCopyPayload(
>          goto fail1;
> 
>      Buffer->Magic = XENBUS_STORE_BUFFER_MAGIC;
> +    Buffer->Length = Length;
>      Buffer->Caller = Caller;
> 
>      RtlCopyMemory(Buffer->Data, Data, Length);
> @@ -1044,7 +1046,7 @@ StoreCopyPayload(
>      InsertTailList(&Context->BufferList, &Buffer->ListEntry);
>      KeReleaseSpinLock(&Context->Lock, Irql);
> 
> -    return Buffer;
> +    return Buffer;
> 
>  fail1:
>      Error("fail1 (%08x)\n", status);
> @@ -1439,6 +1441,10 @@ StoreDirectory(
>      if (Buffer == NULL)
>          goto fail4;
> 
> +    status = STATUS_OBJECT_PATH_NOT_FOUND;
> +    if (Buffer->Length == 0)
> +        goto fail5;
> +
>      StoreFreeResponse(Response);
>      ASSERT(IsZeroMemory(&Request, sizeof (XENBUS_STORE_REQUEST)));
> 
> @@ -1446,6 +1452,9 @@ StoreDirectory(
> 
>      return STATUS_SUCCESS;
> 
> +fail5:
> +    StoreFreePayload(Context, Buffer);
> +
>  fail4:
>  fail3:
>      StoreFreeResponse(Response);
> --
> 2.28.0.windows.1
> 





 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.