Sync code with last security fixes and improvements from OpenBSD

This commit is contained in:
purplerain 2023-04-30 19:16:28 +00:00
parent 95114fbda2
commit f5f0d5c82b
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
106 changed files with 371 additions and 1162 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: efi_machdep.c,v 1.5 2023/01/14 12:11:10 kettenis Exp $ */
/* $OpenBSD: efi_machdep.c,v 1.6 2023/04/30 17:24:24 kettenis Exp $ */
/*
* Copyright (c) 2022 Mark Kettenis <kettenis@openbsd.org>
@ -40,8 +40,6 @@ const struct cfattach efi_ca = {
};
void efi_map_runtime(struct efi_softc *);
int efi_gettime(struct todr_chip_handle *, struct timeval *);
int efi_settime(struct todr_chip_handle *, struct timeval *);
label_t efi_jmpbuf;
@ -67,8 +65,6 @@ efi_attach(struct device *parent, struct device *self, void *aux)
uint64_t system_table;
bus_space_handle_t memh;
EFI_SYSTEM_TABLE *st;
EFI_TIME time;
EFI_STATUS status;
uint16_t major, minor;
int i;
@ -121,25 +117,6 @@ efi_attach(struct device *parent, struct device *self, void *aux)
printf(" rev 0x%x\n", st->FirmwareRevision);
}
efi_leave(sc);
if (efi_enter_check(sc))
return;
status = sc->sc_rs->GetTime(&time, NULL);
efi_leave(sc);
if (status != EFI_SUCCESS)
return;
/*
* EDK II implementations provide an implementation of
* GetTime() that returns a fixed compiled-in time on hardware
* without a (supported) RTC. So only use this interface as a
* last resort.
*/
sc->sc_todr.cookie = sc;
sc->sc_todr.todr_gettime = efi_gettime;
sc->sc_todr.todr_settime = efi_settime;
sc->sc_todr.todr_quality = -1000;
todr_attach(&sc->sc_todr);
}
void
@ -243,65 +220,3 @@ efi_leave(struct efi_softc *sc)
lcr3(sc->sc_cr3);
intr_restore(sc->sc_psw);
}
int
efi_gettime(struct todr_chip_handle *handle, struct timeval *tv)
{
struct efi_softc *sc = handle->cookie;
struct clock_ymdhms dt;
EFI_TIME time;
EFI_STATUS status;
if (efi_enter_check(sc))
return EFAULT;
status = sc->sc_rs->GetTime(&time, NULL);
efi_leave(sc);
if (status != EFI_SUCCESS)
return EIO;
dt.dt_year = time.Year;
dt.dt_mon = time.Month;
dt.dt_day = time.Day;
dt.dt_hour = time.Hour;
dt.dt_min = time.Minute;
dt.dt_sec = time.Second;
if (dt.dt_sec > 59 || dt.dt_min > 59 || dt.dt_hour > 23 ||
dt.dt_day > 31 || dt.dt_day == 0 ||
dt.dt_mon > 12 || dt.dt_mon == 0 ||
dt.dt_year < POSIX_BASE_YEAR)
return EINVAL;
tv->tv_sec = clock_ymdhms_to_secs(&dt);
tv->tv_usec = 0;
return 0;
}
int
efi_settime(struct todr_chip_handle *handle, struct timeval *tv)
{
struct efi_softc *sc = handle->cookie;
struct clock_ymdhms dt;
EFI_TIME time;
EFI_STATUS status;
clock_secs_to_ymdhms(tv->tv_sec, &dt);
time.Year = dt.dt_year;
time.Month = dt.dt_mon;
time.Day = dt.dt_day;
time.Hour = dt.dt_hour;
time.Minute = dt.dt_min;
time.Second = dt.dt_sec;
time.Nanosecond = 0;
time.TimeZone = 0;
time.Daylight = 0;
if (efi_enter_check(sc))
return EFAULT;
status = sc->sc_rs->SetTime(&time);
efi_leave(sc);
if (status != EFI_SUCCESS)
return EIO;
return 0;
}

View file

@ -994,7 +994,7 @@ END(intr_fast_exit)
* FPU/"extended CPU state" handling
* int xrstor_user(sfp, mask)
* load given state, returns 0/1 if okay/it trapped
* void fpusave(sfp)
* void fpusave(sfp)
* save current state, but retain it in the FPU
* void fpusavereset(sfp)
* save current state and reset FPU to initial/kernel state

View file

@ -360,7 +360,7 @@ data_abort_handler(trapframe_t *tf)
p->p_ucred ? (int)p->p_ucred->cr_uid : -1);
sd.signo = SIGKILL;
sd.code = 0;
} else if (error == EACCES)
} else if (error == EACCES)
sd.code = SEGV_ACCERR;
else if (error == EIO) {
sd.signo = SIGBUS;

View file

@ -711,7 +711,7 @@ pmap_free_l2_ptp(pt_entry_t *l2)
* bucket/page table in place.
*
* Note that if a new L2 bucket/page was allocated, the caller *must*
* increment the bucket occupancy counter appropriately *before*
* increment the bucket occupancy counter appropriately *before*
* releasing the pmap's lock to ensure no other thread or cpu deallocates
* the bucket/page in the meantime.
*/

View file

@ -846,7 +846,7 @@ apldchidev_wait(struct apldchidev_softc *sc)
}
return;
}
while (sc->sc_busy) {
error = tsleep_nsec(sc, PZERO, "apldcwt", SEC_TO_NSEC(1));
if (error == EWOULDBLOCK)

View file

@ -1,11 +1,11 @@
# $OpenBSD: Makefile,v 1.11 2023/04/28 08:45:26 krw Exp $
# $OpenBSD: Makefile,v 1.12 2023/04/30 22:28:27 krw Exp $
NOMAN=
#MAN= boot.8
RDBOOT= ${.CURDIR}/../rdboot/obj/rdboot
MRDISKTYPE= rdroot
MRDISKTYPE= rdboot
MRMAKEFSARGS= -o disklabel=${MRDISKTYPE},minfree=0,density=1024
.if ${MACHINE} == "octeon"

View file

@ -205,7 +205,8 @@ static const struct pci_matchid amdgpu_devices[] = {
/* GC 11.0.0, DCN 3.2.0, dGPU, Radeon RX 7900 XT/XTX "Navi 31" */
{0x1002, 0x744c },
/* GC 11.0.1, DCN 3.1.4, APU */
/* GC 11.0.1, DCN 3.1.4, APU, Ryzen 7040 "Phoenix" */
{0x1002, 0x15bf },
/* GC 11.0.2, DCN 3.2.1, dGPU, "Navi 33" */
{0x1002, 0x7480 },

View file

@ -1,4 +1,4 @@
$OpenBSD: pcidevs,v 1.2032 2023/04/25 21:57:29 kettenis Exp $
$OpenBSD: pcidevs,v 1.2033 2023/04/30 23:38:52 jsg Exp $
/* $NetBSD: pcidevs,v 1.30 1997/06/24 06:20:24 thorpej Exp $ */
/*
@ -1278,6 +1278,7 @@ product ATI CYAN_SKILLFISH_2 0x143f Cyan Skillfish
product ATI PPB_1 0x1478 PCIE
product ATI PPB_2 0x1479 PCIE
product ATI MENDOCINO 0x1506 Mendocino
product ATI PHOENIX 0x15bf Phoenix
product ATI PICASSO 0x15d8 Picasso
product ATI RAVEN_VEGA 0x15dd Radeon Vega
product ATI RAVEN_VEGA_HDA 0x15de Radeon Vega HD Audio

View file

@ -2,7 +2,7 @@
* THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.
*
* generated from:
* OpenBSD: pcidevs,v 1.2032 2023/04/25 21:57:29 kettenis Exp
* OpenBSD: pcidevs,v 1.2033 2023/04/30 23:38:52 jsg Exp
*/
/* $NetBSD: pcidevs,v 1.30 1997/06/24 06:20:24 thorpej Exp $ */
@ -1283,6 +1283,7 @@
#define PCI_PRODUCT_ATI_PPB_1 0x1478 /* PCIE */
#define PCI_PRODUCT_ATI_PPB_2 0x1479 /* PCIE */
#define PCI_PRODUCT_ATI_MENDOCINO 0x1506 /* Mendocino */
#define PCI_PRODUCT_ATI_PHOENIX 0x15bf /* Phoenix */
#define PCI_PRODUCT_ATI_PICASSO 0x15d8 /* Picasso */
#define PCI_PRODUCT_ATI_RAVEN_VEGA 0x15dd /* Radeon Vega */
#define PCI_PRODUCT_ATI_RAVEN_VEGA_HDA 0x15de /* Radeon Vega HD Audio */

View file

@ -2,7 +2,7 @@
* THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.
*
* generated from:
* OpenBSD: pcidevs,v 1.2032 2023/04/25 21:57:29 kettenis Exp
* OpenBSD: pcidevs,v 1.2033 2023/04/30 23:38:52 jsg Exp
*/
/* $NetBSD: pcidevs,v 1.30 1997/06/24 06:20:24 thorpej Exp $ */
@ -3259,6 +3259,10 @@ static const struct pci_known_product pci_known_products[] = {
PCI_VENDOR_ATI, PCI_PRODUCT_ATI_MENDOCINO,
"Mendocino",
},
{
PCI_VENDOR_ATI, PCI_PRODUCT_ATI_PHOENIX,
"Phoenix",
},
{
PCI_VENDOR_ATI, PCI_PRODUCT_ATI_PICASSO,
"Picasso",

View file

@ -1,4 +1,4 @@
/* $OpenBSD: msdosfs_fat.c,v 1.34 2021/03/11 13:31:35 jsg Exp $ */
/* $OpenBSD: msdosfs_fat.c,v 1.35 2023/04/30 17:16:36 sf Exp $ */
/* $NetBSD: msdosfs_fat.c,v 1.26 1997/10/17 11:24:02 ws Exp $ */
/*-
@ -409,6 +409,7 @@ updatefats(struct msdosfsmount *pmp, struct buf *bp, uint32_t fatbn)
static __inline void
usemap_alloc(struct msdosfsmount *pmp, uint32_t cn)
{
KASSERT(cn <= pmp->pm_maxcluster);
pmp->pm_inusemap[cn / N_INUSEBITS] |= 1 << (cn % N_INUSEBITS);
pmp->pm_freeclustercount--;
@ -417,6 +418,7 @@ usemap_alloc(struct msdosfsmount *pmp, uint32_t cn)
static __inline void
usemap_free(struct msdosfsmount *pmp, uint32_t cn)
{
KASSERT(cn <= pmp->pm_maxcluster);
pmp->pm_freeclustercount++;
pmp->pm_inusemap[cn / N_INUSEBITS] &= ~(1 << (cn % N_INUSEBITS));
@ -644,6 +646,8 @@ chainlength(struct msdosfsmount *pmp, uint32_t start, uint32_t count)
u_int map;
uint32_t len;
if (start > pmp->pm_maxcluster)
return (0);
max_idx = pmp->pm_maxcluster / N_INUSEBITS;
idx = start / N_INUSEBITS;
start %= N_INUSEBITS;
@ -651,11 +655,15 @@ chainlength(struct msdosfsmount *pmp, uint32_t start, uint32_t count)
map &= ~((1 << start) - 1);
if (map) {
len = ffs(map) - 1 - start;
return (len > count ? count : len);
len = MIN(len, count);
len = MIN(len, pmp->pm_maxcluster - start + 1);
return (len);
}
len = N_INUSEBITS - start;
if (len >= count)
return (count);
if (len >= count) {
len = MIN(count, pmp->pm_maxcluster - start + 1);
return (len);
}
while (++idx <= max_idx) {
if (len >= count)
break;
@ -665,7 +673,9 @@ chainlength(struct msdosfsmount *pmp, uint32_t start, uint32_t count)
}
len += N_INUSEBITS;
}
return (len > count ? count : len);
len = MIN(len, count);
len = MIN(len, pmp->pm_maxcluster - start + 1);
return (len);
}
/*