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

RE: [PATCH] Avoid EINVAL from XenStore



> -----Original Message-----
> From: win-pv-devel <win-pv-devel-bounces@xxxxxxxxxxxxxxxxxxxx> On Behalf Of 
> Owen Smith
> Sent: 05 January 2021 08:12
> To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
> Cc: Owen Smith <owen.smith@xxxxxxxxxx>
> Subject: [PATCH] Avoid EINVAL from XenStore
> 
> XenStore Directory can return an empty string as the first element of
> its buffer, which is converted into a 1 element array of (valid)
> ANSI_STRINGs with length 0. When this 0 length string is passed to
> XenStore Read, it attempts to read an invalid path (e.g. "~/drivers/")
> which fails with EINVAL.
> Add a check to skip 0 length strings in FdoClearDistribution.
> 

I think this is the wrong way to fix this... it's dealing with the symptom 
rather than the cause. The code modified here is
duplicated in other drivers and so they would need fixing too, whereas fixing 
XENBUS_STORE(Directory, ...) to not hand back empty
strings would fix it everywhere.

  Paul

> Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
> ---
>  src/xenbus/fdo.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c
> index 21de867..9c5decc 100644
> --- a/src/xenbus/fdo.c
> +++ b/src/xenbus/fdo.c
> @@ -2606,6 +2606,11 @@ FdoClearDistribution(
>      for (Index = 0; Distributions[Index].Buffer != NULL; Index++) {
>          PANSI_STRING    Distribution = &Distributions[Index];
> 
> +        // If ~/drivers has no children, an empty string could be returned.
> +        // Note: Distribution->Buffer is 1 CHAR of "\0"
> +        if (Distribution[Index].Length == 0)
> +            continue;
> +
>          status = XENBUS_STORE(Read,
>                                &Fdo->StoreInterface,
>                                NULL,
> --
> 2.28.0.windows.1
> 





 


Rackspace

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