Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2131994imu; Wed, 12 Dec 2018 10:01:55 -0800 (PST) X-Google-Smtp-Source: AFSGD/VSlNFMTZpyhyBX2lEqf80Q/IigAvZTr5x/f5c/7MgT43X9uOm8FzoBS0xHXnvsRFddV1pC X-Received: by 2002:a63:ca0a:: with SMTP id n10mr19159579pgi.258.1544637715871; Wed, 12 Dec 2018 10:01:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544637715; cv=none; d=google.com; s=arc-20160816; b=O0B4ZAOau4NstjtO5XE91OA47C3e7wkFqlCCHo+c3jpcS1JHm7smwA1NiUsh7BbuBA zUdAqHba7JfWlEcvTnHYa+llsG3Zwa0eyNrXzAH/PpdsNXLUVUb0ZvWygp00cv9gnXnA 66iejO8mVM0vz7wo9WOUnrbkqWF392xXBcCkzFMSUaTvbkjTNpiX1hsE19fgWIiODebD l27rePFR+Wy+UvlrlWF9SMj+KFr7o0tPFT6DZnbUhPKh2h9bqvYdwzu0ZNFk6PgoOuq3 F9ynsb3ZB4yslBA2ZeeHt2J7SBUq24+eDCeIv1gk4UwEwFkDx9WKNf7Z/8e6kR9fIQsB JPag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=JG4C4xJTenXrcRh905Oqtp2TB13wQSUPsJ6NXQ9z8Fg=; b=JRki/mOwkS1SGDptRNr4ducIB6AxyJcrgK8Zbw/WRSwEUF9VRKIhgJ4tSUvPgxBdWd dYkcNI1Dmfh0la4xJV8ZgXkUyT4SIC6EF08ETgBlZzNQAvNGAkBUanItwydGk+QsUlJa +aAXQyJzg04/ltOUQrK2F9kGlNwqcWfGCd1A+j1DgbN0OZ/u0GoDqpthrBhQMPCW9319 fFz+igihUU5u6syl6AJxymYPuxsZWfTwQVZtfOuzXB7aujtOT7yCmM6rEuXwD2S4GV3Y AjEKVxPW01d4WwVuWv2wHb8+j64aBnO3aAiu2K8tJxHK69o47RN/ZSsLZVtFoT/2hToB rq/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g26si15797913pfe.127.2018.12.12.10.01.40; Wed, 12 Dec 2018 10:01:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728075AbeLLSAZ (ORCPT + 99 others); Wed, 12 Dec 2018 13:00:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50100 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727748AbeLLSAZ (ORCPT ); Wed, 12 Dec 2018 13:00:25 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BCA78C058CB3; Wed, 12 Dec 2018 18:00:24 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.131]) by smtp.corp.redhat.com (Postfix) with SMTP id 626CF61478; Wed, 12 Dec 2018 18:00:18 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Wed, 12 Dec 2018 19:00:24 +0100 (CET) Date: Wed, 12 Dec 2018 19:00:17 +0100 From: Oleg Nesterov To: "Dmitry V. Levin" Cc: Andy Lutomirski , Elvira Khabirova , Eugene Syromyatnikov , Kees Cook , Jann Horn , linux-api@vger.kernel.org, strace-devel@lists.strace.io, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 24/25] ptrace: add PTRACE_GET_SYSCALL_INFO request Message-ID: <20181212180017.GB30309@redhat.com> References: <20181210042352.GA6092@altlinux.org> <20181210043126.GX6131@altlinux.org> <20181210141107.GB4177@redhat.com> <20181210162131.GG14149@altlinux.org> <20181211152953.GA8504@redhat.com> <20181211162305.GA480@altlinux.org> <20181211202709.GA3839@altlinux.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181211202709.GA3839@altlinux.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 12 Dec 2018 18:00:25 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/11, Dmitry V. Levin wrote: > > > > Still can't understand... are you saying that without (say) __pad2[4] > > > sizeof(ptrace_syscall_info) or offsetofend(ptrace_syscall_info, seccomp) > > > will depend on arch? Or what? I am just curious. > > > > Yes, without padding these sizes will depend on architecture: > > > $ cat t.c > > #include > > int main() { > > struct s { > > __u64 nr; > > __u64 args[6]; > > __u32 ret_data; > > }; > > return sizeof(struct s); > > } > > > > $ gcc -m64 -Wall -O2 t.c && ./a.out; echo $? > > 64 > > $ gcc -m32 -Wall -O2 t.c && ./a.out; echo $? > > 60 > > > > This happens because __u64 has 32-bit alignment on some 32-bit > > architectures like x86. > > > > There is also m68k where __u32 has 16-bit alignment. OK, thanks, > Said that, I think it would be better if PTRACE_GET_SYSCALL_INFO > did not take these trailing pads into account, e.g. > > - return offsetofend(struct ptrace_syscall_info, seccomp); > + return offsetofend(struct ptrace_syscall_info, seccomp.ret_data); > ... > - return offsetofend(struct ptrace_syscall_info, exit); > + return offsetofend(struct ptrace_syscall_info, exit.is_error); > > The reason is that it would allow to fill these trailing pads with > something useful in the future. Agreed. But this way everything looks even more confusing. To me it would be better to simply remove these pads, but I won't insist. Oleg.