Skip to content

Commit

Permalink
xnu-517.9.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 ed5869b commit ed48e98
Show file tree
Hide file tree
Showing 49 changed files with 7,238 additions and 200 deletions.
8 changes: 4 additions & 4 deletions bsd/bsm/audit_kevents.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@
#define AUE_FCHOWN 38 /*123*/
#define AUE_FCHMOD 39 /*124*/
#define AUE_O_RECVFROM AUE_RECVFROM /*125*/
#define AUE_O_SETREUID AUE_NULL /*126*/ /*40*/
#define AUE_O_SETREGID AUE_NULL /*127*/ /*41*/
#define AUE_O_SETREUID AUE_SETEUID /*126*/ /*40*/
#define AUE_O_SETREGID AUE_SETEGID /*127*/ /*41*/
#define AUE_RENAME 42 /*128*/
#define AUE_O_TRUNCATE AUE_TRUNCATE /*129*/
#define AUE_O_FTRUNCATE AUE_FTRUNCATE /*130*/
Expand Down Expand Up @@ -209,13 +209,13 @@
#define AUE_O_GETDIRENTRIES AUE_GETDIRENTRIES /*156*/
#define AUE_STATFS 54 /*157*/
#define AUE_FSTATFS 55 /*158*/
#define AUE_UMOUNT 12 /*159*/
#define AUE_UNMOUNT 12 /*159*/
#define AUE_O_ASYNCDAEMON AUE_NULL /*160*/
#define AUE_GETFH 322 /*161*/
#define AUE_O_GETDOMAINNAME AUE_NULL /*162*/
#define AUE_O_SETDOMAINNAME AUE_SYSCTL /*163*/
#define AUE_O_PCFS_MOUNT AUE_NULL /*164*/
#define AUE_QUOTACTL 323 /*165*/
#define AUE_QUOTACTL 60 /*165*/
#define AUE_O_EXPORTFS AUE_NULL /*166*/
#define AUE_MOUNT 62 /*167*/
#define AUE_O_USTATE AUE_NULL /*168*/
Expand Down
1 change: 1 addition & 0 deletions bsd/conf/files
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ bsd/miscfs/nullfs/null_subr.c optional nullfs
bsd/miscfs/nullfs/null_vfsops.c optional nullfs
bsd/miscfs/nullfs/null_vnops.c optional nullfs
bsd/miscfs/specfs/spec_vnops.c standard
bsd/miscfs/specfs/spec_lockf.c standard
bsd/miscfs/union/union_subr.c optional union
bsd/miscfs/union/union_vfsops.c optional union
bsd/miscfs/union/union_vnops.c optional union
Expand Down
2 changes: 1 addition & 1 deletion bsd/conf/version.minor
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5
6
1 change: 0 additions & 1 deletion bsd/hfs/hfs_cnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ typedef struct filefork filefork_t;
struct hfs_index {
SLIST_ENTRY(hfs_index) hi_link;
int hi_index;
void *hi_thread; /* thread that created index entry */
char hi_name[1];
};

Expand Down
21 changes: 19 additions & 2 deletions bsd/hfs/hfs_readwrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -2219,7 +2219,7 @@ hfs_relocate(vp, blockHint, cred, p)
int eflags;
u_int32_t oldstart; /* debug only */
off_t newbytes;
int retval;
int retval, need_vinval=0;

if (vp->v_type != VREG && vp->v_type != VLNK) {
return (EPERM);
Expand Down Expand Up @@ -2323,13 +2323,24 @@ hfs_relocate(vp, blockHint, cred, p)
* STEP 2 - clone data into the new allocation blocks.
*/

// XXXdbg - unlock the extents overflow file because hfs_clonefile()
// calls vinvalbuf() which calls hfs_fsync() which can
// call hfs_metasync() which may need to lock the catalog
// file -- but the catalog file may be locked and blocked
// waiting for the extents overflow file if we're unlucky.
// see radar 3742973 for more details.
(void) hfs_metafilelocking(VTOHFS(vp), kHFSExtentsFileID, LK_RELEASE, p);

if (vp->v_type == VLNK)
retval = hfs_clonelink(vp, blksize, cred, p);
else if (vp->v_flag & VSYSTEM)
retval = hfs_clonesysfile(vp, headblks, datablks, blksize, cred, p);
else
retval = hfs_clonefile(vp, headblks, datablks, blksize, cred, p);

// XXXdbg - relock the extents overflow file
(void)hfs_metafilelocking(hfsmp, kHFSExtentsFileID, LK_EXCLUSIVE, p);

if (retval)
goto restore;

Expand All @@ -2351,13 +2362,19 @@ hfs_relocate(vp, blockHint, cred, p)
fp->ff_size = realsize;
if (UBCISVALID(vp)) {
(void) ubc_setsize(vp, realsize);
(void) vinvalbuf(vp, V_SAVE, cred, p, 0, 0);
need_vinval = 1;
}

CLR(VTOC(vp)->c_flag, C_RELOCATING); /* Resume page-outs for this file. */
out:
(void) hfs_metafilelocking(VTOHFS(vp), kHFSExtentsFileID, LK_RELEASE, p);

// XXXdbg - do this after unlocking the extents-overflow
// file to avoid deadlocks (see comment above by STEP 2)
if (need_vinval) {
(void) vinvalbuf(vp, V_SAVE, cred, p, 0, 0);
}

retval = VOP_FSYNC(vp, cred, MNT_WAIT, p);
out2:
if (hfsmp->jnl) {
Expand Down
11 changes: 2 additions & 9 deletions bsd/hfs/hfs_vfsutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1386,13 +1386,10 @@ char *
hfs_getnamehint(struct cnode *dcp, int index)
{
struct hfs_index *entry;
void *self;

if (index > 0) {
self = current_act();
SLIST_FOREACH(entry, &dcp->c_indexlist, hi_link) {
if ((entry->hi_index == index)
&& (entry->hi_thread == self))
if (entry->hi_index == index)
return (entry->hi_name);
}
}
Expand All @@ -1416,7 +1413,6 @@ hfs_savenamehint(struct cnode *dcp, int index, const char * namehint)
MALLOC(entry, struct hfs_index *, len + sizeof(struct hfs_index),
M_TEMP, M_WAITOK);
entry->hi_index = index;
entry->hi_thread = current_act();
bcopy(namehint, entry->hi_name, len + 1);
SLIST_INSERT_HEAD(&dcp->c_indexlist, entry, hi_link);
}
Expand All @@ -1431,13 +1427,10 @@ void
hfs_relnamehint(struct cnode *dcp, int index)
{
struct hfs_index *entry;
void *self;

if (index > 0) {
self = current_act();
SLIST_FOREACH(entry, &dcp->c_indexlist, hi_link) {
if ((entry->hi_index == index)
&& (entry->hi_thread == self)) {
if (entry->hi_index == index) {
SLIST_REMOVE(&dcp->c_indexlist, entry, hfs_index,
hi_link);
FREE(entry, M_TEMP);
Expand Down
8 changes: 8 additions & 0 deletions bsd/hfs/hfs_vnops.c
Original file line number Diff line number Diff line change
Expand Up @@ -2879,6 +2879,14 @@ hfs_readdir(ap)

*ap->a_ncookies = ncookies;
*ap->a_cookies = cookies;

/* handle cookies for "." and ".." */
if (off == 0) {
cookies[0] = 0;
cookies[1] = sizeof(struct hfsdotentry);
} else if (off == sizeof(struct hfsdotentry)) {
cookies[0] = sizeof(struct hfsdotentry);
}
}

/* If there are no children then we're done */
Expand Down
84 changes: 49 additions & 35 deletions bsd/kern/kern_bsm_audit.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,12 @@ void kau_free(struct au_record *rec)
} \
} while (0)

#define KPATH1_VNODE1_TOKENS \
#define UPATH1_KPATH1_VNODE1_TOKENS \
do { \
if (ar->ar_valid_arg & ARG_UPATH1) { \
tok = au_to_path(ar->ar_arg_upath1); \
kau_write(rec, tok); \
} \
if (ar->ar_valid_arg & ARG_KPATH1) { \
tok = au_to_path(ar->ar_arg_kpath1); \
kau_write(rec, tok); \
Expand All @@ -242,14 +246,12 @@ void kau_free(struct au_record *rec)
kau_write(rec, tok); \
} \
} while (0)

#define KPATH1_VNODE1_OR_UPATH1_TOKENS \
#define KPATH1_VNODE1_TOKENS \
do { \
if (ar->ar_valid_arg & ARG_KPATH1) { \
tok = au_to_path(ar->ar_arg_kpath1); \
kau_write(rec, tok); \
} else { \
UPATH1_TOKENS; \
} \
if (ar->ar_valid_arg & ARG_VNODE1) { \
tok = kau_to_attr32(&ar->ar_arg_vnode1);\
Expand Down Expand Up @@ -487,7 +489,7 @@ kaudit_to_bsm(struct kaudit_record *kar, struct au_record **pau)

case AUE_ACCT:
if (ar->ar_valid_arg & (ARG_KPATH1 | ARG_UPATH1)) {
KPATH1_VNODE1_OR_UPATH1_TOKENS;
UPATH1_KPATH1_VNODE1_TOKENS;
} else {
tok = au_to_arg32(1, "accounting off", 0);
kau_write(rec, tok);
Expand Down Expand Up @@ -551,7 +553,7 @@ kaudit_to_bsm(struct kaudit_record *kar, struct au_record **pau)
break;

case AUE_AUDITCTL:
KPATH1_VNODE1_OR_UPATH1_TOKENS;
UPATH1_KPATH1_VNODE1_TOKENS;
break;

case AUE_ADJTIME:
Expand Down Expand Up @@ -590,38 +592,38 @@ kaudit_to_bsm(struct kaudit_record *kar, struct au_record **pau)
case AUE_UNDELETE:
case AUE_UNLINK:
case AUE_UTIMES:
KPATH1_VNODE1_OR_UPATH1_TOKENS;
UPATH1_KPATH1_VNODE1_TOKENS;
break;

case AUE_CHFLAGS:
tok = au_to_arg32(2, "flags", ar->ar_arg_fflags);
kau_write(rec, tok);
KPATH1_VNODE1_OR_UPATH1_TOKENS;
UPATH1_KPATH1_VNODE1_TOKENS;
break;

case AUE_CHMOD:
tok = au_to_arg32(2, "new file mode", ar->ar_arg_mode);
kau_write(rec, tok);
KPATH1_VNODE1_OR_UPATH1_TOKENS;
UPATH1_KPATH1_VNODE1_TOKENS;
break;

case AUE_CHOWN:
tok = au_to_arg32(2, "new file uid", ar->ar_arg_uid);
kau_write(rec, tok);
tok = au_to_arg32(3, "new file gid", ar->ar_arg_gid);
kau_write(rec, tok);
KPATH1_VNODE1_OR_UPATH1_TOKENS;
UPATH1_KPATH1_VNODE1_TOKENS;
break;

case AUE_EXCHANGEDATA:
KPATH1_VNODE1_OR_UPATH1_TOKENS;
UPATH1_KPATH1_VNODE1_TOKENS;
KPATH2_VNODE2_TOKENS;
break;

case AUE_CLOSE:
tok = au_to_arg32(2, "fd", ar->ar_arg_fd);
kau_write(rec, tok);
KPATH1_VNODE1_OR_UPATH1_TOKENS;
UPATH1_KPATH1_VNODE1_TOKENS;
break;

case AUE_FCHMOD:
Expand All @@ -630,6 +632,14 @@ kaudit_to_bsm(struct kaudit_record *kar, struct au_record **pau)
FD_KPATH1_VNODE1_TOKENS;
break;

case AUE_NFSSVC:
tok = au_to_arg32(1, "request", ar->ar_arg_cmd);
kau_write(rec, tok);
if (ar->ar_valid_arg & (ARG_KPATH1 | ARG_UPATH1)) {
UPATH1_KPATH1_VNODE1_TOKENS;
}
break;

case AUE_FCHDIR:
case AUE_FPATHCONF:
case AUE_FSTAT: /* XXX Need to handle sockets and shm */
Expand All @@ -650,10 +660,9 @@ kaudit_to_bsm(struct kaudit_record *kar, struct au_record **pau)
break;

case AUE_FCNTL:
if (ar->ar_arg_cmd == F_GETLK || ar->ar_arg_cmd == F_SETLK ||
ar->ar_arg_cmd == F_SETLKW) {
tok = au_to_arg32(2, "cmd", ar->ar_arg_cmd);
kau_write(rec, tok);
tok = au_to_arg32(2, "cmd", ar->ar_arg_cmd);
kau_write(rec, tok);
if (ar->ar_valid_arg & ARG_VNODE1) {
FD_KPATH1_VNODE1_TOKENS;
}
break;
Expand Down Expand Up @@ -706,33 +715,33 @@ kaudit_to_bsm(struct kaudit_record *kar, struct au_record **pau)
tok = au_to_arg32(3, "trpoints", ar->ar_arg_value);
kau_write(rec, tok);
PROCESS_PID_TOKENS(4);
KPATH1_VNODE1_OR_UPATH1_TOKENS;
UPATH1_KPATH1_VNODE1_TOKENS;
break;

case AUE_LINK:
case AUE_RENAME:
KPATH1_VNODE1_OR_UPATH1_TOKENS;
UPATH1_KPATH1_VNODE1_TOKENS;
UPATH2_TOKENS;
break;

case AUE_LOADSHFILE:
tok = au_to_arg32(4, "base addr", (u_int32_t)ar->ar_arg_addr);
kau_write(rec, tok);
KPATH1_VNODE1_OR_UPATH1_TOKENS;
UPATH1_KPATH1_VNODE1_TOKENS;
break;

case AUE_MKDIR:
tok = au_to_arg32(2, "mode", ar->ar_arg_mode);
kau_write(rec, tok);
KPATH1_VNODE1_OR_UPATH1_TOKENS;
UPATH1_KPATH1_VNODE1_TOKENS;
break;

case AUE_MKNOD:
tok = au_to_arg32(2, "mode", ar->ar_arg_mode);
kau_write(rec, tok);
tok = au_to_arg32(3, "dev", ar->ar_arg_dev);
kau_write(rec, tok);
KPATH1_VNODE1_OR_UPATH1_TOKENS;
UPATH1_KPATH1_VNODE1_TOKENS;
break;

case AUE_MMAP:
Expand Down Expand Up @@ -766,8 +775,8 @@ kaudit_to_bsm(struct kaudit_record *kar, struct au_record **pau)
kau_write(rec, tok);
}
/* fall through */
case AUE_UMOUNT:
KPATH1_VNODE1_OR_UPATH1_TOKENS;
case AUE_UNMOUNT:
UPATH1_KPATH1_VNODE1_TOKENS;
break;

case AUE_MSGCTL:
Expand Down Expand Up @@ -795,20 +804,25 @@ kaudit_to_bsm(struct kaudit_record *kar, struct au_record **pau)
kau_write(rec, tok);
break;

case AUE_OPEN_R:
case AUE_OPEN_RC:
case AUE_OPEN_RTC:
case AUE_OPEN_RT:
case AUE_OPEN_RW:
case AUE_OPEN_RWC:
case AUE_OPEN_RWTC:
case AUE_OPEN_RWT:
case AUE_OPEN_W:
case AUE_OPEN_WC:
case AUE_OPEN_WTC:
tok = au_to_arg32(3, "mode", ar->ar_arg_mode);
kau_write(rec, tok);
/* fall thru */

case AUE_OPEN_R:
case AUE_OPEN_RT:
case AUE_OPEN_RW:
case AUE_OPEN_RWT:
case AUE_OPEN_W:
case AUE_OPEN_WT:
UPATH1_TOKENS; /* Save the user space path */
KPATH1_VNODE1_TOKENS; /* Audit the kernel path as well */
tok = au_to_arg32(2, "flags", ar->ar_arg_fflags);
kau_write(rec, tok);
UPATH1_KPATH1_VNODE1_TOKENS;
break;

case AUE_PTRACE:
Expand All @@ -826,7 +840,7 @@ kaudit_to_bsm(struct kaudit_record *kar, struct au_record **pau)
kau_write(rec, tok);
tok = au_to_arg32(3, "uid", ar->ar_arg_uid);
kau_write(rec, tok);
KPATH1_VNODE1_OR_UPATH1_TOKENS;
UPATH1_KPATH1_VNODE1_TOKENS;
break;

case AUE_REBOOT:
Expand Down Expand Up @@ -1029,7 +1043,7 @@ kaudit_to_bsm(struct kaudit_record *kar, struct au_record **pau)
tok = au_to_text(ar->ar_arg_text);
kau_write(rec, tok);
}
KPATH1_VNODE1_OR_UPATH1_TOKENS;
UPATH1_KPATH1_VNODE1_TOKENS;
break;

case AUE_SYSCTL:
Expand Down Expand Up @@ -1087,11 +1101,11 @@ kaudit_to_bsm(struct kaudit_record *kar, struct au_record **pau)
tok = au_to_arg32(4, "priority",
(u_int32_t)ar->ar_arg_value);
kau_write(rec, tok);
KPATH1_VNODE1_OR_UPATH1_TOKENS;
UPATH1_KPATH1_VNODE1_TOKENS;
break;

case AUE_SWAPOFF:
KPATH1_VNODE1_OR_UPATH1_TOKENS;
UPATH1_KPATH1_VNODE1_TOKENS;
break;

case AUE_MAPFD:
Expand Down
Loading

0 comments on commit ed48e98

Please sign in to comment.