Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp877386pxk; Thu, 17 Sep 2020 20:05:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyodBQSdMXJibPSbvULSyvZvhTS0z/JkTf8jf9QzW7t4dTzS5KTKit00F4KD/+tFsMlg/y9 X-Received: by 2002:a17:906:4c58:: with SMTP id d24mr35252441ejw.108.1600398319765; Thu, 17 Sep 2020 20:05:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600398319; cv=none; d=google.com; s=arc-20160816; b=ZEkxYX80/VZOcADoAd2WjgbBpRWEzuaBv3ofMldzSB/YlNhlRjP4omztmn1ytKrU1/ rPI0JoxJpXfYDDs0esgNDeuijHGFa5BY7q95lHtFND1y0MXQYx2iULHQRoMcpe+j4izi JavyN/2P76ZBcxeActU6Dq0CQtCPWceT38rT4yRAz1rolZ9ePfWShYlCo43UeRwtiFck qumE2EB1lqa3yCZ+ds53qkXU003NgIi+D9j+FHhEyyqom1j6umLaRsvZvhMymRbDDDmN 8yGkwJa2QGH79aAQTpjB40KW2XPb56P0Kf0HthPnqmSGlShZbosQsyAdKwo2k+Io59hi aSCg== 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=A5reVdeqSZnz34Avk5feJRS/+UmKB5U64T8HQ9u+pEM=; b=aEfopd4OVV3c55V6cJF4+0vIql52G9u8l6RN7yvzoPCgjVj/YUzQ0J1e2Zr3GH4Y14 cP40Zv+zSTKLzuXduJDS2unQKnar9lh+1/P4uONufMzy3kYEbqMJJIJsyKfRGgWw+Xhq Ot/w2UeJLTHsTndsDi3xfk89v9nMaSmfVHg9OktB4M+Jpf50Tpr+3ARYxXeB8RCusmmy 2DbYi4vNUOh67a3T73tMsPHT+vqy7RvFcnpUNAD5A6Ei+ryJM4m0UphfsSdyNKEdgV4j yANm7gZBE9fndXeFRnWPazmrexR+vpbYyRu4rF1ci4fhcIlC3/5NfLYpj5FkzYKRHtf/ 7PPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Oa22Kzgk; 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 u12si1081396edy.390.2020.09.17.20.04.56; Thu, 17 Sep 2020 20:05:19 -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=Oa22Kzgk; 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 S1730484AbgIRDCt (ORCPT + 99 others); Thu, 17 Sep 2020 23:02:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:53518 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727502AbgIRCFS (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 D3B5F23718; Fri, 18 Sep 2020 02:05:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394718; bh=1mIj69/AdI66ecJ3kzCGsxsb13fML65mPCSlmdkpGvE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Oa22KzgkC5FUx3BEwtIBu+GyabC1Ya5xkW1AxuC78IQWsN6zCUZwX0ZsWhqA2+Lo4 cdnadsWiwp7F90a2q9N/7vYk6Zl9PaYYrMu7VMEgUiwktUJ0vwTebTkk+P0Jz1zWS/ qfKRWf5bVdLCZlw2e/30g/Dn6eZGZ1MZqCvAIQr8= 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 202/330] proc: Use new infrastructure to fix deadlocks in execve Date: Thu, 17 Sep 2020 21:59:02 -0400 Message-Id: <20200918020110.2063155-202-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 2db9dbf71bf98d02a0bf33e798e5bfd2a9944696 ] This changes lock_trace to use the new exec_update_mutex instead of cred_guard_mutex. This fixes possible deadlocks when the trace is accessing /proc/$pid/stack for instance. This should be safe, as the credentials are only used for reading, and task->mm is updated on execve under the new exec_update_mutex. Signed-off-by: Bernd Edlinger Signed-off-by: Eric W. Biederman Signed-off-by: Sasha Levin --- fs/proc/base.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index ebea9501afb84..4fdfe4faa74ee 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -403,11 +403,11 @@ print0: static int lock_trace(struct task_struct *task) { - int err = mutex_lock_killable(&task->signal->cred_guard_mutex); + int err = mutex_lock_killable(&task->signal->exec_update_mutex); if (err) return err; if (!ptrace_may_access(task, PTRACE_MODE_ATTACH_FSCREDS)) { - mutex_unlock(&task->signal->cred_guard_mutex); + mutex_unlock(&task->signal->exec_update_mutex); return -EPERM; } return 0; @@ -415,7 +415,7 @@ static int lock_trace(struct task_struct *task) static void unlock_trace(struct task_struct *task) { - mutex_unlock(&task->signal->cred_guard_mutex); + mutex_unlock(&task->signal->exec_update_mutex); } #ifdef CONFIG_STACKTRACE -- 2.25.1