From: Eric Dumazet <eric.dumazet@gmail.com>
To: David Miller <davem@davemloft.net>
Cc: ja@ssi.bg, netdev@vger.kernel.org
Subject: Re: [PATCH] ipv4: Create and use fib_compute_spec_dst() helper.
Date: Thu, 05 Jul 2012 09:52:25 +0200 [thread overview]
Message-ID: <1341474745.2583.3325.camel@edumazet-glaptop> (raw)
In-Reply-To: <20120704.161335.1503971699878518173.davem@davemloft.net>
On Wed, 2012-07-04 at 16:13 -0700, David Miller wrote:
> ====================
> ipv4: Fix crashes in ip_options_compile().
>
> The spec_dst uses should be guarded by skb_rtable() being non-NULL
> not just the SKB being non-null.
>
> Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> ---
Seems good to me thanks.
By the way, maybe we can defer fib_compute_spec_dst() call to the point
we really need it ?
[PATCH] ipv4: defer fib_compute_spec_dst() call
ip_options_compile() can avoid calling fib_compute_spec_dst()
by default, and perform the call if needed.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c
index 1f02251..54ab83f 100644
--- a/net/ipv4/ip_options.c
+++ b/net/ipv4/ip_options.c
@@ -260,8 +260,6 @@ int ip_options_compile(struct net *net,
if (skb != NULL) {
rt = skb_rtable(skb);
- if (rt)
- spec_dst = fib_compute_spec_dst(skb);
optptr = (unsigned char *)&(ip_hdr(skb)[1]);
} else
optptr = opt->__data;
@@ -334,6 +332,7 @@ int ip_options_compile(struct net *net,
goto error;
}
if (rt) {
+ spec_dst = fib_compute_spec_dst(skb);
memcpy(&optptr[optptr[2]-1], &spec_dst, 4);
opt->is_changed = 1;
}
@@ -376,6 +375,7 @@ int ip_options_compile(struct net *net,
}
opt->ts = optptr - iph;
if (rt) {
+ spec_dst = fib_compute_spec_dst(skb);
memcpy(&optptr[optptr[2]-1], &spec_dst, 4);
timeptr = &optptr[optptr[2]+3];
}
next prev parent reply other threads:[~2012-07-05 7:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-28 10:59 [PATCH] ipv4: Create and use fib_compute_spec_dst() helper David Miller
2012-06-28 23:16 ` Julian Anastasov
2012-06-28 23:27 ` David Miller
2012-06-29 1:45 ` David Miller
2012-06-30 9:25 ` Julian Anastasov
2012-07-04 15:21 ` Eric Dumazet
2012-07-04 23:13 ` David Miller
2012-07-05 7:52 ` Eric Dumazet [this message]
2012-07-05 7:59 ` David Miller
2012-07-05 8:10 ` Eric Dumazet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1341474745.2583.3325.camel@edumazet-glaptop \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=ja@ssi.bg \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox