* [PATCH] ip_queue and fragments
@ 2004-08-05 13:32 Pablo Neira
2004-08-05 14:16 ` Patrick McHardy
0 siblings, 1 reply; 4+ messages in thread
From: Pablo Neira @ 2004-08-05 13:32 UTC (permalink / raw)
To: Netfilter Development Mailinglist, Harald Welte, Patrick McHardy
[-- Attachment #1: Type: text/plain, Size: 121 bytes --]
Hi,
I've tracing ip_queue source code and I think that it's not fragment
aware. Am I missing anything?
regards,
Pablo
[-- Attachment #2: ip_queue_frags.patch --]
[-- Type: text/x-patch, Size: 537 bytes --]
diff -u -r1.1.1.1 ip_queue.c
--- a/net/ipv4/netfilter/ip_queue.c 11 May 2004 13:07:08 -0000 1.1.1.1
+++ b/net/ipv4/netfilter/ip_queue.c 4 Aug 2004 14:37:25 -0000
@@ -255,9 +255,10 @@
entry->skb->dev->hard_header_parse(entry->skb,
pmsg->hw_addr);
}
-
- if (data_len)
- memcpy(pmsg->payload, entry->skb->data, data_len);
+
+ if (data_len)
+ if (skb_copy_bits(entry->skb, 0, pmsg->payload, data_len) != 0)
+ goto nlmsg_failure;
nlh->nlmsg_len = skb->tail - old_tail;
return skb;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ip_queue and fragments
2004-08-05 13:32 [PATCH] ip_queue and fragments Pablo Neira
@ 2004-08-05 14:16 ` Patrick McHardy
2004-08-06 16:44 ` Pablo Neira
0 siblings, 1 reply; 4+ messages in thread
From: Patrick McHardy @ 2004-08-05 14:16 UTC (permalink / raw)
To: Pablo Neira; +Cc: Netfilter Development Mailinglist, Harald Welte
Pablo Neira wrote:
> Hi,
>
> I've tracing ip_queue source code and I think that it's not fragment
> aware. Am I missing anything?
This check prevents copying data outside of skb->data:
case IPQ_COPY_PACKET:
if (copy_range == 0 || copy_range > entry->skb->len)
data_len = entry->skb->len;
else
data_len = copy_range;
skb_copy_bits always stays inside limits if len is positive, so you can
do something like this:
if (copy_range == 0)
data_len = ~0UL;
else
data_len = copy_range;
but you have to remove the jump to nlmsg_failure when skb_copy_bits fails.
Regards
Patrick
>------------------------------------------------------------------------
>
>diff -u -r1.1.1.1 ip_queue.c
>--- a/net/ipv4/netfilter/ip_queue.c 11 May 2004 13:07:08 -0000 1.1.1.1
>+++ b/net/ipv4/netfilter/ip_queue.c 4 Aug 2004 14:37:25 -0000
>@@ -255,9 +255,10 @@
> entry->skb->dev->hard_header_parse(entry->skb,
> pmsg->hw_addr);
> }
>-
>- if (data_len)
>- memcpy(pmsg->payload, entry->skb->data, data_len);
>+
>+ if (data_len)
>+ if (skb_copy_bits(entry->skb, 0, pmsg->payload, data_len) != 0)
>+ goto nlmsg_failure;
>
> nlh->nlmsg_len = skb->tail - old_tail;
> return skb;
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ip_queue and fragments
2004-08-05 14:16 ` Patrick McHardy
@ 2004-08-06 16:44 ` Pablo Neira
2004-08-07 19:20 ` Patrick McHardy
0 siblings, 1 reply; 4+ messages in thread
From: Pablo Neira @ 2004-08-06 16:44 UTC (permalink / raw)
To: Patrick McHardy; +Cc: Harald Welte, Netfilter Development Mailinglist
[-- Attachment #1: Type: text/plain, Size: 376 bytes --]
Hi Patrick,
Patrick McHardy wrote:
> skb_copy_bits always stays inside limits if len is positive, so you can
> do something like this:
>
> if (copy_range == 0)
> data_len = ~0UL;
> else
> data_len = copy_range;
>
> but you have to remove the jump to nlmsg_failure when skb_copy_bits
> fails.
thanks for your suggestions, I've applied them to my patch.
regards,
Pablo
[-- Attachment #2: ip_queue-fragments.patch --]
[-- Type: text/x-patch, Size: 604 bytes --]
diff -u -r1.1.1.1 ip_queue.c
--- a/net/ipv4/netfilter/ip_queue.c 4 Aug 2004 15:14:39 -0000 1.1.1.1
+++ b/net/ipv4/netfilter/ip_queue.c 6 Aug 2004 16:38:11 -0000
@@ -205,8 +205,8 @@
break;
case IPQ_COPY_PACKET:
- if (copy_range == 0 || copy_range > entry->skb->len)
- data_len = entry->skb->len;
+ if (copy_range == 0)
+ data_len = ~0UL;
else
data_len = copy_range;
@@ -257,7 +257,7 @@
}
if (data_len)
- memcpy(pmsg->payload, entry->skb->data, data_len);
+ skb_copy_bits(entry->skb, 0, pmsg->payload, data_len);
nlh->nlmsg_len = skb->tail - old_tail;
return skb;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ip_queue and fragments
2004-08-06 16:44 ` Pablo Neira
@ 2004-08-07 19:20 ` Patrick McHardy
0 siblings, 0 replies; 4+ messages in thread
From: Patrick McHardy @ 2004-08-07 19:20 UTC (permalink / raw)
To: Pablo Neira; +Cc: Harald Welte, Netfilter Development Mailinglist
Pablo Neira wrote:
> thanks for your suggestions, I've applied them to my patch.
Actually your first patch was fine and my suggestion was stupid ;)
I'm going to put it in pom-ng later tonight.
Regards
Patrick
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-08-07 19:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-05 13:32 [PATCH] ip_queue and fragments Pablo Neira
2004-08-05 14:16 ` Patrick McHardy
2004-08-06 16:44 ` Pablo Neira
2004-08-07 19:20 ` 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.