[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20101109205716.GB9990@hmsreliant.think-freely.org>
Date: Tue, 9 Nov 2010 15:57:16 -0500
From: Neil Horman <nhorman@...driver.com>
To: Eric Dumazet <eric.dumazet@...il.com>
Cc: netdev@...r.kernel.org, davem@...emloft.net, zenczykowski@...il.com
Subject: Re: [PATCH] Enhance AF_PACKET implementation to not require high
order contiguous memory allocation (v2)
On Tue, Nov 09, 2010 at 08:20:38PM +0100, Eric Dumazet wrote:
> Le mardi 09 novembre 2010 à 13:38 -0500, Neil Horman a écrit :
> > On Tue, Nov 09, 2010 at 07:02:32PM +0100, Eric Dumazet wrote:
> > > Le mardi 09 novembre 2010 à 12:46 -0500, nhorman@...driver.com a écrit :
> > ic char **alloc_pg_vec(struct tpacket_req *req, int order)
> > > > +static struct pgv *alloc_pg_vec(struct tpacket_req *req, int order)
> > > > {
> > > > unsigned int block_nr = req->tp_block_nr;
> > > > - char **pg_vec;
> > > > + struct pgv *pg_vec;
> > > > int i;
> > > >
> > > > - pg_vec = kzalloc(block_nr * sizeof(char *), GFP_KERNEL);
> > > > + pg_vec = kzalloc(block_nr * sizeof(struct pgv), GFP_KERNEL);
> > >
> > > While we are at it, we could check block_nr being a sane value here ;)
> > >
> > This is true. What do you think a reasonable sane value is? libpcap seems to
> > limit itself to 32 order 5 entries in the ring, but that seems a bit arbitrary.
> > Perhaps we could check and limit allocations to being no more than order 8
> > (1Mb), and a total allocation of no more than perhaps max(32Mb, 1% of all ram)?
> > Just throwing it out there, open to any suggestions here
>
> I was refering to a malicious/buggy program giving a big tp_block_nr so
> that (block_nr * sizeof(struct pgv)) overflows the u32
>
> One way to deal with that is to use
>
> kcalloc(block_nr, sizeof(struct pgv), GFP_KERNEL);
>
> I am not sure consistency checks done in packet_set_ring() are enough to
> properly detect such errors.
Ah, I get you, ok. Yeah, I'll respin this with that taken into account.
Thanks!
Neil
>
>
>
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists