Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp797109rdb; Thu, 18 Jan 2024 21:48:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IFRGxkBhUC4q3Nfe+d7dS5EGcEgMgYBAM5vzZ/VZF1mgVPi3wthgO6U6QiRsf5zVHm95h4+ X-Received: by 2002:a05:622a:183:b0:42a:7e2:ae65 with SMTP id s3-20020a05622a018300b0042a07e2ae65mr748808qtw.59.1705643336917; Thu, 18 Jan 2024 21:48:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705643336; cv=pass; d=google.com; s=arc-20160816; b=UeqSg/TqJcSLPVATdEGl+tIdM1cQelF1kYI/jZgyaM9xWd2giPuQkG7oqI3qwzmwih uXKK0UarX37L/XPjCV4GSvj3KbjKPKB9uKiqJ6RKXaFxghRnm54n1iP27Qom+aDDq5rU +m28hJQJddjUQZwOO7g+na9Xl2Fr50AcFv9AkVKm6mng3HPyffIM2k9/MDAhm78yF2D6 Q6prj/ehNLI7v9cyXPsO5NXxex/n+jpzdimqFOJPm4kot0HYxDxqh6peI0VAdTZraD+/ TKXGNXn8vQbxPqnglTAPz/cTU+19NlibXiM48wsyzyySZ6O1hKX0RQJmQBHIy+bQMIZs AL0w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Ktfqjrcw6SPfUG/Mbx5v/qs4aP5sKchmbfw9Mr4CWPc=; fh=0ojbi0dWQXeML7ER9Vuqx9Xc5a+RlwT8ZYPeUvXl0CU=; b=DyiQuqd+c2w7sSr6aiR/tFPAHymFkqQfH/FMyd3DjD7zgS0fIxHrtOJTgVBjBRoGee 6dMGQ2X3Tj/I4Ux5aBjkJUi3VcCvkaMVKrTE9ijK9oCCdxBxqmggVH4tw/ICs93oNB0Y uJagnfbuDNV/zDoi9pVGc8+GBWKq/Pa+kJGm8m/OuWeO4CmXOP0/06QBqZC7sZq5m6gC Pk0P51tNF/prAXoWeGa/JyKtDAJObFIEal1nuFS4Y6YvyssGzYOnFcgGnlfQ2mSvepmD cj3Hp60jhXnyFgek8lLEFDmPgAVZyOoOH7vGHpAOuKpL5FI+d/M6N6xuwWDxcglLiAik wnYw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=De1RDYW1; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-30785-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30785-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id i19-20020ac85c13000000b0042a1dc77359si2392301qti.656.2024.01.18.21.48.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 21:48:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30785-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=De1RDYW1; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-30785-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30785-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id AC2D21C22DDE for ; Fri, 19 Jan 2024 05:48:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A1B474C69; Fri, 19 Jan 2024 05:48:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="De1RDYW1" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1BC13C37; Fri, 19 Jan 2024 05:48:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705643326; cv=none; b=k9x7mleYz4F8hywKrJOGVgHM0u3uTZkNpHRLjUOMTGctpypdEJSb0N8vOAgieG+RiWL6yngCt0XkKTiqab1gesYhUqw0psM+ek6F1jusUEtiTlW3xkV+MYgpr5QngVCWDnkBqF78lK505P6eAZ6oq52zqx8FxubuQC0RLGvNIVM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705643326; c=relaxed/simple; bh=gkPF4VV6kDIgpkL8E52m/jsG+aV/R8c0E5+3UEWMyvY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YPe86wVev6QJUov7f3PApgm+PfNRA0xgL2YoPPLsAwtcIM/xK8tUZWzhySWgNebWjSm4HwiYmY6POvZeOfTtC6ltTqLGWkgah5nlCbLy9RlcTox/QfOejWScbYySuXGWQQFpR8Fkm8JOkonx8iOpeSAE93v8RrWMm/sy1pAecl8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=De1RDYW1; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F10AC433C7; Fri, 19 Jan 2024 05:48:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1705643326; bh=gkPF4VV6kDIgpkL8E52m/jsG+aV/R8c0E5+3UEWMyvY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=De1RDYW1sHKyudNYEL/xPak+b/SmeOjoNWdHIZb4qZZyTc3R1hB2585ek+nJRvtjY c5JIoc2+JnIL2oqF8pBvnjMfnzPWYjcO5uoGb2ADLtM7uYo4AhQaZSRKVOBDdkHniv uNStmfA0flLRbLdM2X1Cbziwxss4puK17GxhevD8= Date: Fri, 19 Jan 2024 06:48:43 +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 , Brian Swetland , linux-kernel@vger.kernel.org, kernel-team@android.com, Alice Ryhl , Greg Kroah-Hartman , stable@vger.kernel.org Subject: Re: [PATCH v2 03/28] binder: fix race between mmput() and do_exit() Message-ID: <2024011935-placidly-justifier-4338@gregkh> References: <20231201172212.1813387-1-cmllamas@google.com> <20231201172212.1813387-4-cmllamas@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Jan 18, 2024 at 07:29:07PM +0000, Carlos Llamas wrote: > On Fri, Dec 01, 2023 at 05:21:32PM +0000, Carlos Llamas wrote: > > Task A calls binder_update_page_range() to allocate and insert pages on > > a remote address space from Task B. For this, Task A pins the remote mm > > via mmget_not_zero() first. This can race with Task B do_exit() and the > > final mmput() refcount decrement will come from Task A. > > > > Task A | Task B > > ------------------+------------------ > > mmget_not_zero() | > > | do_exit() > > | exit_mm() > > | mmput() > > mmput() | > > exit_mmap() | > > remove_vma() | > > fput() | > > > > In this case, the work of ____fput() from Task B is queued up in Task A > > as TWA_RESUME. So in theory, Task A returns to userspace and the cleanup > > work gets executed. However, Task A instead sleep, waiting for a reply > > from Task B that never comes (it's dead). > > > > This means the binder_deferred_release() is blocked until an unrelated > > binder event forces Task A to go back to userspace. All the associated > > death notifications will also be delayed until then. > > > > In order to fix this use mmput_async() that will schedule the work in > > the corresponding mm->async_put_work WQ instead of Task A. > > > > Fixes: 457b9a6f09f0 ("Staging: android: add binder driver") > > Reviewed-by: Alice Ryhl > > Signed-off-by: Carlos Llamas > > --- > > Sorry, I forgot to Cc: stable@vger.kernel.org. This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html for how to do this properly.