Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5725914ybi; Tue, 28 May 2019 18:45:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqxKkpn8NyMW6epjp+ha9vRiI+Hi6yMtDtJ3lNoOk5BvfiJiWml9hrc2jMI1g4HcWupw03Ow X-Received: by 2002:a17:902:4283:: with SMTP id h3mr116390944pld.214.1559094333638; Tue, 28 May 2019 18:45:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559094333; cv=none; d=google.com; s=arc-20160816; b=z1yErFoV+4UXFj5n4SflyduDdqig/CmakLR2dG17ADsG6wPkBrThBY/6uxQAvfG2to 19aIYaALBhwHQ6ayLwtJcldeHcoGX963371mYTkp+H614FElZS83PR/8Eakil8S5wbYM MF39IvYxixtV0PSIUGNKse9qKeDd2efAywRpbx70Co2vbnkA9mFB2e4e842qqrz3Z09u wgXB5jyyU8+HfO3SzoiN5/JZZOvlWCyFfwfohubs6P+hQXrWpjO4YEOQeEQNfEgMOsyi 5lKtkRkgM2KCF9J4DRJ0QwZooJSqFlU/USVzpCvcSfSHI1N1dCo+Tq0TTCOBhp2sc0Kp 7Xog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=7ZTvZQXm2F1JogewY+h8Fa+pYBDgyWlyBHBCV3xktBQ=; b=AJi5QN6sgX4wXttfjfwqPU6WJhLEKeIUozU1Z/sY73PU6MbT6dJlvueu66lVUpAwN1 jPeYU/8qmA3g0ZlyrQ6joRjBCeQ89uRZXIF2uNaXEumX4m5cjKTJ+xPK+XV1xKnQK5pT S4kqSTJiyVty89vgAyqiLCFaBpeA/CeLPbnOqkHrYbSzPUm7W0JNnaRgmTJw4GjCGX3z EntF+kpq58M83mnZ/7A+GaVfI8MbiD1DoW2pXgkjNxBUYS3ftjltG5BeH8UKJn3tNjXq 4z13N5ByEW+z5QFTGfc7ANKd0h1nFENI+l/yzGipX8GdilEbqxlEK/DEXGi8PYfC5K+c CFmg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b4si23157626plz.225.2019.05.28.18.45.17; Tue, 28 May 2019 18:45:33 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726005AbfE2BoJ (ORCPT + 99 others); Tue, 28 May 2019 21:44:09 -0400 Received: from bilbo.ozlabs.org ([203.11.71.1]:49539 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725805AbfE2BoI (ORCPT ); Tue, 28 May 2019 21:44:08 -0400 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 45DD5Z6xB4z9s4V; Wed, 29 May 2019 11:44:02 +1000 (AEST) From: Michael Ellerman To: Peter Zijlstra , Young Xiao <92siuyang@gmail.com> Cc: will.deacon@arm.com, linux@armlinux.org.uk, mark.rutland@arm.com, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, x86@kernel.org, kan.liang@linux.intel.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, ravi.bangoria@linux.vnet.ibm.com Subject: Re: [PATCH] perf: Fix oops when kthread execs user process In-Reply-To: <20190528140103.GT2623@hirez.programming.kicks-ass.net> References: <1559046689-24091-1-git-send-email-92siuyang@gmail.com> <20190528140103.GT2623@hirez.programming.kicks-ass.net> Date: Wed, 29 May 2019 11:44:02 +1000 Message-ID: <87a7f6ox0d.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Peter Zijlstra writes: > 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. > > Why the hell do we set current->mm before it is complete? Note that > normally exec() builds the new mm before attaching it, see exec_mmap() > in flush_old_exec(). > > Also, why did those PPC folks 'fix' this in isolation? And why didn't > you Cc them? We just assumed it was our bug, 'cause we have plenty of those :) cheers