Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp5669250ybh; Wed, 7 Aug 2019 09:28:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqyYD8XCHZJqIAh1BZhCkvDdfA4eCC9+c68To5wXWz52xUlrNKCRFnQJoKRdsEq86drko8XS X-Received: by 2002:a17:902:9004:: with SMTP id a4mr9012775plp.109.1565195326766; Wed, 07 Aug 2019 09:28:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565195326; cv=none; d=google.com; s=arc-20160816; b=B0VJH3KimjXoDTHOL7echtW2J6+cHi84SsBsJbWvbBzBKYSwogXjCTOkXvwam8ABqN qtLRJSldv2lvlkg9Pe3fZizbzA3FsHFAMvcd5wFu88C2Ngdi1EY2eSriaxNz32cv+KcM 0fNSlf/5/CMJUXzLAyzHNykgOG8lR/ZKB/xjbWuXnA6zILksmwDFCyVjsoOg87K7gdnc 4qWDKknlxry3HURvrJBI10ZIni9OPKeYch3I7sU7e2KAmu5bMfMF+ivGn2n9YDZdFClp DtQv24Cdrz6jN+IAtY+97P+VTQmW4Q2ODsc1BhhOcpFhb9PB5urDHGi9+uHyyuu/4ByG UY3Q== 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=ArDK2yd4V6QQ3qyxxBCUgKNW9eV7m38bCdB5S3Z5AXo=; b=VSBsrhdhodi5FWyg9nAcCJ37HvoYRjo1p71Recrn4cLe1BGyX+9OFfjg8SvOkknckD JfjYYnGUKN4xxeM6rGCX2rLSLw8Jv7NKEbIZeOkpDCC6vXH9wFJTiLpFTQOnXfrMeZef xtwaxfZqwIEghbX6mLg21CKU2MUeXo4uvZF3fWHjALaCBnVyThzufJeEblaZj7toN2Vz 7vNergQLAeJgi/9iBFal7DHByT5tykI4hgQq9ciUTcAxr5DvUc9awWX9gZZc2iqfvvam RcrrD06cLuA5gB3b7XtQoDIATI+ESDCOPXSiw4sUO8KO3s/keOwi9sSHvNPBEX80rZSu bBgQ== 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 l1si48554767pgt.137.2019.08.07.09.28.30; Wed, 07 Aug 2019 09:28:46 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388766AbfHGQVQ (ORCPT + 99 others); Wed, 7 Aug 2019 12:21:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33050 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387922AbfHGQVQ (ORCPT ); Wed, 7 Aug 2019 12:21:16 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BDF28641DA; Wed, 7 Aug 2019 16:21:15 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.136]) by smtp.corp.redhat.com (Postfix) with SMTP id 8A2B160852; Wed, 7 Aug 2019 16:21:13 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Wed, 7 Aug 2019 18:21:15 +0200 (CEST) Date: Wed, 7 Aug 2019 18:21:12 +0200 From: Oleg Nesterov To: Dmitry Safonov <0x7f454c46@gmail.com> Cc: Adrian Reber , Christian Brauner , Eric Biederman , Pavel Emelianov , Jann Horn , linux-kernel@vger.kernel.org, Andrei Vagin , Mike Rapoport , Radostin Stoyanov Subject: Re: [PATCH v3 1/2] fork: extend clone3() to support CLONE_SET_TID Message-ID: <20190807162112.GF24112@redhat.com> References: <20190806191551.22192-1-areber@redhat.com> <20190807154828.GD24112@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 07 Aug 2019 16:21:15 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/07, Dmitry Safonov wrote: > > On 8/7/19 4:48 PM, Oleg Nesterov wrote: > > On 08/06, Adrian Reber wrote: > >> > >> @@ -2530,12 +2530,14 @@ noinline static int copy_clone_args_from_user(struct kernel_clone_args *kargs, > >> struct clone_args __user *uargs, > >> size_t size) > >> { > >> + struct pid_namespace *pid_ns = task_active_pid_ns(current); > >> struct clone_args args; > >> > >> if (unlikely(size > PAGE_SIZE)) > >> return -E2BIG; > >> > >> - if (unlikely(size < sizeof(struct clone_args))) > >> + /* The struct needs to be at least the size of the original struct. */ > >> + if (size < (sizeof(struct clone_args) - sizeof(__aligned_u64))) > >> return -EINVAL; > > > > slightly off-topic, but with or without this patch I do not understand > > -EINVAL. Can't we replace this check with > > > > if (size < sizeof(struct clone_args)) > > memset((void*)&args + size, sizeof(struct clone_args) - size, 0); > > > > ? > > > > this way we can new members at the end of clone_args and this matches > > the "if (size > sizeof(struct clone_args))" block below which promises > > that whatever we add into clone_args a zero value should work. > > 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 ? > 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? Oleg.