Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp5602071imw; Wed, 20 Jul 2022 08:44:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tm02vWKtn9Z8DN3HRrEFuQpWm02eP6inkJbDBHHm59/ZrJKIKWeWnPl64VBclyyF5dyhLf X-Received: by 2002:a17:90b:4a47:b0:1f0:3f92:8c80 with SMTP id lb7-20020a17090b4a4700b001f03f928c80mr6019379pjb.199.1658331868964; Wed, 20 Jul 2022 08:44:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658331868; cv=none; d=google.com; s=arc-20160816; b=vPWP7qu0uJpeD+N3cEEDQTRBb6MB5NblzmDIgVSWsrKLjheTUtFCkYzKqXBdiMwNcb 5nrlAtm2qiWjcCQ1tJ4RPcOyWeX1FSRS3gVJQ0O2dYO8H4qxsWEy8ipeISqvDIGX/9Oe hZtx56xWEj+9R3yFunb3kJYHnlfnQM25aa9Th6UiA3tWiXAiQIBhjIkoKKRZDomyEPnj 1c+OEo2yZ6W2v1rJrAyc8GP5zk1cVHFbeDXEq7Y6rnKA9firrhAHUAt+xN+8vpRe23ws RJBmGp3GjDUPcWd13PTU9mWfM6cDwhnzzKJROc4Jh5B2lzi60hGNmwcAINPczwHKQV+n TpIw== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=+ITN8/NzMqMN7zHfyXAOzFRekORzcIckFhvH54+KYKA=; b=DpFQ7BlpBpc43swt//nFhI2LCYqL3xKr1WczJx8wJu8H8ptYFtTQNiA4ntwAejLb6T 6qiLFi+1CZ1L3CBL7F2NbmDHzl4tkNYGovHjx71cm0Sp8P6emkoNzvPghMA4l8ZkT0lg 78bHfJ11QttxjiKWMYfluVpzjNWWKuQ/ZaBZwQelD5IOlRuIQLHxbkDy+crQ1iuNnTiD CczZbJ/NZdHaMrOwZ+DZ30ShvpoON9naXgx5w1rRisPvH4/U7WOVFaqnr6WTFWT/LKNV UdBDINLO7daXA7ztCHoSy1Xx25fdw+hypKoVZA7wZ3j98uuvhwtSFgGMBEPhmxdrXUxQ 9Kbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IenLWnEE; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h67-20020a636c46000000b0041a656374edsi1112079pgc.605.2022.07.20.08.44.13; Wed, 20 Jul 2022 08:44:28 -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=@linaro.org header.s=google header.b=IenLWnEE; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235145AbiGTPdU (ORCPT + 99 others); Wed, 20 Jul 2022 11:33:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237358AbiGTPdR (ORCPT ); Wed, 20 Jul 2022 11:33:17 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C3E961DA5 for ; Wed, 20 Jul 2022 08:33:16 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id b6so10565901wmq.5 for ; Wed, 20 Jul 2022 08:33:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=+ITN8/NzMqMN7zHfyXAOzFRekORzcIckFhvH54+KYKA=; b=IenLWnEEs9XlqJG2dIci50Gy15R7Qnd+SkxKyc3Wl+ZY1jRDLUw324Px2VWmv6BWTq klvrupR+wkZ2uE+ktWw/E/MZsehPUA9xXH0lb3ZIz/8jGvF6av59PCYnc5mpGIMkPgn6 UU8m9zzN6CsMbYUw9XgvVv5J1c2JouJrPr80tGSuSBj6YfMDvoKDVPyfx12cpQ3+Hxne Nxi1BaodgAyIuxXt/EdoF/kW1WDrA0+eND1W2KqiQCmyIME0dVJLwIwARcoC8MdNzxbL Uje/Su6C7SDMC+f/R+xfRn8KNnewYX4fLONmv1pMQJ+TsK8NPHKcTqWMlR8vLNLwUp7k C40A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=+ITN8/NzMqMN7zHfyXAOzFRekORzcIckFhvH54+KYKA=; b=JTUj+wp815RUROW9WozKYqLFFqDv1QuDheaTchVrMTZs50ArnAwcFzJ2OR/8HLtau8 470y8xosvhBYdNjjS1+MGe3G/fuAAtC6YyJJ+uNLDR0pW+un3/0JU8iEid/AChNcJkV1 X+2AC1AMn+5hytn0TxA/tHQX1GbYZ6raX1ok6beJ368+PWm34EoW+LffSe5PSBiV0Mkr aJVzPqX+1uPbw5JWK0c+f4gXXCfrm+X/uZsRdEHrG26ilCeGNGVVHEX2FWf5JBYKdRjj 7SgNp/IEI3bWXYmissAOgITyLo6rMBpjNwyds/bTOknioSLJrmhi2mURnpRVrnBHa5Wi psIw== X-Gm-Message-State: AJIora+IFGftrXOjQxuA+Dct8MwCzP8zjJM86msFcj1oNMceJedVXJV8 jUN33/D2YGiHrKc5dqjwssukqA== X-Received: by 2002:a05:600c:2d09:b0:3a3:1062:ce61 with SMTP id x9-20020a05600c2d0900b003a31062ce61mr4439786wmf.138.1658331195186; Wed, 20 Jul 2022 08:33:15 -0700 (PDT) Received: from google.com (cpc155339-bagu17-2-0-cust87.1-3.cable.virginm.net. [86.27.177.88]) by smtp.gmail.com with ESMTPSA id m126-20020a1ca384000000b003a03e63e428sm3276117wme.36.2022.07.20.08.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 08:33:14 -0700 (PDT) Date: Wed, 20 Jul 2022 16:33:13 +0100 From: Lee Jones To: Will Deacon 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: References: <9A004C03-250B-46C5-BF39-782D7551B00E@tencent.com> <20220720151344.GA16452@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220720151344.GA16452@willie-the-truck> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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, 20 Jul 2022, Will Deacon wrote: > 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. No worries. Just thought I'd ask. > 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. I'll add it to my TODO. -- Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog