bpf: Make dead_bpf_if const

The dead_bpf_if is not subjected to be written. Make it const so that
on destructive writing to it the kernel will panic instead of silent
memory corruption.

No functional change intended.

Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D42189

(cherry picked from commit 7a974a6498)
This commit is contained in:
Zhenlei Huang 2023-10-21 12:52:27 +08:00
parent e968616046
commit 5d031613af

View file

@ -100,7 +100,7 @@
MALLOC_DEFINE(M_BPF, "BPF", "BPF data");
static struct bpf_if_ext dead_bpf_if = {
static const struct bpf_if_ext dead_bpf_if = {
.bif_dlist = CK_LIST_HEAD_INITIALIZER()
};
@ -2859,7 +2859,7 @@ bpfdetach(struct ifnet *ifp)
continue;
CK_LIST_REMOVE(bp, bif_next);
*bp->bif_bpf = (struct bpf_if *)&dead_bpf_if;
*bp->bif_bpf = __DECONST(struct bpf_if *, &dead_bpf_if);
CTR4(KTR_NET,
"%s: sheduling free for encap %d (%p) for if %p",
@ -3154,7 +3154,7 @@ void
bpfattach2(struct ifnet *ifp, u_int dlt, u_int hdrlen, struct bpf_if **driverp)
{
*driverp = (struct bpf_if *)&dead_bpf_if;
*driverp = __DECONST(struct bpf_if *, &dead_bpf_if);
}
void