Browse Source

Merge branch 'freebsd/current/master' into hardened/current/master

* freebsd/current/master:
  Trim a spurious blank line I added in r348969.
  ping: fix -Wformat-truncating warning with GCC
  link ptnet(4) man page to the build system
  if_tuntap: minor improvements
  Fix netdump buffering after r348473.
  ti: sdhci: Correct voltage caps
  arm64: a37x0_gpio: Use syscon instead of MMIO region
  ping6: revert r350857
  vfs: fix up r351193 ("stop always overwriting ->mnt_stat in VFS_STATFS")
  Use TAILQ_FOREACH_SAFE() macro to avoid use after free in soclose().
hardened/current/master
Oliver Pinter + 9 months ago
parent
commit
566353d884
10 changed files with 84 additions and 71 deletions
  1. +1
    -1
      sbin/ping/ping.c
  2. +6
    -6
      sbin/ping6/ping6.c
  3. +2
    -0
      share/man/man4/Makefile
  4. +0
    -1
      share/man/man9/sysctl.9
  5. +10
    -19
      sys/arm/mv/a37x0_gpio.c
  6. +12
    -10
      sys/arm/ti/ti_sdhci.c
  7. +2
    -2
      sys/kern/uipc_socket.c
  8. +6
    -0
      sys/kern/vfs_mount.c
  9. +18
    -20
      sys/net/if_tuntap.c
  10. +27
    -12
      sys/netinet/netdump/netdump_client.c

+ 1
- 1
sbin/ping/ping.c View File

@@ -1661,7 +1661,7 @@ pr_retip(struct ip *ip)
static char *
pr_ntime(n_time timestamp)
{
static char buf[10];
static char buf[11];
int hour, min, sec;

sec = ntohl(timestamp) / 1000;

+ 6
- 6
sbin/ping6/ping6.c View File

@@ -663,12 +663,6 @@ main(int argc, char *argv[])
err(1, "socket srecv");
freeaddrinfo(res);

/* revoke root privilege */
if (seteuid(getuid()) != 0)
err(1, "seteuid() failed");
if (setuid(getuid()) != 0)
err(1, "setuid() failed");

/* set the source address if specified. */
if ((options & F_SRCADDR) != 0) {
/* properly fill sin6_scope_id */
@@ -739,6 +733,12 @@ main(int argc, char *argv[])
#endif
}

/* revoke root privilege */
if (seteuid(getuid()) != 0)
err(1, "seteuid() failed");
if (setuid(getuid()) != 0)
err(1, "setuid() failed");

if ((options & F_FLOOD) && (options & F_INTERVAL))
errx(1, "-f and -i incompatible options");


+ 2
- 0
share/man/man4/Makefile View File

@@ -414,6 +414,7 @@ MAN= aac.4 \
psm.4 \
pst.4 \
pt.4 \
ptnet.4 \
pts.4 \
pty.4 \
puc.4 \
@@ -693,6 +694,7 @@ MLINKS+=pccbb.4 cbb.4
MLINKS+=pcm.4 snd.4 \
pcm.4 sound.4
MLINKS+=pms.4 pmspcv.4
MLINKS+=ptnet.4 if_ptnet.4
MLINKS+=ral.4 if_ral.4
MLINKS+=re.4 if_re.4
MLINKS+=rl.4 if_rl.4

+ 0
- 1
share/man/man9/sysctl.9 View File

@@ -482,7 +482,6 @@
.Fn SYSCTL_UQUAD parent number name ctlflags ptr val descr
.Fn SYSCTL_UMA_MAX parent number name ctlflags ptr descr
.Fn SYSCTL_UMA_CUR parent number name ctlflags ptr descr

.Sh DESCRIPTION
The
.Nm SYSCTL

+ 10
- 19
sys/arm/mv/a37x0_gpio.c View File

@@ -46,21 +46,14 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus_subr.h>

#include "gpio_if.h"

static struct resource_spec a37x0_gpio_res_spec[] = {
{ SYS_RES_MEMORY, 0, RF_ACTIVE }, /* Pinctl / GPIO */
{ SYS_RES_MEMORY, 1, RF_ACTIVE }, /* Interrupts control */
{ -1, 0, 0 }
};
#include "syscon_if.h"

struct a37x0_gpio_softc {
bus_space_tag_t sc_bst;
bus_space_handle_t sc_bsh;
device_t sc_busdev;
int sc_type;
uint32_t sc_max_pins;
uint32_t sc_npins;
struct resource *sc_mem_res[nitems(a37x0_gpio_res_spec) - 1];
struct syscon *syscon;
};

/* Memory regions. */
@@ -72,9 +65,9 @@ struct a37x0_gpio_softc {
#define A37X0_SB_GPIO 2

#define A37X0_GPIO_WRITE(_sc, _off, _val) \
bus_space_write_4((_sc)->sc_bst, (_sc)->sc_bsh, (_off), (_val))
SYSCON_WRITE_4((_sc)->syscon, (_off), (_val))
#define A37X0_GPIO_READ(_sc, _off) \
bus_space_read_4((_sc)->sc_bst, (_sc)->sc_bsh, (_off))
SYSCON_READ_4((_sc)->syscon, (_off))

#define A37X0_GPIO_BIT(_p) (1U << ((_p) % 32))
#define A37X0_GPIO_OUT_EN(_p) (0x0 + ((_p) / 32) * 4)
@@ -280,6 +273,12 @@ a37x0_gpio_attach(device_t dev)

sc = device_get_softc(dev);

err = syscon_get_handle_default(dev, &sc->syscon);
if (err != 0) {
device_printf(dev, "Cannot get syscon handle from parent\n");
return (ENXIO);
}

/* Read and verify the "gpio-ranges" property. */
ncells = OF_getencprop_alloc(ofw_bus_get_node(dev), "gpio-ranges",
(void **)&ranges);
@@ -296,14 +295,6 @@ a37x0_gpio_attach(device_t dev)
if (sc->sc_npins > sc->sc_max_pins)
return (ENXIO);

err = bus_alloc_resources(dev, a37x0_gpio_res_spec, sc->sc_mem_res);
if (err != 0) {
device_printf(dev, "cannot allocate memory window\n");
return (ENXIO);
}
sc->sc_bst = rman_get_bustag(sc->sc_mem_res[A37X0_GPIO]);
sc->sc_bsh = rman_get_bushandle(sc->sc_mem_res[A37X0_GPIO]);

sc->sc_busdev = gpiobus_attach_bus(dev);
if (sc->sc_busdev == NULL)
return (ENXIO);

+ 12
- 10
sys/arm/ti/ti_sdhci.c View File

@@ -482,15 +482,14 @@ ti_sdhci_hw_init(device_t dev)
* The attach() routine has examined fdt data and set flags in
* slot.host.caps to reflect what voltages we can handle. Set those
* values in the CAPA register. The manual says that these values can
* only be set once, "before initialization" whatever that means, and
* that they survive a reset. So maybe doing this will be a no-op if
* u-boot has already initialized the hardware.
* only be set once, and that they survive a reset so unless u-boot didn't
* set this register this code is a no-op.
*/
regval = ti_mmchs_read_4(sc, MMCHS_SD_CAPA);
if (sc->slot.host.caps & MMC_OCR_LOW_VOLTAGE)
regval |= MMCHS_SD_CAPA_VS18;
if (sc->slot.host.caps & (MMC_OCR_290_300 | MMC_OCR_300_310))
regval |= MMCHS_SD_CAPA_VS30;
if (sc->slot.host.caps & (MMC_OCR_320_330 | MMC_OCR_330_340))
regval |= MMCHS_SD_CAPA_VS33;
ti_mmchs_write_4(sc, MMCHS_SD_CAPA, regval);

/* Set initial host configuration (1-bit, std speed, pwr off). */
@@ -524,17 +523,20 @@ ti_sdhci_attach(device_t dev)
}

/*
* The hardware can inherently do dual-voltage (1p8v, 3p0v) on the first
* The hardware can inherently do dual-voltage (1p8v, 3p3v) on the first
* device, and only 1p8v on other devices unless an external transceiver
* is used. The only way we could know about a transceiver is fdt data.
* Note that we have to do this before calling ti_sdhci_hw_init() so
* that it can set the right values in the CAPA register, which can only
* be done once and never reset.
*/
sc->slot.host.caps |= MMC_OCR_LOW_VOLTAGE;
if (sc->mmchs_clk_id == MMC1_CLK || OF_hasprop(node, "ti,dual-volt")) {
sc->slot.host.caps |= MMC_OCR_290_300 | MMC_OCR_300_310;
}
if (OF_hasprop(node, "ti,dual-volt")) {
sc->slot.host.caps |= MMC_OCR_LOW_VOLTAGE | MMC_OCR_320_330 | MMC_OCR_330_340;
} else if (OF_hasprop(node, "no-1-8-v")) {
sc->slot.host.caps |= MMC_OCR_320_330 | MMC_OCR_330_340;
} else
sc->slot.host.caps |= MMC_OCR_LOW_VOLTAGE;


/*
* Set the offset from the device's memory start to the MMCHS registers.

+ 2
- 2
sys/kern/uipc_socket.c View File

@@ -1131,9 +1131,9 @@ drop:
so->so_state |= SS_NOFDREF;
sorele(so);
if (listening) {
struct socket *sp;
struct socket *sp, *tsp;

TAILQ_FOREACH(sp, &lqueue, so_list) {
TAILQ_FOREACH_SAFE(sp, &lqueue, so_list, tsp) {
SOCK_LOCK(sp);
if (sp->so_count == 0) {
SOCK_UNLOCK(sp);

+ 6
- 0
sys/kern/vfs_mount.c View File

@@ -1832,6 +1832,12 @@ int
__vfs_statfs(struct mount *mp, struct statfs *sbp)
{

/*
* Filesystems only fill in part of the structure for updates, we
* have to read the entirety first to get all content.
*/
memcpy(sbp, &mp->mnt_stat, sizeof(*sbp));

/*
* Set these in case the underlying filesystem fails to do so.
*/

+ 18
- 20
sys/net/if_tuntap.c View File

@@ -110,7 +110,6 @@ struct tuntap_softc {
u_short tun_flags; /* misc flags */
#define TUN_OPEN 0x0001
#define TUN_INITED 0x0002
#define TUN_RCOLL 0x0004
#define TUN_IASET 0x0008
#define TUN_DSTADDR 0x0010
#define TUN_LMODE 0x0020
@@ -168,9 +167,9 @@ SX_SYSINIT(tun_ioctl_sx, &tun_ioctl_sx, "tun_ioctl");
SYSCTL_DECL(_net_link);
/* tun */
static SYSCTL_NODE(_net_link, OID_AUTO, tun, CTLFLAG_RW, 0,
"IP tunnel software network interface.");
"IP tunnel software network interface");
SYSCTL_INT(_net_link_tun, OID_AUTO, devfs_cloning, CTLFLAG_RWTUN, &tundclone, 0,
"Enable legacy devfs interface creation.");
"Enable legacy devfs interface creation");

/* tap */
static SYSCTL_NODE(_net_link, OID_AUTO, tap, CTLFLAG_RW, 0,
@@ -442,7 +441,7 @@ tun_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
return (ENXIO);

if (unit != -1) {
/* If this unit number is still available that/s okay. */
/* If this unit number is still available that's okay. */
if (alloc_unr_specific(drv->unrhdr, unit) == -1)
return (EEXIST);
} else {
@@ -1435,22 +1434,22 @@ tunread(struct cdev *dev, struct uio *uio, int flag)

tp->tun_flags &= ~TUN_RWAIT;

do {
for (;;) {
IFQ_DEQUEUE(&ifp->if_snd, m);
if (m == NULL) {
if (flag & O_NONBLOCK) {
TUN_UNLOCK(tp);
return (EWOULDBLOCK);
}
tp->tun_flags |= TUN_RWAIT;
error = mtx_sleep(tp, &tp->tun_mtx, PCATCH | (PZERO + 1),
"tunread", 0);
if (error != 0) {
TUN_UNLOCK(tp);
return (error);
}
if (m != NULL)
break;
if (flag & O_NONBLOCK) {
TUN_UNLOCK(tp);
return (EWOULDBLOCK);
}
} while (m == NULL);
tp->tun_flags |= TUN_RWAIT;
error = mtx_sleep(tp, &tp->tun_mtx, PCATCH | (PZERO + 1),
"tunread", 0);
if (error != 0) {
TUN_UNLOCK(tp);
return (error);
}
}
TUN_UNLOCK(tp);

if ((tp->tun_flags & TUN_L2) != 0)
@@ -1629,8 +1628,7 @@ tunpoll(struct cdev *dev, int events, struct thread *td)
}
IFQ_UNLOCK(&ifp->if_snd);
}
if (events & (POLLOUT | POLLWRNORM))
revents |= events & (POLLOUT | POLLWRNORM);
revents |= events & (POLLOUT | POLLWRNORM);

return (revents);
}

+ 27
- 12
sys/netinet/netdump/netdump_client.c View File

@@ -922,6 +922,24 @@ netdump_network_poll(void)
* Dumping specific primitives.
*/

/*
* Flush any buffered vmcore data.
*/
static int
netdump_flush_buf(void)
{
int error;

error = 0;
if (nd_conf.nd_buf_len != 0) {
error = netdump_send(NETDUMP_VMCORE, nd_conf.nd_tx_off,
nd_buf, nd_conf.nd_buf_len);
if (error == 0)
nd_conf.nd_buf_len = 0;
}
return (error);
}

/*
* Callback from dumpsys() to dump a chunk of memory.
* Copies it out to our static buffer then sends it across the network.
@@ -948,13 +966,9 @@ netdump_dumper(void *priv __unused, void *virtual,
virtual, (uintmax_t)offset, length);

if (virtual == NULL) {
if (nd_conf.nd_buf_len != 0) {
error = netdump_send(NETDUMP_VMCORE, nd_conf.nd_tx_off, nd_buf,
nd_conf.nd_buf_len);
if (error != 0) {
dump_failed = 1;
}
}
error = netdump_flush_buf();
if (error != 0)
dump_failed = 1;

if (dump_failed != 0)
printf("failed to dump the kernel core\n");
@@ -968,16 +982,14 @@ netdump_dumper(void *priv __unused, void *virtual,
if (length > sizeof(nd_buf))
return (ENOSPC);

if (nd_conf.nd_buf_len + length > sizeof(nd_buf) ||
(nd_conf.nd_buf_len != 0 && nd_conf.nd_tx_off +
if (nd_conf.nd_buf_len + length > sizeof(nd_buf) ||
(nd_conf.nd_buf_len != 0 && nd_conf.nd_tx_off +
nd_conf.nd_buf_len != offset)) {
error = netdump_send(NETDUMP_VMCORE, nd_conf.nd_tx_off, nd_buf,
nd_conf.nd_buf_len);
error = netdump_flush_buf();
if (error != 0) {
dump_failed = 1;
return (error);
}
nd_conf.nd_buf_len = 0;
nd_conf.nd_tx_off = offset;
}

@@ -1078,6 +1090,9 @@ netdump_write_headers(struct dumperinfo *di, struct kerneldumpheader *kdh,
{
int error;

error = netdump_flush_buf();
if (error != 0)
return (error);
memcpy(nd_buf, kdh, sizeof(*kdh));
error = netdump_send(NETDUMP_KDH, 0, nd_buf, sizeof(*kdh));
if (error == 0 && keysize > 0) {

Loading…
Cancel
Save