Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp853191pxk; Thu, 17 Sep 2020 19:07:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOD+0oPMjf1YLMf9A9KrBb6aylen6GAZVy+33/mUizQTXq7QEEBYf5eDLeV+9KUEijXcGx X-Received: by 2002:a17:906:1787:: with SMTP id t7mr34990264eje.173.1600394874511; Thu, 17 Sep 2020 19:07:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600394874; cv=none; d=google.com; s=arc-20160816; b=e50qZl0uc5OvkCXpazbNsP1UY91NfUxwKAO3yXxEHhccSqf8303ivJesMnlCTWeV0p gCLYtZR/hWScSgmH7e65Q6vJWA9d+x6EhycBGe9zuYS8pxil5t3rm9J2y8rZ4w4SoSKs aOh2CX0kdAh7miLKN8Dt6iF9P9u7IZF2Uve2MhwBcWrhGUdxpJpoiA3Oc0jgCyPpioJA MvPhEkoEh6F/k/Oajs01KKXYGTDdkorQZJLropQA/VPYvG+8tntuk4hP/4DpXCIhzmS+ u3FE4J4THS4bCyKP273xcH+x6A5vD8To5z+VpdCOOgrnnxxseGuBsY6bBPLEthyXPGfT Fmfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9emb84UjM1rcz/Nnbtl5OiaGuBXBd6fNHiNZgnT1M6o=; b=sw/AFfeNJCKT08RmSqEvljvRGbyEIjGvyspSVcU6zt0jsbcbga3dsKeY9eovRrvyw3 kzcCymCEYurEdXDzylZLwVclj+h58p5tB0yRGkvb+3JkXaysDz1kSpLSwBu03Bw10hH5 XxCkI9XPCUficQA19IYV1fnkxHjDHo7K57B8DET3PzfycJvcVD9AjZzecoN7XO5aQJMj QCpqQ7sipU71f5DfxT6UhetrmPJA0e1MHn9N6ihtQOBEZneg1zqLdMu+erHhzKmCIRB9 erMbFVo7aC0oPTnlsrimM8g/CpgqStbqve2vLRt1CxgpbcTa5n+R2/K5Bpr6KQsZkCwe f4wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bH49yQST; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y8si1091696edv.438.2020.09.17.19.07.31; Thu, 17 Sep 2020 19:07:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bH49yQST; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727530AbgIRCF1 (ORCPT + 99 others); Thu, 17 Sep 2020 22:05:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:53500 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727495AbgIRCFS (ORCPT ); Thu, 17 Sep 2020 22:05:18 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D6D8123772; Fri, 18 Sep 2020 02:05:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394717; bh=ZNSLXRuNGa52uCWoAOHJVDfW8rqDBqg8ZhRQmPT57Hw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bH49yQSTywvR4Nw1PwDEjaUFl3Q8N5fTtf33Zq0B5dJwhbG701FBLZDK5/2CR2jhi yznNxT2kN+7mBPe3fMFi0QS0FZdlnWhiudVHXSZQI76QeKun8a0cL/S6HA6KMqZwvb s7H/4l8zEZ10ScmvLRGqxzscDfQOKMRCdmQiYOd0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Bernd Edlinger , "Eric W . Biederman" , Sasha Levin Subject: [PATCH AUTOSEL 5.4 201/330] kernel/kcmp.c: Use new infrastructure to fix deadlocks in execve Date: Thu, 17 Sep 2020 21:59:01 -0400 Message-Id: <20200918020110.2063155-201-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bernd Edlinger [ Upstream commit 454e3126cb842388e22df6b3ac3da44062c00765 ] This changes kcmp_epoll_target to use the new exec_update_mutex instead of cred_guard_mutex. This should be safe, as the credentials are only used for reading, and furthermore ->mm and ->sighand are updated on execve, but only under the new exec_update_mutex. Signed-off-by: Bernd Edlinger Signed-off-by: Eric W. Biederman Signed-off-by: Sasha Levin --- kernel/kcmp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/kcmp.c b/kernel/kcmp.c index a0e3d7a0e8b81..b3ff9288c6cc9 100644 --- a/kernel/kcmp.c +++ b/kernel/kcmp.c @@ -173,8 +173,8 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type, /* * One should have enough rights to inspect task details. */ - ret = kcmp_lock(&task1->signal->cred_guard_mutex, - &task2->signal->cred_guard_mutex); + ret = kcmp_lock(&task1->signal->exec_update_mutex, + &task2->signal->exec_update_mutex); if (ret) goto err; if (!ptrace_may_access(task1, PTRACE_MODE_READ_REALCREDS) || @@ -229,8 +229,8 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type, } err_unlock: - kcmp_unlock(&task1->signal->cred_guard_mutex, - &task2->signal->cred_guard_mutex); + kcmp_unlock(&task1->signal->exec_update_mutex, + &task2->signal->exec_update_mutex); err: put_task_struct(task1); put_task_struct(task2); -- 2.25.1