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 X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03DFCC433E0 for ; Sat, 20 Jun 2020 02:48:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CF1AA22E01 for ; Sat, 20 Jun 2020 02:48:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732103AbgFTCsW (ORCPT ); Fri, 19 Jun 2020 22:48:22 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:6292 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732006AbgFTCsQ (ORCPT ); Fri, 19 Jun 2020 22:48:16 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 79D4760E13E5667660A4; Sat, 20 Jun 2020 10:48:11 +0800 (CST) Received: from [10.166.213.22] (10.166.213.22) by smtp.huawei.com (10.3.19.214) with Microsoft SMTP Server (TLS) id 14.3.487.0; Sat, 20 Jun 2020 10:48:06 +0800 Subject: Re: [Patch net] cgroup: fix cgroup_sk_alloc() for sk_clone_lock() To: Roman Gushchin CC: Cong Wang , Linux Kernel Network Developers , Cameron Berkenpas , Peter Geis , Lu Fengqi , =?UTF-8?Q?Dani=c3=abl_Sonck?= , Daniel Borkmann , Tejun Heo References: <20200616180352.18602-1-xiyou.wangcong@gmail.com> <141629e1-55b5-34b1-b2ab-bab6b68f0671@huawei.com> <20200618193611.GE24694@carbon.DHCP.thefacebook.com> <4f17229e-1843-5bfc-ea2f-67ebaa9056da@huawei.com> <20200620005115.GE237539@carbon.dhcp.thefacebook.com> <20200620011409.GG237539@carbon.dhcp.thefacebook.com> From: Zefan Li Message-ID: <0851bf66-9d81-5c50-c75d-3a70a069a654@huawei.com> Date: Sat, 20 Jun 2020 10:48:06 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200620011409.GG237539@carbon.dhcp.thefacebook.com> Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.166.213.22] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org >>> If so, we might wanna fix it in a different way, >>> just checking if (!(css->flags & CSS_NO_REF)) in cgroup_bpf_put() >>> like in cgroup_put(). It feels more reliable to me. >>> >> >> Yeah I also have this idea in my mind. > > I wonder if the following patch will fix the issue? > I guess so, but it's better we have someone who reported this bug to test it. > -- > > diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h > index 4598e4da6b1b..7eb51137d896 100644 > --- a/include/linux/cgroup.h > +++ b/include/linux/cgroup.h > @@ -942,12 +942,14 @@ static inline bool cgroup_task_frozen(struct task_struct *task) > #ifdef CONFIG_CGROUP_BPF > static inline void cgroup_bpf_get(struct cgroup *cgrp) > { > - percpu_ref_get(&cgrp->bpf.refcnt); > + if (!(cgrp->self.flags & CSS_NO_REF)) > + percpu_ref_get(&cgrp->bpf.refcnt); > } > > static inline void cgroup_bpf_put(struct cgroup *cgrp) > { > - percpu_ref_put(&cgrp->bpf.refcnt); > + if (!(cgrp->self.flags & CSS_NO_REF)) > + percpu_ref_put(&cgrp->bpf.refcnt); > } > > #else /* CONFIG_CGROUP_BPF */ >