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 50288C4332F for ; Wed, 30 Nov 2022 15:02:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229780AbiK3PCm (ORCPT ); Wed, 30 Nov 2022 10:02:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229861AbiK3PCe (ORCPT ); Wed, 30 Nov 2022 10:02:34 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 859FB2C3 for ; Wed, 30 Nov 2022 07:02:31 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id u15-20020a17090a3fcf00b002191825cf02so2381546pjm.2 for ; Wed, 30 Nov 2022 07:02:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=bAiUVAVMBHvHdImMNL/5roTtNhp0qUcjyhtLJnn/aqo=; b=axzbGQB/DVP2ROYhCiI3Et3IZBHx3Jg45dEq5eNU71GtEUBgHAczDaXP8QH4cPvVlB lB0FGjY9mPg90kKm/lRvbykCrWmUYHdAu5DTmDqryzMe3jjoX7aVNFWXrjqgezLmmLVi SCEjq1gJ2aMu3qnUWX//wBSNVYwZaJK/8k7EMPgTuySxoSP0I4G4/y5cigFO2OIENcuz h/+sIEp6EhnnmiLSkWP6mIvlWjLAxShhStaT/TjL1Qy6uICtyZg/NDwl3buS52tA/M7i n1oD33om7v2HbbmDT4OL21Z0DSMp/ZIjgGBpnnVPhq2a6ZGaiCG9IOIpttmop41O9aYA sFng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=bAiUVAVMBHvHdImMNL/5roTtNhp0qUcjyhtLJnn/aqo=; b=n8tAgICWByrVJxa/RzFy+qois8l8s8V0y3IvYI0PfpylxRxL/4UKzP1+vLhZxnhFHD I4QaJJWNvxAiOpTwxOC2cXABDQMGQcfa9XeQxvwJAjyKlfK+S6fjtOmNYFEjAjlcROBN Gf7FIwEEug0cInIQMtRuh2w0Yk69kgHIMBJNU+WOAqdKKo3m3J9ne+PQk0Lyrq1/BNfC 3otUdrlWtTaQ27HTwQdzw3WonBbjT5rp14/t4HnibhFIhPkcinCWvXLbL72ZtApgaP4f jcMlE4tMaYRW7vJe9SpDJoXTHSsz5Xp5K/5dzw2R0oFrjuedjcNrU1JH/0GVf24FJAUU 9LZw== X-Gm-Message-State: ANoB5pm4XXpgfoRVNLDFNFtpiqvKbVWYFRcL+PkVOTsQjIis282/BpQJ 0cIHuX8/l/4vshIYVh5qVuAohw== X-Google-Smtp-Source: AA0mqf7wiy9QTt8vPIkpfVgyb7rxNT7hhm2lw3u7InJKSLS2+BldtKKt+SRNMlCopPFhDdjrUcnVxA== X-Received: by 2002:a17:902:6804:b0:189:907c:8380 with SMTP id h4-20020a170902680400b00189907c8380mr13310535plk.104.1669820550708; Wed, 30 Nov 2022 07:02:30 -0800 (PST) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id f6-20020a170902ce8600b001743ba85d39sm1611512plg.110.2022.11.30.07.02.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Nov 2022 07:02:30 -0800 (PST) Date: Wed, 30 Nov 2022 15:02:26 +0000 From: Carlos Llamas To: Greg Kroah-Hartman Cc: Arve =?iso-8859-1?B?SGr4bm5lduVn?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Hridya Valsaraju , 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 5.15] binder: validate alloc->mm in ->mmap() handler Message-ID: References: <20221123180922.1502550-1-cmllamas@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 30, 2022 at 01:40:58PM +0100, Greg Kroah-Hartman wrote: > On Wed, Nov 23, 2022 at 06:09:21PM +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 too is already in the 5.15 queue, is this a different version? > > thanks, > > greg k-h It's the same version, please ignore this one too. Thanks.