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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01ECDC433F5 for ; Wed, 20 Apr 2022 23:35:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 90C826B0073; Wed, 20 Apr 2022 19:35:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8BA1C6B0074; Wed, 20 Apr 2022 19:35:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7AB336B0075; Wed, 20 Apr 2022 19:35:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 680626B0073 for ; Wed, 20 Apr 2022 19:35:19 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 42EC922D44 for ; Wed, 20 Apr 2022 23:35:19 +0000 (UTC) X-FDA: 79378865958.15.C3274AF Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf15.hostedemail.com (Postfix) with ESMTP id 05B8AA001A for ; Wed, 20 Apr 2022 23:35:16 +0000 (UTC) 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 EFCE061B2D; Wed, 20 Apr 2022 23:35:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84AADC385A0; Wed, 20 Apr 2022 23:35:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1650497717; bh=CeEIAtnp46ZiHfA8IgNltR02etk9Kcs/s6j4PZaHb/4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ug/4EZiK5prmSe9zK6mMYPhX5ds4QhfqPJO9wPuRdrNxdH24UhyPcc/3mrBJ+Wg+9 5Cw+lJow+azopnbtNjBNBOkm5y0sJUAjWdd4GeMGLQVbHd+Vq8qrx6szVQq0fb9+oh 5BzpqiZvYZzH+GVMkVIDvQmoOlQO2z2eLjQpQYtM= Date: Wed, 20 Apr 2022 16:35:16 -0700 From: Andrew Morton To: Alistair Popple Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, christian.koenig@amd.com, jhubbard@nvidia.com, rcampbell@nvidia.com, Jason Gunthorpe Subject: Re: [PATCH v2] mm/mmu_notifier.c: Fix race in mmu_interval_notifier_remove() Message-Id: <20220420163516.ab713a22af375788a541f045@linux-foundation.org> In-Reply-To: <87ee1rxrn1.fsf@nvdebian.thelocal> References: <20220420043734.476348-1-apopple@nvidia.com> <20220420151142.f60307e749033a24ef0c68d5@linux-foundation.org> <87ee1rxrn1.fsf@nvdebian.thelocal> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 05B8AA001A X-Stat-Signature: cfdz1noqe9nc3m4gkygpxfdqc1xct8fz Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b="ug/4EZiK"; spf=pass (imf15.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-HE-Tag: 1650497716-916645 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, 21 Apr 2022 09:21:06 +1000 Alistair Popple wrote: > >> As the wait_event() condition is true it will return immediately. This > >> can lead to use-after-free type errors if the caller frees the data > >> structure containing the interval notifier subscription while it is > >> still on a deferred list. Fix this by taking the appropriate lock when > >> reading invalidate_seq to ensure proper synchronisation. > >> > >> ... > >> > >> Fixes: 99cb252f5e68 ("mm/mmu_notifier: add an interval tree notifier") > > > > Do you think fix this should be backported into older kernels? > > Yes, I forgot to cc stable sorry. So we have actually seen these use-after-free errors? Some description of the end-user visible impact is always helpful when deciding which trees need a patch. > Do you want me to resend with > 'Cc: stable@vger.kernel.org'? Thanks, I added that.