On Fri, 22 May 2026 16:36:56 +0200
Thomas Weißschuh <[email protected]> wrote:

> On 2026-05-21 18:35:32-0400, Steven Rostedt wrote:
> > From: Steven Rostedt <[email protected]>
> > 
> > Add system calls to register and unregister sframes that can be used by
> > dynamic linkers to tell the kernel where the sframe section is in memory
> > for libraries it loads.  
> 
> How is this system call related to the prctl() with the same
> functionality from Jens' series? I guess it will replace it,
> but some explanation would be nice.

I thought the patch with the prctl() stated it was for debug purposes only.
From the change log:

[
  This adds an interface for prctl() for testing loading of sframes for
  libraries. But this interface should really be a system call. This patch
  is for testing purposes only and should not be applied to mainline.
]

Hence I didn't think there needs to be any explanation. The prctl() patch
should never be applied upstream.

> 
> (...)
> 
> > diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
> > index f5639d5ac331..992ccc401c5e 100644
> > --- a/include/linux/syscalls.h
> > +++ b/include/linux/syscalls.h
> > @@ -999,6 +999,8 @@ asmlinkage long sys_lsm_get_self_attr(unsigned int 
> > attr, struct lsm_ctx __user *
> >  asmlinkage long sys_lsm_set_self_attr(unsigned int attr, struct lsm_ctx 
> > __user *ctx,
> >                                   u32 size, u32 flags);
> >  asmlinkage long sys_lsm_list_modules(u64 __user *ids, u32 __user *size, 
> > u32 flags);
> > +asmlinkage long sys_sframe_register(void *data, unsigned int size);
> > +asmlinkage long sys_sframe_unregister(void *data, unsigned int size);  
> 
> Why not use the actual structure here?

Yeah, I was somewhat lazy here to make sure that this was the direction we
want to go. I just need to add a structure pointer reference at the top of
that file.

Will update in v2.

> 
> >  /*
> >   * Architecture-specific system calls  
> 
> (...)
> 
> > diff --git a/include/uapi/linux/sframe.h b/include/uapi/linux/sframe.h
> > new file mode 100644
> > index 000000000000..137a2ebf91f4
> > --- /dev/null
> > +++ b/include/uapi/linux/sframe.h
> > @@ -0,0 +1,12 @@
> > +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
> > +#ifndef _UAPI_LINUX_SFRAME_H
> > +#define _UAPI_LINUX_SFRAME_H
> > +
> > +struct sframe_setup {
> > +   unsigned long           sframe_start;
> > +   unsigned long           sframe_size;
> > +   unsigned long           text_start;
> > +   unsigned long           text_size;
> > +};  
> 
> This will break for compat processes, as they use a different 'unsigned
> long' than the host kernel. Maybe just use __u64.

I'll update it. I was thinking we wouldn't support compat, but in case we
decide we should forcing the size is better than being architecture
specific.

> 
> > +
> > +#endif /* _UAPI_LINUX_SFRAME_H */  
> 
> (...)
> 
> > +/**
> > + * sys_sframe_register - register an address for user space stacktrace 
> > walking.
> > + * @data: Structure of sframe data used to register the sframe section
> > + * @size: The size of the given structure.
> > + *
> > + * This system call is used by dynamic library utilities to inform the 
> > kernel
> > + * of meta data that it loaded that can be used by the kernel to know how
> > + * to stack walk the given text locations.
> > + *
> > + * Return: 0 if successful, otherwise a negative error.
> > + */
> > +SYSCALL_DEFINE2(sframe_register, __user struct sframe_setup *, data, 
> > unsigned int, size)  
> 
> AFAIK the normal place for the '__user' is right before '*':
> 
>       struct sframe_setup __user *, data,

Will update.

> 
> Use __kernel_size_t for 'size'?

Looking at the history of the accept() system call that started with int
and then wanted size_t, then changed to socklen_t, I guess there's
precedence to use __kernel_size_t.

Will update.

Thanks!

-- Steve


Reply via email to