From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACDEC28DC4; Sat, 3 Feb 2024 04:18:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706933926; cv=none; b=aTo0OaR2fYcrMZtpMPNJeReA0o80PcNeGmu9FLq0wsJdz0RVkm2lFXfGgGpSfRFLwJoOtOU6a9V9kif3WX6WvWZrB2K1mWmPi9benlLlPFQnkbl7WoeNTqS0wyXMH1adMe55TSqSCnxUJenwxPeMWVFr0S9R+HkBwtgHZJijbTA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706933926; c=relaxed/simple; bh=BQyJIO+u++EoYuUUb/QBdz9NADOZwSrZx9rQKi+YIco=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ub/JT2hGydqIY1YpnUU8D2KIes0+m6cCMPhTk4teX3u+cly8jBf81ddNiBMcTMqmZPXsDQPqhsCpT+u5wGI594/Z7uVBpa/u/QSwwq6pqkZZYlVlwO4je4fO4vk+y/Jiguj7im0OstmKvco4gT4cgIMrhms953HqUixmWcFftxM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kWWWDttT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="kWWWDttT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7498EC433C7; Sat, 3 Feb 2024 04:18:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1706933926; bh=BQyJIO+u++EoYuUUb/QBdz9NADOZwSrZx9rQKi+YIco=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kWWWDttTDUTGNQaLfaadFbnpwLCcuUzzhtffQEOLybfaEHE7SGDb8pG52lUHVD/4s qHTrCKQWbjVLoflH9eUWH6ULghd7gkctutibKn4JSV7NAMEv2UJK64q4OHoNea6dXF KZk4lUtDZalYvUZOi/CWTCB2mhBvWE81KwhRC1FQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Christian Brauner , Adrian Reber , Andrei Vagin , Sasha Levin Subject: [PATCH 6.7 258/353] tty: allow TIOCSLCKTRMIOS with CAP_CHECKPOINT_RESTORE Date: Fri, 2 Feb 2024 20:06:16 -0800 Message-ID: <20240203035411.904517191@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240203035403.657508530@linuxfoundation.org> References: <20240203035403.657508530@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.7-stable review patch. If anyone has any objections, please let me know. ------------------ From: Adrian Reber [ Upstream commit e0f25b8992345aa5f113da2815f5add98738c611 ] The capability CAP_CHECKPOINT_RESTORE was introduced to allow non-root users to checkpoint and restore processes as non-root with CRIU. This change extends CAP_CHECKPOINT_RESTORE to enable the CRIU option '--shell-job' as non-root. CRIU's man-page describes the '--shell-job' option like this: Allow one to dump shell jobs. This implies the restored task will inherit session and process group ID from the criu itself. This option also allows to migrate a single external tty connection, to migrate applications like top. TIOCSLCKTRMIOS can only be done if the process has CAP_SYS_ADMIN and this change extends it to CAP_SYS_ADMIN or CAP_CHECKPOINT_RESTORE. With this change it is possible to checkpoint and restore processes which have a tty connection as non-root if CAP_CHECKPOINT_RESTORE is set. Acked-by: Christian Brauner Signed-off-by: Adrian Reber Acked-by: Andrei Vagin Link: https://lore.kernel.org/r/20231208143656.1019-1-areber@redhat.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/tty_ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c index 4b499301a3db..85de90eebc7b 100644 --- a/drivers/tty/tty_ioctl.c +++ b/drivers/tty/tty_ioctl.c @@ -844,7 +844,7 @@ int tty_mode_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) ret = -EFAULT; return ret; case TIOCSLCKTRMIOS: - if (!capable(CAP_SYS_ADMIN)) + if (!checkpoint_restore_ns_capable(&init_user_ns)) return -EPERM; copy_termios_locked(real_tty, &kterm); if (user_termios_to_kernel_termios(&kterm, @@ -861,7 +861,7 @@ int tty_mode_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) ret = -EFAULT; return ret; case TIOCSLCKTRMIOS: - if (!capable(CAP_SYS_ADMIN)) + if (!checkpoint_restore_ns_capable(&init_user_ns)) return -EPERM; copy_termios_locked(real_tty, &kterm); if (user_termios_to_kernel_termios_1(&kterm, -- 2.43.0