Skip to contentSkip to conversation

signal/timer/event fds v6 - signalfd compat code ...

PATCH In review Davide Libenzi 1 participant 2 messages Mar 16, 2007 – Mar 18, 2007 1 message not in the archive VFS

lore
Share & tools
lore
#0 lore raw

PATCH 5/13 signal/timer/event fds v6 - signalfd compat code ...

This patch implement the necessary compat code for the signalfd system call.

- Davide

fs/compat.c +22 -0
Index: linux-2.6.21-rc3.quilt/fs/compat.c
===================================================================
@@ -46,6 +46,7 @@
 #include <linux/rwsem.h>
 #include <linux/tsacct_kern.h>
 #include <linux/highmem.h>
+#include <linux/signal.h>
 #include <linux/poll.h>
 #include <linux/mm.h>
 
@@ -2235,3 +2236,24 @@
 	return sys_ni_syscall();
 }
 #endif
+
+asmlinkage long compat_sys_signalfd(int ufd,
+				    const compat_sigset_t __user *sigmask,
+				    compat_size_t sigsetsize)
+{
+	compat_sigset_t ss32;
+	sigset_t tmp;
+	sigset_t __user *ksigmask;
+
+	if (sigsetsize != sizeof(compat_sigset_t))
+		return -EINVAL;
+	if (copy_from_user(&ss32, sigmask, sizeof(ss32)))
+		return -EFAULT;
+	sigset_from_compat(&tmp, &ss32);
+	ksigmask = compat_alloc_user_space(sizeof(sigset_t));
+	if (copy_to_user(ksigmask, &tmp, sizeof(sigset_t)))
+		return -EFAULT;
+
+	return sys_signalfd(ufd, ksigmask, sizeof(sigset_t));
+}
+

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 24 lines · Arnd Bergmann
Quoted 9 lines · On Friday 16 March 2007 01:22:15 Davide Libenzi wrote:
fs/compat.c +9 -0
+asmlinkage long compat_sys_signalfd(int ufd,
+                                   const compat_sigset_t __user *sigmask,
+                                   compat_size_t sigsetsize)
+{
+       compat_sigset_t ss32;
+       sigset_t tmp;
+       sigset_t __user *ksigmask;
+
+       if (sigsetsize != sizeof(compat_sigset_t))

fs/compat.c line 2258

Quoted 10 lines
fs/compat.c +10 -0
+               return -EINVAL;
+       if (copy_from_user(&ss32, sigmask, sizeof(ss32)))
+               return -EFAULT;
+       sigset_from_compat(&tmp, &ss32);
+       ksigmask = compat_alloc_user_space(sizeof(sigset_t));
+       if (copy_to_user(ksigmask, &tmp, sizeof(sigset_t)))
+               return -EFAULT;
+
+       return sys_signalfd(ufd, ksigmask, sizeof(sigset_t));
+}

Doing the compat_alloc_user_space() magic obviously makes the 32 bit emulation code less efficient. How about having a

Quoted 4 lines

long do_signalfd(int ufd, const sigset_t *sigmask, size_t sigsetsize);

that is called directly by both sys_signalfd and compat_sys_signalfd? Same obviously applies also to do_timerfd.

Hmm, copy_*_user (one or two moves) and compat_alloc_user_space are pretty fast...

- Davide