Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3730726pxb; Mon, 24 Jan 2022 16:34:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJxpfDndbUYOdbu5+udJqNZFODxA9J1ToG75LgTgfWQG5USgi7wOYPr/H10TvF1Rg13xG3AO X-Received: by 2002:a63:595e:: with SMTP id j30mr12472541pgm.487.1643070852423; Mon, 24 Jan 2022 16:34:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643070852; cv=none; d=google.com; s=arc-20160816; b=Lyxb0U2kQVqakjbnAZ5BEYJF0orjznoPpF7dRTGjQz/71FvoBVVgPesXN0YVjVTjU4 6Osa73dKO1pfrqO9pNz3xgtJnuAD9RdLJd5uKFeDWvqDpPcvCyPZSgQTWq+tBePsb8d4 qrl8I72T1iE+f3wbtKm1A+IYMpo1JzEEsi+yYYSMCS8yV22x9L3I4v306b6h3ZIRDEQO Exj+FgEAsZCt0dMfj1Ag2mdIqaF/EsPqILs3ckIBByILFUrxlBVElhFfe6UilLtn686K Za1o5DN6zq5MiVSj7opbsM01GPmxnlBpYggVlOWvnRD7gFuPfw/B0walIv4U9yIDkwPd g0WQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Nzw4X6nFnOyY7YN+BdxtLm2EHOchxh+f91to+Crd7TM=; b=Ji3s9w8+znVWvmywa60ojoTNlENHdoEHFdAzh5XUFXq38dh7n34I4ac4pWRcv2iGk3 rJA0ckNaN4YfymF3gDLCSriS2tN8y1B615NIfTLBgx3SNYmYo3o3zaI6gzXBxrLf06kb DOFyotnVK+/27gd2hzLb/rEuRADn8LEBvyBeul9aNWyq+fRJ+NO3SmCxLfwuEuvDPovV s3KD4IHs6uLWa87C/iBQBjPThz38gg0omaSjT71LOXFUQOglIZLu9VRfjhWGFSFvwxBm q4eOWUbF1/09Xvr6yxuaNOmqsfdNWOIc2F/4VtXIg3Pw4RqD5krG7Co7jrofZ/fbgR3G AyZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VrClL7te; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j9si13903364pgi.638.2022.01.24.16.34.00; Mon, 24 Jan 2022 16:34:12 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=VrClL7te; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354711AbiAYAaw (ORCPT + 99 others); Mon, 24 Jan 2022 19:30:52 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:52320 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1454274AbiAXVcI (ORCPT ); Mon, 24 Jan 2022 16:32:08 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 22BAD614E1; Mon, 24 Jan 2022 21:32:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2FE14C340E4; Mon, 24 Jan 2022 21:32:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059926; bh=Qo14H2WFM8vzQOp8leB6E2PM+33J6T1IeUDHX0WOzv0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VrClL7tev6a3jX4b64q/McsUpZGnPC1Aei3ZLC/RMTnSmkJ5o6S0rQyYhyPqXiSah 6pJU3DHwtd0QljLLrNe5VlSNffASFCw0d9n8OhbHjN5QL9Y8NulFEhNQkbIgR7InQN IyjJlWOz38GpYg9HZEi1TuksnYZ+ChiVDo4VaDkc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kees Cook , "Eric W. Biederman" , Sasha Levin Subject: [PATCH 5.16 0781/1039] signal: In get_signal test for signal_group_exit every time through the loop Date: Mon, 24 Jan 2022 19:42:50 +0100 Message-Id: <20220124184151.539020855@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric W. Biederman [ Upstream commit e7f7c99ba911f56bc338845c1cd72954ba591707 ] Recently while investigating a problem with rr and signals I noticed that siglock is dropped in ptrace_signal and get_signal does not jump to relock. Looking farther to see if the problem is anywhere else I see that do_signal_stop also returns if signal_group_exit is true. I believe that test can now never be true, but it is a bit hard to trace through and be certain. Testing signal_group_exit is not expensive, so move the test for signal_group_exit into the for loop inside of get_signal to ensure the test is never skipped improperly. This has been a potential problem since I added the test for signal_group_exit was added. Fixes: 35634ffa1751 ("signal: Always notice exiting tasks") Reviewed-by: Kees Cook Link: https://lkml.kernel.org/r/875yssekcd.fsf_-_@email.froward.int.ebiederm.org Signed-off-by: "Eric W. Biederman" Signed-off-by: Sasha Levin --- kernel/signal.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/kernel/signal.c b/kernel/signal.c index dfcee3888b00e..cf97b9c4d665a 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2684,19 +2684,19 @@ relock: goto relock; } - /* Has this task already been marked for death? */ - if (signal_group_exit(signal)) { - ksig->info.si_signo = signr = SIGKILL; - sigdelset(¤t->pending.signal, SIGKILL); - trace_signal_deliver(SIGKILL, SEND_SIG_NOINFO, - &sighand->action[SIGKILL - 1]); - recalc_sigpending(); - goto fatal; - } - for (;;) { struct k_sigaction *ka; + /* Has this task already been marked for death? */ + if (signal_group_exit(signal)) { + ksig->info.si_signo = signr = SIGKILL; + sigdelset(¤t->pending.signal, SIGKILL); + trace_signal_deliver(SIGKILL, SEND_SIG_NOINFO, + &sighand->action[SIGKILL - 1]); + recalc_sigpending(); + goto fatal; + } + if (unlikely(current->jobctl & JOBCTL_STOP_PENDING) && do_signal_stop(0)) goto relock; -- 2.34.1