From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0C14C352A1 for ; Wed, 30 Nov 2022 12:40:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234786AbiK3Mkq (ORCPT ); Wed, 30 Nov 2022 07:40:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232159AbiK3Mko (ORCPT ); Wed, 30 Nov 2022 07:40:44 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B7E929801; Wed, 30 Nov 2022 04:40:44 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A3D1B61BA3; Wed, 30 Nov 2022 12:40:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87419C433D6; Wed, 30 Nov 2022 12:40:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1669812043; bh=GlkpgJ1w1hGdnqLs36PrTT1mYKX1ZJWOrDUYgdlxAh0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kRlQ0bzrKC6ACEYnbzLH1rkyXoAMvdqblPg9NlIedJZjD0e9+l379mFVqyL7OOf2n flkRnKX/t2J5mmvh/tKN3VxyGASq3m5UUSc045KMIlXlKbizQ6ckz0i+8zq6t17bpt KmTKhbGz85XWV0jH6sNx7NbB6A4WgMmCXzJ56Pjc= Date: Wed, 30 Nov 2022 13:40:40 +0100 From: Greg Kroah-Hartman To: Carlos Llamas Cc: Arve =?iso-8859-1?B?SGr4bm5lduVn?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Suren Baghdasaryan , "Liam R. Howlett" , linux-kernel@vger.kernel.org, kernel-team@android.com, Jann Horn , stable@vger.kernel.org, Todd Kjos Subject: Re: [PATCH 6.0] binder: validate alloc->mm in ->mmap() handler Message-ID: References: <20221123180809.1501779-1-cmllamas@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221123180809.1501779-1-cmllamas@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 23, 2022 at 06:08:09PM +0000, Carlos Llamas wrote: > commit 3ce00bb7e91cf57d723905371507af57182c37ef upstream. > > Since commit 1da52815d5f1 ("binder: fix alloc->vma_vm_mm null-ptr > dereference") binder caches a pointer to the current->mm during open(). > This fixes a null-ptr dereference reported by syzkaller. Unfortunately, > it also opens the door for a process to update its mm after the open(), > (e.g. via execve) making the cached alloc->mm pointer invalid. > > Things get worse when the process continues to mmap() a vma. From this > point forward, binder will attempt to find this vma using an obsolete > alloc->mm reference. Such as in binder_update_page_range(), where the > wrong vma is obtained via vma_lookup(), yet binder proceeds to happily > insert new pages into it. > > To avoid this issue fail the ->mmap() callback if we detect a mismatch > between the vma->vm_mm and the original alloc->mm pointer. This prevents > alloc->vm_addr from getting set, so that any subsequent vma_lookup() > calls fail as expected. > > Fixes: 1da52815d5f1 ("binder: fix alloc->vma_vm_mm null-ptr dereference") > Reported-by: Jann Horn > Cc: # 5.15+ > Signed-off-by: Carlos Llamas > Acked-by: Todd Kjos > Link: https://lore.kernel.org/r/20221104231235.348958-1-cmllamas@google.com > Signed-off-by: Greg Kroah-Hartman > [cmllamas: renamed alloc->mm since missing e66b77e50522] > Signed-off-by: Carlos Llamas > --- > drivers/android/binder_alloc.c | 7 +++++++ > 1 file changed, 7 insertions(+) This is already in the 6.0 queue, is this a different version? thanks, greg k-h