Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp287543ybi; Fri, 31 May 2019 01:16:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqzU1MCi/IGfRqmyXZF+QGV7M2+Cft+OmxhCbYTmUR7xNO7TRu1DhumZW3D4nFcVZXART7Fn X-Received: by 2002:a63:7d09:: with SMTP id y9mr7715841pgc.350.1559290585244; Fri, 31 May 2019 01:16:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559290585; cv=none; d=google.com; s=arc-20160816; b=qlXGgCo5E2a9s6cGjaiDI8K5l3JKWCn8BC8SQGXx16E0UonRJi6bDOOl+ZnEo5rzmp o1QGRoElhOoiMcawUJ6Du6JCzK3FNptyEi4VNd0FOJcFLBn85O3ST+gDVchlPEdggU0K qIY/yzy7mt1uvKH1pFfoYQvFM2it/lovytInKGPV+bRFWDf74K3ouJQ4MxwCmpe1XT+e j5MZaVrNXCzWPm9V+Q/ioou2cmIchnJOT8VYlTwSzyUpvHK9h54d2rI/fGujzOJShKlA XZ3oK0JIgppvIgsaMzHyitQ4An3A1zQFCM8cp49tVbX+p7ZfBrJELlmOgnZU6HLz2voe AmRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=qz9y4gFluxzPwJy3KPISqVXROmvinNnPW5jrOuJybTo=; b=VujabvThBB6Vc/9EPQf03jo1R8aQGj9/sc8MpXucQIKQXT1jrUCWw/52gzzmk1b7jg 1y2aHlvY3IFV53lIl8eX43xGKwkLdL9TU7wEv1RbRX0ns1H6nHHYOVhziRuWD5iTctED BvUNlr6exedMo5abfiID67G+3+M0/2NKi5SFSXoU9lOV8cJx0i8FaVrTQnuaQRZZh4LV LZaRk6ny4sUhkVqXqN2Aty/rYoDu2YfGhSZt7m17MSMe3+OdGIPSLUD9iWiybTCVrwu0 1sY5aLmSVWlKrAj2fa8l3OaKZfbDGsJJcG9iBUxS4BHMNG5uLtRBd2+pFZ26A/8/o8b2 SLcA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x28si5774509pff.104.2019.05.31.01.16.09; Fri, 31 May 2019 01:16:25 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726845AbfEaIO6 (ORCPT + 99 others); Fri, 31 May 2019 04:14:58 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:39751 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726386AbfEaIO6 (ORCPT ); Fri, 31 May 2019 04:14:58 -0400 Received: by mail-qt1-f193.google.com with SMTP id i34so10347514qta.6; Fri, 31 May 2019 01:14:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qz9y4gFluxzPwJy3KPISqVXROmvinNnPW5jrOuJybTo=; b=Tm5ewF/wi6xIdUKsIkZdEGqPXXKlR882rY6T5MTG1DHJVvlwP0o9cTJDqcudqGhlFR fKEhX4v13F7muxAOKwHJKK9rrnB+4+jOyD/RXIU5YIiJ3XobZdyvS0xV+3+H/Mz6lSr5 ZEaQ3i9oBK3LkpMPoFdWKmLffTKbEkw3C2QMl830DwWBw+OXg/x8GemOkZOZlRFU8UVK SVFeBG9fKp86GgLhwcdBOUuy5mAo1yIt1X5rwxOE4Ml7eL0xnR19fKNv8Xz7I7bDaZZ5 4ALrZJCEN/QuwPzm+wMySnzAOZcjyVECdT0fb8vnfluWr4h7DFB4u6wqt769i+QQXMeO 1xdA== X-Gm-Message-State: APjAAAW+gdazBPq7iQyBbQXa4/1xblRqpHKbCZvUgga3ZaSUnWTT9S8O EntfxlkNp/gu7n5VOP6yhgXgm/0T55o1W9Fx814= X-Received: by 2002:aed:3e7c:: with SMTP id m57mr2760555qtf.204.1559290496946; Fri, 31 May 2019 01:14:56 -0700 (PDT) MIME-Version: 1.0 References: <20190529152237.10719-1-christian@brauner.io> <20190530132012.GS16415@port70.net> In-Reply-To: <20190530132012.GS16415@port70.net> From: Arnd Bergmann Date: Fri, 31 May 2019 10:14:40 +0200 Message-ID: Subject: Re: [PATCH v1 1/2] fork: add clone3 To: Szabolcs Nagy Cc: Christian Brauner , Al Viro , Linux Kernel Mailing List , Linus Torvalds , Jann Horn , Florian Weimer , Oleg Nesterov , David Howells , Pavel Emelyanov , Andrew Morton , Adrian Reber , Andrei Vagin , Linux API Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 30, 2019 at 3:20 PM Szabolcs Nagy wrote: > * Christian Brauner [2019-05-29 17:22:36 +0200]: > > /* uapi */ > > struct clone_args { > > __aligned_u64 flags; > > __aligned_u64 pidfd; > > __aligned_u64 parent_tidptr; > > __aligned_u64 child_tidptr; > > __aligned_u64 stack; > > __aligned_u64 stack_size; > > __aligned_u64 tls; > > }; > > is this new linux syscall api style to pass pointers as u64? This is common for ioctls passing structures now. I don't think we've had many system calls with structures containing pointers, but the idea is the same, i.e. we want structures to be identical on 32-bit and 64-bit architectures. > i think it will look a bit ugly in userspace where cast > to u64 would signextend pointers on most 32bit targets, so > user code would have to do something like > > arg.ptr = (uint64_t)(uintptr_t)ptr; > > such ugliness can be hidden by the libc with a different > struct definition, but it will require bigendian and alignment > hackery (or translation in libc, but that does not really work > when user calls raw syscall). Right. Note also that user space should do zero-extension of the variables in order for the kernel to not care about what called it. Just leaving padding fields in the structure is not enough here. User space that calls the raw syscall certainly has to go through the uintptr_t cast, but I would also expect that applications don't normally do that, and instead call a library function that has regular C calling conventions with individual arguments instead of a structure. Arnd