From patchwork Tue Sep 29 10:58:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 291131 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 714C0C47425 for ; Tue, 29 Sep 2020 11:38:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2EC26208FE for ; Tue, 29 Sep 2020 11:38:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601379516; bh=ZNSLXRuNGa52uCWoAOHJVDfW8rqDBqg8ZhRQmPT57Hw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=XWdXx1rBYTopbVSAE3DBzVt8ddY6/EgU8wP1d56DMHpxpdBF7zbma1teJJxYtzTyW qEpI54hfLr5HZ4z/d21a3OGzGIOMW9vcaiUmKX9y+KC40PjHpm40Ge5SH1anIlFXf/ eSygSLRg+Wgc9iSOIyS7Tj6VaRdEBwVCO8M8EP00= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730368AbgI2Lif (ORCPT ); Tue, 29 Sep 2020 07:38:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:60340 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729832AbgI2Lif (ORCPT ); Tue, 29 Sep 2020 07:38:35 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 614BD22262; Tue, 29 Sep 2020 11:38:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601379507; bh=ZNSLXRuNGa52uCWoAOHJVDfW8rqDBqg8ZhRQmPT57Hw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N9UGCLDqM2kIKM0EWM1YZvViv3bkx1ddOLcydr3Gph7OEaoW462gY5bQMdgGkXROk d1IwPEZoDwptgyjwhchN36d+kvnF5yU8ZpcaeEm5/JOKsw9gGXxpf7QM018UbtySMw s4QHuA2fEOd3I9PafurgLinQ1oJtik0aGNYL71pE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bernd Edlinger , "Eric W. Biederman" , Sasha Levin Subject: [PATCH 5.4 195/388] kernel/kcmp.c: Use new infrastructure to fix deadlocks in execve Date: Tue, 29 Sep 2020 12:58:46 +0200 Message-Id: <20200929110019.919104260@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929110010.467764689@linuxfoundation.org> References: <20200929110010.467764689@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@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);