Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1329409pxb; Fri, 26 Feb 2021 08:08:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJzwY6Fz9UVbGi1f60CHnNbfodd8wPSGcM/Z0A7dSDXH0YzeAeQ6O6uX8TUjX8S2JO2eZPhZ X-Received: by 2002:a17:907:7667:: with SMTP id kk7mr4248682ejc.92.1614355731579; Fri, 26 Feb 2021 08:08:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614355731; cv=none; d=google.com; s=arc-20160816; b=jv6sATlhqrlwX4ADWcwdt+88pwunGEIU8iO+j9Oc8ddzc6fk4fGWOZCe0683m6LQLH n+9EZIZjqBmNGvNacX7err6xg+SYck03plWSspsZpiX9JXcZVdmGeOvNxj1/J4uh9z1B QP7LDUKE4PRlfWzX1v7EWtIHNSksX1PZg+Yak8RQzX60jfkKhtIS4/o2Zo/67V6W5eD8 cExJWeSzNPdGwIPmO/QcghqZawffXErUCSLMGM4lHuGMH+80juuu7CqsiJTildov809p LI0Wmi3ikFvLxxNsv0D8JTSjljST98/ENC98eS3Cy5vAmgKcn/r9zbyCFCiM6FBOf//a 9EXw== 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=LRtnaW8ESBx8mz0zl8Zlp4mDQWaA0l9/JAzTiZqdgXo=; b=haIJ5kR2YOd6NhZs2p38ccKGeghszRCMTnjJzZQkY46tSycApchH9tp06ngJVyaVV/ Ta4PehorrbC3FyeDM/tbyHlrsgps980l9DpTkCn3XzObPSdCVI/Q8l3t3ZbROjGsP3PW h944dMlbvPs6PwawcSyE7q6W09VuNbsgRSbrNgkAzLP7c+SEluMpjkK4Zf+dJqAxVNdx SLlL/cCjPY0xjjpW/nwj7PKNA8ulM5c6SKH/aqv/OkJ2YU78jkQmuu8/P2hZDvOXIdWi 6WlQ3GJkn2PNQWJ+ioRUGVomitx6FkXie4HdmlClOKMjgKbjN/6idowdFl6FlapO5Z6w NdPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TENfYMN3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b4si6297513edk.452.2021.02.26.08.08.25; Fri, 26 Feb 2021 08:08:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TENfYMN3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230014AbhBZQHW (ORCPT + 99 others); Fri, 26 Feb 2021 11:07:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229993AbhBZQHU (ORCPT ); Fri, 26 Feb 2021 11:07:20 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2DA7C061756 for ; Fri, 26 Feb 2021 08:06:37 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id gt32so4174678ejc.6 for ; Fri, 26 Feb 2021 08:06:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=LRtnaW8ESBx8mz0zl8Zlp4mDQWaA0l9/JAzTiZqdgXo=; b=TENfYMN3K/60bIA9hdk3HBlrwOStMfGzsOtvoq7XAxQeKlmCq3EZFj6JcjTN9FnvzI hbTMXnNvqi3qCjsoE2+VCWPPZs/PCLINjLXoeiUsUXR52XGAMMSsFibwKVtn+MUvD01J XmFAVmk+a4Rg4Nq+vuZLgueKB0VqjjEWLrwMtBGtTkj7XGi0Fu4R7qFYb4pNA4MM1+nR UgwzubE3myh0lDe00ntrCG2HdWUiq59J6r23xVyEnTEAp2wv7Z7NbuYC0SAlWuJaX618 xI9/Sy4pn9p1jj+P4gYnrdakH91m156WS2bX3gbO+VC3fOhh1ubvRSlLE/PQ4S5FxQej 8XqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=LRtnaW8ESBx8mz0zl8Zlp4mDQWaA0l9/JAzTiZqdgXo=; b=VawCE5ewY84x3JcSZgpu6LE2cPjEPCL7Cb+RSdMqQ6sNJpix8oYtJWPHjNFXoITqad 72fBxWbv6W9bTuS29he7aSltRq8K5Pm3GGWQwsVDM4GXLEDdfMAwW3Ow7DeNsaVKz4M4 hHVY1uQk/hI5kLny2R6PNcqqmNdDbq74WgH29iwSdwX0mfQ3/EgHudO8oNG2ayt5RyAz Dr4vowYlMhfYDywrQuwXm0iFt0ukhdM0Fad/qcFVCB2N4sgoc7thaSaOKL2ujpWzw2ZX TRN/E87XmnWRrO+akmaCStKH8DC2sDq5Hwq54P4ynBu8t3GQMJ3X4KqTbCeVLw7okTMD 4zOw== X-Gm-Message-State: AOAM532xpZKnOMyLaZTk9HonM2o2TdQZEULBzhYptWYRPAAwLuS2fUiy A9C+snTF4QOJ2RD4tezdqZsHdw== X-Received: by 2002:a17:906:d0d2:: with SMTP id bq18mr4127007ejb.109.1614355596393; Fri, 26 Feb 2021 08:06:36 -0800 (PST) Received: from google.com ([2a00:79e0:2:11:d0b1:99e6:bf05:21bb]) by smtp.gmail.com with ESMTPSA id ap14sm5666473ejc.13.2021.02.26.08.06.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Feb 2021 08:06:35 -0800 (PST) Date: Fri, 26 Feb 2021 17:06:29 +0100 From: Piotr Figiel To: Mathieu Desnoyers Cc: Andrew Morton , Peter Zijlstra , paulmck , Boqun Feng , Oleg Nesterov , "Dmitry V. Levin" , Florian Weimer , Alexey Dobriyan , Andrei Vagin , linux-kernel , Peter Oskolkov , Kamil Yurtsever , Chris Kennelly , Paul Turner , emmir , linux-man , linux-api Subject: Re: [PATCH v2] ptrace: add PTRACE_GET_RSEQ_CONFIGURATION request Message-ID: References: <20210226135156.1081606-1-figiel@google.com> <192824546.8190.1614353555831.JavaMail.zimbra@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <192824546.8190.1614353555831.JavaMail.zimbra@efficios.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Fri, Feb 26, 2021 at 10:32:35AM -0500, Mathieu Desnoyers wrote: > > +static long ptrace_get_rseq_configuration(struct task_struct *task, > > + unsigned long size, void __user *data) > > +{ > > + struct ptrace_rseq_configuration conf = { > > + .rseq_abi_pointer = (u64)(uintptr_t)task->rseq, > > + .rseq_abi_size = sizeof(*task->rseq), > > + .signature = task->rseq_sig, > > + .flags = 0, > > + }; > > + > > + size = min_t(unsigned long, size, sizeof(conf)); > > + if (copy_to_user(data, &conf, size)) > > + return -EFAULT; > > + return sizeof(conf); > > +} > > I think what Florian was after would be: > > struct ptrace_rseq_configuration { > __u32 size; /* size of struct ptrace_rseq_configuration */ > __u32 flags; > __u64 rseq_abi_pointer; > __u32 signature; > __u32 pad; > }; > > where: > > .size = sizeof(struct ptrace_rseq_configuration), > > This way, the configuration structure can be expanded in the future. The > rseq ABI structure is by definition fixed-size, so there is no point in > having its size here. Still rseq syscall accepts the rseq ABI structure size as a paremeter. I think this way the information returned from ptrace is consistent with the userspace view of the rseq state and allows expansion in case the ABI structure would have to be extended (in spite of it's current definition). The configuration structure still can be expanded as its size is reported to userspace as return value from the request (in line with Dmitry's comments). Best regards, Piotr.