Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1248606imm; Wed, 20 Jun 2018 14:22:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLW7Teo/ofS8cRDSCHc6G/nCRexeVvWoifFUjF6fn/D75EJWAYQa3ll40ZEmB1z5L5zKJum X-Received: by 2002:a17:902:292b:: with SMTP id g40-v6mr25764419plb.273.1529529779292; Wed, 20 Jun 2018 14:22:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529529779; cv=none; d=google.com; s=arc-20160816; b=wFdwgd6n1gT74cJ/+3scrnnnD+FrEM16cMnZ9V2dj0/O5RI/RW9Dz0PzdoDUstw+Pj RXTWiBj08xGm8gAT4PtWRG1a+y5iYCBOsSYeTGwalh49M1oLEIG0nO7K6BBqsRfY7qqd PMYKepbKCDCti2Ro57/4wPRhIJo2JuNdDi02bCu1xb0biyEhASowiNakkMmrlKr6syCN EOl78JeZM96o2H3IScbE3ZZg/hRZ0WktrRwbF/Wr5wS11MUm/nt8OVWvcPWUO80lfcla 8uoZSKalm5VSSbYu29S5t78yUq9tcBi+TpqYSXSTUpITVsPDcQ48K2k2u/Xt9iK29+Ra kmhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=XG29ekBSSXhcQEmjNhRSuxxGXBbmxiwvPWXSPfxAbQE=; b=Rsp1SxPHjoDq+sIk5dcYg+0JVJFwp1MZNtTsEo1EP6QyLED58aDmmPF5Uj8cWwtHO2 OZiNL2NHW476iDr8GcKLP81JrB/yYq/DDF2n/OajO3lezxeJc907+iYO6fBPuhWuXwsN qDwoFDIgRGrCpsaj1XUgItZo1/Eqvy/WsZlTzwTCp9SEV0yIvS/KiysD0AUJPcYt4/1l R3zmS9QE0hok7MVo8ahcecsLPfNW93QSjnGvbhovUhlOVIIYt96wyv+A0LgDSSx9Z5FE i2DxnWkifCelLvIh3kK+xIu6r28AiokwMfaUC2YlEDGLSaRaApomDiQe7ZWDu4HoCoto eZBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jtb16NRN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t9-v6si2693717pgn.559.2018.06.20.14.22.42; Wed, 20 Jun 2018 14:22:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jtb16NRN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933326AbeFTVWA (ORCPT + 99 others); Wed, 20 Jun 2018 17:22:00 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:52768 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933092AbeFTVV7 (ORCPT ); Wed, 20 Jun 2018 17:21:59 -0400 Received: by mail-it0-f65.google.com with SMTP id m194-v6so1725199itg.2 for ; Wed, 20 Jun 2018 14:21:59 -0700 (PDT) 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=XG29ekBSSXhcQEmjNhRSuxxGXBbmxiwvPWXSPfxAbQE=; b=jtb16NRNpUaIlqFLptRivFVywuF8K8FIVbB+ZZuGJYYxFwN7M2NiVScn9w8y4qSxhG Rlu8Ozz+xnEGBpNubBB+8CoHEn2CeAAhHx6bixW8H25+PfkshWCSevPYDjS0UvNo532J Q+yB9po0wbf6TWlq739qZDCFRwXRRDsU3TU49IXnzarj2TvT6FBu52RBjAd5GxYLtbeL z5ojx3NXPtjWZLZMF7czKIzsiI+bbXhCM4fVfkoyPEQIgTBeyRa784moXA2mBSM0ZAuT mqmuX6UgYgVoOi0O70wSt+45RuNOhDhvpRLEpZOeBkdB58RZDoYeitX83YX+vUfLrIxX B6Hg== 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=XG29ekBSSXhcQEmjNhRSuxxGXBbmxiwvPWXSPfxAbQE=; b=kGOuDlhY0V43MtdZrVRq1mLtT4GWdxG3vL7V0u/AICyAJTxGKBvrVHrEosBALDKwMA R5yEgOaDaUlVlKrnjZA7yQx4YJsWC7fxQRj52BiL9x4h7t78koLPZ1L4WpPYojCgT4bt LpAddQqHjp31njlzNWIfe1lUI+rwQ2MRmR3PbGZp513zizP/Izny8zOGGoD+aGFrL7Mw QntAZB6NlDpUDpHmt0AX6duleZvo48SNiqob0qM2HtzKsxfsKn057pxbgYSepF8tHcjk 4i3ltPd/ZkbHm7uUsExsiEmZJKU3ngluhH7SrHFtH+jM4H/SGj4DRWYfPIG9ZpxYsAZF XidQ== X-Gm-Message-State: APt69E1SSjBM0YisQAiZ7JD0vdKbDsfqRrqohmSamdMXq5dzfMnnJHpy L1rjY/sNtX6ksHjBdnkaquRnWgZOE1VX81MfQSJ22bptLEs= X-Received: by 2002:a24:3cd7:: with SMTP id m206-v6mr2909540ita.113.1529529718524; Wed, 20 Jun 2018 14:21:58 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a4f:8f86:0:0:0:0:0 with HTTP; Wed, 20 Jun 2018 14:21:57 -0700 (PDT) In-Reply-To: <20180620043200.GA10888@joelaf.mtv.corp.google.com> References: <20180620005735.219840-1-astrachan@google.com> <20180620005735.219840-2-astrachan@google.com> <20180620043200.GA10888@joelaf.mtv.corp.google.com> From: Daniel Colascione Date: Wed, 20 Jun 2018 14:21:57 -0700 Message-ID: Subject: Re: [PATCH 2/2 v2] staging: android: ashmem: Fix mmap size validation To: Joel Fernandes Cc: Alistair Strachan , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , =?UTF-8?B?QXJ2ZSBIasO4bm5ldsOlZw==?= , Todd Kjos , Martijn Coenen , devel@driverdev.osuosl.org, kernel-team@android.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 19, 2018 at 9:32 PM, Joel Fernandes wrote: > On Tue, Jun 19, 2018 at 05:57:35PM -0700, Alistair Strachan wrote: > > The ashmem driver did not check that the size/offset of the vma passed > > to its .mmap() function was not larger than the ashmem object being > > mapped. This could cause mmap() to succeed, even though accessing parts > > of the mapping would later fail with a segmentation fault. > > > > Ensure an error is returned by the ashmem_mmap() function if the vma > > size is larger than the ashmem object size. This enables safer handling > > of the problem in userspace. Are we sure that this approach is a good idea? You can over-mmap regular files. I don't like the idea of creating special mmap semantics for files that happen to be ashmem files. Ashmem users can detect size-changing shenanigans with ASHMEM_GET_SIZE after mmap, since an ashmem file's size can't change after an mmap call succeeds.