Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1181836rwi; Mon, 10 Oct 2022 12:24:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Xf9AZawDY+YwjHbDCwrr3aRCD/xFyHBOx5UJIgK+0+BP18m8I2nc3xEsfFzkuT7saP9oF X-Received: by 2002:a17:90b:3b8d:b0:20d:5c7a:abf1 with SMTP id pc13-20020a17090b3b8d00b0020d5c7aabf1mr1704831pjb.118.1665429887388; Mon, 10 Oct 2022 12:24:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665429887; cv=none; d=google.com; s=arc-20160816; b=SQC1r/XliesYLulyTKZzzE4wu7dKEnHAGOyreHdab/jJteHOcSMrZyiiw1qfsQwHcS +y/5AWLPwoCzO24BikBeCT/SJXvM6ALbLZLcVlwh5wEIh0q2COvfVa1ztRH1LzCRD7fL ecF61q2GcUMl+r05D3G0pEcF2O6Jj2Qf6E7rk9ye3W6cEBWmIrBNKLS+p+B1q04oyKX5 GR0pg4WHXTRzV9FakOVBhSWP9QcFtvECfwcrtxMr0dZ++OgFvAdLyD2RA/f/eCm+4oOX jpxFAS17EMG3QuZDA52z0F24r4qBoVQ2pJIpBxkWa4gR9f23TgN3ClWIy+P6eW4BiXb1 T04A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=GHxfYRRBz6dDvIZIbha75zItKgdN7DRvBB/BdujSutA=; b=mnqmqLvUF9xkumzeDPeS/mJaTuwTk1M25PNEgsNDS15HFJskk8uikcF3si6NxpxVzI tp1m1Yi/TO3eWoBkvZcvsdZ0fxQdZ/kpg7q1OFKhIaJgSC93eGdPyLZAM6lCuraLVQ9M +jGohRb7/0k5ZZJehQnrpBcVDwovJy+qTAcWr7lkgO0YLqam+ZOqmW6dvFsl2KVN9g8k GQUho8BngOETDvSAKrWpI/vmPxs3l7bYh6e99Eyve5LktfIsl10VM+oP+hDI8eoKv8Av xhs4L2qbUSorqSnmoOJV8hXaoK1DyZqDPDd/zh7UWNmDRBRA6ohC/WGEoNrN6h99jtUX HiJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=FrOEX1fo; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d17-20020a056a00199100b00556c1c66b61si4647426pfl.143.2022.10.10.12.24.34; Mon, 10 Oct 2022 12:24:47 -0700 (PDT) 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; dkim=pass header.i=@google.com header.s=20210112 header.b=FrOEX1fo; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229675AbiJJSvg (ORCPT + 99 others); Mon, 10 Oct 2022 14:51:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229648AbiJJSva (ORCPT ); Mon, 10 Oct 2022 14:51:30 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93A211DF0C for ; Mon, 10 Oct 2022 11:51:28 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id fn7-20020a05600c688700b003b4fb113b86so6911452wmb.0 for ; Mon, 10 Oct 2022 11:51:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=GHxfYRRBz6dDvIZIbha75zItKgdN7DRvBB/BdujSutA=; b=FrOEX1fowbDGJqL0kFOl5u+cx57jpmcv97/VlyGSVunxlfQXvSyMo77FY33fGpOhqL 7akRUrYS8Ou6Hr6aHdIFKe69sCQZaicm2uPGF7oWa/BgZ6u+fG/bvcBYGTg2Pis/aPTv 7WpRNFTePVYZQJqipcVa6CdeENDxPy4+vp9UmBxSHGcLV0cFEXFt5VReaTzecEyv5evF cUpPjMqnKhmsIXrDE+iw2CWy0HeV+CVaHVQJCLqfwCmvAwTE9glU4ocCJ8YsHfFFYOFx Vq9ORS7WywEQzqc/PCel2TYWSvevBzSpjWUpNFkNismbXVedgLO+sqrIUMXQNeiBQAQs jGog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GHxfYRRBz6dDvIZIbha75zItKgdN7DRvBB/BdujSutA=; b=mqY04Xznft7Y3p+ZCAJ0sDnYuj+nUov0l0t9HxzLaIpgK6BmKvipU8LG/Jh3+Bhyb8 gf/7JSOAnl0bLrjW0XUc+4GviG+pHR5iz6oZRYxd6+9T7zfkKx26s7HZuMkQzB5QQRNL 9D/ubI76bN2Vh8z/uEVRwX/F8MgTHVu6vctGMxojsBoubQP76io3WD0V8PAVaoTi6Jpj XFLKp/hiJeZr28F4GnZnZU2S5hmimEwZJm0qrGx+Kr9eztoSnU8OM3yizKac3jDXxI6i PY8iUS87FyBkAwrBPa6JBaY+kt624e6DMihZyH3SJDBOBzTtlxeqW9oGl9Rxf/FZP1R7 PD4A== X-Gm-Message-State: ACrzQf103fnJZz31vaxz4myvv9RCtKL0uO9S3za7sfKMaJ3vu8vtDW19 bTf0fE8ecHBNAP85FnZvf1y0JSbP30FCFKocLp/+1w== X-Received: by 2002:a05:600c:524d:b0:3b4:91ee:933e with SMTP id fc13-20020a05600c524d00b003b491ee933emr14106351wmb.80.1665427886879; Mon, 10 Oct 2022 11:51:26 -0700 (PDT) MIME-Version: 1.0 References: <000000000000385cbf05ea3f1862@google.com> <00000000000028a44005ea40352b@google.com> <20221009084039.cw6meqbvy4362lsa@wittgenstein> In-Reply-To: From: Yosry Ahmed Date: Mon, 10 Oct 2022 11:50:50 -0700 Message-ID: Subject: Re: [PATCH] cgroup: Fix crash with CLONE_INTO_CGROUP and v1 cgroups To: Tejun Heo Cc: "Christian A. Ehrhardt" , Christian Brauner , syzbot , gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, Martin KaFai Lau Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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 On Mon, Oct 10, 2022 at 11:44 AM Tejun Heo wrote: > > Hello, > > On Sun, Oct 09, 2022 at 03:10:36PM +0200, Christian A. Ehrhardt wrote: > > > > Since commit f3a2aebdd6, Version 1 cgroups no longer cause an > > error when used with CLONE_INTO_CGROUP. However, the permission > > checks performed during clone assume a Version 2 cgroup. > > > > Restore the error check for V1 cgroups in the clone() path. > > > > Reported-by: syzbot+534ee3d24c37c411f37f@syzkaller.appspotmail.com > > Link: https://lore.kernel.org/lkml/000000000000385cbf05ea3f1862@google.com/ > > Fixes: f3a2aebdd6 ("cgroup: enable cgroup_get_from_file() on cgroup1") > > Signed-off-by: Christian A. Ehrhardt > > This feels too error prone. I'd rather revert the original commit. Yosry, > imma revert f3a2aebdd6. Can you please add a separate function which allows > looking up IDs for cgroup1 hierarchies if absolutely necessary? But, > frankly, given how inherently confusing using IDs for cgroup1 hierarchies is > (fd for cgroup1 identifies both the hierarchy and the cgroup, id is > inherently partial which is super confusing), I'd rather just not do it. The purpose of f3a2aebdd6 was to make cgroup_get_from_fd() support cgroup1, which IIUC makes sense. It was unrelated to IDs. There are currently two users of cgroup_get_from_file()/cgroup_get_from_fd() AFAICT, one of which is the fork code fixed by this commit, the second is BPF cgroup prog attachment. I can send another patch to add explicit filtering in the BPF attachment code as well. Alternatively, we can have separate functions that do the filtering if needed. For example: cgroup_get_from_fd() / cgroup_get_from_file() -> support both v1 and v2 cgroup_get_dfl_from_fd() / cgroup_get_dfl_from_file() -> support only v2 We can then use the versions with filtering for all the current users except cgroup_iter (that needs to support both v1 and v2). WDYT? > > Thanks. > > -- > tejun