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 CE404C433EF for ; Mon, 4 Jul 2022 10:34:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233514AbiGDKeN (ORCPT ); Mon, 4 Jul 2022 06:34:13 -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> 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