PERFORCE change 118261 for review
Scott Long
scottl at FreeBSD.org
Mon Apr 16 20:02:07 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=118261
Change 118261 by scottl at scottl-x64 on 2007/04/16 20:01:40
IFC
Affected files ...
.. //depot/projects/scottl-camlock/src/sys/cam/cam_periph.c#21 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_cd.c#20 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_da.c#32 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_sg.c#7 integrate
.. //depot/projects/scottl-camlock/src/sys/security/audit/audit_bsm_token.c#9 integrate
Differences ...
==== //depot/projects/scottl-camlock/src/sys/cam/cam_periph.c#21 (text+ko) ====
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/cam/cam_periph.c,v 1.65 2007/04/15 08:49:09 scottl Exp $");
+__FBSDID("$FreeBSD: src/sys/cam/cam_periph.c,v 1.66 2007/04/16 19:42:23 scottl Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -501,7 +501,6 @@
static void
camperiphfree(struct cam_periph *periph)
{
- int s;
struct periph_driver **p_drv;
for (p_drv = periph_drivers; *p_drv != NULL; p_drv++) {
@@ -512,15 +511,13 @@
printf("camperiphfree: attempt to free non-existant periph\n");
return;
}
-
- if (periph->periph_dtor != NULL)
- periph->periph_dtor(periph);
-
- s = splsoftcam();
+
TAILQ_REMOVE(&(*p_drv)->units, periph, unit_links);
(*p_drv)->generation++;
- splx(s);
+ xpt_unlock_buses();
+ if (periph->periph_dtor != NULL)
+ periph->periph_dtor(periph);
xpt_remove_periph(periph);
if (periph->flags & CAM_PERIPH_NEW_DEV_FOUND) {
@@ -549,6 +546,7 @@
}
xpt_free_path(periph->path);
free(periph, M_CAMPERIPH);
+ xpt_lock_buses();
}
/*
==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_cd.c#20 (text+ko) ====
@@ -46,7 +46,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/cam/scsi/scsi_cd.c,v 1.98 2007/04/15 08:49:10 scottl Exp $");
+__FBSDID("$FreeBSD: src/sys/cam/scsi/scsi_cd.c,v 1.99 2007/04/16 19:41:14 scottl Exp $");
#include "opt_cd.h"
@@ -486,7 +486,9 @@
xpt_print(periph->path, "removing changer entry\n");
free(softc->changer, M_DEVBUF);
}
+ cam_periph_unlock(periph);
disk_destroy(softc->disk);
+ cam_periph_lock(periph);
free(softc, M_DEVBUF);
}
==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_da.c#32 (text+ko) ====
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/cam/scsi/scsi_da.c,v 1.204 2007/04/15 08:49:10 scottl Exp $");
+__FBSDID("$FreeBSD: src/sys/cam/scsi/scsi_da.c,v 1.205 2007/04/16 19:41:14 scottl Exp $");
#include <sys/param.h>
@@ -939,13 +939,9 @@
&& sysctl_ctx_free(&softc->sysctl_ctx) != 0) {
xpt_print(periph->path, "can't remove sysctl context\n");
}
- disk_destroy(softc->disk);
- /*
- * XXX Gotta drop the periph lock so that the drain can complete with
- * deadlocking on the lock. Hopefully dropping here is safe.
- */
cam_periph_unlock(periph);
+ disk_destroy(softc->disk);
callout_drain(&softc->sendordered_c);
cam_periph_lock(periph);
free(softc, M_DEVBUF);
==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_sg.c#7 (text+ko) ====
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/cam/scsi/scsi_sg.c,v 1.5 2007/04/15 08:49:11 scottl Exp $");
+__FBSDID("$FreeBSD: src/sys/cam/scsi/scsi_sg.c,v 1.6 2007/04/16 19:40:13 scottl Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -223,8 +223,8 @@
softc = (struct sg_softc *)periph->softc;
devstat_remove_entry(softc->device_stats);
+ destroy_dev(softc->devalias);
destroy_dev(softc->dev);
- destroy_dev(softc->devalias);
if (bootverbose) {
xpt_print(periph->path, "removing device entry\n");
}
==== //depot/projects/scottl-camlock/src/sys/security/audit/audit_bsm_token.c#9 (text) ====
@@ -31,7 +31,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* $P4: //depot/projects/trustedbsd/audit3/sys/security/audit/audit_bsm_token.c#23 $
- * $FreeBSD: src/sys/security/audit/audit_bsm_token.c,v 1.10 2007/04/13 14:55:19 csjp Exp $
+ * $FreeBSD: src/sys/security/audit/audit_bsm_token.c,v 1.11 2007/04/16 16:20:45 rwatson Exp $
*/
#include <sys/types.h>
@@ -49,7 +49,6 @@
#include <netinet/in_systm.h>
#include <netinet/ip.h>
-#include <sys/socketvar.h>
#include <bsm/audit.h>
#include <bsm/audit_internal.h>
@@ -180,8 +179,44 @@
token_t *
au_to_attr64(struct vnode_au_info *vni)
{
+ token_t *t;
+ u_char *dptr = NULL;
+ u_int16_t pad0_16 = 0;
+ u_int16_t pad0_32 = 0;
+
+ GET_TOKEN_AREA(t, dptr, sizeof(u_char) + 2 * sizeof(u_int16_t) +
+ 3 * sizeof(u_int32_t) + sizeof(u_int64_t) * 2);
+
+ ADD_U_CHAR(dptr, AUT_ATTR64);
+
+ /*
+ * Darwin defines the size for the file mode
+ * as 2 bytes; BSM defines 4 so pad with 0
+ */
+ ADD_U_INT16(dptr, pad0_16);
+ ADD_U_INT16(dptr, vni->vn_mode);
+
+ ADD_U_INT32(dptr, vni->vn_uid);
+ ADD_U_INT32(dptr, vni->vn_gid);
+ ADD_U_INT32(dptr, vni->vn_fsid);
+
+ /*
+ * Some systems use 32-bit file ID's, other's use 64-bit file IDs.
+ * Attempt to handle both, and let the compiler sort it out. If we
+ * could pick this out at compile-time, it would be better, so as to
+ * avoid the else case below.
+ */
+ if (sizeof(vni->vn_fileid) == sizeof(uint32_t)) {
+ ADD_U_INT32(dptr, pad0_32);
+ ADD_U_INT32(dptr, vni->vn_fileid);
+ } else if (sizeof(vni->vn_fileid) == sizeof(uint64_t))
+ ADD_U_INT64(dptr, vni->vn_fileid);
+ else
+ ADD_U_INT64(dptr, 0LL);
- return (NULL);
+ ADD_U_INT64(dptr, vni->vn_dev);
+
+ return (t);
}
token_t *
@@ -270,7 +305,7 @@
au_to_groups(int *groups)
{
- return (au_to_newgroups(AUDIT_MAX_GROUPS, groups));
+ return (au_to_newgroups(AUDIT_MAX_GROUPS, (gid_t*)groups));
}
/*
@@ -578,18 +613,32 @@
}
token_t *
-au_to_process64(__unused au_id_t auid, __unused uid_t euid,
- __unused gid_t egid, __unused uid_t ruid, __unused gid_t rgid,
- __unused pid_t pid, __unused au_asid_t sid, __unused au_tid_t *tid)
+au_to_process64(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, gid_t rgid,
+ pid_t pid, au_asid_t sid, au_tid_t *tid)
{
+ token_t *t;
+ u_char *dptr = NULL;
- return (NULL);
+ GET_TOKEN_AREA(t, dptr, sizeof(u_char) + 8 * sizeof(u_int32_t) +
+ sizeof(u_int64_t));
+
+ ADD_U_CHAR(dptr, AUT_PROCESS64);
+ ADD_U_INT32(dptr, auid);
+ ADD_U_INT32(dptr, euid);
+ ADD_U_INT32(dptr, egid);
+ ADD_U_INT32(dptr, ruid);
+ ADD_U_INT32(dptr, rgid);
+ ADD_U_INT32(dptr, pid);
+ ADD_U_INT32(dptr, sid);
+ ADD_U_INT64(dptr, tid->port);
+ ADD_MEM(dptr, &tid->machine, sizeof(u_int32_t));
+
+ return (t);
}
token_t *
-au_to_process(__unused au_id_t auid, __unused uid_t euid,
- __unused gid_t egid, __unused uid_t ruid, __unused gid_t rgid,
- __unused pid_t pid, __unused au_asid_t sid, __unused au_tid_t *tid)
+au_to_process(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, gid_t rgid,
+ pid_t pid, au_asid_t sid, au_tid_t *tid)
{
return (au_to_process32(auid, euid, egid, ruid, rgid, pid, sid,
@@ -647,8 +696,39 @@
au_to_process64_ex(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid,
gid_t rgid, pid_t pid, au_asid_t sid, au_tid_addr_t *tid)
{
+ token_t *t;
+ u_char *dptr = NULL;
+
+ if (tid->at_type == AU_IPv4)
+ GET_TOKEN_AREA(t, dptr, sizeof(u_char) +
+ 7 * sizeof(u_int32_t) + sizeof(u_int64_t) +
+ 2 * sizeof(u_int32_t));
+ else if (tid->at_type == AU_IPv6)
+ GET_TOKEN_AREA(t, dptr, sizeof(u_char) +
+ 7 * sizeof(u_int32_t) + sizeof(u_int64_t) +
+ 5 * sizeof(u_int32_t));
+ else
+ panic("au_to_process64_ex: invalidate at_type (%d)",
+ tid->at_type);
- return (NULL);
+ ADD_U_CHAR(dptr, AUT_PROCESS64_EX);
+ ADD_U_INT32(dptr, auid);
+ ADD_U_INT32(dptr, euid);
+ ADD_U_INT32(dptr, egid);
+ ADD_U_INT32(dptr, ruid);
+ ADD_U_INT32(dptr, rgid);
+ ADD_U_INT32(dptr, pid);
+ ADD_U_INT32(dptr, sid);
+ ADD_U_INT64(dptr, tid->at_port);
+ ADD_U_INT32(dptr, tid->at_type);
+ ADD_MEM(dptr, &tid->at_addr[0], sizeof(u_int32_t));
+ if (tid->at_type == AU_IPv6) {
+ ADD_MEM(dptr, &tid->at_addr[1], sizeof(u_int32_t));
+ ADD_MEM(dptr, &tid->at_addr[2], sizeof(u_int32_t));
+ ADD_MEM(dptr, &tid->at_addr[3], sizeof(u_int32_t));
+ }
+
+ return (t);
}
token_t *
@@ -918,8 +998,24 @@
au_to_subject64(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, gid_t rgid,
pid_t pid, au_asid_t sid, au_tid_t *tid)
{
+ token_t *t;
+ u_char *dptr = NULL;
- return (NULL);
+ GET_TOKEN_AREA(t, dptr, sizeof(u_char) + 7 * sizeof(u_int32_t) +
+ sizeof(u_int64_t) + sizeof(u_int32_t));
+
+ ADD_U_CHAR(dptr, AUT_SUBJECT64);
+ ADD_U_INT32(dptr, auid);
+ ADD_U_INT32(dptr, euid);
+ ADD_U_INT32(dptr, egid);
+ ADD_U_INT32(dptr, ruid);
+ ADD_U_INT32(dptr, rgid);
+ ADD_U_INT32(dptr, pid);
+ ADD_U_INT32(dptr, sid);
+ ADD_U_INT64(dptr, tid->port);
+ ADD_MEM(dptr, &tid->machine, sizeof(u_int32_t));
+
+ return (t);
}
token_t *
@@ -982,8 +1078,37 @@
au_to_subject64_ex(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid,
gid_t rgid, pid_t pid, au_asid_t sid, au_tid_addr_t *tid)
{
+ token_t *t;
+ u_char *dptr = NULL;
+
+ if (tid->at_type == AU_IPv4)
+ GET_TOKEN_AREA(t, dptr, sizeof(u_char) +
+ 7 * sizeof(u_int32_t) + sizeof(u_int64_t) +
+ 2 * sizeof(u_int32_t));
+ else if (tid->at_type == AU_IPv6)
+ GET_TOKEN_AREA(t, dptr, sizeof(u_char) +
+ 7 * sizeof(u_int32_t) + sizeof(u_int64_t) +
+ 5 * sizeof(u_int32_t));
+ else
+ panic("au_to_subject64_ex: invalid at_type (%d)",
+ tid->at_type);
- return (NULL);
+ ADD_U_CHAR(dptr, AUT_SUBJECT64_EX);
+ ADD_U_INT32(dptr, auid);
+ ADD_U_INT32(dptr, euid);
+ ADD_U_INT32(dptr, egid);
+ ADD_U_INT32(dptr, ruid);
+ ADD_U_INT32(dptr, rgid);
+ ADD_U_INT32(dptr, pid);
+ ADD_U_INT32(dptr, sid);
+ ADD_U_INT64(dptr, tid->at_port);
+ ADD_U_INT32(dptr, tid->at_type);
+ if (tid->at_type == AU_IPv6)
+ ADD_MEM(dptr, &tid->at_addr[0], 4 * sizeof(u_int32_t));
+ else
+ ADD_MEM(dptr, &tid->at_addr[0], sizeof(u_int32_t));
+
+ return (t);
}
token_t *
@@ -1102,6 +1227,27 @@
}
/*
+ * token ID 1 byte
+ * zonename length 2 bytes
+ * zonename N bytes + 1 terminating NULL byte
+ */
+token_t *
+au_to_zonename(char *zonename)
+{
+ u_char *dptr = NULL;
+ u_int16_t textlen;
+ token_t *t;
+
+ textlen = strlen(zonename);
+ textlen += 1;
+ GET_TOKEN_AREA(t, dptr, sizeof(u_char) + sizeof(u_int16_t) + textlen);
+ ADD_U_CHAR(dptr, AUT_ZONENAME);
+ ADD_U_INT16(dptr, textlen);
+ ADD_STRING(dptr, zonename, textlen);
+ return (t);
+}
+
+/*
* token ID 1 byte
* count 4 bytes
* text count null-terminated strings
@@ -1175,6 +1321,31 @@
return (t);
}
+token_t *
+au_to_header64_tm(int rec_size, au_event_t e_type, au_emod_t e_mod,
+ struct timeval tm)
+{
+ token_t *t;
+ u_char *dptr = NULL;
+ u_int32_t timems;
+
+ GET_TOKEN_AREA(t, dptr, sizeof(u_char) + sizeof(u_int32_t) +
+ sizeof(u_char) + 2 * sizeof(u_int16_t) + 2 * sizeof(u_int64_t));
+
+ ADD_U_CHAR(dptr, AUT_HEADER64);
+ ADD_U_INT32(dptr, rec_size);
+ ADD_U_CHAR(dptr, AUDIT_HEADER_VERSION_OPENBSM);
+ ADD_U_INT16(dptr, e_type);
+ ADD_U_INT16(dptr, e_mod);
+
+ timems = tm.tv_usec/1000;
+ /* Add the timestamp */
+ ADD_U_INT64(dptr, tm.tv_sec);
+ ADD_U_INT64(dptr, timems); /* We need time in ms. */
+
+ return (t);
+}
+
/*
* token ID 1 byte
* trailer magic number 2 bytes
More information about the p4-projects
mailing list