Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp9133imw; Mon, 4 Jul 2022 04:22:08 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tOK0WCIxhu0T6Gh+35lCv0Uod9G+YWE5nswc04ko8AUUsIaw70bSd7qpA/SL5HvtdJqTTe X-Received: by 2002:aa7:cd91:0:b0:438:33a1:d5aa with SMTP id x17-20020aa7cd91000000b0043833a1d5aamr33030768edv.157.1656933728653; Mon, 04 Jul 2022 04:22:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656933728; cv=none; d=google.com; s=arc-20160816; b=pBYsOHuu+1pKPZqIxSicPxxvDHHedCdp41+dzRbZiU/nvbYUkY+Sp/mOXQJsHoNgKk XXUtRK69K9yaFfO1hhTn2AQVHlGfOfNpZd4O8buP4xk0RwqoWilsCViTxD2CJ1Hvt6NX ra3e6r6dcrsk3AQeuYNeuS+Gk7Zehtd/lLIEK/PsaQvAqD75AmwRPXVZlwhMEOyt+35B tDWKIVb9fjuxrrh9ZdS26aqaGCdAn6KXTNtaiZPMF7SucROBlletSJhhPu+LIwWZoP2A wIKDNd7xiUHn/oKZVzOfhOt7tfb8gR2FHGMfs37TSalZsp3itsSlr6cOtjgmhLU5z16h 0Yuw== 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; bh=23FJkiBr44s+a6DR0WczAbFuZlwi+UelXd+m7UWmJ0I=; b=qdFaMdjywgjcecYAH+06EO2/R0OIGpxp560aQZcrmOjVK8mPjxlby5Eie3WybUBevp KDKpHU2w09eSpItRJqapQdsXM+/ZSBpZrDnfJWvaiywIkAzjavmv8SCF65R4ntYU0UJa DC0Ol3yxqZWAnfFGULr+mewYxEa9W6zFl1VtOkfLI5El9sLGeg3ssYmxgoutkkxpyxlu GQpvRN6hiTsWkO5BJk0EoNUCZbVIchWWD11/ZlZq2HFhLQoIYwwNOA97aIbpziLHUDOf jGDM0K9oDAUVTNAFpMgl4ysXnb4pj/WnGrLjdLJn08NFEpbB/0iNY42oOZXoLCA97ZSP Cikg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s10-20020aa7d78a000000b00435201d9705si8255571edq.602.2022.07.04.04.21.43; Mon, 04 Jul 2022 04:22:08 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233092AbiGDKeM (ORCPT + 99 others); Mon, 4 Jul 2022 06:34:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233067AbiGDKeJ (ORCPT ); Mon, 4 Jul 2022 06:34:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AF81DFF0 for ; Mon, 4 Jul 2022 03:34:08 -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 dfw.source.kernel.org (Postfix) with ESMTPS id F096861592 for ; Mon, 4 Jul 2022 10:34:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3425C341CA; Mon, 4 Jul 2022 10:34:05 +0000 (UTC) Date: Mon, 4 Jul 2022 11:34:02 +0100 From: Catalin Marinas To: =?utf-8?B?aGFpYmluemhhbmco5byg5rW35paMKQ==?= Cc: Will Deacon , 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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9A004C03-250B-46C5-BF39-782D7551B00E@tencent.com> X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 Sat, Jul 02, 2022 at 05:43:19AM +0000, 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. > > Signed-off-by: hewenliang > Signed-off-by: Haibin Zhang Reviewed-by: Catalin Marinas