Re: [PATCH 2/4 - 2.6.15]net: 32 bit (socket layer) ioctl emulation for 64 bit kernels

Arnd Bergmann
2006-01-12T19:24:23Z

On Thursday 12 January 2006 06:02, Shaun Pereira wrote:
> +int compat_sock_get_timestamp(struct sock *sk, struct timeval __user
> *userstamp)
> +{
> +       struct compat_timeval __user *ctv;
> +       ctv = (struct compat_timeval __user*) userstamp;
> +       if(!sock_flag(sk, SOCK_TIMESTAMP))
> +               sock_enable_timestamp(sk);
> +       if(sk->sk_stamp.tv_sec == -1)
> +               return -ENOENT;
> +       if(sk->sk_stamp.tv_sec == 0)
> +               do_gettimeofday(&sk->sk_stamp);
> +       return copy_to_user(ctv, &sk->sk_stamp, sizeof(struct
> compat_timeval)) ?
> +                       -EFAULT : 0;
> +}

This looks wrong, you're not doing any conversion here.
You cannot just copy sk_stamp to ctv, they are not compatible.
See compat_sys_gettimeofday on how to copy a struct timeval
correctly.

The other patches look good.