From patchwork Tue Sep 29 10:58:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 263134 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 274F7C4727C for ; Tue, 29 Sep 2020 12:03:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D454A2074B for ; Tue, 29 Sep 2020 12:03:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601381008; bh=6h2dBenQ50K3IFjlwte/EwE+N6avJPpgBmGXxDM0h9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=NjLAQnC+gOezgLG6iV0z11xTWG9vdgwHypPhqT0q5Sfn7O6f5ze6egHkTge3K2M0Y /Kth/NU1GmXrEM1InfbGvI4eAmasNBQsnVJNjT/SJAOX7xM0QgloEJ/N10N6uAgiKM SDE+GeZ4wVQ1bwoOurq0tSUfd3X6PIE2iB2/CAUs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731680AbgI2MD2 (ORCPT ); Tue, 29 Sep 2020 08:03:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:60238 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728186AbgI2Lie (ORCPT ); Tue, 29 Sep 2020 07:38:34 -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 CBF9B206E5; Tue, 29 Sep 2020 11:38:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601379512; bh=6h2dBenQ50K3IFjlwte/EwE+N6avJPpgBmGXxDM0h9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1Qpda1tnWItF0txGoYLA6HUQ1a6SkHuTT4UIb0GYWCWCiOK39pRP/n6RwQB6JbURX h6UT/+Y8VibHonUmx4VFCVrzW2iLeStCaE5i3ptH7Bvxohf86yvFga/ovBweLG+87X NKA+8uN+88aP2cy7VYJIb33KcAL6tdca9Wrt613c= 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 197/388] proc: io_accounting: Use new infrastructure to fix deadlocks in execve Date: Tue, 29 Sep 2020 12:58:48 +0200 Message-Id: <20200929110020.016764274@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 76518d3798855242817e8a8ed76b2d72f4415624 ] This changes do_io_accounting to use the new exec_update_mutex instead of cred_guard_mutex. This fixes possible deadlocks when the trace is accessing /proc/$pid/io for instance. This should be safe, as the credentials are only used for reading. Signed-off-by: Bernd Edlinger Signed-off-by: Eric W. Biederman Signed-off-by: Sasha Levin --- fs/proc/base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index 4fdfe4faa74ee..529d0c6ec6f9c 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2770,7 +2770,7 @@ static int do_io_accounting(struct task_struct *task, struct seq_file *m, int wh unsigned long flags; int result; - result = mutex_lock_killable(&task->signal->cred_guard_mutex); + result = mutex_lock_killable(&task->signal->exec_update_mutex); if (result) return result; @@ -2806,7 +2806,7 @@ static int do_io_accounting(struct task_struct *task, struct seq_file *m, int wh result = 0; out_unlock: - mutex_unlock(&task->signal->cred_guard_mutex); + mutex_unlock(&task->signal->exec_update_mutex); return result; }