Skip to content

Commit

Permalink
xnu-1228.3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
Darwin authored and das committed Jun 4, 2017
1 parent 8c94aea commit 19422ef
Show file tree
Hide file tree
Showing 123 changed files with 1,940 additions and 575 deletions.
24 changes: 10 additions & 14 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,27 @@ A. How to build XNU:

By default, architecture defaults to the build machine
architecture, and the kernel configuration is set to build for DEVELOPMENT.
The machine configuration defaults to MX31ADS for arm and nothing for i386 and ppc.
The machine configuration defaults to S5L8900XRB for arm and default for i386 and ppc.

This will also create a bootable image, mach_kernel, and a kernel binary
with symbols, mach_kernel.sys.

Here are the valid arm machine configs:
LN2410SBC MX31ADS INTEGRATORCP S5I3000SMDK S5L8900XFPGA S5L8900XRB
OLOCREEK

Examples:
/* make a debug kernel for MX31 arm board */
make TARGET_CONFIGS="debug arm MX31ADS"
/* make a debug kernel for H1 arm board */
make TARGET_CONFIGS="debug arm s5l8900xrb"

$(OBJROOT)/DEBUG_ARM_MX31ADS/osfmk/DEBUG/osfmk.o: pre-linked object for osfmk component
$(OBJROOT)/DEBUG_ARM_MX31ADS/mach_kernel: bootable image
$(OBJROOT)/DEBUG_ARM_S5L8900XRB/osfmk/DEBUG/osfmk.o: pre-linked object for osfmk component
$(OBJROOT)/DEBUG_ARM_S5L8900XRB/mach_kernel: bootable image

/* make debug and development kernels for MX31 arm board */
make TARGET_CONFIGS="debug arm MX31ADS development arm MX31ADS"
/* make debug and development kernels for H1 arm board */
make TARGET_CONFIGS="debug arm s5l8900xrb development arm s5l8900xrb"

$(OBJROOT)/DEBUG_ARM_MX31ADS/osfmk/DEBUG/osfmk.o: pre-linked object for osfmk component
$(OBJROOT)/DEBUG_ARM_MX31ADS/mach_kernel: bootable image
$(OBJROOT)/DEBUG_ARM_S5L8900XRB/osfmk/DEBUG/osfmk.o: pre-linked object for osfmk component
$(OBJROOT)/DEBUG_ARM_S5L8900XRB/mach_kernel: bootable image
$(OBJROOT)/DEVELOPMENT_ARM/osfmk/DEVELOPMENT/osfmk.o: pre-linked object for osfmk component
$(OBJROOT)/DEVELOPMENT_ARM/mach_kernel: bootable image

/* this is all you need to do to build MX31ADS arm with DEVELOPMENT kernel configuration */
/* this is all you need to do to build H1 arm with DEVELOPMENT kernel configuration */
make TARGET_CONFIGS="default arm default"

or the following is equivalent
Expand Down
5 changes: 3 additions & 2 deletions bsd/conf/MASTER.i386
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
#
# EMBEDDED_BASE = [ intel mach bsmall vol pst gdb kernobjc fixpri simple_clock mdebug kernserv driverkit uxpr kernstack ipc_compat ipc_debug compat_43_tty sysv_sem sysv_msg sysv_shm audit panic_info config_imageboot ]
# EMBEDDED_FILESYS = [ devfs hfs journaling fdesc fifo ]
# EMBEDDED_NET = [ inet compat_oldsock mrouting tcpdrop_synfin bpfilter ipdivert config_mbuf_noexpand dummynet ipfirewall ipfw2 zlib ifnet_input_chk ]
# EMBEDDED_NET = [ inet compat_oldsock mrouting tcpdrop_synfin bpfilter config_mbuf_noexpand ]
# EMBEDDED = [ EMBEDDED_BASE EMBEDDED_NET VPN EMBEDDED_FILESYS libdriver no_printf_str no_kprintf_str no_kdebug ]
# DEVELOPMENT = [ EMBEDDED_BASE EMBEDDED_NET NFS VPN EMBEDDED_FILESYS libdriver netmibs development mach_assert config_dtrace ]
#
Expand All @@ -79,7 +79,8 @@ config mach_kernel swap generic # <mach>
options EVENT # <event>

#
# Note: MAC options must be set in both bsd/conf and security/conf MASTER files
# Note: MAC options must be set in all the bsd/conf, osfmk/conf, and
# security/conf MASTER files.
#
options CONFIG_MACF # Mandatory Access Control Framework
options CONFIG_MACF_SOCKET_SUBSET # MAC socket subest (no labels)
Expand Down
3 changes: 2 additions & 1 deletion bsd/conf/MASTER.ppc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ options UXPR # user-level XPR package # <uxpr>
config mach_kernel swap generic # <mach>

#
# Note: MAC options must be set in both bsd/conf and security/conf MASTER files
# Note: MAC options must be set in all the bsd/conf, osfmk/conf, and
# security/conf MASTER files.
#
options CONFIG_MACF # Mandatory Access Control Framework
options CONFIG_MACF_SOCKET_SUBSET # MAC socket subest (no labels)
Expand Down
1 change: 0 additions & 1 deletion bsd/conf/files
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ OPTIONS/vndevice optional vndevice
OPTIONS/audit optional audit
OPTIONS/config_fse optional config_fse
OPTIONS/sockets optional sockets
OPTIONS/kpidirect optional kpidirect
OPTIONS/development optional development
OPTIONS/sysv_sem optional sysv_sem
OPTIONS/sysv_msg optional sysv_msg
Expand Down
18 changes: 17 additions & 1 deletion bsd/dev/dtrace/dtrace_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,16 @@ dtrace_copyinstr(user_addr_t src, uintptr_t dst, size_t len)
size_t actual;

if (dtrace_copycheck( src, dst, len )) {
if (copyinstr((const user_addr_t)src, (char *)dst, (vm_size_t)len, &actual)) {
/* copyin as many as 'len' bytes. */
int error = copyinstr((const user_addr_t)src, (char *)dst, (vm_size_t)len, &actual);

/*
* ENAMETOOLONG is returned when 'len' bytes have been copied in but the NUL terminator was
* not encountered. That does not require raising CPU_DTRACE_BADADDR, and we press on.
* Note that we do *not* stuff a NUL terminator when returning ENAMETOOLONG, that's left
* to the caller.
*/
if (error && error != ENAMETOOLONG) {
DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
cpu_core[CPU->cpu_id].cpuc_dtrace_illval = src;
}
Expand All @@ -1244,6 +1253,13 @@ dtrace_copyoutstr(uintptr_t src, user_addr_t dst, size_t len)
size_t actual;

if (dtrace_copycheck( dst, src, len )) {

/*
* ENAMETOOLONG is returned when 'len' bytes have been copied out but the NUL terminator was
* not encountered. We raise CPU_DTRACE_BADADDR in that case.
* Note that we do *not* stuff a NUL terminator when returning ENAMETOOLONG, that's left
* to the caller.
*/
if (copyoutstr((const void *)src, dst, (size_t)len, &actual)) {
DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
cpu_core[CPU->cpu_id].cpuc_dtrace_illval = dst;
Expand Down
2 changes: 1 addition & 1 deletion bsd/dev/dtrace/lockstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ typedef struct lockstat_probe {

lockstat_probe_t lockstat_probes[] =
{
#ifndef __PPC__
#ifdef __i386__
/* Not implemented yet on PPC... */
{ LS_LCK_MTX_LOCK, LSA_ACQUIRE, LS_LCK_MTX_LOCK_ACQUIRE, DTRACE_IDNONE },
{ LS_LCK_MTX_LOCK, LSA_SPIN, LS_LCK_MTX_LOCK_SPIN, DTRACE_IDNONE },
Expand Down
22 changes: 22 additions & 0 deletions bsd/dev/memdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ int mdevCMajor = -1;
static int mdevioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p, int is_char);
dev_t mdevadd(int devid, ppnum_t base, unsigned int size, int phys);
dev_t mdevlookup(int devid);
void mdevremoveall(void);

static int mdevclose(__unused dev_t dev, __unused int flags,
__unused int devtype, __unused struct proc *p) {
Expand Down Expand Up @@ -609,3 +610,24 @@ dev_t mdevlookup(int devid) {
if(!(mdev[devid].mdFlags & mdInited)) return -1; /* This one hasn't been defined */
return mdev[devid].mdBDev; /* Return the device number */
}

void mdevremoveall(void) {

int i;

for(i = 0; i < 16; i++) {
if(!(mdev[i].mdFlags & mdInited)) continue; /* Ignore unused mdevs */

devfs_remove(mdev[i].mdbdevb); /* Remove the block device */
devfs_remove(mdev[i].mdcdevb); /* Remove the character device */

mdev[i].mdBase = 0; /* Clear the mdev's storage */
mdev[i].mdSize = 0;
mdev[i].mdSecsize = 0;
mdev[i].mdFlags = 0;
mdev[i].mdBDev = 0;
mdev[i].mdCDev = 0;
mdev[i].mdbdevb = 0;
mdev[i].mdcdevb = 0;
}
}
43 changes: 31 additions & 12 deletions bsd/dev/random/randomdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ typedef BlockWord Block[kBSize];

void add_blocks(Block a, Block b, BlockWord carry);
void fips_initialize(void);
void random_block(Block b);
void random_block(Block b, int addOptional);
u_int32_t CalculateCRC(u_int8_t* buffer, size_t length);

/*
Expand Down Expand Up @@ -194,18 +194,22 @@ u_int32_t CalculateCRC(u_int8_t* buffer, size_t length)
* get a random block of data per fips 186-2
*/
void
random_block(Block b)
random_block(Block b, int addOptional)
{
int repeatCount = 0;
do
{
// do one iteration
Block xSeed;
prngOutput (gPrngRef, (BYTE*) &xSeed, sizeof (xSeed));

// add the seed to the previous value of g_xkey
add_blocks (g_xkey, xSeed, 0);

if (addOptional)
{
Block xSeed;
prngOutput (gPrngRef, (BYTE*) &xSeed, sizeof (xSeed));

// add the seed to the previous value of g_xkey
add_blocks (g_xkey, xSeed, 0);
}

// compute "G"
SHA1Update (&g_sha1_ctx, (const u_int8_t *) &g_xkey, sizeof (g_xkey));

Expand Down Expand Up @@ -309,19 +313,34 @@ PreliminarySetup(void)
fips_initialize ();
}

const Block kKnownAnswer = {0x92b404e5, 0x56588ced, 0x6c1acd4e, 0xbf053f68, 0x9f73a93};

void
fips_initialize(void)
{
/* Read the initial value of g_xkey from yarrow */
prngOutput (gPrngRef, (BYTE*) &g_xkey, sizeof (g_xkey));
/* So that we can do the self test, set the seed to zero */
memset(&g_xkey, 0, sizeof(g_xkey));

/* initialize our SHA1 generator */
SHA1Init (&g_sha1_ctx);

/* other initializations */
memset (zeros, 0, sizeof (zeros));
g_bytes_used = 0;
random_block(g_random_data);
random_block(g_random_data, FALSE);

// check here to see if we got the initial data we were expecting
int i;
for (i = 0; i < kBSize; ++i)
{
if (kKnownAnswer[i] != g_random_data[i])
{
panic("FIPS random self test failed");
}
}

// now do the random block again to make sure that userland doesn't get predicatable data
random_block(g_random_data, TRUE);
}

/*
Expand Down Expand Up @@ -490,7 +509,7 @@ random_read(__unused dev_t dev, struct uio *uio, __unused int ioflag)
int bytes_available = kBSizeInBytes - g_bytes_used;
if (bytes_available == 0)
{
random_block(g_random_data);
random_block(g_random_data, TRUE);
g_bytes_used = 0;
bytes_available = kBSizeInBytes;
}
Expand Down Expand Up @@ -533,7 +552,7 @@ read_random(void* buffer, u_int numbytes)
int bytes_to_read = min(bytes_remaining, kBSizeInBytes - g_bytes_used);
if (bytes_to_read == 0)
{
random_block(g_random_data);
random_block(g_random_data, TRUE);
g_bytes_used = 0;
bytes_to_read = min(bytes_remaining, kBSizeInBytes);
}
Expand Down
25 changes: 24 additions & 1 deletion bsd/hfs/hfs_catalog.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2007 Apple Inc. All rights reserved.
* Copyright (c) 2000-2008 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
Expand Down Expand Up @@ -226,6 +226,11 @@ cat_convertattr(
}
}

/*
* Convert a raw catalog key and record into an in-core catalog descriptor.
*
* Note: The caller is responsible for releasing the catalog descriptor.
*/
__private_extern__
int
cat_convertkey(
Expand Down Expand Up @@ -286,6 +291,9 @@ cat_releasedesc(struct cat_desc *descp)

/*
* cat_lookup - lookup a catalog node using a cnode decriptor
*
* Note: The caller is responsible for releasing the output
* catalog descriptor (when supplied outdescp is non-null).
*/
__private_extern__
int
Expand Down Expand Up @@ -394,6 +402,10 @@ cat_insertfilethread(struct hfsmount *hfsmp, struct cat_desc *descp)
* cat_findname - obtain a descriptor from cnid
*
* Only a thread lookup is performed.
*
* Note: The caller is responsible for releasing the output
* catalog descriptor (when supplied outdescp is non-null).
*/
__private_extern__
int
Expand Down Expand Up @@ -464,6 +476,9 @@ cat_findname(struct hfsmount *hfsmp, cnid_t cnid, struct cat_desc *outdescp)

/*
* cat_idlookup - lookup a catalog node using a cnode id
*
* Note: The caller is responsible for releasing the output
* catalog descriptor (when supplied outdescp is non-null).
*/
__private_extern__
int
Expand Down Expand Up @@ -765,6 +780,9 @@ cat_lookupbykey(struct hfsmount *hfsmp, CatalogKey *keyp, int allow_system_files
*
* NOTE: both the catalog file and attribute file locks must
* be held before calling this function.
*
* The caller is responsible for releasing the output
* catalog descriptor (when supplied outdescp is non-null).
*/
__private_extern__
int
Expand Down Expand Up @@ -937,6 +955,9 @@ cat_create(struct hfsmount *hfsmp, struct cat_desc *descp, struct cat_attr *attr
* 3. BTDeleteRecord(from_cnode);
* 4. BTDeleteRecord(from_thread);
* 5. BTInsertRecord(to_thread);
*
* Note: The caller is responsible for releasing the output
* catalog descriptor (when supplied out_cdp is non-null).
*/
__private_extern__
int
Expand Down Expand Up @@ -1690,13 +1711,15 @@ cat_set_childlinkbit(struct hfsmount *hfsmp, cnid_t cnid)
if (retval) {
hfs_systemfile_unlock(hfsmp, lockflags);
hfs_end_transaction(hfsmp);
cat_releasedesc(&desc);
break;
}

hfs_systemfile_unlock(hfsmp, lockflags);
hfs_end_transaction(hfsmp);

cnid = desc.cd_parentcnid;
cat_releasedesc(&desc);
}

return retval;
Expand Down
Loading

0 comments on commit 19422ef

Please sign in to comment.