Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2235545pxf; Sat, 27 Mar 2021 06:07:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0KOvuct2o30ptcbfOiCW0+lxUj+VO6hb0mTynEvg43I3S1GtY3yUyNVbkQfY6HK0TeUI3 X-Received: by 2002:a17:906:f283:: with SMTP id gu3mr20004397ejb.91.1616850475871; Sat, 27 Mar 2021 06:07:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616850475; cv=none; d=google.com; s=arc-20160816; b=jYNzToYVSsx8CRyL/5l8eKwF+yDGSYa26h+u+dM7KmHzEL8Fmu31MYfKrqVQWtBq8i 1460K50+yNjMWnVXv4Mvuq4SHu65S+Crg1oNEyCrPEacsKGEJGOexAsKElSYbDCKIxdm hlzt2u/A/CGkJxtuXiNGBf5Dw/1BUlxeazKB52lCs2X5ho2cknJ69SeMSevBG8TKHoo4 IpHgDwcyHniE3ETRDoEBgtHdCuaRYpyqp+WCM3KEOXU7mQTjap9jMDDs260mmhYjHUsj /CnuwJN9jNElWcEfIr5jhheLmTy9LcC3pD6wqOwpKd0Pljjd2oSARZj7PiYdl6Hqp69t eSvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=+0Ka3FlCKqDeNsWRAIS6u6LHmAn+V0UWd/xtumA09GU=; b=w6BfqvnQ7yMzSdfbGobPqq8qkAZGsKalSTu8qLjpOhRdY+rXuZoLTwe2PKLKok1r0A Z66jI5O8H7AttLD+fRxM0v8l/9AKkplpjnPfNksHgTu0HKv9AgtuEO7MjH4X/vyrod7q OGONnf+4uWKFVeBJ+uerTenfPnn9iLLKBtnYatppYP6t1mUTkjRvWo3YVOwWRAd0x+n4 47tw4N69RfoZ/xLk+BD5/VUfKuQ16TpiMfDhyYItPL9SdsBX99Ofvg4YZr1QEK7VcJwU 2AKO066PYwORC6PbxRk/kSmjMvGZmpCA4zF8eXEEB+KSONKwwcTHVlewcyAm82b4U3Uu NgMw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s18si8952551ejj.88.2021.03.27.06.07.26; Sat, 27 Mar 2021 06:07:55 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230043AbhC0NBF (ORCPT + 99 others); Sat, 27 Mar 2021 09:01:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:58440 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229582AbhC0NBE (ORCPT ); Sat, 27 Mar 2021 09:01:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 75A6561971; Sat, 27 Mar 2021 13:01:03 +0000 (UTC) Date: Sat, 27 Mar 2021 13:01:01 +0000 From: Catalin Marinas To: Andrei Vagin Cc: Will Deacon , Oleg Nesterov , linux-arm-kernel@lists.infradead.org, LKML , Dave Martin , Keno Fischer Subject: Re: [PATCH 1/4] arm64: expose orig_x0 in the user_pt_regs structure Message-ID: <20210327130100.GA31076@arm.com> References: <20210322225053.428615-1-avagin@gmail.com> <20210322225053.428615-2-avagin@gmail.com> <20210326182839.GE5126@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 26, 2021 at 05:35:19PM -0700, Andrei Vagin wrote: > On Fri, Mar 26, 2021 at 11:28 AM Catalin Marinas > wrote: > > > > On Mon, Mar 22, 2021 at 03:50:50PM -0700, Andrei Vagin wrote: > > > diff --git a/arch/arm64/include/uapi/asm/ptrace.h b/arch/arm64/include/uapi/asm/ptrace.h > > > index 758ae984ff97..3c118c5b0893 100644 > > > --- a/arch/arm64/include/uapi/asm/ptrace.h > > > +++ b/arch/arm64/include/uapi/asm/ptrace.h > > > @@ -90,6 +90,7 @@ struct user_pt_regs { > > > __u64 sp; > > > __u64 pc; > > > __u64 pstate; > > > + __u64 orig_x0; > > > }; > > > > That's a UAPI change, likely to go wrong. For example, a > > ptrace(PTRACE_GETREGSET, pid, REGSET_GPR, data) would write past the end > > of an old struct user_pt_regs in the debugger. > > ptrace(PTRACE_GETREGSET, ...) receives iovec: > ptrace(PTRACE_GETREGSET, pid, NT_PRSTATUS, &iov) > > iov contains a pointer to a buffer and its size and the kernel fills > only the part that fits the buffer. > I think this interface was invented to allow extending structures > without breaking backward compatibility. You are right here, it doesn't write past the end of the iov buffer. However, it's still an ABI change. An unaware program using a newer user_pt_regs but running on an older kernel may be surprised that the updated iov.len is smaller than sizeof (struct user_pt_regs). Changing this structure also changes the core dump format, see ELF_NGREG and ELF_CORE_COPY_REGS. Maybe this doesn't matter much either since the ELF note would have size information but I'd prefer if we didn't modify this structure. -- Catalin