All of lore.kernel.org
 help / color / mirror / Atom feed
* What basic sanity checking on packet headers is done
@ 2006-09-29 16:20 Wayne Schroeder
  2006-09-29 16:50 ` Patrick McHardy
  0 siblings, 1 reply; 4+ messages in thread
From: Wayne Schroeder @ 2006-09-29 16:20 UTC (permalink / raw)
  To: netfilter-devel

I've written a new target module that uses the ip header fields of ihl
and tot_len for offsets into the packets.  How safe is the data in the
ip headers?  Is there sanity checking when the packet is received off
the wire... for instance -- is it safe to assume in the prerouting chain
of the mangle table that tot_len will not put me past the memory
allocated for the packet?  Same goes for ihl?

Wayne

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: What basic sanity checking on packet headers is done
  2006-09-29 16:20 What basic sanity checking on packet headers is done Wayne Schroeder
@ 2006-09-29 16:50 ` Patrick McHardy
  2006-09-29 16:59   ` Wayne Schroeder
  0 siblings, 1 reply; 4+ messages in thread
From: Patrick McHardy @ 2006-09-29 16:50 UTC (permalink / raw)
  To: Wayne Schroeder; +Cc: netfilter-devel

Wayne Schroeder wrote:
> I've written a new target module that uses the ip header fields of ihl
> and tot_len for offsets into the packets.  How safe is the data in the
> ip headers?  Is there sanity checking when the packet is received off
> the wire... for instance -- is it safe to assume in the prerouting chain
> of the mangle table that tot_len will not put me past the memory
> allocated for the packet?  Same goes for ihl?

Check out ip_rcv() in ip_input.c. ihl and tot_len are _usually_ valid
within netfilter. The only exception is raw sockets, on the outgoing
hooks the only guarantee is that ihl * 4 >= sizeof(struct iphdr) (
only for ip_tables, see iptable_filter.c). We could consider providing
stricter guarantees, I'm pretty sure some modules only perform
insufficient checks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: What basic sanity checking on packet headers is done
  2006-09-29 16:50 ` Patrick McHardy
@ 2006-09-29 16:59   ` Wayne Schroeder
  2006-09-29 17:14     ` Patrick McHardy
  0 siblings, 1 reply; 4+ messages in thread
From: Wayne Schroeder @ 2006-09-29 16:59 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: netfilter-devel

Sounds like somone as root on the local machine could make packets that
would pop the kernel if the conditions were right, but everything else,
specifically remote traffic, will be safe to trust ihl and tot_len on?
If that's the case, then I'm in the clear.

Wayne


Patrick McHardy wrote:
> Wayne Schroeder wrote:
> 
>>I've written a new target module that uses the ip header fields of ihl
>>and tot_len for offsets into the packets.  How safe is the data in the
>>ip headers?  Is there sanity checking when the packet is received off
>>the wire... for instance -- is it safe to assume in the prerouting chain
>>of the mangle table that tot_len will not put me past the memory
>>allocated for the packet?  Same goes for ihl?
> 
> 
> Check out ip_rcv() in ip_input.c. ihl and tot_len are _usually_ valid
> within netfilter. The only exception is raw sockets, on the outgoing
> hooks the only guarantee is that ihl * 4 >= sizeof(struct iphdr) (
> only for ip_tables, see iptable_filter.c). We could consider providing
> stricter guarantees, I'm pretty sure some modules only perform
> insufficient checks.
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: What basic sanity checking on packet headers is done
  2006-09-29 16:59   ` Wayne Schroeder
@ 2006-09-29 17:14     ` Patrick McHardy
  0 siblings, 0 replies; 4+ messages in thread
From: Patrick McHardy @ 2006-09-29 17:14 UTC (permalink / raw)
  To: Wayne Schroeder; +Cc: netfilter-devel

Wayne Schroeder wrote:
> Sounds like somone as root on the local machine could make packets that
> would pop the kernel if the conditions were right, but everything else,
> specifically remote traffic, will be safe to trust ihl and tot_len on?
> If that's the case, then I'm in the clear.

Right. I didn't find any problematic cases by doing a quick grep,
but I guess its worth going over everything to make sure.
With things like OpenVZ even "root might crash the machine" is
a problem.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-09-29 17:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-29 16:20 What basic sanity checking on packet headers is done Wayne Schroeder
2006-09-29 16:50 ` Patrick McHardy
2006-09-29 16:59   ` Wayne Schroeder
2006-09-29 17:14     ` Patrick McHardy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.