Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2326476rdb; Fri, 8 Dec 2023 05:12:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IHdJdtJqek3AzeIKWbDbr62U75/OBMa6E+ot/zDB9ncVBStpxzksiwB8I86VKNCPFkrzDqb X-Received: by 2002:a05:6e02:2192:b0:35d:5d80:ff11 with SMTP id j18-20020a056e02219200b0035d5d80ff11mr92268ila.62.1702041156767; Fri, 08 Dec 2023 05:12:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702041156; cv=none; d=google.com; s=arc-20160816; b=J2Ao8YK+EauEzZneR3yhF9i4G/Ie3C1NyNt40eZ7Nse18srWr5zvqBCK/vN33WvYbt ZWWL8qfX9+gSuWWK1/LLio/yuFMnvsBGDpuZQdJ4H5zOveRBEy9LnDnYuvS9B+2nSGut rO9KnrsNIuHQN7VcDRxZX5+i+I6+SLwsMCwzHAjzgPVGGt3/kpcC17TyJp4/ZfjFT7YO ZrwaMmL9UOH9fOT4THXjJy6TFbuLsDdPXsJx73ty0BV2Uii3jYfTCDLaUH8LY+0dKksd gzycQ/PlGYYVb4yHtDgtxoD9cqKFid4ajG7TnteilJzIHwCCSHh1EG2u8gci3bd9Mfa0 KFwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=UCxJLIGCGjLVjiME0iQoROoaxCB4dpgNzUjDCKTgGDE=; fh=jcbvltrZfCjv2GEm7owlpTaYv5e0reVCgcmdzEGNxas=; b=nKcR955SQRJsyjyB4SX0JUwd3wTxLOaa2sYSDXizlLQi5htlTny0xub56HhKiVSj0n f0Ng9uwE78UzbUCkVKfFoAj9LXveJF0fxoxGIKAxZOr6aiaVwBPrWVPOmvxz5xTpQ4vx 4jeonc7AOkBPYEuBGtBXG8fJlmzBJ1ADL8k4DnrV9elfjvKzTqnceS7063BOh4axQ0WQ tCL7dK0/o6VjJ6ZM9+z+hcU5FgCsIDC9zYdW3Z5XDIiAHPN2Nf0U8A33uw52p76xC2ll 4U2vE06jn4YqKnle2hn5rh0+IK0xv2WbTee/PjsilNFEQtdkGpqYZZZ0ZZMzIp9eSciM xYTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tW11Uc29; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id y18-20020a634b12000000b005c6259da621si1503747pga.555.2023.12.08.05.12.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 05:12:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tW11Uc29; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 33D89809E702; Fri, 8 Dec 2023 05:12:35 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233597AbjLHNMZ (ORCPT + 99 others); Fri, 8 Dec 2023 08:12:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229844AbjLHNMX (ORCPT ); Fri, 8 Dec 2023 08:12:23 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40705171F for ; Fri, 8 Dec 2023 05:12:30 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58C6AC433C8; Fri, 8 Dec 2023 13:12:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702041149; bh=LRHKXloa3MmO6SoONfxXn/xJpmyyKAc/mIUHXv6+GMg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tW11Uc298n3GMfqBAAke/uzS7WbHqNqrm5l7/LAA1eYmPWnqBHiGdej+PPvMGhynk coRDgr19TLIFhhi6RaBoqtkSAYKsl98u+Tf/2UH580LCdsmbZ3+TsPT4ZwkYPunoMf 1I1dr5MchgWH1PC+o1HFr5Cxc2fzQfBBkoU1AZmvE0nybp32t0fnP6BAtKF1MyIc/I WcI4oqGHtaKKnpASkzt48/aDUrgrm8wY/Lp3gwmB7X6iVadCH38r8J21InGn8BtUF1 uzgxqpVi4aFJTg5sTTjhV2/zt9nqCEUSqqH+Bh8au7+2yzS+V1Tc0JjdMPFuj0Tnjw kvmeCou1Fl4aQ== Date: Fri, 8 Dec 2023 14:12:25 +0100 From: Christian Brauner To: Adrian Reber Cc: Greg Kroah-Hartman , Jiri Slaby , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: Re: [PATCH] tty: allow TIOCSLCKTRMIOS with CAP_CHECKPOINT_RESTORE Message-ID: <20231208-begibt-besonderen-096761ac8d3b@brauner> References: <20231206134340.7093-1-areber@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20231206134340.7093-1-areber@redhat.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 08 Dec 2023 05:12:35 -0800 (PST) On Wed, Dec 06, 2023 at 02:43:40PM +0100, Adrian Reber wrote: > 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. > > Signed-off-by: Adrian Reber > --- > 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..95d14d7128cc 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 (!capable(CAP_SYS_ADMIN) && !capable(CAP_CHECKPOINT_RESTORE)) In both cases you should be able to use: if (!checkpoint_restore_ns_capable(&init_user_ns)) return -EPERM; with that fixed, Acked-by: Christian Brauner > 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 (!capable(CAP_SYS_ADMIN) && !capable(CAP_CHECKPOINT_RESTORE)) > return -EPERM; > copy_termios_locked(real_tty, &kterm); > if (user_termios_to_kernel_termios_1(&kterm, > > base-commit: 98b1cc82c4affc16f5598d4fa14b1858671b2263 > -- > 2.43.0 >