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 03242C25B08 for ; Fri, 5 Aug 2022 21:49:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241538AbiHEVtU (ORCPT ); Fri, 5 Aug 2022 17:49:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241243AbiHEVtA (ORCPT ); Fri, 5 Aug 2022 17:49:00 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA9D67A530 for ; Fri, 5 Aug 2022 14:48:56 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-32851d0f8beso31033597b3.22 for ; Fri, 05 Aug 2022 14:48:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc; bh=yX3R/1i2LvTgNgg51J0RQhSR+naxU23tOgWOVNggIfM=; b=a7tYZIN2B6Y2XNLphifwjcXADFx7gkBmMvn3k+uUvzZ3plqE2SbhHbFhSrzbeff3ob gpEkWJ+BU4BsSNfrGwlvuHWUfSz9wrzda85SNVzeODOFirlekVdIFXIDC690ySk6LjnV TKO7Dajm4ek5OH5PQo33IjTrMjr23rtrutvRF8uWrZBGLMdE4hI0vfFixcLZKpnrvxof MJhLvW7up+1p/h18noKqidVfcZrWhSkNQRSCmX2jeEpraXunH+F4G0xLO1YXelQ02PQ/ OOykHlZU56GWzNfJT0elWItS0IcvSaxsXc+l6TRBYs7vgujcEPzpqiK68zkf+UF7XHZ5 ONAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc; bh=yX3R/1i2LvTgNgg51J0RQhSR+naxU23tOgWOVNggIfM=; b=qdWxJj2dNf+MlGHuKJs4AXr7J37DYqCmBSBMo2y7r5NEPRHRJBsHRjDU1ERSyj7cNI hwEKKIds4gTe2k37UBvxnetadh2yvfGO2pjuUl3JpxAUQows1T58jKRGr3W4kf3MgVTq uiXFTwaUCubP+/vkBMyLvY5JkhEM5ElVlp5exh6MV6rL5uFSvW0AFlpV+ikCDXe8onUS Amn2bqHfWc/z1gUi65Z388WgMi/cpfiZVAucya4QKVhlfZg6LZ+q+s7MvSEzMzWHql5r VYgc7vN57Sngq0nEYf21jliOJzIHwxV7Pkmh1b//Ej4lkRjh60CI9AZeG1/M44qTysXr dBoA== X-Gm-Message-State: ACgBeo00oThf8/F7XuRAeWkgkLSGg2huKnQkKEpYlo7bW8o057OxVpuQ CA6arpFk8i7FTS5G4VZ3rfzNjVY1O4kRRlBu2ueQ1ocuDuKWppZFMTGLcqqP+l+Ca8nl1I10H9d UmhtOS/nTCR7x+09hS7EC6YQTnMPOExI3zpOUEaj2HPXR1sbIM9kAMIbp3AMg8pXa6TcrrA== X-Google-Smtp-Source: AA6agR4H2bQkt5vkX1vf0DXDEkJRbK1x+84BjvFdi5mYU07GFA9bTVydk11jeARHUUFFpgLekr8jfkDBotQ= X-Received: from haoluo.svl.corp.google.com ([2620:15c:2d4:203:4f27:97db:8644:dc82]) (user=haoluo job=sendgmr) by 2002:a81:1390:0:b0:322:2378:c198 with SMTP id 138-20020a811390000000b003222378c198mr7864153ywt.244.1659736136411; Fri, 05 Aug 2022 14:48:56 -0700 (PDT) Date: Fri, 5 Aug 2022 14:48:15 -0700 In-Reply-To: <20220805214821.1058337-1-haoluo@google.com> Message-Id: <20220805214821.1058337-3-haoluo@google.com> Mime-Version: 1.0 References: <20220805214821.1058337-1-haoluo@google.com> X-Mailer: git-send-email 2.37.1.559.g78731f0fdb-goog Subject: [PATCH bpf-next v7 2/8] cgroup: enable cgroup_get_from_file() on cgroup1 From: Hao Luo To: linux-kernel@vger.kernel.org, bpf@vger.kernel.org, cgroups@vger.kernel.org, netdev@vger.kernel.org Cc: Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Tejun Heo , Zefan Li , KP Singh , Johannes Weiner , Michal Hocko , Benjamin Tissoires , John Fastabend , Michal Koutny , Roman Gushchin , David Rientjes , Stanislav Fomichev , Shakeel Butt , Yosry Ahmed , Hao Luo Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yosry Ahmed cgroup_get_from_file() currently fails with -EBADF if called on cgroup v1. However, the current implementation works on cgroup v1 as well, so the restriction is unnecessary. This enabled cgroup_get_from_fd() to work on cgroup v1, which would be the only thing stopping bpf cgroup_iter from supporting cgroup v1. Signed-off-by: Yosry Ahmed Acked-by: Tejun Heo Signed-off-by: Hao Luo --- kernel/cgroup/cgroup.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 13c8e91d7862..49803849a289 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -6099,11 +6099,6 @@ static struct cgroup *cgroup_get_from_file(struct file *f) return ERR_CAST(css); cgrp = css->cgroup; - if (!cgroup_on_dfl(cgrp)) { - cgroup_put(cgrp); - return ERR_PTR(-EBADF); - } - return cgrp; } -- 2.37.1.559.g78731f0fdb-goog