From patchwork Thu Jun 4 11:37:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 1303463 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sipsolutions.net Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=aPHUXoQG; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49d3gR1G4nz9sSy for ; Thu, 4 Jun 2020 21:38:09 +1000 (AEST) 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=UuhRV4vDT3BTLo9dSu8lG1Q63oUvqfF31qEKhy6XpEE=; b=aPHUXoQGnDCclb OmKTnGtB0VjPxQxwIdKXMlGqL9D35UUeflyf7Jco4+1sDPUl3w6x4Q0k4ad6NWgLuQMp/f4DfPlob rO6diiwpEYAPF72zmySZDBhumFbLlhDMhLaMkGipZ/Gg3rHRlhC9pCdk9VHOX8VdCux6A4vqGtf37 A1cuxWkFX+3X4Zo9xVmWOwyL2oHFA8iukf3DPj558dMn9sSMOtJj2BcLuslwyBnPl86c4GG0tfROR biE7mARfyRseQ6ixnePy4z1PLdZXLZ4bYLft/f/A+WAOIV/RkNUyiU/OJnWHcPR6rn450TEpgKQE3 68mB4NitRY2rlsBj6KRA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jgoC9-0003sr-BV; Thu, 04 Jun 2020 11:38:01 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:191:4433::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jgoC6-0003sX-Tm for linux-um@lists.infradead.org; Thu, 04 Jun 2020 11:38:00 +0000 Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) (envelope-from ) id 1jgoC4-009IBR-Qj; Thu, 04 Jun 2020 13:37:56 +0200 From: Johannes Berg To: linux-um@lists.infradead.org Subject: [PATCH] um: remove mmap_sem usage from activate_mm() Date: Thu, 4 Jun 2020 13:37:52 +0200 Message-Id: <20200604133752.397dedea0758.I7a24aaa26794eb3fa432003c1bf55cbb816489e2@changeid> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200604_043758_957309_49156F4D X-CRM114-Status: UNSURE ( 8.80 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.4 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (0.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Johannes Berg Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Johannes Berg Lockdep complains about the mmap_sem because we try to down_write() it while we already hold the task (spin)lock. Since commit 9bfb23fc4a48 ("sys_unshare: remove the dead CLONE_THREAD/SIGHAND/VM code") this is no longer called by sys_unshare(), and thus the only caller of this is exec_mmap() in fs/exec.c. But in this case, the new mm is completely new, so it shouldn't be possible to change it concurrently. Remove the mmap_sem handling completely. Signed-off-by: Johannes Berg --- arch/um/include/asm/mmu_context.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/um/include/asm/mmu_context.h b/arch/um/include/asm/mmu_context.h index b4deb1bfbb68..8a6e1c5e2c22 100644 --- a/arch/um/include/asm/mmu_context.h +++ b/arch/um/include/asm/mmu_context.h @@ -43,13 +43,11 @@ extern void force_flush_all(void); static inline void activate_mm(struct mm_struct *old, struct mm_struct *new) { /* - * This is called by fs/exec.c and sys_unshare() - * when the new ->mm is used for the first time. + * This is called by fs/exec.c when the new ->mm is used + * for the first time. */ __switch_mm(&new->context.id); - down_write_nested(&new->mmap_sem, 1); uml_setup_stubs(new); - up_write(&new->mmap_sem); } static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,