Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5093013ybi; Tue, 28 May 2019 07:26:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnpbCk1AcK9stlUtJVh8mC0dDGo0J4CU8ZaNnN5wZn3rp9Bz/GRh49CeS0jJ1GP59K4RyE X-Received: by 2002:a63:5443:: with SMTP id e3mr21834151pgm.265.1559053584088; Tue, 28 May 2019 07:26:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559053584; cv=none; d=google.com; s=arc-20160816; b=0TJt3R6v1XLx6yIc4h6R8G8T9DKq1XpfhPHMhVAv5Q+gf6DlwlkjTgRookhyH8rl03 zTLchGLbcXqy/UTbppeq/kYvgvjZZn6bPL6ZPjqTEL4xNgKtcx0zh0Ls/Df/PRBPF9NJ +U4YacUdbNUDWsQzMkXUPKa094aJpsvs4oU4azkk9TT55KikBv7ulw2mPLzGsYj7mlgi jTH3g2S02Z7fPIXEEAenXhGsdTUZ27YRooL4nyduVApc8PppPNLHerxmh/MQ6oEAbwSp pnWjgBFc1zrc4hlS+JyBi4QB9NLwiiW0A+ECcgA7Tcp+Old1QXRlN9TU5tgmfbIN3gR0 MtWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=t2vArhK5ONSzG4f61utNPX6iuQEVIA/xkviTlXVlEb4=; b=tx2jmzFbMrEGJ6n3D3hdEojupsoXSlcxidng2Wgl8k+PN6GRoLcdNa0zeblu4zl9pR 6dOrozsaWu0RhvjU2ViR7iMwyJKW6JYTsmz7sBfU7xjr/lCf0vqwXzTEEKe/6haREF/n eZU4elOkEnJyX0yhPhDIjGtCOFgoLZOjYIba3KLbDZ+9oDoDNcRkQB0/kYxOswA5lZLh nkyduwvEzX8tZrap7Qwxlwjyl5HgkjLa6x16/bV/4W/UU1utoe3vjkBlH2CmxcxPVzoW e2ZTot4GzNrvKMH4ncgv3yZ2Gpt49lG88KBxtYqzmJiQ0GD+KMftycFT/Bd/VUPexx2Y j4bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=HPRJ9AXd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y6si11098569pgs.342.2019.05.28.07.26.08; Tue, 28 May 2019 07:26:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=HPRJ9AXd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727442AbfE1MmY (ORCPT + 99 others); Tue, 28 May 2019 08:42:24 -0400 Received: from pandora.armlinux.org.uk ([78.32.30.218]:37976 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727390AbfE1MmX (ORCPT ); Tue, 28 May 2019 08:42:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=t2vArhK5ONSzG4f61utNPX6iuQEVIA/xkviTlXVlEb4=; b=HPRJ9AXdPxXH93KtZWMlngs4d oLca7XsLgMK+6r6FdA4ZxY5y/aTFakuSI1ts6DG7/vtK92LYzhXJvGTVO1RTDATctncupVy4biIGM c14v4cUXQ9R9xaGfMz+wXoROvs7/teJ1apRU5hP1s+MEKHvIMeNVduA7NPxAlFKijYKStRXmdRUaB HycwgL/lBtOVl4LbgU7XZx0Kwp/EDpL0I5l+TXVTmZz85KEH+rDWSJTfWxOr+4hX19oY0ABEq0P54 XthKetauAq/9eWp9+emsOoOJ0Q8T2I03rK3gXz4jkv7PpgO8rwQeZ6OGYOHz8pYbzhnd70glyCVbU n/lH3o41A==; Received: from shell.armlinux.org.uk ([2001:4d48:ad52:3201:5054:ff:fe00:4ec]:56030) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1hVbQS-0005lo-AK; Tue, 28 May 2019 13:41:56 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.89) (envelope-from ) id 1hVbQO-0003cr-Ip; Tue, 28 May 2019 13:41:52 +0100 Date: Tue, 28 May 2019 13:41:52 +0100 From: Russell King - ARM Linux admin To: Young Xiao <92siuyang@gmail.com> Cc: will.deacon@arm.com, mark.rutland@arm.com, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, x86@kernel.org, peterz@infradead.org, kan.liang@linux.intel.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] perf: Fix oops when kthread execs user process Message-ID: <20190528124152.z76z7ar62hklz7tk@shell.armlinux.org.uk> References: <1559046689-24091-1-git-send-email-92siuyang@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1559046689-24091-1-git-send-email-92siuyang@gmail.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 28, 2019 at 08:31:29PM +0800, Young Xiao wrote: > When a kthread calls call_usermodehelper() the steps are: > 1. allocate current->mm > 2. load_elf_binary() > 3. populate current->thread.regs > > While doing this, interrupts are not disabled. If there is a perf > interrupt in the middle of this process (i.e. step 1 has completed > but not yet reached to step 3) and if perf tries to read userspace > regs, kernel oops. > > Fix it by setting abi to PERF_SAMPLE_REGS_ABI_NONE when userspace > pt_regs are not set. > > See commit bf05fc25f268 ("powerpc/perf: Fix oops when kthread execs > user process") for details. > > Signed-off-by: Young Xiao <92siuyang@gmail.com> > --- > arch/arm/kernel/perf_regs.c | 3 ++- > arch/arm64/kernel/perf_regs.c | 3 ++- > arch/x86/kernel/perf_regs.c | 3 ++- > 3 files changed, 6 insertions(+), 3 deletions(-) > > diff --git a/arch/arm/kernel/perf_regs.c b/arch/arm/kernel/perf_regs.c > index 05fe92a..78ee29a 100644 > --- a/arch/arm/kernel/perf_regs.c > +++ b/arch/arm/kernel/perf_regs.c > @@ -36,5 +36,6 @@ void perf_get_regs_user(struct perf_regs *regs_user, > struct pt_regs *regs_user_copy) > { > regs_user->regs = task_pt_regs(current); > - regs_user->abi = perf_reg_abi(current); > + regs_user->abi = (regs_user->regs) ? perf_reg_abi(current) : > + PERF_SAMPLE_REGS_ABI_NONE; I'd prefer it if we didn't introduce unnecessary parens - what function do the parens around "regs_user->regs" serve? -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up