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


Groups > linux.kernel > #1629472

Re: [PATCH] macsec: avoid heap overflow in skb_to_sgvec

From "Jason A. Donenfeld" <Jason@zx2c4.com>
Newsgroups linux.kernel
Subject Re: [PATCH] macsec: avoid heap overflow in skb_to_sgvec
Date 2017-04-24 14:20 +0200
Message-ID <tzL8d-6Tf-15@gated-at.bofh.it> (permalink)
References <tyO8a-2k7-3@gated-at.bofh.it> <tzK2t-6io-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Apr 24, 2017 at 1:02 PM, David Laight <David.Laight@aculab.com> wrote:
> ...
>
> Shouldn't skb_to_sgvec() be checking the number of fragments against
> the size of the sg list?
> The callers would then all need auditing to allow for failure.

This has never been done before, since this is one of those operations
that simply _shouldn't fail_ this late in the driver's path. There's
an easy way to use a fixed size array of MAX_SKB_FRAGS+1, and then
just not specify FRAGLIST as a device feature. Then the function
succeeds every time, rather than dropping packets. Alternatively, if
the array is being allocated dynamically (kmalloc), a call to
skb_cow_data returns the number of fragments needed; since usually
people using scattergather are going to be modifying the skb anyway, I
believe this function should be being called anyway...

It would be possible to do as you suggest, though, by using sg_is_last
in skb_to_sgvec. In this case we'd need to change every call site of
skb_to_sgvec to ensure the return value is being checked as well as
making sure that the sglist is initialized with sg_init_table to
ensure the last frag is properly marked. I wouldn't be opposed to
this, though it is potentially error prone work.

In any case, this patch here follows the pattern of the entire rest of
the present-day kernel, so it ought to be merged as-is.

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


Thread

[PATCH] macsec: avoid heap overflow in skb_to_sgvec "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-04-21 23:20 +0200
  RE: [PATCH] macsec: avoid heap overflow in skb_to_sgvec David Laight <David.Laight@ACULAB.COM> - 2017-04-24 13:10 +0200
    Re: [PATCH] macsec: avoid heap overflow in skb_to_sgvec "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-04-24 14:20 +0200
  Re: [PATCH] macsec: avoid heap overflow in skb_to_sgvec David Miller <davem@davemloft.net> - 2017-04-24 19:50 +0200

csiph-web