Skip to content

Commit

Permalink
pf: Do not allow negative ps_len in DIOCGETSTATES
Browse files Browse the repository at this point in the history
Userspace may pass a negative ps_len value to us, which causes an
assertion failure in malloc().
Treat negative values as zero, i.e. return the required size.

Reported-by:	syzbot+53370d9d0358ee2a059a@syzkaller.appspotmail.com
Reviewed by:	lutz at donnerhacke.de
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D24447
  • Loading branch information
kprovost committed Apr 17, 2020
1 parent 70066b9 commit 9319f3c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sys/netpfil/pf/pf_ioctl.c
Expand Up @@ -2163,7 +2163,7 @@ pfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td
struct pfsync_state *pstore, *p;
int i, nr;

if (ps->ps_len == 0) {
if (ps->ps_len <= 0) {
nr = uma_zone_get_cur(V_pf_state_z);
ps->ps_len = sizeof(struct pfsync_state) * nr;
break;
Expand Down

0 comments on commit 9319f3c

Please sign in to comment.