From patchwork Tue Jan 13 23:17:27 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Purdie X-Patchwork-Id: 78650 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1751FD2D114 for ; Tue, 13 Jan 2026 23:17:36 +0000 (UTC) Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.72920.1768346253465982773 for ; Tue, 13 Jan 2026 15:17:33 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=S6friGYJ; spf=pass (domain: linuxfoundation.org, ip: 209.85.128.49, mailfrom: richard.purdie@linuxfoundation.org) Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-47774d3536dso2728995e9.0 for ; Tue, 13 Jan 2026 15:17:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1768346251; x=1768951051; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=H0dk1D1dSI4+Em/wzNmfWzw1Ftb5BQWw5aSX4WE76bA=; b=S6friGYJ4vTbtt/YKxJbI6jK7ztfe/3Ewhz3CWjqglI0N2PZQirY9e22ig+JHw6GOl A99w27/O/NgdMaj9HP/stjomJ75S6qyiBS/kWbsEiRmZ2imt6cDybvCMTb9tzyq0Etpr dV8QMLdSwq5llfWP5kQBPt/cEXRXZtKICm1zw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768346251; x=1768951051; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=H0dk1D1dSI4+Em/wzNmfWzw1Ftb5BQWw5aSX4WE76bA=; b=bctdnisNTp90l7KmTIOM+TVgQ3T3hH4u6PvfUPK4T6BBRX8b48cG5fgB7ZuQCMS1YW x0LyhgW+0/O9AFon2rt0xKpSBH5zIEZgorNrHt32URkP+1j4RMH7uTNffLbR2z7Lb1fK OSEgpafYEZcMVi5kbeuAwT6V3ML4CJzTfuVpULCAJWz0PCVSJfST/kIa8hwYu+iRSsZB H5Wv93AkZoSCegA9kqD2EKKOeLHr3SI+cZrXrWLlPQs5NUCe0CWjnF25PD70hFcTU9qF 3NGQTVBmIeDCUWe0GoKTOyqIaR5V2SGYdLQthFmBeUdXt7VOxOLAeCGjatT0lGu9GeG1 mQzQ== X-Gm-Message-State: AOJu0Yzr0/UFCKgmb/SFDLxP2vlPU9xYA3Vk9OFMjo/3F06n0LTxbB04 CZXTplCD2i9OL82dRPRE2DoIKQ8LbFLDPyIqaKUORt7rHCwWDiM1QqHSkUpcpPglSBAUIm3oLmr 0HWluoLM= X-Gm-Gg: AY/fxX4tCGX/ao0uXP4r9FWCaTO4qtWzOmFoJ2rKJNLPCf1JYFwPaBkk6nVDukvQ+uk tIfLI6GBqQPONFMhasXCY0lcZwN7820T31twqXUzXiRbYrhssTQ1c2AlNL2W4Ve8kNSpQfzMKA1 dxt0GUqQlSS1m4pJC6oeAeJGAnUjzPanv1hir9Zi8t47MjQ+9UfU0EQ6RlA436U+qhMhOngFxyz ro0imaMt+o9whXHi1Fto7un3MUmcEmB25oqZbmH7ZSnn5ewFV4lgBydOBA3VlHc+P4aIV76C4e5 /LgazIB3YcpIkkGAUuDy7bcLDrvPJKFbK++Ga4NwTEfhUoORKEJUPHfXXgnxHFR7MxQS3mp+wun iFr34xv/bE79tARPn4NEDAEX/XfVjmMT4iJh2YVRx/jYITK/1fkqp664Bc/uM5mNDHvkp8lIRrM V4MMQN1cG7be5mUpjObiMruydkKnxMmg2LIRwJlQ== X-Received: by 2002:a05:600c:6992:b0:47d:403a:277 with SMTP id 5b1f17b1804b1-47ee3775159mr7182635e9.4.1768346251306; Tue, 13 Jan 2026 15:17:31 -0800 (PST) Received: from max.int.rpsys.net ([2001:8b0:aba:5f3c:143:ebd4:ccef:c4b7]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47d7f695956sm436956115e9.6.2026.01.13.15.17.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jan 2026 15:17:30 -0800 (PST) From: Richard Purdie To: yocto-patches@lists.yoctoproject.org Cc: seebs@seebs.net, mark.hatle@kernel.crashing.org Subject: [pseudo] [PATCH 1/3] test-syscall: Add a syscall test Date: Tue, 13 Jan 2026 23:17:27 +0000 Message-ID: <20260113231729.2698563-1-richard.purdie@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 13 Jan 2026 23:17:36 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/2951 From: "mark.hatle" Verify the syscalls we intercept are being handled properly. This usually means ENOSYS. In the future we may catch and forward them to wrappers, if that happens the test can be improved. Signed-off-by: mark.hatle --- test/test-syscall.c | 87 ++++++++++++++++++++++++++++++++++++++++++++ test/test-syscall.sh | 5 +++ 2 files changed, 92 insertions(+) create mode 100644 test/test-syscall.c create mode 100755 test/test-syscall.sh diff --git a/test/test-syscall.c b/test/test-syscall.c new file mode 100644 index 0000000..1e21525 --- /dev/null +++ b/test/test-syscall.c @@ -0,0 +1,87 @@ +/* This test case must match the implementation in: + * ports/linux/pseudo_wrappers.c + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) { + long rc = 0; + +#ifdef SYS_renameat2 + int retval; + + #ifndef RENAME_NOREPLACE + # define RENAME_NOREPLACE (1 << 0) + #endif + + /* The two paths don't exist, but we're just checking on error what the errno is. */ + retval = syscall(SYS_renameat2, AT_FDCWD, "empty_path_1", AT_FDCWD, "empty_path_2", RENAME_NOREPLACE); + if (retval != -1) { + errno = 0; + printf("renameat2: fail: function implemented\n"); + rc++; + } else { + if (errno != ENOSYS) { + printf("renameat2: fail: function implemented: %s\n", strerror(errno)); + rc++; + } + else + printf("renameat2: pass\n"); + } + +#endif + +#ifdef SYS_seccomp + /* We should verify this was intercepted, but at present we're not able to. */ + errno = 0; + printf("seccomp: skip\n"); +#endif + +#ifdef SYS_openat2 + struct open_how + { + # ifdef __UINT64_TYPE__ + __UINT64_TYPE__ flags, mode, resolve; + # else + unsigned long long int flags, mode, resolve; + # endif + }; + # define RESOLVE_NO_XDEV 0x01 + # define RESOLVE_NO_MAGICLINKS 0x02 + # define RESOLVE_NO_SYMLINKS 0x04 + # define RESOLVE_BENEATH 0x08 + # define RESOLVE_IN_ROOT 0x10 + # define RESOLVE_CACHED 0x20 + + struct open_how how; + memset(&how, 0, sizeof(how)); + how.flags = O_DIRECTORY; + how.resolve = RESOLVE_IN_ROOT; + + int fd; + fd = syscall(SYS_openat2, AT_FDCWD, ".", &how, sizeof(how)); + if (fd == -1) { + if (errno != ENOSYS) { + printf("openat2: fail: function implemented: %s\n", strerror(errno)); + rc++; + } + else + printf("openat2: pass\n"); + } + else { + printf("openat2: fail: function implemented\n"); + rc++; + } + + close(fd); +#endif + + return rc; +} diff --git a/test/test-syscall.sh b/test/test-syscall.sh new file mode 100755 index 0000000..69774db --- /dev/null +++ b/test/test-syscall.sh @@ -0,0 +1,5 @@ +#! /bin/sh + +mypath=$(dirname $0) + +exec ${mypath}/test-syscall From patchwork Tue Jan 13 23:17:28 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Purdie X-Patchwork-Id: 78649 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17FCCD2D11F for ; Tue, 13 Jan 2026 23:17:36 +0000 (UTC) Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.72584.1768346254848757129 for ; Tue, 13 Jan 2026 15:17:35 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=WqrRHs/P; spf=pass (domain: linuxfoundation.org, ip: 209.85.128.42, mailfrom: richard.purdie@linuxfoundation.org) Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-47edd6111b4so9126925e9.1 for ; Tue, 13 Jan 2026 15:17:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1768346253; x=1768951053; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OwRWRSEF/DaVz1qv5Ly5Re2l18JpcfF8KGR1OMCLMJk=; b=WqrRHs/Py6wuAdZ1zbzgdF7Ptr1qzpbdDmbmy0A5AGwj5rgSR9Ky750z1Ti9L2vI4d DFFdp+Gx1NnQeDzCZdIk633YqyKjnAJA2m93FRvsuAbhmds48eioJyfTMxz34gbKjAez ThI3V6CUi86DY347opcrvLzTWFvbFTx20Y/n8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768346253; x=1768951053; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=OwRWRSEF/DaVz1qv5Ly5Re2l18JpcfF8KGR1OMCLMJk=; b=hOnWbsvb7ECMn6/XtpCAYf6YtLGAIjsjlqv/OFZOTf4l7ci3+OoreAwIy0I/LOBhGS xGcDHryoA8uB9vh7OgAUhmckyDFWp3RqeREp8au9dZtg5ictmpfQcZYA7rsVI6F2pl6C NLqLp9R2kgrHHaXYYqCJ17xI/oID3Evq6+6QH9xUKa3exOdQMcff7tMoO/OuwigsiODU iG/yuy/PiItjVIi5E02X/Py6O2l71meOTLDTrZQ+qMNQHWwHu24qwyALBYvJ/tYzSM+p 1+cflTEjdMtPvOrc+qOdDlB1n9w+ilM2iNqlFUrLuIjBBlQEfJi0oQCgVFwBtSSEe9FV QLFw== X-Gm-Message-State: AOJu0YyMAKrfWFvBB978OT4Omub+Ekw3WjL1EPweKgZsRwNc/sao/DfU 0d1i8k6kRELB5gvYKt25tOCZQVRGVy9P241VCC7HTCikaFe7k45+ADgBl6UnMQc+ZQKx7mNpN3d 0Ki2o1nA= X-Gm-Gg: AY/fxX4XbTJHeA7o2U8HijNQW/Jii0iSObWQoetelvtXmAlXgrSpx3WC2eeo0b23hfz HHnK72JVRd+ylkMfO2VDZ75PegcvyyCarqUS+1tw+pMHHPo7WpLbp7fF1r1O6br4XzQc6FghHwB Kuf4ET2JCyf69qm0UYtlR+aMxTH1t0eIRvVruHsUL4Vzef2vyrqqst3aP9CFjY+A9La+lLs7QnT 1kSwmFWWb2cTvCypNmjWn+uLGYcUqtKHCf4W+Y/o1S2ZmUNivmyxz+yET3RoXz9Bu/UrqYOh7Xs ucBal1eaR7y+6vfekiha9TdVuyHW9ZuRNVSGe9x1OH37leEzOsVZOpbpsjs3cDgYs4QWLnvY25P 4LnjqkiCnHPedvkmh8+jJaNKbLDCf9TmhWe1Dfamj9b8nBGKd6gI6UeFaDIqkaqhsHQIfGoCWlj XNa3VxVA4pmCNUK1WizL3RzQtycc6/UxezRRsEuw== X-Received: by 2002:a05:600c:8183:b0:475:da1a:5418 with SMTP id 5b1f17b1804b1-47ee47bb085mr1993775e9.1.1768346252672; Tue, 13 Jan 2026 15:17:32 -0800 (PST) Received: from max.int.rpsys.net ([2001:8b0:aba:5f3c:143:ebd4:ccef:c4b7]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47d7f695956sm436956115e9.6.2026.01.13.15.17.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jan 2026 15:17:31 -0800 (PST) From: Richard Purdie To: yocto-patches@lists.yoctoproject.org Cc: seebs@seebs.net, mark.hatle@kernel.crashing.org Subject: [pseudo] [PATCH 2/3] ports/linux/openat2: Add dummy wrapper Date: Tue, 13 Jan 2026 23:17:28 +0000 Message-ID: <20260113231729.2698563-2-richard.purdie@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20260113231729.2698563-1-richard.purdie@linuxfoundation.org> References: <20260113231729.2698563-1-richard.purdie@linuxfoundation.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 13 Jan 2026 23:17:36 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/2952 From: "mark.hatle" For now fail politely, most callers have fallback behavior. Signed-off-by: mark.hatle --- makewrappers | 1 + ports/linux/openat2/guts/openat2.c | 23 +++++++++++++++++++++++ ports/linux/openat2/portdefs.h | 13 +++++++++++++ ports/linux/openat2/wrapfuncs.in | 1 + ports/linux/subports | 2 ++ 5 files changed, 40 insertions(+) create mode 100644 ports/linux/openat2/guts/openat2.c create mode 100644 ports/linux/openat2/portdefs.h create mode 100644 ports/linux/openat2/wrapfuncs.in diff --git a/makewrappers b/makewrappers index 67c73e2..0d73cc1 100755 --- a/makewrappers +++ b/makewrappers @@ -209,6 +209,7 @@ typedata = { 'ssize_t': { 'format': '%ld', 'value': '(long) rc' }, 'struct group *': { 'format': '%p', 'value': '(void *) rc' }, 'struct passwd *': { 'format': '%p', 'value': '(void *) rc' }, + 'struct open_how *': { 'format': '%p', 'value': '(void *) rc' }, 'uid_t': { 'format': '%ld', 'value': ' (long) rc' }, 'void *': { 'format': '%p', 'value': 'rc' }, 'void': { 'format': 'void%s', 'value': '""' }, diff --git a/ports/linux/openat2/guts/openat2.c b/ports/linux/openat2/guts/openat2.c new file mode 100644 index 0000000..da01b31 --- /dev/null +++ b/ports/linux/openat2/guts/openat2.c @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2026 Mark Hatle ; see + * guts/COPYRIGHT for information. + * + * SPDX-License-Identifier: LGPL-2.1-only + * + * int openat2(int dirfd, const char *path, struct open_how *how, size_t size) + * int rc = -1; + */ + + (void) dirfd; + (void) path; + (void) how; + (void) size; + /* for now, let's try just failing out hard, and hope things retry with a + * different syscall. + */ + errno = ENOSYS; + rc = -1; + +/* return rc; + * } + */ diff --git a/ports/linux/openat2/portdefs.h b/ports/linux/openat2/portdefs.h new file mode 100644 index 0000000..8e4e33e --- /dev/null +++ b/ports/linux/openat2/portdefs.h @@ -0,0 +1,13 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-only + * + */ +#if __has_include () +# include +#else + struct open_how { + __u64 flags; + __u64 mode; + __u64 resolve; + }; +#endif diff --git a/ports/linux/openat2/wrapfuncs.in b/ports/linux/openat2/wrapfuncs.in new file mode 100644 index 0000000..96ae8a7 --- /dev/null +++ b/ports/linux/openat2/wrapfuncs.in @@ -0,0 +1 @@ +int openat2(int dirfd, const char *path, struct open_how *how, size_t size); diff --git a/ports/linux/subports b/ports/linux/subports index 099ea59..b202c27 100755 --- a/ports/linux/subports +++ b/ports/linux/subports @@ -70,3 +70,5 @@ else fi rm -f dummy.c dummy.o +# For openat2, similar to statx, we need to be able to build on systems without that support. +echo "linux/openat2" From patchwork Tue Jan 13 23:17:29 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Purdie X-Patchwork-Id: 78651 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6663D2D11F for ; Tue, 13 Jan 2026 23:17:45 +0000 (UTC) Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.72586.1768346255684035748 for ; Tue, 13 Jan 2026 15:17:35 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=Bvp369Lr; spf=pass (domain: linuxfoundation.org, ip: 209.85.128.50, mailfrom: richard.purdie@linuxfoundation.org) Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-477563e28a3so1803775e9.1 for ; Tue, 13 Jan 2026 15:17:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1768346254; x=1768951054; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XnC+a81ZAQhXoZ+tD4f/rd5qFPFOCPRPBfeCtNBLZDY=; b=Bvp369LrOVGPz/rGvgwCZPH8+EWCkOU1SQiyI4SWPXlXVTO90kn03ezLcTA2NfdDmD UGdeEpHEbk4sljCVDGXZVbRjbJlIGoZjxizLIkwlDYzA7kcYTHgNacIigg4ZvOpHwFq8 K7vgFo2RQ0I6umUL5zZIUa3fwdhqqJbmr//F0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768346254; x=1768951054; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=XnC+a81ZAQhXoZ+tD4f/rd5qFPFOCPRPBfeCtNBLZDY=; b=QE+tr1hEzzVGUPhECVsVneO4KeVkmT6cq2nY37Mt1mTIF2S26hZWdmLZ6Nl5dWfHVH /k8YEzkar241b1ZILLdmf22IxvZTpqYIndKbWekCego7zCftJRTPO9bjip5tNHJ8Wmm9 BT4TmyoVm5v1KIVig4Wr4Bg6nD8BD3JC8xGF2z4e/nIUoJvLXueGg7bTwCEy1jC0W6OE xg0oqL9+TgWBBZhTISgK4Hn6yvHLyaaYpDCFrYClK/s2abizuheyhf6HqbkOMmhNx2mw +GGmkXE5+R2GSnQlkqfdHL4HJyYhsZMSbXzmyclIZ0QcWZ71J1A0L1bPoZRZ4z005ZNC mmDg== X-Gm-Message-State: AOJu0Yywlg49CornkOp+VfXxehMozzZWHV1cX8bkMHbeP1habI5jxtSt AiVoIump27hWWjTXutCMsIH2GxPK3CYxPbcVrKUD4pNdqXMR8TEKCjFuWjmIipGO0FUx6zKXaET UlWi3okk= X-Gm-Gg: AY/fxX6k373jsCF1810JIer4Bgw8Me5pi0NOPkz4sjkaUv+S9JV/b3ZNr1yw35La6bo GwBZ6/o7D2tSv5rXrk+gZCqSVGyyFNJNuYX9IwqZltbdY+nhFyYjASP/VX+2eqOeHo080rqL4zA lt4Z1ekW4mz+ILAcSnytDHl28Vfrys7l113Jt81w8G1kdHOT48LvJrRerWmyWfIMzebeHV99Enp mkWdTDQrxGqqenlUzL+sVZbRoC3wsjKWtUeygbyMZVQ+CsXmNLWNp+CCO/SlpJ9KFIBQF3PfIa/ gZdMRyULlzq+eMg/cpgXB/Q0riWKTp05LBoTuZLeknXv/Uk6JtTEJxPemmOPLjY0FaqtbR7M4wo Dc1F9j+6wI1bQnm2wQ894sr+4LWqM9Tv6kMfyzVr/kNE9nqJKHHooMXz/GwfcfMHzITQ2FQU1QB aI1SJejA6h+J8QvIkYTiKxZYvRZBWFX/e78SG1jg== X-Received: by 2002:a05:600c:a10f:b0:47e:e452:ec12 with SMTP id 5b1f17b1804b1-47ee452ed0bmr1825225e9.15.1768346253745; Tue, 13 Jan 2026 15:17:33 -0800 (PST) Received: from max.int.rpsys.net ([2001:8b0:aba:5f3c:143:ebd4:ccef:c4b7]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47d7f695956sm436956115e9.6.2026.01.13.15.17.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jan 2026 15:17:33 -0800 (PST) From: Richard Purdie To: yocto-patches@lists.yoctoproject.org Cc: seebs@seebs.net, mark.hatle@kernel.crashing.org Subject: [pseudo] [PATCH 3/3] makewrappers: Enable a new efault option Date: Tue, 13 Jan 2026 23:17:29 +0000 Message-ID: <20260113231729.2698563-3-richard.purdie@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20260113231729.2698563-1-richard.purdie@linuxfoundation.org> References: <20260113231729.2698563-1-richard.purdie@linuxfoundation.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 13 Jan 2026 23:17:45 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/2953 From: "mark.hatle" See Yocto Project Bugzilla 16075. On Linux, some functions will return EFAULT if certain paths are NULL vs empty. RUST specifically uses this Linux specific behavior as an optimization to detect if the statx function is available. In my opinion, this is a horrible idea, even though the man page for Linux/glibc says EFAULT is returned. Looking through the call code the EFAULT happens to occur when the kernel syscall attempts to copy the path from userspace to kernel memory and then faults. Relying on this (posix) undefined behavior is really bad practice, but we have to work with RUST and other tools. Signed-off-by: mark.hatle --- makewrappers | 10 ++++++++++ ports/linux/statx/wrapfuncs.in | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/makewrappers b/makewrappers index 0d73cc1..154b489 100755 --- a/makewrappers +++ b/makewrappers @@ -245,6 +245,8 @@ class Function: self.async_skip = None # used for the copyright date when creating stub functions self.date = datetime.date.today().year + # Used to define pointers that should EFAULT if null + self.efault = None function, comments = line.split(';') comment = re.search(r'/\* *(.*) *\*/', comments) @@ -392,6 +394,14 @@ class Function: "asm(\"\" : \"+r\"(%s));" "if (%s && !*%s && (flags & AT_EMPTY_PATH))\n" "\t\t\tflags |= AT_SYMLINK_NOFOLLOW;" % (path, path, path)) + if self.efault and path in self.efault.split('|'): + fix_paths.append( + # Emulate EFAULT when path is null + "if (%s == NULL) {\n" + "\t\t\terrno = EFAULT;\n" + "\t\t\trc = -1;\n" + "\t\t\t%s\n" + "\t\t}\n" % (path, self.rc_return())) fix_paths.append( "%s = pseudo_root_path(__func__, __LINE__, %s%s, %s, %s);" % (path, prefix, self.dirfd, path, self.flags)) diff --git a/ports/linux/statx/wrapfuncs.in b/ports/linux/statx/wrapfuncs.in index 168234f..a81fb91 100644 --- a/ports/linux/statx/wrapfuncs.in +++ b/ports/linux/statx/wrapfuncs.in @@ -1 +1 @@ -int statx(int dirfd, const char *path, int flags, unsigned int mask, struct statx *statxbuf); +int statx(int dirfd, const char *path, int flags, unsigned int mask, struct statx *statxbuf); /* efault=path */