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 C94C1C636D4 for ; Tue, 31 Jan 2023 23:06:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229767AbjAaXGr (ORCPT ); Tue, 31 Jan 2023 18:06:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229637AbjAaXGr (ORCPT ); Tue, 31 Jan 2023 18:06:47 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E472946727; Tue, 31 Jan 2023 15:06:45 -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 7F42D6173D; Tue, 31 Jan 2023 23:06:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D98A2C433D2; Tue, 31 Jan 2023 23:06:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1675206404; bh=xv0QVceRR/ZYreqhO38LCdq8D4iCdsXU2lOGetLMRjE=; h=Date:To:From:Subject:From; b=YDItXoaQkFoOvwnhx6fnaR70fvhEoWcEAbW4z+ngE9f4buKJgcbnal8y1henOJ5FE guExHFvAPHAxiAXZCiIdWD+JQjU8uIhizg+JUiKzMP68vC3BX6gQ5LaAFDRdvYa8cU VO9WD3w/ezWe2DkJomEnJgWtZYv0u9ixEe2g1ZOM= Date: Tue, 31 Jan 2023 15:06:44 -0800 To: mm-commits@vger.kernel.org, xemul@parallels.com, viro@zeniv.linux.org.uk, stable@vger.kernel.org, jmoyer@redhat.com, jannh@google.com, bcrl@kvack.org, sethjenkins@google.com, akpm@linux-foundation.org From: Andrew Morton Subject: + aio-fix-mremap-after-fork-null-deref.patch added to mm-hotfixes-unstable branch Message-Id: <20230131230644.D98A2C433D2@smtp.kernel.org> Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org The patch titled Subject: aio: fix mremap after fork null-deref has been added to the -mm mm-hotfixes-unstable branch. Its filename is aio-fix-mremap-after-fork-null-deref.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/aio-fix-mremap-after-fork-null-deref.patch This patch will later appear in the mm-hotfixes-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Seth Jenkins Subject: aio: fix mremap after fork null-deref Date: Tue, 31 Jan 2023 12:25:55 -0500 Commit e4a0d3e720e7 ("aio: Make it possible to remap aio ring") introduced a null-deref if mremap is called on an old aio mapping after fork as mm->ioctx_table will be set to NULL. [jmoyer@redhat.com: fix 80 column issue] Link: https://lkml.kernel.org/r/x49sffq4nvg.fsf@segfault.boston.devel.redhat.com Fixes: e4a0d3e720e7 ("aio: Make it possible to remap aio ring") Signed-off-by: Seth Jenkins Signed-off-by: Jeff Moyer Cc: Alexander Viro Cc: Benjamin LaHaise Cc: Jann Horn Cc: Pavel Emelyanov Cc: Signed-off-by: Andrew Morton --- fs/aio.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/fs/aio.c~aio-fix-mremap-after-fork-null-deref +++ a/fs/aio.c @@ -361,6 +361,9 @@ static int aio_ring_mremap(struct vm_are spin_lock(&mm->ioctx_lock); rcu_read_lock(); table = rcu_dereference(mm->ioctx_table); + if (!table) + goto out_unlock; + for (i = 0; i < table->nr; i++) { struct kioctx *ctx; @@ -374,6 +377,7 @@ static int aio_ring_mremap(struct vm_are } } +out_unlock: rcu_read_unlock(); spin_unlock(&mm->ioctx_lock); return res; _ Patches currently in -mm which might be from sethjenkins@google.com are aio-fix-mremap-after-fork-null-deref.patch