On 11 July 2014 16:18, Joakim Tjernlund <joakim.tjernl...@transmode.se> wrote: > Signed-off-by: Joakim Tjernlund <joakim.tjernl...@transmode.se> > --- > 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