Browse Source

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

* freebsd/current/master:
  No need to include netinet/sctp_crc32.h twice.
  Move the definition of SCTP's system_base_info into sctp_crc32.c.
  acpi_ibm(4): Add support for putting fans in disengaged mode.
  strtok(3): make it easier to find the RETURN VALUES section
  Translaate the PCI address when activating a resource
  gpiobus_release_pin: remove incorrect prefix from error messages
  Improve the rcorder manual page
hardened/current/safestack
HardenedBSD Sync Service 3 months ago
parent
commit
c55f351d81
8 changed files with 144 additions and 80 deletions
  1. +1
    -1
      lib/libc/string/strtok.3
  2. +55
    -35
      sbin/rcorder/rcorder.8
  3. +9
    -2
      share/man/man4/acpi_ibm.4
  4. +19
    -6
      sys/dev/acpi_support/acpi_ibm.c
  5. +2
    -2
      sys/dev/gpio/gpiobus.c
  6. +54
    -28
      sys/dev/pci/pci_host_generic.c
  7. +4
    -4
      sys/netinet/sctp_crc32.c
  8. +0
    -2
      sys/netinet/sctp_pcb.c

+ 1
- 1
lib/libc/string/strtok.3 View File

@@ -97,7 +97,7 @@ The
function
may also be used to nest two parsing loops within one another, as
long as separate context pointers are used.
.Pp
.Sh RETURN VALUES
The
.Fn strtok
and


+ 55
- 35
sbin/rcorder/rcorder.8 View File

@@ -31,7 +31,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd October 27, 2018
.Dd June 22, 2020
.Dt RCORDER 8
.Os
.Sh NAME
@@ -62,30 +62,30 @@ and which indicate, for each file, which
may be expected to be filled by that file.
.Pp
Within each file, a block containing a series of
.Dq Li REQUIRE ,
.Dq Li PROVIDE ,
.Dq Li BEFORE
.Ql REQUIRE ,
.Ql PROVIDE ,
.Ql BEFORE
and
.Dq Li KEYWORD
.Ql KEYWORD
lines must appear.
The format of the lines is rigid.
Each line must begin with a single
.Ql # ,
followed by a single space, followed by
.Dq Li PROVIDE: ,
.Dq Li REQUIRE: ,
.Dq Li BEFORE: ,
.Ql PROVIDE\&: ,
.Ql REQUIRE\&: ,
.Ql BEFORE\&: ,
or
.Dq Li KEYWORD: .
.Ql KEYWORD\&: .
No deviation is permitted.
Each dependency line is then followed by a series of conditions,
separated by whitespace.
Multiple
.Dq Li PROVIDE ,
.Dq Li REQUIRE ,
.Dq Li BEFORE
.Ql PROVIDE ,
.Ql REQUIRE ,
.Ql BEFORE
and
.Dq Li KEYWORD
.Ql KEYWORD
lines may appear, but all such lines must appear in a sequence without
any intervening lines, as once a line that does not follow the format
is reached, parsing stops.
@@ -94,19 +94,21 @@ is reached, parsing stops.
.\" that they can be deprecated at some point in the future.
.Pp
The options are as follows:
.Bl -tag -width indent
.It Fl k
.Bl -tag -width "-k keep"
.It Fl k Ar keep
Add the specified keyword to the
.Dq "keep list" .
If any
.Fl k
option is given, only those files containing the matching keyword are listed.
.It Fl s
This option can be specified multiple times.
.It Fl s Ar skip
Add the specified keyword to the
.Dq "skip list" .
If any
.Fl s
option is given, files containing the matching keyword are not listed.
This option can be specified multiple times.
.El
.Pp
An example block follows:
@@ -117,20 +119,20 @@ An example block follows:
.Ed
.Pp
This block states that the file in which it appears depends upon the
.Dq Li networking ,
.Dq Li syslog ,
.Ql networking ,
.Ql syslog ,
and
.Dq Li usr
.Ql usr
conditions, and provides the
.Dq Li dns
.Ql dns
and
.Dq Li nscd
.Ql nscd
conditions.
.Pp
A file may contain zero
.Dq Li PROVIDE
.Ql PROVIDE
lines, in which case it provides no conditions, and may contain zero
.Dq Li REQUIRE
.Ql REQUIRE
lines, in which case it has no dependencies.
There must be at least one file with no dependencies in the set of
arguments passed to
@@ -140,19 +142,36 @@ in order for it to find a starting place in the dependency ordering.
There are several
.Em KEYWORDs
in use:
.Bl -tag -width ".Cm shutdown" -offset indent
.It Cm firstboot, nojail, nojailvnet, nostart
.Bl -tag -width "shutdown" -offset indent
.It Sy firstboot , nojail , nojailvnet , nostart
Used by
.Xr rc 8 .
.It Cm resume
.It Sy resume
Used by
.Nm /etc/rc.resume
(see
.Xr acpiconf 8 )
.It Cm shutdown
.It Sy shutdown
Used by
.Xr rc.shutdown 8 .
.El
.Sh EXAMPLES
Print the dependency ordering of the services from the base system and
.Xr ports 7 :
.Bd -literal -offset indent
$ rcorder /etc/rc.d/* /usr/local/etc/rc.d/*
.Ed
.Pp
Count the number of services in the base system, which specify the
.Sy shutdown
keyword, while skipping those with
.Sy firstboot
and
.Sy nojailvnet :
.Bd -literal -offset indent
$ rcorder -k nostart -s firstboot -s nojailvnet /etc/rc.d/* | wc -l
3
.Ed
.Sh DIAGNOSTICS
The
.Nm
@@ -161,9 +180,9 @@ status if it encounters an error while processing the file list.
.Bl -diag
.It "Requirement %s has no providers, aborting."
No file has a
.Dq Li PROVIDE
.Ql PROVIDE
line corresponding to a condition present in a
.Dq Li REQUIRE
.Ql REQUIRE
line in another file.
.It "Circular dependency on provision %s, aborting."
A set of files has a circular dependency which was detected while
@@ -175,7 +194,8 @@ processing the stated file.
.Sh SEE ALSO
.Xr acpiconf 8 ,
.Xr rc 8 ,
.Xr rc.shutdown 8
.Xr rc.shutdown 8 ,
.Xr service 8
.Sh HISTORY
The
.Nm
@@ -192,7 +212,7 @@ and
.An Matthew R. Green Aq Mt mrg@eterna.com.au .
.Sh BUGS
The
.Dq Li REQUIRE
.Ql REQUIRE
keyword is misleading:
It does not describe which daemons have to be running before a script
will be started.
@@ -200,12 +220,12 @@ It describes which scripts must be placed before it in
the dependency ordering.
For example,
if your script has a
.Dq Li REQUIRE
.Ql REQUIRE
on
.Dq Li named ,
.Ql sshd ,
it means the script must be placed after the
.Dq Li named
.Ql sshd
script in the dependency ordering,
not necessarily that it requires
.Xr named 8
.Nm sshd
to be started or enabled.

+ 9
- 2
share/man/man4/acpi_ibm.4 View File

@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd June 19, 2015
.Dd June 19, 2020
.Dt ACPI_IBM 4
.Os
.Sh NAME
@@ -292,7 +292,12 @@ fan control might overheat the ThinkPad and lead to permanent damage if the
is not set accordingly.
.It Va dev.acpi_ibm.0.fan_level
Indicates at what speed the fan should run when being in manual mode.
Values are ranging from 0 (off) to 7 (max).
Valid values range from 0 (off) to 7 (max) and 8.
Level 8 is used by the driver to set the fan in disengaged mode.
In this mode, the fan is set to spin freely and will quickly reach a very
high speed.
Use this mode only if absolutely necessary, e.g., if the system has reached its
critical temperature and it is about to shut down.
The resulting speed differs from model to model.
On a T41p this is as follows:
.Pp
@@ -305,6 +310,8 @@ off
~3600 RPM
.It Li 6, 7
~4300 RPM
.It Li 8
~6400 RPM (Full-speed, disengaged)
.El
.It Va dev.acpi_ibm.0.fan_speed
(read-only)


+ 19
- 6
sys/dev/acpi_support/acpi_ibm.c View File

@@ -2,6 +2,7 @@
* Copyright (c) 2004 Takanori Watanabe
* Copyright (c) 2005 Markus Brueffer <markus@FreeBSD.org>
* All rights reserved.
* Copyright (c) 2020 Ali Abdallah <ali.abdallah@suse.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -263,7 +264,8 @@ static struct {
{
.name = "fan_level",
.method = ACPI_IBM_METHOD_FANLEVEL,
.description = "Fan level",
.description = "Fan level, 0-7 (recommended max), "
"8 (disengaged, full-speed)",
},
{
.name = "fan",
@@ -829,7 +831,10 @@ acpi_ibm_sysctl_get(struct acpi_ibm_softc *sc, int method)
*/
if (!sc->fan_handle) {
ACPI_EC_READ(sc->ec_dev, IBM_EC_FANSTATUS, &val_ec, 1);
val = val_ec & IBM_EC_MASK_FANLEVEL;
if (val_ec & IBM_EC_MASK_FANDISENGAGED)
val = 8;
else
val = val_ec & IBM_EC_MASK_FANLEVEL;
}
break;

@@ -912,15 +917,23 @@ acpi_ibm_sysctl_set(struct acpi_ibm_softc *sc, int method, int arg)
break;

case ACPI_IBM_METHOD_FANLEVEL:
if (arg < 0 || arg > 7)
if (arg < 0 || arg > 8)
return (EINVAL);

if (!sc->fan_handle) {
/* Read the current fanstatus */
/* Read the current fan status. */
ACPI_EC_READ(sc->ec_dev, IBM_EC_FANSTATUS, &val_ec, 1);
val = val_ec & (~IBM_EC_MASK_FANLEVEL);
val = val_ec & ~(IBM_EC_MASK_FANLEVEL |
IBM_EC_MASK_FANDISENGAGED);

if (arg == 8)
/* Full speed, set the disengaged bit. */
val |= 7 | IBM_EC_MASK_FANDISENGAGED;
else
val |= arg;

return ACPI_EC_WRITE(sc->ec_dev, IBM_EC_FANSTATUS, val | arg, 1);
return (ACPI_EC_WRITE(sc->ec_dev, IBM_EC_FANSTATUS, val,
1));
}
break;



+ 2
- 2
sys/dev/gpio/gpiobus.c View File

@@ -421,13 +421,13 @@ gpiobus_release_pin(device_t bus, uint32_t pin)
/* Consistency check. */
if (pin >= sc->sc_npins) {
device_printf(bus,
"gpiobus_acquire_pin: invalid pin %d, max=%d\n",
"invalid pin %d, max=%d\n",
pin, sc->sc_npins - 1);
return (-1);
}

if (!sc->sc_pins[pin].mapped) {
device_printf(bus, "gpiobus_acquire_pin: pin %d is not mapped\n", pin);
device_printf(bus, "pin %d is not mapped\n", pin);
return (-1);
}
sc->sc_pins[pin].mapped = 0;


+ 54
- 28
sys/dev/pci/pci_host_generic.c View File

@@ -324,13 +324,11 @@ pci_host_generic_core_release_resource(device_t dev, device_t child, int type,
return (bus_generic_release_resource(dev, child, type, rid, res));
}

struct resource *
pci_host_generic_core_alloc_resource(device_t dev, device_t child, int type,
int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
static bool
generic_pcie_translate_resource(device_t dev, int type, rman_res_t start,
rman_res_t end, rman_res_t *new_start, rman_res_t *new_end)
{
struct generic_pcie_core_softc *sc;
struct resource *res;
struct rman *rm;
uint64_t phys_base;
uint64_t pci_base;
uint64_t size;
@@ -338,19 +336,6 @@ pci_host_generic_core_alloc_resource(device_t dev, device_t child, int type,
bool found;

sc = device_get_softc(dev);

#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
if (type == PCI_RES_BUS) {
return (pci_domain_alloc_bus(sc->ecam, child, rid, start, end,
count, flags));
}
#endif

rm = generic_pcie_rman(sc, type, flags);
if (rm == NULL)
return (BUS_ALLOC_RESOURCE(device_get_parent(dev), child,
type, rid, start, end, count, flags));

/* Translate the address from a PCI address to a physical address */
switch (type) {
case SYS_RES_IOPORT:
@@ -378,25 +363,57 @@ pci_host_generic_core_alloc_resource(device_t dev, device_t child, int type,
}

if (type == space) {
start = start - pci_base + phys_base;
end = end - pci_base + phys_base;
*new_start = start - pci_base + phys_base;
*new_end = end - pci_base + phys_base;
found = true;
break;
}
}
if (!found) {
device_printf(dev,
"Failed to allocate %s resource %jx-%jx for %s\n",
type == SYS_RES_IOPORT ? "IOPORT" : "MEMORY",
(uintmax_t)start, (uintmax_t)end,
device_get_nameunit(child));
return (NULL);
}
break;
default:
/* No translation for non-memory types */
*new_start = start;
*new_end = end;
found = true;
break;
}

return (found);
}

struct resource *
pci_host_generic_core_alloc_resource(device_t dev, device_t child, int type,
int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
{
struct generic_pcie_core_softc *sc;
struct resource *res;
struct rman *rm;
rman_res_t phys_start, phys_end;

sc = device_get_softc(dev);

#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
if (type == PCI_RES_BUS) {
return (pci_domain_alloc_bus(sc->ecam, child, rid, start, end,
count, flags));
}
#endif

rm = generic_pcie_rman(sc, type, flags);
if (rm == NULL)
return (BUS_ALLOC_RESOURCE(device_get_parent(dev), child,
type, rid, start, end, count, flags));

/* Translate the address from a PCI address to a physical address */
if (!generic_pcie_translate_resource(dev, type, start, end, &phys_start,
&phys_end)) {
device_printf(dev,
"Failed to translate resource %jx-%jx type %x for %s\n",
(uintmax_t)start, (uintmax_t)end, type,
device_get_nameunit(child));
return (NULL);
}

if (bootverbose) {
device_printf(dev,
"rman_reserve_resource: start=%#jx, end=%#jx, count=%#jx\n",
@@ -430,6 +447,7 @@ generic_pcie_activate_resource(device_t dev, device_t child, int type,
int rid, struct resource *r)
{
struct generic_pcie_core_softc *sc;
rman_res_t start, end;
int res;

sc = device_get_softc(dev);
@@ -437,6 +455,14 @@ generic_pcie_activate_resource(device_t dev, device_t child, int type,
if ((res = rman_activate_resource(r)) != 0)
return (res);

start = rman_get_start(r);
end = rman_get_end(r);
if (!generic_pcie_translate_resource(dev, type, start, end, &start,
&end))
return (EINVAL);
rman_set_start(r, start);
rman_set_end(r, end);

return (BUS_ACTIVATE_RESOURCE(device_get_parent(dev), child, type,
rid, r));
}


+ 4
- 4
sys/netinet/sctp_crc32.c View File

@@ -44,9 +44,8 @@ __FBSDID("$FreeBSD$");

#include <netinet/sctp.h>
#include <netinet/sctp_crc32.h>
#ifdef SCTP
#if defined(SCTP) || defined(SCTP_SUPPORT)
#include <netinet/sctp_os.h>
#include <netinet/sctp_crc32.h>
#include <netinet/sctp_pcb.h>
#endif

@@ -117,6 +116,9 @@ sctp_calculate_cksum(struct mbuf *m, uint32_t offset)
}

#if defined(SCTP) || defined(SCTP_SUPPORT)

VNET_DEFINE(struct sctp_base_info, system_base_info);

/*
* Compute and insert the SCTP checksum in network byte order for a given
* mbuf chain m which contains an SCTP packet starting at offset.
@@ -127,10 +129,8 @@ sctp_delayed_cksum(struct mbuf *m, uint32_t offset)
uint32_t checksum;

checksum = sctp_calculate_cksum(m, offset);
#ifdef SCTP
SCTP_STAT_DECR(sctps_sendhwcrc);
SCTP_STAT_INCR(sctps_sendswcrc);
#endif
offset += offsetof(struct sctphdr, checksum);

if (offset + sizeof(uint32_t) > (uint32_t)(m->m_pkthdr.len)) {


+ 0
- 2
sys/netinet/sctp_pcb.c View File

@@ -57,8 +57,6 @@ __FBSDID("$FreeBSD$");
#include <sys/smp.h>
#include <sys/unistd.h>

VNET_DEFINE(struct sctp_base_info, system_base_info);

/* FIX: we don't handle multiple link local scopes */
/* "scopeless" replacement IN6_ARE_ADDR_EQUAL */
#ifdef INET6


Loading…
Cancel
Save