Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp3542026imb; Tue, 5 Mar 2019 12:06:42 -0800 (PST) X-Google-Smtp-Source: APXvYqweHsOl7cq3D/j2Ycp0f0bSjL+YL2PUaL9X+5PqTaFfL3oQt86+v5CaTi+FH8vWIZv49cWJ X-Received: by 2002:a63:3446:: with SMTP id b67mr2960117pga.122.1551816402875; Tue, 05 Mar 2019 12:06:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551816402; cv=none; d=google.com; s=arc-20160816; b=ROK5Bf+DIqIxn4xMDwOHTuZ/1hQhAjLV8uqjYe4OvS/QuuYaWz1aY0DFIFI+YFqVpO yS5f7tYcNbmbdq7Mw7Rsz4XHAH4l28IyloHNCByiq2+rxoZQKVWfpS5ShN5H46W/g0Bj 0xmtcWcxo/+8F9tRA+JXL27AH2I9lAajhT6pThUJEWZ64SP+RvoIw5SO+7zkBlvotTdS wb0nCnHZdVYRN+FAy2flD1SZzFRc4MbZAYuky3N+CemDtCzQKxM08UESbcfWvLRk9fPQ ZQsrosbflunkZ5VlEtgUP5QulMBAGuVZE/Z6EJRWi+Z4hW+v+Gh3tuyZfAxbMUuDCSKm AwPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=K+3BPzXujBFtjqPxXDYt4guAQdVBXgcnJWhW+gCBb5M=; b=fE1txy54Io2HWGIJtsPMxja3GKXbqKh8pF6Z5/9jAFRvR/378mt+D4BtxD1/Oc3QzM +3u/TXntTfKxZA48xM5Ux2oc5oVInB0KiRycKa1EmvO85DHPH/+tB3V4zJwfmsz6ASc0 CA8MX0VXikLhsJUdlChaRwXUtoI5qkKS3vRKzs/DSczrBoB8JTv7BosdxqQnUbi7zBKe uFnWSxytRKoUgOdQTCFJchSKa8uDeueFIkB8ZfBMKYLboCHOT+PxYYge+vldwmMYXFBK 3XKzl63aGX/anYxZMnqk3zFtVPDyxvxg+Zi5ce4AsQcxee8uGq5tdaDADp19MoVy8Gpf 6eUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=IPQTzISm; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 17si8596765pgu.262.2019.03.05.12.06.25; Tue, 05 Mar 2019 12:06:42 -0800 (PST) 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=@joelfernandes.org header.s=google header.b=IPQTzISm; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727746AbfCETfL (ORCPT + 99 others); Tue, 5 Mar 2019 14:35:11 -0500 Received: from mail-qt1-f193.google.com ([209.85.160.193]:42258 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726873AbfCETfK (ORCPT ); Tue, 5 Mar 2019 14:35:10 -0500 Received: by mail-qt1-f193.google.com with SMTP id u7so10191004qtg.9 for ; Tue, 05 Mar 2019 11:35:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=K+3BPzXujBFtjqPxXDYt4guAQdVBXgcnJWhW+gCBb5M=; b=IPQTzISmXsvh9Sjoh2DftlLWyMajWSphYY8IxXcioNpKUZo9XpUKxJ3aZqnG+O8Zrw 9L6FKwaOdD3CuaBvYp7W+J3yRlSztdNGQ3HzPzQn2qJRC+Yu34mkBhRQZRs/xlyNsPFV xkRD/i10lKoGSMaJxaYuOOXKBELhaXJ5xPVtc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=K+3BPzXujBFtjqPxXDYt4guAQdVBXgcnJWhW+gCBb5M=; b=swiyZTTQkqbGVf+Ab+Us0tGfSu7pWWeQGH5E76D/ty8o0V07lVZbhbFkmfroznEV+6 spbFu3OJfnu9KU9M72H4Z8QYPBOER/RDJfOFt2CTnUFLHkzR0VJXRtBE9vmp2vjtVXDP RID9v3X8KZSGMHv76TWV9DLOfBZP4m+7GadtlsHNxkq99i0q6/xqnzEhzHHZ9zndHLh2 5R6KhitQloZH/ISG0YzVRjmWmZJf+B1Xv5ILfz2e4En2Tk4pVW5So3xb+2Pb//RUw93T 9Diicj4OztPQU0Yvo8UWQjzPpt9WQDtaTRljYBzLX71ag8Oejvbl/GC3j/dfV4zqhnC6 /CRw== X-Gm-Message-State: APjAAAUGqyt6HkqJDt3P0NS8nEdUkcLeRmVkrBwu1VoQvr7owYsjop55 Xbl4SrtAa9DskxEdigk3Mlsm4w== X-Received: by 2002:aed:3504:: with SMTP id a4mr2786179qte.139.1551814509514; Tue, 05 Mar 2019 11:35:09 -0800 (PST) Received: from localhost ([2620:0:1004:1100:cca9:fccc:8667:9bdc]) by smtp.gmail.com with ESMTPSA id r64sm5454138qkb.60.2019.03.05.11.35.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Mar 2019 11:35:08 -0800 (PST) Date: Tue, 5 Mar 2019 14:35:07 -0500 From: Joel Fernandes To: Todd Kjos Cc: Greg KH , Todd Kjos , Arve =?iso-8859-1?B?SGr4bm5lduVn?= , "open list:ANDROID DRIVERS" , LKML , Martijn Coenen , Android Kernel Team Subject: Re: [PATCH] binder: fix race between munmap() and direct reclaim Message-ID: <20190305193507.GA149288@google.com> References: <20190301230606.8302-1-tkjos@google.com> <20190302075720.GA18046@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Mar 02, 2019 at 08:27:44AM -0800, Todd Kjos wrote: > On Fri, Mar 1, 2019 at 11:57 PM Greg KH wrote: > > > > On Fri, Mar 01, 2019 at 03:06:06PM -0800, Todd Kjos wrote: > > > An munmap() on a binder device causes binder_vma_close() to be called > > > which clears the alloc->vma pointer. > > > > > > If direct reclaim causes binder_alloc_free_page() to be called, there > > > is a race where alloc->vma is read into a local vma pointer and then > > > used later after the mm->mmap_sem is acquired. This can result in > > > calling zap_page_range() with an invalid vma which manifests as a > > > use-after-free in zap_page_range(). > > > > > > The fix is to check alloc->vma after acquiring the mmap_sem (which we > > > were acquiring anyway) and skip zap_page_range() if it has changed > > > to NULL. > > > > > > Signed-off-by: Todd Kjos Awesome patch, Reviewed-by: Joel Fernandes (Google) thanks! - Joel > > > --- > > > > Any specific commit that this fixes? > > No, it's been there a long time. > > > And should it be marked for stable releases? > > It is needed in stable (back to 4.4), but will need to be backported. > Should I post backported versions targeting the specific releases now? > I was thinking we'd wait for this one to land. I think we'll need 1 > patch for 4.4/4.9 and a second one for 4.14/4.19 (and some of those > backported patches will have conflicts when merged down to android-4.X > -- I think the 4.14/4.19 version will apply to all the android > branches). Let me know how you want to handle this. > > > > > thanks, > > > > greg k-h