Skip to content

Commit

Permalink
xnu-6153.121.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Darwin authored and das committed Jan 11, 2021
1 parent 7049016 commit 0430d98
Show file tree
Hide file tree
Showing 53 changed files with 1,414 additions and 834 deletions.
71 changes: 0 additions & 71 deletions .gitignore

This file was deleted.

3 changes: 3 additions & 0 deletions bsd/kern/bsd_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ lck_grp_t * proc_kqhashlock_grp;
lck_grp_t * proc_knhashlock_grp;
lck_grp_t * proc_ucred_mlock_grp;
lck_grp_t * proc_mlock_grp;
lck_grp_t * proc_dirslock_grp;
lck_grp_attr_t * proc_lck_grp_attr;
lck_attr_t * proc_lck_attr;
lck_mtx_t * proc_list_mlock;
Expand Down Expand Up @@ -533,6 +534,7 @@ bsd_init(void)
proc_fdmlock_grp = lck_grp_alloc_init("proc-fdmlock", proc_lck_grp_attr);
proc_kqhashlock_grp = lck_grp_alloc_init("proc-kqhashlock", proc_lck_grp_attr);
proc_knhashlock_grp = lck_grp_alloc_init("proc-knhashlock", proc_lck_grp_attr);
proc_dirslock_grp = lck_grp_alloc_init("proc-dirslock", proc_lck_grp_attr);
#if CONFIG_XNUPOST
sysctl_debug_test_stackshot_owner_grp = lck_grp_alloc_init("test-stackshot-owner-grp", LCK_GRP_ATTR_NULL);
sysctl_debug_test_stackshot_owner_init_mtx = lck_mtx_alloc_init(
Expand All @@ -548,6 +550,7 @@ bsd_init(void)
lck_mtx_init(&kernproc->p_fdmlock, proc_fdmlock_grp, proc_lck_attr);
lck_mtx_init(&kernproc->p_ucred_mlock, proc_ucred_mlock_grp, proc_lck_attr);
lck_spin_init(&kernproc->p_slock, proc_slock_grp, proc_lck_attr);
lck_rw_init(&kernproc->p_dirs_lock, proc_dirslock_grp, proc_lck_attr);

assert(bsd_simul_execs != 0);
execargs_cache_lock = lck_mtx_alloc_init(proc_lck_grp, proc_lck_attr);
Expand Down
10 changes: 7 additions & 3 deletions bsd/kern/kern_control.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2017 Apple Inc. All rights reserved.
* Copyright (c) 1999-2020 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
Expand Down Expand Up @@ -1036,7 +1036,7 @@ ctl_enqueuembuf(kern_ctl_ref kctlref, u_int32_t unit, struct mbuf *m,
}

so_recv_data_stat(so, m, 0);
if (sbappend(&so->so_rcv, m) != 0) {
if (sbappend_nodrop(&so->so_rcv, m) != 0) {
if ((flags & CTL_DATA_NOWAKEUP) == 0) {
sorwakeup(so);
}
Expand Down Expand Up @@ -1133,7 +1133,7 @@ ctl_enqueuembuf_list(void *kctlref, u_int32_t unit, struct mbuf *m_list,
*/
m->m_nextpkt = NULL;
so_recv_data_stat(so, m, 0);
if (sbappendrecord(&so->so_rcv, m) != 0) {
if (sbappendrecord_nodrop(&so->so_rcv, m) != 0) {
needwakeup = 1;
} else {
/*
Expand Down Expand Up @@ -1239,6 +1239,10 @@ ctl_enqueuedata(void *kctlref, u_int32_t unit, void *data, size_t len,
m->m_flags |= M_EOR;
}
so_recv_data_stat(so, m, 0);
/*
* No need to call the "nodrop" variant of sbappend
* because the mbuf is local to the scope of the function
*/
if (sbappend(&so->so_rcv, m) != 0) {
if ((flags & CTL_DATA_NOWAKEUP) == 0) {
sorwakeup(so);
Expand Down
25 changes: 25 additions & 0 deletions bsd/kern/kern_descrip.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,30 @@ file_lock_init(void)
}


void
proc_dirs_lock_shared(proc_t p)
{
lck_rw_lock_shared(&p->p_dirs_lock);
}

void
proc_dirs_unlock_shared(proc_t p)
{
lck_rw_unlock_shared(&p->p_dirs_lock);
}

void
proc_dirs_lock_exclusive(proc_t p)
{
lck_rw_lock_exclusive(&p->p_dirs_lock);
}

void
proc_dirs_unlock_exclusive(proc_t p)
{
lck_rw_unlock_exclusive(&p->p_dirs_lock);
}

/*
* proc_fdlock, proc_fdlock_spin
*
Expand Down Expand Up @@ -5061,6 +5085,7 @@ fdcopy(proc_t p, vnode_t uth_cdir)
}
/* Coming from a chroot environment and unable to get a reference... */
if (newfdp->fd_rdir == NULL && fdp->fd_rdir) {
proc_fdunlock(p);
/*
* We couldn't get a new reference on
* the chroot directory being
Expand Down
1 change: 1 addition & 0 deletions bsd/kern/kern_fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,7 @@ forkproc(proc_t parent_proc)
*
* XXX may fail to copy descriptors to child
*/
lck_rw_init(&child_proc->p_dirs_lock, proc_dirslock_grp, proc_lck_attr);
child_proc->p_fd = fdcopy(parent_proc, parent_uthread->uu_cdir);

#if SYSV_SHM
Expand Down
2 changes: 1 addition & 1 deletion bsd/kern/kern_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ proc_gettty(proc_t p, vnode_t *vp)

if (ttyvp) {
if (vnode_getwithvid(ttyvp, ttyvid) == 0) {
*vp = procsp->s_ttyvp;
*vp = ttyvp;
err = 0;
}
} else {
Expand Down
13 changes: 7 additions & 6 deletions bsd/kern/kern_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,6 @@ fill_user32_externproc(proc_t p, struct user32_extern_proc *__restrict exp)
exp->p_pid = p->p_pid;
exp->p_oppid = p->p_oppid;
/* Mach related */
exp->user_stack = p->user_stack;
exp->p_debugger = p->p_debugger;
exp->sigwait = p->sigwait;
/* scheduling */
Expand Down Expand Up @@ -1142,7 +1141,6 @@ fill_user64_externproc(proc_t p, struct user64_extern_proc *__restrict exp)
exp->p_pid = p->p_pid;
exp->p_oppid = p->p_oppid;
/* Mach related */
exp->user_stack = p->user_stack;
exp->p_debugger = p->p_debugger;
exp->sigwait = p->sigwait;
/* scheduling */
Expand Down Expand Up @@ -3657,6 +3655,9 @@ SYSCTL_INT(_vm, OID_AUTO, compressor_is_active, CTLFLAG_RD | CTLFLAG_LOCKED, &vm
SYSCTL_INT(_vm, OID_AUTO, compressor_swapout_target_age, CTLFLAG_RD | CTLFLAG_LOCKED, &swapout_target_age, 0, "");
SYSCTL_INT(_vm, OID_AUTO, compressor_available, CTLFLAG_RD | CTLFLAG_LOCKED, &vm_compressor_available, 0, "");

extern int min_csegs_per_major_compaction;
SYSCTL_INT(_vm, OID_AUTO, compressor_min_csegs_per_major_compaction, CTLFLAG_RW | CTLFLAG_LOCKED, &min_csegs_per_major_compaction, 0, "");

SYSCTL_INT(_vm, OID_AUTO, vm_ripe_target_age_in_secs, CTLFLAG_RW | CTLFLAG_LOCKED, &vm_ripe_target_age, 0, "");

SYSCTL_INT(_vm, OID_AUTO, compressor_eval_period_in_msecs, CTLFLAG_RW | CTLFLAG_LOCKED, &compressor_eval_period_in_msecs, 0, "");
Expand Down Expand Up @@ -4959,15 +4960,15 @@ sysctl_get_owned_vmobjects SYSCTL_HANDLER_ARGS
int error;
mach_port_name_t task_port_name;
task_t task;
int buffer_size = (req->oldptr != USER_ADDR_NULL) ? req->oldlen : 0;
size_t buffer_size = (req->oldptr != USER_ADDR_NULL) ? req->oldlen : 0;
vmobject_list_output_t buffer;
size_t output_size;

if (buffer_size) {
const int min_size = sizeof(vm_object_query_data_t) + sizeof(int64_t);
const size_t min_size = sizeof(vm_object_query_data_t) + sizeof(int64_t);

if (buffer_size < min_size) {
buffer_size = min_size;
if (buffer_size < min_size || buffer_size > INT_MAX) {
return EINVAL;
}

buffer = kalloc(buffer_size);
Expand Down
2 changes: 2 additions & 0 deletions bsd/kern/trace_codes
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@
0x1300494 MACH_vm_page_expedite_no_memory
0x1300498 MACH_vm_page_grab
0x130049c MACH_vm_page_release
0x13004a0 MACH_vm_compressor_compact_and_swap
0x13004a4 MACH_vm_compressor_do_delayed_compactions
0x13004c0 MACH_vm_pressure_event
0x13004c4 MACH_vm_execve
0x13004c8 MACH_vm_wakeup_compactor_swapper
Expand Down
36 changes: 36 additions & 0 deletions bsd/kern/uipc_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1839,6 +1839,39 @@ soconnectxlocked(struct socket *so, struct sockaddr *src,
(error = sodisconnectlocked(so)) != 0)) {
error = EISCONN;
} else {
if ((so->so_proto->pr_flags & PR_DATA_IDEMPOTENT) &&
(flags & CONNECT_DATA_IDEMPOTENT)) {
so->so_flags1 |= SOF1_DATA_IDEMPOTENT;

if (flags & CONNECT_DATA_AUTHENTICATED) {
so->so_flags1 |= SOF1_DATA_AUTHENTICATED;
}
}

/*
* Case 1: CONNECT_RESUME_ON_READ_WRITE set, no data.
* Case 2: CONNECT_RESUME_ON_READ_WRITE set, with data (user error)
* Case 3: CONNECT_RESUME_ON_READ_WRITE not set, with data
* Case 3 allows user to combine write with connect even if they have
* no use for TFO (such as regular TCP, and UDP).
* Case 4: CONNECT_RESUME_ON_READ_WRITE not set, no data (regular case)
*/
if ((so->so_proto->pr_flags & PR_PRECONN_WRITE) &&
((flags & CONNECT_RESUME_ON_READ_WRITE) || auio)) {
so->so_flags1 |= SOF1_PRECONNECT_DATA;
}

/*
* If a user sets data idempotent and does not pass an uio, or
* sets CONNECT_RESUME_ON_READ_WRITE, this is an error, reset
* SOF1_DATA_IDEMPOTENT.
*/
if (!(so->so_flags1 & SOF1_PRECONNECT_DATA) &&
(so->so_flags1 & SOF1_DATA_IDEMPOTENT)) {
/* We should return EINVAL instead perhaps. */
so->so_flags1 &= ~SOF1_DATA_IDEMPOTENT;
}

/*
* Run connect filter before calling protocol:
* - non-blocking connect returns before completion;
Expand All @@ -1856,6 +1889,9 @@ soconnectxlocked(struct socket *so, struct sockaddr *src,
flags, arg, arglen, auio, bytes_written);
if (error != 0) {
so->so_state &= ~SS_ISCONNECTING;
if (error != EINPROGRESS) {
so->so_flags1 &= ~SOF1_PRECONNECT_DATA;
}
}
}
}
Expand Down
Loading

0 comments on commit 0430d98

Please sign in to comment.