Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp5661465ybh; Wed, 7 Aug 2019 09:21:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqwgcuhgbyGXdwXcIREd2DQEQtF615UPd/v299ZK+asF2zj8jM24RLyvPiNdANSgKcfb3Cti X-Received: by 2002:a17:902:aa93:: with SMTP id d19mr660659plr.148.1565194890223; Wed, 07 Aug 2019 09:21:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565194890; cv=none; d=google.com; s=arc-20160816; b=S8ZfDbx95jTPScw0Y3j2vlUogaL8bA5DYafqstPoqOw7zeUBE+OPOBKEiaHHIuoCXl tBZlVF0JQHNu1boS4Myl6UL4AmiDXPLD6tO9JXqItQMFf8CgoYe6TCL/L6RmNlbjw1mk y5c5IfaBnmzq46Bhd3We7Nn1EEp5EWCjYKZD80Iyb3H0+IPMwU4APeiqsflkwCTA9q1l wJ1+GBLxR+9zAl7XFB5JXvNMO5X6ej6/hdO7jPudclGDAf/G+yf6yGgY42+1Q+j9Wiwv U+SZhOuHPZDnZ+J1v1jw2X/tVs4Lrrk5KE2bve5VXulDFr4US0WeNhDVMCDrOhU6KPXU c36A== 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=gfZpuj45Ev+OU5FnhTdkXFsKqS1/cYJCjuIEw4WcKDA=; b=lM0CAF4TuGuu38gPa1NAkzX4J7Y5UNw6nVQhXbLX59IaL7M2z516pNXllkvdbXb63C duOpgLqG7ytEgfpmj92OAWoRcIBxltLUekDODYzrN/yJpdwJ0hOExPsASO4x0eSWmzbE g5Bvk1Loy4lifGCSVZgpIUOSyjB35aZlO2FfGnTtnaTezpMDlnrUW0nqym02y48YDaPk r2bBIMrlfX8dIkhDYjn8awjARnIF6+Bg1w86ZPvTKGZt7ia4BTGalikrDWYcjWPB79Tg +X0CwxE+UcS+2mlcL+AP2Jaxt78DXKtIyepa3n5FegcG/hUOb1pOOjBP/1OYwaDoFygt 7hGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vCTR9djq; 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 o13si246605pjr.101.2019.08.07.09.21.13; Wed, 07 Aug 2019 09:21:30 -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=vCTR9djq; 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 S2388835AbfHGP5M (ORCPT + 99 others); Wed, 7 Aug 2019 11:57:12 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:42622 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387985AbfHGP5M (ORCPT ); Wed, 7 Aug 2019 11:57:12 -0400 Received: by mail-wr1-f65.google.com with SMTP id x1so42005127wrr.9 for ; Wed, 07 Aug 2019 08:57:11 -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=gfZpuj45Ev+OU5FnhTdkXFsKqS1/cYJCjuIEw4WcKDA=; b=vCTR9djqvjSIKY69pRkJ45/cgQX6ysZIL6c3dcecj0jumYyiVFpvH1eGpW52fGto1E JdKQIFLVZ8BKwg9Ony1km0mqhY63BZ7N9ElCag2avsTol+suwhd5Y+e00CVfAxVKA9fx 5ERoB5nJEivq7LtFOPBOjvmOy75b7qC5lAEPCRxDF7bVzzluH6yj9no2/Os+d9qsCf/3 uVWpbvulF57QmwxvOCKkVuHjKavZHaHDdp3IlrSy0WWSxi0aIJR8xvBUvPd0LSvBb0ni T/vWepdZNKyhjNIkXIESH/wLgEbkKeUd1CViVM/cRXeZqsoGjr/3WG4FFzgsP8ozNjR+ e0tA== 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=gfZpuj45Ev+OU5FnhTdkXFsKqS1/cYJCjuIEw4WcKDA=; b=JvwnYzfYc5vQeF0EFTH8OPX5FuHiW8ExpfpLeucUfhKrKmnJDdJSpGw3WiHYnU9p1c XRwiEGqUmGIyQoANX9fIVE5/QcCM8778itv5C6uJsDuBWJrHcDOp3QmPEhvxsx+EnsPj xglVMkWvNuMvhI9YxDRGljhulLs8dEEgftnE6XArWi1neT4iMu6M5fid5Sruka1aA972 ly4SCV5rXPXniK+sL90UdTEKsEdrnUG5mqajexSrgH5raCIuaHmimk5/IOi+vHuyD+rA NEXav+IfhKPz1Ry5EhsMTomZdevMU3tFQtMK6zh/SdFAEbIzpXfAZcy1hm1ARzX77hLE 589A== X-Gm-Message-State: APjAAAXeH0tSZ1lcrVpS+sfySshVxseZugwAZEhcZ9tSOvGKXis+0y+k leUYrmJMN7u5Yz8ykFaw31U= X-Received: by 2002:adf:fc0c:: with SMTP id i12mr10837869wrr.86.1565193430378; Wed, 07 Aug 2019 08:57:10 -0700 (PDT) Received: from [10.83.36.153] ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id m6sm2778610wrq.95.2019.08.07.08.57.09 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Wed, 07 Aug 2019 08:57:09 -0700 (PDT) Subject: Re: [PATCH v3 1/2] fork: extend clone3() to support CLONE_SET_TID To: Oleg Nesterov , Adrian Reber Cc: 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> From: Dmitry Safonov <0x7f454c46@gmail.com> Message-ID: Date: Wed, 7 Aug 2019 16:57:08 +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: <20190807154828.GD24112@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 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.. 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 = {}; -- Dmitry