[Bug 209475] pf didn't check if enough free RAM for net.pf.states_hashsize
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Sat Jan 27 09:39:56 UTC 2018
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=209475
--- Comment #22 from fehmi noyan isi <fnoyanisi at yahoo.com> ---
Hi there. I patched pf_initialize() in head (r328383, which has mallocarray(9))
by implementing a fallback mallocarray(9) call (as discussed in the comments)
if ((V_pf_idhash = mallocarray(pf_hashsize, sizeof(pf_idhash), M_PFHASH,
M_WAITOK|M_ZERO)) == NULL) {
V_pf_idhash = mallocarray(PH_HASHSIZ, sizeof(pf_idhash), M_PFHASH,
M_NOWAIT|M_ZERO)
}
// and all other malloc(9) calls
Although, this change prevents the initialisation process against any overflow
issues, the fallback mallocarray(...,M_WAITOK) calls still block in case too
much memory is requested.
>> Memory allocation is very complicated and it's basically impossible to predict if there'd be enough free memory to satisfy a request without actually doing it. Moreover, it'd always be susceptible to races.
Based on Kristof's comment above, shall we assume this is as far as we can go?
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-pf
mailing list