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.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no 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 0E743C433DF for ; Fri, 17 Jul 2020 16:25:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ECFF12074B for ; Fri, 17 Jul 2020 16:25:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726550AbgGQQZa (ORCPT ); Fri, 17 Jul 2020 12:25:30 -0400 Received: from verein.lst.de ([213.95.11.211]:39423 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726013AbgGQQZa (ORCPT ); Fri, 17 Jul 2020 12:25:30 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 29CBD68BEB; Fri, 17 Jul 2020 18:25:27 +0200 (CEST) Date: Fri, 17 Jul 2020 18:25:26 +0200 From: Christoph Hellwig To: Alexei Starovoitov Cc: Christoph Hellwig , Stanislav Fomichev , Alexei Starovoitov , "David S. Miller" , Network Development , bpf Subject: Re: how is the bpfilter sockopt processing supposed to work Message-ID: <20200717162526.GA17072@lst.de> References: <20200717055245.GA9577@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, Jul 17, 2020 at 09:13:07AM -0700, Alexei Starovoitov wrote: > On Thu, Jul 16, 2020 at 10:52 PM Christoph Hellwig wrote: > > > > Hi Alexei, > > > > I've just been auditing the sockopt code, and bpfilter looks really > > odd. Both getsockopts and setsockopt eventually end up > > in__bpfilter_process_sockopt, which then passes record to the > > userspace helper containing the address of the optval buffer. > > Which depending on bpf-cgroup might be in user or kernel space. > > But even if it is in userspace it would be in a different process > > than the bpfiler helper. What makes all this work? > > Hmm. Good point. bpfilter assumes user addresses. It will break > if bpf cgroup sockopt messes with it. > We had a different issue with bpf-cgroup-sockopt and iptables in the past. > Probably the easiest way forward is to special case this particular one. > With your new series is there a way to tell in bpfilter_ip_get_sockopt() > whether addr is kernel or user? And if it's the kernel just return with error. Yes, I can send a fix. But how do even the user space addressed work? If some random process calls getsockopt or setsockopt, how does the bpfilter user mode helper attach to its address space?