Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 27 Jan 2018 09:39:54 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-pf@FreeBSD.org
Subject:   [Bug 209475] pf didn't check if enough free RAM for net.pf.states_hashsize
Message-ID:  <bug-209475-17777-puFZ3MMMFi@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-209475-17777@https.bugs.freebsd.org/bugzilla/>
References:  <bug-209475-17777@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=209475

--- Comment #22 from fehmi noyan isi <fnoyanisi@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.


Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-209475-17777-puFZ3MMMFi>