(not) Protecting of case IP_FW_GET.

Brian Fundakowski Feldman green at freebsd.org
Thu Oct 7 23:09:55 PDT 2004


On Wed, Aug 25, 2004 at 01:38:22PM +0200, Pawel Malachowski wrote:
> On Wed, Aug 25, 2004 at 01:19:11PM +0200, Maxime Henrion wrote:
> 
> > > Another thing, in HEAD, there are three mallocs with M_WAITOK flag, only
> > > one of them checks if malloc succeed (lookup tables code) and returns
> > > ENOMEM, if not. Another two are assuming malloc will always succeed.
> > > In RELENG_4, result is checked and ENOBUFS (why not ENOMEM?) is returned
> > > if malloc failed.
> > 
> > The case where it checks the return value of malloc() is wrong.  When
> > called with the M_WAITOK flag, malloc() is not supposed to return NULL.
> 
> malloc(9) states that. What would happen, if one tries to malloc more
> memory than we physically have, with M_WAITOK flag -- will it eat all
> available memory and wait forever for more?

No, it would crash the kernel.  You are only supposed to make "reasonable"
request for memory.

-- 
Brian Fundakowski Feldman                           \'[ FreeBSD ]''''''''''\
  <> green at FreeBSD.org                               \  The Power to Serve! \
 Opinions expressed are my own.                       \,,,,,,,,,,,,,,,,,,,,,,\


More information about the freebsd-ipfw mailing list