Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp5603023imw; Wed, 20 Jul 2022 08:45:42 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tQxm/GO9xGMkN74bvDixYa4BtLEboGnU5+/DVwFeYScep7dhdR0yR+8ax6jvp7KQr0+HQh X-Received: by 2002:a05:6402:3041:b0:43a:d8b1:8b5 with SMTP id bs1-20020a056402304100b0043ad8b108b5mr49916747edb.242.1658331942093; Wed, 20 Jul 2022 08:45:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658331942; cv=none; d=google.com; s=arc-20160816; b=M7kFCWlsflb9eQ7tc9EQBeQInETG7fRYXWK3QF+eGO+WRuKlbfjuHz8+Rt3NxGaqFv 15alNGmsJbq9FriJfK5Yk85YOg3qVjaBe7Bz0wl5pMqzLTcgJ5enUluqnz6zuk6xBhWP UTId/hGbz19eQzAz7w0R8vgPxBFNl3Jdd1ciYBjf5i4F3c4hmc5FMl8cjWYzIrcGNBU7 OtcYVU9K+2b4/m4fsorDkK7eqdTEcBD9j/Bo66n/X+PBfdG0twt1QzlDZm909w/k0vp7 bD9CsDpDCic3bSwRBtwkpMcVOb+J/9mpoDH67Lu3qcu8vbVUltczCxMRrOCe5ftmvjeN qXvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=T1WI6P44eNklkPzaI6xwjMThNh56F2EWfqguxr/NTlc=; b=f9NVjfaKpbNJDNxjE/1+zgL6rmIDbOCJ4C80m+0y4n79QZQqNXl6eF8Ii3Z79tJOty POfpgVEX3CkfmdSx3Hsk7TsrtStG0Bxr/7iucph0Vzcf08fH1vgy0r1pBRVUl8YPxTyl WJ/W9DMDx3jFrYE+YSiaWesSnEtX+BGaspyXQZ2CxDXYqNnctUCQiWL36v+cxJ0Nin1P 2LCDz9RFSO6uwfcaaiW4qPEmW6GQ7WB3bnOkiis3trBlxH6dsQOTQcTyz2cM63KOKNiI uTOpUXhaNaUauGJQOech+MX20h8JuGJNyt5tPuwCd9ducHc3sYoXe033a5lYBpTzkDaH 1yAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=glBh9aEW; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020a056402278800b0043b9010d871si6892099ede.104.2022.07.20.08.45.17; Wed, 20 Jul 2022 08:45:42 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=glBh9aEW; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233222AbiGTPOR (ORCPT + 99 others); Wed, 20 Jul 2022 11:14:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241277AbiGTPN6 (ORCPT ); Wed, 20 Jul 2022 11:13:58 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E65D58842 for ; Wed, 20 Jul 2022 08:13:53 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 1A036B81E95 for ; Wed, 20 Jul 2022 15:13:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CE99C3411E; Wed, 20 Jul 2022 15:13:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658330030; bh=nGt3Aby0DEsD4O/j96Wopr2DY0zyfin9FwsBSZGUq1s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=glBh9aEW8cXsqumGpksb4ZHfU3E6/Fpy8afP4Xz5VUGkb6jaiJx+/Qd6ipiscwBHD fUfNqZcKFKcOB97AMTDp1Ww2oehpD18b9TfCS/frvSbgNuq3WD633/gyUa7gBPoMw5 WNrYaUavOhgtjRA7Q9qGIFGZiz+AigWCKz1JxaVLQCN0XCUnrfhKVLO1TpzFQvaUO0 y1bHGjVbKC0HOaR8Dhk1Gupx+ZwSjrDshayrkWltmVOxBuOouHPomeJ7pYLk3ocyL+ 9uCOKJdXYnWdsJ4IdeZzuiSTEExd1FAn4/4xOSH2uEo0x06ib/NnSZaPHVSvMTfBk+ tNWIvdUCQNFCQ== Date: Wed, 20 Jul 2022 16:13:45 +0100 From: Will Deacon To: Lee Jones Cc: =?utf-8?B?aGFpYmluemhhbmco5byg5rW35paMKQ==?= , Catalin Marinas , Ard Biesheuvel , Martin Ma , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "hewenliang4@huawei.com" Subject: Re: [PATCH V2] arm64: fix oops in concurrently setting insn_emulation sysctls Message-ID: <20220720151344.GA16452@willie-the-truck> References: <9A004C03-250B-46C5-BF39-782D7551B00E@tencent.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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, Jul 20, 2022 at 01:23:24PM +0100, Lee Jones wrote: > On Sat, 02 Jul 2022, haibinzhang(张海斌) wrote: > > > How to reproduce: > > launch two shell executions: > > #!/bin/bash > > while [ 1 ]; > > do > > echo 1 > /proc/sys/abi/swp > > done > > > > Oops info: > > Unable to handle kernel NULL pointer dereference at virtual address 0000000000000010 > > Internal error: Oops: 96000006 [#1] SMP > > Call trace: > > update_insn_emulation_mode+0xc0/0x148 > > emulation_proc_handler+0x64/0xb8 > > proc_sys_call_handler+0x9c/0xf8 > > proc_sys_write+0x18/0x20 > > __vfs_write+0x20/0x48 > > vfs_write+0xe4/0x1d0 > > ksys_write+0x70/0xf8 > > __arm64_sys_write+0x20/0x28 > > el0_svc_common.constprop.0+0x7c/0x1c0 > > el0_svc_handler+0x2c/0xa0 > > el0_svc+0x8/0x200 > > > > emulation_proc_handler changes table->data for proc_dointvec_minmax > > and so it isn't allowed to reenter before restoring table->data, > > which isn't right now. > > To fix this issue, keep the table->data as &insn->current_mode and > > use container_of() to retrieve the insn pointer. Another mutex is > > used to protect against the current_mode update but not for retrieving > > insn_emulation as table->data is no longer changing. > > Looks as though this lost its Fixes tag during the rework. > > Fixes: 587064b610c7 ("arm64: Add framework for legacy instruction emulation") > > Will, are you able to add this retroactively? Sadly, this is now buried under some other patches so I'd have to rebase the branch if I were to add this and I don't think it's worth it just to add a tag. On the plus side, the patch has a Link: tag to this thread, so the Fixes tag is retrievable if you're determined enough. If somebody wants this for stable, then I suppose they'll have to send a backport to make sure it doesn't get missed. Will