Skip to content

Commit

Permalink
sysv ipc: match FreeBSD for {msg,sem,shm}sys args
Browse files Browse the repository at this point in the history
Restore the use of int as the argument for these extremely obsolete
syscalls.  It would arguably be more accurate to use syscallarg_t, but
in practice it doesn't matter.  First, because these are x86 only and
really only used on practice on ancient i386 binaries and second,
because of the way they are dispatched to the real sys_ syscall
implementations.  The only thing that might matter is the number of
arguments.
  • Loading branch information
brooksdavis committed Aug 8, 2024
1 parent cfca9fa commit c31758d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 107 deletions.
24 changes: 12 additions & 12 deletions sys/kern/syscalls.master
Original file line number Diff line number Diff line change
Expand Up @@ -1054,28 +1054,28 @@
169 AUE_SEMSYS NOSTD|VARARG4 {
int semsys(
int which,
intptr_t a2,
intptr_t a3,
intptr_t a4,
intptr_t a5
int a2,
int a3,
int a4,
int a5
);
}
170 AUE_MSGSYS NOSTD|VARARG5 {
int msgsys(
int which,
intptr_t a2,
intptr_t a3,
intptr_t a4,
intptr_t a5,
intptr_t a6
int a2,
int a3,
int a4,
int a5,
int a6
);
}
171 AUE_SHMSYS NOSTD|VARARG3 {
int shmsys(
int which,
intptr_t a2,
intptr_t a3,
intptr_t a4
int a2,
int a3,
int a4
);
}
172 AUE_NULL RESERVED
Expand Down
26 changes: 1 addition & 25 deletions sys/kern/sysv_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ static struct syscall_helper_data msg64_syscalls[] = {
FREEBSD64_SYSCALL_INIT_HELPER(freebsd64_msgrcv),
FREEBSD64_SYSCALL_INIT_HELPER_COMPAT(msgget),
#if defined(COMPAT_FREEBSD7)
FREEBSD64_SYSCALL_INIT_HELPER(freebsd64_msgsys),
FREEBSD64_SYSCALL_INIT_HELPER_COMPAT(msgsys),
FREEBSD64_SYSCALL_INIT_HELPER(freebsd7_freebsd64_msgctl),
#endif
SYSCALL_INIT_LAST
Expand Down Expand Up @@ -1818,30 +1818,6 @@ freebsd32_msgrcv(struct thread *td, struct freebsd32_msgrcv_args *uap)
#endif

#ifdef COMPAT_FREEBSD64
int
freebsd64_msgsys(struct thread *td, struct freebsd64_msgsys_args *uap)
{

#ifdef COMPAT_FREEBSD7
AUDIT_ARG_SVIPC_WHICH(uap->which);
switch (uap->which) {
case 0:
return (freebsd7_freebsd64_msgctl(td,
(struct freebsd7_freebsd64_msgctl_args *)&uap->a2));
case 2:
return (freebsd64_msgsnd(td,
(struct freebsd64_msgsnd_args *)&uap->a2));
case 3:
return (freebsd64_msgrcv(td,
(struct freebsd64_msgrcv_args *)&uap->a2));
default:
return (sys_msgsys(td, (struct msgsys_args *)uap));
}
#else
return (nosys(td, (struct nosys_args *)uap));
#endif
}

#if defined(COMPAT_FREEBSD7)
int
freebsd7_freebsd64_msgctl(struct thread *td,
Expand Down
22 changes: 1 addition & 21 deletions sys/kern/sysv_sem.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ static struct syscall_helper_data sem64_syscalls[] = {
FREEBSD64_SYSCALL_INIT_HELPER_COMPAT(semget),
FREEBSD64_SYSCALL_INIT_HELPER(freebsd64_semop),
#if defined(COMPAT_FREEBSD7)
FREEBSD64_SYSCALL_INIT_HELPER(freebsd64_semsys),
FREEBSD64_SYSCALL_INIT_HELPER_COMPAT(semsys),
FREEBSD64_SYSCALL_INIT_HELPER(freebsd7_freebsd64___semctl),
#endif
SYSCALL_INIT_LAST
Expand Down Expand Up @@ -2072,25 +2072,6 @@ freebsd32___semctl(struct thread *td, struct freebsd32___semctl_args *uap)
#endif /* COMPAT_FREEBSD32 */

#ifdef COMPAT_FREEBSD64

int
freebsd64_semsys(struct thread *td, struct freebsd64_semsys_args *uap)
{

#ifdef COMPAT_FREEBSD7
AUDIT_ARG_SVIPC_WHICH(uap->which);
switch (uap->which) {
case 0:
return (freebsd7_freebsd64___semctl(td,
(struct freebsd7_freebsd64___semctl_args *)&uap->a2));
default:
return (sys_semsys(td, (struct semsys_args *)uap));
}
#else
return (nosys(td, (struct nosys_args *)uap));
#endif
}

#if defined(COMPAT_FREEBSD7)
int
freebsd7_freebsd64___semctl(struct thread *td,
Expand Down Expand Up @@ -2244,7 +2225,6 @@ freebsd64___semctl(struct thread *td, struct freebsd64___semctl_args *uap)
int
freebsd64_semop(struct thread *td, struct freebsd64_semop_args *uap)
{

return (kern_semop(td, uap->semid,
__USER_CAP_ARRAY(uap->sops, uap->nsops), uap->nsops, NULL));
}
Expand Down
52 changes: 3 additions & 49 deletions sys/kern/sysv_shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1089,8 +1089,10 @@ static struct syscall_helper_data shm64_syscalls[] = {
FREEBSD64_SYSCALL_INIT_HELPER(freebsd64_shmat),
FREEBSD64_SYSCALL_INIT_HELPER(freebsd64_shmdt),
FREEBSD64_SYSCALL_INIT_HELPER_COMPAT(shmget),
FREEBSD64_SYSCALL_INIT_HELPER(freebsd64_shmsys),
FREEBSD64_SYSCALL_INIT_HELPER(freebsd64_shmctl),
#if defined(__i386__) && (defined(COMPAT_FREEBSD4) || defined(COMPAT_43))
FREEBSD64_SYSCALL_INIT_HELPER_COMPAT(shmsys),
#endif
#if defined(COMPAT_FREEBSD7)
FREEBSD64_SYSCALL_INIT_HELPER(freebsd7_freebsd64_shmctl),
#endif
Expand Down Expand Up @@ -1798,64 +1800,16 @@ freebsd32_shmctl(struct thread *td, struct freebsd32_shmctl_args *uap)
int
freebsd64_shmat(struct thread *td, struct freebsd64_shmat_args *uap)
{

return (kern_shmat(td, uap->shmid, __USER_CAP_UNBOUND(uap->shmaddr),
uap->shmflg));
}

int
freebsd64_shmdt(struct thread *td, struct freebsd64_shmdt_args *uap)
{

return (kern_shmdt(td, __USER_CAP_UNBOUND(uap->shmaddr)));
}

int
freebsd64_shmsys(struct thread *td, struct freebsd64_shmsys_args *uap)
{

#ifdef COMPAT_FREEBSD7
AUDIT_ARG_SVIPC_WHICH(uap->which);
switch (uap->which) {
case 0: { /* shmat */
struct shmat_args ap;

ap.shmid = uap->a2;
ap.shmaddr = (void *)uap->a3;
ap.shmflg = uap->a4;
return (sysent[SYS_shmat].sy_call(td, &ap));
}
case 2: { /* shmdt */
struct shmdt_args ap;

ap.shmaddr = (void *)uap->a2;
return (sysent[SYS_shmdt].sy_call(td, &ap));
}
case 3: { /* shmget */
struct shmget_args ap;

ap.key = uap->a2;
ap.size = uap->a3;
ap.shmflg = uap->a4;
return (sysent[SYS_shmget].sy_call(td, &ap));
}
case 4: { /* shmctl */
struct freebsd7_freebsd64_shmctl_args ap;

ap.shmid = uap->a2;
ap.cmd = uap->a3;
ap.buf = (void *)uap->a4;
return (freebsd7_freebsd64_shmctl(td, &ap));
}
case 1: /* oshmctl */
default:
return (EINVAL);
}
#else
return (nosys(td, NULL));
#endif
}

#ifdef COMPAT_FREEBSD7
int
freebsd7_freebsd64_shmctl(struct thread *td,
Expand Down

0 comments on commit c31758d

Please sign in to comment.