From patchwork Wed Mar 8 10:51:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Klauser X-Patchwork-Id: 66150 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp269589wrd; Wed, 8 Mar 2023 03:16:59 -0800 (PST) X-Google-Smtp-Source: AK7set/XMQNN5tJ9cnWpeUamBUUXxIgIIv2VVdgp42v4fQKkoTi80O7zZbi2VojDo0VLaBOVnlQa X-Received: by 2002:a17:906:350e:b0:8f8:edfc:b670 with SMTP id r14-20020a170906350e00b008f8edfcb670mr21125381eja.32.1678274219695; Wed, 08 Mar 2023 03:16:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678274219; cv=none; d=google.com; s=arc-20160816; b=oFlV8UYdA26hJb3V0kyKXY1G7XAPyKvK4QXnQcv1Mu+ZiTG/OWgb0AQ3g8cZmnYbSQ NtwRFHQKAFee6ISa/UgtgI0nLWWpRS5GN8qIeKxKe4bgNlqus1WoYyCt36Eizf+8pTmS /hIF5z9VgD3KWea2v0OPOq1ZL8bbJFuA78i1NOg/0b8MV3Xho4+j2d5cxht0NTxWuil0 Eu/VB3nk6qQHnBd6IhsSfNFmHdtyAVguTWDbMzn+EXVGg0oyzmZBwkTN/eJAaBxWZsBG 3dc4/xQ2OI8XBS/uE4TBv9noM64FgFCUvNPdn9Y2qLWOhfog327QHisxuy1cTQw69yz8 qc4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=QIcQu/49uaP2F59ilaDDohRC/dtpk7xCo7/OgUbcQwY=; b=mGSr+qieX6qsN3nc7bgUQfha44En1jXirfpRNXVUGZzfmqCIuJAgIx+cbyG5G6vgWD 17/K/BsrxYztrIdGxV+J5wn8OUWQrYAVXvXFd1F4kmHVIdHKawW+3zZ3Hebn71uY7VFE /5baG6up/FFLd7Dm9tJ1umbE3zlDHKnqy/hrnZk8zTeTqzmJOn943eV7BV4/+tODc1K2 qDHxDJu6J2a2tuq79jhBCaCj7hLOqsbpFRqM+Nr1mRYT8MWE/cCE4Hh+42p7BODawV8D s+LJlqZjqh7wywaZIFgSvX9c5rQSdDj7AdZM5iSFzIEh3/qwhLrnZQC3fDgDd0MBPsmy 1T5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y5-20020aa7ccc5000000b004bf4b5c2516si17300147edt.239.2023.03.08.03.16.15; Wed, 08 Mar 2023 03:16:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229893AbjCHLKq (ORCPT + 99 others); Wed, 8 Mar 2023 06:10:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230373AbjCHLKk (ORCPT ); Wed, 8 Mar 2023 06:10:40 -0500 X-Greylist: delayed 601 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 08 Mar 2023 03:10:31 PST Received: from sym2.noone.org (sym.noone.org [178.63.92.236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68C969F058; Wed, 8 Mar 2023 03:10:30 -0800 (PST) Received: by sym2.noone.org (Postfix, from userid 1002) id 4PWpyk2zyFzvjfm; Wed, 8 Mar 2023 11:51:26 +0100 (CET) From: Tobias Klauser To: Christian Brauner Cc: Andrew Morton , Andrei Vagin , Dmitry Safonov , Thomas Gleixner , linux-kernel@vger.kernel.org, Andrey Vagin , stable@vger.kernel.org Subject: [PATCH 1/2] fork: allow CLONE_NEWTIME in clone3 flags Date: Wed, 8 Mar 2023 11:51:26 +0100 Message-Id: <20230308105126.10107-1-tklauser@distanz.ch> X-Mailer: git-send-email 2.11.0 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759798068513468467?= X-GMAIL-MSGID: =?utf-8?q?1759798068513468467?= Currently, calling clone3() with CLONE_NEWTIME in clone_args->flags fails with -EINVAL. This is because CLONE_NEWTIME intersects with CSIGNAL. However, CSIGNAL was deprecated when clone3 was introduced in commit 7f192e3cd316 ("fork: add clone3"), allowing re-use of that part of clone flags. Fix this by explicitly allowing CLONE_NEWTIME in clone3_args_valid. This is also in line with the respective check in check_unshare_flags which allow CLONE_NEWTIME for unshare(). Fixes: 769071ac9f20 ("ns: Introduce Time Namespace") Cc: Andrey Vagin Cc: Christian Brauner Cc: stable@vger.kernel.org Signed-off-by: Tobias Klauser Reviewed-by: Christian Brauner --- kernel/fork.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/fork.c b/kernel/fork.c index f68954d05e89..d8cda4c6de6c 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -2936,7 +2936,7 @@ static bool clone3_args_valid(struct kernel_clone_args *kargs) * - make the CLONE_DETACHED bit reusable for clone3 * - make the CSIGNAL bits reusable for clone3 */ - if (kargs->flags & (CLONE_DETACHED | CSIGNAL)) + if (kargs->flags & (CLONE_DETACHED | (CSIGNAL & (~CLONE_NEWTIME)))) return false; if ((kargs->flags & (CLONE_SIGHAND | CLONE_CLEAR_SIGHAND)) ==