Skip to content

Commit

Permalink
Remove never implemented sbrk and sstk syscalls
Browse files Browse the repository at this point in the history
Both system calls were stubs returning EOPNOTSUPP and libc did not
provide _ or __sys_ prefixed symbols.  The actual implementation of
sbrk(2) is on top of the undocumented break(2) system call.

Technically this is a change in ABI, but no non-contrived program ever
called these syscalls.

Reviewed by:	kib, emaste
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42872
  • Loading branch information
brooksdavis committed Dec 4, 2023
1 parent 4b92c77 commit 7893419
Show file tree
Hide file tree
Showing 18 changed files with 19 additions and 155 deletions.
3 changes: 1 addition & 2 deletions lib/libc/aarch64/sys/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ MDASM= cerror.S \
vfork.S

# Don't generate default code for these syscalls:
NOASM+= sbrk.o \
vfork.o
NOASM+= vfork.o
2 changes: 1 addition & 1 deletion lib/libc/amd64/sys/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ SRCS+= \
MDASM= vfork.S cerror.S getcontext.S

# Don't generate default code for these syscalls:
NOASM+= sbrk.o vfork.o
NOASM+= vfork.o
2 changes: 1 addition & 1 deletion lib/libc/arm/sys/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ SRCS+= __vdso_gettc.c \
MDASM= Ovfork.S cerror.S syscall.S

# Don't generate default code for these syscalls:
NOASM+= sbrk.o vfork.o
NOASM+= vfork.o
2 changes: 1 addition & 1 deletion lib/libc/i386/sys/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SRCS+= i386_get_fsbase.c i386_get_gsbase.c i386_get_ioperm.c i386_get_ldt.c \

MDASM= Ovfork.S cerror.S getcontext.S syscall.S

NOASM+= sbrk.o vfork.o
NOASM+= vfork.o

MAN+= i386_get_ioperm.2 i386_get_ldt.2 i386_vm86.2
MAN+= i386_set_watch.3
Expand Down
2 changes: 1 addition & 1 deletion lib/libc/riscv/sys/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ MDASM= cerror.S \
vfork.S

# Don't generate default code for these syscalls:
NOASM+= sbrk.o vfork.o
NOASM+= vfork.o
1 change: 0 additions & 1 deletion lib/libc/sys/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#
NOASM= exit.o \
getlogin.o \
sstk.o \
yield.o
PSEUDO= _exit.o \
_getlogin.o
Expand Down
4 changes: 2 additions & 2 deletions sys/compat/freebsd32/freebsd32_syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
#define FREEBSD32_SYS_vfork 66
/* 67 is obsolete vread */
/* 68 is obsolete vwrite */
#define FREEBSD32_SYS_sbrk 69
#define FREEBSD32_SYS_sstk 70
/* 69 is obsolete sbrk */
/* 70 is obsolete sstk */
/* 71 is old freebsd32_mmap */
#define FREEBSD32_SYS_freebsd11_vadvise 72
#define FREEBSD32_SYS_munmap 73
Expand Down
4 changes: 2 additions & 2 deletions sys/compat/freebsd32/freebsd32_syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ const char *freebsd32_syscallnames[] = {
"vfork", /* 66 = vfork */
"obs_vread", /* 67 = obsolete vread */
"obs_vwrite", /* 68 = obsolete vwrite */
"sbrk", /* 69 = sbrk */
"sstk", /* 70 = sstk */
"obs_sbrk", /* 69 = obsolete sbrk */
"obs_sstk", /* 70 = obsolete sstk */
"compat.freebsd32_mmap", /* 71 = old freebsd32_mmap */
"compat11.vadvise", /* 72 = freebsd11 vadvise */
"munmap", /* 73 = munmap */
Expand Down
4 changes: 2 additions & 2 deletions sys/compat/freebsd32/freebsd32_sysent.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ struct sysent freebsd32_sysent[] = {
{ .sy_narg = 0, .sy_call = (sy_call_t *)sys_vfork, .sy_auevent = AUE_VFORK, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 66 = vfork */
{ .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 67 = obsolete vread */
{ .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 68 = obsolete vwrite */
{ .sy_narg = AS(sbrk_args), .sy_call = (sy_call_t *)sys_sbrk, .sy_auevent = AUE_SBRK, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 69 = sbrk */
{ .sy_narg = AS(sstk_args), .sy_call = (sy_call_t *)sys_sstk, .sy_auevent = AUE_SSTK, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 70 = sstk */
{ .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 69 = obsolete sbrk */
{ .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 70 = obsolete sstk */
{ compat(AS(ofreebsd32_mmap_args),freebsd32_mmap), .sy_auevent = AUE_MMAP, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 71 = old freebsd32_mmap */
{ compat11(AS(freebsd11_vadvise_args),vadvise), .sy_auevent = AUE_O_VADVISE, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 72 = freebsd11 vadvise */
{ .sy_narg = AS(munmap_args), .sy_call = (sy_call_t *)sys_munmap, .sy_auevent = AUE_MUNMAP, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 73 = munmap */
Expand Down
44 changes: 0 additions & 44 deletions sys/compat/freebsd32/freebsd32_systrace_args.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,20 +421,6 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
*n_args = 0;
break;
}
/* sbrk */
case 69: {
struct sbrk_args *p = params;
iarg[a++] = p->incr; /* int */
*n_args = 1;
break;
}
/* sstk */
case 70: {
struct sstk_args *p = params;
iarg[a++] = p->incr; /* int */
*n_args = 1;
break;
}
/* munmap */
case 73: {
struct munmap_args *p = params;
Expand Down Expand Up @@ -4009,26 +3995,6 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
/* vfork */
case 66:
break;
/* sbrk */
case 69:
switch (ndx) {
case 0:
p = "int";
break;
default:
break;
};
break;
/* sstk */
case 70:
switch (ndx) {
case 0:
p = "int";
break;
default:
break;
};
break;
/* munmap */
case 73:
switch (ndx) {
Expand Down Expand Up @@ -9347,16 +9313,6 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
break;
/* vfork */
case 66:
/* sbrk */
case 69:
if (ndx == 0 || ndx == 1)
p = "int";
break;
/* sstk */
case 70:
if (ndx == 0 || ndx == 1)
p = "int";
break;
/* munmap */
case 73:
if (ndx == 0 || ndx == 1)
Expand Down
4 changes: 2 additions & 2 deletions sys/kern/init_sysent.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ struct sysent sysent[] = {
{ .sy_narg = 0, .sy_call = (sy_call_t *)sys_vfork, .sy_auevent = AUE_VFORK, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 66 = vfork */
{ .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 67 = obsolete vread */
{ .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 68 = obsolete vwrite */
{ .sy_narg = AS(sbrk_args), .sy_call = (sy_call_t *)sys_sbrk, .sy_auevent = AUE_SBRK, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 69 = sbrk */
{ .sy_narg = AS(sstk_args), .sy_call = (sy_call_t *)sys_sstk, .sy_auevent = AUE_SSTK, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 70 = sstk */
{ .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 69 = obsolete sbrk */
{ .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 70 = obsolete sstk */
{ compat(AS(ommap_args),mmap), .sy_auevent = AUE_MMAP, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 71 = old mmap */
{ compat11(AS(freebsd11_vadvise_args),vadvise), .sy_auevent = AUE_O_VADVISE, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 72 = freebsd11 vadvise */
{ .sy_narg = AS(munmap_args), .sy_call = (sy_call_t *)sys_munmap, .sy_auevent = AUE_MUNMAP, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 73 = munmap */
Expand Down
4 changes: 2 additions & 2 deletions sys/kern/syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ const char *syscallnames[] = {
"vfork", /* 66 = vfork */
"obs_vread", /* 67 = obsolete vread */
"obs_vwrite", /* 68 = obsolete vwrite */
"sbrk", /* 69 = sbrk */
"sstk", /* 70 = sstk */
"obs_sbrk", /* 69 = obsolete sbrk */
"obs_sstk", /* 70 = obsolete sstk */
"compat.mmap", /* 71 = old mmap */
"compat11.vadvise", /* 72 = freebsd11 vadvise */
"munmap", /* 73 = munmap */
Expand Down
12 changes: 2 additions & 10 deletions sys/kern/syscalls.master
Original file line number Diff line number Diff line change
Expand Up @@ -502,16 +502,8 @@
}
67 AUE_NULL OBSOL vread
68 AUE_NULL OBSOL vwrite
69 AUE_SBRK STD|CAPENABLED {
int sbrk(
int incr
);
}
70 AUE_SSTK STD|CAPENABLED {
int sstk(
int incr
);
}
69 AUE_NULL OBSOL sbrk
70 AUE_NULL OBSOL sstk
71 AUE_MMAP COMPAT|CAPENABLED {
void *mmap(
_In_ void *addr,
Expand Down
44 changes: 0 additions & 44 deletions sys/kern/systrace_args.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,20 +418,6 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
*n_args = 0;
break;
}
/* sbrk */
case 69: {
struct sbrk_args *p = params;
iarg[a++] = p->incr; /* int */
*n_args = 1;
break;
}
/* sstk */
case 70: {
struct sstk_args *p = params;
iarg[a++] = p->incr; /* int */
*n_args = 1;
break;
}
/* munmap */
case 73: {
struct munmap_args *p = params;
Expand Down Expand Up @@ -4096,26 +4082,6 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
/* vfork */
case 66:
break;
/* sbrk */
case 69:
switch (ndx) {
case 0:
p = "int";
break;
default:
break;
};
break;
/* sstk */
case 70:
switch (ndx) {
case 0:
p = "int";
break;
default:
break;
};
break;
/* munmap */
case 73:
switch (ndx) {
Expand Down Expand Up @@ -9492,16 +9458,6 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
break;
/* vfork */
case 66:
/* sbrk */
case 69:
if (ndx == 0 || ndx == 1)
p = "int";
break;
/* sstk */
case 70:
if (ndx == 0 || ndx == 1)
p = "int";
break;
/* munmap */
case 73:
if (ndx == 0 || ndx == 1)
Expand Down
4 changes: 2 additions & 2 deletions sys/sys/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
#define SYS_vfork 66
/* 67 is obsolete vread */
/* 68 is obsolete vwrite */
#define SYS_sbrk 69
#define SYS_sstk 70
/* 69 is obsolete sbrk */
/* 70 is obsolete sstk */
/* 71 is old mmap */
#define SYS_freebsd11_vadvise 72
#define SYS_munmap 73
Expand Down
2 changes: 0 additions & 2 deletions sys/sys/syscall.mk
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ MIASM = \
chroot.o \
msync.o \
vfork.o \
sbrk.o \
sstk.o \
freebsd11_vadvise.o \
munmap.o \
mprotect.o \
Expand Down
10 changes: 0 additions & 10 deletions sys/sys/sysproto.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,6 @@ struct msync_args {
struct vfork_args {
syscallarg_t dummy;
};
struct sbrk_args {
char incr_l_[PADL_(int)]; int incr; char incr_r_[PADR_(int)];
};
struct sstk_args {
char incr_l_[PADL_(int)]; int incr; char incr_r_[PADR_(int)];
};
struct munmap_args {
char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)];
char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)];
Expand Down Expand Up @@ -1928,8 +1922,6 @@ int sys_umask(struct thread *, struct umask_args *);
int sys_chroot(struct thread *, struct chroot_args *);
int sys_msync(struct thread *, struct msync_args *);
int sys_vfork(struct thread *, struct vfork_args *);
int sys_sbrk(struct thread *, struct sbrk_args *);
int sys_sstk(struct thread *, struct sstk_args *);
int sys_munmap(struct thread *, struct munmap_args *);
int sys_mprotect(struct thread *, struct mprotect_args *);
int sys_madvise(struct thread *, struct madvise_args *);
Expand Down Expand Up @@ -2838,8 +2830,6 @@ int freebsd13_swapoff(struct thread *, struct freebsd13_swapoff_args *);
#define SYS_AUE_ogetpagesize AUE_NULL
#define SYS_AUE_msync AUE_MSYNC
#define SYS_AUE_vfork AUE_VFORK
#define SYS_AUE_sbrk AUE_SBRK
#define SYS_AUE_sstk AUE_SSTK
#define SYS_AUE_ommap AUE_MMAP
#define SYS_AUE_freebsd11_vadvise AUE_O_VADVISE
#define SYS_AUE_munmap AUE_MUNMAP
Expand Down
26 changes: 0 additions & 26 deletions sys/vm/vm_mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,32 +106,6 @@ SYSCTL_INT(_vm, OID_AUTO, imply_prot_max, CTLFLAG_RWTUN, &imply_prot_max, 0,

_Static_assert(MAXPAGESIZES <= 4, "MINCORE_SUPER too narrow");

#ifndef _SYS_SYSPROTO_H_
struct sbrk_args {
int incr;
};
#endif

int
sys_sbrk(struct thread *td, struct sbrk_args *uap)
{
/* Not yet implemented */
return (EOPNOTSUPP);
}

#ifndef _SYS_SYSPROTO_H_
struct sstk_args {
int incr;
};
#endif

int
sys_sstk(struct thread *td, struct sstk_args *uap)
{
/* Not yet implemented */
return (EOPNOTSUPP);
}

#if defined(COMPAT_43)
int
ogetpagesize(struct thread *td, struct ogetpagesize_args *uap)
Expand Down

0 comments on commit 7893419

Please sign in to comment.