Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp791162imm; Fri, 31 Aug 2018 13:24:58 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbPM5q3gJlDeqRnAl6mwtSGV96tCLosBTf1oik/b0QdoYHtizxyPNbVug3r3bLtHn8q0nJB X-Received: by 2002:a17:902:2904:: with SMTP id g4-v6mr16683841plb.70.1535747097968; Fri, 31 Aug 2018 13:24:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535747097; cv=none; d=google.com; s=arc-20160816; b=m7hmQ3CM/N8GVi4ufRlHSfiTjDFWy5r9qARsJtQrREFZS+h9qz0HV8Nv3kwNUTRRrd iwtReBoWHbi9qYDW2HjQKjXI0/qTLvhhJFc1u8P83S9E7QwZcOaN2T49Lt1vAhKQpLYp 8yYq2nSWCb/9GtsKEMpxzm3KbUfB/RNcXAXOa4Xsb/MnPZksTTcsAvIRHPj57r0rt3kC RdPoutLZ/os9S7wKbE7/7fsjK9LwnwfvOtlvGq0/jZqU66Tb4t5uTB2aicsDqtSBbEyv 4nMIIxSbwUfs9IIL3rFYeSuM5CI3kYemPpn+saSRAQNfY+MyuaHpVYh577FyhF45xSrW MH5w== 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:arc-authentication-results; bh=nRaz0ZK01aSfkYsfr6l5LSJF0x6sHLcroA9i+pLSsfg=; b=aBmYQvGLMS5YVF/eQxAiZKotHkHgHqOn/eXrAL4Pf3HopoVwg83KFpLAjZ8TFuUcPx MrJV221tUj2bzkBmyy+zViL/lmHJgPnGM6hYVlncdymnF4l7tDZf0YME397FOfCBW5MD 20w0esELfJhF2bqOG4OWyo0SdH7wz7wUsMl2z3LBkb8RB7YnlHQUfHTkj0TDLbKbUOD/ lWWWAI0u6cw+v20gR6dZIw9jeCSfYcP8WOT/TiAtOdeo66ZjLsYhJoUC3khHtkoe6FzL OYY2tjN+zOMDYsFrBwRYgV8bVGuhJgkuSssw2WfdaAj+EuUZ3RPVqGsXXfJOsk/hN+Vj ye9Q== ARC-Authentication-Results: i=1; mx.google.com; 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 bc5-v6si10397270plb.278.2018.08.31.13.24.41; Fri, 31 Aug 2018 13:24:57 -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; 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 S1727586AbeIAAb6 (ORCPT + 99 others); Fri, 31 Aug 2018 20:31:58 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:52492 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727228AbeIAAb6 (ORCPT ); Fri, 31 Aug 2018 20:31:58 -0400 Received: from localhost (unknown [72.28.92.217]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 6F4E2D23; Fri, 31 Aug 2018 20:22:52 +0000 (UTC) Date: Fri, 31 Aug 2018 13:22:50 -0700 From: Greg Kroah-Hartman To: Greg Hackmann Cc: Greg Hackmann , linux-kernel@vger.kernel.org, Laura Abbott , Sumit Semwal , devel@driverdev.osuosl.org, kernel-team@android.com, stable@vger.kernel.org Subject: Re: [PATCH] staging: android: ion: fix ION_IOC_{MAP,SHARE} use-after-free Message-ID: <20180831202250.GB30176@kroah.com> References: <20180831200627.59712-1-ghackmann@google.com> <20180831201232.GA23559@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 Fri, Aug 31, 2018 at 01:17:20PM -0700, Greg Hackmann wrote: > On 08/31/2018 01:12 PM, Greg Kroah-Hartman wrote: > > On Fri, Aug 31, 2018 at 01:06:27PM -0700, Greg Hackmann wrote: > >> The ION_IOC_{MAP,SHARE} ioctls drop and reacquire client->lock several > >> times while operating on one of the client's ion_handles. This creates > >> windows where userspace can call ION_IOC_FREE on the same client with > >> the same handle, and effectively make the kernel drop its own reference. > >> For example: > >> > >> - thread A: ION_IOC_ALLOC creates an ion_handle with refcount 1 > >> - thread A: starts ION_IOC_MAP and increments the refcount to 2 > >> - thread B: ION_IOC_FREE decrements the refcount to 1 > >> - thread B: ION_IOC_FREE decrements the refcount to 0 and frees the > >> handle > >> - thread A: continues ION_IOC_MAP with a dangling ion_handle * to > >> freed memory > >> > >> Fix this by holding client->lock for the duration of > >> ION_IOC_{MAP,SHARE}, preventing the concurrent ION_IOC_FREE. Also > >> remove ion_handle_get_by_id(), since there's literally no way to use it > >> safely. > >> > >> This patch is applied on top of 4.9.y. Kernels 4.12 and later are > >> unaffected, since all the underlying ion_handle infrastructure has been > >> ripped out. > > > > Does 4.4.y or older also need this? If so, can you send backports, as > > this one does not apply there. > > > > thanks, > > > > greg k-h > > > > Yes, 4.4.y and older will need this. If there are no objections to this > patch, I'll send backports ASAP. None from me, thanks! greg k-h