svn commit: r246457 - in user/attilio/vmc-playground/sys: dev/ath dev/sound/pcm dev/sound/usb kern security/audit
Attilio Rao
attilio at FreeBSD.org
Thu Feb 7 10:24:07 UTC 2013
Author: attilio
Date: Thu Feb 7 10:24:04 2013
New Revision: 246457
URL: http://svnweb.freebsd.org/changeset/base/246457
Log:
Merge from vmcontention
Modified:
user/attilio/vmc-playground/sys/dev/ath/if_ath.c
user/attilio/vmc-playground/sys/dev/ath/if_ath_ahb.c
user/attilio/vmc-playground/sys/dev/ath/if_ath_misc.h
user/attilio/vmc-playground/sys/dev/ath/if_ath_pci.c
user/attilio/vmc-playground/sys/dev/ath/if_ath_tx.c
user/attilio/vmc-playground/sys/dev/ath/if_ath_tx_edma.c
user/attilio/vmc-playground/sys/dev/ath/if_athvar.h
user/attilio/vmc-playground/sys/dev/sound/pcm/mixer.c
user/attilio/vmc-playground/sys/dev/sound/pcm/mixer.h
user/attilio/vmc-playground/sys/dev/sound/usb/uaudio.c
user/attilio/vmc-playground/sys/kern/kern_intr.c
user/attilio/vmc-playground/sys/kern/uipc_syscalls.c
user/attilio/vmc-playground/sys/security/audit/audit.h
Directory Properties:
user/attilio/vmc-playground/ (props changed)
user/attilio/vmc-playground/sys/ (props changed)
Modified: user/attilio/vmc-playground/sys/dev/ath/if_ath.c
==============================================================================
--- user/attilio/vmc-playground/sys/dev/ath/if_ath.c Thu Feb 7 10:21:01 2013 (r246456)
+++ user/attilio/vmc-playground/sys/dev/ath/if_ath.c Thu Feb 7 10:24:04 2013 (r246457)
@@ -2687,7 +2687,7 @@ ath_txq_qadd(struct ifnet *ifp, struct m
struct mbuf *m;
/* XXX recursive TX completion -> TX? */
- ATH_TX_UNLOCK_ASSERT(sc);
+ ATH_TX_IC_UNLOCK_ASSERT(sc);
/*
* We grab the node pointer, but we don't deref
@@ -2749,7 +2749,7 @@ ath_txq_qadd(struct ifnet *ifp, struct m
* into the driver.
*/
- ATH_TX_LOCK(sc);
+ ATH_TX_IC_LOCK(sc);
/*
* Throw the single frame onto the queue.
@@ -2797,7 +2797,7 @@ ath_txq_qadd(struct ifnet *ifp, struct m
m = m->m_nextpkt;
}
- ATH_TX_UNLOCK(sc);
+ ATH_TX_IC_UNLOCK(sc);
return (0);
bad:
@@ -2825,13 +2825,13 @@ ath_txq_qflush(struct ifnet *ifp)
TAILQ_INIT(&txlist);
/* Grab lock */
- ATH_TX_LOCK(sc);
+ ATH_TX_IC_LOCK(sc);
/* Copy everything out of sc_txbuf_list into txlist */
TAILQ_CONCAT(&txlist, &sc->sc_txbuf_list, bf_list);
/* Unlock */
- ATH_TX_UNLOCK(sc);
+ ATH_TX_IC_UNLOCK(sc);
/* Now, walk the list, freeing things */
while ((bf = TAILQ_FIRST(&txlist)) != NULL) {
@@ -2879,16 +2879,9 @@ ath_txq_qrun(struct ifnet *ifp)
*/
/* Copy everything out of sc_txbuf_list into txlist */
- ATH_TX_LOCK(sc);
+ ATH_TX_IC_LOCK(sc);
TAILQ_CONCAT(&txlist, &sc->sc_txbuf_list, bf_list);
- ATH_TX_UNLOCK(sc);
-
- /*
- * For now, the ath_tx_start() code sits behind the same lock;
- * worry about serialising this in a taskqueue later.
- */
-
- ATH_TX_LOCK(sc);
+ ATH_TX_IC_UNLOCK(sc);
/*
* Attempt to transmit each frame.
@@ -2899,6 +2892,7 @@ ath_txq_qrun(struct ifnet *ifp)
* It would be nice to chain together TX fragments in this
* way so they can be aborted together.
*/
+ ATH_TX_LOCK(sc);
TAILQ_FOREACH_SAFE(bf, &txlist, bf_list, bf_next) {
/*
* Clear, because we're going to reuse this
@@ -4230,9 +4224,9 @@ ath_tx_processq(struct ath_softc *sc, st
ieee80211_ff_flush(ic, txq->axq_ac);
#endif
- /* Kick the TXQ scheduler */
+ /* Kick the software TXQ scheduler */
if (dosched) {
- taskqueue_enqueue(sc->sc_tx_tq, &sc->sc_txqtask);
+ ath_tx_swq_kick(sc);
}
ATH_KTR(sc, ATH_KTR_TXCOMP, 1,
Modified: user/attilio/vmc-playground/sys/dev/ath/if_ath_ahb.c
==============================================================================
--- user/attilio/vmc-playground/sys/dev/ath/if_ath_ahb.c Thu Feb 7 10:21:01 2013 (r246456)
+++ user/attilio/vmc-playground/sys/dev/ath/if_ath_ahb.c Thu Feb 7 10:24:04 2013 (r246457)
@@ -195,6 +195,7 @@ ath_ahb_attach(device_t dev)
ATH_PCU_LOCK_INIT(sc);
ATH_RX_LOCK_INIT(sc);
ATH_TX_LOCK_INIT(sc);
+ ATH_TX_IC_LOCK_INIT(sc);
ATH_TXSTATUS_LOCK_INIT(sc);
error = ath_attach(AR9130_DEVID, sc);
@@ -204,6 +205,7 @@ ath_ahb_attach(device_t dev)
ATH_TXSTATUS_LOCK_DESTROY(sc);
ATH_RX_LOCK_DESTROY(sc);
ATH_TX_LOCK_DESTROY(sc);
+ ATH_TX_IC_LOCK_DESTROY(sc);
ATH_PCU_LOCK_DESTROY(sc);
ATH_LOCK_DESTROY(sc);
bus_dma_tag_destroy(sc->sc_dmat);
@@ -247,6 +249,7 @@ ath_ahb_detach(device_t dev)
ATH_TXSTATUS_LOCK_DESTROY(sc);
ATH_RX_LOCK_DESTROY(sc);
ATH_TX_LOCK_DESTROY(sc);
+ ATH_TX_IC_LOCK_DESTROY(sc);
ATH_PCU_LOCK_DESTROY(sc);
ATH_LOCK_DESTROY(sc);
Modified: user/attilio/vmc-playground/sys/dev/ath/if_ath_misc.h
==============================================================================
--- user/attilio/vmc-playground/sys/dev/ath/if_ath_misc.h Thu Feb 7 10:21:01 2013 (r246456)
+++ user/attilio/vmc-playground/sys/dev/ath/if_ath_misc.h Thu Feb 7 10:24:04 2013 (r246457)
@@ -120,12 +120,24 @@ extern void ath_tx_update_tim(struct ath
extern void ath_start(struct ifnet *ifp);
extern void ath_start_task(void *arg, int npending);
+/*
+ * Kick the frame TX task.
+ */
static inline void
ath_tx_kick(struct ath_softc *sc)
{
- /* XXX eventually try sc_tx_tq? */
taskqueue_enqueue(sc->sc_tx_tq, &sc->sc_txpkttask);
}
+/*
+ * Kick the software TX queue task.
+ */
+static inline void
+ath_tx_swq_kick(struct ath_softc *sc)
+{
+
+ taskqueue_enqueue(sc->sc_tx_tq, &sc->sc_txqtask);
+}
+
#endif
Modified: user/attilio/vmc-playground/sys/dev/ath/if_ath_pci.c
==============================================================================
--- user/attilio/vmc-playground/sys/dev/ath/if_ath_pci.c Thu Feb 7 10:21:01 2013 (r246456)
+++ user/attilio/vmc-playground/sys/dev/ath/if_ath_pci.c Thu Feb 7 10:24:04 2013 (r246457)
@@ -251,6 +251,7 @@ ath_pci_attach(device_t dev)
ATH_PCU_LOCK_INIT(sc);
ATH_RX_LOCK_INIT(sc);
ATH_TX_LOCK_INIT(sc);
+ ATH_TX_IC_LOCK_INIT(sc);
ATH_TXSTATUS_LOCK_INIT(sc);
error = ath_attach(pci_get_device(dev), sc);
@@ -260,6 +261,7 @@ ath_pci_attach(device_t dev)
ATH_TXSTATUS_LOCK_DESTROY(sc);
ATH_PCU_LOCK_DESTROY(sc);
ATH_RX_LOCK_DESTROY(sc);
+ ATH_TX_IC_LOCK_DESTROY(sc);
ATH_TX_LOCK_DESTROY(sc);
ATH_LOCK_DESTROY(sc);
bus_dma_tag_destroy(sc->sc_dmat);
@@ -302,6 +304,7 @@ ath_pci_detach(device_t dev)
ATH_TXSTATUS_LOCK_DESTROY(sc);
ATH_PCU_LOCK_DESTROY(sc);
ATH_RX_LOCK_DESTROY(sc);
+ ATH_TX_IC_LOCK_DESTROY(sc);
ATH_TX_LOCK_DESTROY(sc);
ATH_LOCK_DESTROY(sc);
Modified: user/attilio/vmc-playground/sys/dev/ath/if_ath_tx.c
==============================================================================
--- user/attilio/vmc-playground/sys/dev/ath/if_ath_tx.c Thu Feb 7 10:21:01 2013 (r246456)
+++ user/attilio/vmc-playground/sys/dev/ath/if_ath_tx.c Thu Feb 7 10:24:04 2013 (r246457)
@@ -2999,9 +2999,11 @@ ath_tx_tid_resume(struct ath_softc *sc,
}
ath_tx_tid_sched(sc, tid);
- /* Punt some frames to the hardware if needed */
- //ath_txq_sched(sc, sc->sc_ac2q[tid->ac]);
- taskqueue_enqueue(sc->sc_tx_tq, &sc->sc_txqtask);
+
+ /*
+ * Queue the software TX scheduler.
+ */
+ ath_tx_swq_kick(sc);
}
/*
Modified: user/attilio/vmc-playground/sys/dev/ath/if_ath_tx_edma.c
==============================================================================
--- user/attilio/vmc-playground/sys/dev/ath/if_ath_tx_edma.c Thu Feb 7 10:21:01 2013 (r246456)
+++ user/attilio/vmc-playground/sys/dev/ath/if_ath_tx_edma.c Thu Feb 7 10:24:04 2013 (r246457)
@@ -655,7 +655,7 @@ ath_edma_tx_processq(struct ath_softc *s
* the txq task for _one_ TXQ. This should be fixed.
*/
if (dosched)
- taskqueue_enqueue(sc->sc_tx_tq, &sc->sc_txqtask);
+ ath_tx_swq_kick(sc);
}
static void
Modified: user/attilio/vmc-playground/sys/dev/ath/if_athvar.h
==============================================================================
--- user/attilio/vmc-playground/sys/dev/ath/if_athvar.h Thu Feb 7 10:21:01 2013 (r246456)
+++ user/attilio/vmc-playground/sys/dev/ath/if_athvar.h Thu Feb 7 10:24:04 2013 (r246457)
@@ -520,8 +520,10 @@ struct ath_softc {
char sc_pcu_mtx_name[32];
struct mtx sc_rx_mtx; /* RX access mutex */
char sc_rx_mtx_name[32];
- struct mtx sc_tx_mtx; /* TX access mutex */
+ struct mtx sc_tx_mtx; /* TX handling/comp mutex */
char sc_tx_mtx_name[32];
+ struct mtx sc_tx_ic_mtx; /* TX queue mutex */
+ char sc_tx_ic_mtx_name[32];
struct taskqueue *sc_tq; /* private task queue */
struct taskqueue *sc_tx_tq; /* private TX task queue */
struct ath_hal *sc_ah; /* Atheros HAL */
@@ -795,10 +797,8 @@ struct ath_softc {
#define ATH_UNLOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_mtx, MA_NOTOWNED)
/*
- * The TX lock is non-reentrant and serialises the TX send operations.
- * (ath_start(), ath_raw_xmit().) It doesn't yet serialise the TX
- * completion operations; thus it can't be used (yet!) to protect
- * hardware / software TXQ operations.
+ * The TX lock is non-reentrant and serialises the TX frame send
+ * and completion operations.
*/
#define ATH_TX_LOCK_INIT(_sc) do {\
snprintf((_sc)->sc_tx_mtx_name, \
@@ -817,6 +817,26 @@ struct ath_softc {
MA_NOTOWNED)
/*
+ * The IC TX lock is non-reentrant and serialises packet queuing from
+ * the upper layers.
+ */
+#define ATH_TX_IC_LOCK_INIT(_sc) do {\
+ snprintf((_sc)->sc_tx_ic_mtx_name, \
+ sizeof((_sc)->sc_tx_ic_mtx_name), \
+ "%s IC TX lock", \
+ device_get_nameunit((_sc)->sc_dev)); \
+ mtx_init(&(_sc)->sc_tx_ic_mtx, (_sc)->sc_tx_ic_mtx_name, \
+ NULL, MTX_DEF); \
+ } while (0)
+#define ATH_TX_IC_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_tx_ic_mtx)
+#define ATH_TX_IC_LOCK(_sc) mtx_lock(&(_sc)->sc_tx_ic_mtx)
+#define ATH_TX_IC_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_tx_ic_mtx)
+#define ATH_TX_IC_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_tx_ic_mtx, \
+ MA_OWNED)
+#define ATH_TX_IC_UNLOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_tx_ic_mtx, \
+ MA_NOTOWNED)
+
+/*
* The PCU lock is non-recursive and should be treated as a spinlock.
* Although currently the interrupt code is run in netisr context and
* doesn't require this, this may change in the future.
Modified: user/attilio/vmc-playground/sys/dev/sound/pcm/mixer.c
==============================================================================
--- user/attilio/vmc-playground/sys/dev/sound/pcm/mixer.c Thu Feb 7 10:21:01 2013 (r246456)
+++ user/attilio/vmc-playground/sys/dev/sound/pcm/mixer.c Thu Feb 7 10:24:04 2013 (r246457)
@@ -893,14 +893,8 @@ mixer_hwvol_init(device_t dev)
}
void
-mixer_hwvol_mute(device_t dev)
+mixer_hwvol_mute_locked(struct snd_mixer *m)
{
- struct snd_mixer *m;
- struct cdev *pdev;
-
- pdev = mixer_get_devt(dev);
- m = pdev->si_drv1;
- snd_mtxlock(m->lock);
if (m->hwvol_muted) {
m->hwvol_muted = 0;
mixer_set(m, m->hwvol_mixer, m->hwvol_mute_level);
@@ -909,19 +903,26 @@ mixer_hwvol_mute(device_t dev)
m->hwvol_mute_level = mixer_get(m, m->hwvol_mixer);
mixer_set(m, m->hwvol_mixer, 0);
}
- snd_mtxunlock(m->lock);
}
void
-mixer_hwvol_step(device_t dev, int left_step, int right_step)
+mixer_hwvol_mute(device_t dev)
{
struct snd_mixer *m;
- int level, left, right;
struct cdev *pdev;
pdev = mixer_get_devt(dev);
m = pdev->si_drv1;
snd_mtxlock(m->lock);
+ mixer_hwvol_mute_locked(m);
+ snd_mtxunlock(m->lock);
+}
+
+void
+mixer_hwvol_step_locked(struct snd_mixer *m, int left_step, int right_step)
+{
+ int level, left, right;
+
if (m->hwvol_muted) {
m->hwvol_muted = 0;
level = m->hwvol_mute_level;
@@ -929,15 +930,31 @@ mixer_hwvol_step(device_t dev, int left_
level = mixer_get(m, m->hwvol_mixer);
if (level != -1) {
left = level & 0xff;
- right = level >> 8;
+ right = (level >> 8) & 0xff;
left += left_step * m->hwvol_step;
if (left < 0)
left = 0;
+ else if (left > 100)
+ left = 100;
right += right_step * m->hwvol_step;
if (right < 0)
right = 0;
+ else if (right > 100)
+ right = 100;
mixer_set(m, m->hwvol_mixer, left | right << 8);
}
+}
+
+void
+mixer_hwvol_step(device_t dev, int left_step, int right_step)
+{
+ struct snd_mixer *m;
+ struct cdev *pdev;
+
+ pdev = mixer_get_devt(dev);
+ m = pdev->si_drv1;
+ snd_mtxlock(m->lock);
+ mixer_hwvol_step_locked(m, left_step, right_step);
snd_mtxunlock(m->lock);
}
Modified: user/attilio/vmc-playground/sys/dev/sound/pcm/mixer.h
==============================================================================
--- user/attilio/vmc-playground/sys/dev/sound/pcm/mixer.h Thu Feb 7 10:21:01 2013 (r246456)
+++ user/attilio/vmc-playground/sys/dev/sound/pcm/mixer.h Thu Feb 7 10:24:04 2013 (r246457)
@@ -40,7 +40,9 @@ int mixer_ioctl_cmd(struct cdev *i_dev,
int mixer_oss_mixerinfo(struct cdev *i_dev, oss_mixerinfo *mi);
int mixer_hwvol_init(device_t dev);
+void mixer_hwvol_mute_locked(struct snd_mixer *m);
void mixer_hwvol_mute(device_t dev);
+void mixer_hwvol_step_locked(struct snd_mixer *m, int l_step, int r_step);
void mixer_hwvol_step(device_t dev, int left_step, int right_step);
int mixer_busy(struct snd_mixer *m);
Modified: user/attilio/vmc-playground/sys/dev/sound/usb/uaudio.c
==============================================================================
--- user/attilio/vmc-playground/sys/dev/sound/usb/uaudio.c Thu Feb 7 10:21:01 2013 (r246456)
+++ user/attilio/vmc-playground/sys/dev/sound/usb/uaudio.c Thu Feb 7 10:24:04 2013 (r246457)
@@ -287,14 +287,17 @@ struct uaudio_hid {
struct usb_xfer *xfer[UAUDIO_HID_N_TRANSFER];
struct hid_location volume_up_loc;
struct hid_location volume_down_loc;
+ struct hid_location mute_loc;
uint32_t flags;
#define UAUDIO_HID_VALID 0x0001
#define UAUDIO_HID_HAS_ID 0x0002
#define UAUDIO_HID_HAS_VOLUME_UP 0x0004
#define UAUDIO_HID_HAS_VOLUME_DOWN 0x0008
+#define UAUDIO_HID_HAS_MUTE 0x0010
uint8_t iface_index;
uint8_t volume_up_id;
uint8_t volume_down_id;
+ uint8_t mute_id;
};
struct uaudio_softc {
@@ -1012,6 +1015,8 @@ uaudio_attach_sub(device_t dev, kobj_cla
goto detach;
sc->sc_mixer_init = 1;
+ mixer_hwvol_init(dev);
+
snprintf(status, sizeof(status), "at ? %s", PCM_KLDSTRING(snd_uaudio));
if (pcm_register(dev, sc,
@@ -5520,9 +5525,6 @@ uaudio_hid_rx_callback(struct usb_xfer *
struct uaudio_softc *sc = usbd_xfer_softc(xfer);
const uint8_t *buffer = usbd_xfer_get_frame_buffer(xfer, 0);
struct snd_mixer *m;
- int v;
- int v_l;
- int v_r;
uint8_t id;
int actlen;
@@ -5543,6 +5545,16 @@ uaudio_hid_rx_callback(struct usb_xfer *
m = sc->sc_mixer_dev;
+ if ((sc->sc_hid.flags & UAUDIO_HID_HAS_MUTE) &&
+ (sc->sc_hid.mute_id == id) &&
+ hid_get_data(buffer, actlen,
+ &sc->sc_hid.mute_loc)) {
+
+ DPRINTF("Mute toggle\n");
+
+ mixer_hwvol_mute_locked(m);
+ }
+
if ((sc->sc_hid.flags & UAUDIO_HID_HAS_VOLUME_UP) &&
(sc->sc_hid.volume_up_id == id) &&
hid_get_data(buffer, actlen,
@@ -5550,13 +5562,7 @@ uaudio_hid_rx_callback(struct usb_xfer *
DPRINTF("Volume Up\n");
- v = mix_get_locked(m, SOUND_MIXER_PCM, &v_l, &v_r);
- if (v == 0) {
- v = ((v_l + v_r) / 2) + 5;
- if (v > 100)
- v = 100;
- mix_set_locked(m, SOUND_MIXER_PCM, v, v);
- }
+ mixer_hwvol_step_locked(m, 1, 1);
}
if ((sc->sc_hid.flags & UAUDIO_HID_HAS_VOLUME_DOWN) &&
@@ -5566,13 +5572,7 @@ uaudio_hid_rx_callback(struct usb_xfer *
DPRINTF("Volume Down\n");
- v = mix_get_locked(m, SOUND_MIXER_PCM, &v_l, &v_r);
- if (v == 0) {
- v = ((v_l + v_r) / 2) - 5;
- if (v < 0)
- v = 0;
- mix_set_locked(m, SOUND_MIXER_PCM, v, v);
- }
+ mixer_hwvol_step_locked(m, -1, -1);
}
case USB_ST_SETUP:
@@ -5641,10 +5641,20 @@ uaudio_hid_probe(struct uaudio_softc *sc
DPRINTFN(1, "Found Volume Down key\n");
}
+ if (hid_locate(d_ptr, d_len,
+ HID_USAGE2(HUP_CONSUMER, 0xE2 /* Mute */),
+ hid_input, 0, &sc->sc_hid.mute_loc, &flags,
+ &sc->sc_hid.mute_id)) {
+ if (flags & HIO_VARIABLE)
+ sc->sc_hid.flags |= UAUDIO_HID_HAS_MUTE;
+ DPRINTFN(1, "Found Mute key\n");
+ }
+
free(d_ptr, M_TEMP);
if (!(sc->sc_hid.flags & (UAUDIO_HID_HAS_VOLUME_UP |
- UAUDIO_HID_HAS_VOLUME_DOWN))) {
+ UAUDIO_HID_HAS_VOLUME_DOWN |
+ UAUDIO_HID_HAS_MUTE))) {
DPRINTFN(1, "Did not find any volume related keys\n");
return (-1);
}
Modified: user/attilio/vmc-playground/sys/kern/kern_intr.c
==============================================================================
--- user/attilio/vmc-playground/sys/kern/kern_intr.c Thu Feb 7 10:21:01 2013 (r246456)
+++ user/attilio/vmc-playground/sys/kern/kern_intr.c Thu Feb 7 10:24:04 2013 (r246457)
@@ -336,7 +336,7 @@ intr_event_bind(struct intr_event *ie, u
if (ie->ie_cpu == NOCPU)
CPU_COPY(cpuset_root, &mask);
else
- CPU_SET(cpu, &mask);
+ CPU_SET(ie->ie_cpu, &mask);
id = ie->ie_thread->it_thread->td_tid;
mtx_unlock(&ie->ie_lock);
(void)cpuset_setthread(id, &mask);
Modified: user/attilio/vmc-playground/sys/kern/uipc_syscalls.c
==============================================================================
--- user/attilio/vmc-playground/sys/kern/uipc_syscalls.c Thu Feb 7 10:21:01 2013 (r246456)
+++ user/attilio/vmc-playground/sys/kern/uipc_syscalls.c Thu Feb 7 10:24:04 2013 (r246457)
@@ -238,6 +238,7 @@ kern_bind(td, fd, sa)
int error;
AUDIT_ARG_FD(fd);
+ AUDIT_ARG_SOCKADDR(td, sa);
error = getsock_cap(td->td_proc->p_fd, fd, CAP_BIND, &fp, NULL);
if (error)
return (error);
@@ -452,6 +453,7 @@ kern_accept(struct thread *td, int s, st
*namelen = 0;
goto done;
}
+ AUDIT_ARG_SOCKADDR(td, sa);
if (name) {
/* check sa_len before it is destroyed */
if (*namelen > sa->sa_len)
@@ -547,6 +549,7 @@ kern_connect(td, fd, sa)
int interrupted = 0;
AUDIT_ARG_FD(fd);
+ AUDIT_ARG_SOCKADDR(td, sa);
error = getsock_cap(td->td_proc->p_fd, fd, CAP_CONNECT, &fp, NULL);
if (error)
return (error);
@@ -763,8 +766,10 @@ kern_sendit(td, s, mp, flags, control, s
AUDIT_ARG_FD(s);
rights = CAP_WRITE;
- if (mp->msg_name != NULL)
+ if (mp->msg_name != NULL) {
+ AUDIT_ARG_SOCKADDR(td, mp->msg_name);
rights |= CAP_CONNECT;
+ }
error = getsock_cap(td->td_proc->p_fd, s, rights, &fp, NULL);
if (error)
return (error);
@@ -956,11 +961,11 @@ kern_recvit(td, s, mp, fromseg, controlp
int i;
ssize_t len;
int error;
- struct mbuf *m, *control = 0;
+ struct mbuf *m, *control = NULL;
caddr_t ctlbuf;
struct file *fp;
struct socket *so;
- struct sockaddr *fromsa = 0;
+ struct sockaddr *fromsa = NULL;
#ifdef KTRACE
struct uio *ktruio = NULL;
#endif
@@ -1001,14 +1006,16 @@ kern_recvit(td, s, mp, fromseg, controlp
ktruio = cloneuio(&auio);
#endif
len = auio.uio_resid;
- error = soreceive(so, &fromsa, &auio, (struct mbuf **)0,
- (mp->msg_control || controlp) ? &control : (struct mbuf **)0,
+ error = soreceive(so, &fromsa, &auio, NULL,
+ (mp->msg_control || controlp) ? &control : NULL,
&mp->msg_flags);
if (error) {
if (auio.uio_resid != len && (error == ERESTART ||
error == EINTR || error == EWOULDBLOCK))
error = 0;
}
+ if (fromsa != NULL)
+ AUDIT_ARG_SOCKADDR(td, fromsa);
#ifdef KTRACE
if (ktruio != NULL) {
ktruio->uio_resid = len - auio.uio_resid;
@@ -1020,7 +1027,7 @@ kern_recvit(td, s, mp, fromseg, controlp
td->td_retval[0] = len - auio.uio_resid;
if (mp->msg_name) {
len = mp->msg_namelen;
- if (len <= 0 || fromsa == 0)
+ if (len <= 0 || fromsa == NULL)
len = 0;
else {
/* save sa_len before it is destroyed by MSG_COMPAT */
@@ -1095,7 +1102,7 @@ out:
if (fromsa)
free(fromsa, M_SONAME);
- if (error == 0 && controlp != NULL)
+ if (error == 0 && controlp != NULL)
*controlp = control;
else if (control)
m_freem(control);
@@ -1716,7 +1723,7 @@ getsockaddr(namp, uaddr, len)
struct sendfile_sync {
struct mtx mtx;
struct cv cv;
- unsigned count;
+ unsigned count;
};
/*
@@ -2233,7 +2240,7 @@ retry_space:
}
/* Quit outer loop on error or when we're done. */
- if (done)
+ if (done)
break;
if (error)
goto done;
@@ -2333,7 +2340,7 @@ sys_sctp_peeloff(td, uap)
CURVNET_SET(head->so_vnet);
so = sonewconn(head, SS_ISCONNECTED);
- if (so == NULL)
+ if (so == NULL)
goto noconnection;
/*
* Before changing the flags on the socket, we have to bump the
@@ -2387,12 +2394,12 @@ int
sys_sctp_generic_sendmsg (td, uap)
struct thread *td;
struct sctp_generic_sendmsg_args /* {
- int sd,
- caddr_t msg,
- int mlen,
- caddr_t to,
- __socklen_t tolen,
- struct sctp_sndrcvinfo *sinfo,
+ int sd,
+ caddr_t msg,
+ int mlen,
+ caddr_t to,
+ __socklen_t tolen,
+ struct sctp_sndrcvinfo *sinfo,
int flags
} */ *uap;
{
@@ -2498,12 +2505,12 @@ int
sys_sctp_generic_sendmsg_iov(td, uap)
struct thread *td;
struct sctp_generic_sendmsg_iov_args /* {
- int sd,
- struct iovec *iov,
- int iovlen,
- caddr_t to,
- __socklen_t tolen,
- struct sctp_sndrcvinfo *sinfo,
+ int sd,
+ struct iovec *iov,
+ int iovlen,
+ caddr_t to,
+ __socklen_t tolen,
+ struct sctp_sndrcvinfo *sinfo,
int flags
} */ *uap;
{
@@ -2625,12 +2632,12 @@ int
sys_sctp_generic_recvmsg(td, uap)
struct thread *td;
struct sctp_generic_recvmsg_args /* {
- int sd,
- struct iovec *iov,
+ int sd,
+ struct iovec *iov,
int iovlen,
- struct sockaddr *from,
+ struct sockaddr *from,
__socklen_t *fromlenaddr,
- struct sctp_sndrcvinfo *sinfo,
+ struct sctp_sndrcvinfo *sinfo,
int *msg_flags
} */ *uap;
{
@@ -2696,7 +2703,7 @@ sys_sctp_generic_recvmsg(td, uap)
}
auio.uio_iov = iov;
auio.uio_iovcnt = uap->iovlen;
- auio.uio_segflg = UIO_USERSPACE;
+ auio.uio_segflg = UIO_USERSPACE;
auio.uio_rw = UIO_READ;
auio.uio_td = td;
auio.uio_offset = 0; /* XXX */
@@ -2767,7 +2774,7 @@ sys_sctp_generic_recvmsg(td, uap)
out:
free(iov, M_IOV);
out1:
- if (fp)
+ if (fp)
fdrop(fp, td);
return (error);
Modified: user/attilio/vmc-playground/sys/security/audit/audit.h
==============================================================================
--- user/attilio/vmc-playground/sys/security/audit/audit.h Thu Feb 7 10:21:01 2013 (r246456)
+++ user/attilio/vmc-playground/sys/security/audit/audit.h Thu Feb 7 10:24:04 2013 (r246457)
@@ -261,6 +261,11 @@ void audit_thread_free(struct thread *t
audit_arg_socket((sodomain), (sotype), (soprotocol)); \
} while (0)
+#define AUDIT_ARG_SOCKADDR(td, sa) do { \
+ if (AUDITING_TD(curthread)) \
+ audit_arg_sockaddr((td), (sa)); \
+} while (0)
+
#define AUDIT_ARG_SUID(suid) do { \
if (AUDITING_TD(curthread)) \
audit_arg_suid((suid)); \
@@ -353,6 +358,7 @@ void audit_thread_free(struct thread *t
#define AUDIT_ARG_SIGNUM(signum)
#define AUDIT_ARG_SGID(sgid)
#define AUDIT_ARG_SOCKET(sodomain, sotype, soprotocol)
+#define AUDIT_ARG_SOCKADDR(td, sa)
#define AUDIT_ARG_SUID(suid)
#define AUDIT_ARG_TEXT(text)
#define AUDIT_ARG_UID(uid)
More information about the svn-src-user
mailing list