All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] execveat.2: Fix prototype
@ 2021-02-03 18:45 Alejandro Colomar
  2021-02-06  9:54 ` Michael Kerrisk (man-pages)
  0 siblings, 1 reply; 5+ messages in thread
From: Alejandro Colomar @ 2021-02-03 18:45 UTC (permalink / raw)
  To: mtk.manpages; +Cc: Alejandro Colomar, linux-man, David Drysdale

.../linux$ grep_syscall execveat
fs/exec.c:2062:
SYSCALL_DEFINE5(execveat,
		int, fd, const char __user *, filename,
		const char __user *const __user *, argv,
		const char __user *const __user *, envp,
		int, flags)
fs/exec.c:2083:
COMPAT_SYSCALL_DEFINE5(execveat, int, fd,
		       const char __user *, filename,
		       const compat_uptr_t __user *, argv,
		       const compat_uptr_t __user *, envp,
		       int,  flags)
include/linux/syscalls.h:980:
asmlinkage long sys_execveat(int dfd, const char __user *filename,
			const char __user *const __user *argv,
			const char __user *const __user *envp, int flags);
.../linux$

function grep_syscall()
{
	if ! [ -v 1 ]; then
		>&2 echo "Usage: ${FUNCNAME[0]} <syscall>";
		return ${EX_USAGE};
	fi

	find * -type f \
	|grep '\.c$' \
	|sort -V \
	|xargs pcregrep -Mn "(?s)^\w*SYSCALL_DEFINE.\(${1},.*?\)" \
	|sed -E 's/^[^:]+:[0-9]+:/&\n/';

	find * -type f \
	|grep '\.h$' \
	|sort -V \
	|xargs pcregrep -Mn "(?s)^asmlinkage \w+ \**sys_${1}\(.*?\)" \
	|sed -E 's/^[^:]+:[0-9]+:/&\n/';
}

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---
 man2/execveat.2 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/man2/execveat.2 b/man2/execveat.2
index 02d9c7331..d1ce4bee1 100644
--- a/man2/execveat.2
+++ b/man2/execveat.2
@@ -31,7 +31,7 @@ execveat \- execute program relative to a directory file descriptor
 .B #include <unistd.h>
 .PP
 .BI "int execveat(int " dirfd ", const char *" pathname ,
-.BI "             char *const " argv "[], char *const " envp [],
+.BI "             const char *const " argv "[], const char *const " envp [],
 .BI "             int " flags );
 .fi
 .PP
-- 
2.30.0


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

* Re: [PATCH] execveat.2: Fix prototype
  2021-02-03 18:45 [PATCH] execveat.2: Fix prototype Alejandro Colomar
@ 2021-02-06  9:54 ` Michael Kerrisk (man-pages)
  2021-02-06 11:04   ` Alejandro Colomar (man-pages)
  2021-02-07 11:43   ` [PATCH v2] " Alejandro Colomar
  0 siblings, 2 replies; 5+ messages in thread
From: Michael Kerrisk (man-pages) @ 2021-02-06  9:54 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: linux-man, David Drysdale

Hi Alex,

Can we please begin every commit message with some English sentences :-).

I'm a little hesitant about the proposed change. execve() has a
similar prototype in the kernel, but the glibc wrapper is just:

extern int execve (const char *__path, char *const __argv[],
                   char *const __envp[]) ;

I expect that one day when execveat() is added to glibc, it will be
the same. What do you think?

Thanks,

Michael

On Wed, 3 Feb 2021 at 19:46, Alejandro Colomar <alx.manpages@gmail.com> wrote:
>
> .../linux$ grep_syscall execveat
> fs/exec.c:2062:
> SYSCALL_DEFINE5(execveat,
>                 int, fd, const char __user *, filename,
>                 const char __user *const __user *, argv,
>                 const char __user *const __user *, envp,
>                 int, flags)
> fs/exec.c:2083:
> COMPAT_SYSCALL_DEFINE5(execveat, int, fd,
>                        const char __user *, filename,
>                        const compat_uptr_t __user *, argv,
>                        const compat_uptr_t __user *, envp,
>                        int,  flags)
> include/linux/syscalls.h:980:
> asmlinkage long sys_execveat(int dfd, const char __user *filename,
>                         const char __user *const __user *argv,
>                         const char __user *const __user *envp, int flags);
> .../linux$
>
> function grep_syscall()
> {
>         if ! [ -v 1 ]; then
>                 >&2 echo "Usage: ${FUNCNAME[0]} <syscall>";
>                 return ${EX_USAGE};
>         fi
>
>         find * -type f \
>         |grep '\.c$' \
>         |sort -V \
>         |xargs pcregrep -Mn "(?s)^\w*SYSCALL_DEFINE.\(${1},.*?\)" \
>         |sed -E 's/^[^:]+:[0-9]+:/&\n/';
>
>         find * -type f \
>         |grep '\.h$' \
>         |sort -V \
>         |xargs pcregrep -Mn "(?s)^asmlinkage \w+ \**sys_${1}\(.*?\)" \
>         |sed -E 's/^[^:]+:[0-9]+:/&\n/';
> }
>
> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
> ---
>  man2/execveat.2 | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/man2/execveat.2 b/man2/execveat.2
> index 02d9c7331..d1ce4bee1 100644
> --- a/man2/execveat.2
> +++ b/man2/execveat.2
> @@ -31,7 +31,7 @@ execveat \- execute program relative to a directory file descriptor
>  .B #include <unistd.h>
>  .PP
>  .BI "int execveat(int " dirfd ", const char *" pathname ,
> -.BI "             char *const " argv "[], char *const " envp [],
> +.BI "             const char *const " argv "[], const char *const " envp [],
>  .BI "             int " flags );
>  .fi
>  .PP
> --
> 2.30.0
>


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

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

* Re: [PATCH] execveat.2: Fix prototype
  2021-02-06  9:54 ` Michael Kerrisk (man-pages)
@ 2021-02-06 11:04   ` Alejandro Colomar (man-pages)
  2021-02-07 11:43   ` [PATCH v2] " Alejandro Colomar
  1 sibling, 0 replies; 5+ messages in thread
From: Alejandro Colomar (man-pages) @ 2021-02-06 11:04 UTC (permalink / raw)
  To: mtk.manpages; +Cc: linux-man, David Drysdale

On 2/6/21 10:54 AM, Michael Kerrisk (man-pages) wrote:
> Hi Alex,
> 
> Can we please begin every commit message with some English sentences :-).

Sure! Thanks for the reminder! :-)

> 
> I'm a little hesitant about the proposed change. execve() has a
> similar prototype in the kernel, but the glibc wrapper is just:
> 
> extern int execve (const char *__path, char *const __argv[],
>                    char *const __envp[]) ;

I guess that was the reason to write it like that.

> 
> I expect that one day when execveat() is added to glibc, it will be
> the same. What do you think?

execveat() was added 6 years ago to the kernel (kernel commit
51f39a1f0cea1cacf8c787f652f26dfee9611874) and there's still no wrapper.
 It's not like epoll_pwait2() that isn't yet in a stable release.  I'd
document the actual prototype, maybe open a bug in glibc to request a
wrapper, and if some day glibc adds that wrapper, I'd just revert the
commit.  Wouldn't you?

Thanks,

Alex

> 
> Thanks,
> 
> Michael
> 
> On Wed, 3 Feb 2021 at 19:46, Alejandro Colomar <alx.manpages@gmail.com> wrote:
>>
>> .../linux$ grep_syscall execveat
>> fs/exec.c:2062:
>> SYSCALL_DEFINE5(execveat,
>>                 int, fd, const char __user *, filename,
>>                 const char __user *const __user *, argv,
>>                 const char __user *const __user *, envp,
>>                 int, flags)
>> fs/exec.c:2083:
>> COMPAT_SYSCALL_DEFINE5(execveat, int, fd,
>>                        const char __user *, filename,
>>                        const compat_uptr_t __user *, argv,
>>                        const compat_uptr_t __user *, envp,
>>                        int,  flags)
>> include/linux/syscalls.h:980:
>> asmlinkage long sys_execveat(int dfd, const char __user *filename,
>>                         const char __user *const __user *argv,
>>                         const char __user *const __user *envp, int flags);
>> .../linux$
>>
>> function grep_syscall()
>> {
>>         if ! [ -v 1 ]; then
>>                 >&2 echo "Usage: ${FUNCNAME[0]} <syscall>";
>>                 return ${EX_USAGE};
>>         fi
>>
>>         find * -type f \
>>         |grep '\.c$' \
>>         |sort -V \
>>         |xargs pcregrep -Mn "(?s)^\w*SYSCALL_DEFINE.\(${1},.*?\)" \
>>         |sed -E 's/^[^:]+:[0-9]+:/&\n/';
>>
>>         find * -type f \
>>         |grep '\.h$' \
>>         |sort -V \
>>         |xargs pcregrep -Mn "(?s)^asmlinkage \w+ \**sys_${1}\(.*?\)" \
>>         |sed -E 's/^[^:]+:[0-9]+:/&\n/';
>> }
>>
>> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
>> ---
>>  man2/execveat.2 | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/man2/execveat.2 b/man2/execveat.2
>> index 02d9c7331..d1ce4bee1 100644
>> --- a/man2/execveat.2
>> +++ b/man2/execveat.2
>> @@ -31,7 +31,7 @@ execveat \- execute program relative to a directory file descriptor
>>  .B #include <unistd.h>
>>  .PP
>>  .BI "int execveat(int " dirfd ", const char *" pathname ,
>> -.BI "             char *const " argv "[], char *const " envp [],
>> +.BI "             const char *const " argv "[], const char *const " envp [],
>>  .BI "             int " flags );
>>  .fi
>>  .PP
>> --
>> 2.30.0
>>
> 
> 


-- 
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/

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

* [PATCH v2] execveat.2: Fix prototype
  2021-02-06  9:54 ` Michael Kerrisk (man-pages)
  2021-02-06 11:04   ` Alejandro Colomar (man-pages)
@ 2021-02-07 11:43   ` Alejandro Colomar
  2021-02-09 18:59     ` Michael Kerrisk (man-pages)
  1 sibling, 1 reply; 5+ messages in thread
From: Alejandro Colomar @ 2021-02-07 11:43 UTC (permalink / raw)
  To: mtk.manpages; +Cc: Alejandro Colomar, linux-man, David Drysdale

It's been 6 years since execveat(2) was added to the kernel,
and there's still no glibc wrapper.  Let's document the kernel
syscall prototype.

I reported a bug against glibc requesting a wrapper;
when glibc adds the wrapper, this commit should probably be
reverted.

......

.../linux$ grep_syscall execveat
fs/exec.c:2062:
SYSCALL_DEFINE5(execveat,
		int, fd, const char __user *, filename,
		const char __user *const __user *, argv,
		const char __user *const __user *, envp,
		int, flags)
fs/exec.c:2083:
COMPAT_SYSCALL_DEFINE5(execveat, int, fd,
		       const char __user *, filename,
		       const compat_uptr_t __user *, argv,
		       const compat_uptr_t __user *, envp,
		       int,  flags)
include/linux/compat.h:815:
asmlinkage long compat_sys_execveat(int dfd, const char __user *filename,
		     const compat_uptr_t __user *argv,
		     const compat_uptr_t __user *envp, int flags);
include/linux/syscalls.h:980:
asmlinkage long sys_execveat(int dfd, const char __user *filename,
			const char __user *const __user *argv,
			const char __user *const __user *envp, int flags);
.../linux$

function grep_syscall()
{
	if ! [ -v 1 ]; then
		>&2 echo "Usage: ${FUNCNAME[0]} <syscall>";
		return ${EX_USAGE};
	fi

	find * -type f \
	|grep '\.c$' \
	|sort -V \
	|xargs pcregrep -Mn "(?s)^\w*SYSCALL_DEFINE.\(${1},.*?\)" \
	|sed -E 's/^[^:]+:[0-9]+:/&\n/';

	find * -type f \
	|grep '\.[ch]$' \
	|sort -V \
	|xargs pcregrep -Mn "(?s)^asmlinkage\s+[\w\s]+\**sys_${1}\s*\(.*?\)" \
	|sed -E 's/^[^:]+:[0-9]+:/&\n/';
}

Glibc bug: <https://sourceware.org/bugzilla/show_bug.cgi?id=27364>
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---
 man2/execveat.2 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/man2/execveat.2 b/man2/execveat.2
index 02d9c7331..d1ce4bee1 100644
--- a/man2/execveat.2
+++ b/man2/execveat.2
@@ -31,7 +31,7 @@ execveat \- execute program relative to a directory file descriptor
 .B #include <unistd.h>
 .PP
 .BI "int execveat(int " dirfd ", const char *" pathname ,
-.BI "             char *const " argv "[], char *const " envp [],
+.BI "             const char *const " argv "[], const char *const " envp [],
 .BI "             int " flags );
 .fi
 .PP
-- 
2.30.0


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

* Re: [PATCH v2] execveat.2: Fix prototype
  2021-02-07 11:43   ` [PATCH v2] " Alejandro Colomar
@ 2021-02-09 18:59     ` Michael Kerrisk (man-pages)
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Kerrisk (man-pages) @ 2021-02-09 18:59 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: mtk.manpages, linux-man, David Drysdale

Hi Alex,

On 2/7/21 12:43 PM, Alejandro Colomar wrote:
> It's been 6 years since execveat(2) was added to the kernel,
> and there's still no glibc wrapper.  Let's document the kernel
> syscall prototype.
> 
> I reported a bug against glibc requesting a wrapper;
> when glibc adds the wrapper, this commit should probably be
> reverted.

Thanks for filing the glibc bug.

I've applied this patch. Thanks!

Cheers,

Michael

> ......
> 
> .../linux$ grep_syscall execveat
> fs/exec.c:2062:
> SYSCALL_DEFINE5(execveat,
> 		int, fd, const char __user *, filename,
> 		const char __user *const __user *, argv,
> 		const char __user *const __user *, envp,
> 		int, flags)
> fs/exec.c:2083:
> COMPAT_SYSCALL_DEFINE5(execveat, int, fd,
> 		       const char __user *, filename,
> 		       const compat_uptr_t __user *, argv,
> 		       const compat_uptr_t __user *, envp,
> 		       int,  flags)
> include/linux/compat.h:815:
> asmlinkage long compat_sys_execveat(int dfd, const char __user *filename,
> 		     const compat_uptr_t __user *argv,
> 		     const compat_uptr_t __user *envp, int flags);
> include/linux/syscalls.h:980:
> asmlinkage long sys_execveat(int dfd, const char __user *filename,
> 			const char __user *const __user *argv,
> 			const char __user *const __user *envp, int flags);
> .../linux$
> 
> function grep_syscall()
> {
> 	if ! [ -v 1 ]; then
> 		>&2 echo "Usage: ${FUNCNAME[0]} <syscall>";
> 		return ${EX_USAGE};
> 	fi
> 
> 	find * -type f \
> 	|grep '\.c$' \
> 	|sort -V \
> 	|xargs pcregrep -Mn "(?s)^\w*SYSCALL_DEFINE.\(${1},.*?\)" \
> 	|sed -E 's/^[^:]+:[0-9]+:/&\n/';
> 
> 	find * -type f \
> 	|grep '\.[ch]$' \
> 	|sort -V \
> 	|xargs pcregrep -Mn "(?s)^asmlinkage\s+[\w\s]+\**sys_${1}\s*\(.*?\)" \
> 	|sed -E 's/^[^:]+:[0-9]+:/&\n/';
> }
> 
> Glibc bug: <https://sourceware.org/bugzilla/show_bug.cgi?id=27364>
> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
> ---
>  man2/execveat.2 | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/man2/execveat.2 b/man2/execveat.2
> index 02d9c7331..d1ce4bee1 100644
> --- a/man2/execveat.2
> +++ b/man2/execveat.2
> @@ -31,7 +31,7 @@ execveat \- execute program relative to a directory file descriptor
>  .B #include <unistd.h>
>  .PP
>  .BI "int execveat(int " dirfd ", const char *" pathname ,
> -.BI "             char *const " argv "[], char *const " envp [],
> +.BI "             const char *const " argv "[], const char *const " envp [],
>  .BI "             int " flags );
>  .fi
>  .PP
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

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

end of thread, other threads:[~2021-02-09 21:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03 18:45 [PATCH] execveat.2: Fix prototype Alejandro Colomar
2021-02-06  9:54 ` Michael Kerrisk (man-pages)
2021-02-06 11:04   ` Alejandro Colomar (man-pages)
2021-02-07 11:43   ` [PATCH v2] " Alejandro Colomar
2021-02-09 18:59     ` Michael Kerrisk (man-pages)

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.