[OE-core] [PATCH][RFC] pseudo: intercept syscall() and return ENOTSUP for renameat2
Khem Raj
raj.khem at gmail.com
Wed Apr 4 21:28:11 UTC 2018
On 3/27/18 8:48 AM, Ross Burton wrote:
> coreutils is now using renameat2() in mv(1) but as this syscall isn't in most
> glibc headers yet it falls back to directly calling syscall(), which pseudo
> doesn't intercept. This results in permission problems as files mysteriously
> move without pseudo knowing.
>
> This patch intercepts syscall() and returns ENOTSUP if renameat2() is being
> called. Thanks to Andre McCurdy for the proof-of-concept that this patch is
> based on.
what is the performance impact of adding another stack frame and
function call in the chain here. Do we have data ?
>
> Signed-off-by: Ross Burton <ross.burton at intel.com>
> ---
> meta/recipes-devtools/pseudo/files/renameat2.patch | 63 ++++++++++++++++++++++
> meta/recipes-devtools/pseudo/pseudo_git.bb | 1 +
> 2 files changed, 64 insertions(+)
> create mode 100644 meta/recipes-devtools/pseudo/files/renameat2.patch
>
> diff --git a/meta/recipes-devtools/pseudo/files/renameat2.patch b/meta/recipes-devtools/pseudo/files/renameat2.patch
> new file mode 100644
> index 00000000000..467b0b3e79f
> --- /dev/null
> +++ b/meta/recipes-devtools/pseudo/files/renameat2.patch
> @@ -0,0 +1,63 @@
> +commit 3a4c536817dce4d0cbaa8f4efe30e722108357dd
> +Author: Ross Burton <ross.burton at intel.com>
> +Date: Tue Mar 27 14:02:10 2018 +0100
> +
> + HACK syscall
> +
> +diff --git a/ports/linux/guts/syscall.c b/ports/linux/guts/syscall.c
> +new file mode 100644
> +index 0000000..4ed38ed
> +--- /dev/null
> ++++ b/ports/linux/guts/syscall.c
> +@@ -0,0 +1,30 @@
> ++/*
> ++ * Copyright (c) 2018 Wind River Systems; see
> ++ * guts/COPYRIGHT for information.
> ++ *
> ++ * long syscall(long number, ...)
> ++ * long rc = -1;
> ++ */
> ++ typedef long syscall_arg_t;
> ++ syscall_arg_t a,b,c,d,e,f;
> ++
> ++ //va_start (ap, number);
> ++ a = va_arg (ap, syscall_arg_t);
> ++ b = va_arg (ap, syscall_arg_t);
> ++ c = va_arg (ap, syscall_arg_t);
> ++ d = va_arg (ap, syscall_arg_t);
> ++ e = va_arg (ap, syscall_arg_t);
> ++ f = va_arg (ap, syscall_arg_t);
> ++ va_end (ap);
> ++
> ++ if ((number == SYS_renameat2)) {
> ++ errno = ENOTSUP;
> ++ rc = -1;
> ++ }
> ++ else {
> ++ rc = real_syscall (number, a, b, c, d, e, f);
> ++ }
> ++
> ++/* return rc;
> ++ * }
> ++ */
> +diff --git a/ports/linux/wrapfuncs.in b/ports/linux/wrapfuncs.in
> +index fca5b50..137612c 100644
> +--- a/ports/linux/wrapfuncs.in
> ++++ b/ports/linux/wrapfuncs.in
> +@@ -54,3 +54,4 @@ int getpw(uid_t uid, char *buf);
> + int getpwent_r(struct passwd *pwbuf, char *buf, size_t buflen, struct passwd **pwbufp);
> + int getgrent_r(struct group *gbuf, char *buf, size_t buflen, struct group **gbufp);
> + int capset(cap_user_header_t hdrp, const cap_user_data_t datap); /* real_func=pseudo_capset */
> ++long syscall(long number, ...);
> +diff --git a/pseudo_wrappers.c b/pseudo_wrappers.c
> +index e05f73a..b7225d7 100644
> +--- a/pseudo_wrappers.c
> ++++ b/pseudo_wrappers.c
> +@@ -36,6 +36,7 @@
> + #include <sys/time.h>
> + #include <sys/wait.h>
> + #include <dlfcn.h>
> ++#include <sys/syscall.h>
> +
> + /* include this to get PSEUDO_PORT_* definitions */
> + #include "pseudo.h"
> diff --git a/meta/recipes-devtools/pseudo/pseudo_git.bb b/meta/recipes-devtools/pseudo/pseudo_git.bb
> index 66da1cc53b8..44343c3bc57 100644
> --- a/meta/recipes-devtools/pseudo/pseudo_git.bb
> +++ b/meta/recipes-devtools/pseudo/pseudo_git.bb
> @@ -6,6 +6,7 @@ SRC_URI = "git://git.yoctoproject.org/pseudo \
> file://fallback-group \
> file://moreretries.patch \
> file://toomanyfiles.patch \
> + file://renameat2.patch \
> "
>
> SRCREV = "d7c31a25e4b02af0c64e6be0b4b0a9ac4ffc9da2"
>
More information about the Openembedded-core
mailing list