From: Khem Raj <raj.khem@gmail.com>
To: Ross Burton <ross.burton@intel.com>,
openembedded-core@lists.openembedded.org
Subject: Re: [PATCH][RFC] pseudo: intercept syscall() and return ENOTSUP for renameat2
Date: Wed, 4 Apr 2018 14:28:11 -0700 [thread overview]
Message-ID: <39787e20-0d21-00bd-a5bb-73faa52c0839@gmail.com> (raw)
In-Reply-To: <20180327154802.14611-1-ross.burton@intel.com>
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@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@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"
>
next prev parent reply other threads:[~2018-04-04 21:28 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-27 15:48 [PATCH][RFC] pseudo: intercept syscall() and return ENOTSUP for renameat2 Ross Burton
2018-03-27 15:53 ` Seebs
2018-03-27 16:02 ` ✗ patchtest: failure for " Patchwork
2018-03-27 22:43 ` [PATCH][RFC] " Andre McCurdy
2018-03-28 9:15 ` Burton, Ross
2018-03-31 4:15 ` Andre McCurdy
2018-03-31 5:06 ` Seebs
2018-03-31 6:02 ` Andre McCurdy
2018-03-31 15:35 ` Seebs
2018-03-31 15:58 ` Bruce Ashfield
2018-03-31 13:12 ` Richard Purdie
2018-03-31 15:39 ` Seebs
2018-03-31 21:03 ` Joshua Watt
2018-03-31 21:16 ` Seebs
2018-04-02 22:20 ` Richard Purdie
2018-04-04 21:28 ` Khem Raj [this message]
2018-04-04 21:45 ` Seebs
2018-04-05 0:29 ` Khem Raj
2018-04-04 21:51 ` Andre McCurdy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=39787e20-0d21-00bd-a5bb-73faa52c0839@gmail.com \
--to=raj.khem@gmail.com \
--cc=openembedded-core@lists.openembedded.org \
--cc=ross.burton@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox