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


Groups > linux.kernel > #1265441

Re: [GIT] Networking

From Ingo Molnar <mingo@kernel.org>
Newsgroups linux.kernel
Subject Re: [GIT] Networking
Date 2015-11-09 09:20 +0100
Message-ID <qsPQd-3Rn-1@gated-at.bofh.it> (permalink)
References (5 earlier) <qqz3d-4xe-31@gated-at.bofh.it> <qqzFT-50z-9@gated-at.bofh.it> <qqJlW-2OU-51@gated-at.bofh.it> <qqQ42-7sq-5@gated-at.bofh.it> <qqQGJ-7Hz-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


* Linus Torvalds <torvalds@linux-foundation.org> wrote:

> Does anybody have any particular other "uhhuh, overflow in multiplication" 
> issues in mind? Because the interface for a saturating multiplication (or 
> addition, for that matter) would actually be much easier. And would be trivial 
> to have as an inline asm for compatibility with older versions of gcc too.
> 
> Then you could just do that jiffies conversion - or allocation, for that matter 
> - without any special overflow handling at all. Doing
> 
>     buf = kmalloc(sat_mul(sizeof(x), nr), GFP_KERNEL);
> 
> would just magically work.

Exactly: saturation is the default behavior for many GPU vector/pixel attributes 
as well, to simplify and speed up the code and the hardware. I always wanted our 
ABIs to saturate instead of duplicating complexity with overflow failure logic.

In the kernel the first point of failure is missing overflow checks. The second 
point of failure are buggy overflow checks. We can eliminate both if we just use 
safe operations that produce output that never exit the valid range. This also 
happens to result in the simplest code. We should start thinking of overflow 
checks as rootkit enablers.

And note how much this simplifies review and static analysis: if this is the 
dominant model used in new kernel code then the analysis (human or machine) would 
only have to ensure that no untrusted input values get multiplied (or added) in an 
unsafe way. It would not have to be able to understand and track any 'overflow 
logic' through a maze of return paths, and validate whether the 'overflow logic' 
is correct for all input parameter ranges...

The flip side is marginally less ABI robustness: random input parameters due to 
memory corruption will just saturate and produce nonsensical results. I don't 
think it's a big issue, and I also think the simplicity of input parameter 
validation is _way_ more important than our behavior to random input - but I've 
been overruled in the past when trying to introduce saturating ABIs, so saturation 
is something people sometimes find inelegant.

Thanks,

	Ingo
--
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/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [GIT] Networking Andy Lutomirski <luto@kernel.org> - 2015-11-02 21:40 +0100
  Re: [GIT] Networking Linus Torvalds <torvalds@linux-foundation.org> - 2015-11-02 22:20 +0100
    Re: [GIT] Networking Linus Torvalds <torvalds@linux-foundation.org> - 2015-11-02 22:20 +0100
      Re: [GIT] Networking Andy Lutomirski <luto@amacapital.net> - 2015-11-02 22:40 +0100
        Re: [GIT] Networking Hannes Frederic Sowa <hannes@stressinduktion.org> - 2015-11-02 23:20 +0100
          Re: [GIT] Networking Linus Torvalds <torvalds@linux-foundation.org> - 2015-11-03 00:30 +0100
        Re: [GIT] Networking Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2015-11-03 02:00 +0100
          Re: [GIT] Networking Andy Lutomirski <luto@amacapital.net> - 2015-11-03 03:00 +0100
            Re: [GIT] Networking Linus Torvalds <torvalds@linux-foundation.org> - 2015-11-03 03:40 +0100
              Re: [GIT] Networking Hannes Frederic Sowa <hannes@stressinduktion.org> - 2015-11-03 14:00 +0100
                Re: [GIT] Networking Linus Torvalds <torvalds@linux-foundation.org> - 2015-11-03 21:10 +0100
                Re: [GIT] Networking Linus Torvalds <torvalds@linux-foundation.org> - 2015-11-03 21:50 +0100
                RE: [GIT] Networking David Laight <David.Laight@ACULAB.COM> - 2015-11-06 16:30 +0100
                Re: [GIT] Networking Andy Lutomirski <luto@amacapital.net> - 2015-11-07 01:50 +0100
                Re: [GIT] Networking Ingo Molnar <mingo@kernel.org> - 2015-11-09 09:20 +0100
                Re: [GIT] Networking Hannes Frederic Sowa <hannes@stressinduktion.org> - 2015-11-09 11:40 +0100
                Re: [GIT] Networking Hannes Frederic Sowa <hannes@stressinduktion.org> - 2015-11-09 11:40 +0100
          Re: [GIT] Networking Linus Torvalds <torvalds@linux-foundation.org> - 2015-11-03 03:00 +0100

csiph-web