Received: by 2002:a05:7412:9c07:b0:fa:6e18:a558 with SMTP id lr7csp779659rdb; Sun, 28 Jan 2024 08:34:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IFc9ITLJ/IgGYRwkZUSoheZMLz3elROxQj44ld0ODokvTc5wFB5nwBcMr3tFp7UkLD1+8sZ X-Received: by 2002:a2e:9606:0:b0:2cf:2d7d:e7d7 with SMTP id v6-20020a2e9606000000b002cf2d7de7d7mr1903328ljh.46.1706459680550; Sun, 28 Jan 2024 08:34:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706459680; cv=pass; d=google.com; s=arc-20160816; b=wST9jdU+e0V5OR73tQcA97RdNXgYimy9miyGlTeCmiWOlNP1xwoAPibzV0UDGppEzq 63N+/0sLXJVNG+GnjMszigtZtVfw5UQXWQyix7QWZ6AocijDrCfTA9oQw99P8lDBQKKJ V2m+COEvG+fwbD3b3BkJaRLfgJ/jj0hAhNzjE7e01WU3Df+dFrtP7JxEve40kR6XcOBa hCGm1GnZQfaB61Z/ti1lFRHxxuOgorTHqbuI6/HINN/ZqvP4ebHQDH0IQnchJEbUQWFn +ctqoJ0Ny/RlELwFuYqNrpHDGiiC8mnBuQfhIxFcKqxeXfULKnwonvLS+Q10aXXVDBEk 6J5Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=JfQsq+quYMJQyv0+AslCHs3Zcndlwq65M3SeM3Drq8M=; fh=nFhKLwmSKnQ9KLoYDpiPdMc9Ywd5CM3LEuMkctOqa9o=; b=bkyPOnQD3mIu9jIiKlgQ9aHY9erI1VW8qioXFzwm/ZD0xyA0tJLUwMNRjArT0mrk6I MMbGgIwjMPINs7DncWS5rs6N81W0TwOLGj/qsrp049+5KB8BbnPv3onCCeO6aLN7jnat NmIiNf34lDOdMD/hdtuKrgQgGXl2+xd9NRVw8TnBHyg/7hvHYgaVLDqN17Gv3/1fQXNg YWLxiZmYJdkj11iKotOBB+CZNN3N02D4drX83cBAAgmhLgltJnUInqyt+6YyIRQq3EpW GgOX6t0xNywoLPJjC2Dj0aHqJPVolmeVfbKKAJmnwiFPlnEy3QeUY4SUJmVy3IUYbcbI HyqQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="fayOrCW/"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-41763-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41763-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id n13-20020a056402514d00b0055c0e98881dsi2563404edd.347.2024.01.28.08.34.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 08:34:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41763-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="fayOrCW/"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-41763-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41763-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3320F1F23A5F for ; Sun, 28 Jan 2024 16:33:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 83EF06D1C1; Sun, 28 Jan 2024 16:14:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fayOrCW/" 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 A2F006D1A7; Sun, 28 Jan 2024 16:14:40 +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=1706458480; cv=none; b=hXvsuJwNiNDImGgn0ghqeKrHKJWHEkXaxeN0/D6xO02mEGgNy5C560epF6IlX+a9MbmT4AtH2IdIQXN5ucJZVPDiVYZGKxrkBUwot7oOu8TpYqlKYLogPrFoERrEd3tr6RF4yFC3I80Y5F/aHji+UfgWvYdUFx68idT7uHMExEc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706458480; c=relaxed/simple; bh=t/oLxMaAwbqU9K66T9Ia3Kt9Jt0nznQv+B09sf5KI/M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lO/ekNFwH8oi8b0bSOtVXxkxw9tflAN/ALdg2jV1ZJywzV9ccY8QHJR+AskWqN7BrlGviGjAUTLwQlszojAX1Ex7YR7fpQLHyphs+FAiKwZpvzyvO+ny3hDX8LMaGOIf2sN8k+9P4gcgMw/D8/W/PtaP2WL6fHf5dWIk0Ky/aCk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fayOrCW/; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FCD8C433A6; Sun, 28 Jan 2024 16:14:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706458480; bh=t/oLxMaAwbqU9K66T9Ia3Kt9Jt0nznQv+B09sf5KI/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fayOrCW/zVfWobUC4MWSLxwMyU9LwWWDOkh2mDDjbs7KLwEM470MK3lyBMxHtmF9q IElLqqmrAUl28EFTiwxTijGL+yOcfqYWirWiAk6vZQArtULaNj9IvurpdazMQLIbMZ uxssi7JZMl7Zy+uQ0JzGYv9WjSEc/aVUu9XnEhlEdxzT28JWFviNkDqxZawHHmpmpi q9Wj0oGFw9cqh9sec2UMm9ZRPEzhwCQEcmoVSIWlr4RzZmwSpIWg7i1ST9fFI1W9ao 9o3JzxQrm0IAqE7kmcmRKrjcIEw0irdMpmN3TVjABdEoiY/GQj34DMIAIuwxPnI+pT 9KRdgZ5sbm2eA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Adrian Reber , Christian Brauner , Andrei Vagin , Greg Kroah-Hartman , Sasha Levin , jirislaby@kernel.org, linux-serial@vger.kernel.org Subject: [PATCH AUTOSEL 6.1 08/27] tty: allow TIOCSLCKTRMIOS with CAP_CHECKPOINT_RESTORE Date: Sun, 28 Jan 2024 11:13:53 -0500 Message-ID: <20240128161424.203600-8-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240128161424.203600-1-sashal@kernel.org> References: <20240128161424.203600-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.75 Content-Transfer-Encoding: 8bit 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 ad1cf51ecd11..41004720d4ae 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