Re: arch_prctl()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Adhemerval, Elliott,

On Wed, Aug 21, 2024 at 03:19:02PM GMT, Adhemerval Zanella Netto wrote:
> I would use either the kernel interface: 
> 
> arch/x86/kernel/process_64.c
> 961 SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2)
> 
> Where is seems to what most caller do, or maybe something like:
> 
> union __arch_prctl_arg
> {
>   unsigned long addr;
>   unsigned long *vaddr;
> };
> 
> int arch_prctl (int option, union __arch_prctl_arg *arg);

Or you could use a transparent union:

	$ cat arch_prctl.c 
	union __attribute__((__transparent_union__)) __arch_prctl_arg {
		unsigned long  set;
		unsigned long  *get;
	};

	int my_arch_prctl(int op, union __arch_prctl_arg arg2);

	int
	main(void)
	{
		unsigned long  u = 0;

		my_arch_prctl(1, u);
		my_arch_prctl(1, &u);
	}
	$ gcc -Wall -Wextra -S arch_prctl.c 
	$ 

> And for constants, it would require a x86_64 specific sys/prctl.h header
> with either the has_include tricks to include the kernel one or to just
> copy the kernel one (along with possible a test to check the sync with
> kernel definitions).

I think including would be simpler, if it's possible.

I've seen some problems arise from copying kernel stuff in glibc
headers, such as being unable to include both a some kernel and some
glibc headers in the same program due to redefinitions.


Have a lovely night!
Alex


-- 
<https://www.alejandro-colomar.es/>

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux