Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6244066ybi; Wed, 31 Jul 2019 10:47:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqySMq38ffKhiUmBkWxF19+Qec8DxSFqpvoKRWIs6k798/i7JXBX46ynyjJfsE/zZ4vBS9ih X-Received: by 2002:a63:5811:: with SMTP id m17mr44497506pgb.237.1564595226997; Wed, 31 Jul 2019 10:47:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564595226; cv=none; d=google.com; s=arc-20160816; b=jE5avpTXMHgjx63NNGLNXZJZ7775e+7vg9yDOXeQ2EHdwuUwbejFU5TjedGQ219BMy anTAird+Iwi/EXpNRnGODfb2g6jhhYBoHffNbVi0MJNncHKiAlzvQP0FVCKM7s9VECL+ ehHzdfgsi/ggtgUehwsPHwQO4kiXOIpkkp99Oak90MBcTultR2s0k2gqqCPUxAeHRSp8 T5QApIbW4snljj5tvjKR70NoKWrliV/h8TUg5KAhQQJs6koLOdgVaOThw259wsNXpo/c bFCKGKdqC7XCZC4FZrXBmOz05jkGDOD6E34weD3ojZ5aD0+NohhNpbF3/XET4c3Po4rH YbaQ== 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=qrmVYgiFrygAbwYOEEMHH0NYuDdaUguNNXX83FQoVys=; b=RLiPiMTeaBzPNSWMtjSLFFTZN4AveSCYDyJyvPjL9kJcMnyaiqVFAl+O/7M6Xpwoq2 SJ/7I7WhcGne6L+uBwPb9zktSgktbgcIw62NxEBWa7l37ATGsCSfHmBSPlVL8JBCSrfJ xuT113A7FcLnFk7VI8CX5oB19RJaQnMtT3y73AuAv3qIQQxu0BLIKxrtxm7GNycqKM/x HIdRmRrU8cI5OnXs1itrw+V6LFuu6P4VyTEuJImWKIFHG1fHE939ttKOgQ0zpYWGX8gs 2PHOLuDxEe1uvtyhfzVCA3vGQyrOGmP7w3HXugt3+FLovo6efl7sY+ZNDHYEMOygZ2Ir Zg4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WYqDm0aj; 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 r1si32954263pls.69.2019.07.31.10.46.51; Wed, 31 Jul 2019 10:47:06 -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=WYqDm0aj; 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 S1730405AbfGaQuD (ORCPT + 99 others); Wed, 31 Jul 2019 12:50:03 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:34966 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727041AbfGaQuC (ORCPT ); Wed, 31 Jul 2019 12:50:02 -0400 Received: by mail-wm1-f67.google.com with SMTP id l2so60437226wmg.0 for ; Wed, 31 Jul 2019 09:50:01 -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=qrmVYgiFrygAbwYOEEMHH0NYuDdaUguNNXX83FQoVys=; b=WYqDm0aj2GA8Xeog244Z1cJSk2l3lK+xS2hBabX+bWJE1ZeUqVA0fdZm4T6gkbi1Zj CsIUDE68jDvaiRfBXFjz+iIFNoJVjrIAYCaXOSvk9tKYhShUsKeHU/+pnV1G3OXpHhJB 2mAnSJAsyAKPUmN6CdHJ9IO8qkrYLjaFkyGJSqPaxNRiMLxcI1WtGzKqI/0tmOhEFSok QVjOLAbuhLnJAHz/7Wb+9wOVb8srhRnUPwdY8YhYugqfvGTeJ415KTcZ4Ba4TNCXKlnP OGkpmlzsb7FHhANKAGtsqDxAcbOl9MjAOTgPCt1NpSMM/wiQouobjXgxCbcB2ne25Ozu YKNg== 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=qrmVYgiFrygAbwYOEEMHH0NYuDdaUguNNXX83FQoVys=; b=tdCIOIMkrPzZpLWrHvCVNGTE4q8td7+dGbMEHrQxl8thsYRCfIgTv8txGq3qAW/QOn OEfRLOi5UBWV8Z/NdYFuUR1a3jz0B2gcWWylZlkiRD+Kxo33K76Jk1ukTMifwaxNhApt +xbCpDE/Zi2y3WBhcXPczkN0qU4t6EHhRq4xLzfmg7TqrNykz0ikyHVa7Z8ZYUj8lt76 VYJetf+zusyI6VoiFWdEvXvupH2XwKBcVlsq1wsmqheTuJwpjzdozioGQ+BIXwCis2ts 9fQacx86uwPmPssno+oOO50VHDtQ4oj4c4DqsjPi2x1q6oqqo6v46SjoK6Og7j1Y3a3C JtZg== X-Gm-Message-State: APjAAAWFVuBOEq03S535T/tvDVfIQlBhuMFIGZSkXe0lEs6z2SdA4/jh 5c3MNI9+QQCyYIWyVdSm42g= X-Received: by 2002:a1c:4803:: with SMTP id v3mr113366670wma.49.1564591800571; Wed, 31 Jul 2019 09:50:00 -0700 (PDT) Received: from [10.83.36.153] ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id x185sm63607355wmg.46.2019.07.31.09.49.59 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Wed, 31 Jul 2019 09:49:59 -0700 (PDT) Subject: Re: [PATCH v2 1/2] fork: extend clone3() to support CLONE_SET_TID To: Adrian Reber , Christian Brauner , Eric Biederman , Pavel Emelianov , Jann Horn , Oleg Nesterov Cc: linux-kernel@vger.kernel.org, Andrei Vagin , Mike Rapoport , Radostin Stoyanov References: <20190731161223.2928-1-areber@redhat.com> From: Dmitry Safonov <0x7f454c46@gmail.com> Message-ID: <417a9682-c7fc-fec4-3510-81a8aa7cd0af@gmail.com> Date: Wed, 31 Jul 2019 17:49:58 +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: <20190731161223.2928-1-areber@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 Hi Adrian, On 7/31/19 5:12 PM, Adrian Reber wrote: [..] > @@ -2530,14 +2530,12 @@ 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))) > - return -EINVAL; > - It might be better to validate it still somehow, but I don't insist. [..] > @@ -2578,11 +2580,16 @@ noinline static int copy_clone_args_from_user(struct kernel_clone_args *kargs, > > static bool clone3_args_valid(const struct kernel_clone_args *kargs) > { > - /* > - * All lower bits of the flag word are taken. > - * Verify that no other unknown flags are passed along. > - */ > - if (kargs->flags & ~CLONE_LEGACY_FLAGS) > + /* Verify that no other unknown flags are passed along. */ > + if (kargs->flags & ~(CLONE_LEGACY_FLAGS | CLONE_SET_TID)) > + return false; > + > + /* Fail if set_tid is set without CLONE_SET_TID */ > + if (kargs->set_tid && !(kargs->flags & CLONE_SET_TID)) > + return false; > + > + /* Also fail if set_tid is invalid */ > + if ((kargs->set_tid <= 0) && (kargs->flags & CLONE_SET_TID)) > return false; Sorry for not mentioning it on v1, but I've noticed it only now: you check kargs->set_tid even with the legacy-sized kernel_clone_args, which is probably some random value on a task's stack? [..] Thanks much, Dmitry