| Message ID | 20260217154814.483670-1-yoann.congal@smile.fr |
|---|---|
| State | New |
| Headers | show |
| Series | [pseudo] ports/linux: define __NR_openat2 if missing | expand |
On Tue, Feb 17, 2026 at 7:48 AM Yoann Congal via lists.yoctoproject.org <yoann.congal=smile.fr@lists.yoctoproject.org> wrote: > From: Yoann Congal <yoann.congal@smile.fr> > > On kernel <5.6, __NR_openat2 is not defined. To support build on these > older kernel, define __NR_openat2 at the value it has on every kernel > since 5.6: 437 [0]. > > [0]: > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fddb5d430ad9fa91b49b1d34d0202ffe2fa0e179 > > Signed-off-by: Yoann Congal <yoann.congal@smile.fr> > --- > ports/linux/portdefs.h | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/ports/linux/portdefs.h b/ports/linux/portdefs.h > index a8b2be6..32b95ba 100644 > --- a/ports/linux/portdefs.h > +++ b/ports/linux/portdefs.h > @@ -54,7 +54,15 @@ GLIBC_COMPAT_SYMBOL(memcpy,2.0); > #endif > #endif > > -/* Debian 11 and Opensuse 15.5 need this */ > +/* Ubuntu 20.04, Debian 11 and Opensuse 15.5 need this */ > #ifndef SYS_openat2 > + > +/* On kernel <5.6, __NR_openat2 is not defined. Import the definition > from > + * > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fddb5d430ad9fa91b49b1d34d0202ffe2fa0e179 > + */ > +#ifndef __NR_openat2 > +#define __NR_openat2 437 > +#endif > it will fix compile time problems but I wonder if it will run okay on kernels < 5.6 ? > + > #define SYS_openat2 __NR_openat2 > #endif > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#3248): > https://lists.yoctoproject.org/g/yocto-patches/message/3248 > Mute This Topic: https://lists.yoctoproject.org/mt/117858536/1997914 > Group Owner: yocto-patches+owner@lists.yoctoproject.org > Unsubscribe: > https://lists.yoctoproject.org/g/yocto-patches/leave/13340786/1997914/645821814/xyzzy > [raj.khem@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- > > >
On Tue, 2026-02-17 at 08:38 -0800, Khem Raj via lists.yoctoproject.org wrote: > > > On Tue, Feb 17, 2026 at 7:48 AM Yoann Congal via > lists.yoctoproject.org <yoann.congal=smile.fr@lists.yoctoproject.org> > wrote: > > From: Yoann Congal <yoann.congal@smile.fr> > > > > On kernel <5.6, __NR_openat2 is not defined. To support build on > > these > > older kernel, define __NR_openat2 at the value it has on every > > kernel > > since 5.6: 437 [0]. > > > > [0]: > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fddb5d430ad9fa91b49b1d34d0202ffe2fa0e179 > > > > Signed-off-by: Yoann Congal <yoann.congal@smile.fr> > > --- > > ports/linux/portdefs.h | 10 +++++++++- > > 1 file changed, 9 insertions(+), 1 deletion(-) > > > > diff --git a/ports/linux/portdefs.h b/ports/linux/portdefs.h > > index a8b2be6..32b95ba 100644 > > --- a/ports/linux/portdefs.h > > +++ b/ports/linux/portdefs.h > > @@ -54,7 +54,15 @@ GLIBC_COMPAT_SYMBOL(memcpy,2.0); > > #endif > > #endif > > > > -/* Debian 11 and Opensuse 15.5 need this */ > > +/* Ubuntu 20.04, Debian 11 and Opensuse 15.5 need this */ > > #ifndef SYS_openat2 > > + > > +/* On kernel <5.6, __NR_openat2 is not defined. Import the > > definition from > > + * > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fddb5d430ad9fa91b49b1d34d0202ffe2fa0e179 > > + */ > > +#ifndef __NR_openat2 > > +#define __NR_openat2 437 > > +#endif > > > > > it will fix compile time problems but I wonder if it will run okay on > kernels < 5.6 ? It will be fine. The code should simply never get called and even if it did, it is just returns an error code so it wouldn't make any difference to the standard behaviour. Cheers, Richard
I'm inclined to say if __NR_openat2 isn't defined we don't want to support openat2 at all in the _standard_ pseudo. Since the system userspace is effectively disconnected from the kernel. Now, from the OE/YP point of view this is different, we want to build a system with support for openat2 (at least the intercept) even if the host system doesn't support it. (I thought all of the 'modern' supported/not deprecated host systems were new enough that everyone had NR_openat2 defined in them. I guess I was wrong.) Right now the reply is ENOSYS, so it shouldn't be any sort of issue just always enabling it. But I'd really like to get openat2 enabled at some point, and if we do it becomes very important that we only wrap it if it exists, otherwise we need to wrap and call the syscall then look for ENOSYS and 'unwrap' any changes we've made... So I'm tempted to suggest a few things: 1) If NR_openat2 is not defined, we disable openat2 in the upstream project. YP then carries a patch that unconditionally defines the value. 2) We optionally supply the NR_openat2 value (if undefined), but we add some sort of configure switch to pseudo to activate this behavior. 3) We say we always support openat2 due to the current ENOSYS behavior and just bake it into the future implementation that we need to handle this. In this case the patch below (or one like it) is fine. (A few notes below) On 2/17/26 9:48 AM, Yoann Congal via lists.yoctoproject.org wrote: > From: Yoann Congal <yoann.congal@smile.fr> > > On kernel <5.6, __NR_openat2 is not defined. To support build on these > older kernel, define __NR_openat2 at the value it has on every kernel > since 5.6: 437 [0]. > > [0]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fddb5d430ad9fa91b49b1d34d0202ffe2fa0e179 > > Signed-off-by: Yoann Congal <yoann.congal@smile.fr> > --- > ports/linux/portdefs.h | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/ports/linux/portdefs.h b/ports/linux/portdefs.h > index a8b2be6..32b95ba 100644 > --- a/ports/linux/portdefs.h > +++ b/ports/linux/portdefs.h > @@ -54,7 +54,15 @@ GLIBC_COMPAT_SYMBOL(memcpy,2.0); > #endif > #endif > > -/* Debian 11 and Opensuse 15.5 need this */ > +/* Ubuntu 20.04, Debian 11 and Opensuse 15.5 need this */ > #ifndef SYS_openat2 > + > +/* On kernel <5.6, __NR_openat2 is not defined. Import the definition from > + * https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fddb5d430ad9fa91b49b1d34d0202ffe2fa0e179 > + */ > +#ifndef __NR_openat2 > +#define __NR_openat2 437 The value of 437 is arch specific. I'm worried we need to expand this. alpha - 547 (everyone else is 437) I seriously down anyone is going to use pseudo on an alpha platform, so maybe this isn't a real concern anymore. --Mark > +#endif > + > #define SYS_openat2 __NR_openat2 > #endif > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#3248): https://lists.yoctoproject.org/g/yocto-patches/message/3248 > Mute This Topic: https://lists.yoctoproject.org/mt/117858536/3616948 > Group Owner: yocto-patches+owner@lists.yoctoproject.org > Unsubscribe: https://lists.yoctoproject.org/g/yocto-patches/leave/13201099/3616948/947757854/xyzzy [mark.hatle@kernel.crashing.org] > -=-=-=-=-=-=-=-=-=-=-=- >
On 2/17/26 10:44 AM, Richard Purdie via lists.yoctoproject.org wrote: > On Tue, 2026-02-17 at 08:38 -0800, Khem Raj via lists.yoctoproject.org > wrote: >> >> >> On Tue, Feb 17, 2026 at 7:48 AM Yoann Congal via >> lists.yoctoproject.org <yoann.congal=smile.fr@lists.yoctoproject.org> >> wrote: >>> From: Yoann Congal <yoann.congal@smile.fr> >>> >>> On kernel <5.6, __NR_openat2 is not defined. To support build on >>> these >>> older kernel, define __NR_openat2 at the value it has on every >>> kernel >>> since 5.6: 437 [0]. >>> >>> [0]: >>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fddb5d430ad9fa91b49b1d34d0202ffe2fa0e179 >>> >>> Signed-off-by: Yoann Congal <yoann.congal@smile.fr> >>> --- >>> ports/linux/portdefs.h | 10 +++++++++- >>> 1 file changed, 9 insertions(+), 1 deletion(-) >>> >>> diff --git a/ports/linux/portdefs.h b/ports/linux/portdefs.h >>> index a8b2be6..32b95ba 100644 >>> --- a/ports/linux/portdefs.h >>> +++ b/ports/linux/portdefs.h >>> @@ -54,7 +54,15 @@ GLIBC_COMPAT_SYMBOL(memcpy,2.0); >>> #endif >>> #endif >>> >>> -/* Debian 11 and Opensuse 15.5 need this */ >>> +/* Ubuntu 20.04, Debian 11 and Opensuse 15.5 need this */ >>> #ifndef SYS_openat2 >>> + >>> +/* On kernel <5.6, __NR_openat2 is not defined. Import the >>> definition from >>> + * >>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fddb5d430ad9fa91b49b1d34d0202ffe2fa0e179 >>> + */ >>> +#ifndef __NR_openat2 >>> +#define __NR_openat2 437 >>> +#endif >>> >> >> >> it will fix compile time problems but I wonder if it will run okay on >> kernels < 5.6 ? > > It will be fine. The code should simply never get called and even if it > did, it is just returns an error code so it wouldn't make any > difference to the standard behaviour. Even on an old platform will return ENOSYS which SHOULD be the same as if openat2 was called on a pre 5.6 kernel. So shouldn't be an issue. --Mark > Cheers, > > Richard > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#3250): https://lists.yoctoproject.org/g/yocto-patches/message/3250 > Mute This Topic: https://lists.yoctoproject.org/mt/117858536/3616948 > Group Owner: yocto-patches+owner@lists.yoctoproject.org > Unsubscribe: https://lists.yoctoproject.org/g/yocto-patches/leave/13201099/3616948/947757854/xyzzy [mark.hatle@kernel.crashing.org] > -=-=-=-=-=-=-=-=-=-=-=- > >
On Tue, 2026-02-17 at 10:45 -0600, Mark Hatle wrote: > I'm inclined to say if __NR_openat2 isn't defined we don't want to > support openat2 at all in the _standard_ pseudo. Since the system > userspace is effectively disconnected from the kernel. > > Now, from the OE/YP point of view this is different, we want to build > a system with support for openat2 (at least the intercept) even if > the host system doesn't support it. > > (I thought all of the 'modern' supported/not deprecated host systems > were new enough that everyone had NR_openat2 defined in them. I > guess I was wrong.) > > Right now the reply is ENOSYS, so it shouldn't be any sort of issue > just always enabling it. But I'd really like to get openat2 enabled > at some point, and if we do it becomes very important that we only > wrap it if it exists, otherwise we need to wrap and call the syscall > then look for ENOSYS and 'unwrap' any changes we've made... I think if we have the wrapper, it will only trigger if something in the system calls it and that is unlikely if the base system never had it in the first place. If it is called, our wrapper should be functional, so again, I can't see much bad happening. It is possible with sstate that something could be compiled on a newer system and calls it even if it isn't present on the older system too, so we need to handle that case as well. > So I'm tempted to suggest a few things: > > 1) If NR_openat2 is not defined, we disable openat2 in the upstream > project. YP then carries a patch that unconditionally defines the > value. Maybe. I'm not sure I want to do that but I'm not going to push really hard. I would ask we don't do it with a patch but a configuration option though. We're an important enough user of pseudo we should make that configurable. > 2) We optionally supply the NR_openat2 value (if undefined), but we > add some sort of configure switch to pseudo to activate this > behavior. That would be better IMO but again, I'm not sure we really do need to make this configurable. > 3) We say we always support openat2 due to the current ENOSYS > behavior and just bake it into the future implementation that we need > to handle this. In this case the patch below (or one like it) is > fine. I'd probably lean more towards this overall. > (A few notes below) > > +/* On kernel <5.6, __NR_openat2 is not defined. Import the > > definition from > > + * > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fddb5d430ad9fa91b49b1d34d0202ffe2fa0e179 > > + */ > > +#ifndef __NR_openat2 > > +#define __NR_openat2 437 > > The value of 437 is arch specific. I'm worried we need to expand > this. > > alpha - 547 > > (everyone else is 437) > > I seriously down anyone is going to use pseudo on an alpha platform, > so maybe this isn't a real concern anymore. I did check this before I took the patch and that it had the same value on any of the platforms we're likely to run on (x86/arm, maybe riscv). So I think we're ok for now and the plan looks ok. I do really not want to need to patch pseudo at all though. Cheers, Richard
diff --git a/ports/linux/portdefs.h b/ports/linux/portdefs.h index a8b2be6..32b95ba 100644 --- a/ports/linux/portdefs.h +++ b/ports/linux/portdefs.h @@ -54,7 +54,15 @@ GLIBC_COMPAT_SYMBOL(memcpy,2.0); #endif #endif -/* Debian 11 and Opensuse 15.5 need this */ +/* Ubuntu 20.04, Debian 11 and Opensuse 15.5 need this */ #ifndef SYS_openat2 + +/* On kernel <5.6, __NR_openat2 is not defined. Import the definition from + * https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fddb5d430ad9fa91b49b1d34d0202ffe2fa0e179 + */ +#ifndef __NR_openat2 +#define __NR_openat2 437 +#endif + #define SYS_openat2 __NR_openat2 #endif