5.3-RELEASE TODO
Dag-Erling Smørgrav
des at des.no
Fri Sep 17 12:30:21 PDT 2004
Brooks Davis <brooks at one-eyed-alien.net> writes:
> On Fri, Sep 17, 2004 at 07:57:32PM +0200, Dag-Erling Smørgrav wrote:
> > struct sbuf *sb = sbuf_new(NULL, NULL, size, ifc->ifc_len + 1);
> What are you trying to do here? Unless my manpages are wrong, the
> fourth arg is flags. Do you mean to set SBUF_FIXEDLEN?
I meant
struct sbuf *sb = sbuf_new(NULL, NULL, ifc->ifc_len + 1, SBUF_FIXEDLEN);
but I'm typing over a slow link and Meta-D'ed the wrong word.
> I think you
> would have to to avoid a new LOR.
Of course.
> would have to to avoid a new LOR. Also, it is not safe to trust
> ifc->ifc_len for allocations because it is provided by potentially
> unpriveleged users.
so just make sure before you call sbuf_new() that ifc_len is
reasonable (e.g. < MAXPHYS)
> Thus, so you have to know how much space you will
> need before doing any kind of allocation, hence the double loop and the
> potential race.
Using sbufs removes the need for loop and greatly simplifies how you
deal with overflows.
DES
--
Dag-Erling Smørgrav - des at des.no
More information about the freebsd-current
mailing list