Re: Generic compat_sys_rt_sigqueueinfo

Arnd Bergmann
2006-10-28T23:09:21Z

On Sunday 29 October 2006 00:37, Kyle McMartin wrote:
> +asmlinkage long compat_sys_rt_sigqueueinfo(int pid, int sig,
> +       struct compat_siginfo __user *uinfo)
> +{
> +       mm_segment_t old_fs = get_fs();
> +       siginfo_t info;
> +       int ret;
> +
> +       if (copy_siginfo_from_user32(&info, uinfo))
> +               return -EFAULT;
> +
> +       set_fs(KERNEL_DS);
> +       ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *)&info);
> +       set_fs(old_fs);
> +
> +       return ret;
> +}

Since sys_rt_sigqueueinfo() is so simple, I think it would be much
better to define the common version as

asmlinkage long
sys_rt_sigqueueinfo(int pid, int sig, siginfo_t __user *uinfo)
{
siginfo_t info;

if (compat_copy_siginfo_from_user(&info, uinfo))
return -EFAULT;

/* Not even root can pretend to send signals from the kernel.
Nor can they impersonate a kill(), which adds source info. */
if (info.si_code >= 0)
return -EPERM;
info.si_signo = sig;

/* POSIX.1b doesn't mention process groups. */
return kill_proc_info(sig, &info, pid);
}