Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1614724
| From | Eric Dumazet <eric.dumazet@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: KASAN, xt_TCPMSS finally found nasty use-after-free bug? 4.10.8 |
| Date | 2017-04-02 14:30 +0200 |
| Message-ID | <trMNP-mF-1@gated-at.bofh.it> (permalink) |
| References | <trIqS-5Yh-7@gated-at.bofh.it> <trLRL-8ck-9@gated-at.bofh.it> <trMb7-8kH-19@gated-at.bofh.it> <trMkN-8nM-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Sun, 2017-04-02 at 04:54 -0700, Eric Dumazet wrote:
> On Sun, 2017-04-02 at 13:45 +0200, Florian Westphal wrote:
> > Eric Dumazet <eric.dumazet@gmail.com> wrote:
> > > - for (i = sizeof(struct tcphdr); i <= tcp_hdrlen - TCPOLEN_MSS; i += optlen(opt, i)) {
> > > + for (i = sizeof(struct tcphdr); i < tcp_hdrlen - TCPOLEN_MSS; i += optlen(opt, i)) {
> > > if (opt[i] == TCPOPT_MSS && opt[i+1] == TCPOLEN_MSS) {
> > > u_int16_t oldmss;
> >
> > maybe I am low on caffeeine but this looks fine, for tcp header with
> > only tcpmss this boils down to "20 <= 24 - 4" so we acccess offsets 20-23 which seems ok.
>
> I am definitely low on caffeine ;)
>
> An issue in this function is that we might add the missing MSS option,
> without checking that TCP options are already full.
>
> But this should not cause a KASAN splat, only some malformed TCP packet
>
> (tcph->doff would wrap)
Something like that maybe.
diff --git a/net/netfilter/xt_TCPMSS.c b/net/netfilter/xt_TCPMSS.c
index
27241a767f17b4b27d24095a31e5e9a2d3e29ce4..1465aaf0e3a15d69d105d0a50b0429b11b6439d3 100644
--- a/net/netfilter/xt_TCPMSS.c
+++ b/net/netfilter/xt_TCPMSS.c
@@ -151,7 +151,9 @@ tcpmss_mangle_packet(struct sk_buff *skb,
*/
if (len > tcp_hdrlen)
return 0;
-
+ /* tcph->doff is 4 bits wide, do not wrap its value to 0 */
+ if (tcp_hdrlen >= 15 * 4)
+ return 0;
/*
* MSS Option not found ?! add it..
*/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
KASAN, xt_TCPMSS finally found nasty use-after-free bug? 4.10.8 Denys Fedoryshchenko <nuclearcat@nuclearcat.com> - 2017-04-02 09:50 +0200
Re: KASAN, xt_TCPMSS finally found nasty use-after-free bug? 4.10.8 Eric Dumazet <eric.dumazet@gmail.com> - 2017-04-02 13:30 +0200
Re: KASAN, xt_TCPMSS finally found nasty use-after-free bug? 4.10.8 Florian Westphal <fw@strlen.de> - 2017-04-02 13:50 +0200
Re: KASAN, xt_TCPMSS finally found nasty use-after-free bug? 4.10.8 Denys Fedoryshchenko <nuclearcat@nuclearcat.com> - 2017-04-02 14:00 +0200
Re: KASAN, xt_TCPMSS finally found nasty use-after-free bug? 4.10.8 Eric Dumazet <eric.dumazet@gmail.com> - 2017-04-02 14:00 +0200
Re: KASAN, xt_TCPMSS finally found nasty use-after-free bug? 4.10.8 Eric Dumazet <eric.dumazet@gmail.com> - 2017-04-02 14:30 +0200
Re: KASAN, xt_TCPMSS finally found nasty use-after-free bug? 4.10.8 Denys Fedoryshchenko <nuclearcat@nuclearcat.com> - 2017-04-02 14:30 +0200
Re: KASAN, xt_TCPMSS finally found nasty use-after-free bug? 4.10.8 Eric Dumazet <eric.dumazet@gmail.com> - 2017-04-02 14:40 +0200
Re: KASAN, xt_TCPMSS finally found nasty use-after-free bug? 4.10.8 Denys Fedoryshchenko <nuclearcat@nuclearcat.com> - 2017-04-02 19:00 +0200
Re: KASAN, xt_TCPMSS finally found nasty use-after-free bug? 4.10.8 Eric Dumazet <eric.dumazet@gmail.com> - 2017-04-02 19:20 +0200
Re: KASAN, xt_TCPMSS finally found nasty use-after-free bug? 4.10.8 Eric Dumazet <eric.dumazet@gmail.com> - 2017-04-02 19:30 +0200
Re: KASAN, xt_TCPMSS finally found nasty use-after-free bug? 4.10.8 Denys Fedoryshchenko <nuclearcat@nuclearcat.com> - 2017-04-03 10:20 +0200
Re: KASAN, xt_TCPMSS finally found nasty use-after-free bug? 4.10.8 Eric Dumazet <eric.dumazet@gmail.com> - 2017-04-03 14:10 +0200
Re: KASAN, xt_TCPMSS finally found nasty use-after-free bug? 4.10.8 Denys Fedoryshchenko <nuclearcat@nuclearcat.com> - 2017-04-03 14:20 +0200
Re: KASAN, xt_TCPMSS finally found nasty use-after-free bug? 4.10.8 Eric Dumazet <eric.dumazet@gmail.com> - 2017-04-03 14:30 +0200
csiph-web