Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp4602687ybh; Tue, 6 Aug 2019 14:40:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwEPawYcYMrYh33tv4IHTjQTM3UF8AKMbLaigxkWcwVqDTVVwSE7knkJPg5GTTG8LmavLBL X-Received: by 2002:a17:902:5ac4:: with SMTP id g4mr5248866plm.80.1565127650690; Tue, 06 Aug 2019 14:40:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565127650; cv=none; d=google.com; s=arc-20160816; b=WrRmF3OgkXQhyleCcMqCbvic/7vZIR2MQijhvAQOH7H5da5t0GWqK45NNCui0WLvuH DUsmxZ7K8pSVNEiom+vVEGNEBIsvSOoUEsd9b0Hnvz3HIXSv35dLY/wl27TarM7BKJFm o9N9KWsEYBhQAVff7TbsyaIX3WKBXvZwqW3MJ2EyjzHTYPpjEevHUTNcUS61sc8XrUEq 546qBPslEcdFdR5a/nKSXNW/WE27ac7rsxR7ve6pxl1msxkda7hqlKsUGvn8Iwlarhmc 2thwwjWt6GRi+yTFUGdvZwDLjYLpc6AxaEnduHKVS/PGSyG+JX6f++KFlzcMiukTzIaA 6H+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=i81q9Fg95HSuBfa4P6Ks9/TF9sZvUfWi4IwlAzRgm4M=; b=yczu73uiMSkutJFFq5nPEx9Ol3WfJKE9AmGAk3jBA57X9rDNvtjuRbUYCRbLXJQIoN mUM8j7dmdzQu65F5cEvKYakHxwiYGlzwBT6mxUjgJPK6hzkq3BpcdJeG62HwGa8LmpaA GoKSZGa46Nbt0xrnCdctwkbC/HhrhtCnN9EoQQUrFSATxgVDo9nBvBbHoOOdS4/NOA7e MlE0DA2XBE3yyQlOdP/9Cocha6HDGrTjCHzMblItnNwBWhdy1Tn6fy3lH9kLveh8bz2b iFBYA3WASDeJ85wX6Dh9l2+/46r5QFskhZPVosODqRSzrF4lQiagScuTR3ln19EGgU8x Kncw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sIC4Hrm4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id h5si45500735pls.280.2019.08.06.14.40.35; Tue, 06 Aug 2019 14:40:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sIC4Hrm4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1729648AbfHFViJ (ORCPT + 99 others); Tue, 6 Aug 2019 17:38:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:55770 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729604AbfHFViG (ORCPT ); Tue, 6 Aug 2019 17:38:06 -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 9A78A20C01; Tue, 6 Aug 2019 21:38:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565127485; bh=OSDZjGF/Qz2AU+ibnMfKOlSobEgeyAk25LXtXkBD0/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sIC4Hrm4Y2b+mH5yJDEVLMA77c6ylNgSUugPw+W+suic9OHrVDjoUTI+zEyAuYlQx u019R9iPJSSUJjDiwfMZdlVeDz7fhuuhlvSHkBfaDu6JL/L+WdsnP49MDD3GbNS+68 UlwWoztCqnxTWBrodu668XvYQ4sZPpJ6W42jo6sI= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Christian Brauner , Oleg Nesterov , Linus Torvalds , Sasha Levin Subject: [PATCH AUTOSEL 4.4 08/14] exit: make setting exit_state consistent Date: Tue, 6 Aug 2019 17:37:42 -0400 Message-Id: <20190806213749.20689-8-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190806213749.20689-1-sashal@kernel.org> References: <20190806213749.20689-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christian Brauner [ Upstream commit 30b692d3b390c6fe78a5064be0c4bbd44a41be59 ] Since commit b191d6491be6 ("pidfd: fix a poll race when setting exit_state") we unconditionally set exit_state to EXIT_ZOMBIE before calling into do_notify_parent(). This was done to eliminate a race when querying exit_state in do_notify_pidfd(). Back then we decided to do the absolute minimal thing to fix this and not touch the rest of the exit_notify() function where exit_state is set. Since this fix has not caused any issues change the setting of exit_state to EXIT_DEAD in the autoreap case to account for the fact hat exit_state is set to EXIT_ZOMBIE unconditionally. This fix was planned but also explicitly requested in [1] and makes the whole code more consistent. /* References */ [1]: https://lore.kernel.org/lkml/CAHk-=wigcxGFR2szue4wavJtH5cYTTeNES=toUBVGsmX0rzX+g@mail.gmail.com Signed-off-by: Christian Brauner Acked-by: Oleg Nesterov Cc: Linus Torvalds Signed-off-by: Sasha Levin --- kernel/exit.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/exit.c b/kernel/exit.c index 03f6722302b54..14c2f0717ee4b 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -619,9 +619,10 @@ static void exit_notify(struct task_struct *tsk, int group_dead) autoreap = true; } - tsk->exit_state = autoreap ? EXIT_DEAD : EXIT_ZOMBIE; - if (tsk->exit_state == EXIT_DEAD) + if (autoreap) { + tsk->exit_state = EXIT_DEAD; list_add(&tsk->ptrace_entry, &dead); + } /* mt-exec, de_thread() is waiting for group leader */ if (unlikely(tsk->signal->notify_count < 0)) -- 2.20.1