From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 697AFC433F5 for ; Mon, 10 Oct 2022 18:51:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229677AbiJJSvg (ORCPT ); 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-Google-Smtp-Source: AMsMyM5AKLWySZlXmYn97zNtwveG+wQlrLJ8/5UDHDwNZ6wcqBCJ0tO96aERRvSCo5LOXiEqmTwv5Hwe/To6GSNfaAw= 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" 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