Merge remote-tracking branch 'origin/hardened/current/master' into hardened/current/cross-dso-cfi

This commit is contained in:
HardenedBSD Sync Services 2024-11-27 12:01:35 -07:00
commit 2cdacf0ab0
No known key found for this signature in database
9 changed files with 78 additions and 47 deletions

View File

@ -706,30 +706,18 @@ apply_with(int (*db_func)(SCR *, recno_t, CHAR_T *, size_t), SCR *sp,
recno_t lno, u_char *p, size_t len)
{
#ifdef USE_WIDECHAR
typedef unsigned long nword;
static size_t blen;
static nword *bp;
nword *lp = (nword *)((uintptr_t)p / sizeof(nword) * sizeof(nword));
if (lp != (nword *)p) {
int offl = ((uintptr_t)p - (uintptr_t)lp) << 3;
int offr = (sizeof(nword) << 3) - offl;
size_t i, cnt = (len + sizeof(nword) / 2) / sizeof(nword);
static u_char *bp;
if (!is_aligned(p, sizeof(unsigned long))) {
if (len > blen) {
blen = p2roundup(MAX(len, 512));
REALLOC(sp, bp, nword *, blen);
REALLOC(sp, bp, u_char *, blen);
if (bp == NULL)
return (1);
}
for (i = 0; i < cnt; ++i)
#if BYTE_ORDER == BIG_ENDIAN
bp[i] = (lp[i] << offl) ^ (lp[i+1] >> offr);
#else
bp[i] = (lp[i] >> offl) ^ (lp[i+1] << offr);
#endif
p = (u_char *)bp;
memmove(bp, p, len);
p = bp;
}
#endif
return db_func(sp, lno, (CHAR_T *)p, len / sizeof(CHAR_T));

View File

@ -212,6 +212,18 @@ p2roundup(size_t n)
return (n);
}
/*
* is_aligned --
* Determine whether the program can safely read an object with an
* alignment requirement from ptr.
*
* See also: https://clang.llvm.org/docs/LanguageExtensions.html#alignment-builtins
*/
static __inline int
is_aligned(void *ptr, size_t alignment) {
return ((uintptr_t)ptr % alignment) == 0;
}
/* Additional TAILQ helper. */
#define TAILQ_ENTRY_ISVALID(elm, field) \
((elm)->field.tqe_prev != NULL)

View File

@ -545,6 +545,10 @@
..
auditpipe
..
cam
ctl
..
..
capsicum
..
cddl
@ -795,10 +799,6 @@
..
compat32
..
cam
ctl
..
..
devrandom
..
dtrace
@ -949,6 +949,8 @@
..
ses
..
sound
..
sys
..
vfs

View File

@ -24,7 +24,7 @@
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.Dd November 16, 2023
.Dd November 27, 2024
.Dt INTRO 3
.Os
.Sh NAME
@ -268,12 +268,8 @@ See
.Bl -tag -width /usr/lib/libm_p.a -compact
.It Pa /usr/lib/libc.a
the C library
.It Pa /usr/lib/libc_p.a
the C library compiled for profiling
.It Pa /usr/lib/libm.a
the math library
.It Pa /usr/lib/libm_p.a
the math library compiled for profiling
.El
.Sh LIBRARY TYPES
The system libraries are located in

View File

@ -77,6 +77,11 @@ static int broken_txfifo = 0;
SYSCTL_INT(_hw, OID_AUTO, broken_txfifo, CTLFLAG_RWTUN,
&broken_txfifo, 0, "UART FIFO has QEMU emulation bug");
static int uart_noise_threshold = 0;
SYSCTL_INT(_hw, OID_AUTO, uart_noise_threshold, CTLFLAG_RWTUN,
&uart_noise_threshold, 0,
"Number of UART RX interrupts where TX is not ready, before data is discarded");
/*
* To use early printf on x86, add the following to your kernel config:
*
@ -1012,6 +1017,7 @@ int
ns8250_bus_receive(struct uart_softc *sc)
{
struct uart_bas *bas;
struct ns8250_softc *ns8250 = (struct ns8250_softc *)sc;
int xc;
uint8_t lsr;
@ -1023,6 +1029,17 @@ ns8250_bus_receive(struct uart_softc *sc)
sc->sc_rxbuf[sc->sc_rxput] = UART_STAT_OVERRUN;
break;
}
/* Filter out possible noise on the line.
* Expect that the device should be able to transmit as well as
* receive, so if we receive too many characters before transmit
* is ready, it's probably noise.
*/
if ((lsr & (LSR_TXRDY | LSR_TEMT)) == 0 &&
uart_noise_threshold > 0) {
if (++ns8250->noise_count >= uart_noise_threshold)
break;
} else
ns8250->noise_count = 0;
xc = uart_getreg(bas, REG_DATA);
if (lsr & LSR_FE)
xc |= UART_STAT_FRAMERR;

View File

@ -41,6 +41,7 @@ struct ns8250_softc {
uint8_t ier_mask;
uint8_t ier_rxbits;
uint8_t busy_detect;
int noise_count;
};
extern struct uart_ops uart_ns8250_ops;

View File

@ -8090,7 +8090,7 @@ pf_route6(struct mbuf **m, struct pf_krule *r, struct ifnet *oifp,
dst.sin6_addr.s6_addr16[1] = htons(ifp->if_index);
mtag = m_tag_find(m0, PACKET_TAG_PF_REASSEMBLED, NULL);
if (mtag != NULL) {
int ret;
int ret __sdt_used;
ret = pf_refragment6(ifp, &m0, mtag, ifp, true);
SDT_PROBE2(pf, ip6, route_to, output, ifp, ret);
goto done;

View File

@ -29,14 +29,16 @@
* SUCH DAMAGE.
*/
#include <err.h>
#include <ctype.h>
#include <err.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <capsicum_helpers.h>
static void doalarm(u_int);
static void usage(void) __dead2;
@ -61,12 +63,17 @@ main(int argc, char **argv)
if (setlocale(LC_TIME, "") == NULL)
warn("setlocale");
caph_cache_tzdata();
caph_cache_catpages();
if (caph_limit_stdio() < 0 || caph_enter() < 0)
err(EXIT_FAILURE, "capsicum");
if (argc < 2) {
#define MSG1 "When do you have to leave? "
(void)write(STDOUT_FILENO, MSG1, sizeof(MSG1) - 1);
cp = fgets(buf, sizeof(buf), stdin);
if (cp == NULL || *cp == '\n')
exit(0);
exit(EXIT_SUCCESS);
} else if (argc > 2)
usage();
else
@ -108,7 +115,7 @@ main(int argc, char **argv)
t_12_hour = t->tm_hour;
if (hours < t_12_hour ||
(hours == t_12_hour && minutes <= t->tm_min))
(hours == t_12_hour && minutes <= t->tm_min))
/* Leave time is in the past so we add 12 hrs */
hours += 12;
@ -117,7 +124,7 @@ main(int argc, char **argv)
secs -= now % 60; /* truncate (now + secs) to min */
}
doalarm(secs);
exit(0);
exit(EXIT_SUCCESS);
}
void
@ -133,7 +140,7 @@ doalarm(u_int secs)
daytime += secs;
strftime(tb, sizeof(tb), "%+", localtime(&daytime));
printf("Alarm set for %s. (pid %d)\n", tb, pid);
exit(0);
exit(EXIT_SUCCESS);
}
sleep((u_int)2); /* let parent print set message */
if (secs >= 2)
@ -148,7 +155,7 @@ doalarm(u_int secs)
if (secs >= FIVEMIN) {
sleep(secs - FIVEMIN);
if (write(STDOUT_FILENO, MSG2, sizeof(MSG2) - 1) != sizeof(MSG2) - 1)
exit(0);
exit(EXIT_SUCCESS);
secs = FIVEMIN;
}
@ -157,24 +164,24 @@ doalarm(u_int secs)
if (secs >= ONEMIN) {
sleep(secs - ONEMIN);
if (write(STDOUT_FILENO, MSG3, sizeof(MSG3) - 1) != sizeof(MSG3) - 1)
exit(0);
exit(EXIT_SUCCESS);
}
#define MSG4 "\07\07Time to leave!\n"
for (bother = 10; bother--;) {
sleep((u_int)ONEMIN);
if (write(STDOUT_FILENO, MSG4, sizeof(MSG4) - 1) != sizeof(MSG4) - 1)
exit(0);
exit(EXIT_SUCCESS);
}
#define MSG5 "\07\07That was the last time I'll tell you. Bye.\n"
(void)write(STDOUT_FILENO, MSG5, sizeof(MSG5) - 1);
exit(0);
exit(EXIT_SUCCESS);
}
static void
usage(void)
{
fprintf(stderr, "usage: leave [[+]hhmm]\n");
exit(1);
exit(EXIT_FAILURE);
}

View File

@ -28,16 +28,19 @@
*/
#include <sys/cdefs.h>
#include <sys/errno.h>
#include <err.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <err.h>
#include <locale.h>
#include <sys/errno.h>
#include <capsicum_helpers.h>
static void usage(void) __dead2;
int
int
main(int argc, char **argv)
{
char *cp;
@ -45,6 +48,11 @@ main(int argc, char **argv)
long errnum;
(void) setlocale(LC_MESSAGES, "");
caph_cache_catpages();
if (caph_limit_stdio() < 0 || caph_enter() < 0)
err(EXIT_FAILURE, "capsicum");
if (argc != 2)
usage();
@ -53,20 +61,20 @@ main(int argc, char **argv)
errnum = strtol(argv[1], &cp, 0);
if (errno != 0)
err(1, NULL);
err(EXIT_FAILURE, NULL);
if ((errstr = strerror(errnum)) == NULL)
err(1, NULL);
if ((errstr = strerror(errnum)) == NULL)
err(EXIT_FAILURE, NULL);
printf("%s\n", errstr);
exit(0);
exit(EXIT_SUCCESS);
}
static void
static void
usage(void)
{
fprintf(stderr, "usage: perror number\n");
exit(1);
exit(EXIT_FAILURE);
}