Skip to content

Commit

Permalink
xnu-7195.81.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Darwin authored and das committed Feb 2, 2021
1 parent 33eb983 commit 8f02f2a
Show file tree
Hide file tree
Showing 93 changed files with 585 additions and 2,001 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export MakeInc_def=${VERSDIR}/makedefs/MakeInc.def
export MakeInc_rule=${VERSDIR}/makedefs/MakeInc.rule
export MakeInc_dir=${VERSDIR}/makedefs/MakeInc.dir


#
# Dispatch non-xnu build aliases to their own build
# systems. All xnu variants start with MakeInc_top.
Expand Down Expand Up @@ -186,7 +187,7 @@ TOP_TARGETS = \
install install_desktop install_embedded \
install_release_embedded install_development_embedded \
install_kernels \
cscope tags TAGS checkstyle restyle check_uncrustify uncrustify \
cscope tags TAGS \
help

DEFAULT_TARGET = all
Expand Down
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,6 @@ Set up your build environment and from the top directory, run:
$ make cscope # this will build cscope database


Code Style
==========

Source files can be reformatted to comply with the xnu code style using the "restyle" make target invoked from the
top-level project directory.

$ make restyle # re-format all source files to be xnu code style conformant.

Compliance can be checked using the "checkstyle" make target.

$ make checkstyle # Check all relevant source files for xnu code style conformance.

How to install a new header file from XNU
=========================================

Expand Down
1 change: 1 addition & 0 deletions SETUP/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ struct file_list {
*/
#define CONFIGDEP 0x01 /* obsolete? */
#define OPTIONSDEF 0x02 /* options definition entry */
#define LIBRARYDEP 0x04 /* include file in library build */

struct device {
int d_type; /* CONTROLLER, DEVICE, bus adaptor */
Expand Down
34 changes: 28 additions & 6 deletions SETUP/config/mkmakefile.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static char sccsid[] __attribute__((used)) = "@(#)mkmakefile.c 5.21 (Berkeley) 6
#include "config.h"

void read_files(void);
void do_objs(FILE *fp, const char *msg, int ext);
void do_objs(FILE *fp, const char *msg, int ext, int flags);
void do_files(FILE *fp, const char *msg, char ext);
void do_machdep(FILE *ofp);
void do_rules(FILE *f);
Expand Down Expand Up @@ -243,16 +243,18 @@ makefile(void)
continue;
percent:
if (eq(line, "%OBJS\n")) {
do_objs(ofp, "OBJS=", -1);
do_objs(ofp, "OBJS=", -1, 0);
} else if (eq(line, "%LIBOBJS\n")) {
do_objs(ofp, "LIBOBJS=", -1, LIBRARYDEP);
} else if (eq(line, "%CFILES\n")) {
do_files(ofp, "CFILES=", 'c');
do_objs(ofp, "COBJS=", 'c');
do_objs(ofp, "COBJS=", 'c', 0);
} else if (eq(line, "%CXXFILES\n")) {
do_files(ofp, "CXXFILES=", 'p');
do_objs(ofp, "CXXOBJS=", 'p');
do_objs(ofp, "CXXOBJS=", 'p', 0);
} else if (eq(line, "%SFILES\n")) {
do_files(ofp, "SFILES=", 's');
do_objs(ofp, "SOBJS=", 's');
do_objs(ofp, "SOBJS=", 's', 0);
} else if (eq(line, "%MACHDEP\n")) {
do_machdep(ofp);
} else if (eq(line, "%RULES\n")) {
Expand Down Expand Up @@ -287,6 +289,7 @@ read_files(void)
const char *devorprof;
int options;
int not_option;
int for_xnu_lib;
char pname[BUFSIZ];
char fname[1024];
char *rest = (char *) 0;
Expand Down Expand Up @@ -346,6 +349,7 @@ read_files(void)
nreqs = 0;
devorprof = "";
needs = 0;
for_xnu_lib = 0;
if (eq(wd, "standard")) {
goto checkdev;
}
Expand All @@ -371,6 +375,10 @@ read_files(void)
next_word(fp, wd);
goto save;
}
if (eq(wd, "xnu-library")) {
for_xnu_lib = 1;
goto nextopt;
}
nreqs++;
if (needs == 0 && nreqs == 1) {
needs = ns(wd);
Expand Down Expand Up @@ -469,6 +477,10 @@ read_files(void)
goto getrest;
}
next_word(fp, wd);
if (wd && eq(wd, "xnu-library")) {
for_xnu_lib = 1;
next_word(fp, wd);
}
if (wd) {
devorprof = wd;
next_word(fp, wd);
Expand Down Expand Up @@ -508,6 +520,9 @@ read_files(void)
if (pf && pf->f_type == INVISIBLE) {
pf->f_flags = 1; /* mark as duplicate */
}
if (for_xnu_lib) {
tp->f_flags |= LIBRARYDEP;
}
goto next;
}

Expand Down Expand Up @@ -541,7 +556,7 @@ put_source_file_name(FILE *fp, struct file_list *tp)
}

void
do_objs(FILE *fp, const char *msg, int ext)
do_objs(FILE *fp, const char *msg, int ext, int flags)
{
struct file_list *tp;
int lpos, len;
Expand All @@ -556,6 +571,13 @@ do_objs(FILE *fp, const char *msg, int ext)
continue;
}

/*
* Check flags (if any)
*/
if (flags && ((tp->f_flags & flags) != flags)) {
continue;
}

/*
* Check for '.o' file in list
*/
Expand Down
12 changes: 12 additions & 0 deletions bsd/conf/Makefile.template
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ COMP_SUBDIRS =

%OBJS

%LIBOBJS

%CFILES

%CXXFILES
Expand Down Expand Up @@ -606,6 +608,12 @@ $(COMPONENT).filelist: $(OBJS)
$(ECHO) $(TARGET)/$(CURRENT_KERNEL_CONFIG)/$${obj}; \
done > $(COMPONENT).filelist

$(COMPONENT).libfilelist: $(LIBOBJS)
@$(LOG_LDFILELIST) "lib$(COMPONENT)"
$(_v)for obj in ${LIBOBJS}; do \
$(ECHO) $(TARGET)/$(CURRENT_KERNEL_CONFIG)/$${obj}; \
done > $(COMPONENT).libfilelist

MAKESYSCALLS = $(SRCROOT)/bsd/kern/makesyscalls.sh

init_sysent.c: $(TARGET)/bsd.syscalls.master
Expand All @@ -624,7 +632,11 @@ systrace_args.c: $(TARGET)/bsd.syscalls.master
@$(LOG_GENERATE) "$@$(Color0) from $(ColorF)$(<F)$(Color0)"
$(_v)$(MAKESYSCALLS) $< systrace > /dev/null

ifeq ($(RC_ProjectName),xnu_libraries)
do_all: $(COMPONENT).libfilelist
else
do_all: $(COMPONENT).filelist
endif

do_build_all:: do_all

Expand Down
2 changes: 1 addition & 1 deletion bsd/conf/files
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ bsd/kern/mach_loader.c standard
bsd/kern/posix_sem.c standard
bsd/kern/posix_shm.c standard
# XXXdbg - I need this in the journaling and block cache code
bsd/kern/qsort.c standard
bsd/kern/qsort.c standard xnu-library
bsd/kern/kpi_socket.c optional sockets
bsd/kern/kpi_socketfilter.c optional sockets
bsd/kern/proc_info.c standard
Expand Down
13 changes: 13 additions & 0 deletions bsd/kern/kern_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
#include <kern/task.h>

#include <vm/vm_map.h>
#include <vm/pmap.h>
#include <vm/vm_kern.h>


Expand Down Expand Up @@ -231,6 +232,18 @@ cs_allow_invalid(struct proc *p)
if (p->p_csflags & CS_VALID) {
p->p_csflags |= CS_DEBUGGED;
}
#if PMAP_CS
task_t procTask = proc_task(p);
if (procTask) {
vm_map_t proc_map = get_task_map_reference(procTask);
if (proc_map) {
if (vm_map_cs_wx_enable(proc_map) != KERN_SUCCESS) {
printf("CODE SIGNING: cs_allow_invalid() not allowed by pmap: pid %d\n", p->p_pid);
}
vm_map_deallocate(proc_map);
}
}
#endif // MAP_CS
proc_unlock(p);

/* allow a debugged process to hide some (debug-only!) memory */
Expand Down
16 changes: 8 additions & 8 deletions bsd/kern/kern_descrip.c
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ sys_dup(proc_t p, struct dup_args *uap, int32_t *retval)
proc_fdunlock(p);
return error;
}
if (FP_ISGUARDED(fp, GUARD_DUP)) {
if (fp_isguarded(fp, GUARD_DUP)) {
error = fp_guard_exception(p, old, fp, kGUARD_EXC_DUP);
(void) fp_drop(p, old, fp, 1);
proc_fdunlock(p);
Expand Down Expand Up @@ -820,7 +820,7 @@ dup2(proc_t p, int old, int new, int *retval)
proc_fdunlock(p);
return error;
}
if (FP_ISGUARDED(fp, GUARD_DUP)) {
if (fp_isguarded(fp, GUARD_DUP)) {
error = fp_guard_exception(p, old, fp, kGUARD_EXC_DUP);
(void) fp_drop(p, old, fp, 1);
proc_fdunlock(p);
Expand Down Expand Up @@ -861,7 +861,7 @@ dup2(proc_t p, int old, int new, int *retval)
}

if ((nfp = fdp->fd_ofiles[new]) != NULL) {
if (FP_ISGUARDED(nfp, GUARD_CLOSE)) {
if (fp_isguarded(nfp, GUARD_CLOSE)) {
fp_drop(p, old, fp, 1);
error = fp_guard_exception(p,
new, nfp, kGUARD_EXC_CLOSE);
Expand Down Expand Up @@ -1047,7 +1047,7 @@ sys_fcntl_nocancel(proc_t p, struct fcntl_nocancel_args *uap, int32_t *retval)
switch (uap->cmd) {
case F_DUPFD:
case F_DUPFD_CLOEXEC:
if (FP_ISGUARDED(fp, GUARD_DUP)) {
if (fp_isguarded(fp, GUARD_DUP)) {
error = fp_guard_exception(p, fd, fp, kGUARD_EXC_DUP);
goto out;
}
Expand Down Expand Up @@ -1075,7 +1075,7 @@ sys_fcntl_nocancel(proc_t p, struct fcntl_nocancel_args *uap, int32_t *retval)
if (uap->arg & FD_CLOEXEC) {
*pop |= UF_EXCLOSE;
} else {
if (FILEPROC_TYPE(fp) == FTYPE_GUARDED) {
if (fp_isguarded(fp, 0)) {
error = fp_guard_exception(p,
fd, fp, kGUARD_EXC_NOCLOEXEC);
goto out;
Expand Down Expand Up @@ -3332,7 +3332,7 @@ close_nocancel(proc_t p, int fd)
return EBADF;
}

if (FP_ISGUARDED(fp, GUARD_CLOSE)) {
if (fp_isguarded(fp, GUARD_CLOSE)) {
int error = fp_guard_exception(p, fd, fp, kGUARD_EXC_CLOSE);
proc_fdunlock(p);
return error;
Expand Down Expand Up @@ -5290,7 +5290,7 @@ sys_fileport_makeport(proc_t p, struct fileport_makeport_args *uap,
goto out_unlock;
}

if (FP_ISGUARDED(fp, GUARD_FILEPORT)) {
if (fp_isguarded(fp, GUARD_FILEPORT)) {
err = fp_guard_exception(p, fd, fp, kGUARD_EXC_FILEPORT);
goto out_unlock;
}
Expand Down Expand Up @@ -5517,7 +5517,7 @@ dupfdopen(struct filedesc *fdp, int indx, int dfd, int flags, int error)
*/
switch (error) {
case ENODEV:
if (FP_ISGUARDED(wfp, GUARD_DUP)) {
if (fp_isguarded(wfp, GUARD_DUP)) {
proc_fdunlock(p);
return EPERM;
}
Expand Down
2 changes: 1 addition & 1 deletion bsd/kern/kern_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -2463,7 +2463,7 @@ exec_handle_file_actions(struct image_params *imgp, short psa_flags)
proc_fdlock(p);
if ((fp = fp_get_noref_locked(p, psfa->psfaa_filedes)) == NULL) {
error = EBADF;
} else if (FILEPROC_TYPE(fp) == FTYPE_GUARDED) {
} else if (fp_isguarded(fp, 0)) {
error = fp_guard_exception(p, psfa->psfaa_filedes,
fp, kGUARD_EXC_NOCLOEXEC);
} else {
Expand Down
Loading

0 comments on commit 8f02f2a

Please sign in to comment.