qemu-trivial
[Top][All Lists]
Advanced

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

Re: [PATCH] linux-user: NETLINK_LIST_MEMBERSHIPS: Allow bad ptr if its l


From: Laurent Vivier
Subject: Re: [PATCH] linux-user: NETLINK_LIST_MEMBERSHIPS: Allow bad ptr if its length is 0
Date: Mon, 29 Mar 2021 11:00:13 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0

Le 28/03/2021 à 20:01, Frédéric Fortier via a écrit :
> getsockopt(fd, SOL_NETLINK, NETLINK_LIST_MEMBERSHIPS, *optval, *optlen)
> syscall allows optval to be NULL/invalid if optlen points to a size of
> zero. This allows userspace to query the length of the array they should
> use to get the full membership list before allocating memory for said
> list, then re-calling getsockopt with proper optval/optlen arguments.
> 
> Notable users of this pattern include systemd-networkd, which in the
> (albeit old) version 237 tested, cannot start without this fix.
> 
> Signed-off-by: Frédéric Fortier <frf@ghgsat.com>
> ---
>  linux-user/syscall.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 1e508576c7..9b7556a9a2 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -3025,7 +3025,7 @@ get_timeout:
>                  return -TARGET_EINVAL;
>              }
>              results = lock_user(VERIFY_WRITE, optval_addr, len, 1);
> -            if (!results) {
> +            if (!results && len > 0) {
>                  return -TARGET_EFAULT;
>              }
>              lv = len;
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>



reply via email to

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