summaryrefslogtreecommitdiffstats
path: root/sys/netpfil
diff options
context:
space:
mode:
authorkp <kp@FreeBSD.org>2016-03-03 07:16:35 +0000
committerkp <kp@FreeBSD.org>2016-03-03 07:16:35 +0000
commit2667c3d5fbaef4a37daa33b9e899e7bd2070cf31 (patch)
tree993486756a17a71cc48b355cf2c837af7e10ecfb /sys/netpfil
parent73af9669cdc04af0c06344ce6f0d85808187eab3 (diff)
downloadFreeBSD-src-2667c3d5fbaef4a37daa33b9e899e7bd2070cf31.zip
FreeBSD-src-2667c3d5fbaef4a37daa33b9e899e7bd2070cf31.tar.gz
MFC: r296025:
pf: Fix possible out-of-bounds write In the DIOCRSETADDRS ioctl() handler we allocate a table for struct pfr_addrs, which is processed in pfr_set_addrs(). At the users request we also provide feedback on the deleted addresses, by storing them after the new list ('bcopy(&ad, addr + size + i, sizeof(ad));' in pfr_set_addrs()). This means we write outside the bounds of the buffer we've just allocated. We need to look at pfrio_size2 instead (i.e. the size the user reserved for our feedback). That'd allow a malicious user to specify a smaller pfrio_size2 than pfrio_size though, in which case we'd still read outside of the allocated buffer. Instead we allocate the largest of the two values. Reported By: Paul J Murphy <paul@inetstat.net> PR: 207463 Approved by: re (marius)
Diffstat (limited to 'sys/netpfil')
-rw-r--r--sys/netpfil/pf/pf_ioctl.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c
index 29ebb68..e90a8fa 100644
--- a/sys/netpfil/pf/pf_ioctl.c
+++ b/sys/netpfil/pf/pf_ioctl.c
@@ -2714,13 +2714,14 @@ DIOCCHANGEADDR_error:
case DIOCRSETADDRS: {
struct pfioc_table *io = (struct pfioc_table *)addr;
struct pfr_addr *pfras;
- size_t totlen;
+ size_t totlen, count;
if (io->pfrio_esize != sizeof(struct pfr_addr)) {
error = ENODEV;
break;
}
- totlen = io->pfrio_size * sizeof(struct pfr_addr);
+ count = max(io->pfrio_size, io->pfrio_size2);
+ totlen = count * sizeof(struct pfr_addr);
pfras = malloc(totlen, M_TEMP, M_WAITOK);
error = copyin(io->pfrio_buffer, pfras, totlen);
if (error) {
OpenPOWER on IntegriCloud