All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE
@ 2014-03-06 15:51 Heiko Carstens
  2014-03-06 15:51 ` [PATCH/RFC 01/16] compat: let architectures define __ARCH_WANT_COMPAT_SYS_GETDENTS64 Heiko Carstens
                   ` (17 more replies)
  0 siblings, 18 replies; 28+ messages in thread
From: Heiko Carstens @ 2014-03-06 15:51 UTC (permalink / raw)
  To: Al Viro, H. Peter Anvin, Ingo Molnar, Thomas Gleixner
  Cc: linux-arch, Martin Schwidefsky, Heiko Carstens

Hi all,

this patch series converts all common code compat syscalls to use the new
COMPAT_SYSCALL_DEFINE macros introduced by Al Viro.
My main motivation is to get rid of the 1400+ line s390 specific assembler
file which contains code for each and every compat system call to perform
proper sign, zero and pointer conversion.

Eventually the conversion is pretty trivial, except that for a couple of
compat syscalls argument types needed to be changed from e.g. 'long' to
'compat_long_t' so that the COMPAT_SYSCALL_DEFINE macro can perform
proper sign extension from the 32 bit compat system call argument like
it was orginally passed in from user space.

The patch series keeps the "noop" conversions (5-10) and those with type
changes (11-15) separate.

Patches 1-4 are just additional cleanup patches.

Especially I'd like to know from somebody familiar with the x32 ABI if
any of the type changes break x32?
I intentionally did not touch the preadv64 and pwritev64 compat system
calls since they have been explicitly added to allow x32 pass 64 bit
arguments.
However it's not obvious to me if any of my other compat system call
changes break x32 or not.

FWIW, this patch series omits the whole s390 patches, since I assume
they are not very interesting to non-s390 people ;)

The complete series (including the s390 only patches) is available at

  git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git compat

If nobody objects I'd like to have the branch integrated into linux-next
to get some additional testing.

So, please let me know if I screwed up something! :)

Thanks,
Heiko

Heiko Carstens (16):
      compat: let architectures define __ARCH_WANT_COMPAT_SYS_GETDENTS64
      compat: add COMPAT_SYSCALL_DEFINE0 macro
      ipc/compat_sys_msgrcv: change msgtyp type from long to compat_long_t
      fs/compat: optional preadv64/pwrite64 compat system calls
      kernel/compat: convert to COMPAT_SYSCALL_DEFINE
      net/compat: convert to COMPAT_SYSCALL_DEFINE
      mm/compat: convert to COMPAT_SYSCALL_DEFINE
      security/compat: convert to COMPAT_SYSCALL_DEFINE
      fs/compat: convert to COMPAT_SYSCALL_DEFINE
      ipc/compat: convert to COMPAT_SYSCALL_DEFINE
      fs/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types
      ipc/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types
      net/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types
      kexec/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types
      mm/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types
      s390/compat: build error for large compat syscall args

(diffstat below includes the s390 only patches)

 arch/arm64/include/asm/unistd.h   |    1 +
 arch/mips/include/asm/unistd.h    |    1 -
 arch/s390/include/asm/compat.h    |    6 +-
 arch/s390/kernel/compat_linux.c   |  116 +--
 arch/s390/kernel/compat_linux.h   |   81 +--
 arch/s390/kernel/compat_signal.c  |    4 +-
 arch/s390/kernel/compat_wrapper.S | 1425 -------------------------------------
 arch/s390/kernel/compat_wrapper.c |  209 ++++++
 arch/s390/kernel/entry.h          |    6 +-
 arch/s390/kernel/syscalls.S       |  504 ++++++-------
 arch/x86/include/asm/unistd.h     |    3 +
 fs/compat.c                       |  121 ++--
 fs/compat_ioctl.c                 |    5 +-
 fs/exec.c                         |    6 +-
 fs/read_write.c                   |   36 +-
 include/linux/compat.h            |   62 +-
 include/linux/kexec.h             |    6 -
 include/linux/syscalls.h          |    2 +
 include/uapi/asm-generic/unistd.h |    1 +
 ipc/compat.c                      |   13 +-
 ipc/compat_mq.c                   |   32 +-
 kernel/compat.c                   |  100 +--
 kernel/kexec.c                    |    8 +-
 kernel/ptrace.c                   |    4 +-
 mm/mempolicy.c                    |   18 +-
 mm/process_vm_access.c            |   26 +-
 net/compat.c                      |   32 +-
 security/keys/compat.c            |    4 +-
 28 files changed, 828 insertions(+), 2004 deletions(-)

-- 
1.8.4.5

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH/RFC 01/16] compat: let architectures define __ARCH_WANT_COMPAT_SYS_GETDENTS64
  2014-03-06 15:51 [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE Heiko Carstens
@ 2014-03-06 15:51 ` Heiko Carstens
  2014-03-20 10:03   ` Geert Uytterhoeven
  2014-03-06 15:51 ` [PATCH/RFC 02/16] compat: add COMPAT_SYSCALL_DEFINE0 macro Heiko Carstens
                   ` (16 subsequent siblings)
  17 siblings, 1 reply; 28+ messages in thread
From: Heiko Carstens @ 2014-03-06 15:51 UTC (permalink / raw)
  To: Al Viro, H. Peter Anvin, Ingo Molnar, Thomas Gleixner
  Cc: linux-arch, Martin Schwidefsky, Heiko Carstens

For architecture dependent compat syscalls in common code an architecture
must define something like __ARCH_WANT_<WHATEVER> if it wants to use the
code.
This however is not true for compat_sys_getdents64 for which architectures
must define __ARCH_OMIT_COMPAT_SYS_GETDENTS64 if they do not want the code.

This leads to the situation where all architectures, except mips, get the
compat code but only x86_64, arm64 and the generic syscall architectures
actually use it.

So invert the logic, so that architectures actively must do something to
get the compat code.

This way a couple of architectures get rid of otherwise dead code.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 arch/arm64/include/asm/unistd.h   | 1 +
 arch/mips/include/asm/unistd.h    | 1 -
 arch/x86/include/asm/unistd.h     | 1 +
 fs/compat.c                       | 4 ++--
 include/linux/compat.h            | 2 ++
 include/uapi/asm-generic/unistd.h | 1 +
 6 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h
index 82ce217e94cf..a4654c656a1e 100644
--- a/arch/arm64/include/asm/unistd.h
+++ b/arch/arm64/include/asm/unistd.h
@@ -14,6 +14,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 #ifdef CONFIG_COMPAT
+#define __ARCH_WANT_COMPAT_SYS_GETDENTS64
 #define __ARCH_WANT_COMPAT_STAT64
 #define __ARCH_WANT_SYS_GETHOSTNAME
 #define __ARCH_WANT_SYS_PAUSE
diff --git a/arch/mips/include/asm/unistd.h b/arch/mips/include/asm/unistd.h
index 4d3b92886665..413d6c612bec 100644
--- a/arch/mips/include/asm/unistd.h
+++ b/arch/mips/include/asm/unistd.h
@@ -24,7 +24,6 @@
 
 #ifndef __ASSEMBLY__
 
-#define __ARCH_OMIT_COMPAT_SYS_GETDENTS64
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_SYS_ALARM
 #define __ARCH_WANT_SYS_GETHOSTNAME
diff --git a/arch/x86/include/asm/unistd.h b/arch/x86/include/asm/unistd.h
index c2a48139c340..f4b5795d7e34 100644
--- a/arch/x86/include/asm/unistd.h
+++ b/arch/x86/include/asm/unistd.h
@@ -23,6 +23,7 @@
 #  include <asm/unistd_64.h>
 #  include <asm/unistd_64_x32.h>
 #  define __ARCH_WANT_COMPAT_SYS_TIME
+#  define __ARCH_WANT_COMPAT_SYS_GETDENTS64
 
 # endif
 
diff --git a/fs/compat.c b/fs/compat.c
index 6af20de2c1a3..0095a6978eef 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -981,7 +981,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
 	return error;
 }
 
-#ifndef __ARCH_OMIT_COMPAT_SYS_GETDENTS64
+#ifdef __ARCH_WANT_COMPAT_SYS_GETDENTS64
 
 struct compat_getdents_callback64 {
 	struct dir_context ctx;
@@ -1066,7 +1066,7 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
 	fdput(f);
 	return error;
 }
-#endif /* ! __ARCH_OMIT_COMPAT_SYS_GETDENTS64 */
+#endif /* __ARCH_WANT_COMPAT_SYS_GETDENTS64 */
 
 /*
  * Exactly like fs/open.c:sys_open(), except that it doesn't set the
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 3f448c65511b..beded18f992d 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -502,9 +502,11 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
 asmlinkage long compat_sys_getdents(unsigned int fd,
 				    struct compat_linux_dirent __user *dirent,
 				    unsigned int count);
+#ifdef __ARCH_WANT_COMPAT_SYS_GETDENTS64
 asmlinkage long compat_sys_getdents64(unsigned int fd,
 				      struct linux_dirent64 __user *dirent,
 				      unsigned int count);
+#endif
 asmlinkage long compat_sys_vmsplice(int fd, const struct compat_iovec __user *,
 				    unsigned int nr_segs, unsigned int flags);
 asmlinkage long compat_sys_open(const char __user *filename, int flags,
diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h
index dde8041f40d2..6db66783d268 100644
--- a/include/uapi/asm-generic/unistd.h
+++ b/include/uapi/asm-generic/unistd.h
@@ -191,6 +191,7 @@ __SYSCALL(__NR_quotactl, sys_quotactl)
 
 /* fs/readdir.c */
 #define __NR_getdents64 61
+#define __ARCH_WANT_COMPAT_SYS_GETDENTS64
 __SC_COMP(__NR_getdents64, sys_getdents64, compat_sys_getdents64)
 
 /* fs/read_write.c */
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH/RFC 02/16] compat: add COMPAT_SYSCALL_DEFINE0 macro
  2014-03-06 15:51 [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE Heiko Carstens
  2014-03-06 15:51 ` [PATCH/RFC 01/16] compat: let architectures define __ARCH_WANT_COMPAT_SYS_GETDENTS64 Heiko Carstens
@ 2014-03-06 15:51 ` Heiko Carstens
  2014-03-06 15:51 ` [PATCH/RFC 03/16] ipc/compat_sys_msgrcv: change msgtyp type from long to compat_long_t Heiko Carstens
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2014-03-06 15:51 UTC (permalink / raw)
  To: Al Viro, H. Peter Anvin, Ingo Molnar, Thomas Gleixner
  Cc: linux-arch, Martin Schwidefsky, Heiko Carstens

For consistency reason add a COMPAT_SYSCALL_DEFINE0 macro.
This macro should be used for compat system calls with zero parameters.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 include/linux/compat.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/compat.h b/include/linux/compat.h
index beded18f992d..4c42df3fce37 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -27,6 +27,9 @@
 #define __SC_DELOUSE(t,v) ((t)(unsigned long)(v))
 #endif
 
+#define COMPAT_SYSCALL_DEFINE0(name) \
+	asmlinkage long compat_sys_##name(void)
+
 #define COMPAT_SYSCALL_DEFINE1(name, ...) \
         COMPAT_SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
 #define COMPAT_SYSCALL_DEFINE2(name, ...) \
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH/RFC 03/16] ipc/compat_sys_msgrcv: change msgtyp type from long to compat_long_t
  2014-03-06 15:51 [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE Heiko Carstens
  2014-03-06 15:51 ` [PATCH/RFC 01/16] compat: let architectures define __ARCH_WANT_COMPAT_SYS_GETDENTS64 Heiko Carstens
  2014-03-06 15:51 ` [PATCH/RFC 02/16] compat: add COMPAT_SYSCALL_DEFINE0 macro Heiko Carstens
@ 2014-03-06 15:51 ` Heiko Carstens
  2014-03-06 15:51 ` [PATCH/RFC 04/16] fs/compat: optional preadv64/pwrite64 compat system calls Heiko Carstens
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2014-03-06 15:51 UTC (permalink / raw)
  To: Al Viro, H. Peter Anvin, Ingo Molnar, Thomas Gleixner
  Cc: linux-arch, Martin Schwidefsky, Heiko Carstens

Change the type of compat_sys_msgrcv's msgtyp parameter from long
to compat_long_t, since compat user space passes only a 32 bit signed
value.
Let the compat wrapper do proper sign extension to 64 bit of this
parameter.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 include/linux/compat.h | 2 +-
 ipc/compat.c           | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/compat.h b/include/linux/compat.h
index 4c42df3fce37..179b1da9e19f 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -321,7 +321,7 @@ asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
 		compat_ssize_t msgsz, int msgflg);
 asmlinkage long compat_sys_msgrcv(int msqid, compat_uptr_t msgp,
-		compat_ssize_t msgsz, long msgtyp, int msgflg);
+		compat_ssize_t msgsz, compat_long_t msgtyp, int msgflg);
 long compat_sys_msgctl(int first, int second, void __user *uptr);
 long compat_sys_shmctl(int first, int second, void __user *uptr);
 long compat_sys_semtimedop(int semid, struct sembuf __user *tsems,
diff --git a/ipc/compat.c b/ipc/compat.c
index f486b0096a67..e1f4ab65660c 100644
--- a/ipc/compat.c
+++ b/ipc/compat.c
@@ -430,9 +430,9 @@ COMPAT_SYSCALL_DEFINE4(msgsnd, int, msqid, compat_uptr_t, msgp,
 }
 
 COMPAT_SYSCALL_DEFINE5(msgrcv, int, msqid, compat_uptr_t, msgp,
-		       compat_ssize_t, msgsz, long, msgtyp, int, msgflg)
+		       compat_ssize_t, msgsz, compat_long_t, msgtyp, int, msgflg)
 {
-	return do_msgrcv(msqid, compat_ptr(msgp), (ssize_t)msgsz, msgtyp,
+	return do_msgrcv(msqid, compat_ptr(msgp), (ssize_t)msgsz, (long)msgtyp,
 			 msgflg, compat_do_msg_fill);
 }
 
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH/RFC 04/16] fs/compat: optional preadv64/pwrite64 compat system calls
  2014-03-06 15:51 [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE Heiko Carstens
                   ` (2 preceding siblings ...)
  2014-03-06 15:51 ` [PATCH/RFC 03/16] ipc/compat_sys_msgrcv: change msgtyp type from long to compat_long_t Heiko Carstens
@ 2014-03-06 15:51 ` Heiko Carstens
  2014-03-06 15:51 ` [PATCH/RFC 05/16] kernel/compat: convert to COMPAT_SYSCALL_DEFINE Heiko Carstens
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2014-03-06 15:51 UTC (permalink / raw)
  To: Al Viro, H. Peter Anvin, Ingo Molnar, Thomas Gleixner
  Cc: linux-arch, Martin Schwidefsky, Heiko Carstens

The preadv64/pwrite64 have been implemented for the x32 ABI, in order
to allow passing 64 bit arguments from user space without splitting
them into two 32 bit parameters, like it would be necessary for usual
compat tasks.
Howevert these two system calls are only being used for the x32 ABI,
so add __ARCH_WANT_COMPAT defines for these two compat syscalls and
make these two only visible for x86.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 arch/x86/include/asm/unistd.h |  2 ++
 fs/read_write.c               | 36 ++++++++++++++++++++++++++++--------
 include/linux/compat.h        | 13 +++++++++++++
 3 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/arch/x86/include/asm/unistd.h b/arch/x86/include/asm/unistd.h
index f4b5795d7e34..3f556c6a0157 100644
--- a/arch/x86/include/asm/unistd.h
+++ b/arch/x86/include/asm/unistd.h
@@ -24,6 +24,8 @@
 #  include <asm/unistd_64_x32.h>
 #  define __ARCH_WANT_COMPAT_SYS_TIME
 #  define __ARCH_WANT_COMPAT_SYS_GETDENTS64
+#  define __ARCH_WANT_COMPAT_SYS_PREADV64
+#  define __ARCH_WANT_COMPAT_SYS_PWRITEV64
 
 # endif
 
diff --git a/fs/read_write.c b/fs/read_write.c
index edc5746a902a..72c09b4a01a4 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -982,9 +982,9 @@ COMPAT_SYSCALL_DEFINE3(readv, compat_ulong_t, fd,
 	return ret;
 }
 
-COMPAT_SYSCALL_DEFINE4(preadv64, unsigned long, fd,
-		const struct compat_iovec __user *,vec,
-		unsigned long, vlen, loff_t, pos)
+static long __compat_sys_preadv64(unsigned long fd,
+				  const struct compat_iovec __user *vec,
+				  unsigned long vlen, loff_t pos)
 {
 	struct fd f;
 	ssize_t ret;
@@ -1001,12 +1001,22 @@ COMPAT_SYSCALL_DEFINE4(preadv64, unsigned long, fd,
 	return ret;
 }
 
+#ifdef __ARCH_WANT_COMPAT_SYS_PREADV64
+COMPAT_SYSCALL_DEFINE4(preadv64, unsigned long, fd,
+		const struct compat_iovec __user *,vec,
+		unsigned long, vlen, loff_t, pos)
+{
+	return __compat_sys_preadv64(fd, vec, vlen, pos);
+}
+#endif
+
 COMPAT_SYSCALL_DEFINE5(preadv, compat_ulong_t, fd,
 		const struct compat_iovec __user *,vec,
 		compat_ulong_t, vlen, u32, pos_low, u32, pos_high)
 {
 	loff_t pos = ((loff_t)pos_high << 32) | pos_low;
-	return compat_sys_preadv64(fd, vec, vlen, pos);
+
+	return __compat_sys_preadv64(fd, vec, vlen, pos);
 }
 
 static size_t compat_writev(struct file *file,
@@ -1049,9 +1059,9 @@ COMPAT_SYSCALL_DEFINE3(writev, compat_ulong_t, fd,
 	return ret;
 }
 
-COMPAT_SYSCALL_DEFINE4(pwritev64, unsigned long, fd,
-		const struct compat_iovec __user *,vec,
-		unsigned long, vlen, loff_t, pos)
+static long __compat_sys_pwritev64(unsigned long fd,
+				   const struct compat_iovec __user *vec,
+				   unsigned long vlen, loff_t pos)
 {
 	struct fd f;
 	ssize_t ret;
@@ -1068,12 +1078,22 @@ COMPAT_SYSCALL_DEFINE4(pwritev64, unsigned long, fd,
 	return ret;
 }
 
+#ifdef __ARCH_WANT_COMPAT_SYS_PWRITEV64
+COMPAT_SYSCALL_DEFINE4(pwritev64, unsigned long, fd,
+		const struct compat_iovec __user *,vec,
+		unsigned long, vlen, loff_t, pos)
+{
+	return __compat_sys_pwritev64(fd, vec, vlen, pos);
+}
+#endif
+
 COMPAT_SYSCALL_DEFINE5(pwritev, compat_ulong_t, fd,
 		const struct compat_iovec __user *,vec,
 		compat_ulong_t, vlen, u32, pos_low, u32, pos_high)
 {
 	loff_t pos = ((loff_t)pos_high << 32) | pos_low;
-	return compat_sys_pwritev64(fd, vec, vlen, pos);
+
+	return __compat_sys_pwritev64(fd, vec, vlen, pos);
 }
 #endif
 
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 179b1da9e19f..1c457428ec0a 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -340,6 +340,19 @@ asmlinkage ssize_t compat_sys_preadv(compat_ulong_t fd,
 asmlinkage ssize_t compat_sys_pwritev(compat_ulong_t fd,
 		const struct compat_iovec __user *vec,
 		compat_ulong_t vlen, u32 pos_low, u32 pos_high);
+
+#ifdef __ARCH_WANT_COMPAT_SYS_PREADV64
+asmlinkage long compat_sys_preadv64(unsigned long fd,
+		const struct compat_iovec __user *vec,
+		unsigned long vlen, loff_t pos);
+#endif
+
+#ifdef __ARCH_WANT_COMPAT_SYS_PWRITEV64
+asmlinkage long compat_sys_pwritev64(unsigned long fd,
+		const struct compat_iovec __user *vec,
+		unsigned long vlen, loff_t pos);
+#endif
+
 asmlinkage long compat_sys_lseek(unsigned int, compat_off_t, unsigned int);
 
 asmlinkage long compat_sys_execve(const char __user *filename, const compat_uptr_t __user *argv,
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH/RFC 05/16] kernel/compat: convert to COMPAT_SYSCALL_DEFINE
  2014-03-06 15:51 [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE Heiko Carstens
                   ` (3 preceding siblings ...)
  2014-03-06 15:51 ` [PATCH/RFC 04/16] fs/compat: optional preadv64/pwrite64 compat system calls Heiko Carstens
@ 2014-03-06 15:51 ` Heiko Carstens
  2014-03-06 15:51 ` [PATCH/RFC 06/16] net/compat: " Heiko Carstens
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2014-03-06 15:51 UTC (permalink / raw)
  To: Al Viro, H. Peter Anvin, Ingo Molnar, Thomas Gleixner
  Cc: linux-arch, Martin Schwidefsky, Heiko Carstens

Convert all compat system call functions where all parameter types
have a size of four or less than four bytes, or are pointer types
to COMPAT_SYSCALL_DEFINE.
The implicit casts within COMPAT_SYSCALL_DEFINE will perform proper
zero and sign extension to 64 bit of all parameters if needed.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 kernel/compat.c | 90 ++++++++++++++++++++++++++++-----------------------------
 kernel/ptrace.c |  4 +--
 2 files changed, 47 insertions(+), 47 deletions(-)

diff --git a/kernel/compat.c b/kernel/compat.c
index 0a09e481b70b..2622011a44c9 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -110,8 +110,8 @@ static int compat_put_timex(struct compat_timex __user *utp, struct timex *txc)
 	return 0;
 }
 
-asmlinkage long compat_sys_gettimeofday(struct compat_timeval __user *tv,
-		struct timezone __user *tz)
+COMPAT_SYSCALL_DEFINE2(gettimeofday, struct compat_timeval __user *, tv,
+		       struct timezone __user *, tz)
 {
 	if (tv) {
 		struct timeval ktv;
@@ -127,8 +127,8 @@ asmlinkage long compat_sys_gettimeofday(struct compat_timeval __user *tv,
 	return 0;
 }
 
-asmlinkage long compat_sys_settimeofday(struct compat_timeval __user *tv,
-		struct timezone __user *tz)
+COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval __user *, tv,
+		       struct timezone __user *, tz)
 {
 	struct timespec kts;
 	struct timezone ktz;
@@ -236,8 +236,8 @@ static long compat_nanosleep_restart(struct restart_block *restart)
 	return ret;
 }
 
-asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
-				     struct compat_timespec __user *rmtp)
+COMPAT_SYSCALL_DEFINE2(nanosleep, struct compat_timespec __user *, rqtp,
+		       struct compat_timespec __user *, rmtp)
 {
 	struct timespec tu, rmt;
 	mm_segment_t oldfs;
@@ -328,7 +328,7 @@ static compat_clock_t clock_t_to_compat_clock_t(clock_t x)
 	return compat_jiffies_to_clock_t(clock_t_to_jiffies(x));
 }
 
-asmlinkage long compat_sys_times(struct compat_tms __user *tbuf)
+COMPAT_SYSCALL_DEFINE1(times, struct compat_tms __user *, tbuf)
 {
 	if (tbuf) {
 		struct tms tms;
@@ -354,7 +354,7 @@ asmlinkage long compat_sys_times(struct compat_tms __user *tbuf)
  * types that can be passed to put_user()/get_user().
  */
 
-asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
+COMPAT_SYSCALL_DEFINE1(sigpending, compat_old_sigset_t __user *, set)
 {
 	old_sigset_t s;
 	long ret;
@@ -424,8 +424,8 @@ COMPAT_SYSCALL_DEFINE3(sigprocmask, int, how,
 
 #endif
 
-asmlinkage long compat_sys_setrlimit(unsigned int resource,
-		struct compat_rlimit __user *rlim)
+COMPAT_SYSCALL_DEFINE2(setrlimit, unsigned int, resource,
+		       struct compat_rlimit __user *, rlim)
 {
 	struct rlimit r;
 
@@ -443,8 +443,8 @@ asmlinkage long compat_sys_setrlimit(unsigned int resource,
 
 #ifdef COMPAT_RLIM_OLD_INFINITY
 
-asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
-		struct compat_rlimit __user *rlim)
+COMPAT_SYSCALL_DEFINE2(old_getrlimit, unsigned int, resource,
+		       struct compat_rlimit __user *, rlim)
 {
 	struct rlimit r;
 	int ret;
@@ -470,8 +470,8 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
 
 #endif
 
-asmlinkage long compat_sys_getrlimit(unsigned int resource,
-		struct compat_rlimit __user *rlim)
+COMPAT_SYSCALL_DEFINE2(getrlimit, unsigned int, resource,
+		       struct compat_rlimit __user *, rlim)
 {
 	struct rlimit r;
 	int ret;
@@ -596,9 +596,9 @@ static int compat_get_user_cpu_mask(compat_ulong_t __user *user_mask_ptr,
 	return compat_get_bitmap(k, user_mask_ptr, len * 8);
 }
 
-asmlinkage long compat_sys_sched_setaffinity(compat_pid_t pid,
-					     unsigned int len,
-					     compat_ulong_t __user *user_mask_ptr)
+COMPAT_SYSCALL_DEFINE3(sched_setaffinity, compat_pid_t, pid,
+		       unsigned int, len,
+		       compat_ulong_t __user *, user_mask_ptr)
 {
 	cpumask_var_t new_mask;
 	int retval;
@@ -616,8 +616,8 @@ out:
 	return retval;
 }
 
-asmlinkage long compat_sys_sched_getaffinity(compat_pid_t pid, unsigned int len,
-					     compat_ulong_t __user *user_mask_ptr)
+COMPAT_SYSCALL_DEFINE3(sched_getaffinity, compat_pid_t,  pid, unsigned int, len,
+		       compat_ulong_t __user *, user_mask_ptr)
 {
 	int ret;
 	cpumask_var_t mask;
@@ -662,9 +662,9 @@ int put_compat_itimerspec(struct compat_itimerspec __user *dst,
 	return 0;
 }
 
-long compat_sys_timer_create(clockid_t which_clock,
-			struct compat_sigevent __user *timer_event_spec,
-			timer_t __user *created_timer_id)
+COMPAT_SYSCALL_DEFINE3(timer_create, clockid_t, which_clock,
+		       struct compat_sigevent __user *, timer_event_spec,
+		       timer_t __user *, created_timer_id)
 {
 	struct sigevent __user *event = NULL;
 
@@ -680,9 +680,9 @@ long compat_sys_timer_create(clockid_t which_clock,
 	return sys_timer_create(which_clock, event, created_timer_id);
 }
 
-long compat_sys_timer_settime(timer_t timer_id, int flags,
-			  struct compat_itimerspec __user *new,
-			  struct compat_itimerspec __user *old)
+COMPAT_SYSCALL_DEFINE4(timer_settime, timer_t, timer_id, int, flags,
+		       struct compat_itimerspec __user *, new,
+		       struct compat_itimerspec __user *, old)
 {
 	long err;
 	mm_segment_t oldfs;
@@ -703,8 +703,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
 	return err;
 }
 
-long compat_sys_timer_gettime(timer_t timer_id,
-		struct compat_itimerspec __user *setting)
+COMPAT_SYSCALL_DEFINE2(timer_gettime, timer_t, timer_id,
+		       struct compat_itimerspec __user *, setting)
 {
 	long err;
 	mm_segment_t oldfs;
@@ -720,8 +720,8 @@ long compat_sys_timer_gettime(timer_t timer_id,
 	return err;
 }
 
-long compat_sys_clock_settime(clockid_t which_clock,
-		struct compat_timespec __user *tp)
+COMPAT_SYSCALL_DEFINE2(clock_settime, clockid_t, which_clock,
+		       struct compat_timespec __user *, tp)
 {
 	long err;
 	mm_segment_t oldfs;
@@ -737,8 +737,8 @@ long compat_sys_clock_settime(clockid_t which_clock,
 	return err;
 }
 
-long compat_sys_clock_gettime(clockid_t which_clock,
-		struct compat_timespec __user *tp)
+COMPAT_SYSCALL_DEFINE2(clock_gettime, clockid_t, which_clock,
+		       struct compat_timespec __user *, tp)
 {
 	long err;
 	mm_segment_t oldfs;
@@ -754,8 +754,8 @@ long compat_sys_clock_gettime(clockid_t which_clock,
 	return err;
 }
 
-long compat_sys_clock_adjtime(clockid_t which_clock,
-		struct compat_timex __user *utp)
+COMPAT_SYSCALL_DEFINE2(clock_adjtime, clockid_t, which_clock,
+		       struct compat_timex __user *, utp)
 {
 	struct timex txc;
 	mm_segment_t oldfs;
@@ -777,8 +777,8 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
 	return ret;
 }
 
-long compat_sys_clock_getres(clockid_t which_clock,
-		struct compat_timespec __user *tp)
+COMPAT_SYSCALL_DEFINE2(clock_getres, clockid_t, which_clock,
+		       struct compat_timespec __user *, tp)
 {
 	long err;
 	mm_segment_t oldfs;
@@ -818,9 +818,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
 	return err;
 }
 
-long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
-			    struct compat_timespec __user *rqtp,
-			    struct compat_timespec __user *rmtp)
+COMPAT_SYSCALL_DEFINE4(clock_nanosleep, clockid_t, which_clock, int, flags,
+		       struct compat_timespec __user *, rqtp,
+		       struct compat_timespec __user *, rmtp)
 {
 	long err;
 	mm_segment_t oldfs;
@@ -1010,7 +1010,7 @@ COMPAT_SYSCALL_DEFINE4(rt_sigtimedwait, compat_sigset_t __user *, uthese,
 
 /* compat_time_t is a 32 bit "long" and needs to get converted. */
 
-asmlinkage long compat_sys_time(compat_time_t __user * tloc)
+COMPAT_SYSCALL_DEFINE1(time, compat_time_t __user *, tloc)
 {
 	compat_time_t i;
 	struct timeval tv;
@@ -1026,7 +1026,7 @@ asmlinkage long compat_sys_time(compat_time_t __user * tloc)
 	return i;
 }
 
-asmlinkage long compat_sys_stime(compat_time_t __user *tptr)
+COMPAT_SYSCALL_DEFINE1(stime, compat_time_t __user *, tptr)
 {
 	struct timespec tv;
 	int err;
@@ -1046,7 +1046,7 @@ asmlinkage long compat_sys_stime(compat_time_t __user *tptr)
 
 #endif /* __ARCH_WANT_COMPAT_SYS_TIME */
 
-asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp)
+COMPAT_SYSCALL_DEFINE1(adjtimex, struct compat_timex __user *, utp)
 {
 	struct timex txc;
 	int err, ret;
@@ -1085,10 +1085,10 @@ asmlinkage long compat_sys_move_pages(pid_t pid, unsigned long nr_pages,
 	return sys_move_pages(pid, nr_pages, pages, nodes, status, flags);
 }
 
-asmlinkage long compat_sys_migrate_pages(compat_pid_t pid,
-			compat_ulong_t maxnode,
-			const compat_ulong_t __user *old_nodes,
-			const compat_ulong_t __user *new_nodes)
+COMPAT_SYSCALL_DEFINE4(migrate_pages, compat_pid_t, pid,
+		       compat_ulong_t, maxnode,
+		       const compat_ulong_t __user *, old_nodes,
+		       const compat_ulong_t __user *, new_nodes)
 {
 	unsigned long __user *old = NULL;
 	unsigned long __user *new = NULL;
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 1f4bcb3cc21c..adf98622cb32 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -1180,8 +1180,8 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
 	return ret;
 }
 
-asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
-				  compat_long_t addr, compat_long_t data)
+COMPAT_SYSCALL_DEFINE4(ptrace, compat_long_t, request, compat_long_t, pid,
+		       compat_long_t, addr, compat_long_t, data)
 {
 	struct task_struct *child;
 	long ret;
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH/RFC 06/16] net/compat: convert to COMPAT_SYSCALL_DEFINE
  2014-03-06 15:51 [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE Heiko Carstens
                   ` (4 preceding siblings ...)
  2014-03-06 15:51 ` [PATCH/RFC 05/16] kernel/compat: convert to COMPAT_SYSCALL_DEFINE Heiko Carstens
@ 2014-03-06 15:51 ` Heiko Carstens
  2014-03-06 15:51 ` [PATCH/RFC 07/16] mm/compat: " Heiko Carstens
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2014-03-06 15:51 UTC (permalink / raw)
  To: Al Viro, H. Peter Anvin, Ingo Molnar, Thomas Gleixner
  Cc: linux-arch, Martin Schwidefsky, Heiko Carstens

Convert all compat system call functions where all parameter types
have a size of four or less than four bytes, or are pointer types
to COMPAT_SYSCALL_DEFINE.
The implicit casts within COMPAT_SYSCALL_DEFINE will perform proper
zero and sign extension to 64 bit of all parameters if needed.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 net/compat.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/net/compat.c b/net/compat.c
index f50161fb812e..706b78be9a23 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -384,8 +384,8 @@ static int compat_sock_setsockopt(struct socket *sock, int level, int optname,
 	return sock_setsockopt(sock, level, optname, optval, optlen);
 }
 
-asmlinkage long compat_sys_setsockopt(int fd, int level, int optname,
-				char __user *optval, unsigned int optlen)
+COMPAT_SYSCALL_DEFINE5(setsockopt, int, fd, int, level, int, optname,
+		       char __user *, optval, unsigned int, optlen)
 {
 	int err;
 	struct socket *sock = sockfd_lookup(fd, &err);
@@ -504,8 +504,8 @@ int compat_sock_get_timestampns(struct sock *sk, struct timespec __user *usersta
 }
 EXPORT_SYMBOL(compat_sock_get_timestampns);
 
-asmlinkage long compat_sys_getsockopt(int fd, int level, int optname,
-				char __user *optval, int __user *optlen)
+COMPAT_SYSCALL_DEFINE5(getsockopt, int, fd, int, level, int, optname,
+		       char __user *, optval, int __user *, optlen)
 {
 	int err;
 	struct socket *sock = sockfd_lookup(fd, &err);
@@ -735,15 +735,15 @@ static unsigned char nas[21] = {
 };
 #undef AL
 
-asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg, unsigned int flags)
+COMPAT_SYSCALL_DEFINE3(sendmsg, int, fd, struct compat_msghdr __user *, msg, unsigned int, flags)
 {
 	if (flags & MSG_CMSG_COMPAT)
 		return -EINVAL;
 	return __sys_sendmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT);
 }
 
-asmlinkage long compat_sys_sendmmsg(int fd, struct compat_mmsghdr __user *mmsg,
-				    unsigned int vlen, unsigned int flags)
+COMPAT_SYSCALL_DEFINE4(sendmmsg, int, fd, struct compat_mmsghdr __user *, mmsg,
+		       unsigned int, vlen, unsigned int, flags)
 {
 	if (flags & MSG_CMSG_COMPAT)
 		return -EINVAL;
@@ -751,7 +751,7 @@ asmlinkage long compat_sys_sendmmsg(int fd, struct compat_mmsghdr __user *mmsg,
 			      flags | MSG_CMSG_COMPAT);
 }
 
-asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg, unsigned int flags)
+COMPAT_SYSCALL_DEFINE3(recvmsg, int, fd, struct compat_msghdr __user *, msg, unsigned int, flags)
 {
 	if (flags & MSG_CMSG_COMPAT)
 		return -EINVAL;
@@ -770,9 +770,9 @@ asmlinkage long compat_sys_recvfrom(int fd, void __user *buf, size_t len,
 	return sys_recvfrom(fd, buf, len, flags | MSG_CMSG_COMPAT, addr, addrlen);
 }
 
-asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
-				    unsigned int vlen, unsigned int flags,
-				    struct compat_timespec __user *timeout)
+COMPAT_SYSCALL_DEFINE5(recvmmsg, int, fd, struct compat_mmsghdr __user *, mmsg,
+		       unsigned int, vlen, unsigned int, flags,
+		       struct compat_timespec __user *, timeout)
 {
 	int datagrams;
 	struct timespec ktspec;
@@ -795,7 +795,7 @@ asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
 	return datagrams;
 }
 
-asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
+COMPAT_SYSCALL_DEFINE2(socketcall, int, call, u32 __user *, args)
 {
 	int ret;
 	u32 a[6];
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH/RFC 07/16] mm/compat: convert to COMPAT_SYSCALL_DEFINE
  2014-03-06 15:51 [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE Heiko Carstens
                   ` (5 preceding siblings ...)
  2014-03-06 15:51 ` [PATCH/RFC 06/16] net/compat: " Heiko Carstens
@ 2014-03-06 15:51 ` Heiko Carstens
  2014-03-06 15:51 ` [PATCH/RFC 08/16] security/compat: " Heiko Carstens
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2014-03-06 15:51 UTC (permalink / raw)
  To: Al Viro, H. Peter Anvin, Ingo Molnar, Thomas Gleixner
  Cc: linux-arch, Martin Schwidefsky, Heiko Carstens

Convert all compat system call functions where all parameter types
have a size of four or less than four bytes, or are pointer types
to COMPAT_SYSCALL_DEFINE.
The implicit casts within COMPAT_SYSCALL_DEFINE will perform proper
zero and sign extension to 64 bit of all parameters if needed.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 mm/mempolicy.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index ae3c8f3595d4..eeb2e3d2c962 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1556,10 +1556,10 @@ SYSCALL_DEFINE5(get_mempolicy, int __user *, policy,
 
 #ifdef CONFIG_COMPAT
 
-asmlinkage long compat_sys_get_mempolicy(int __user *policy,
-				     compat_ulong_t __user *nmask,
-				     compat_ulong_t maxnode,
-				     compat_ulong_t addr, compat_ulong_t flags)
+COMPAT_SYSCALL_DEFINE5(get_mempolicy, int __user *, policy,
+		       compat_ulong_t __user *, nmask,
+		       compat_ulong_t, maxnode,
+		       compat_ulong_t, addr, compat_ulong_t, flags)
 {
 	long err;
 	unsigned long __user *nm = NULL;
@@ -1586,8 +1586,8 @@ asmlinkage long compat_sys_get_mempolicy(int __user *policy,
 	return err;
 }
 
-asmlinkage long compat_sys_set_mempolicy(int mode, compat_ulong_t __user *nmask,
-				     compat_ulong_t maxnode)
+COMPAT_SYSCALL_DEFINE3(set_mempolicy, int, mode, compat_ulong_t __user *, nmask,
+		       compat_ulong_t, maxnode)
 {
 	long err = 0;
 	unsigned long __user *nm = NULL;
@@ -1609,9 +1609,9 @@ asmlinkage long compat_sys_set_mempolicy(int mode, compat_ulong_t __user *nmask,
 	return sys_set_mempolicy(mode, nm, nr_bits+1);
 }
 
-asmlinkage long compat_sys_mbind(compat_ulong_t start, compat_ulong_t len,
-			     compat_ulong_t mode, compat_ulong_t __user *nmask,
-			     compat_ulong_t maxnode, compat_ulong_t flags)
+COMPAT_SYSCALL_DEFINE6(mbind, compat_ulong_t, start, compat_ulong_t, len,
+		       compat_ulong_t, mode, compat_ulong_t __user *, nmask,
+		       compat_ulong_t, maxnode, compat_ulong_t, flags)
 {
 	long err = 0;
 	unsigned long __user *nm = NULL;
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH/RFC 08/16] security/compat: convert to COMPAT_SYSCALL_DEFINE
  2014-03-06 15:51 [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE Heiko Carstens
                   ` (6 preceding siblings ...)
  2014-03-06 15:51 ` [PATCH/RFC 07/16] mm/compat: " Heiko Carstens
@ 2014-03-06 15:51 ` Heiko Carstens
  2014-03-06 15:51 ` [PATCH/RFC 09/16] fs/compat: " Heiko Carstens
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2014-03-06 15:51 UTC (permalink / raw)
  To: Al Viro, H. Peter Anvin, Ingo Molnar, Thomas Gleixner
  Cc: linux-arch, Martin Schwidefsky, Heiko Carstens

Convert all compat system call functions where all parameter types
have a size of four or less than four bytes, or are pointer types
to COMPAT_SYSCALL_DEFINE.
The implicit casts within COMPAT_SYSCALL_DEFINE will perform proper
zero and sign extension to 64 bit of all parameters if needed.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 security/keys/compat.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/security/keys/compat.c b/security/keys/compat.c
index bbd32c729dbb..347896548ad3 100644
--- a/security/keys/compat.c
+++ b/security/keys/compat.c
@@ -65,8 +65,8 @@ no_payload:
  * taking a 32-bit syscall are zero.  If you can, you should call sys_keyctl()
  * directly.
  */
-asmlinkage long compat_sys_keyctl(u32 option,
-				  u32 arg2, u32 arg3, u32 arg4, u32 arg5)
+COMPAT_SYSCALL_DEFINE5(keyctl, u32, option,
+		       u32, arg2, u32, arg3, u32, arg4, u32, arg5)
 {
 	switch (option) {
 	case KEYCTL_GET_KEYRING_ID:
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH/RFC 09/16] fs/compat: convert to COMPAT_SYSCALL_DEFINE
  2014-03-06 15:51 [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE Heiko Carstens
                   ` (7 preceding siblings ...)
  2014-03-06 15:51 ` [PATCH/RFC 08/16] security/compat: " Heiko Carstens
@ 2014-03-06 15:51 ` Heiko Carstens
  2014-03-06 15:51 ` [PATCH/RFC 10/16] ipc/compat: " Heiko Carstens
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2014-03-06 15:51 UTC (permalink / raw)
  To: Al Viro, H. Peter Anvin, Ingo Molnar, Thomas Gleixner
  Cc: linux-arch, Martin Schwidefsky, Heiko Carstens

Convert all compat system call functions where all parameter types
have a size of four or less than four bytes, or are pointer types
to COMPAT_SYSCALL_DEFINE.
The implicit casts within COMPAT_SYSCALL_DEFINE will perform proper
zero and sign extension to 64 bit of all parameters if needed.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 fs/compat.c | 73 ++++++++++++++++++++++++++++++-------------------------------
 fs/exec.c   |  6 ++---
 2 files changed, 39 insertions(+), 40 deletions(-)

diff --git a/fs/compat.c b/fs/compat.c
index 0095a6978eef..6d8312b7a51d 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -72,8 +72,8 @@ int compat_printk(const char *fmt, ...)
  * Not all architectures have sys_utime, so implement this in terms
  * of sys_utimes.
  */
-asmlinkage long compat_sys_utime(const char __user *filename,
-				 struct compat_utimbuf __user *t)
+COMPAT_SYSCALL_DEFINE2(utime, const char __user *, filename,
+		       struct compat_utimbuf __user *, t)
 {
 	struct timespec tv[2];
 
@@ -87,7 +87,7 @@ asmlinkage long compat_sys_utime(const char __user *filename,
 	return do_utimes(AT_FDCWD, filename, t ? tv : NULL, 0);
 }
 
-asmlinkage long compat_sys_utimensat(unsigned int dfd, const char __user *filename, struct compat_timespec __user *t, int flags)
+COMPAT_SYSCALL_DEFINE4(utimensat, unsigned int, dfd, const char __user *, filename, struct compat_timespec __user *, t, int, flags)
 {
 	struct timespec tv[2];
 
@@ -102,7 +102,7 @@ asmlinkage long compat_sys_utimensat(unsigned int dfd, const char __user *filena
 	return do_utimes(dfd, filename, t ? tv : NULL, flags);
 }
 
-asmlinkage long compat_sys_futimesat(unsigned int dfd, const char __user *filename, struct compat_timeval __user *t)
+COMPAT_SYSCALL_DEFINE3(futimesat, unsigned int, dfd, const char __user *, filename, struct compat_timeval __user *, t)
 {
 	struct timespec tv[2];
 
@@ -121,7 +121,7 @@ asmlinkage long compat_sys_futimesat(unsigned int dfd, const char __user *filena
 	return do_utimes(dfd, filename, t ? tv : NULL, 0);
 }
 
-asmlinkage long compat_sys_utimes(const char __user *filename, struct compat_timeval __user *t)
+COMPAT_SYSCALL_DEFINE2(utimes, const char __user *, filename, struct compat_timeval __user *, t)
 {
 	return compat_sys_futimesat(AT_FDCWD, filename, t);
 }
@@ -159,8 +159,8 @@ static int cp_compat_stat(struct kstat *stat, struct compat_stat __user *ubuf)
 	return copy_to_user(ubuf, &tmp, sizeof(tmp)) ? -EFAULT : 0;
 }
 
-asmlinkage long compat_sys_newstat(const char __user * filename,
-		struct compat_stat __user *statbuf)
+COMPAT_SYSCALL_DEFINE2(newstat, const char __user *, filename,
+		       struct compat_stat __user *, statbuf)
 {
 	struct kstat stat;
 	int error;
@@ -171,8 +171,8 @@ asmlinkage long compat_sys_newstat(const char __user * filename,
 	return cp_compat_stat(&stat, statbuf);
 }
 
-asmlinkage long compat_sys_newlstat(const char __user * filename,
-		struct compat_stat __user *statbuf)
+COMPAT_SYSCALL_DEFINE2(newlstat, const char __user *, filename,
+		       struct compat_stat __user *, statbuf)
 {
 	struct kstat stat;
 	int error;
@@ -184,9 +184,9 @@ asmlinkage long compat_sys_newlstat(const char __user * filename,
 }
 
 #ifndef __ARCH_WANT_STAT64
-asmlinkage long compat_sys_newfstatat(unsigned int dfd,
-		const char __user *filename,
-		struct compat_stat __user *statbuf, int flag)
+COMPAT_SYSCALL_DEFINE4(newfstatat, unsigned int, dfd,
+		       const char __user *, filename,
+		       struct compat_stat __user *, statbuf, int, flag)
 {
 	struct kstat stat;
 	int error;
@@ -198,8 +198,8 @@ asmlinkage long compat_sys_newfstatat(unsigned int dfd,
 }
 #endif
 
-asmlinkage long compat_sys_newfstat(unsigned int fd,
-		struct compat_stat __user * statbuf)
+COMPAT_SYSCALL_DEFINE2(newfstat, unsigned int, fd,
+		       struct compat_stat __user *, statbuf)
 {
 	struct kstat stat;
 	int error = vfs_fstat(fd, &stat);
@@ -247,7 +247,7 @@ static int put_compat_statfs(struct compat_statfs __user *ubuf, struct kstatfs *
  * The following statfs calls are copies of code from fs/statfs.c and
  * should be checked against those from time to time
  */
-asmlinkage long compat_sys_statfs(const char __user *pathname, struct compat_statfs __user *buf)
+COMPAT_SYSCALL_DEFINE2(statfs, const char __user *, pathname, struct compat_statfs __user *, buf)
 {
 	struct kstatfs tmp;
 	int error = user_statfs(pathname, &tmp);
@@ -256,7 +256,7 @@ asmlinkage long compat_sys_statfs(const char __user *pathname, struct compat_sta
 	return error;
 }
 
-asmlinkage long compat_sys_fstatfs(unsigned int fd, struct compat_statfs __user *buf)
+COMPAT_SYSCALL_DEFINE2(fstatfs, unsigned int, fd, struct compat_statfs __user *, buf)
 {
 	struct kstatfs tmp;
 	int error = fd_statfs(fd, &tmp);
@@ -298,7 +298,7 @@ static int put_compat_statfs64(struct compat_statfs64 __user *ubuf, struct kstat
 	return 0;
 }
 
-asmlinkage long compat_sys_statfs64(const char __user *pathname, compat_size_t sz, struct compat_statfs64 __user *buf)
+COMPAT_SYSCALL_DEFINE3(statfs64, const char __user *, pathname, compat_size_t, sz, struct compat_statfs64 __user *, buf)
 {
 	struct kstatfs tmp;
 	int error;
@@ -312,7 +312,7 @@ asmlinkage long compat_sys_statfs64(const char __user *pathname, compat_size_t s
 	return error;
 }
 
-asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz, struct compat_statfs64 __user *buf)
+COMPAT_SYSCALL_DEFINE3(fstatfs64, unsigned int, fd, compat_size_t, sz, struct compat_statfs64 __user *, buf)
 {
 	struct kstatfs tmp;
 	int error;
@@ -331,7 +331,7 @@ asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz, struct c
  * Given how simple this syscall is that apporach is more maintainable
  * than the various conversion hacks.
  */
-asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u)
+COMPAT_SYSCALL_DEFINE2(ustat, unsigned, dev, struct compat_ustat __user *, u)
 {
 	struct compat_ustat tmp;
 	struct kstatfs sbuf;
@@ -476,8 +476,7 @@ asmlinkage long compat_sys_fcntl(unsigned int fd, unsigned int cmd,
 	return compat_sys_fcntl64(fd, cmd, arg);
 }
 
-asmlinkage long
-compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
+COMPAT_SYSCALL_DEFINE2(io_setup, unsigned, nr_reqs, u32 __user *, ctx32p)
 {
 	long ret;
 	aio_context_t ctx64;
@@ -869,8 +868,8 @@ efault:
 	return -EFAULT;
 }
 
-asmlinkage long compat_sys_old_readdir(unsigned int fd,
-	struct compat_old_linux_dirent __user *dirent, unsigned int count)
+COMPAT_SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
+		struct compat_old_linux_dirent __user *, dirent, unsigned int, count)
 {
 	int error;
 	struct fd f = fdget(fd);
@@ -948,8 +947,8 @@ efault:
 	return -EFAULT;
 }
 
-asmlinkage long compat_sys_getdents(unsigned int fd,
-		struct compat_linux_dirent __user *dirent, unsigned int count)
+COMPAT_SYSCALL_DEFINE3(getdents, unsigned int, fd,
+		struct compat_linux_dirent __user *, dirent, unsigned int, count)
 {
 	struct fd f;
 	struct compat_linux_dirent __user * lastdirent;
@@ -1033,8 +1032,8 @@ efault:
 	return -EFAULT;
 }
 
-asmlinkage long compat_sys_getdents64(unsigned int fd,
-		struct linux_dirent64 __user * dirent, unsigned int count)
+COMPAT_SYSCALL_DEFINE3(getdents64, unsigned int, fd,
+		struct linux_dirent64 __user *, dirent, unsigned int, count)
 {
 	struct fd f;
 	struct linux_dirent64 __user * lastdirent;
@@ -1287,9 +1286,9 @@ out_nofds:
 	return ret;
 }
 
-asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
-	compat_ulong_t __user *outp, compat_ulong_t __user *exp,
-	struct compat_timeval __user *tvp)
+COMPAT_SYSCALL_DEFINE5(select, int, n, compat_ulong_t __user *, inp,
+	compat_ulong_t __user *, outp, compat_ulong_t __user *, exp,
+	struct compat_timeval __user *, tvp)
 {
 	struct timespec end_time, *to = NULL;
 	struct compat_timeval tv;
@@ -1320,7 +1319,7 @@ struct compat_sel_arg_struct {
 	compat_uptr_t tvp;
 };
 
-asmlinkage long compat_sys_old_select(struct compat_sel_arg_struct __user *arg)
+COMPAT_SYSCALL_DEFINE1(old_select, struct compat_sel_arg_struct __user *, arg)
 {
 	struct compat_sel_arg_struct a;
 
@@ -1381,9 +1380,9 @@ static long do_compat_pselect(int n, compat_ulong_t __user *inp,
 	return ret;
 }
 
-asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp,
-	compat_ulong_t __user *outp, compat_ulong_t __user *exp,
-	struct compat_timespec __user *tsp, void __user *sig)
+COMPAT_SYSCALL_DEFINE6(pselect6, int, n, compat_ulong_t __user *, inp,
+	compat_ulong_t __user *, outp, compat_ulong_t __user *, exp,
+	struct compat_timespec __user *, tsp, void __user *, sig)
 {
 	compat_size_t sigsetsize = 0;
 	compat_uptr_t up = 0;
@@ -1400,9 +1399,9 @@ asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp,
 				 sigsetsize);
 }
 
-asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds,
-	unsigned int nfds, struct compat_timespec __user *tsp,
-	const compat_sigset_t __user *sigmask, compat_size_t sigsetsize)
+COMPAT_SYSCALL_DEFINE5(ppoll, struct pollfd __user *, ufds,
+	unsigned int,  nfds, struct compat_timespec __user *, tsp,
+	const compat_sigset_t __user *, sigmask, compat_size_t, sigsetsize)
 {
 	compat_sigset_t ss32;
 	sigset_t ksigmask, sigsaved;
diff --git a/fs/exec.c b/fs/exec.c
index 3d78fccdd723..4f59402fdda5 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1619,9 +1619,9 @@ SYSCALL_DEFINE3(execve,
 	return do_execve(getname(filename), argv, envp);
 }
 #ifdef CONFIG_COMPAT
-asmlinkage long compat_sys_execve(const char __user * filename,
-	const compat_uptr_t __user * argv,
-	const compat_uptr_t __user * envp)
+COMPAT_SYSCALL_DEFINE3(execve, const char __user *, filename,
+	const compat_uptr_t __user *, argv,
+	const compat_uptr_t __user *, envp)
 {
 	return compat_do_execve(getname(filename), argv, envp);
 }
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH/RFC 10/16] ipc/compat: convert to COMPAT_SYSCALL_DEFINE
  2014-03-06 15:51 [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE Heiko Carstens
                   ` (8 preceding siblings ...)
  2014-03-06 15:51 ` [PATCH/RFC 09/16] fs/compat: " Heiko Carstens
@ 2014-03-06 15:51 ` Heiko Carstens
  2014-03-06 15:51 ` [PATCH/RFC 11/16] fs/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types Heiko Carstens
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2014-03-06 15:51 UTC (permalink / raw)
  To: Al Viro, H. Peter Anvin, Ingo Molnar, Thomas Gleixner
  Cc: linux-arch, Martin Schwidefsky, Heiko Carstens

Convert all compat system call functions where all parameter types
have a size of four or less than four bytes, or are pointer types
to COMPAT_SYSCALL_DEFINE.
The implicit casts within COMPAT_SYSCALL_DEFINE will perform proper
zero and sign extension to 64 bit of all parameters if needed.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 ipc/compat.c    |  9 +++++----
 ipc/compat_mq.c | 16 ++++++++--------
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/ipc/compat.c b/ipc/compat.c
index e1f4ab65660c..98b9016cab6c 100644
--- a/ipc/compat.c
+++ b/ipc/compat.c
@@ -498,7 +498,7 @@ static inline int put_compat_msqid_ds(struct msqid64_ds *m,
 	return err;
 }
 
-long compat_sys_msgctl(int first, int second, void __user *uptr)
+COMPAT_SYSCALL_DEFINE3(msgctl, int, first, int, second, void __user *, uptr)
 {
 	int err, err2;
 	struct msqid64_ds m64;
@@ -668,7 +668,7 @@ static inline int put_compat_shm_info(struct shm_info __user *ip,
 	return err;
 }
 
-long compat_sys_shmctl(int first, int second, void __user *uptr)
+COMPAT_SYSCALL_DEFINE3(shmctl, int, first, int, second, void __user *, uptr)
 {
 	void __user *p;
 	struct shmid64_ds s64;
@@ -749,8 +749,9 @@ long compat_sys_shmctl(int first, int second, void __user *uptr)
 	return err;
 }
 
-long compat_sys_semtimedop(int semid, struct sembuf __user *tsems,
-		unsigned nsops, const struct compat_timespec __user *timeout)
+COMPAT_SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsems,
+		       unsigned, nsops,
+		       const struct compat_timespec __user *, timeout)
 {
 	struct timespec __user *ts64 = NULL;
 	if (timeout) {
diff --git a/ipc/compat_mq.c b/ipc/compat_mq.c
index 63d7c6de335b..af087fb40bf7 100644
--- a/ipc/compat_mq.c
+++ b/ipc/compat_mq.c
@@ -46,9 +46,9 @@ static inline int put_compat_mq_attr(const struct mq_attr *attr,
 		| __put_user(attr->mq_curmsgs, &uattr->mq_curmsgs);
 }
 
-asmlinkage long compat_sys_mq_open(const char __user *u_name,
-			int oflag, compat_mode_t mode,
-			struct compat_mq_attr __user *u_attr)
+COMPAT_SYSCALL_DEFINE4(mq_open, const char __user *, u_name,
+		       int, oflag, compat_mode_t, mode,
+		       struct compat_mq_attr __user *, u_attr)
 {
 	void __user *p = NULL;
 	if (u_attr && oflag & O_CREAT) {
@@ -105,8 +105,8 @@ asmlinkage ssize_t compat_sys_mq_timedreceive(mqd_t mqdes,
 			u_msg_prio, u_ts);
 }
 
-asmlinkage long compat_sys_mq_notify(mqd_t mqdes,
-			const struct compat_sigevent __user *u_notification)
+COMPAT_SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes,
+		       const struct compat_sigevent __user *, u_notification)
 {
 	struct sigevent __user *p = NULL;
 	if (u_notification) {
@@ -122,9 +122,9 @@ asmlinkage long compat_sys_mq_notify(mqd_t mqdes,
 	return sys_mq_notify(mqdes, p);
 }
 
-asmlinkage long compat_sys_mq_getsetattr(mqd_t mqdes,
-			const struct compat_mq_attr __user *u_mqstat,
-			struct compat_mq_attr __user *u_omqstat)
+COMPAT_SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes,
+		       const struct compat_mq_attr __user *, u_mqstat,
+		       struct compat_mq_attr __user *, u_omqstat)
 {
 	struct mq_attr mqstat;
 	struct mq_attr __user *p = compat_alloc_user_space(2 * sizeof(*p));
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH/RFC 11/16] fs/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types
  2014-03-06 15:51 [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE Heiko Carstens
                   ` (9 preceding siblings ...)
  2014-03-06 15:51 ` [PATCH/RFC 10/16] ipc/compat: " Heiko Carstens
@ 2014-03-06 15:51 ` Heiko Carstens
  2014-03-06 15:51 ` [PATCH/RFC 12/16] ipc/compat: " Heiko Carstens
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2014-03-06 15:51 UTC (permalink / raw)
  To: Al Viro, H. Peter Anvin, Ingo Molnar, Thomas Gleixner
  Cc: linux-arch, Martin Schwidefsky, Heiko Carstens

Some fs compat system calls have unsigned long parameters instead of
compat_ulong_t.
In order to allow the COMPAT_SYSCALL_DEFINE macro generate code that
performs proper zero and sign extension convert all 64 bit parameters
their corresponding 32 bit counterparts.

compat_sys_io_getevents() is a bit different: the non-compat version
has signed parameters for the "min_nr" and "nr" parameters while the
compat version has unsigned parameters.
So change this as well. For all practical purposes this shouldn't make
any difference (doesn't fix a real bug).
Also introduce a generic compat_aio_context_t type which can be used
everywhere.
The access_ok() check within compat_sys_io_getevents() got also removed
since the non-compat sys_io_getevents() should be able to handle
everything anyway.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 fs/compat.c            | 44 ++++++++++++++++++--------------------------
 fs/compat_ioctl.c      |  5 +++--
 include/linux/compat.h | 18 ++++++++++--------
 3 files changed, 31 insertions(+), 36 deletions(-)

diff --git a/fs/compat.c b/fs/compat.c
index 6d8312b7a51d..19252b97f0cc 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -399,8 +399,8 @@ static int put_compat_flock64(struct flock *kfl, struct compat_flock64 __user *u
 }
 #endif
 
-asmlinkage long compat_sys_fcntl64(unsigned int fd, unsigned int cmd,
-		unsigned long arg)
+COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
+		       compat_ulong_t, arg)
 {
 	mm_segment_t old_fs;
 	struct flock f;
@@ -468,8 +468,8 @@ asmlinkage long compat_sys_fcntl64(unsigned int fd, unsigned int cmd,
 	return ret;
 }
 
-asmlinkage long compat_sys_fcntl(unsigned int fd, unsigned int cmd,
-		unsigned long arg)
+COMPAT_SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd,
+		       compat_ulong_t, arg)
 {
 	if ((cmd == F_GETLK64) || (cmd == F_SETLK64) || (cmd == F_SETLKW64))
 		return -EINVAL;
@@ -495,32 +495,24 @@ COMPAT_SYSCALL_DEFINE2(io_setup, unsigned, nr_reqs, u32 __user *, ctx32p)
 	return ret;
 }
 
-asmlinkage long
-compat_sys_io_getevents(aio_context_t ctx_id,
-				 unsigned long min_nr,
-				 unsigned long nr,
-				 struct io_event __user *events,
-				 struct compat_timespec __user *timeout)
+COMPAT_SYSCALL_DEFINE5(io_getevents, compat_aio_context_t, ctx_id,
+		       compat_long_t, min_nr,
+		       compat_long_t, nr,
+		       struct io_event __user *, events,
+		       struct compat_timespec __user *, timeout)
 {
-	long ret;
 	struct timespec t;
 	struct timespec __user *ut = NULL;
 
-	ret = -EFAULT;
-	if (unlikely(!access_ok(VERIFY_WRITE, events, 
-				nr * sizeof(struct io_event))))
-		goto out;
 	if (timeout) {
 		if (get_compat_timespec(&t, timeout))
-			goto out;
+			return -EFAULT;
 
 		ut = compat_alloc_user_space(sizeof(*ut));
 		if (copy_to_user(ut, &t, sizeof(t)) )
-			goto out;
+			return -EFAULT;
 	} 
-	ret = sys_io_getevents(ctx_id, min_nr, nr, events, ut);
-out:
-	return ret;
+	return sys_io_getevents(ctx_id, min_nr, nr, events, ut);
 }
 
 /* A write operation does a read from user space and vice versa */
@@ -616,8 +608,8 @@ copy_iocb(long nr, u32 __user *ptr32, struct iocb __user * __user *ptr64)
 
 #define MAX_AIO_SUBMITS 	(PAGE_SIZE/sizeof(struct iocb *))
 
-asmlinkage long
-compat_sys_io_submit(aio_context_t ctx_id, int nr, u32 __user *iocb)
+COMPAT_SYSCALL_DEFINE3(io_submit, compat_aio_context_t, ctx_id,
+		       int, nr, u32 __user *, iocb)
 {
 	struct iocb __user * __user *iocb64; 
 	long ret;
@@ -769,10 +761,10 @@ static int do_nfs4_super_data_conv(void *raw_data)
 #define NCPFS_NAME      "ncpfs"
 #define NFS4_NAME	"nfs4"
 
-asmlinkage long compat_sys_mount(const char __user * dev_name,
-				 const char __user * dir_name,
-				 const char __user * type, unsigned long flags,
-				 const void __user * data)
+COMPAT_SYSCALL_DEFINE5(mount, const char __user *, dev_name,
+		       const char __user *, dir_name,
+		       const char __user *, type, compat_ulong_t, flags,
+		       const void __user *, data)
 {
 	char *kernel_type;
 	unsigned long data_page;
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 3881610b6438..e82289047272 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -1538,9 +1538,10 @@ static int compat_ioctl_check_table(unsigned int xcmd)
 	return ioctl_pointer[i] == xcmd;
 }
 
-asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
-				unsigned long arg)
+COMPAT_SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd,
+		       compat_ulong_t, arg32)
 {
+	unsigned long arg = arg32;
 	struct fd f = fdget(fd);
 	int error = -EBADF;
 	if (!f.file)
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 1c457428ec0a..fea8ee9afe22 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -71,6 +71,8 @@ typedef struct compat_sigaltstack {
 typedef __compat_uid32_t	compat_uid_t;
 typedef __compat_gid32_t	compat_gid_t;
 
+typedef	compat_ulong_t		compat_aio_context_t;
+
 struct compat_sel_arg_struct;
 struct rusage;
 
@@ -497,20 +499,20 @@ asmlinkage long compat_sys_statfs64(const char __user *pathname,
 asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz,
 				     struct compat_statfs64 __user *buf);
 asmlinkage long compat_sys_fcntl64(unsigned int fd, unsigned int cmd,
-				   unsigned long arg);
+				   compat_ulong_t arg);
 asmlinkage long compat_sys_fcntl(unsigned int fd, unsigned int cmd,
-				 unsigned long arg);
+				 compat_ulong_t arg);
 asmlinkage long compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p);
-asmlinkage long compat_sys_io_getevents(aio_context_t ctx_id,
-					unsigned long min_nr,
-					unsigned long nr,
+asmlinkage long compat_sys_io_getevents(compat_aio_context_t ctx_id,
+					compat_long_t min_nr,
+					compat_long_t nr,
 					struct io_event __user *events,
 					struct compat_timespec __user *timeout);
-asmlinkage long compat_sys_io_submit(aio_context_t ctx_id, int nr,
+asmlinkage long compat_sys_io_submit(compat_aio_context_t ctx_id, int nr,
 				     u32 __user *iocb);
 asmlinkage long compat_sys_mount(const char __user *dev_name,
 				 const char __user *dir_name,
-				 const char __user *type, unsigned long flags,
+				 const char __user *type, compat_ulong_t flags,
 				 const void __user *data);
 asmlinkage long compat_sys_old_readdir(unsigned int fd,
 				       struct compat_old_linux_dirent __user *,
@@ -633,7 +635,7 @@ asmlinkage long compat_sys_rt_sigqueueinfo(compat_pid_t pid, int sig,
 				struct compat_siginfo __user *uinfo);
 asmlinkage long compat_sys_sysinfo(struct compat_sysinfo __user *info);
 asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
-				 unsigned long arg);
+				 compat_ulong_t arg);
 asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, u32 val,
 		struct compat_timespec __user *utime, u32 __user *uaddr2,
 		u32 val3);
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH/RFC 12/16] ipc/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types
  2014-03-06 15:51 [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE Heiko Carstens
                   ` (10 preceding siblings ...)
  2014-03-06 15:51 ` [PATCH/RFC 11/16] fs/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types Heiko Carstens
@ 2014-03-06 15:51 ` Heiko Carstens
  2014-03-06 15:51 ` [PATCH/RFC 13/16] net/compat: " Heiko Carstens
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2014-03-06 15:51 UTC (permalink / raw)
  To: Al Viro, H. Peter Anvin, Ingo Molnar, Thomas Gleixner
  Cc: linux-arch, Martin Schwidefsky, Heiko Carstens

In order to allow the COMPAT_SYSCALL_DEFINE macro generate code that
performs proper zero and sign extension convert all 64 bit parameters
to their corresponding 32 bit compat counterparts.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 include/linux/compat.h |  4 ++--
 ipc/compat_mq.c        | 16 ++++++++--------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/include/linux/compat.h b/include/linux/compat.h
index fea8ee9afe22..f670e591aff8 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -655,11 +655,11 @@ asmlinkage long compat_sys_mq_open(const char __user *u_name,
 			struct compat_mq_attr __user *u_attr);
 asmlinkage long compat_sys_mq_timedsend(mqd_t mqdes,
 			const char __user *u_msg_ptr,
-			size_t msg_len, unsigned int msg_prio,
+			compat_size_t msg_len, unsigned int msg_prio,
 			const struct compat_timespec __user *u_abs_timeout);
 asmlinkage ssize_t compat_sys_mq_timedreceive(mqd_t mqdes,
 			char __user *u_msg_ptr,
-			size_t msg_len, unsigned int __user *u_msg_prio,
+			compat_size_t msg_len, unsigned int __user *u_msg_prio,
 			const struct compat_timespec __user *u_abs_timeout);
 asmlinkage long compat_sys_socketcall(int call, u32 __user *args);
 asmlinkage long compat_sys_sysctl(struct compat_sysctl_args __user *args);
diff --git a/ipc/compat_mq.c b/ipc/compat_mq.c
index af087fb40bf7..d58747293772 100644
--- a/ipc/compat_mq.c
+++ b/ipc/compat_mq.c
@@ -78,10 +78,10 @@ static int compat_prepare_timeout(struct timespec __user **p,
 	return 0;
 }
 
-asmlinkage long compat_sys_mq_timedsend(mqd_t mqdes,
-			const char __user *u_msg_ptr,
-			size_t msg_len, unsigned int msg_prio,
-			const struct compat_timespec __user *u_abs_timeout)
+COMPAT_SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes,
+		       const char __user *, u_msg_ptr,
+		       compat_size_t, msg_len, unsigned int, msg_prio,
+		       const struct compat_timespec __user *, u_abs_timeout)
 {
 	struct timespec __user *u_ts;
 
@@ -92,10 +92,10 @@ asmlinkage long compat_sys_mq_timedsend(mqd_t mqdes,
 			msg_prio, u_ts);
 }
 
-asmlinkage ssize_t compat_sys_mq_timedreceive(mqd_t mqdes,
-			char __user *u_msg_ptr,
-			size_t msg_len, unsigned int __user *u_msg_prio,
-			const struct compat_timespec __user *u_abs_timeout)
+COMPAT_SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes,
+		       char __user *, u_msg_ptr,
+		       compat_size_t, msg_len, unsigned int __user *, u_msg_prio,
+		       const struct compat_timespec __user *, u_abs_timeout)
 {
 	struct timespec __user *u_ts;
 	if (compat_prepare_timeout(&u_ts, u_abs_timeout))
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH/RFC 13/16] net/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types
  2014-03-06 15:51 [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE Heiko Carstens
                   ` (11 preceding siblings ...)
  2014-03-06 15:51 ` [PATCH/RFC 12/16] ipc/compat: " Heiko Carstens
@ 2014-03-06 15:51 ` Heiko Carstens
  2014-03-06 15:51 ` [PATCH/RFC 14/16] kexec/compat: " Heiko Carstens
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2014-03-06 15:51 UTC (permalink / raw)
  To: Al Viro, H. Peter Anvin, Ingo Molnar, Thomas Gleixner
  Cc: linux-arch, Martin Schwidefsky, Heiko Carstens

In order to allow the COMPAT_SYSCALL_DEFINE macro generate code that
performs proper zero and sign extension convert all 64 bit parameters
to their corresponding 32 bit compat counterparts.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 include/linux/compat.h | 4 ++--
 net/compat.c           | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/linux/compat.h b/include/linux/compat.h
index f670e591aff8..8e636211f334 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -569,9 +569,9 @@ asmlinkage long compat_sys_sendmmsg(int fd, struct compat_mmsghdr __user *mmsg,
 				    unsigned vlen, unsigned int flags);
 asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg,
 				   unsigned int flags);
-asmlinkage long compat_sys_recv(int fd, void __user *buf, size_t len,
+asmlinkage long compat_sys_recv(int fd, void __user *buf, compat_size_t len,
 				unsigned flags);
-asmlinkage long compat_sys_recvfrom(int fd, void __user *buf, size_t len,
+asmlinkage long compat_sys_recvfrom(int fd, void __user *buf, compat_size_t len,
 			    unsigned flags, struct sockaddr __user *addr,
 			    int __user *addrlen);
 asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
diff --git a/net/compat.c b/net/compat.c
index 706b78be9a23..9a76eaf63184 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -758,14 +758,14 @@ COMPAT_SYSCALL_DEFINE3(recvmsg, int, fd, struct compat_msghdr __user *, msg, uns
 	return __sys_recvmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT);
 }
 
-asmlinkage long compat_sys_recv(int fd, void __user *buf, size_t len, unsigned int flags)
+COMPAT_SYSCALL_DEFINE4(recv, int, fd, void __user *, buf, compat_size_t, len, unsigned int, flags)
 {
 	return sys_recv(fd, buf, len, flags | MSG_CMSG_COMPAT);
 }
 
-asmlinkage long compat_sys_recvfrom(int fd, void __user *buf, size_t len,
-				    unsigned int flags, struct sockaddr __user *addr,
-				    int __user *addrlen)
+COMPAT_SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, buf, compat_size_t, len,
+		       unsigned int, flags, struct sockaddr __user *, addr,
+		       int __user *, addrlen)
 {
 	return sys_recvfrom(fd, buf, len, flags | MSG_CMSG_COMPAT, addr, addrlen);
 }
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH/RFC 14/16] kexec/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types
  2014-03-06 15:51 [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE Heiko Carstens
                   ` (12 preceding siblings ...)
  2014-03-06 15:51 ` [PATCH/RFC 13/16] net/compat: " Heiko Carstens
@ 2014-03-06 15:51 ` Heiko Carstens
  2014-03-06 15:51 ` [PATCH/RFC 15/16] mm/compat: " Heiko Carstens
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2014-03-06 15:51 UTC (permalink / raw)
  To: Al Viro, H. Peter Anvin, Ingo Molnar, Thomas Gleixner
  Cc: linux-arch, Martin Schwidefsky, Heiko Carstens

In order to allow the COMPAT_SYSCALL_DEFINE macro generate code that
performs proper zero and sign extension convert all 64 bit parameters
to their corresponding 32 bit compat counterparts.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 include/linux/compat.h | 6 +++---
 include/linux/kexec.h  | 6 ------
 kernel/kexec.c         | 8 ++++----
 3 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/include/linux/compat.h b/include/linux/compat.h
index 8e636211f334..ef4834c5bcab 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -641,10 +641,10 @@ asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, u32 val,
 		u32 val3);
 asmlinkage long compat_sys_getsockopt(int fd, int level, int optname,
 				      char __user *optval, int __user *optlen);
-asmlinkage long compat_sys_kexec_load(unsigned long entry,
-				      unsigned long nr_segments,
+asmlinkage long compat_sys_kexec_load(compat_ulong_t entry,
+				      compat_ulong_t nr_segments,
 				      struct compat_kexec_segment __user *,
-				      unsigned long flags);
+				      compat_ulong_t flags);
 asmlinkage long compat_sys_mq_getsetattr(mqd_t mqdes,
 			const struct compat_mq_attr __user *u_mqstat,
 			struct compat_mq_attr __user *u_omqstat);
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 6d4066cdb5b5..a75641930049 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -127,12 +127,6 @@ extern asmlinkage long sys_kexec_load(unsigned long entry,
 					struct kexec_segment __user *segments,
 					unsigned long flags);
 extern int kernel_kexec(void);
-#ifdef CONFIG_COMPAT
-extern asmlinkage long compat_sys_kexec_load(unsigned long entry,
-				unsigned long nr_segments,
-				struct compat_kexec_segment __user *segments,
-				unsigned long flags);
-#endif
 extern struct page *kimage_alloc_control_pages(struct kimage *image,
 						unsigned int order);
 extern void crash_kexec(struct pt_regs *);
diff --git a/kernel/kexec.c b/kernel/kexec.c
index 60bafbed06ab..45601cf41bee 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -1039,10 +1039,10 @@ void __weak crash_unmap_reserved_pages(void)
 {}
 
 #ifdef CONFIG_COMPAT
-asmlinkage long compat_sys_kexec_load(unsigned long entry,
-				unsigned long nr_segments,
-				struct compat_kexec_segment __user *segments,
-				unsigned long flags)
+COMPAT_SYSCALL_DEFINE4(kexec_load, compat_ulong_t, entry,
+		       compat_ulong_t, nr_segments,
+		       struct compat_kexec_segment __user *, segments,
+		       compat_ulong_t, flags)
 {
 	struct compat_kexec_segment in;
 	struct kexec_segment out, __user *ksegments;
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH/RFC 15/16] mm/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types
  2014-03-06 15:51 [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE Heiko Carstens
                   ` (13 preceding siblings ...)
  2014-03-06 15:51 ` [PATCH/RFC 14/16] kexec/compat: " Heiko Carstens
@ 2014-03-06 15:51 ` Heiko Carstens
  2014-03-06 15:51 ` [PATCH/RFC 16/16] s390/compat: build error for large compat syscall args Heiko Carstens
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2014-03-06 15:51 UTC (permalink / raw)
  To: Al Viro, H. Peter Anvin, Ingo Molnar, Thomas Gleixner
  Cc: linux-arch, Martin Schwidefsky, Heiko Carstens

In order to allow the COMPAT_SYSCALL_DEFINE macro generate code that
performs proper zero and sign extension convert all 64 bit parameters
to their corresponding 32 bit compat counterparts.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 include/linux/compat.h | 10 +++++-----
 kernel/compat.c        | 10 +++++-----
 mm/process_vm_access.c | 26 ++++++++++++--------------
 3 files changed, 22 insertions(+), 24 deletions(-)

diff --git a/include/linux/compat.h b/include/linux/compat.h
index ef4834c5bcab..7c765624b7ef 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -469,7 +469,7 @@ asmlinkage long compat_sys_timerfd_settime(int ufd, int flags,
 asmlinkage long compat_sys_timerfd_gettime(int ufd,
 				   struct compat_itimerspec __user *otmr);
 
-asmlinkage long compat_sys_move_pages(pid_t pid, unsigned long nr_page,
+asmlinkage long compat_sys_move_pages(pid_t pid, compat_ulong_t nr_pages,
 				      __u32 __user *pages,
 				      const int __user *nodes,
 				      int __user *status,
@@ -674,12 +674,12 @@ extern void __user *compat_alloc_user_space(unsigned long len);
 
 asmlinkage ssize_t compat_sys_process_vm_readv(compat_pid_t pid,
 		const struct compat_iovec __user *lvec,
-		unsigned long liovcnt, const struct compat_iovec __user *rvec,
-		unsigned long riovcnt, unsigned long flags);
+		compat_ulong_t liovcnt, const struct compat_iovec __user *rvec,
+		compat_ulong_t riovcnt, compat_ulong_t flags);
 asmlinkage ssize_t compat_sys_process_vm_writev(compat_pid_t pid,
 		const struct compat_iovec __user *lvec,
-		unsigned long liovcnt, const struct compat_iovec __user *rvec,
-		unsigned long riovcnt, unsigned long flags);
+		compat_ulong_t liovcnt, const struct compat_iovec __user *rvec,
+		compat_ulong_t riovcnt, compat_ulong_t flags);
 
 asmlinkage long compat_sys_sendfile(int out_fd, int in_fd,
 				    compat_off_t __user *offset, compat_size_t count);
diff --git a/kernel/compat.c b/kernel/compat.c
index 2622011a44c9..488ff8c4cf48 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -1065,11 +1065,11 @@ COMPAT_SYSCALL_DEFINE1(adjtimex, struct compat_timex __user *, utp)
 }
 
 #ifdef CONFIG_NUMA
-asmlinkage long compat_sys_move_pages(pid_t pid, unsigned long nr_pages,
-		compat_uptr_t __user *pages32,
-		const int __user *nodes,
-		int __user *status,
-		int flags)
+COMPAT_SYSCALL_DEFINE6(move_pages, pid_t, pid, compat_ulong_t, nr_pages,
+		       compat_uptr_t __user *, pages32,
+		       const int __user *, nodes,
+		       int __user *, status,
+		       int, flags)
 {
 	const void __user * __user *pages;
 	int i;
diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
index fd26d0433509..3c5cf68566ec 100644
--- a/mm/process_vm_access.c
+++ b/mm/process_vm_access.c
@@ -456,25 +456,23 @@ free_iovecs:
 	return rc;
 }
 
-asmlinkage ssize_t
-compat_sys_process_vm_readv(compat_pid_t pid,
-			    const struct compat_iovec __user *lvec,
-			    unsigned long liovcnt,
-			    const struct compat_iovec __user *rvec,
-			    unsigned long riovcnt,
-			    unsigned long flags)
+COMPAT_SYSCALL_DEFINE6(process_vm_readv, compat_pid_t, pid,
+		       const struct compat_iovec __user *, lvec,
+		       compat_ulong_t, liovcnt,
+		       const struct compat_iovec __user *, rvec,
+		       compat_ulong_t, riovcnt,
+		       compat_ulong_t, flags)
 {
 	return compat_process_vm_rw(pid, lvec, liovcnt, rvec,
 				    riovcnt, flags, 0);
 }
 
-asmlinkage ssize_t
-compat_sys_process_vm_writev(compat_pid_t pid,
-			     const struct compat_iovec __user *lvec,
-			     unsigned long liovcnt,
-			     const struct compat_iovec __user *rvec,
-			     unsigned long riovcnt,
-			     unsigned long flags)
+COMPAT_SYSCALL_DEFINE6(process_vm_writev, compat_pid_t, pid,
+		       const struct compat_iovec __user *, lvec,
+		       compat_ulong_t, liovcnt,
+		       const struct compat_iovec __user *, rvec,
+		       compat_ulong_t, riovcnt,
+		       compat_ulong_t, flags)
 {
 	return compat_process_vm_rw(pid, lvec, liovcnt, rvec,
 				    riovcnt, flags, 1);
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH/RFC 16/16] s390/compat: build error for large compat syscall args
  2014-03-06 15:51 [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE Heiko Carstens
                   ` (14 preceding siblings ...)
  2014-03-06 15:51 ` [PATCH/RFC 15/16] mm/compat: " Heiko Carstens
@ 2014-03-06 15:51 ` Heiko Carstens
  2014-03-06 16:14 ` [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE Geert Uytterhoeven
  2014-03-12 19:45 ` Heiko Carstens
  17 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2014-03-06 15:51 UTC (permalink / raw)
  To: Al Viro, H. Peter Anvin, Ingo Molnar, Thomas Gleixner
  Cc: linux-arch, Martin Schwidefsky, Heiko Carstens

Enforce 32 bit types for all compat syscall argument types.

This way we can make sure that all arguments get correct sign
or zero extension. Otherwise incorrect code would be generated.

E.g. for a 'long' type the COMPAT_SYSCALL_DEFINE macro wouldn't
generate code that would cause sign extension of the passed in 32
bit user space parameter.
This can cause quite subtle bugs like e.g. the one that was fixed
with dfd948e32af2e "fs/compat: fix parameter handling for compat
readv/writev syscalls".

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 arch/s390/include/asm/compat.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/s390/include/asm/compat.h b/arch/s390/include/asm/compat.h
index 5d7e8cf83bd6..d350ed9d0fbb 100644
--- a/arch/s390/include/asm/compat.h
+++ b/arch/s390/include/asm/compat.h
@@ -8,7 +8,11 @@
 #include <linux/thread_info.h>
 
 #define __TYPE_IS_PTR(t) (!__builtin_types_compatible_p(typeof(0?(t)0:0ULL), u64))
-#define __SC_DELOUSE(t,v) (t)(__TYPE_IS_PTR(t) ? ((v) & 0x7fffffff) : (v))
+
+#define __SC_DELOUSE(t,v) ({ \
+	BUILD_BUG_ON(sizeof(t) > 4 && !__TYPE_IS_PTR(t)); \
+	(t)(__TYPE_IS_PTR(t) ? ((v) & 0x7fffffff) : (v)); \
+})
 
 #define PSW32_MASK_PER		0x40000000UL
 #define PSW32_MASK_DAT		0x04000000UL
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* Re: [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE
  2014-03-06 15:51 [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE Heiko Carstens
                   ` (15 preceding siblings ...)
  2014-03-06 15:51 ` [PATCH/RFC 16/16] s390/compat: build error for large compat syscall args Heiko Carstens
@ 2014-03-06 16:14 ` Geert Uytterhoeven
  2014-03-12 19:45 ` Heiko Carstens
  17 siblings, 0 replies; 28+ messages in thread
From: Geert Uytterhoeven @ 2014-03-06 16:14 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: Al Viro, H. Peter Anvin, Ingo Molnar, Thomas Gleixner,
	Linux-Arch, Martin Schwidefsky

On Thu, Mar 6, 2014 at 4:51 PM, Heiko Carstens
<heiko.carstens@de.ibm.com> wrote:
> FWIW, this patch series omits the whole s390 patches, since I assume
> they are not very interesting to non-s390 people ;)

"Given enough eyeballs, all bugs are shallow"

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE
  2014-03-06 15:51 [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE Heiko Carstens
                   ` (16 preceding siblings ...)
  2014-03-06 16:14 ` [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE Geert Uytterhoeven
@ 2014-03-12 19:45 ` Heiko Carstens
  2014-03-13  7:32   ` Heiko Carstens
  2014-03-17  6:02   ` Stephen Rothwell
  17 siblings, 2 replies; 28+ messages in thread
From: Heiko Carstens @ 2014-03-12 19:45 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: linux-next, Al Viro, H. Peter Anvin, Ingo Molnar,
	Thomas Gleixner, linux-arch, Martin Schwidefsky, H. Peter Anvin

Hi Stephen,

since nobody objected to the compat changes I described below, could you
please add the tree

  git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git compat

to linux-next?

Thanks,
Heiko

[full quote below]

On Thu, Mar 06, 2014 at 04:51:07PM +0100, Heiko Carstens wrote:
> Hi all,
> 
> this patch series converts all common code compat syscalls to use the new
> COMPAT_SYSCALL_DEFINE macros introduced by Al Viro.
> My main motivation is to get rid of the 1400+ line s390 specific assembler
> file which contains code for each and every compat system call to perform
> proper sign, zero and pointer conversion.
> 
> Eventually the conversion is pretty trivial, except that for a couple of
> compat syscalls argument types needed to be changed from e.g. 'long' to
> 'compat_long_t' so that the COMPAT_SYSCALL_DEFINE macro can perform
> proper sign extension from the 32 bit compat system call argument like
> it was orginally passed in from user space.
> 
> The patch series keeps the "noop" conversions (5-10) and those with type
> changes (11-15) separate.
> 
> Patches 1-4 are just additional cleanup patches.
> 
> Especially I'd like to know from somebody familiar with the x32 ABI if
> any of the type changes break x32?
> I intentionally did not touch the preadv64 and pwritev64 compat system
> calls since they have been explicitly added to allow x32 pass 64 bit
> arguments.
> However it's not obvious to me if any of my other compat system call
> changes break x32 or not.
> 
> FWIW, this patch series omits the whole s390 patches, since I assume
> they are not very interesting to non-s390 people ;)
> 
> The complete series (including the s390 only patches) is available at
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git compat
> 
> If nobody objects I'd like to have the branch integrated into linux-next
> to get some additional testing.
> 
> So, please let me know if I screwed up something! :)
> 
> Thanks,
> Heiko
> 
> Heiko Carstens (16):
>       compat: let architectures define __ARCH_WANT_COMPAT_SYS_GETDENTS64
>       compat: add COMPAT_SYSCALL_DEFINE0 macro
>       ipc/compat_sys_msgrcv: change msgtyp type from long to compat_long_t
>       fs/compat: optional preadv64/pwrite64 compat system calls
>       kernel/compat: convert to COMPAT_SYSCALL_DEFINE
>       net/compat: convert to COMPAT_SYSCALL_DEFINE
>       mm/compat: convert to COMPAT_SYSCALL_DEFINE
>       security/compat: convert to COMPAT_SYSCALL_DEFINE
>       fs/compat: convert to COMPAT_SYSCALL_DEFINE
>       ipc/compat: convert to COMPAT_SYSCALL_DEFINE
>       fs/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types
>       ipc/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types
>       net/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types
>       kexec/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types
>       mm/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types
>       s390/compat: build error for large compat syscall args
> 
> (diffstat below includes the s390 only patches)
> 
>  arch/arm64/include/asm/unistd.h   |    1 +
>  arch/mips/include/asm/unistd.h    |    1 -
>  arch/s390/include/asm/compat.h    |    6 +-
>  arch/s390/kernel/compat_linux.c   |  116 +--
>  arch/s390/kernel/compat_linux.h   |   81 +--
>  arch/s390/kernel/compat_signal.c  |    4 +-
>  arch/s390/kernel/compat_wrapper.S | 1425 -------------------------------------
>  arch/s390/kernel/compat_wrapper.c |  209 ++++++
>  arch/s390/kernel/entry.h          |    6 +-
>  arch/s390/kernel/syscalls.S       |  504 ++++++-------
>  arch/x86/include/asm/unistd.h     |    3 +
>  fs/compat.c                       |  121 ++--
>  fs/compat_ioctl.c                 |    5 +-
>  fs/exec.c                         |    6 +-
>  fs/read_write.c                   |   36 +-
>  include/linux/compat.h            |   62 +-
>  include/linux/kexec.h             |    6 -
>  include/linux/syscalls.h          |    2 +
>  include/uapi/asm-generic/unistd.h |    1 +
>  ipc/compat.c                      |   13 +-
>  ipc/compat_mq.c                   |   32 +-
>  kernel/compat.c                   |  100 +--
>  kernel/kexec.c                    |    8 +-
>  kernel/ptrace.c                   |    4 +-
>  mm/mempolicy.c                    |   18 +-
>  mm/process_vm_access.c            |   26 +-
>  net/compat.c                      |   32 +-
>  security/keys/compat.c            |    4 +-
>  28 files changed, 828 insertions(+), 2004 deletions(-)
> 
> -- 
> 1.8.4.5

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE
  2014-03-12 19:45 ` Heiko Carstens
@ 2014-03-13  7:32   ` Heiko Carstens
  2014-03-13 19:09     ` Mark Brown
  2014-03-17  6:02   ` Stephen Rothwell
  1 sibling, 1 reply; 28+ messages in thread
From: Heiko Carstens @ 2014-03-13  7:32 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-next

Hi Mark,

I obviously missed that you are currently handling linux-next, so I sent my
request to Stephen yesterday :)

Could you add the

  git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git compat

to linux-next, please?

Thanks,
Heiko

(sorry for top-posting)

On Wed, Mar 12, 2014 at 08:45:26PM +0100, Heiko Carstens wrote:
> Hi Stephen,
> 
> since nobody objected to the compat changes I described below, could you
> please add the tree
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git compat
> 
> to linux-next?
> 
> Thanks,
> Heiko
> 
> [full quote below]
> 
> On Thu, Mar 06, 2014 at 04:51:07PM +0100, Heiko Carstens wrote:
> > Hi all,
> > 
> > this patch series converts all common code compat syscalls to use the new
> > COMPAT_SYSCALL_DEFINE macros introduced by Al Viro.
> > My main motivation is to get rid of the 1400+ line s390 specific assembler
> > file which contains code for each and every compat system call to perform
> > proper sign, zero and pointer conversion.
> > 
> > Eventually the conversion is pretty trivial, except that for a couple of
> > compat syscalls argument types needed to be changed from e.g. 'long' to
> > 'compat_long_t' so that the COMPAT_SYSCALL_DEFINE macro can perform
> > proper sign extension from the 32 bit compat system call argument like
> > it was orginally passed in from user space.
> > 
> > The patch series keeps the "noop" conversions (5-10) and those with type
> > changes (11-15) separate.
> > 
> > Patches 1-4 are just additional cleanup patches.
> > 
> > Especially I'd like to know from somebody familiar with the x32 ABI if
> > any of the type changes break x32?
> > I intentionally did not touch the preadv64 and pwritev64 compat system
> > calls since they have been explicitly added to allow x32 pass 64 bit
> > arguments.
> > However it's not obvious to me if any of my other compat system call
> > changes break x32 or not.
> > 
> > FWIW, this patch series omits the whole s390 patches, since I assume
> > they are not very interesting to non-s390 people ;)
> > 
> > The complete series (including the s390 only patches) is available at
> > 
> >   git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git compat
> > 
> > If nobody objects I'd like to have the branch integrated into linux-next
> > to get some additional testing.
> > 
> > So, please let me know if I screwed up something! :)
> > 
> > Thanks,
> > Heiko
> > 
> > Heiko Carstens (16):
> >       compat: let architectures define __ARCH_WANT_COMPAT_SYS_GETDENTS64
> >       compat: add COMPAT_SYSCALL_DEFINE0 macro
> >       ipc/compat_sys_msgrcv: change msgtyp type from long to compat_long_t
> >       fs/compat: optional preadv64/pwrite64 compat system calls
> >       kernel/compat: convert to COMPAT_SYSCALL_DEFINE
> >       net/compat: convert to COMPAT_SYSCALL_DEFINE
> >       mm/compat: convert to COMPAT_SYSCALL_DEFINE
> >       security/compat: convert to COMPAT_SYSCALL_DEFINE
> >       fs/compat: convert to COMPAT_SYSCALL_DEFINE
> >       ipc/compat: convert to COMPAT_SYSCALL_DEFINE
> >       fs/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types
> >       ipc/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types
> >       net/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types
> >       kexec/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types
> >       mm/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types
> >       s390/compat: build error for large compat syscall args
> > 
> > (diffstat below includes the s390 only patches)
> > 
> >  arch/arm64/include/asm/unistd.h   |    1 +
> >  arch/mips/include/asm/unistd.h    |    1 -
> >  arch/s390/include/asm/compat.h    |    6 +-
> >  arch/s390/kernel/compat_linux.c   |  116 +--
> >  arch/s390/kernel/compat_linux.h   |   81 +--
> >  arch/s390/kernel/compat_signal.c  |    4 +-
> >  arch/s390/kernel/compat_wrapper.S | 1425 -------------------------------------
> >  arch/s390/kernel/compat_wrapper.c |  209 ++++++
> >  arch/s390/kernel/entry.h          |    6 +-
> >  arch/s390/kernel/syscalls.S       |  504 ++++++-------
> >  arch/x86/include/asm/unistd.h     |    3 +
> >  fs/compat.c                       |  121 ++--
> >  fs/compat_ioctl.c                 |    5 +-
> >  fs/exec.c                         |    6 +-
> >  fs/read_write.c                   |   36 +-
> >  include/linux/compat.h            |   62 +-
> >  include/linux/kexec.h             |    6 -
> >  include/linux/syscalls.h          |    2 +
> >  include/uapi/asm-generic/unistd.h |    1 +
> >  ipc/compat.c                      |   13 +-
> >  ipc/compat_mq.c                   |   32 +-
> >  kernel/compat.c                   |  100 +--
> >  kernel/kexec.c                    |    8 +-
> >  kernel/ptrace.c                   |    4 +-
> >  mm/mempolicy.c                    |   18 +-
> >  mm/process_vm_access.c            |   26 +-
> >  net/compat.c                      |   32 +-
> >  security/keys/compat.c            |    4 +-
> >  28 files changed, 828 insertions(+), 2004 deletions(-)
> > 
> > -- 
> > 1.8.4.5
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-next" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE
  2014-03-13  7:32   ` Heiko Carstens
@ 2014-03-13 19:09     ` Mark Brown
  0 siblings, 0 replies; 28+ messages in thread
From: Mark Brown @ 2014-03-13 19:09 UTC (permalink / raw)
  To: Heiko Carstens; +Cc: linux-next

[-- Attachment #1: Type: text/plain, Size: 2062 bytes --]

On Thu, Mar 13, 2014 at 08:32:30AM +0100, Heiko Carstens wrote:

> I obviously missed that you are currently handling linux-next, so I sent my
> request to Stephen yesterday :)

> Could you add the

>   git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git compat

> to linux-next, please?

OK, I think I did this but it's entirely possible I'm not driving the
scripts correctly so things might explode.  Take a look tomorrow :)  You
should also make sure this is handed over to Stephen when he's back from
vacation next week.

Thanks for adding your subsystem tree as a participant of linux-next.
As you may know, this is not a judgment of your code.  The purpose of
linux-next is for integration testing and to lower the impact of
conflicts between subsystems in the next merge window.

You will need to ensure that the patches/commits in your tree/series
have been:
     * submitted under GPL v2 (or later) and include the Contributor's
	Signed-off-by,
     * posted to the relevant mailing list,
     * reviewed by you (or another maintainer of your subsystem tree),
     * successfully unit tested, and 
     * destined for the current or next Linux merge window.

Basically, this should be just what you would send to Linus (or ask him
to fetch).  It is allowed to be rebased if you deem it necessary.

Legal Stuff:
By participating in linux-next, your subsystem tree contributions are
public and will be included in the linux-next trees.  You may be sent
e-mail messages indicating errors or other issues when the
patches/commits from your subsystem tree are merged and tested in
linux-next.  These messages may also be cross-posted to the linux-next
mailing list, the linux-kernel mailing list, etc.  The linux-next tree
project, Linaro (my employer) and IBM (Stephen's employer) make no
warranties regarding the linux-next project, the testing procedures, the
results, the e-mails, etc.  If you don't agree to these ground rules,
let me know and I'll remove your tree from participation in linux-next.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE
  2014-03-12 19:45 ` Heiko Carstens
  2014-03-13  7:32   ` Heiko Carstens
@ 2014-03-17  6:02   ` Stephen Rothwell
  1 sibling, 0 replies; 28+ messages in thread
From: Stephen Rothwell @ 2014-03-17  6:02 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: linux-next, Al Viro, H. Peter Anvin, Ingo Molnar,
	Thomas Gleixner, linux-arch, Martin Schwidefsky, H. Peter Anvin,
	Mark Brown

[-- Attachment #1: Type: text/plain, Size: 1917 bytes --]

Hi Heiko,

On Wed, 12 Mar 2014 20:45:26 +0100 Heiko Carstens <heiko.carstens@de.ibm.com> wrote:
>
> since nobody objected to the compat changes I described below, could you
> please add the tree
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git compat
> 
> to linux-next?

Mark added this the other day and I will add it to my tree from today.

Thanks for adding your subsystem tree as a participant of linux-next.  As
you may know, this is not a judgment of your code.  The purpose of
linux-next is for integration testing and to lower the impact of
conflicts between subsystems in the next merge window. 

You will need to ensure that the patches/commits in your tree/series have
been:
     * submitted under GPL v2 (or later) and include the Contributor's
	Signed-off-by,
     * posted to the relevant mailing list,
     * reviewed by you (or another maintainer of your subsystem tree),
     * successfully unit tested, and 
     * destined for the current or next Linux merge window.

Basically, this should be just what you would send to Linus (or ask him
to fetch).  It is allowed to be rebased if you deem it necessary.

-- 
Cheers,
Stephen Rothwell 
sfr@canb.auug.org.au

Legal Stuff:
By participating in linux-next, your subsystem tree contributions are
public and will be included in the linux-next trees.  You may be sent
e-mail messages indicating errors or other issues when the
patches/commits from your subsystem tree are merged and tested in
linux-next.  These messages may also be cross-posted to the linux-next
mailing list, the linux-kernel mailing list, etc.  The linux-next tree
project and IBM (my employer) make no warranties regarding the linux-next
project, the testing procedures, the results, the e-mails, etc.  If you
don't agree to these ground rules, let me know and I'll remove your tree
from participation in linux-next.

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH/RFC 01/16] compat: let architectures define __ARCH_WANT_COMPAT_SYS_GETDENTS64
  2014-03-06 15:51 ` [PATCH/RFC 01/16] compat: let architectures define __ARCH_WANT_COMPAT_SYS_GETDENTS64 Heiko Carstens
@ 2014-03-20 10:03   ` Geert Uytterhoeven
  2014-03-20 11:33     ` Heiko Carstens
  0 siblings, 1 reply; 28+ messages in thread
From: Geert Uytterhoeven @ 2014-03-20 10:03 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: Al Viro, H. Peter Anvin, Ingo Molnar, Thomas Gleixner,
	Linux-Arch, Martin Schwidefsky, Linux-Next, Chris Metcalf

On Thu, Mar 6, 2014 at 4:51 PM, Heiko Carstens
<heiko.carstens@de.ibm.com> wrote:
> For architecture dependent compat syscalls in common code an architecture
> must define something like __ARCH_WANT_<WHATEVER> if it wants to use the
> code.
> This however is not true for compat_sys_getdents64 for which architectures
> must define __ARCH_OMIT_COMPAT_SYS_GETDENTS64 if they do not want the code.
>
> This leads to the situation where all architectures, except mips, get the
> compat code but only x86_64, arm64 and the generic syscall architectures
> actually use it.
>
> So invert the logic, so that architectures actively must do something to
> get the compat code.
>
> This way a couple of architectures get rid of otherwise dead code.
>
> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>

Is this the cause of the tilegx_defconfig failures in -next?

include/uapi/asm-generic/unistd.h:195:1: error:
'compat_sys_getdents64' undeclared here (not in a function)
make[3]: *** [arch/tile/kernel/compat.o] Error 1

http://kisskb.ellerman.id.au/kisskb/buildresult/10808012/

> ---
>  arch/arm64/include/asm/unistd.h   | 1 +
>  arch/mips/include/asm/unistd.h    | 1 -
>  arch/x86/include/asm/unistd.h     | 1 +
>  fs/compat.c                       | 4 ++--
>  include/linux/compat.h            | 2 ++
>  include/uapi/asm-generic/unistd.h | 1 +
>  6 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h
> index 82ce217e94cf..a4654c656a1e 100644
> --- a/arch/arm64/include/asm/unistd.h
> +++ b/arch/arm64/include/asm/unistd.h
> @@ -14,6 +14,7 @@
>   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   */
>  #ifdef CONFIG_COMPAT
> +#define __ARCH_WANT_COMPAT_SYS_GETDENTS64
>  #define __ARCH_WANT_COMPAT_STAT64
>  #define __ARCH_WANT_SYS_GETHOSTNAME
>  #define __ARCH_WANT_SYS_PAUSE
> diff --git a/arch/mips/include/asm/unistd.h b/arch/mips/include/asm/unistd.h
> index 4d3b92886665..413d6c612bec 100644
> --- a/arch/mips/include/asm/unistd.h
> +++ b/arch/mips/include/asm/unistd.h
> @@ -24,7 +24,6 @@
>
>  #ifndef __ASSEMBLY__
>
> -#define __ARCH_OMIT_COMPAT_SYS_GETDENTS64
>  #define __ARCH_WANT_OLD_READDIR
>  #define __ARCH_WANT_SYS_ALARM
>  #define __ARCH_WANT_SYS_GETHOSTNAME
> diff --git a/arch/x86/include/asm/unistd.h b/arch/x86/include/asm/unistd.h
> index c2a48139c340..f4b5795d7e34 100644
> --- a/arch/x86/include/asm/unistd.h
> +++ b/arch/x86/include/asm/unistd.h
> @@ -23,6 +23,7 @@
>  #  include <asm/unistd_64.h>
>  #  include <asm/unistd_64_x32.h>
>  #  define __ARCH_WANT_COMPAT_SYS_TIME
> +#  define __ARCH_WANT_COMPAT_SYS_GETDENTS64
>
>  # endif
>
> diff --git a/fs/compat.c b/fs/compat.c
> index 6af20de2c1a3..0095a6978eef 100644
> --- a/fs/compat.c
> +++ b/fs/compat.c
> @@ -981,7 +981,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
>         return error;
>  }
>
> -#ifndef __ARCH_OMIT_COMPAT_SYS_GETDENTS64
> +#ifdef __ARCH_WANT_COMPAT_SYS_GETDENTS64
>
>  struct compat_getdents_callback64 {
>         struct dir_context ctx;
> @@ -1066,7 +1066,7 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
>         fdput(f);
>         return error;
>  }
> -#endif /* ! __ARCH_OMIT_COMPAT_SYS_GETDENTS64 */
> +#endif /* __ARCH_WANT_COMPAT_SYS_GETDENTS64 */
>
>  /*
>   * Exactly like fs/open.c:sys_open(), except that it doesn't set the
> diff --git a/include/linux/compat.h b/include/linux/compat.h
> index 3f448c65511b..beded18f992d 100644
> --- a/include/linux/compat.h
> +++ b/include/linux/compat.h
> @@ -502,9 +502,11 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
>  asmlinkage long compat_sys_getdents(unsigned int fd,
>                                     struct compat_linux_dirent __user *dirent,
>                                     unsigned int count);
> +#ifdef __ARCH_WANT_COMPAT_SYS_GETDENTS64
>  asmlinkage long compat_sys_getdents64(unsigned int fd,
>                                       struct linux_dirent64 __user *dirent,
>                                       unsigned int count);
> +#endif
>  asmlinkage long compat_sys_vmsplice(int fd, const struct compat_iovec __user *,
>                                     unsigned int nr_segs, unsigned int flags);
>  asmlinkage long compat_sys_open(const char __user *filename, int flags,
> diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h
> index dde8041f40d2..6db66783d268 100644
> --- a/include/uapi/asm-generic/unistd.h
> +++ b/include/uapi/asm-generic/unistd.h
> @@ -191,6 +191,7 @@ __SYSCALL(__NR_quotactl, sys_quotactl)
>
>  /* fs/readdir.c */
>  #define __NR_getdents64 61
> +#define __ARCH_WANT_COMPAT_SYS_GETDENTS64
>  __SC_COMP(__NR_getdents64, sys_getdents64, compat_sys_getdents64)
>
>  /* fs/read_write.c */
> --
> 1.8.4.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-arch" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH/RFC 01/16] compat: let architectures define __ARCH_WANT_COMPAT_SYS_GETDENTS64
  2014-03-20 10:03   ` Geert Uytterhoeven
@ 2014-03-20 11:33     ` Heiko Carstens
  2014-03-20 14:51         ` Heiko Carstens
  0 siblings, 1 reply; 28+ messages in thread
From: Heiko Carstens @ 2014-03-20 11:33 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Al Viro, H. Peter Anvin, Ingo Molnar, Thomas Gleixner,
	Linux-Arch, Martin Schwidefsky, Linux-Next, Chris Metcalf

On Thu, Mar 20, 2014 at 11:03:14AM +0100, Geert Uytterhoeven wrote:
> On Thu, Mar 6, 2014 at 4:51 PM, Heiko Carstens
> <heiko.carstens@de.ibm.com> wrote:
> > For architecture dependent compat syscalls in common code an architecture
> > must define something like __ARCH_WANT_<WHATEVER> if it wants to use the
> > code.
> > This however is not true for compat_sys_getdents64 for which architectures
> > must define __ARCH_OMIT_COMPAT_SYS_GETDENTS64 if they do not want the code.
> >
> > This leads to the situation where all architectures, except mips, get the
> > compat code but only x86_64, arm64 and the generic syscall architectures
> > actually use it.
> >
> > So invert the logic, so that architectures actively must do something to
> > get the compat code.
> >
> > This way a couple of architectures get rid of otherwise dead code.
> >
> > Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
> 
> Is this the cause of the tilegx_defconfig failures in -next?
> 
> include/uapi/asm-generic/unistd.h:195:1: error:
> 'compat_sys_getdents64' undeclared here (not in a function)
> make[3]: *** [arch/tile/kernel/compat.o] Error 1
> 
> http://kisskb.ellerman.id.au/kisskb/buildresult/10808012/

Yes. That's unexpected header include order from my side...
Looking into it. Thanks!

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH/RFC 01/16] compat: let architectures define __ARCH_WANT_COMPAT_SYS_GETDENTS64
  2014-03-20 11:33     ` Heiko Carstens
@ 2014-03-20 14:51         ` Heiko Carstens
  0 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2014-03-20 14:51 UTC (permalink / raw)
  To: Geert Uytterhoeven, Al Viro, H. Peter Anvin, Ingo Molnar,
	Thomas Gleixner, Linux-Arch, Martin Schwidefsky, Linux-Next,
	Chris Metcalf

On Thu, Mar 20, 2014 at 12:33:33PM +0100, Heiko Carstens wrote:
> On Thu, Mar 20, 2014 at 11:03:14AM +0100, Geert Uytterhoeven wrote:
> > On Thu, Mar 6, 2014 at 4:51 PM, Heiko Carstens
> > <heiko.carstens@de.ibm.com> wrote:
> > > For architecture dependent compat syscalls in common code an architecture
> > > must define something like __ARCH_WANT_<WHATEVER> if it wants to use the
> > > code.
> > > This however is not true for compat_sys_getdents64 for which architectures
> > > must define __ARCH_OMIT_COMPAT_SYS_GETDENTS64 if they do not want the code.
> > >
> > > This leads to the situation where all architectures, except mips, get the
> > > compat code but only x86_64, arm64 and the generic syscall architectures
> > > actually use it.
> > >
> > > So invert the logic, so that architectures actively must do something to
> > > get the compat code.
> > >
> > > This way a couple of architectures get rid of otherwise dead code.
> > >
> > > Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
> > 
> > Is this the cause of the tilegx_defconfig failures in -next?
> > 
> > include/uapi/asm-generic/unistd.h:195:1: error:
> > 'compat_sys_getdents64' undeclared here (not in a function)
> > make[3]: *** [arch/tile/kernel/compat.o] Error 1
> > 
> > http://kisskb.ellerman.id.au/kisskb/buildresult/10808012/
> 
> Yes. That's unexpected header include order from my side...
> Looking into it. Thanks!

I think the simple patch below should fix the compile error.
Unfortunately I don't have a tile cross compiler.

But at least s390, x86_64, sparc64 and mip64 still compile, so it
looks like I'm not immediatly lost in include order hell.

(pushed to the s390 compat branch, so the next linux-next release
 should contain the fix)

>From f80f4cd232c56f491ecbeea3dd0627598b59b61e Mon Sep 17 00:00:00 2001
From: Heiko Carstens <heiko.carstens@de.ibm.com>
Date: Thu, 20 Mar 2014 15:30:14 +0100
Subject: [PATCH] compat: include linux/unistd.h within linux/compat.h

linux/compat.h does not include linux/unistd.h but the compat.h header
file contains various conditional

 #ifdef __ARCH_WANT_COMPAT_...
 asmlinkage long compat...()
 #endif

compat system call function declarations.
If linux/unistd.h isn't included it depends on previous includes if those
__ARCH_WANT_COMPAT_... defines are defined or not. So add an additional
linux/unistd.h include.

Should fix this compile error on tile:

include/uapi/asm-generic/unistd.h:195:1: error: 'compat_sys_getdents64' undeclared
make[3]: *** [arch/tile/kernel/compat.o] Error 1

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 include/linux/compat.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/compat.h b/include/linux/compat.h
index 7c765624b7ef..01c0aa57ccec 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -14,6 +14,7 @@
 #include <linux/if.h>
 #include <linux/fs.h>
 #include <linux/aio_abi.h>	/* for aio_context_t */
+#include <linux/unistd.h>
 
 #include <asm/compat.h>
 #include <asm/siginfo.h>
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* Re: [PATCH/RFC 01/16] compat: let architectures define __ARCH_WANT_COMPAT_SYS_GETDENTS64
@ 2014-03-20 14:51         ` Heiko Carstens
  0 siblings, 0 replies; 28+ messages in thread
From: Heiko Carstens @ 2014-03-20 14:51 UTC (permalink / raw)
  To: Geert Uytterhoeven, Al Viro, H. Peter Anvin, Ingo Molnar,
	Thomas Gleixner, Linux-Arch, Martin Schwidefsky, Linux-Next,
	Chris Metcalf

On Thu, Mar 20, 2014 at 12:33:33PM +0100, Heiko Carstens wrote:
> On Thu, Mar 20, 2014 at 11:03:14AM +0100, Geert Uytterhoeven wrote:
> > On Thu, Mar 6, 2014 at 4:51 PM, Heiko Carstens
> > <heiko.carstens@de.ibm.com> wrote:
> > > For architecture dependent compat syscalls in common code an architecture
> > > must define something like __ARCH_WANT_<WHATEVER> if it wants to use the
> > > code.
> > > This however is not true for compat_sys_getdents64 for which architectures
> > > must define __ARCH_OMIT_COMPAT_SYS_GETDENTS64 if they do not want the code.
> > >
> > > This leads to the situation where all architectures, except mips, get the
> > > compat code but only x86_64, arm64 and the generic syscall architectures
> > > actually use it.
> > >
> > > So invert the logic, so that architectures actively must do something to
> > > get the compat code.
> > >
> > > This way a couple of architectures get rid of otherwise dead code.
> > >
> > > Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
> > 
> > Is this the cause of the tilegx_defconfig failures in -next?
> > 
> > include/uapi/asm-generic/unistd.h:195:1: error:
> > 'compat_sys_getdents64' undeclared here (not in a function)
> > make[3]: *** [arch/tile/kernel/compat.o] Error 1
> > 
> > http://kisskb.ellerman.id.au/kisskb/buildresult/10808012/
> 
> Yes. That's unexpected header include order from my side...
> Looking into it. Thanks!

I think the simple patch below should fix the compile error.
Unfortunately I don't have a tile cross compiler.

But at least s390, x86_64, sparc64 and mip64 still compile, so it
looks like I'm not immediatly lost in include order hell.

(pushed to the s390 compat branch, so the next linux-next release
 should contain the fix)

From f80f4cd232c56f491ecbeea3dd0627598b59b61e Mon Sep 17 00:00:00 2001
From: Heiko Carstens <heiko.carstens@de.ibm.com>
Date: Thu, 20 Mar 2014 15:30:14 +0100
Subject: [PATCH] compat: include linux/unistd.h within linux/compat.h

linux/compat.h does not include linux/unistd.h but the compat.h header
file contains various conditional

 #ifdef __ARCH_WANT_COMPAT_...
 asmlinkage long compat...()
 #endif

compat system call function declarations.
If linux/unistd.h isn't included it depends on previous includes if those
__ARCH_WANT_COMPAT_... defines are defined or not. So add an additional
linux/unistd.h include.

Should fix this compile error on tile:

include/uapi/asm-generic/unistd.h:195:1: error: 'compat_sys_getdents64' undeclared
make[3]: *** [arch/tile/kernel/compat.o] Error 1

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 include/linux/compat.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/compat.h b/include/linux/compat.h
index 7c765624b7ef..01c0aa57ccec 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -14,6 +14,7 @@
 #include <linux/if.h>
 #include <linux/fs.h>
 #include <linux/aio_abi.h>	/* for aio_context_t */
+#include <linux/unistd.h>
 
 #include <asm/compat.h>
 #include <asm/siginfo.h>
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* Re: [PATCH/RFC 01/16] compat: let architectures define __ARCH_WANT_COMPAT_SYS_GETDENTS64
  2014-03-20 14:51         ` Heiko Carstens
  (?)
@ 2014-03-20 15:20         ` Geert Uytterhoeven
  -1 siblings, 0 replies; 28+ messages in thread
From: Geert Uytterhoeven @ 2014-03-20 15:20 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: Al Viro, H. Peter Anvin, Ingo Molnar, Thomas Gleixner,
	Linux-Arch, Martin Schwidefsky, Linux-Next, Chris Metcalf

Hi Heiko,

On Thu, Mar 20, 2014 at 3:51 PM, Heiko Carstens
<heiko.carstens@de.ibm.com> wrote:
> I think the simple patch below should fix the compile error.

Thanks!

> Unfortunately I don't have a tile cross compiler.

Unfortunately https://www.kernel.org/pub/tools/crosstool/ doesn't have
one for s390 hosts, only for ia32 and amd64.

> linux/compat.h does not include linux/unistd.h but the compat.h header
> file contains various conditional
>
>  #ifdef __ARCH_WANT_COMPAT_...
>  asmlinkage long compat...()
>  #endif
>
> compat system call function declarations.
> If linux/unistd.h isn't included it depends on previous includes if those
> __ARCH_WANT_COMPAT_... defines are defined or not. So add an additional
> linux/unistd.h include.
>
> Should fix this compile error on tile:
>
> include/uapi/asm-generic/unistd.h:195:1: error: 'compat_sys_getdents64' undeclared
> make[3]: *** [arch/tile/kernel/compat.o] Error 1
>
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>

Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH/RFC 01/16] compat: let architectures define __ARCH_WANT_COMPAT_SYS_GETDENTS64
  2014-03-20 14:51         ` Heiko Carstens
  (?)
  (?)
@ 2014-03-20 15:29         ` Chris Metcalf
  -1 siblings, 0 replies; 28+ messages in thread
From: Chris Metcalf @ 2014-03-20 15:29 UTC (permalink / raw)
  To: Heiko Carstens, Geert Uytterhoeven, Al Viro, H. Peter Anvin,
	Ingo Molnar, Thomas Gleixner, Linux-Arch, Martin Schwidefsky,
	Linux-Next

On 3/20/2014 10:51 AM, Heiko Carstens wrote:
> I think the simple patch below should fix the compile error.
> Unfortunately I don't have a tile cross compiler.
>
> But at least s390, x86_64, sparc64 and mip64 still compile, so it
> looks like I'm not immediatly lost in include order hell.
>
> (pushed to the s390 compat branch, so the next linux-next release
>  should contain the fix)
>
> From f80f4cd232c56f491ecbeea3dd0627598b59b61e Mon Sep 17 00:00:00 2001
> From: Heiko Carstens <heiko.carstens@de.ibm.com>
> Date: Thu, 20 Mar 2014 15:30:14 +0100
> Subject: [PATCH] compat: include linux/unistd.h within linux/compat.h
>
> linux/compat.h does not include linux/unistd.h but the compat.h header
> file contains various conditional
>
>  #ifdef __ARCH_WANT_COMPAT_...
>  asmlinkage long compat...()
>  #endif
>
> compat system call function declarations.
> If linux/unistd.h isn't included it depends on previous includes if those
> __ARCH_WANT_COMPAT_... defines are defined or not. So add an additional
> linux/unistd.h include.
>
> Should fix this compile error on tile:
>
> include/uapi/asm-generic/unistd.h:195:1: error: 'compat_sys_getdents64' undeclared
> make[3]: *** [arch/tile/kernel/compat.o] Error 1
>
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>

This does fix the error on tilegx.  Thanks.

Acked-by: Chris Metcalf <cmetcalf@tilera.com>

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2014-03-20 15:29 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-06 15:51 [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE Heiko Carstens
2014-03-06 15:51 ` [PATCH/RFC 01/16] compat: let architectures define __ARCH_WANT_COMPAT_SYS_GETDENTS64 Heiko Carstens
2014-03-20 10:03   ` Geert Uytterhoeven
2014-03-20 11:33     ` Heiko Carstens
2014-03-20 14:51       ` Heiko Carstens
2014-03-20 14:51         ` Heiko Carstens
2014-03-20 15:20         ` Geert Uytterhoeven
2014-03-20 15:29         ` Chris Metcalf
2014-03-06 15:51 ` [PATCH/RFC 02/16] compat: add COMPAT_SYSCALL_DEFINE0 macro Heiko Carstens
2014-03-06 15:51 ` [PATCH/RFC 03/16] ipc/compat_sys_msgrcv: change msgtyp type from long to compat_long_t Heiko Carstens
2014-03-06 15:51 ` [PATCH/RFC 04/16] fs/compat: optional preadv64/pwrite64 compat system calls Heiko Carstens
2014-03-06 15:51 ` [PATCH/RFC 05/16] kernel/compat: convert to COMPAT_SYSCALL_DEFINE Heiko Carstens
2014-03-06 15:51 ` [PATCH/RFC 06/16] net/compat: " Heiko Carstens
2014-03-06 15:51 ` [PATCH/RFC 07/16] mm/compat: " Heiko Carstens
2014-03-06 15:51 ` [PATCH/RFC 08/16] security/compat: " Heiko Carstens
2014-03-06 15:51 ` [PATCH/RFC 09/16] fs/compat: " Heiko Carstens
2014-03-06 15:51 ` [PATCH/RFC 10/16] ipc/compat: " Heiko Carstens
2014-03-06 15:51 ` [PATCH/RFC 11/16] fs/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types Heiko Carstens
2014-03-06 15:51 ` [PATCH/RFC 12/16] ipc/compat: " Heiko Carstens
2014-03-06 15:51 ` [PATCH/RFC 13/16] net/compat: " Heiko Carstens
2014-03-06 15:51 ` [PATCH/RFC 14/16] kexec/compat: " Heiko Carstens
2014-03-06 15:51 ` [PATCH/RFC 15/16] mm/compat: " Heiko Carstens
2014-03-06 15:51 ` [PATCH/RFC 16/16] s390/compat: build error for large compat syscall args Heiko Carstens
2014-03-06 16:14 ` [PATCH/RFC 00/16] compat: convert to COMPAT_SYSCALL_DEFINE Geert Uytterhoeven
2014-03-12 19:45 ` Heiko Carstens
2014-03-13  7:32   ` Heiko Carstens
2014-03-13 19:09     ` Mark Brown
2014-03-17  6:02   ` Stephen Rothwell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.