Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1232139 > unrolled thread

Re: [PATCH] tcp: Use absolute system clock for TCP timestamps

Started byEric Dumazet <edumazet@google.com>
First post2015-09-24 16:50 +0200
Last post2015-09-24 17:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH] tcp: Use absolute system clock for TCP timestamps Eric Dumazet <edumazet@google.com> - 2015-09-24 16:50 +0200
    Re: [PATCH] tcp: Use absolute system clock for TCP timestamps Florian Westphal <fw@strlen.de> - 2015-09-24 17:40 +0200

#1232139 — Re: [PATCH] tcp: Use absolute system clock for TCP timestamps

FromEric Dumazet <edumazet@google.com>
Date2015-09-24 16:50 +0200
SubjectRe: [PATCH] tcp: Use absolute system clock for TCP timestamps
Message-ID<qcg0q-61m-7@gated-at.bofh.it>
On Thu, Sep 24, 2015 at 7:14 AM, Jovi Zhangwei <jovi@cloudflare.com> wrote:
> From f455dc3958593250909627474100f6cc5c158a5c Mon Sep 17 00:00:00 2001
> From: Marek Majkowski <marek@cloudflare.com>
> Date: Fri, 11 Sep 2015 06:05:07 -0700
> Subject: [PATCH] tcp: Use absolute system clock for TCP timestamps
>
> Using TCP timestamps is beneficial due for to its purpose in PAWS and when
> its role when SYN cookies are enabled. In practice though TCP timestamps are
> often disabled due to being a perceived security issue - they leak Linux
> system uptime.
>
> This patch introduces a kernel option that makes TCP timestamp always return
> an absolute value derived from a system clock as opposed to jiffies from
> boot.
>
> This patch is based on the approach taken by grsecurity:
>     https://grsecurity.net/~spender/random_timestamp.diff
>

Please do not send html messages, they wont reach lists.

May I ask how this patch was really tested ?

It cannot possibly work on current kernels, as TCP Timestamps are
generated from clock samples taken from skb_mstamp_get(),
and you did not change it.

static inline void skb_mstamp_get(struct skb_mstamp *cl)
{
        u64 val = local_clock();

        do_div(val, NSEC_PER_USEC);
        cl->stamp_us = (u32)val;
        cl->stamp_jiffies = (u32)jiffies;
}

TCP stack uses tcp_time_stamp internally, we do not want to add
overhead adding an offset on all places.

tp->lsndtime is an example, but we have others.

Therefore, I suggest you add a new function and use it only where needed.

static inline u32 secure_tcp_time_stamp(void)
{
   returns (u32)(tcp_time_stamp + rtc_timestamp_base);
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1232194

FromFlorian Westphal <fw@strlen.de>
Date2015-09-24 17:40 +0200
Message-ID<qcgMN-7bv-13@gated-at.bofh.it>
In reply to#1232139
Eric Dumazet <edumazet@google.com> wrote:
> On Thu, Sep 24, 2015 at 7:14 AM, Jovi Zhangwei <jovi@cloudflare.com> wrote:
> > From f455dc3958593250909627474100f6cc5c158a5c Mon Sep 17 00:00:00 2001
> > From: Marek Majkowski <marek@cloudflare.com>
> > Date: Fri, 11 Sep 2015 06:05:07 -0700
> > Subject: [PATCH] tcp: Use absolute system clock for TCP timestamps
> >
> > Using TCP timestamps is beneficial due for to its purpose in PAWS and when
> > its role when SYN cookies are enabled. In practice though TCP timestamps are
> > often disabled due to being a perceived security issue - they leak Linux
> > system uptime.
> >
> > This patch introduces a kernel option that makes TCP timestamp always return
> > an absolute value derived from a system clock as opposed to jiffies from
> > boot.
> >
> > This patch is based on the approach taken by grsecurity:
> >     https://grsecurity.net/~spender/random_timestamp.diff
> >

I did not see the proposed patch because it didn't make this list,
but I do not like the patch linked to above.

With HZ=1000 the clock wraps every 49 days anyway.
If thats is still deemed a problem, then the proposed solution doesn't
help since all this does is add some 'random uptime' when the machine
is booted so remote monitoring will easily give a good approximation of
real uptime.

Really, where is the problem...?

> TCP stack uses tcp_time_stamp internally, we do not want to add
> overhead adding an offset on all places.
> 
> tp->lsndtime is an example, but we have others.
> 
> Therefore, I suggest you add a new function and use it only where needed.

Agreed, the mangling should only be performed when writing ts stamp
into tcp header, and undone when reading ts echo from network.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web