Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2481211rwb; Wed, 30 Nov 2022 07:09:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf43Tb1mkX1iUm/f1vzEBeUUvyg5fWZplMsNQpEIRG1qy2B0tF63KwId6WL96HV/jOAbgysC X-Received: by 2002:a63:5719:0:b0:476:ea7d:3ff6 with SMTP id l25-20020a635719000000b00476ea7d3ff6mr38715229pgb.73.1669820993990; Wed, 30 Nov 2022 07:09:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669820993; cv=none; d=google.com; s=arc-20160816; b=MEsG6nFV6FND21UeYpvJ+b9hc9ucR7oKd6yoBowEpkaf+Pa30bGA/1tgdHFaAKGKoV 7A+zp6apXKqAX1NqaujMjJlpowqsiq6S07nE6xpr8mLaHwxkcunwhxRpKw84kV5SZu4a DfsG+o/9XNBaZQIJoBQ3QhXUCvJ/Z2MB0r7BNFewDFMu2waJ4BdXAC/4aPlMSeMtmeiT EsN4ApXJkGD+ag45GTZe7+QS0tgShDNmWJEoT0iTECA432FOOF63pMv+dgClkhBQWj/M lAtIIMiH6yPzcnoxydwbKsgnwsf7fSsM71xAMbJIz/Y5OJGKMAh0WBXSYeGyrAMA3IVi q+Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=bAiUVAVMBHvHdImMNL/5roTtNhp0qUcjyhtLJnn/aqo=; b=ZR+KI7A3C/1AcDc99cPjec0nDitM6Iek5J/POkyZ0/4UiJWM0cvVsRsujVG+PLwRfc 4t7aFR+W0c0HJ8Dd6HdgfRjG7rb3IdDH+1W0K6Wd+SRYr+TN5uMcvxvblqEyXbUbsRUL 8hh6oJFmjRBYv/hHZ7jSRuKKswLckW/vX8epgT8jf+m0y67iShtMqYwvu3mlaK89Flwy uy4N6mcxJuSBix58hi6AsdGfwLP0ZJvGCxnAgbjrs/qHBkmiQpkbCWGWzgMqotDaU3j+ gWYn8CBJJb9rVdKNKfxvbQ1Vsr6X9MvdmmgC9nOyxJ2gsMUMiG30hWX6mx2u6IcRB68v L3mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="axzbGQB/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cd5-20020a056a00420500b0056ed0d35397si1792267pfb.184.2022.11.30.07.09.41; Wed, 30 Nov 2022 07:09:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="axzbGQB/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229818AbiK3PCm (ORCPT + 83 others); 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-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: X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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.