From patchwork Tue May 7 07:36:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 10932413 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2A738912 for ; Tue, 7 May 2019 07:36:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 11D102881C for ; Tue, 7 May 2019 07:36:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03B5828869; Tue, 7 May 2019 07:36:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9165C2881C for ; Tue, 7 May 2019 07:36:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=w4P+BYmGg4WLQxU7y5x7iNJshs7x/8LnG/qIXZtOLP0=; b=i1PrLPqtIIqzQT SLDYLPSPJlqdkqkudloINRbrrQlzcNR8PLERyf62gOuAzuRXDtqqzWHiQpQDihPvMbcnueXnXqKDS AXrRTy2cIi0bJxfRVlieAjdKr7/71/4kuZJgthyzZOpSwViGX3VRiMtCDyAGBzq6wPd39GD+bZBUT VEIr0+i4PiCJU9uSGlCpZXroK9Y1hFQ5RWqsCvr7v7qW2P1sN90Wc2Q50syo/J09/oRZI6oHFQDKD +4G38AWquiLlDZnYdfnBqg8Koq9QDeAumlcqN7Dg7QpLBRfVjjwuZ2HDpbQ4YgpblcP4GKqhv5DL+ XW3fQvWHYUEmZkQDNy6A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hNuei-0000T9-Uq; Tue, 07 May 2019 07:36:52 +0000 Received: from mx2.suse.de ([195.135.220.15] helo=mx1.suse.de) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hNuef-0000SR-J1 for linux-riscv@lists.infradead.org; Tue, 07 May 2019 07:36:50 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 83F24AD17; Tue, 7 May 2019 07:36:46 +0000 (UTC) From: Andreas Schwab To: linux-riscv@lists.infradead.org Subject: [PATCH] riscv: fix locking violation in page fault handler X-Yow: I'm rated PG-34!! Date: Tue, 07 May 2019 09:36:46 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190507_003649_766304_5881E3C7 X-CRM114-Status: GOOD ( 11.10 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When a user mode process accesses an address in the vmalloc area do_page_fault tries to unlock the mmap semaphore when it isn't locked. Signed-off-by: Andreas Schwab Reviewed-by: Palmer Dabbelt --- arch/riscv/mm/fault.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c index 88401d5125bc..c51878e5a66a 100644 --- a/arch/riscv/mm/fault.c +++ b/arch/riscv/mm/fault.c @@ -181,6 +181,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs) up_read(&mm->mmap_sem); /* User mode accesses just cause a SIGSEGV */ if (user_mode(regs)) { +bad_area_do_trap: do_trap(regs, SIGSEGV, code, addr, tsk); return; } @@ -230,7 +231,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs) int index; if (user_mode(regs)) - goto bad_area; + goto bad_area_do_trap; /* * Synchronize this task's top level page-table