Skip to content

Commit

Permalink
xnu-1504.7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Darwin authored and das committed Jun 4, 2017
1 parent 7d720fa commit 2e47baa
Show file tree
Hide file tree
Showing 168 changed files with 3,742 additions and 6,359 deletions.
9 changes: 8 additions & 1 deletion bsd/conf/MASTER
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ options VLAN # # <vlan>
options BOND # # <bond>
options PF # Packet Filter # <pf>
options PF_PKTHDR # PF tag inside mbuf pkthdr # <pf_pkthdr>
options PKT_PRIORITY # Packet priority support # <pkt_priority>
options PFLOG # PF log interface # <pflog>
options IPDIVERT # Divert sockets (for NAT) # <ipdivert>
options IPFLOW # IP fast forwarding # <ipflow>
Expand All @@ -143,6 +144,7 @@ options RANDOM_IP_ID # random (not sequential) ip ids # <randomipid>
options TCP_DROP_SYNFIN # Drop TCP packets with SYN+FIN set # <tcpdrop_synfin>
options ICMP_BANDLIM # ICMP bandwidth limiting sysctl
options IFNET_INPUT_SANITY_CHK # allow dlil/ifnet input sanity check # <ifnet_input_chk>
options IFNET_ROUTE_REFCNT # count route references to ifnet # <ifnet_route_refcnt>
options SYSV_SEM # SVID semaphores # <sysv_sem>
options SYSV_MSG # SVID messages # <sysv_msg>
options SYSV_SHM # SVID shared mem # <sysv_shm>
Expand Down Expand Up @@ -246,7 +248,6 @@ options randomipid # <inet,randomipid>

options ZLIB # inflate/deflate support # <zlib>

options IF_BRIDGE # <if_bridge>

makeoptions LIBDRIVER = "libDriver_kern.o" # <libdriver>
makeoptions LIBOBJC = "libkobjc.o" # <kernobjc>
Expand Down Expand Up @@ -425,6 +426,12 @@ options CONFIG_DYNAMIC_CODE_SIGNING # <dynamic_codesigning>
#
options CONFIG_CODE_DECRYPTION # <config_embedded>

#
# User Content Protection, used on embedded
#

options CONFIG_PROTECT # <config_protect>


#
# Ethernet (ARP)
Expand Down
4 changes: 1 addition & 3 deletions bsd/conf/files
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ OPTIONS/ipfw2 optional ipfw2
OPTIONS/ipfirewall optional ipfirewall
OPTIONS/ipv6firewall optional ipv6firewall
OPTIONS/tcpdebug optional tcpdebug
OPTIONS/if_bridge optional if_bridge
OPTIONS/faith optional faith
OPTIONS/gif optional gif
OPTIONS/netat optional netat
Expand Down Expand Up @@ -200,8 +199,6 @@ bsd/kern/decmpfs.c standard

bsd/net/bpf.c optional bpfilter
bsd/net/bpf_filter.c optional bpfilter
bsd/net/if_bridge.c optional if_bridge
bsd/net/bridgestp.c optional if_bridge
bsd/net/bsd_comp.c optional ppp_bsdcomp
bsd/net/if.c optional networking
bsd/net/if_atmsubr.c optional atm
Expand Down Expand Up @@ -446,6 +443,7 @@ bsd/hfs/hfs_vfsutils.c optional hfs
bsd/hfs/hfs_vnops.c optional hfs
bsd/hfs/hfs_xattr.c optional hfs
bsd/hfs/MacOSStubs.c optional hfs
bsd/hfs/cprotect.c optional hfs
bsd/hfs/rangelist.c optional hfs
bsd/hfs/hfscommon/BTree/BTree.c optional hfs
bsd/hfs/hfscommon/BTree/BTreeAllocate.c optional hfs
Expand Down
2 changes: 2 additions & 0 deletions bsd/dev/dtrace/systrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ dtrace_systrace_syscall(struct proc *pp, void *uap, int *rv)
munged_rv1 = ((u_int)rv[1]);
break;
case _SYSCALL_RET_OFF_T:
case _SYSCALL_RET_UINT64_T:
munged_rv0 = *(u_int64_t *)rv;
munged_rv1 = 0LL;
break;
Expand Down Expand Up @@ -302,6 +303,7 @@ dtrace_systrace_syscall_return(unsigned short code, int rval, int *rv)
munged_rv1 = ((u_int)rv[1]);
break;
case _SYSCALL_RET_OFF_T:
case _SYSCALL_RET_UINT64_T:
munged_rv0 = *(u_int64_t *)rv;
munged_rv1 = 0LL;
break;
Expand Down
2 changes: 2 additions & 0 deletions bsd/dev/i386/systemcalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ unix_syscall64(x86_saved_state_t *state)
case _SYSCALL_RET_ADDR_T:
case _SYSCALL_RET_SIZE_T:
case _SYSCALL_RET_SSIZE_T:
case _SYSCALL_RET_UINT64_T:
regs->rax = *((uint64_t *)(&uthread->uu_rval[0]));
regs->rdx = 0;
break;
Expand Down Expand Up @@ -504,6 +505,7 @@ unix_syscall_return(int error)
case _SYSCALL_RET_ADDR_T:
case _SYSCALL_RET_SIZE_T:
case _SYSCALL_RET_SSIZE_T:
case _SYSCALL_RET_UINT64_T:
regs->rax = *((uint64_t *)(&uthread->uu_rval[0]));
regs->rdx = 0;
break;
Expand Down
6 changes: 4 additions & 2 deletions bsd/dev/ppc/systemcalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ unix_syscall(struct savearea *regs)
regs->save_r4 = ((u_int)uthread->uu_rval[1]);
break;
case _SYSCALL_RET_OFF_T:
/* off_t returns 64 bits split across two registers for 32 bit */
case _SYSCALL_RET_UINT64_T:
/* return 64 bits split across two registers for 32 bit */
/* process and in one register for 64 bit process */
if (IS_64BIT_PROCESS(proc)) {
u_int64_t *retp = (u_int64_t *)&uthread->uu_rval[0];
Expand Down Expand Up @@ -336,7 +337,8 @@ unix_syscall_return(int error)
regs->save_r4 = ((u_int)uthread->uu_rval[1]);
break;
case _SYSCALL_RET_OFF_T:
/* off_t returns 64 bits split across two registers for 32 bit */
case _SYSCALL_RET_UINT64_T:
/* return 64 bits split across two registers for 32 bit */
/* process and in one register for 64 bit process */
if (IS_64BIT_PROCESS(proc)) {
u_int64_t *retp = (u_int64_t *)&uthread->uu_rval[0];
Expand Down
15 changes: 14 additions & 1 deletion bsd/dev/random/randomdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ static struct cdevsw random_cdevsw =
0 /* type */
};


/*
WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
ANY CODE PROTECTED UNDER "#ifdef __arm__" IS SERIOUSLY SUPPOSED TO BE THERE!
IF YOU REMOVE ARM CODE, RANDOM WILL NOT MEAN ANYTHING FOR iPHONES ALL OVER.
PLEASE DON'T TOUCH __arm__ CODE IN THIS FILE!
WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
*/


/* Used to detect whether we've already been initialized */
static int gRandomInstalled = 0;
static PrngRef gPrngRef;
Expand Down Expand Up @@ -517,6 +529,7 @@ random_read(__unused dev_t dev, struct uio *uio, __unused int ioflag)
/* lock down the mutex */
lck_mtx_lock(gYarrowMutex);


int bytes_remaining = uio_resid(uio);
while (bytes_remaining > 0 && retCode == 0) {
/* get the user's data */
Expand Down Expand Up @@ -557,7 +570,6 @@ read_random(void* buffer, u_int numbytes)
}

lck_mtx_lock(gYarrowMutex);

int bytes_read = 0;

int bytes_remaining = numbytes;
Expand Down Expand Up @@ -589,3 +601,4 @@ RandomULong(void)
read_random(&buf, sizeof (buf));
return (buf);
}

50 changes: 50 additions & 0 deletions bsd/hfs/cprotect.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2000-2009 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#include <sys/mount.h>
#include <sys/vnode_if.h>
#include <sys/vnode_internal.h>

#include <sys/cprotect.h>
#include <sys/random.h>
#include <sys/xattr.h>
#include <sys/uio_internal.h>

#include "hfs.h"
#include "hfs_cnode.h"

int cp_key_store_action(int action __unused)
{
return ENOTSUP;
}


int cp_register_wraps(cp_wrap_func_t key_store_func __unused)
{
return ENOTSUP;
}

19 changes: 17 additions & 2 deletions bsd/hfs/hfs_btreeio.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ OSStatus ReleaseBTreeBlock(FileReference vp, BlockDescPtr blockPtr, ReleaseBlock
} else {
buf_brelse(bp); /* note: B-tree code will clear blockPtr->blockHeader and blockPtr->buffer */
}

/* Don't let anyone else try to use this bp, it's been consumed */
blockPtr->blockHeader = NULL;

} else {
if (options & kForceWriteBlock) {
if (hfsmp->jnl) {
Expand All @@ -252,6 +256,10 @@ OSStatus ReleaseBTreeBlock(FileReference vp, BlockDescPtr blockPtr, ReleaseBlock
} else {
retval = VNOP_BWRITE(bp);
}

/* Don't let anyone else try to use this bp, it's been consumed */
blockPtr->blockHeader = NULL;

} else if (options & kMarkBlockDirty) {
struct timeval tv;
microuptime(&tv);
Expand Down Expand Up @@ -292,6 +300,10 @@ OSStatus ReleaseBTreeBlock(FileReference vp, BlockDescPtr blockPtr, ReleaseBlock
buf_clearflags(bp, B_LOCKED);
buf_bawrite(bp);
}

/* Don't let anyone else try to use this bp, it's been consumed */
blockPtr->blockHeader = NULL;

} else {
// check if we had previously called journal_modify_block_start()
// on this block and if so, abort it (which will call buf_brelse()).
Expand All @@ -308,8 +320,11 @@ OSStatus ReleaseBTreeBlock(FileReference vp, BlockDescPtr blockPtr, ReleaseBlock
} else {
buf_brelse(bp); /* note: B-tree code will clear blockPtr->blockHeader and blockPtr->buffer */
}
};
};

/* Don't let anyone else try to use this bp, it's been consumed */
blockPtr->blockHeader = NULL;
}
}

exit:
return (retval);
Expand Down
34 changes: 30 additions & 4 deletions bsd/hfs/hfs_vfsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -3471,10 +3471,11 @@ hfs_extendfs(struct hfsmount *hfsmp, u_int64_t newsize, vfs_context_t context)
u_int32_t phys_sectorsize;
daddr64_t prev_alt_sector;
daddr_t bitmapblks;
int lockflags;
int lockflags = 0;
int error;
int64_t oldBitmapSize;
Boolean usedExtendFileC = false;
int transaction_begun = 0;

devvp = hfsmp->hfs_devvp;
vcb = HFSTOVCB(hfsmp);
Expand Down Expand Up @@ -3548,12 +3549,27 @@ hfs_extendfs(struct hfsmount *hfsmp, u_int64_t newsize, vfs_context_t context)
addblks = newblkcnt - vcb->totalBlocks;

printf("hfs_extendfs: growing %s by %d blocks\n", vcb->vcbVN, addblks);

HFS_MOUNT_LOCK(hfsmp, TRUE);
if (hfsmp->hfs_flags & HFS_RESIZE_IN_PROGRESS) {
HFS_MOUNT_UNLOCK(hfsmp, TRUE);
error = EALREADY;
goto out;
}
hfsmp->hfs_flags |= HFS_RESIZE_IN_PROGRESS;
HFS_MOUNT_UNLOCK(hfsmp, TRUE);

/* Invalidate the current free extent cache */
invalidate_free_extent_cache(hfsmp);

/*
* Enclose changes inside a transaction.
*/
if (hfs_start_transaction(hfsmp) != 0) {
return (EINVAL);
error = EINVAL;
goto out;
}
transaction_begun = 1;

/*
* Note: we take the attributes lock in case we have an attribute data vnode
Expand Down Expand Up @@ -3782,9 +3798,16 @@ hfs_extendfs(struct hfsmount *hfsmp, u_int64_t newsize, vfs_context_t context)
we should reset the allocLimit field. If it changed, it will
get updated; if not, it will remain the same.
*/
HFS_MOUNT_LOCK(hfsmp, TRUE);
hfsmp->hfs_flags &= ~HFS_RESIZE_IN_PROGRESS;
hfsmp->allocLimit = vcb->totalBlocks;
hfs_systemfile_unlock(hfsmp, lockflags);
hfs_end_transaction(hfsmp);
HFS_MOUNT_UNLOCK(hfsmp, TRUE);
if (lockflags) {
hfs_systemfile_unlock(hfsmp, lockflags);
}
if (transaction_begun) {
hfs_end_transaction(hfsmp);
}

return (error);
}
Expand Down Expand Up @@ -3851,6 +3874,9 @@ hfs_truncatefs(struct hfsmount *hfsmp, u_int64_t newsize, vfs_context_t context)
goto out;
}

/* Invalidate the current free extent cache */
invalidate_free_extent_cache(hfsmp);

/* Start with a clean journal. */
hfs_journal_flush(hfsmp);

Expand Down
9 changes: 5 additions & 4 deletions bsd/hfs/hfs_vfsutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -2766,15 +2766,16 @@ int
hfs_journal_flush(struct hfsmount *hfsmp)
{
int ret;


/* Only peek at hfsmp->jnl while holding the global lock */
lck_rw_lock_shared(&hfsmp->hfs_global_lock);
if (hfsmp->jnl) {
lck_rw_lock_shared(&hfsmp->hfs_global_lock);
ret = journal_flush(hfsmp->jnl);
lck_rw_unlock_shared(&hfsmp->hfs_global_lock);
} else {
ret = 0;
}

lck_rw_unlock_shared(&hfsmp->hfs_global_lock);

return ret;
}

Expand Down
2 changes: 1 addition & 1 deletion bsd/hfs/hfs_vnops.c
Original file line number Diff line number Diff line change
Expand Up @@ -3798,7 +3798,7 @@ hfs_vnop_readdir(ap)
}

out:
if (hfsmp->jnl && user_start) {
if (user_start) {
vsunlock(user_start, user_len, TRUE);
}
/* If we didn't do anything then go ahead and dump the hint. */
Expand Down
5 changes: 2 additions & 3 deletions bsd/hfs/hfscommon/BTree/BTree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1583,7 +1583,6 @@ BTUpdateRecord(FCB *filePtr, BTreeIterator *iterator,
u_int16_t index;
Boolean validHint;


////////////////////////// Priliminary Checks ///////////////////////////////

nodeRec.buffer = nil; // so we can call ReleaseNode
Expand Down Expand Up @@ -1667,9 +1666,9 @@ BTUpdateRecord(FCB *filePtr, BTreeIterator *iterator,
////////////////////////////// Error Exit ///////////////////////////////////

ErrorExit:

(void) ReleaseNode (btreePtr, &nodeRec);

iterator->hint.writeCount = 0;
iterator->hint.nodeNum = 0;
iterator->hint.index = 0;
Expand Down
Loading

0 comments on commit 2e47baa

Please sign in to comment.