From patchwork Fri Aug 5 21:48:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Luo X-Patchwork-Id: 12937710 X-Patchwork-Delegate: bpf@iogearbox.net 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 E3A3CC25B08 for ; Fri, 5 Aug 2022 21:49:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241393AbiHEVtQ (ORCPT ); Fri, 5 Aug 2022 17:49:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240663AbiHEVtB (ORCPT ); Fri, 5 Aug 2022 17:49:01 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D77A7A533 for ; Fri, 5 Aug 2022 14:48:57 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-328c683e73aso30925197b3.23 for ; Fri, 05 Aug 2022 14:48:57 -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=QyedOTn3+lJZl4nvaJExPJGpgyueBMNmj9dRN5vIxVBkjRWvy3nXIYNvxLGumsQ78P Ym+ONz977PkVx1YB8PoNewKAxyT5B+Yb1Rm+XB4xy+U5ARMnjxoG10hR9uFeiZySGyqu GKlqxFL1kNp6tHo5ANoCHNckp7F8onAo+VIHMrYGve7iIIZoZOip33vPFXM5aipuzDBf V5Ks80xcGWBuxvaOR254ZZh0fjh/q7WOoJ5+2DvzLHjAzqXElQfi2ULHhqx2WBZRDYTD HkvfDkRkkVUaEAujHurQcokdpweP5QANzxkiQqrikSKl/bLONivGSRjktsE1GfHL5DqQ jojw== X-Gm-Message-State: ACgBeo2uAIM4VuFWUIas+TQBOl7dBHzJ5/PKTl89ucdr3n9ez3M8t+FD vOwAEXNEvHuJIWkUK/VU69OHSE5Q+NI= 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 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net 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; }