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


Groups > linux.kernel > #1575047

Re: [PATCH] scatterlist: don't overflow length field

Path csiph.com!feeder.erje.net!1.us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!news.mixmin.net!aioe.org!bofh.it!news.nic.it!robomod
From David Dillow <dillow@google.com>
Newsgroups linux.kernel
Subject Re: [PATCH] scatterlist: don't overflow length field
Date Mon, 06 Feb 2017 19:40:02 +0100
Message-ID <t7WmK-do-17@gated-at.bofh.it> (permalink)
References <t6aDw-30T-23@gated-at.bofh.it> <t6Sbv-6dd-13@gated-at.bofh.it>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=+O9I6Zz4YOjodFljnWtDxKVDzEtGaFlVN4/e9idfpEQ=; b=XtPRvXVITqmRVoLXUhXNmDu+0pj7UJE4MSHVq+32qcvk+fr3E2pdCX+JuPtdwJh2O9 WeF1QFsnKC4JjPFZOyhMIiqtJL4hhKZXlRqdYKN7hjM/uO01VL1p6O7o3DnanEc9S0vd 2rmfoTlJW6lmlyKe0GDpmaQIha7F0nBsoBiir5J/ggoPG8YSwwSHNwrLi/p9TdeuCGwk ZCMT07e9RjT6bVVwChHeTZ4tPb3/MjfaBNsbMdxTEHwpW4jJiJHHYZhoVTVEa3mLfFOH MbzWKFq3+p0vf8Qw2zHEg3TAJzZ4dsyf78dr+PSuLI9zWXUzRIV8AXKSTYECnWy47Vyu AjPA==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=+O9I6Zz4YOjodFljnWtDxKVDzEtGaFlVN4/e9idfpEQ=; b=Q/4Qx3BPJVLkdgoE7u4MCJT09+OvtsSDB12mmDyQ9EsLSxlNtUS8bomSVxmJz9Le0H fmOJGNykQFKobXZhPhCHmzDLmCg/qEGgQenHXBhkIEoH3usTWqPZpfqdXSsGIOy+HJVf u8Q196rI/ih6rquJGpkCmP5YZEweF5dIrCD1uwelAt7EEtJGQAaSuq26gdXD5eDxvLqp DDZkZo4YTxHByORxA0DI8qiIaQLf67N/SkPeOp3uzz6mc7G83aPBocCcx0sZCFdvhqbk 9nCf/ByJE5YVj+FCSPqvw0xD39+YBs4plUMBVF0Py/Uc1GbgmtPlHcgqBFrFu+Jei57M YzGg==
X-Gm-Message-State AMke39nb8KJPO4YO4vuJcdy8LrqvNxxjf91Dr4eJR5VnQnS/z9eZuHIUWfXOtK42S55bxk3S3UeP1OMbsyAD/wQf
X-Received by 10.13.239.7 with SMTP id y7mr7542092ywe.33.1486405890616; Mon, 06 Feb 2017 10:31:30 -0800 (PST)
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 44
Organization linux.* mail to news gateway
X-Original-Cc Andrew Morton <akpm@linux-foundation.org>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, axboe@fb.com, hch@lst.de, ming.lei@canonical.com
X-Original-Date Mon, 6 Feb 2017 10:31:30 -0800
X-Original-Message-ID <CALRx4h_dXS1vh255sgM3E=BmhAi0qe6c+uzU64W3GhRfD91Kdw@mail.gmail.com>
X-Original-References <20170201212917.11278-1-dillow@google.com> <CA+55aFwksH6sry-QBwt8_g8di938UxLJfotob3LY5XS8xhSBag@mail.gmail.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1575047

Show key headers only | View raw


+Jens, Christoph, and Ming based on off-list suggestion

On Fri, Feb 3, 2017 at 11:57 AM, Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
> On Wed, Feb 1, 2017 at 1:29 PM, David Dillow <dillow@google.com> wrote:
> > When called with a region of contiguous pages totaling > 4 GB of memory,
> > sg_alloc_table_from_pages() will overflow the length field, leading to a
> > corrupt scatter list. Fix this by tracking the number of pages we've
> > merged and start a new chunk when we would overflow.
>
> So what allows these things to be built in the first place?
>
> We limit IO sizes to fit in a signed int (so just below 2GB) not only
> because it's often an effective denial of service, but also because
> we've had issues with various drivers (and filesystems) getting
> int/long wrong.
>
> So nothing should be building those kinds of scatterlists, and it
> something is able to, it might result in other problems downstreams..

This isn't from normal read/write IO -- some applications want to
access large amounts
of userspace memory directly from hardware, and it is cleaner for them
to manage one
mapping than multiple 1GB or 2GB mappings -- assuming the hardware can even
support multiple mappings. If they have room in their container to
allocate and pin the
memory, we'd like to allow it.

There's definitely potential for problems downstream, even without
going through the
filesystems and block layers -- we noticed this potential issue while
tracking down an
bug in the IOMMU code when an entry in the list was over 1GB. We still
see a benefit
from building the large entries, though -- it allows superpages in the
IOMMU mapping
which helps the IOTLB cache.

We currently use sg_alloc_table_from_pages() to build the scatterlist
for dma_map_sg()
but we could do it ourselves if you'd rather add a length limit to the
more general code.

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


Thread

[PATCH] scatterlist: don't overflow length field David Dillow <dillow@google.com> - 2017-02-01 22:30 +0100
  Re: [PATCH] scatterlist: don't overflow length field Linus Torvalds <torvalds@linux-foundation.org> - 2017-02-03 21:00 +0100
    Re: [PATCH] scatterlist: don't overflow length field David Dillow <dillow@google.com> - 2017-02-06 19:40 +0100

csiph-web