Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3614725rwb; Fri, 20 Jan 2023 20:03:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXs1dY/PCPBkCU6mUQ64O0zG1NUfGas9Bg1PAyH4QLumL5bFB/ppBYZBS5di41Y24VxWvJGs X-Received: by 2002:a17:906:ddb:b0:7b2:757a:1411 with SMTP id p27-20020a1709060ddb00b007b2757a1411mr27780235eji.9.1674273817671; Fri, 20 Jan 2023 20:03:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674273817; cv=pass; d=google.com; s=arc-20160816; b=SfyFgz6bn9Nk809HkG4KZ0poVi5iDBZllfki1w2lPXuc/fndX6hAkeHSWfiyCJ5O+r OkhxQA7BHGzqZopydk5JtPQnElX+Hkd9TavbZ13Jb2di2csEgyoJ9SzU4dx6W00nuGCp 1xBj7wQO1F6GpaXQIiTwnkmsFNwyhkhdgoxFGCuTAq2IrX0lvSofZiyVwrEcT1rD2+vH dQlJ7otJKl0Nhfdnw+V+6QQUGjPAByOWvihUS+c7UkKl7YLEuI7mk6buxDKrVaV4QlX3 EXv7J7gc348OZWvfDvWMCC3jyaiyvc2vyy/VZIYPbADRPBIU45SG++M15zcy1XKEESu/ frgw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=KBgeGfn5mAfqmfSvzmRlgN7H6tUWWIJCcEONlOXDIgk=; b=WIahNbCUlMaB4QdZ7QBRbZ+BLfjFhJXhcbonPUymPU0bSob679dclp96yLPbAIITcv kr2guynuDcQQ33VhEchSHoE0XCXQHRbyosCAhStn1piMWyp3euXmpcTRx8h1mnmresHT 0gomr2OpNthrDLKk8ZiWStFKGOhs74OmlRYpr/u3G4/EHCx0yRvXmoQDQNBG0acYR5jL NHfetAG/UfMqTdub8x3cNGuZbjEX6/cc7jFU6B8mzH69+0WG8RA7jVucZzmfiFabEN5g VnOTcL7S45VsY7SlP8Xq/WLdrLds9JkWualDrzprrGU+w7DmnvYixICustt4dugN4Mr0 Gw9w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@memverge.com header.s=selector2 header.b=teG3t4iY; arc=pass (i=1 spf=pass spfdomain=memverge.com dkim=pass dkdomain=memverge.com dmarc=pass fromdomain=memverge.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=memverge.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cr16-20020a170906d55000b00870b95fb7c4si22115827ejc.998.2023.01.20.20.03.25; Fri, 20 Jan 2023 20:03:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@memverge.com header.s=selector2 header.b=teG3t4iY; arc=pass (i=1 spf=pass spfdomain=memverge.com dkim=pass dkdomain=memverge.com dmarc=pass fromdomain=memverge.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=memverge.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229553AbjAUD1W (ORCPT + 50 others); Fri, 20 Jan 2023 22:27:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjAUD1V (ORCPT ); Fri, 20 Jan 2023 22:27:21 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A824B1B541; Fri, 20 Jan 2023 19:27:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GDdH3tkLSqkrLKA2MTLojaAqjRy6y8CbiolI8qlwESmdpZStBkPzYQ2bF5r6vOtH2McVs4ZsmaUI3E/Riwp4sGzTnhVtY/OHqH8C8pQQSSHgPEjYbPMX3AxD+9NPPZ9Gz4lJA61zBbswbK/z2yQbh32SXsLQXbYCEtQc1TkEeQdiVin3R/dxblTuYfHValU2qZKP2qzWo5Mia9Gw/9D500CqnbkYiRiz8XxZllrpXAob71Bf8WfS14ch52P57kbXwkZJ4z1bNS76b7HBOrOt+ilkxE4WBn4iX0q+/zYtC2HvgsseGQaT8myG9AyMmk85hwHGCDNIP42n4GGZGEnBGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KBgeGfn5mAfqmfSvzmRlgN7H6tUWWIJCcEONlOXDIgk=; b=TzUBVB450XHG62eYvuNriRVbILrofGv6diXYtdQUvsoOWV5nyx1UKWI9wg1LPN81xirshCatmG2CWlc4BAvWLgFZV0f2rkep3nCFx+OAg5EUXTiYftRJz6kz6T6KQFAooAIwEvyzH0Qqb8KlIbLXYLMQjjWq+JLuESAeR+hM7meVC2LO/kbbp4Rs2FjD4s4zxIJMyF7SWlL8/bzCTcGxRdR/hAOCqLA0NRQrTokSJ2h8UKlATBd6gH+ILuIVz/yYntW4SxPAG440XjZAk2/M4sA46w9tzbggqgaLm81KMVbXG76Wpip3lM3Rm3XD21qmrn1z+Lp4CZXalHps25Gzbw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=memverge.com; dmarc=pass action=none header.from=memverge.com; dkim=pass header.d=memverge.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=memverge.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KBgeGfn5mAfqmfSvzmRlgN7H6tUWWIJCcEONlOXDIgk=; b=teG3t4iYOC4iS7FHq5Qe83tXniQ8FODDUZfu7EVGVLy/vkF7WXpuVRrxc9I1vw0nmvvQ3qxIpCB6qrXlbebyD9GxqqRtJNDjM5FFcU1fawlhdxH3tBs+Qr0wHzTjffCa37qu45gSMOzmWlEkWnNC0QkgnCbP6fzw03MSX//S01I= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=memverge.com; Received: from BN6PR17MB3121.namprd17.prod.outlook.com (2603:10b6:405:7c::19) by DM4PR17MB5948.namprd17.prod.outlook.com (2603:10b6:8:53::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Sat, 21 Jan 2023 03:27:17 +0000 Received: from BN6PR17MB3121.namprd17.prod.outlook.com ([fe80::d253:1eb3:9347:c660]) by BN6PR17MB3121.namprd17.prod.outlook.com ([fe80::d253:1eb3:9347:c660%4]) with mapi id 15.20.6002.027; Sat, 21 Jan 2023 03:27:17 +0000 Date: Fri, 20 Jan 2023 22:27:14 -0500 From: Gregory Price To: Andrei Vagin Cc: Gregory Price , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, krisman@collabora.com, tglx@linutronix.de, luto@kernel.org, oleg@redhat.com, peterz@infradead.org, ebiederm@xmission.com, akpm@linux-foundation.org, adobriyan@gmail.com, corbet@lwn.net, shuah@kernel.org Subject: Re: [PATCH v3 3/3] ptrace,syscall_user_dispatch: add a getter/setter for sud configuration Message-ID: References: <20230120144356.40717-1-gregory.price@memverge.com> <20230120144356.40717-4-gregory.price@memverge.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: MN2PR20CA0005.namprd20.prod.outlook.com (2603:10b6:208:e8::18) To BN6PR17MB3121.namprd17.prod.outlook.com (2603:10b6:405:7c::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN6PR17MB3121:EE_|DM4PR17MB5948:EE_ X-MS-Office365-Filtering-Correlation-Id: a5bbcf58-e2e6-41dc-7cd3-08dafb5f656c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8XIL0krENnKtUfzKAztwrZBZPuORXABty9grp1AfW/uL/wmR3WSy6TvEBuvh7QiNJEqjfoEi8G8Tx404eyqLtjDm+LIQQ4rC9H3yRI2Gv9Mq9n7umr7AfJIPUmn2B94iwQ9fSmQq0t6/xd77+e35UtZFC9eTxo2DlgmAEAGwAvcxu/9gd1j+43CYDU/4EShf1hBXoLAuggqTkGWoJQ4V5wmTWI7DlQyXGRhhAEeplz/FpE5t8FY/U8zHMdG7KyWW2wJDKxe/s7CV76lyNm/p3Ii56uy2JWfS9WYdl2M6ZqxGo2fjs56JVi9QL8h2rwyiLii0HuGOk9uP5qHEzgSsXQtcdDnLHwUEMu7CFaCOlJTaRlS8nyo8SQJOAgclpbCSF8Wq4ZTeYHbPYzjPptzp9VAmB8r2CiK/SZ4ViBscjYpcBMWlKxzRLMvqVDxlRQp3TvFL8vSuw+aK321o7wMG8u/4o8lRRSSb/bbyR6KxPqN3W7RoW9VoeaWaQLQ3ygD5XFaxS7Og3Hnpl9uR+NHYpcR5TQ5fP9vaEds9JD4QfRo4evrYxc1EpkF4cvP59YRyycOp3sVcn7d6a6UVAyl2c8ZJUR73IqMfuxHP6zQtoDCPJ5nw/0QPSRFYnzawEtFBlLtGSn4bzO7xloi6yPS2xw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN6PR17MB3121.namprd17.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(39840400004)(396003)(376002)(136003)(346002)(451199015)(38100700002)(4326008)(66556008)(2906002)(478600001)(66476007)(86362001)(8936002)(66946007)(5660300002)(44832011)(7416002)(8676002)(6512007)(2616005)(186003)(26005)(83380400001)(6666004)(316002)(6486002)(6506007)(53546011)(36756003)(6916009)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?V0InV0gR8SHKGTRR65Ti5Z/grM7DDYVB8M/axCAUU0rBQy0R+mMvcQoukXm+?= =?us-ascii?Q?1gS7k+V2OAEYcBBmtoHEc7vNaLZnuYO1mwKXYNvcQ9ygO4bE4KqMrrtSrcxi?= =?us-ascii?Q?14msJD1aTSLGiCN64tM2vj3gifAslr9BdGIxnnYuPkF2ewBql2KBWp3P+Dgf?= =?us-ascii?Q?2UBmX7zsnhw+qsWvvMvkLrp0NuuEVIpFI9CJNI027kQ+HzNxx513Svvdvk5d?= =?us-ascii?Q?KLC0Cfxpx+UZiddNtASLv2/66JkH5MgkZDvjkIm9IpBgQt1Wm+AxVs80A3Xs?= =?us-ascii?Q?HyhxJsRZOP+2lB7f5oO+wkyOdr0q7lsiG45uLChwW2K5TOa9Pio5vkqQriSi?= =?us-ascii?Q?t1JVqMBSzHppX2UmjLWwUaC8nUc3svAB6eokZCMVbTAdZ7d+LOcsjnIbwiok?= =?us-ascii?Q?H7nknv5yPv705kPYW6d9g6RjGvvm8uR2gH4GhKB+dESTXg2yS81ldGDyIAPy?= =?us-ascii?Q?+0FvqliG+68L9qkGWvPJ9YCENwYD5lZBFaHltbuAyujbE0b8fN2TzoEiHqlA?= =?us-ascii?Q?93zozwW73h2A2s6LIjk+dMiTYKUGwMHkTA7ditFCr/Yri9Amkdyz3/vehJHN?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yMA8OeWJXx98qLIA+?= =?us-ascii?Q?/Ssbq20zYuFUJUVVY2YJHSsBqYVxHi6EU165y14lDfH+HVejv1hqgQlXXx3v?= =?us-ascii?Q?Z4l/uZLyklJGTRhZDanmJyzYEDMA2i2xdUBD9N/CF688h4y8zGpm21cSRo++?= =?us-ascii?Q?/A=3D=3D?= X-OriginatorOrg: memverge.com X-MS-Exchange-CrossTenant-Network-Message-Id: a5bbcf58-e2e6-41dc-7cd3-08dafb5f656c X-MS-Exchange-CrossTenant-AuthSource: BN6PR17MB3121.namprd17.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2023 03:27:17.0919 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5c90cb59-37e7-4c81-9c07-00473d5fb682 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rHuty7KCxBbyo2uP4xkvkfDnPHYwCCGgkO+6P8r6wx31RmvZ1t6tGZdwVukBuQ+yJUjVwpqlDt4lI/+x2Ker0bCCU7r022INFUsH0kZcx3U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR17MB5948 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no 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 On Fri, Jan 20, 2023 at 07:18:49PM -0800, Andrei Vagin wrote: > On Fri, Jan 20, 2023 at 7:05 AM Gregory Price wrote: > > > > Implement ptrace getter/setter interface for syscall user dispatch. > > > > Presently, these settings are write-only via prctl, making it impossible > > to implement transparent checkpoint (coordination with the software is > > required). > > > > This is modeled after a similar interface for SECCOMP, which can have > > its configuration dumped by ptrace for software like CRIU. > > > > Signed-off-by: Gregory Price > > --- > > .../admin-guide/syscall-user-dispatch.rst | 5 +- > > include/linux/syscall_user_dispatch.h | 19 +++++++ > > include/uapi/linux/ptrace.h | 10 ++++ > > kernel/entry/syscall_user_dispatch.c | 49 +++++++++++++++++++ > > kernel/ptrace.c | 9 ++++ > > 5 files changed, 91 insertions(+), 1 deletion(-) > > > > diff --git a/Documentation/admin-guide/syscall-user-dispatch.rst b/Documentation/admin-guide/syscall-user-dispatch.rst > > index 60314953c728..a23ae21a1d5b 100644 > > --- a/Documentation/admin-guide/syscall-user-dispatch.rst > > +++ b/Documentation/admin-guide/syscall-user-dispatch.rst > > > > > + > > +int syscall_user_dispatch_get_config(struct task_struct *task, unsigned long size, > > + void __user *data) > > +{ > > + struct syscall_user_dispatch *sd = &task->syscall_dispatch; > > + struct syscall_user_dispatch_config config; > > + > > + if (size != sizeof(struct syscall_user_dispatch_config)) > > + return -EINVAL; > > + > > + if (sd->selector) { > > + config.mode = PR_SYS_DISPATCH_ON; > > + config.offset = sd->offset; > > + config.len = sd->len; > > + config.selector = sd->selector; > > + config.on_dispatch = sd->on_dispatch; > > + } else { > > This doesn't look right for me. selector is optional and if it is 0, > it doesn't mean that > mode is PR_SYS_DISPATCH_OFF, does it? > > > + config.mode = PR_SYS_DISPATCH_OFF; > > + config.offset = 0; > > + config.len = 0; > > + config.selector = NULL; > > + config.on_dispatch = false; > > + } > > + if (copy_to_user(data, &config, sizeof(config))) > > + return -EFAULT; > > + > > + return 0; > > +} > > + Hm. Right you are. I suppose I should change this to checking offset instead. Will need to validate the fields are correctly cleared on disable and on task allocate (i presume this is true). Otherwise it might behoove us to actually add a state field. Thank you, i'll push an update tomorrow. I also need change patch 2/3 as well.