Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp680596imm; Fri, 28 Sep 2018 05:12:41 -0700 (PDT) X-Google-Smtp-Source: ACcGV60PIKD6bs0LbS5g6ofleWPSc1M+6byoRAkRquEUdt36KYvrN+Jjzsnesfd5xr7lXCd9my1C X-Received: by 2002:a63:f616:: with SMTP id m22-v6mr5713591pgh.293.1538136761487; Fri, 28 Sep 2018 05:12:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538136761; cv=none; d=google.com; s=arc-20160816; b=AD5Qa8RCO9HbfoRK6i/P9WFyNkM+0ksDxFR4QAzcxO5bRc/iUR28vKKgbxJMDsssAA 7uMCHVnlN3EMjCyKt5YArrWZUk1pq2VYb/OvY7ZAATRwsy7k6ynwh1KoEvH/6CZvyKjJ SPP90RjcSsvz4709nS66CUOBNmDGTbje1qDVcz1CeTDpZi4nHm2he6hu9f0Wgk5PdKxo 0ypzRJjkV/k6TQrMeyRxhRHKQjkt2qmc8d5BmNirzsNIoEMUbPcp43k4KW4wM4mdW+cM utS3VvKJ6Si0XcbagkdfsIG2CZ5wbDbZJVCfQnseS+ahH6V3r+N11FoaAPAXqIxlvvuy gm4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=b+mXAPaMIL+GlxX2df37lx4jK1ZKT8LOy7wrJGpxVDg=; b=y68hkPT6orpnznhExFlF5D2t71hDE5R8BODF/TxYuvVwMAqOxRPTQOquq1Shadeu7p dRxQll1LmJM4CJPoN5iYz7ZvxwuuRudDq1qZDs4Jn7/iA15mLxw3a+lmd+LsE+QaZpfX JsTagQjVv2rjtznPmRtNsicWsFsf8DfHKxDISN4ZHlIKqEnpesxJCsk3OCU+MwLWx4m0 Nxos273ssjULmTJIJ4Q6AykJ0k0LebQw2+3K2Ug6Q3t5R+ebssordBZRlKOFdQiZtw3Z XRSKkymB/yg/orFdmEDhkBt/khh/+X8xs20aS/p1aQ+WtAYfu3TecBWC4q5qQdC5mgWn kDnQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n6-v6si4736826pla.79.2018.09.28.05.12.25; Fri, 28 Sep 2018 05:12:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728832AbeI1SfV (ORCPT + 99 others); Fri, 28 Sep 2018 14:35:21 -0400 Received: from www62.your-server.de ([213.133.104.62]:39444 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726106AbeI1SfU (ORCPT ); Fri, 28 Sep 2018 14:35:20 -0400 Received: from [78.46.172.2] (helo=sslproxy05.your-server.de) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.85_2) (envelope-from ) id 1g5rcb-0001fR-Fr; Fri, 28 Sep 2018 14:11:49 +0200 Received: from [178.197.248.15] (helo=linux.home) by sslproxy05.your-server.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1g5rcb-000HfH-Az; Fri, 28 Sep 2018 14:11:49 +0200 Subject: Re: [PATCH bpf-next] bpf: fix flags check in bpf_percpu_cgroup_storage_update() To: Roman Gushchin , netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, Alexei Starovoitov References: <20180928110648.22973-1-guro@fb.com> From: Daniel Borkmann Message-ID: Date: Fri, 28 Sep 2018 14:11:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20180928110648.22973-1-guro@fb.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.100.1/24989/Fri Sep 28 10:53:45 2018) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/28/2018 01:06 PM, Roman Gushchin wrote: > Fix an issue in bpf_percpu_cgroup_storage_update(): it should return > -EINVAL on an attempt to pass BPF_NOEXIST rather than BPF_EXIST. > > Cgroup local storage is automatically created on attaching of a bpf > program to a cgroup, and it can't be done from the userspace. > > Fixes: 0daef9b42374 ("bpf: introduce per-cpu cgroup local storage") > Signed-off-by: Roman Gushchin > Cc: Daniel Borkmann > Cc: Alexei Starovoitov > --- > kernel/bpf/local_storage.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/bpf/local_storage.c b/kernel/bpf/local_storage.c > index c739f6dcc3c2..190535f6d5e2 100644 > --- a/kernel/bpf/local_storage.c > +++ b/kernel/bpf/local_storage.c > @@ -191,7 +191,7 @@ int bpf_percpu_cgroup_storage_update(struct bpf_map *_map, void *_key, > int cpu, off = 0; > u32 size; > > - if (unlikely(map_flags & BPF_EXIST)) > + if (map_flags & BPF_NOEXIST) > return -EINVAL; Hmm, this is also incorrect as any future reserved flag would be accepted here and couldn't be extended anymore. :/ And it looks like cgroup_storage_update_elem() is doing the same today, given the cgroups local storage is still early, we should route a patch to stable for fixing this. Wrt this series, given the series is top of tree right now, I would prefer a fresh respin so we have the fix integrated properly w/o follow-up. Perhaps this could also incorporate Alexei's previous cleanup suggestions as well from today if you have a chance. Thanks, Daniel