Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp5676003ybh; Wed, 7 Aug 2019 09:34:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqzC8e1FFcsgoimnS9K4tBrDb+TmnJGyCD/Vw2HG06YPy6CEXo826H2C2/CVdvvceGKe+O0b X-Received: by 2002:a17:902:e306:: with SMTP id cg6mr8970159plb.263.1565195682045; Wed, 07 Aug 2019 09:34:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565195682; cv=none; d=google.com; s=arc-20160816; b=M1ERUcP0uLS6+OD42xqUJRy2W9QszxTFuehVufL3lmYXjSSGAXChrqd5Lx3rAIrxe8 E5e3pBFQzUD/3fyf14Kn/5w2PpRgDyaau6KiGhFoyO4qv+Gmof18re0JpAPyCRhoIhME ZbMwufOfHTDvPW7J83lNqS152GSSnRmNP4zAeCwBDU14XGdnzF7ig7j465Q9jhtQMQZE Z8Tc7oyvPvTwW37iwFHORfCzp6oyHmXklV07P7436+stkDHxreN0lWSgARPgFYKrMopw KO0DqNPfBKN4EBrUFvK1kO712sP7ks1FmgIErjeSJ5vxtm0USDfj21vo1V65et8Ig7fP P7jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=PyMH3s6DZTu1a3zBXJ4WgJJMbxCCocJmzYslfypUQpc=; b=MKMC18LO96vG7XSRIS5PjfSx+unPsmBZ+QLeqRCwSTBN37sHyMoSSqbCbfgvNXX8j0 lR3uTRhTzDuUmSvdLuYwwLcAK22cZA8SpJXwYELT1OS0kFSTA3VHDkjP+BUDofTJc40E wOQ24LpSMGSk5Zhn5PFfRzmfy+YZ+MkrBL3CcS7W/8NmBjJacQzZ/DPGW+k+3IAEk0uK 8J5BC/CcDxPnd5k87sP1HqLSb1EbuqMDVmCFs8EourhP+cg+o8mF+hyZ4atvRoFNMXKC r0EanZ+eJXSRprKNbwRbBTUdBtRaQPW3Y4S2ahuatvYhSYGpJ2fysEz7Sq8QUBBripCE /NmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FqASuH1a; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z10si46024587pln.285.2019.08.07.09.34.26; Wed, 07 Aug 2019 09:34:42 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FqASuH1a; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388761AbfHGQdd (ORCPT + 99 others); Wed, 7 Aug 2019 12:33:33 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:35598 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388603AbfHGQdc (ORCPT ); Wed, 7 Aug 2019 12:33:32 -0400 Received: by mail-wm1-f68.google.com with SMTP id l2so691366wmg.0 for ; Wed, 07 Aug 2019 09:33:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=PyMH3s6DZTu1a3zBXJ4WgJJMbxCCocJmzYslfypUQpc=; b=FqASuH1aH/ywKFpQSzRJQ4MoP4+/iM5sYEGzXqW5mhd5EQ9mJ0bZ4Uhm3054bwscNA KbIydURCYSAG9ZJhlcpBhERoS56IX+GOrzag5L4eOnHg1uEpfUwHxPvmpJEa7P1zu4k1 RV+leHpajnwfMPx5q2aszW3+KtdD1613BH66KqTdRrPsSsjp1rZ+YLlIHzs2yb7sPqaF vEO1oc0tfGqEfMhZa6XkEM6qYxczsVqgvOiUVa13pAESQ767mnWdXNjVV5OTdQejWZ9K p9uW7OndR8oOtYA4M99Gv8U8x5Yk/Vcb+/rCVZocotl70oa5T4XJraynf3ytTK6rnzQR TKNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=PyMH3s6DZTu1a3zBXJ4WgJJMbxCCocJmzYslfypUQpc=; b=FvPJfEzJ1yxqgluifIW9wbFTRwSaG3KdztXdTylaqF8pF0CoP2VKvNqH//OBQWHG4F L6uKNlUq46EiLqvwKE34BZdpaAbXg6gcmjzOPo71QRrQ+dlutZp1yMxm8d7x1yqSg7OV QkMZCoDEe9cMGBwuQuCNF0XBjJYAtRfs/twuXK+SmDSFBRoOx6qCWZBWsAfjvzKWobQH l79rIjhopI+0yI66QDJToOdlLNsljmQ+FuavoWxNn3sBm8jm89vFATt8lMQzQOnvVIkZ 1UM17L0pAxyP7GR39jzJvagURgoGr5ixdvlDsV4LUQ1IJbPYXk9mz1e63D/5/5Es8wS1 W1YA== X-Gm-Message-State: APjAAAV0LyBYSmj5m75AlabHU2tvs6XasgtCoh0QxafRY4YWmDkokuSx CQCc8Tm/oISGRAlx/2mUBY0= X-Received: by 2002:a7b:c8c3:: with SMTP id f3mr812810wml.124.1565195611072; Wed, 07 Aug 2019 09:33:31 -0700 (PDT) Received: from [10.83.36.153] ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id z1sm93853513wrp.51.2019.08.07.09.33.29 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Wed, 07 Aug 2019 09:33:30 -0700 (PDT) Subject: Re: [PATCH v3 1/2] fork: extend clone3() to support CLONE_SET_TID To: Oleg Nesterov Cc: Adrian Reber , Christian Brauner , Eric Biederman , Pavel Emelianov , Jann Horn , linux-kernel@vger.kernel.org, Andrei Vagin , Mike Rapoport , Radostin Stoyanov References: <20190806191551.22192-1-areber@redhat.com> <20190807154828.GD24112@redhat.com> <20190807162112.GF24112@redhat.com> From: Dmitry Safonov <0x7f454c46@gmail.com> Message-ID: <6af63d84-b948-edd2-4fa1-a2e639fa716f@gmail.com> Date: Wed, 7 Aug 2019 17:33:29 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20190807162112.GF24112@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/7/19 5:21 PM, Oleg Nesterov wrote: > On 08/07, Dmitry Safonov wrote: [..] >> What if the size is lesser than offsetof(struct clone_args, stack_size)? >> Probably, there should be still a check that it's not lesser than what's >> the required minimum.. > > Not sure I understand... I mean, this doesn't differ from the case when > size == sizeof(clone_args) but uargs->stack == NULL ? I might be mistaken and I confess that I don't fully understand the code, but wouldn't it mystically fail in copy_thread_tls() with -ENOMEM instead of -EINVAL? Maybe not a huge difference, but.. >> Also note, that (kargs) and (args) are a bit different beasts in this >> context.. >> kargs lies on the stack and might want to be with zero-initializer >> : struct kernel_clone_args kargs = {}; > > I don't think so. Lets consider this patch which adds the new set_tid > into clone_args and kernel_clone_args. copy_clone_args_from_user() does > > *kargs = (struct kernel_clone_args){ > .flags = args.flags, > .pidfd = u64_to_user_ptr(args.pidfd), > .child_tid = u64_to_user_ptr(args.child_tid), > .parent_tid = u64_to_user_ptr(args.parent_tid), > .exit_signal = args.exit_signal, > .stack = args.stack, > .stack_size = args.stack_size, > .tls = args.tls, > }; > > so this patch should simply add > > .set_tid = args.set_tid; > > at the end. No? Agree, this may be better. -- Dmitry