unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Mark unsigned long arguments with U in more syscalls [BZ #25810]
@ 2020-04-29 14:47 H.J. Lu via Libc-alpha
  2020-04-29 14:47 ` [PATCH 2/2] Add C wrappers for prctl/process_vm_readv/process_vm_writev " H.J. Lu via Libc-alpha
  2020-04-29 14:57 ` [PATCH 1/2] Mark unsigned long arguments with U in more syscalls " Florian Weimer via Libc-alpha
  0 siblings, 2 replies; 19+ messages in thread
From: H.J. Lu via Libc-alpha @ 2020-04-29 14:47 UTC (permalink / raw
  To: libc-alpha

Mark unsigned long arguments in mmap, read, recv, recvfrom, send, sendto,
write, ioperm, sendfile64, setxattr, lsetxattr, fsetxattr, getxattr,
lgetxattr, fgetxattr, listxattr, llistxattr and flistxattr with U.
---
 sysdeps/unix/syscalls.list            | 14 +++++++-------
 sysdeps/unix/sysv/linux/syscalls.list | 22 +++++++++++-----------
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/sysdeps/unix/syscalls.list b/sysdeps/unix/syscalls.list
index 766d1664aa..7209c24110 100644
--- a/sysdeps/unix/syscalls.list
+++ b/sysdeps/unix/syscalls.list
@@ -39,25 +39,25 @@ listen		-	listen		i:ii	__listen	listen
 lseek		-	lseek		i:iii	__libc_lseek	__lseek lseek
 madvise		-	madvise		i:pUi	__madvise	madvise
 mkdir		-	mkdir		i:si	__mkdir		mkdir
-mmap		-	mmap		b:aniiii __mmap		mmap
+mmap		-	mmap		b:aUiiii __mmap		mmap
 mprotect	-	mprotect	i:aUi	__mprotect	mprotect
 munmap		-	munmap		i:aU	__munmap	munmap
 open		-	open		Ci:siv	__libc_open __open open
 profil		-	profil		i:piii	__profil	profil
 ptrace		-	ptrace		i:iiii	ptrace
-read		-	read		Ci:ibn	__libc_read	__read read
+read		-	read		Ci:ibU	__libc_read	__read read
 readlink	-	readlink	i:spU	__readlink	readlink
 readv		-	readv		Ci:ipi	__readv		readv
 reboot		-	reboot		i:i	reboot
-recv		-	recv		Ci:ibni	__libc_recv	recv
-recvfrom	-	recvfrom	Ci:ibniBN	__libc_recvfrom __recvfrom recvfrom
+recv		-	recv		Ci:ibUi	__libc_recv	recv
+recvfrom	-	recvfrom	Ci:ibUiBN	__libc_recvfrom __recvfrom recvfrom
 recvmsg		-	recvmsg		Ci:ipi	__libc_recvmsg	__recvmsg recvmsg
 rename		-	rename		i:ss	rename
 rmdir		-	rmdir		i:s	__rmdir		rmdir
 select		-	select		Ci:iPPPP	__select	__libc_select select
-send		-	send		Ci:ibni	__libc_send	__send send
+send		-	send		Ci:ibUi	__libc_send	__send send
 sendmsg		-	sendmsg		Ci:ipi	__libc_sendmsg	__sendmsg sendmsg
-sendto		-	sendto		Ci:ibnibn	__libc_sendto	__sendto sendto
+sendto		-	sendto		Ci:ibUibn	__libc_sendto	__sendto sendto
 setdomain	-	setdomainname	i:si	setdomainname
 setegid		-	setegid		i:i	__setegid	setegid
 seteuid		-	seteuid		i:i	__seteuid	seteuid
@@ -90,5 +90,5 @@ uname		-	uname		i:p	__uname		uname
 unlink		-	unlink		i:s	__unlink	unlink
 utimes		-	utimes		i:sp	__utimes	utimes
 vhangup		-	vhangup		i:i	vhangup
-write		-	write		Ci:ibn	__libc_write	__write write
+write		-	write		Ci:ibU	__libc_write	__write write
 writev		-	writev		Ci:ipi	__writev	writev
diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list
index 1b1010d4c8..5b4e205934 100644
--- a/sysdeps/unix/sysv/linux/syscalls.list
+++ b/sysdeps/unix/sysv/linux/syscalls.list
@@ -28,7 +28,7 @@ inotify_add_watch	EXTRA	inotify_add_watch	i:isi	inotify_add_watch
 inotify_init	EXTRA	inotify_init	i:	inotify_init
 inotify_init1	EXTRA	inotify_init1	i:I	inotify_init1
 inotify_rm_watch	EXTRA	inotify_rm_watch	i:ii	inotify_rm_watch
-ioperm		-	ioperm		i:iii	ioperm
+ioperm		-	ioperm		i:UUi	ioperm
 iopl		-	iopl		i:i	iopl
 klogctl		EXTRA	syslog		i:isi	klogctl
 lchown		-	lchown		i:sii	__lchown	lchown
@@ -55,7 +55,7 @@ sched_setp	-	sched_setparam	i:ip	__sched_setparam	sched_setparam
 sched_sets	-	sched_setscheduler	i:iip	__sched_setscheduler	sched_setscheduler
 sched_yield	-	sched_yield	i:	__sched_yield	sched_yield
 sendfile	-	sendfile	i:iipU	sendfile
-sendfile64	-	sendfile64	i:iipi	sendfile64
+sendfile64	-	sendfile64	i:iipU	sendfile64
 setfsgid	EXTRA	setfsgid	i:i	setfsgid
 setfsuid	EXTRA	setfsuid	i:i	setfsuid
 setpgid		-	setpgid		i:ii	__setpgid	setpgid
@@ -75,15 +75,15 @@ readlinkat	-	readlinkat	i:issU	readlinkat
 symlinkat	-	symlinkat	i:sis	symlinkat
 unlinkat	-	unlinkat	i:isi	unlinkat
 
-setxattr	-	setxattr	i:sspii	setxattr
-lsetxattr	-	lsetxattr	i:sspii	lsetxattr
-fsetxattr	-	fsetxattr	i:ispii	fsetxattr
-getxattr	-	getxattr	i:sspi	getxattr
-lgetxattr	-	lgetxattr	i:sspi	lgetxattr
-fgetxattr	-	fgetxattr	i:ispi	fgetxattr
-listxattr	-	listxattr	i:ssi	listxattr
-llistxattr	-	llistxattr	i:ssi	llistxattr
-flistxattr	-	flistxattr	i:isi	flistxattr
+setxattr	-	setxattr	i:sspUi	setxattr
+lsetxattr	-	lsetxattr	i:sspUi	lsetxattr
+fsetxattr	-	fsetxattr	i:ispUi	fsetxattr
+getxattr	-	getxattr	i:sspU	getxattr
+lgetxattr	-	lgetxattr	i:sspU	lgetxattr
+fgetxattr	-	fgetxattr	i:ispU	fgetxattr
+listxattr	-	listxattr	i:ssU	listxattr
+llistxattr	-	llistxattr	i:ssU	llistxattr
+flistxattr	-	flistxattr	i:isU	flistxattr
 removexattr	-	removexattr	i:ss	removexattr
 lremovexattr	-	lremovexattr	i:ss	lremovexattr
 fremovexattr	-	fremovexattr	i:is	fremovexattr
-- 
2.25.4


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

* [PATCH 2/2] Add C wrappers for prctl/process_vm_readv/process_vm_writev [BZ #25810]
  2020-04-29 14:47 [PATCH 1/2] Mark unsigned long arguments with U in more syscalls [BZ #25810] H.J. Lu via Libc-alpha
@ 2020-04-29 14:47 ` H.J. Lu via Libc-alpha
  2020-04-29 14:55   ` Florian Weimer via Libc-alpha
  2020-04-29 14:58   ` [PATCH 2/2] Add C wrappers for prctl/process_vm_readv/process_vm_writev " Florian Weimer via Libc-alpha
  2020-04-29 14:57 ` [PATCH 1/2] Mark unsigned long arguments with U in more syscalls " Florian Weimer via Libc-alpha
  1 sibling, 2 replies; 19+ messages in thread
From: H.J. Lu via Libc-alpha @ 2020-04-29 14:47 UTC (permalink / raw
  To: libc-alpha

Since the the U marker can only be applied to 2 unsigned long arguments,
add a C wrapper for prctl, process_vm_readv and process_vm_writev syscals
which have more than 2 unsigned long arguments.
---
 sysdeps/unix/sysv/linux/Makefile            |  3 +-
 sysdeps/unix/sysv/linux/prctl.c             | 39 +++++++++++++++++++++
 sysdeps/unix/sysv/linux/process_vm_readv.c  | 32 +++++++++++++++++
 sysdeps/unix/sysv/linux/process_vm_writev.c | 32 +++++++++++++++++
 sysdeps/unix/sysv/linux/syscalls.list       |  3 --
 5 files changed, 105 insertions(+), 4 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/prctl.c
 create mode 100644 sysdeps/unix/sysv/linux/process_vm_readv.c
 create mode 100644 sysdeps/unix/sysv/linux/process_vm_writev.c

diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 089a4899d5..1d9a8d3cdb 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -59,7 +59,8 @@ sysdep_routines += adjtimex clone umount umount2 readahead sysctl \
 		   eventfd eventfd_read eventfd_write prlimit \
 		   personality epoll_wait tee vmsplice splice \
 		   open_by_handle_at mlock2 pkey_mprotect pkey_set pkey_get \
-		   timerfd_gettime timerfd_settime
+		   timerfd_gettime timerfd_settime prctl \
+		   process_vm_readv process_vm_writev
 
 CFLAGS-gethostid.c = -fexceptions
 CFLAGS-tee.c = -fexceptions -fasynchronous-unwind-tables
diff --git a/sysdeps/unix/sysv/linux/prctl.c b/sysdeps/unix/sysv/linux/prctl.c
new file mode 100644
index 0000000000..e0e5ef4e47
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/prctl.c
@@ -0,0 +1,39 @@
+/* prctl - Linux specific syscall.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <unistd.h>
+#include <sysdep.h>
+#include <errno.h>
+
+extern int prctl (int, unsigned long, unsigned long, unsigned long,
+		  unsigned long);
+hidden_proto (prctl)
+extern int __prctl (int, unsigned long, unsigned long, unsigned long,
+		    unsigned long);
+hidden_proto (__prctl)
+
+int
+__prctl (int option, unsigned long arg2, unsigned long arg3,
+	 unsigned long arg4, unsigned long arg5)
+{
+  return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5);
+}
+
+hidden_def (__prctl)
+weak_alias (__prctl, prctl)
+hidden_weak (prctl)
diff --git a/sysdeps/unix/sysv/linux/process_vm_readv.c b/sysdeps/unix/sysv/linux/process_vm_readv.c
new file mode 100644
index 0000000000..1e711abe43
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/process_vm_readv.c
@@ -0,0 +1,32 @@
+/* process_vm_readv - Linux specific syscall.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <unistd.h>
+#include <sysdep.h>
+#include <errno.h>
+#include <sys/uio.h>
+
+ssize_t
+process_vm_readv (pid_t pid, const struct iovec *local_iov,
+		  unsigned long liovcnt, const struct iovec *remote_iov,
+		  unsigned long riovcnt, unsigned long flags)
+{
+  return INLINE_SYSCALL_CALL (process_vm_readv, pid, local_iov,
+			      liovcnt, remote_iov, riovcnt, flags);
+}
+
diff --git a/sysdeps/unix/sysv/linux/process_vm_writev.c b/sysdeps/unix/sysv/linux/process_vm_writev.c
new file mode 100644
index 0000000000..e41058750b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/process_vm_writev.c
@@ -0,0 +1,32 @@
+/* process_vm_writev - Linux specific syscall.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <unistd.h>
+#include <sysdep.h>
+#include <errno.h>
+#include <sys/uio.h>
+
+ssize_t
+process_vm_writev (pid_t pid, const struct iovec *local_iov,
+		   unsigned long liovcnt, const struct iovec *remote_iov,
+		   unsigned long riovcnt, unsigned long flags)
+{
+  return INLINE_SYSCALL_CALL (process_vm_writev, pid, local_iov,
+			      liovcnt, remote_iov, riovcnt, flags);
+}
+
diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list
index 5b4e205934..1d8893d1b8 100644
--- a/sysdeps/unix/sysv/linux/syscalls.list
+++ b/sysdeps/unix/sysv/linux/syscalls.list
@@ -43,7 +43,6 @@ nfsservctl	EXTRA	nfsservctl	i:ipp	__compat_nfsservctl	nfsservctl@GLIBC_2.0:GLIBC
 pipe		-	pipe		i:f	__pipe		pipe
 pipe2		-	pipe2		i:fi	__pipe2		pipe2
 pivot_root	EXTRA	pivot_root	i:ss	pivot_root
-prctl		EXTRA	prctl		i:iiiii	__prctl		prctl
 query_module	EXTRA	query_module	i:sipip	__compat_query_module	query_module@GLIBC_2.0:GLIBC_2.23
 quotactl	EXTRA	quotactl	i:isip	quotactl
 remap_file_pages -	remap_file_pages i:pUiUi	__remap_file_pages remap_file_pages
@@ -98,8 +97,6 @@ name_to_handle_at EXTRA	name_to_handle_at i:isppi name_to_handle_at
 
 setns		EXTRA	setns		i:ii	setns
 
-process_vm_readv EXTRA	process_vm_readv i:ipipii process_vm_readv
-process_vm_writev EXTRA	process_vm_writev i:ipipii process_vm_writev
 memfd_create    EXTRA	memfd_create	i:si    memfd_create
 pkey_alloc	EXTRA	pkey_alloc	i:ii	pkey_alloc
 pkey_free	EXTRA	pkey_free	i:i	pkey_free
-- 
2.25.4


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

* Re: [PATCH 2/2] Add C wrappers for prctl/process_vm_readv/process_vm_writev [BZ #25810]
  2020-04-29 14:47 ` [PATCH 2/2] Add C wrappers for prctl/process_vm_readv/process_vm_writev " H.J. Lu via Libc-alpha
@ 2020-04-29 14:55   ` Florian Weimer via Libc-alpha
  2020-04-29 15:20     ` V2 " H.J. Lu via Libc-alpha
  2020-04-29 14:58   ` [PATCH 2/2] Add C wrappers for prctl/process_vm_readv/process_vm_writev " Florian Weimer via Libc-alpha
  1 sibling, 1 reply; 19+ messages in thread
From: Florian Weimer via Libc-alpha @ 2020-04-29 14:55 UTC (permalink / raw
  To: H.J. Lu; +Cc: libc-alpha

* H. J. Lu:

> diff --git a/sysdeps/unix/sysv/linux/prctl.c b/sysdeps/unix/sysv/linux/prctl.c
> new file mode 100644
> index 0000000000..e0e5ef4e47
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/prctl.c
> @@ -0,0 +1,39 @@
> +/* prctl - Linux specific syscall.
> +   Copyright (C) 2020 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <unistd.h>
> +#include <sysdep.h>
> +#include <errno.h>
> +
> +extern int prctl (int, unsigned long, unsigned long, unsigned long,
> +		  unsigned long);
> +hidden_proto (prctl)
> +extern int __prctl (int, unsigned long, unsigned long, unsigned long,
> +		    unsigned long);
> +hidden_proto (__prctl)
> +
> +int
> +__prctl (int option, unsigned long arg2, unsigned long arg3,
> +	 unsigned long arg4, unsigned long arg5)

unsigned long int everywhere.

> +{
> +  return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5);
> +}
> +
> +hidden_def (__prctl)
> +weak_alias (__prctl, prctl)
> +hidden_weak (prctl)

Can't you use libc_hidden_proto in include/sys/prctl.h and
libc_hidden_proto here?


> diff --git a/sysdeps/unix/sysv/linux/process_vm_readv.c b/sysdeps/unix/sysv/linux/process_vm_readv.c
> new file mode 100644
> index 0000000000..1e711abe43
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/process_vm_readv.c
> @@ -0,0 +1,32 @@
> +/* process_vm_readv - Linux specific syscall.
> +   Copyright (C) 2020 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <unistd.h>
> +#include <sysdep.h>
> +#include <errno.h>
> +#include <sys/uio.h>
> +
> +ssize_t
> +process_vm_readv (pid_t pid, const struct iovec *local_iov,
> +		  unsigned long liovcnt, const struct iovec *remote_iov,
> +		  unsigned long riovcnt, unsigned long flags)
> +{
> +  return INLINE_SYSCALL_CALL (process_vm_readv, pid, local_iov,
> +			      liovcnt, remote_iov, riovcnt, flags);
> +}

Likewise, unsigned long int.

> +
> diff --git a/sysdeps/unix/sysv/linux/process_vm_writev.c b/sysdeps/unix/sysv/linux/process_vm_writev.c
> new file mode 100644
> index 0000000000..e41058750b
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/process_vm_writev.c
> @@ -0,0 +1,32 @@
> +/* process_vm_writev - Linux specific syscall.
> +   Copyright (C) 2020 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <unistd.h>
> +#include <sysdep.h>
> +#include <errno.h>
> +#include <sys/uio.h>
> +
> +ssize_t
> +process_vm_writev (pid_t pid, const struct iovec *local_iov,
> +		   unsigned long liovcnt, const struct iovec *remote_iov,
> +		   unsigned long riovcnt, unsigned long flags)
> +{
> +  return INLINE_SYSCALL_CALL (process_vm_writev, pid, local_iov,
> +			      liovcnt, remote_iov, riovcnt, flags);
> +}

Likewise.

(I trust the indentation is only wrong in the patch, it's okay when
applied.)

Thanks,
Florian


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

* Re: [PATCH 1/2] Mark unsigned long arguments with U in more syscalls [BZ #25810]
  2020-04-29 14:47 [PATCH 1/2] Mark unsigned long arguments with U in more syscalls [BZ #25810] H.J. Lu via Libc-alpha
  2020-04-29 14:47 ` [PATCH 2/2] Add C wrappers for prctl/process_vm_readv/process_vm_writev " H.J. Lu via Libc-alpha
@ 2020-04-29 14:57 ` Florian Weimer via Libc-alpha
  1 sibling, 0 replies; 19+ messages in thread
From: Florian Weimer via Libc-alpha @ 2020-04-29 14:57 UTC (permalink / raw
  To: H.J. Lu; +Cc: libc-alpha

* H. J. Lu:

> Mark unsigned long arguments in mmap, read, recv, recvfrom, send, sendto,
> write, ioperm, sendfile64, setxattr, lsetxattr, fsetxattr, getxattr,
> lgetxattr, fgetxattr, listxattr, llistxattr and flistxattr with U.

This looks okay to me.

Thanks,
Florian


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

* Re: [PATCH 2/2] Add C wrappers for prctl/process_vm_readv/process_vm_writev [BZ #25810]
  2020-04-29 14:47 ` [PATCH 2/2] Add C wrappers for prctl/process_vm_readv/process_vm_writev " H.J. Lu via Libc-alpha
  2020-04-29 14:55   ` Florian Weimer via Libc-alpha
@ 2020-04-29 14:58   ` Florian Weimer via Libc-alpha
  2020-04-29 15:10     ` H.J. Lu via Libc-alpha
  1 sibling, 1 reply; 19+ messages in thread
From: Florian Weimer via Libc-alpha @ 2020-04-29 14:58 UTC (permalink / raw
  To: H.J. Lu; +Cc: libc-alpha

* H. J. Lu:

> Since the the U marker can only be applied to 2 unsigned long arguments,
> add a C wrapper for prctl, process_vm_readv and process_vm_writev syscals
> which have more than 2 unsigned long arguments.

I forgot: Please mention syscalls.list somewhere in the commit message,
so that it is clear that the U marker refers to that.

Thanks,
Florian


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

* Re: [PATCH 2/2] Add C wrappers for prctl/process_vm_readv/process_vm_writev [BZ #25810]
  2020-04-29 14:58   ` [PATCH 2/2] Add C wrappers for prctl/process_vm_readv/process_vm_writev " Florian Weimer via Libc-alpha
@ 2020-04-29 15:10     ` H.J. Lu via Libc-alpha
  2020-04-29 15:18       ` Florian Weimer via Libc-alpha
  0 siblings, 1 reply; 19+ messages in thread
From: H.J. Lu via Libc-alpha @ 2020-04-29 15:10 UTC (permalink / raw
  To: Florian Weimer; +Cc: GNU C Library

On Wed, Apr 29, 2020 at 7:58 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > Since the the U marker can only be applied to 2 unsigned long arguments,
> > add a C wrapper for prctl, process_vm_readv and process_vm_writev syscals
> > which have more than 2 unsigned long arguments.
>
> I forgot: Please mention syscalls.list somewhere in the commit message,
> so that it is clear that the U marker refers to that.
>
> Thanks,
> Florian

This is I am going to push:

commit 86f4f2263bf21ff7f80905b3062c16213b016fe6 (HEAD -> master)
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Apr 29 08:08:40 2020 -0700

    Mark unsigned long arguments with U in more syscalls [BZ #25810]

    Mark unsigned long arguments in mmap, read, recv, recvfrom, send, sendto,
    write, ioperm, sendfile64, setxattr, lsetxattr, fsetxattr, getxattr,
    lgetxattr, fgetxattr, listxattr, llistxattr and flistxattr with U in
    syscalls.list files.


-- 
H.J.

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

* Re: [PATCH 2/2] Add C wrappers for prctl/process_vm_readv/process_vm_writev [BZ #25810]
  2020-04-29 15:10     ` H.J. Lu via Libc-alpha
@ 2020-04-29 15:18       ` Florian Weimer via Libc-alpha
  2020-04-29 15:22         ` H.J. Lu via Libc-alpha
  0 siblings, 1 reply; 19+ messages in thread
From: Florian Weimer via Libc-alpha @ 2020-04-29 15:18 UTC (permalink / raw
  To: H.J. Lu; +Cc: GNU C Library

* H. J. Lu:

> On Wed, Apr 29, 2020 at 7:58 AM Florian Weimer <fweimer@redhat.com> wrote:
>>
>> * H. J. Lu:
>>
>> > Since the the U marker can only be applied to 2 unsigned long arguments,
>> > add a C wrapper for prctl, process_vm_readv and process_vm_writev syscals
>> > which have more than 2 unsigned long arguments.
>>
>> I forgot: Please mention syscalls.list somewhere in the commit message,
>> so that it is clear that the U marker refers to that.
>>
>> Thanks,
>> Florian
>
> This is I am going to push:
>
> commit 86f4f2263bf21ff7f80905b3062c16213b016fe6 (HEAD -> master)
> Author: H.J. Lu <hjl.tools@gmail.com>
> Date:   Wed Apr 29 08:08:40 2020 -0700
>
>     Mark unsigned long arguments with U in more syscalls [BZ #25810]
>
>     Mark unsigned long arguments in mmap, read, recv, recvfrom, send, sendto,
>     write, ioperm, sendfile64, setxattr, lsetxattr, fsetxattr, getxattr,
>     lgetxattr, fgetxattr, listxattr, llistxattr and flistxattr with U in
>     syscalls.list files.

This is for the other commit.  In that context, U is clear.  It is less
clear for the prctl/process_vm_readv/process_vm_writev commit.

Thanks,
Florian


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

* V2 [PATCH 2/2] Add C wrappers for prctl/process_vm_readv/process_vm_writev [BZ #25810]
  2020-04-29 14:55   ` Florian Weimer via Libc-alpha
@ 2020-04-29 15:20     ` H.J. Lu via Libc-alpha
  2020-04-29 15:22       ` Florian Weimer via Libc-alpha
  2020-04-29 15:32       ` Andreas Schwab
  0 siblings, 2 replies; 19+ messages in thread
From: H.J. Lu via Libc-alpha @ 2020-04-29 15:20 UTC (permalink / raw
  To: Florian Weimer; +Cc: libc-alpha

On Wed, Apr 29, 2020 at 04:55:43PM +0200, Florian Weimer wrote:
> * H. J. Lu:
> 
> > diff --git a/sysdeps/unix/sysv/linux/prctl.c b/sysdeps/unix/sysv/linux/prctl.c
> > new file mode 100644
> > index 0000000000..e0e5ef4e47
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/prctl.c
> > @@ -0,0 +1,39 @@
> > +/* prctl - Linux specific syscall.
> > +   Copyright (C) 2020 Free Software Foundation, Inc.
> > +   This file is part of the GNU C Library.
> > +
> > +   The GNU C Library is free software; you can redistribute it and/or
> > +   modify it under the terms of the GNU Lesser General Public
> > +   License as published by the Free Software Foundation; either
> > +   version 2.1 of the License, or (at your option) any later version.
> > +
> > +   The GNU C Library is distributed in the hope that it will be useful,
> > +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> > +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> > +   Lesser General Public License for more details.
> > +
> > +   You should have received a copy of the GNU Lesser General Public
> > +   License along with the GNU C Library; if not, see
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#include <unistd.h>
> > +#include <sysdep.h>
> > +#include <errno.h>
> > +
> > +extern int prctl (int, unsigned long, unsigned long, unsigned long,
> > +		  unsigned long);
> > +hidden_proto (prctl)
> > +extern int __prctl (int, unsigned long, unsigned long, unsigned long,
> > +		    unsigned long);
> > +hidden_proto (__prctl)
> > +
> > +int
> > +__prctl (int option, unsigned long arg2, unsigned long arg3,
> > +	 unsigned long arg4, unsigned long arg5)
> 
> unsigned long int everywhere.

Fixed.

> 
> > +{
> > +  return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5);
> > +}
> > +
> > +hidden_def (__prctl)
> > +weak_alias (__prctl, prctl)
> > +hidden_weak (prctl)
> 
> Can't you use libc_hidden_proto in include/sys/prctl.h and
> libc_hidden_proto here?
> 

Since include/sys/prctl.h has

extern int __prctl (int __option, ...);

it can't be used.

> 
> > diff --git a/sysdeps/unix/sysv/linux/process_vm_readv.c b/sysdeps/unix/sysv/linux/process_vm_readv.c
> > new file mode 100644
> > index 0000000000..1e711abe43
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/process_vm_readv.c
> > @@ -0,0 +1,32 @@
> > +/* process_vm_readv - Linux specific syscall.
> > +   Copyright (C) 2020 Free Software Foundation, Inc.
> > +   This file is part of the GNU C Library.
> > +
> > +   The GNU C Library is free software; you can redistribute it and/or
> > +   modify it under the terms of the GNU Lesser General Public
> > +   License as published by the Free Software Foundation; either
> > +   version 2.1 of the License, or (at your option) any later version.
> > +
> > +   The GNU C Library is distributed in the hope that it will be useful,
> > +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> > +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> > +   Lesser General Public License for more details.
> > +
> > +   You should have received a copy of the GNU Lesser General Public
> > +   License along with the GNU C Library; if not, see
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#include <unistd.h>
> > +#include <sysdep.h>
> > +#include <errno.h>
> > +#include <sys/uio.h>
> > +
> > +ssize_t
> > +process_vm_readv (pid_t pid, const struct iovec *local_iov,
> > +		  unsigned long liovcnt, const struct iovec *remote_iov,
> > +		  unsigned long riovcnt, unsigned long flags)
> > +{
> > +  return INLINE_SYSCALL_CALL (process_vm_readv, pid, local_iov,
> > +			      liovcnt, remote_iov, riovcnt, flags);
> > +}
> 
> Likewise, unsigned long int.

Fixed.
 
> > +
> > diff --git a/sysdeps/unix/sysv/linux/process_vm_writev.c b/sysdeps/unix/sysv/linux/process_vm_writev.c
> > new file mode 100644
> > index 0000000000..e41058750b
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/process_vm_writev.c
> > @@ -0,0 +1,32 @@
> > +/* process_vm_writev - Linux specific syscall.
> > +   Copyright (C) 2020 Free Software Foundation, Inc.
> > +   This file is part of the GNU C Library.
> > +
> > +   The GNU C Library is free software; you can redistribute it and/or
> > +   modify it under the terms of the GNU Lesser General Public
> > +   License as published by the Free Software Foundation; either
> > +   version 2.1 of the License, or (at your option) any later version.
> > +
> > +   The GNU C Library is distributed in the hope that it will be useful,
> > +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> > +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> > +   Lesser General Public License for more details.
> > +
> > +   You should have received a copy of the GNU Lesser General Public
> > +   License along with the GNU C Library; if not, see
> > +   <https://www.gnu.org/licenses/>.  */
> > +
> > +#include <unistd.h>
> > +#include <sysdep.h>
> > +#include <errno.h>
> > +#include <sys/uio.h>
> > +
> > +ssize_t
> > +process_vm_writev (pid_t pid, const struct iovec *local_iov,
> > +		   unsigned long liovcnt, const struct iovec *remote_iov,
> > +		   unsigned long riovcnt, unsigned long flags)
> > +{
> > +  return INLINE_SYSCALL_CALL (process_vm_writev, pid, local_iov,
> > +			      liovcnt, remote_iov, riovcnt, flags);
> > +}
> 
> Likewise.

Fixed.

> 
> (I trust the indentation is only wrong in the patch, it's okay when
> applied.)
> 

It is due to spaces vs tab.  The indentation is OK.

Ok for master?

Thanks.

H.J.
---
Since the the U marker can only be applied to 2 unsigned long arguments,
add a C wrapper for prctl, process_vm_readv and process_vm_writev syscals
which have more than 2 unsigned long arguments.
---
 sysdeps/unix/sysv/linux/Makefile            |  3 +-
 sysdeps/unix/sysv/linux/prctl.c             | 39 +++++++++++++++++++++
 sysdeps/unix/sysv/linux/process_vm_readv.c  | 33 +++++++++++++++++
 sysdeps/unix/sysv/linux/process_vm_writev.c | 33 +++++++++++++++++
 sysdeps/unix/sysv/linux/syscalls.list       |  3 --
 5 files changed, 107 insertions(+), 4 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/prctl.c
 create mode 100644 sysdeps/unix/sysv/linux/process_vm_readv.c
 create mode 100644 sysdeps/unix/sysv/linux/process_vm_writev.c

diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 089a4899d5..1d9a8d3cdb 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -59,7 +59,8 @@ sysdep_routines += adjtimex clone umount umount2 readahead sysctl \
 		   eventfd eventfd_read eventfd_write prlimit \
 		   personality epoll_wait tee vmsplice splice \
 		   open_by_handle_at mlock2 pkey_mprotect pkey_set pkey_get \
-		   timerfd_gettime timerfd_settime
+		   timerfd_gettime timerfd_settime prctl \
+		   process_vm_readv process_vm_writev
 
 CFLAGS-gethostid.c = -fexceptions
 CFLAGS-tee.c = -fexceptions -fasynchronous-unwind-tables
diff --git a/sysdeps/unix/sysv/linux/prctl.c b/sysdeps/unix/sysv/linux/prctl.c
new file mode 100644
index 0000000000..6a9c1a8fbf
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/prctl.c
@@ -0,0 +1,39 @@
+/* prctl - Linux specific syscall.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <unistd.h>
+#include <sysdep.h>
+#include <errno.h>
+
+extern int prctl (int, unsigned long int, unsigned long int,
+		  unsigned long int, unsigned long int);
+hidden_proto (prctl)
+extern int __prctl (int, unsigned long int, unsigned long int,
+		    unsigned long int, unsigned long int);
+hidden_proto (__prctl)
+
+int
+__prctl (int option, unsigned long int arg2, unsigned long int arg3,
+	 unsigned long int arg4, unsigned long int arg5)
+{
+  return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5);
+}
+
+hidden_def (__prctl)
+weak_alias (__prctl, prctl)
+hidden_weak (prctl)
diff --git a/sysdeps/unix/sysv/linux/process_vm_readv.c b/sysdeps/unix/sysv/linux/process_vm_readv.c
new file mode 100644
index 0000000000..dca826b679
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/process_vm_readv.c
@@ -0,0 +1,33 @@
+/* process_vm_readv - Linux specific syscall.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <unistd.h>
+#include <sysdep.h>
+#include <errno.h>
+#include <sys/uio.h>
+
+ssize_t
+process_vm_readv (pid_t pid, const struct iovec *local_iov,
+		  unsigned long int liovcnt,
+		  const struct iovec *remote_iov,
+		  unsigned long int riovcnt, unsigned long int flags)
+{
+  return INLINE_SYSCALL_CALL (process_vm_readv, pid, local_iov,
+			      liovcnt, remote_iov, riovcnt, flags);
+}
+
diff --git a/sysdeps/unix/sysv/linux/process_vm_writev.c b/sysdeps/unix/sysv/linux/process_vm_writev.c
new file mode 100644
index 0000000000..15748451aa
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/process_vm_writev.c
@@ -0,0 +1,33 @@
+/* process_vm_writev - Linux specific syscall.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <unistd.h>
+#include <sysdep.h>
+#include <errno.h>
+#include <sys/uio.h>
+
+ssize_t
+process_vm_writev (pid_t pid, const struct iovec *local_iov,
+		   unsigned long int liovcnt,
+		   const struct iovec *remote_iov,
+		   unsigned long int riovcnt, unsigned long int flags)
+{
+  return INLINE_SYSCALL_CALL (process_vm_writev, pid, local_iov,
+			      liovcnt, remote_iov, riovcnt, flags);
+}
+
diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list
index 5b4e205934..1d8893d1b8 100644
--- a/sysdeps/unix/sysv/linux/syscalls.list
+++ b/sysdeps/unix/sysv/linux/syscalls.list
@@ -43,7 +43,6 @@ nfsservctl	EXTRA	nfsservctl	i:ipp	__compat_nfsservctl	nfsservctl@GLIBC_2.0:GLIBC
 pipe		-	pipe		i:f	__pipe		pipe
 pipe2		-	pipe2		i:fi	__pipe2		pipe2
 pivot_root	EXTRA	pivot_root	i:ss	pivot_root
-prctl		EXTRA	prctl		i:iiiii	__prctl		prctl
 query_module	EXTRA	query_module	i:sipip	__compat_query_module	query_module@GLIBC_2.0:GLIBC_2.23
 quotactl	EXTRA	quotactl	i:isip	quotactl
 remap_file_pages -	remap_file_pages i:pUiUi	__remap_file_pages remap_file_pages
@@ -98,8 +97,6 @@ name_to_handle_at EXTRA	name_to_handle_at i:isppi name_to_handle_at
 
 setns		EXTRA	setns		i:ii	setns
 
-process_vm_readv EXTRA	process_vm_readv i:ipipii process_vm_readv
-process_vm_writev EXTRA	process_vm_writev i:ipipii process_vm_writev
 memfd_create    EXTRA	memfd_create	i:si    memfd_create
 pkey_alloc	EXTRA	pkey_alloc	i:ii	pkey_alloc
 pkey_free	EXTRA	pkey_free	i:i	pkey_free
-- 
2.25.4


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

* Re: V2 [PATCH 2/2] Add C wrappers for prctl/process_vm_readv/process_vm_writev [BZ #25810]
  2020-04-29 15:20     ` V2 " H.J. Lu via Libc-alpha
@ 2020-04-29 15:22       ` Florian Weimer via Libc-alpha
  2020-04-29 15:29         ` H.J. Lu via Libc-alpha
  2020-04-29 15:32       ` Andreas Schwab
  1 sibling, 1 reply; 19+ messages in thread
From: Florian Weimer via Libc-alpha @ 2020-04-29 15:22 UTC (permalink / raw
  To: H.J. Lu; +Cc: libc-alpha

* H. J. Lu:

>> > +{
>> > +  return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5);
>> > +}
>> > +
>> > +hidden_def (__prctl)
>> > +weak_alias (__prctl, prctl)
>> > +hidden_weak (prctl)
>> 
>> Can't you use libc_hidden_proto in include/sys/prctl.h and
>> libc_hidden_proto here?
>> 
>
> Since include/sys/prctl.h has
>
> extern int __prctl (int __option, ...);
>
> it can't be used.

I still don't get it.  What happens if you use libc_hidden_proto and
libc_hidden_def?

> Since the the U marker can only be applied to 2 unsigned long arguments,
> add a C wrapper for prctl, process_vm_readv and process_vm_writev syscals
> which have more than 2 unsigned long arguments.

Please add that syscalls.list reference.  Thanks.

Florian


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

* Re: [PATCH 2/2] Add C wrappers for prctl/process_vm_readv/process_vm_writev [BZ #25810]
  2020-04-29 15:18       ` Florian Weimer via Libc-alpha
@ 2020-04-29 15:22         ` H.J. Lu via Libc-alpha
  2020-04-29 15:25           ` Florian Weimer via Libc-alpha
  0 siblings, 1 reply; 19+ messages in thread
From: H.J. Lu via Libc-alpha @ 2020-04-29 15:22 UTC (permalink / raw
  To: Florian Weimer; +Cc: GNU C Library

On Wed, Apr 29, 2020 at 8:18 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > On Wed, Apr 29, 2020 at 7:58 AM Florian Weimer <fweimer@redhat.com> wrote:
> >>
> >> * H. J. Lu:
> >>
> >> > Since the the U marker can only be applied to 2 unsigned long arguments,
> >> > add a C wrapper for prctl, process_vm_readv and process_vm_writev syscals
> >> > which have more than 2 unsigned long arguments.
> >>
> >> I forgot: Please mention syscalls.list somewhere in the commit message,
> >> so that it is clear that the U marker refers to that.
> >>
> >> Thanks,
> >> Florian
> >
> > This is I am going to push:
> >
> > commit 86f4f2263bf21ff7f80905b3062c16213b016fe6 (HEAD -> master)
> > Author: H.J. Lu <hjl.tools@gmail.com>
> > Date:   Wed Apr 29 08:08:40 2020 -0700
> >
> >     Mark unsigned long arguments with U in more syscalls [BZ #25810]
> >
> >     Mark unsigned long arguments in mmap, read, recv, recvfrom, send, sendto,
> >     write, ioperm, sendfile64, setxattr, lsetxattr, fsetxattr, getxattr,
> >     lgetxattr, fgetxattr, listxattr, llistxattr and flistxattr with U in
> >     syscalls.list files.
>
> This is for the other commit.  In that context, U is clear.  It is less
> clear for the prctl/process_vm_readv/process_vm_writev commit.

How about

Since the the U marker can only be applied to 2 unsigned long arguments
in syscalls.list files, add a C wrapper for prctl, process_vm_readv and
process_vm_writev syscals which have more than 2 unsigned long arguments.


-- 
H.J.

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

* Re: [PATCH 2/2] Add C wrappers for prctl/process_vm_readv/process_vm_writev [BZ #25810]
  2020-04-29 15:22         ` H.J. Lu via Libc-alpha
@ 2020-04-29 15:25           ` Florian Weimer via Libc-alpha
  0 siblings, 0 replies; 19+ messages in thread
From: Florian Weimer via Libc-alpha @ 2020-04-29 15:25 UTC (permalink / raw
  To: H.J. Lu; +Cc: GNU C Library

* H. J. Lu:

> Since the the U marker can only be applied to 2 unsigned long arguments
> in syscalls.list files, add a C wrapper for prctl, process_vm_readv and
> process_vm_writev syscals which have more than 2 unsigned long
> arguments.

Yes, that's fine.  Thanks.

Florian


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

* Re: V2 [PATCH 2/2] Add C wrappers for prctl/process_vm_readv/process_vm_writev [BZ #25810]
  2020-04-29 15:22       ` Florian Weimer via Libc-alpha
@ 2020-04-29 15:29         ` H.J. Lu via Libc-alpha
  2020-04-29 15:35           ` Florian Weimer via Libc-alpha
  0 siblings, 1 reply; 19+ messages in thread
From: H.J. Lu via Libc-alpha @ 2020-04-29 15:29 UTC (permalink / raw
  To: Florian Weimer; +Cc: GNU C Library

On Wed, Apr 29, 2020 at 8:22 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> >> > +{
> >> > +  return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5);
> >> > +}
> >> > +
> >> > +hidden_def (__prctl)
> >> > +weak_alias (__prctl, prctl)
> >> > +hidden_weak (prctl)
> >>
> >> Can't you use libc_hidden_proto in include/sys/prctl.h and
> >> libc_hidden_proto here?
> >>
> >
> > Since include/sys/prctl.h has
> >
> > extern int __prctl (int __option, ...);
> >
> > it can't be used.
>
> I still don't get it.  What happens if you use libc_hidden_proto and
> libc_hidden_def?

With

extern int __prctl (int __option, ...);
libc_hidden_proto (__prctl)
libc_hidden_proto (prctl)

and

#include <unistd.h>
#include <sysdep.h>
#include <errno.h>
#include <sys/prctl.h>

int
__prctl (int option, unsigned long int arg2, unsigned long int arg3,
unsigned long int arg4, unsigned long int arg5)
{
  return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5);
}

libc_hidden_def (__prctl)
weak_alias (__prctl, prctl)
hidden_weak (prctl)

I got

../sysdeps/unix/sysv/linux/prctl.c:25:1: error: conflicting types for ‘__prctl’
   25 | __prctl (int option, unsigned long int arg2, unsigned long int arg3,
      | ^~~~~~~
In file included from <command-line>:
../include/sys/prctl.h:7:20: note: previous declaration of ‘__prctl’ was here
    7 | libc_hidden_proto (__prctl)
      |                    ^~~~~~~
./../include/libc-symbols.h:541:33: note: in definition of macro
‘__hidden_proto’
  541 |   extern thread __typeof (name) name __asm__ (__hidden_asmname
(#internal)) \
      |                                 ^~~~
./../include/libc-symbols.h:624:44: note: in expansion of macro ‘hidden_proto’
  624 | # define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
      |                                            ^~~~~~~~~~~~
../include/sys/prctl.h:7:1: note: in expansion of macro ‘libc_hidden_proto’
    7 | libc_hidden_proto (__prctl)
      | ^~~~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/prctl.c:32:22: error: conflicting types for ‘prctl’
   32 | weak_alias (__prctl, prctl)
      |                      ^~~~~
./../include/libc-symbols.h:152:26: note: in definition of macro ‘_weak_alias’
  152 |   extern __typeof (name) aliasname __attribute__ ((weak, alias
(#name))) \
      |                          ^~~~~~~~~
../sysdeps/unix/sysv/linux/prctl.c:32:1: note: in expansion of macro
‘weak_alias’
   32 | weak_alias (__prctl, prctl)
      | ^~~~~~~~~~
../include/sys/prctl.h:8:20: note: previous declaration of ‘prctl’ was here
    8 | libc_hidden_proto (prctl)
      |                    ^~~~~
./../include/libc-symbols.h:541:33: note: in definition of macro
‘__hidden_proto’
  541 |   extern thread __typeof (name) name __asm__ (__hidden_asmname
(#internal)) \
      |                                 ^~~~
./../include/libc-symbols.h:624:44: note: in expansion of macro ‘hidden_proto’
  624 | # define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
      |                                            ^~~~~~~~~~~~
../include/sys/prctl.h:8:1: note: in expansion of macro ‘libc_hidden_proto’
    8 | libc_hidden_proto (prctl)
      | ^~~~~~~~~~~~~~~~~
./../include/libc-symbols.h:552:33: error: ‘__EI___prctl’ aliased to
undefined symbol ‘__GI___prctl’
  552 |   extern thread __typeof (name) __EI_##name \
      |                                 ^~~~~
./../include/libc-symbols.h:548:3: note: in expansion of macro ‘__hidden_ver2’
  548 |   __hidden_ver2 (, local, internal, name)
      |   ^~~~~~~~~~~~~
./../include/libc-symbols.h:557:29: note: in expansion of macro ‘__hidden_ver1’
  557 | #  define hidden_def(name)  __hidden_ver1(__GI_##name, name, name);
      |                             ^~~~~~~~~~~~~
./../include/libc-symbols.h:626:32: note: in expansion of macro ‘hidden_def’
  626 | # define libc_hidden_def(name) hidden_def (name)
      |                                ^~~~~~~~~~
../sysdeps/unix/sysv/linux/prctl.c:31:1: note: in expansion of macro
‘libc_hidden_def’
   31 | libc_hidden_def (__prctl)
      | ^~~~~~~~~~~~~~~
./../include/libc-symbols.h:552:33: error: ‘__EI_prctl’ aliased to
undefined symbol ‘__GI_prctl’
  552 |   extern thread __typeof (name) __EI_##name \
      |                                 ^~~~~
./../include/libc-symbols.h:548:3: note: in expansion of macro ‘__hidden_ver2’
  548 |   __hidden_ver2 (, local, internal, name)
      |   ^~~~~~~~~~~~~
./../include/libc-symbols.h:562:2: note: in expansion of macro ‘__hidden_ver1’
  562 |  __hidden_ver1(__GI_##name, name, name) __attribute__((weak));
      |  ^~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/prctl.c:33:1: note: in expansion of macro
‘hidden_weak’
   33 | hidden_weak (prctl)
      | ^~~~~~~~~~~

> > Since the the U marker can only be applied to 2 unsigned long arguments,
> > add a C wrapper for prctl, process_vm_readv and process_vm_writev syscals
> > which have more than 2 unsigned long arguments.
>
> Please add that syscalls.list reference.  Thanks.
>

I have

---
Since the the U marker can only be applied to 2 unsigned long arguments
in syscalls.list files, add a C wrapper for prctl, process_vm_readv and
process_vm_writev syscals which have more than 2 unsigned long arguments.
---

-- 
H.J.

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

* Re: V2 [PATCH 2/2] Add C wrappers for prctl/process_vm_readv/process_vm_writev [BZ #25810]
  2020-04-29 15:20     ` V2 " H.J. Lu via Libc-alpha
  2020-04-29 15:22       ` Florian Weimer via Libc-alpha
@ 2020-04-29 15:32       ` Andreas Schwab
  2020-04-29 15:36         ` H.J. Lu via Libc-alpha
  1 sibling, 1 reply; 19+ messages in thread
From: Andreas Schwab @ 2020-04-29 15:32 UTC (permalink / raw
  To: H.J. Lu via Libc-alpha; +Cc: Florian Weimer

On Apr 29 2020, H.J. Lu via Libc-alpha wrote:

>> > +int
>> > +__prctl (int option, unsigned long arg2, unsigned long arg3,
>> > +	 unsigned long arg4, unsigned long arg5)
>> 
>> unsigned long int everywhere.
>
> Fixed.
>
>> 
>> > +{
>> > +  return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5);
>> > +}
>> > +
>> > +hidden_def (__prctl)
>> > +weak_alias (__prctl, prctl)
>> > +hidden_weak (prctl)
>> 
>> Can't you use libc_hidden_proto in include/sys/prctl.h and
>> libc_hidden_proto here?
>> 
>
> Since include/sys/prctl.h has
>
> extern int __prctl (int __option, ...);
>
> it can't be used.

You cannot implement a function declared as varargs with a non-varargs
definition.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

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

* Re: V2 [PATCH 2/2] Add C wrappers for prctl/process_vm_readv/process_vm_writev [BZ #25810]
  2020-04-29 15:29         ` H.J. Lu via Libc-alpha
@ 2020-04-29 15:35           ` Florian Weimer via Libc-alpha
  2020-04-29 15:41             ` Florian Weimer via Libc-alpha
  0 siblings, 1 reply; 19+ messages in thread
From: Florian Weimer via Libc-alpha @ 2020-04-29 15:35 UTC (permalink / raw
  To: H.J. Lu; +Cc: GNU C Library

* H. J. Lu:

> With
>
> extern int __prctl (int __option, ...);
> libc_hidden_proto (__prctl)
> libc_hidden_proto (prctl)
>
> and
>
> #include <unistd.h>
> #include <sysdep.h>
> #include <errno.h>
> #include <sys/prctl.h>
>
> int
> __prctl (int option, unsigned long int arg2, unsigned long int arg3,
> unsigned long int arg4, unsigned long int arg5)
> {
>   return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5);
> }
>
> libc_hidden_def (__prctl)
> weak_alias (__prctl, prctl)
> hidden_weak (prctl)

Please try:

extern int __prctl (int __option, ...);
libc_hidden_proto (__prctl)

And:

int
__prctl (int option, unsigned long int arg2, unsigned long int arg3,
unsigned long int arg4, unsigned long int arg5)
{
  return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5);
}
libc_hidden_def (__prctl)
strong_alias (__prctl, prctl)

Internal users should always use __prctl to avoid linknamespace
failures, so there are no callers of prctl and we don't need a hidden
alias for it.

>> > Since the the U marker can only be applied to 2 unsigned long arguments,
>> > add a C wrapper for prctl, process_vm_readv and process_vm_writev syscals
>> > which have more than 2 unsigned long arguments.
>>
>> Please add that syscalls.list reference.  Thanks.
>>
>
> I have
>
> ---
> Since the the U marker can only be applied to 2 unsigned long arguments
> in syscalls.list files, add a C wrapper for prctl, process_vm_readv and
> process_vm_writev syscals which have more than 2 unsigned long arguments.
> ---

Nice.

Thanks,
Florian


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

* Re: V2 [PATCH 2/2] Add C wrappers for prctl/process_vm_readv/process_vm_writev [BZ #25810]
  2020-04-29 15:32       ` Andreas Schwab
@ 2020-04-29 15:36         ` H.J. Lu via Libc-alpha
  2020-04-29 15:43           ` Florian Weimer via Libc-alpha
  0 siblings, 1 reply; 19+ messages in thread
From: H.J. Lu via Libc-alpha @ 2020-04-29 15:36 UTC (permalink / raw
  To: Andreas Schwab; +Cc: Florian Weimer, H.J. Lu via Libc-alpha

On Wed, Apr 29, 2020 at 8:32 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
>
> On Apr 29 2020, H.J. Lu via Libc-alpha wrote:
>
> >> > +int
> >> > +__prctl (int option, unsigned long arg2, unsigned long arg3,
> >> > +   unsigned long arg4, unsigned long arg5)
> >>
> >> unsigned long int everywhere.
> >
> > Fixed.
> >
> >>
> >> > +{
> >> > +  return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5);
> >> > +}
> >> > +
> >> > +hidden_def (__prctl)
> >> > +weak_alias (__prctl, prctl)
> >> > +hidden_weak (prctl)
> >>
> >> Can't you use libc_hidden_proto in include/sys/prctl.h and
> >> libc_hidden_proto here?
> >>
> >
> > Since include/sys/prctl.h has
> >
> > extern int __prctl (int __option, ...);
> >
> > it can't be used.
>
> You cannot implement a function declared as varargs with a non-varargs
> definition.

True.  There is a separate bug:

https://sourceware.org/bugzilla/show_bug.cgi?id=25896

-- 
H.J.

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

* Re: V2 [PATCH 2/2] Add C wrappers for prctl/process_vm_readv/process_vm_writev [BZ #25810]
  2020-04-29 15:35           ` Florian Weimer via Libc-alpha
@ 2020-04-29 15:41             ` Florian Weimer via Libc-alpha
  0 siblings, 0 replies; 19+ messages in thread
From: Florian Weimer via Libc-alpha @ 2020-04-29 15:41 UTC (permalink / raw
  To: H.J. Lu; +Cc: GNU C Library

* Florian Weimer:

>> extern int __prctl (int __option, ...);
>> libc_hidden_proto (__prctl)
>> libc_hidden_proto (prctl)
>>
>> and
>>
>> #include <unistd.h>
>> #include <sysdep.h>
>> #include <errno.h>
>> #include <sys/prctl.h>
>>
>> int
>> __prctl (int option, unsigned long int arg2, unsigned long int arg3,
>> unsigned long int arg4, unsigned long int arg5)
>> {
>>   return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5);
>> }
>>
>> libc_hidden_def (__prctl)
>> weak_alias (__prctl, prctl)
>> hidden_weak (prctl)
>
> Please try:
>
> extern int __prctl (int __option, ...);
> libc_hidden_proto (__prctl)
>
> And:
>
> int
> __prctl (int option, unsigned long int arg2, unsigned long int arg3,
> unsigned long int arg4, unsigned long int arg5)
> {
>   return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5);
> }
> libc_hidden_def (__prctl)
> strong_alias (__prctl, prctl)
>
> Internal users should always use __prctl to avoid linknamespace
> failures, so there are no callers of prctl and we don't need a hidden
> alias for it.

My bad.  I see it know.  It's the variadic/non-variadic mismatch.

For the open family of functions, we actually use <stdarg.h> and try to
match the actual argument list.  This has caused bugs, so I don't
recommend it.

For fcntl, we unconditionally access the optional arguments, also with
<stdarg.h>.  This avoids the bug.  Likewise for ptrace.

I think it's safe for the ABIs we support to implement a variadic
function with a non-variadic one.  It's needed for implicit function
declaration support.  (The converse is definitely unsafe and causes
stack corruption on some targets.)

So perhaps use <stdarg.h> for prctl as well?

Thanks,
Florian


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

* Re: V2 [PATCH 2/2] Add C wrappers for prctl/process_vm_readv/process_vm_writev [BZ #25810]
  2020-04-29 15:36         ` H.J. Lu via Libc-alpha
@ 2020-04-29 15:43           ` Florian Weimer via Libc-alpha
  2020-04-29 15:52             ` Add C wrappers for process_vm_readv/process_vm_writev " H.J. Lu via Libc-alpha
  0 siblings, 1 reply; 19+ messages in thread
From: Florian Weimer via Libc-alpha @ 2020-04-29 15:43 UTC (permalink / raw
  To: H.J. Lu; +Cc: H.J. Lu via Libc-alpha, Andreas Schwab

* H. J. Lu:

> On Wed, Apr 29, 2020 at 8:32 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
>>
>> On Apr 29 2020, H.J. Lu via Libc-alpha wrote:
>>
>> >> > +int
>> >> > +__prctl (int option, unsigned long arg2, unsigned long arg3,
>> >> > +   unsigned long arg4, unsigned long arg5)
>> >>
>> >> unsigned long int everywhere.
>> >
>> > Fixed.
>> >
>> >>
>> >> > +{
>> >> > +  return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5);
>> >> > +}
>> >> > +
>> >> > +hidden_def (__prctl)
>> >> > +weak_alias (__prctl, prctl)
>> >> > +hidden_weak (prctl)
>> >>
>> >> Can't you use libc_hidden_proto in include/sys/prctl.h and
>> >> libc_hidden_proto here?
>> >>
>> >
>> > Since include/sys/prctl.h has
>> >
>> > extern int __prctl (int __option, ...);
>> >
>> > it can't be used.
>>
>> You cannot implement a function declared as varargs with a non-varargs
>> definition.
>
> True.  There is a separate bug:
>
> https://sourceware.org/bugzilla/show_bug.cgi?id=25896

I suggest to drop prctl from process_vm_*v fix and commit only the
latter now.

Thanks,
Florian


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

* Add C wrappers for process_vm_readv/process_vm_writev [BZ #25810]
  2020-04-29 15:43           ` Florian Weimer via Libc-alpha
@ 2020-04-29 15:52             ` H.J. Lu via Libc-alpha
  2020-04-29 15:55               ` Florian Weimer via Libc-alpha
  0 siblings, 1 reply; 19+ messages in thread
From: H.J. Lu via Libc-alpha @ 2020-04-29 15:52 UTC (permalink / raw
  To: Florian Weimer; +Cc: H.J. Lu via Libc-alpha, Andreas Schwab

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

On Wed, Apr 29, 2020 at 8:43 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > On Wed, Apr 29, 2020 at 8:32 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
> >>
> >> On Apr 29 2020, H.J. Lu via Libc-alpha wrote:
> >>
> >> >> > +int
> >> >> > +__prctl (int option, unsigned long arg2, unsigned long arg3,
> >> >> > +   unsigned long arg4, unsigned long arg5)
> >> >>
> >> >> unsigned long int everywhere.
> >> >
> >> > Fixed.
> >> >
> >> >>
> >> >> > +{
> >> >> > +  return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5);
> >> >> > +}
> >> >> > +
> >> >> > +hidden_def (__prctl)
> >> >> > +weak_alias (__prctl, prctl)
> >> >> > +hidden_weak (prctl)
> >> >>
> >> >> Can't you use libc_hidden_proto in include/sys/prctl.h and
> >> >> libc_hidden_proto here?
> >> >>
> >> >
> >> > Since include/sys/prctl.h has
> >> >
> >> > extern int __prctl (int __option, ...);
> >> >
> >> > it can't be used.
> >>
> >> You cannot implement a function declared as varargs with a non-varargs
> >> definition.
> >
> > True.  There is a separate bug:
> >
> > https://sourceware.org/bugzilla/show_bug.cgi?id=25896
>
> I suggest to drop prctl from process_vm_*v fix and commit only the
> latter now.
>
> Thanks,
> Florian
>

Sounds good.  I will submit a separate patch for prctl later.

This is I am going to check in.

Thanks.

-- 
H.J.

[-- Attachment #2: 0001-Add-C-wrappers-for-process_vm_readv-process_vm_write.patch --]
[-- Type: application/x-patch, Size: 5142 bytes --]

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

* Re: Add C wrappers for process_vm_readv/process_vm_writev [BZ #25810]
  2020-04-29 15:52             ` Add C wrappers for process_vm_readv/process_vm_writev " H.J. Lu via Libc-alpha
@ 2020-04-29 15:55               ` Florian Weimer via Libc-alpha
  0 siblings, 0 replies; 19+ messages in thread
From: Florian Weimer via Libc-alpha @ 2020-04-29 15:55 UTC (permalink / raw
  To: H.J. Lu; +Cc: H.J. Lu via Libc-alpha, Andreas Schwab

* H. J. Lu:

> Sounds good.  I will submit a separate patch for prctl later.
>
> This is I am going to check in.

Yes, looks good, thanks.

Florian


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

end of thread, other threads:[~2020-04-29 15:55 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-29 14:47 [PATCH 1/2] Mark unsigned long arguments with U in more syscalls [BZ #25810] H.J. Lu via Libc-alpha
2020-04-29 14:47 ` [PATCH 2/2] Add C wrappers for prctl/process_vm_readv/process_vm_writev " H.J. Lu via Libc-alpha
2020-04-29 14:55   ` Florian Weimer via Libc-alpha
2020-04-29 15:20     ` V2 " H.J. Lu via Libc-alpha
2020-04-29 15:22       ` Florian Weimer via Libc-alpha
2020-04-29 15:29         ` H.J. Lu via Libc-alpha
2020-04-29 15:35           ` Florian Weimer via Libc-alpha
2020-04-29 15:41             ` Florian Weimer via Libc-alpha
2020-04-29 15:32       ` Andreas Schwab
2020-04-29 15:36         ` H.J. Lu via Libc-alpha
2020-04-29 15:43           ` Florian Weimer via Libc-alpha
2020-04-29 15:52             ` Add C wrappers for process_vm_readv/process_vm_writev " H.J. Lu via Libc-alpha
2020-04-29 15:55               ` Florian Weimer via Libc-alpha
2020-04-29 14:58   ` [PATCH 2/2] Add C wrappers for prctl/process_vm_readv/process_vm_writev " Florian Weimer via Libc-alpha
2020-04-29 15:10     ` H.J. Lu via Libc-alpha
2020-04-29 15:18       ` Florian Weimer via Libc-alpha
2020-04-29 15:22         ` H.J. Lu via Libc-alpha
2020-04-29 15:25           ` Florian Weimer via Libc-alpha
2020-04-29 14:57 ` [PATCH 1/2] Mark unsigned long arguments with U in more syscalls " Florian Weimer via Libc-alpha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).