Skip to content

Commit

Permalink
Allow sysctl hw.machine/hw.machine_arch in capability mode
Browse files Browse the repository at this point in the history
There's no harm in reading strings like 'amd64'.

Reviewed by: emaste, manu
Sponsored by: https://www.patreon.com/valpackett
Differential Revision: https://reviews.freebsd.org/D28703
  • Loading branch information
valpackett authored and emaste committed Feb 6, 2023
1 parent 61593cb commit 4a1c4de
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion sys/arm/arm/identcpu-v6.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$");

char machine[] = "arm";

SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD,
SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD | CTLFLAG_CAPRD,
machine, 0, "Machine class");

static char cpu_model[64];
Expand Down
3 changes: 2 additions & 1 deletion sys/arm64/arm64/identcpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ sysctl_hw_machine(SYSCTL_HANDLER_ARGS)
}

SYSCTL_PROC(_hw, HW_MACHINE, machine, CTLTYPE_STRING | CTLFLAG_RD |
CTLFLAG_MPSAFE, NULL, 0, sysctl_hw_machine, "A", "Machine class");
CTLFLAG_CAPRD | CTLFLAG_MPSAFE, NULL, 0, sysctl_hw_machine, "A",
"Machine class");

static char cpu_model[64];
SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD,
Expand Down
2 changes: 1 addition & 1 deletion sys/kern/kern_mib.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ sysctl_hw_machine_arch(SYSCTL_HANDLER_ARGS)
return (SYSCTL_OUT(req, machine_arch, strlen(machine_arch) + 1));
}
SYSCTL_PROC(_hw, HW_MACHINE_ARCH, machine_arch, CTLTYPE_STRING | CTLFLAG_RD |
CTLFLAG_MPSAFE, NULL, 0, sysctl_hw_machine_arch, "A",
CTLFLAG_CAPRD | CTLFLAG_MPSAFE, NULL, 0, sysctl_hw_machine_arch, "A",
"System architecture");

#ifndef MACHINE_ARCHES
Expand Down
2 changes: 1 addition & 1 deletion sys/powerpc/powerpc/machdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ static char init_kenv[2048];
static struct trapframe frame0;

char machine[] = "powerpc";
SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, machine, 0, "");
SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD | CTLFLAG_CAPRD, machine, 0, "");

static void cpu_startup(void *);
SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL);
Expand Down
2 changes: 1 addition & 1 deletion sys/riscv/riscv/identcpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ __FBSDID("$FreeBSD$");

char machine[] = "riscv";

SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, machine, 0,
SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD | CTLFLAG_CAPRD, machine, 0,
"Machine class");

/* Hardware implementation info. These values may be empty. */
Expand Down
4 changes: 2 additions & 2 deletions sys/x86/x86/identcpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ sysctl_hw_machine(SYSCTL_HANDLER_ARGS)

}
SYSCTL_PROC(_hw, HW_MACHINE, machine, CTLTYPE_STRING | CTLFLAG_RD |
CTLFLAG_MPSAFE, NULL, 0, sysctl_hw_machine, "A", "Machine class");
CTLFLAG_CAPRD | CTLFLAG_MPSAFE, NULL, 0, sysctl_hw_machine, "A", "Machine class");
#else
SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD,
SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD | CTLFLAG_CAPRD,
machine, 0, "Machine class");
#endif

Expand Down

0 comments on commit 4a1c4de

Please sign in to comment.