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 4991918622; Sat, 3 Feb 2024 04:10:34 +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=1706933434; cv=none; b=MnI7y17iK1l1k2qa60nIgiMGFwTzLJLsEu+ZYVvURm61Ej4Wxqea7DDSJWsCr2W/5kzczi4saVlHdcCo/oB8cmTiDWZiTQiA/kXld24EZGXkY/nsU8xsLX8PqqzqBJYpDFsKwgoLqGabU+Nk4e+G6LzKDZOpxhbJHJ+ZJsmvw2c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706933434; c=relaxed/simple; bh=0iH1ZDr4agu+A1J/3RuqZq6MlHthprQNoFLeF5BEZm0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BIM2Rcm4VsMZk+aMIuTT/BdmZ6IiP/Cqd5lSu822+h5EmHkUK3dgCqHw/f76TFOHZfmG8Go5JABWij19dwhBlnH3Liv9rnF5AkozaUiXkCZJxF+pWaS9oEB8FnaaAutgddRgwucm+p7jlMqMKQCD+8DdT3wTEQttu9Om8CeNdIw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=2pTtFS3x; 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="2pTtFS3x" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CE27C433C7; Sat, 3 Feb 2024 04:10:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1706933434; bh=0iH1ZDr4agu+A1J/3RuqZq6MlHthprQNoFLeF5BEZm0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2pTtFS3xozdMKTQ2Sthh2m5ylu1JN1MOqKh/IBwEFWg8j2cvlukOKBavjeHsWYs6n B+BrUtWt51iy4fLciaz8+ztT6nyt7s6F6buhGDBOsJ8AXq2gzXTavKjcpEuhMGR2/3 9i+JY8QT+yJM4Ozqg4rC34ym477jv0QdLmwRx+p0= 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.1 163/219] tty: allow TIOCSLCKTRMIOS with CAP_CHECKPOINT_RESTORE Date: Fri, 2 Feb 2024 20:05:36 -0800 Message-ID: <20240203035339.418628344@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240203035317.354186483@linuxfoundation.org> References: <20240203035317.354186483@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.1-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 8767c504b95d..9d3b237304ea 100644 --- a/drivers/tty/tty_ioctl.c +++ b/drivers/tty/tty_ioctl.c @@ -859,7 +859,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, @@ -876,7 +876,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