1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2000 Marcel Moolenaar
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD$");
31
32#include <sys/param.h>
33#include <sys/capsicum.h>
34#include <sys/fcntl.h>
35#include <sys/file.h>
36#include <sys/imgact.h>
37#include <sys/lock.h>
38#include <sys/malloc.h>
39#include <sys/mman.h>
40#include <sys/mutex.h>
41#include <sys/priv.h>
42#include <sys/proc.h>
43#include <sys/queue.h>
44#include <sys/resource.h>
45#include <sys/resourcevar.h>
46#include <sys/sched.h>
47#include <sys/signalvar.h>
48#include <sys/syscallsubr.h>
49#include <sys/sysproto.h>
50#include <sys/systm.h>
51#include <sys/sx.h>
52#include <sys/unistd.h>
53#include <sys/wait.h>
54
55#include <machine/frame.h>
56#include <machine/psl.h>
57#include <machine/segments.h>
58#include <machine/sysarch.h>
59
60#include <vm/pmap.h>
61#include <vm/vm.h>
62#include <vm/vm_map.h>
63
64#include <security/audit/audit.h>
65
66#include <i386/linux/linux.h>
67#include <i386/linux/linux_proto.h>
68#include <compat/linux/linux_emul.h>
69#include <compat/linux/linux_ipc.h>
70#include <compat/linux/linux_misc.h>
71#include <compat/linux/linux_mmap.h>
72#include <compat/linux/linux_signal.h>
73#include <compat/linux/linux_util.h>
74
75#include <i386/include/pcb.h>			/* needed for pcb definition in linux_set_thread_area */
76
77#include "opt_posix.h"
78
79extern struct sysentvec elf32_freebsd_sysvec;	/* defined in i386/i386/elf_machdep.c */
80
81struct l_descriptor {
82	l_uint		entry_number;
83	l_ulong		base_addr;
84	l_uint		limit;
85	l_uint		seg_32bit:1;
86	l_uint		contents:2;
87	l_uint		read_exec_only:1;
88	l_uint		limit_in_pages:1;
89	l_uint		seg_not_present:1;
90	l_uint		useable:1;
91};
92
93struct l_old_select_argv {
94	l_int		nfds;
95	l_fd_set	*readfds;
96	l_fd_set	*writefds;
97	l_fd_set	*exceptfds;
98	struct l_timeval	*timeout;
99};
100
101
102int
103linux_execve(struct thread *td, struct linux_execve_args *args)
104{
105	struct image_args eargs;
106	char *newpath;
107	int error;
108
109	LCONVPATHEXIST(td, args->path, &newpath);
110
111	error = exec_copyin_args(&eargs, newpath, UIO_SYSSPACE,
112	    args->argp, args->envp);
113	free(newpath, M_TEMP);
114	if (error == 0)
115		error = linux_common_execve(td, &eargs);
116	AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td);
117	return (error);
118}
119
120struct l_ipc_kludge {
121	struct l_msgbuf *msgp;
122	l_long msgtyp;
123};
124
125int
126linux_ipc(struct thread *td, struct linux_ipc_args *args)
127{
128
129	switch (args->what & 0xFFFF) {
130	case LINUX_SEMOP: {
131		struct linux_semop_args a;
132
133		a.semid = args->arg1;
134		a.tsops = PTRIN(args->ptr);
135		a.nsops = args->arg2;
136		return (linux_semop(td, &a));
137	}
138	case LINUX_SEMGET: {
139		struct linux_semget_args a;
140
141		a.key = args->arg1;
142		a.nsems = args->arg2;
143		a.semflg = args->arg3;
144		return (linux_semget(td, &a));
145	}
146	case LINUX_SEMCTL: {
147		struct linux_semctl_args a;
148		int error;
149
150		a.semid = args->arg1;
151		a.semnum = args->arg2;
152		a.cmd = args->arg3;
153		error = copyin(PTRIN(args->ptr), &a.arg, sizeof(a.arg));
154		if (error)
155			return (error);
156		return (linux_semctl(td, &a));
157	}
158	case LINUX_MSGSND: {
159		struct linux_msgsnd_args a;
160
161		a.msqid = args->arg1;
162		a.msgp = PTRIN(args->ptr);
163		a.msgsz = args->arg2;
164		a.msgflg = args->arg3;
165		return (linux_msgsnd(td, &a));
166	}
167	case LINUX_MSGRCV: {
168		struct linux_msgrcv_args a;
169
170		a.msqid = args->arg1;
171		a.msgsz = args->arg2;
172		a.msgflg = args->arg3;
173		if ((args->what >> 16) == 0) {
174			struct l_ipc_kludge tmp;
175			int error;
176
177			if (args->ptr == 0)
178				return (EINVAL);
179			error = copyin(PTRIN(args->ptr), &tmp, sizeof(tmp));
180			if (error)
181				return (error);
182			a.msgp = PTRIN(tmp.msgp);
183			a.msgtyp = tmp.msgtyp;
184		} else {
185			a.msgp = PTRIN(args->ptr);
186			a.msgtyp = args->arg5;
187		}
188		return (linux_msgrcv(td, &a));
189	}
190	case LINUX_MSGGET: {
191		struct linux_msgget_args a;
192
193		a.key = args->arg1;
194		a.msgflg = args->arg2;
195		return (linux_msgget(td, &a));
196	}
197	case LINUX_MSGCTL: {
198		struct linux_msgctl_args a;
199
200		a.msqid = args->arg1;
201		a.cmd = args->arg2;
202		a.buf = PTRIN(args->ptr);
203		return (linux_msgctl(td, &a));
204	}
205	case LINUX_SHMAT: {
206		struct linux_shmat_args a;
207		l_uintptr_t addr;
208		int error;
209
210		a.shmid = args->arg1;
211		a.shmaddr = PTRIN(args->ptr);
212		a.shmflg = args->arg2;
213		error = linux_shmat(td, &a);
214		if (error != 0)
215			return (error);
216		addr = td->td_retval[0];
217		error = copyout(&addr, PTRIN(args->arg3), sizeof(addr));
218		td->td_retval[0] = 0;
219		return (error);
220	}
221	case LINUX_SHMDT: {
222		struct linux_shmdt_args a;
223
224		a.shmaddr = PTRIN(args->ptr);
225		return (linux_shmdt(td, &a));
226	}
227	case LINUX_SHMGET: {
228		struct linux_shmget_args a;
229
230		a.key = args->arg1;
231		a.size = args->arg2;
232		a.shmflg = args->arg3;
233		return (linux_shmget(td, &a));
234	}
235	case LINUX_SHMCTL: {
236		struct linux_shmctl_args a;
237
238		a.shmid = args->arg1;
239		a.cmd = args->arg2;
240		a.buf = PTRIN(args->ptr);
241		return (linux_shmctl(td, &a));
242	}
243	default:
244		break;
245	}
246
247	return (EINVAL);
248}
249
250int
251linux_old_select(struct thread *td, struct linux_old_select_args *args)
252{
253	struct l_old_select_argv linux_args;
254	struct linux_select_args newsel;
255	int error;
256
257	error = copyin(args->ptr, &linux_args, sizeof(linux_args));
258	if (error)
259		return (error);
260
261	newsel.nfds = linux_args.nfds;
262	newsel.readfds = linux_args.readfds;
263	newsel.writefds = linux_args.writefds;
264	newsel.exceptfds = linux_args.exceptfds;
265	newsel.timeout = linux_args.timeout;
266	return (linux_select(td, &newsel));
267}
268
269int
270linux_set_cloned_tls(struct thread *td, void *desc)
271{
272	struct segment_descriptor sd;
273	struct l_user_desc info;
274	int idx, error;
275	int a[2];
276
277	error = copyin(desc, &info, sizeof(struct l_user_desc));
278	if (error) {
279		linux_msg(td, "set_cloned_tls copyin failed!");
280	} else {
281		idx = info.entry_number;
282
283		/*
284		 * looks like we're getting the idx we returned
285		 * in the set_thread_area() syscall
286		 */
287		if (idx != 6 && idx != 3) {
288			linux_msg(td, "set_cloned_tls resetting idx!");
289			idx = 3;
290		}
291
292		/* this doesnt happen in practice */
293		if (idx == 6) {
294			/* we might copy out the entry_number as 3 */
295			info.entry_number = 3;
296			error = copyout(&info, desc, sizeof(struct l_user_desc));
297			if (error)
298				linux_msg(td, "set_cloned_tls copyout failed!");
299		}
300
301		a[0] = LINUX_LDT_entry_a(&info);
302		a[1] = LINUX_LDT_entry_b(&info);
303
304		memcpy(&sd, &a, sizeof(a));
305		/* set %gs */
306		td->td_pcb->pcb_gsd = sd;
307		td->td_pcb->pcb_gs = GSEL(GUGS_SEL, SEL_UPL);
308	}
309
310	return (error);
311}
312
313int
314linux_set_upcall_kse(struct thread *td, register_t stack)
315{
316
317	if (stack)
318		td->td_frame->tf_esp = stack;
319
320	/*
321	 * The newly created Linux thread returns
322	 * to the user space by the same path that a parent do.
323	 */
324	td->td_frame->tf_eax = 0;
325	return (0);
326}
327
328int
329linux_mmap2(struct thread *td, struct linux_mmap2_args *args)
330{
331
332	return (linux_mmap_common(td, args->addr, args->len, args->prot,
333		args->flags, args->fd, (uint64_t)(uint32_t)args->pgoff *
334		PAGE_SIZE));
335}
336
337int
338linux_mmap(struct thread *td, struct linux_mmap_args *args)
339{
340	int error;
341	struct l_mmap_argv linux_args;
342
343	error = copyin(args->ptr, &linux_args, sizeof(linux_args));
344	if (error)
345		return (error);
346
347	return (linux_mmap_common(td, linux_args.addr, linux_args.len,
348	    linux_args.prot, linux_args.flags, linux_args.fd,
349	    (uint32_t)linux_args.pgoff));
350}
351
352int
353linux_mprotect(struct thread *td, struct linux_mprotect_args *uap)
354{
355
356	return (linux_mprotect_common(td, PTROUT(uap->addr), uap->len, uap->prot));
357}
358
359int
360linux_madvise(struct thread *td, struct linux_madvise_args *uap)
361{
362
363	return (linux_madvise_common(td, PTROUT(uap->addr), uap->len, uap->behav));
364}
365
366int
367linux_ioperm(struct thread *td, struct linux_ioperm_args *args)
368{
369	int error;
370	struct i386_ioperm_args iia;
371
372	iia.start = args->start;
373	iia.length = args->length;
374	iia.enable = args->enable;
375	error = i386_set_ioperm(td, &iia);
376	return (error);
377}
378
379int
380linux_iopl(struct thread *td, struct linux_iopl_args *args)
381{
382	int error;
383
384	if (args->level < 0 || args->level > 3)
385		return (EINVAL);
386	if ((error = priv_check(td, PRIV_IO)) != 0)
387		return (error);
388	if ((error = securelevel_gt(td->td_ucred, 0)) != 0)
389		return (error);
390	td->td_frame->tf_eflags = (td->td_frame->tf_eflags & ~PSL_IOPL) |
391	    (args->level * (PSL_IOPL / 3));
392	return (0);
393}
394
395int
396linux_modify_ldt(struct thread *td, struct linux_modify_ldt_args *uap)
397{
398	int error;
399	struct i386_ldt_args ldt;
400	struct l_descriptor ld;
401	union descriptor desc;
402	int size, written;
403
404	switch (uap->func) {
405	case 0x00: /* read_ldt */
406		ldt.start = 0;
407		ldt.descs = uap->ptr;
408		ldt.num = uap->bytecount / sizeof(union descriptor);
409		error = i386_get_ldt(td, &ldt);
410		td->td_retval[0] *= sizeof(union descriptor);
411		break;
412	case 0x02: /* read_default_ldt = 0 */
413		size = 5*sizeof(struct l_desc_struct);
414		if (size > uap->bytecount)
415			size = uap->bytecount;
416		for (written = error = 0; written < size && error == 0; written++)
417			error = subyte((char *)uap->ptr + written, 0);
418		td->td_retval[0] = written;
419		break;
420	case 0x01: /* write_ldt */
421	case 0x11: /* write_ldt */
422		if (uap->bytecount != sizeof(ld))
423			return (EINVAL);
424
425		error = copyin(uap->ptr, &ld, sizeof(ld));
426		if (error)
427			return (error);
428
429		ldt.start = ld.entry_number;
430		ldt.descs = &desc;
431		ldt.num = 1;
432		desc.sd.sd_lolimit = (ld.limit & 0x0000ffff);
433		desc.sd.sd_hilimit = (ld.limit & 0x000f0000) >> 16;
434		desc.sd.sd_lobase = (ld.base_addr & 0x00ffffff);
435		desc.sd.sd_hibase = (ld.base_addr & 0xff000000) >> 24;
436		desc.sd.sd_type = SDT_MEMRO | ((ld.read_exec_only ^ 1) << 1) |
437			(ld.contents << 2);
438		desc.sd.sd_dpl = 3;
439		desc.sd.sd_p = (ld.seg_not_present ^ 1);
440		desc.sd.sd_xx = 0;
441		desc.sd.sd_def32 = ld.seg_32bit;
442		desc.sd.sd_gran = ld.limit_in_pages;
443		error = i386_set_ldt(td, &ldt, &desc);
444		break;
445	default:
446		error = ENOSYS;
447		break;
448	}
449
450	if (error == EOPNOTSUPP) {
451		linux_msg(td, "modify_ldt needs kernel option USER_LDT");
452		error = ENOSYS;
453	}
454
455	return (error);
456}
457
458int
459linux_sigaction(struct thread *td, struct linux_sigaction_args *args)
460{
461	l_osigaction_t osa;
462	l_sigaction_t act, oact;
463	int error;
464
465	if (args->nsa != NULL) {
466		error = copyin(args->nsa, &osa, sizeof(l_osigaction_t));
467		if (error)
468			return (error);
469		act.lsa_handler = osa.lsa_handler;
470		act.lsa_flags = osa.lsa_flags;
471		act.lsa_restorer = osa.lsa_restorer;
472		LINUX_SIGEMPTYSET(act.lsa_mask);
473		act.lsa_mask.__mask = osa.lsa_mask;
474	}
475
476	error = linux_do_sigaction(td, args->sig, args->nsa ? &act : NULL,
477	    args->osa ? &oact : NULL);
478
479	if (args->osa != NULL && !error) {
480		osa.lsa_handler = oact.lsa_handler;
481		osa.lsa_flags = oact.lsa_flags;
482		osa.lsa_restorer = oact.lsa_restorer;
483		osa.lsa_mask = oact.lsa_mask.__mask;
484		error = copyout(&osa, args->osa, sizeof(l_osigaction_t));
485	}
486
487	return (error);
488}
489
490/*
491 * Linux has two extra args, restart and oldmask.  We dont use these,
492 * but it seems that "restart" is actually a context pointer that
493 * enables the signal to happen with a different register set.
494 */
495int
496linux_sigsuspend(struct thread *td, struct linux_sigsuspend_args *args)
497{
498	sigset_t sigmask;
499	l_sigset_t mask;
500
501	LINUX_SIGEMPTYSET(mask);
502	mask.__mask = args->mask;
503	linux_to_bsd_sigset(&mask, &sigmask);
504	return (kern_sigsuspend(td, sigmask));
505}
506
507int
508linux_rt_sigsuspend(struct thread *td, struct linux_rt_sigsuspend_args *uap)
509{
510	l_sigset_t lmask;
511	sigset_t sigmask;
512	int error;
513
514	if (uap->sigsetsize != sizeof(l_sigset_t))
515		return (EINVAL);
516
517	error = copyin(uap->newset, &lmask, sizeof(l_sigset_t));
518	if (error)
519		return (error);
520
521	linux_to_bsd_sigset(&lmask, &sigmask);
522	return (kern_sigsuspend(td, sigmask));
523}
524
525int
526linux_pause(struct thread *td, struct linux_pause_args *args)
527{
528	struct proc *p = td->td_proc;
529	sigset_t sigmask;
530
531	PROC_LOCK(p);
532	sigmask = td->td_sigmask;
533	PROC_UNLOCK(p);
534	return (kern_sigsuspend(td, sigmask));
535}
536
537int
538linux_sigaltstack(struct thread *td, struct linux_sigaltstack_args *uap)
539{
540	stack_t ss, oss;
541	l_stack_t lss;
542	int error;
543
544	if (uap->uss != NULL) {
545		error = copyin(uap->uss, &lss, sizeof(l_stack_t));
546		if (error)
547			return (error);
548
549		ss.ss_sp = lss.ss_sp;
550		ss.ss_size = lss.ss_size;
551		ss.ss_flags = linux_to_bsd_sigaltstack(lss.ss_flags);
552	}
553	error = kern_sigaltstack(td, (uap->uss != NULL) ? &ss : NULL,
554	    (uap->uoss != NULL) ? &oss : NULL);
555	if (!error && uap->uoss != NULL) {
556		lss.ss_sp = oss.ss_sp;
557		lss.ss_size = oss.ss_size;
558		lss.ss_flags = bsd_to_linux_sigaltstack(oss.ss_flags);
559		error = copyout(&lss, uap->uoss, sizeof(l_stack_t));
560	}
561
562	return (error);
563}
564
565int
566linux_set_thread_area(struct thread *td, struct linux_set_thread_area_args *args)
567{
568	struct l_user_desc info;
569	int error;
570	int idx;
571	int a[2];
572	struct segment_descriptor sd;
573
574	error = copyin(args->desc, &info, sizeof(struct l_user_desc));
575	if (error)
576		return (error);
577
578	idx = info.entry_number;
579	/*
580	 * Semantics of Linux version: every thread in the system has array of
581	 * 3 tls descriptors. 1st is GLIBC TLS, 2nd is WINE, 3rd unknown. This
582	 * syscall loads one of the selected tls decriptors with a value and
583	 * also loads GDT descriptors 6, 7 and 8 with the content of the
584	 * per-thread descriptors.
585	 *
586	 * Semantics of FreeBSD version: I think we can ignore that Linux has 3
587	 * per-thread descriptors and use just the 1st one. The tls_array[]
588	 * is used only in set/get-thread_area() syscalls and for loading the
589	 * GDT descriptors. In FreeBSD we use just one GDT descriptor for TLS
590	 * so we will load just one.
591	 *
592	 * XXX: this doesn't work when a user space process tries to use more
593	 * than 1 TLS segment. Comment in the Linux sources says wine might do
594	 * this.
595	 */
596
597	/*
598	 * we support just GLIBC TLS now
599	 * we should let 3 proceed as well because we use this segment so
600	 * if code does two subsequent calls it should succeed
601	 */
602	if (idx != 6 && idx != -1 && idx != 3)
603		return (EINVAL);
604
605	/*
606	 * we have to copy out the GDT entry we use
607	 * FreeBSD uses GDT entry #3 for storing %gs so load that
608	 *
609	 * XXX: what if a user space program doesn't check this value and tries
610	 * to use 6, 7 or 8?
611	 */
612	idx = info.entry_number = 3;
613	error = copyout(&info, args->desc, sizeof(struct l_user_desc));
614	if (error)
615		return (error);
616
617	if (LINUX_LDT_empty(&info)) {
618		a[0] = 0;
619		a[1] = 0;
620	} else {
621		a[0] = LINUX_LDT_entry_a(&info);
622		a[1] = LINUX_LDT_entry_b(&info);
623	}
624
625	memcpy(&sd, &a, sizeof(a));
626	/* this is taken from i386 version of cpu_set_user_tls() */
627	critical_enter();
628	/* set %gs */
629	td->td_pcb->pcb_gsd = sd;
630	PCPU_GET(fsgs_gdt)[1] = sd;
631	load_gs(GSEL(GUGS_SEL, SEL_UPL));
632	critical_exit();
633
634	return (0);
635}
636
637int
638linux_get_thread_area(struct thread *td, struct linux_get_thread_area_args *args)
639{
640
641	struct l_user_desc info;
642	int error;
643	int idx;
644	struct l_desc_struct desc;
645	struct segment_descriptor sd;
646
647	error = copyin(args->desc, &info, sizeof(struct l_user_desc));
648	if (error)
649		return (error);
650
651	idx = info.entry_number;
652	/* XXX: I am not sure if we want 3 to be allowed too. */
653	if (idx != 6 && idx != 3)
654		return (EINVAL);
655
656	idx = 3;
657
658	memset(&info, 0, sizeof(info));
659
660	sd = PCPU_GET(fsgs_gdt)[1];
661
662	memcpy(&desc, &sd, sizeof(desc));
663
664	info.entry_number = idx;
665	info.base_addr = LINUX_GET_BASE(&desc);
666	info.limit = LINUX_GET_LIMIT(&desc);
667	info.seg_32bit = LINUX_GET_32BIT(&desc);
668	info.contents = LINUX_GET_CONTENTS(&desc);
669	info.read_exec_only = !LINUX_GET_WRITABLE(&desc);
670	info.limit_in_pages = LINUX_GET_LIMIT_PAGES(&desc);
671	info.seg_not_present = !LINUX_GET_PRESENT(&desc);
672	info.useable = LINUX_GET_USEABLE(&desc);
673
674	error = copyout(&info, args->desc, sizeof(struct l_user_desc));
675	if (error)
676		return (EFAULT);
677
678	return (0);
679}
680
681/* XXX: this wont work with module - convert it */
682int
683linux_mq_open(struct thread *td, struct linux_mq_open_args *args)
684{
685#ifdef P1003_1B_MQUEUE
686	return (sys_kmq_open(td, (struct kmq_open_args *)args));
687#else
688	return (ENOSYS);
689#endif
690}
691
692int
693linux_mq_unlink(struct thread *td, struct linux_mq_unlink_args *args)
694{
695#ifdef P1003_1B_MQUEUE
696	return (sys_kmq_unlink(td, (struct kmq_unlink_args *)args));
697#else
698	return (ENOSYS);
699#endif
700}
701
702int
703linux_mq_timedsend(struct thread *td, struct linux_mq_timedsend_args *args)
704{
705#ifdef P1003_1B_MQUEUE
706	return (sys_kmq_timedsend(td, (struct kmq_timedsend_args *)args));
707#else
708	return (ENOSYS);
709#endif
710}
711
712int
713linux_mq_timedreceive(struct thread *td, struct linux_mq_timedreceive_args *args)
714{
715#ifdef P1003_1B_MQUEUE
716	return (sys_kmq_timedreceive(td, (struct kmq_timedreceive_args *)args));
717#else
718	return (ENOSYS);
719#endif
720}
721
722int
723linux_mq_notify(struct thread *td, struct linux_mq_notify_args *args)
724{
725#ifdef P1003_1B_MQUEUE
726	return (sys_kmq_notify(td, (struct kmq_notify_args *)args));
727#else
728	return (ENOSYS);
729#endif
730}
731
732int
733linux_mq_getsetattr(struct thread *td, struct linux_mq_getsetattr_args *args)
734{
735#ifdef P1003_1B_MQUEUE
736	return (sys_kmq_setattr(td, (struct kmq_setattr_args *)args));
737#else
738	return (ENOSYS);
739#endif
740}
741