aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristof Provost <kp@FreeBSD.org>2021-05-16 06:50:17 +0000
committerKristof Provost <kp@FreeBSD.org>2021-05-24 15:40:28 +0000
commitb34127064fde4d144b6d63dce0eada01563bc562 (patch)
tree33de0e8f631e05849bc2379a3fb6c358eb2561e4
parentef46ce0e29ac89daabe3e65efacd57eff02172c1 (diff)
downloadsrc-b34127064fde4d144b6d63dce0eada01563bc562.tar.gz
src-b34127064fde4d144b6d63dce0eada01563bc562.zip
pf: Set the pfik_group for userspace
Userspace relies on this pointer to work out if the kif is a group or not. It can't use it for anything else, because it's a pointer to a kernel address. Substitute 0xfeedc0de for 'true', so that we don't leak kernel memory addresses to userspace. PR: 255852 Reviewed by: donner MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30284 (cherry picked from commit d69cc040147284c414dfd1c9f498dcc7c8291a8b)
-rw-r--r--sys/netpfil/pf/pf_if.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/netpfil/pf/pf_if.c b/sys/netpfil/pf/pf_if.c
index 656cdfab6018..9c10be3b3b77 100644
--- a/sys/netpfil/pf/pf_if.c
+++ b/sys/netpfil/pf/pf_if.c
@@ -817,6 +817,14 @@ pf_kkif_to_kif(const struct pfi_kkif *kkif, struct pfi_kif *kif)
kif->pfik_flags = kkif->pfik_flags;
kif->pfik_tzero = kkif->pfik_tzero;
kif->pfik_rulerefs = kkif->pfik_rulerefs;
+ /*
+ * Userspace relies on this pointer to decide if this is a group or
+ * not. We don't want to share the actual pointer, because it's
+ * useless to userspace and leaks kernel memory layout information.
+ * So instead we provide 0xfeedcode as 'true' and NULL as 'false'.
+ */
+ kif->pfik_group =
+ kkif->pfik_group ? (struct ifg_group *)0xfeedc0de : NULL;
}
void