From patchwork Tue Mar 27 15:48:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 132481 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp5242221ljb; Tue, 27 Mar 2018 08:48:13 -0700 (PDT) X-Google-Smtp-Source: AG47ELvZudTT1hnTQTYVSe0+ea6iUkHBmz6VKu5MayujPORBsYG3MWGPTyi5OWIwIAmS9t1Lc1SZ X-Received: by 10.99.153.17 with SMTP id d17mr20679977pge.62.1522165693130; Tue, 27 Mar 2018 08:48:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522165693; cv=none; d=google.com; s=arc-20160816; b=i0kcMG7usgVm49d0+loipyaezf/83TcH2fbJpbi/CmrfcsMcuPWo6mWPUr1Im/RKY2 CkJpltLroAab+E2Lm2FqYpT2//Qy6MzCsaPYomkY9fRtSP4mieXGUfHGY4NkCbj+T9CB sQz/z/4Bk7QzDVxXkMCV+IkXhAfu12Cab2EIrlQK2Qb0KkkHsyQ8hljFjhEXxC5T6ScQ AtvFkm2af2Dd2++XQC4TpJ2PKNc1CATVnygK0G8VCoQIurCcx1x47C3RFZQerjYEeRMb SADAIYZC/cLSTc+2thcMCf5QHj/vRHO9MPTwGQC5PL9rFe3Hxcxi9MSJ69S2hX+hCcm+ 3mpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=/bA8oUf4HvYgXnBdwYkg59bd3yL0nRN+o9CplLetMBA=; b=HhewxjwIy0rPeV5bkxmrqsbm+H/X/S5jtFnKNwRuzKlfI5Wam8InFUV0+0wdpD10PR gNiqrx+E5sudPQvUdtE5zwSY/l2+MSzLksgUWf919cTF8yZa/opRNLAjTWRzjv4nMUiQ q+72hMT9TzsodyhSkNqVsDoJBsBfGidW3Uxx1SW0FBP1RsDzVr5KYwZB2ZmKJh2Xjg5p zxoXXy5HNi0K2y7hzen5SNlcbVtEpQscENmpyVFOri9HVfYpeegZ4a8XITzFHP+pmkhx F9BOaWwSNyLeoUtTwD4tHJOzRePU589UXicO22on7+vDBMYAxwrI+iDUX4bSdoarf3L+ fP+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=Ku6ACyXm; spf=pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) smtp.mailfrom=openembedded-core-bounces@lists.openembedded.org Return-Path: Received: from mail.openembedded.org (mail.openembedded.org. [140.211.169.62]) by mx.google.com with ESMTP id f26si1160773pfn.121.2018.03.27.08.48.12; Tue, 27 Mar 2018 08:48:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) client-ip=140.211.169.62; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=Ku6ACyXm; spf=pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) smtp.mailfrom=openembedded-core-bounces@lists.openembedded.org Received: from layers.openembedded.org (localhost [127.0.0.1]) by mail.openembedded.org (Postfix) with ESMTP id E28F16FF73; Tue, 27 Mar 2018 15:48:06 +0000 (UTC) X-Original-To: openembedded-core@lists.openembedded.org Delivered-To: openembedded-core@lists.openembedded.org Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by mail.openembedded.org (Postfix) with ESMTP id 863656003C for ; Tue, 27 Mar 2018 15:48:05 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id a20so21921381wmd.1 for ; Tue, 27 Mar 2018 08:48:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id; bh=VPp9RZnSlCC1PLFZ8j5jTpml65F0yxRbGip+wmsLikY=; b=Ku6ACyXmUOa6OV7xO0KhB9u1rfvWp9I/eX4Iq9fzu/zP8TFsi3bLcr1pqg1B++NNzD 0nbnKF+io1PTN69HIeAN4vXZArjkHacWxULwueaU7VqQkOuk32Th5LTPgX0lwZE5ZvlD areTIKOhb+JSXE1NjuSriMQhgLLGtev/7VvXIw/qg2n+7SWWPn8Ag77oDyS/XWqkxYK1 oKSmZ2gfoHZHCelJHVHiRQDj1pUJQm9MzJ+D/dr3p63IYztkAfjUjK30b7tRMbxoDWiC L/uc1HEhrCPBPIXnjqrz/3KX0RlFfYF/Gk2IWHovEQCDDxMAOIyLE8NNDgsPPNxbMGKw IhaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=VPp9RZnSlCC1PLFZ8j5jTpml65F0yxRbGip+wmsLikY=; b=aKttflK/ZloCPvFjY+QDMfnqcBr/JMwhk6WzGpR79+snytTZmOmW2quBQeWkURhYRm ZkOJq/+36JKHAjl0B1uzgz1j6Xz3R7K+o9zt6408f1pegYmedfcbBdHKVA3oEbEJmfZV 73/tMeiGLdd5N0K8VVccmH+jhXaaEgvFBUaD7TQFaJCsIPhRItwHiKg148ZvNaqzKRom C8qp7noLmrWZBmw1NF90XADoZOAtojxg6hLgsIVnA7NlVYkAEWk6dJY+uLaRJSHfYKMb GAXRstSNa4KYSFgS+mHlDTKNsVpCV3mD4xmDPUihtS5/ctwaCpda0zRWwuZYEqy8L/IK 1o8Q== X-Gm-Message-State: AElRT7Gfx/XLRA2692h61tSltT6gKZJQiS20HffDtcRfd73JGoLc7a09 Sxg/Y8In0QLQscM/cAMsmlGJplTs X-Received: by 10.28.193.13 with SMTP id r13mr17380546wmf.38.1522165685795; Tue, 27 Mar 2018 08:48:05 -0700 (PDT) Received: from flashheart.burtonini.com (35.106.2.81.in-addr.arpa. [81.2.106.35]) by smtp.gmail.com with ESMTPSA id b9sm1571519wrc.85.2018.03.27.08.48.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Mar 2018 08:48:04 -0700 (PDT) From: Ross Burton To: openembedded-core@lists.openembedded.org Date: Tue, 27 Mar 2018 16:48:02 +0100 Message-Id: <20180327154802.14611-1-ross.burton@intel.com> X-Mailer: git-send-email 2.11.0 Subject: [OE-core] [PATCH][RFC] pseudo: intercept syscall() and return ENOTSUP for renameat2 X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: openembedded-core-bounces@lists.openembedded.org Errors-To: openembedded-core-bounces@lists.openembedded.org 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. Signed-off-by: Ross Burton --- 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 -- 2.11.0 -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core Tested-by: Andre McCurdy 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 +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 + #include + #include ++#include + + /* 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"