[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/4] qemu-user: Impl. setsockopt(SO_BINDTODEVICE
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH 1/4] qemu-user: Impl. setsockopt(SO_BINDTODEVICE) |
Date: |
Fri, 11 Jul 2014 16:46:28 +0100 |
On 11 July 2014 16:18, Joakim Tjernlund <address@hidden> wrote:
> Signed-off-by: Joakim Tjernlund <address@hidden>
> ---
> linux-user/syscall.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 5a272d3..1380f4e 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -1497,6 +1497,18 @@ set_timeout:
> unlock_user_struct(tfprog, optval_addr, 1);
> return ret;
> }
> + case TARGET_SO_BINDTODEVICE:
> + {
> + char *dev_ifname;
> +
> + if (optlen > IFNAMSIZ)
> + return -TARGET_EINVAL;
This needs braces for our coding style; you might like
to run your patches through scripts/checkpatch.pl, which
will warn about this kind of thing.
Also, the kernel implementation handles overlong
lengths via
if (optlen > IFNAMSIZ - 1) {
optlen = IFNAMSIZ - 1;
}
which effectively truncates overlong strings rather
than rejecting them. We should do the same (there will
be complication required to ensure we pass the kernel
a NUL-terminated string even if we don't get one from
the guest; may be easiest to use a local array, given
IFNAMSIZ is only 16).
> +
> + dev_ifname = lock_user(VERIFY_READ, optval_addr, optlen, 1);
> + ret = get_errno(setsockopt(sockfd, level, optname,
> dev_ifname, optlen));
This is passing the target optname through to the
host kernel; you need to set 'optname = SO_BINDTODEVICE;'
(look at the other cases in this switch).
> + unlock_user (dev_ifname, optval_addr, 0);
> + return ret;
> + }
> /* Options with 'int' argument. */
> case TARGET_SO_DEBUG:
> optname = SO_DEBUG;
> --
> 1.8.5.5
thanks
-- PMM
- Re: [Qemu-devel] [Qemu-ppc] [PATCH 4/4] ppc: remove excessive logging, (continued)
- Re: [Qemu-devel] [Qemu-ppc] [PATCH 4/4] ppc: remove excessive logging, Alexander Graf, 2014/07/11
- Re: [Qemu-devel] [Qemu-ppc] [PATCH 4/4] ppc: remove excessive logging, Joakim Tjernlund, 2014/07/12
- Re: [Qemu-devel] [Qemu-ppc] [PATCH 4/4] ppc: remove excessive logging, Peter Maydell, 2014/07/12
- Re: [Qemu-devel] [Qemu-ppc] [PATCH 4/4] ppc: remove excessive logging, Alexander Graf, 2014/07/12
- Re: [Qemu-devel] [Qemu-ppc] [PATCH 4/4] ppc: remove excessive logging, Peter Maydell, 2014/07/12
- Re: [Qemu-devel] [Qemu-ppc] [PATCH 4/4] ppc: remove excessive logging, Alexander Graf, 2014/07/12
- Re: [Qemu-devel] [Qemu-ppc] [PATCH 4/4] ppc: remove excessive logging, Joakim Tjernlund, 2014/07/12
[Qemu-devel] [PATCH 3/4] alloca one extra byte sockets, Joakim Tjernlund, 2014/07/11
[Qemu-devel] [PATCH 1/4] qemu-user: Impl. setsockopt(SO_BINDTODEVICE), Joakim Tjernlund, 2014/07/11
- Re: [Qemu-devel] [PATCH 1/4] qemu-user: Impl. setsockopt(SO_BINDTODEVICE),
Peter Maydell <=
- Re: [Qemu-devel] [PATCH 1/4] qemu-user: Impl. setsockopt(SO_BINDTODEVICE), Joakim Tjernlund, 2014/07/11
- Re: [Qemu-devel] [PATCH 1/4] qemu-user: Impl. setsockopt(SO_BINDTODEVICE), Peter Maydell, 2014/07/11
- Re: [Qemu-devel] [PATCH 1/4] qemu-user: Impl. setsockopt(SO_BINDTODEVICE), Joakim Tjernlund, 2014/07/12
- Re: [Qemu-devel] [PATCH 1/4] qemu-user: Impl. setsockopt(SO_BINDTODEVICE), Peter Maydell, 2014/07/12
- Re: [Qemu-devel] [PATCH 1/4] qemu-user: Impl. setsockopt(SO_BINDTODEVICE), Joakim Tjernlund, 2014/07/12
- Re: [Qemu-devel] [PATCH 1/4] qemu-user: Impl. setsockopt(SO_BINDTODEVICE), Peter Maydell, 2014/07/12
- Re: [Qemu-devel] [PATCH 1/4] qemu-user: Impl. setsockopt(SO_BINDTODEVICE), Joakim Tjernlund, 2014/07/12
Re: [Qemu-devel] [PATCH 1/4] qemu-user: Impl. setsockopt(SO_BINDTODEVICE), Joakim Tjernlund, 2014/07/12
Re: [Qemu-devel] [PATCH 1/4] qemu-user: Impl. setsockopt(SO_BINDTODEVICE), Peter Maydell, 2014/07/12
Re: [Qemu-devel] [PATCH 1/4] qemu-user: Impl. setsockopt(SO_BINDTODEVICE), Joakim Tjernlund, 2014/07/12