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=-4.0 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED 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 EB33AC282C5 for ; Thu, 24 Jan 2019 20:08:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B020E21855 for ; Thu, 24 Jan 2019 20:08:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="ciD23NBy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730239AbfAXUIo (ORCPT ); Thu, 24 Jan 2019 15:08:44 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:41884 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730614AbfAXT26 (ORCPT ); Thu, 24 Jan 2019 14:28:58 -0500 Received: by mail-pg1-f195.google.com with SMTP id m1so3084424pgq.8 for ; Thu, 24 Jan 2019 11:28:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=f7dgJSKO9GG3y3kD5qvGT+mHgwqeMIriycK8FkJEBFM=; b=ciD23NByjWOWRzsHTks+1G+4SgewayzSDzFHWBryvoYmc/Ud5EMhdK5iQalGfckLhF EMr+kP9U21gk5uXMyB7wPPeZS6gArxwXM9dSj7wwGgSTVzh+lT5mBTF64xGuhYmV30ja JPwBnH+yx7C3yT/QmzMulqX1v+4/+QngjEFv07s7/suH8HZHzPiMS0I1BF8hG3DMwE/V usT3oxli6CaavYoIiOIZnUMKpxCe/kr95bRxnDWMIIDRxqB21dRXFA0zx9Iy/xqXAG2c s2U5BiXiPc3OqMFw1RwxGzX+4yDzMRmCzJ+jhWsVjB3ZnzKIet2vzApHjWF+fvqFtyMh 0AIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=f7dgJSKO9GG3y3kD5qvGT+mHgwqeMIriycK8FkJEBFM=; b=AC4mdxk68RZbnpr/n/fvdJ22CyU4Y30f+OtIyWCdNuINIu+j2nALk+tD2zIBgHKEqM 8CYI6GkJ3NkAIO2RTVcwV5Z173g0c86CJ4/sseQ4nuGR58bcn5B2gIW6hHpx8niUpF+u bvzY1pgINTuut/HtHRY/jl23Dy2HT2eGhHeilg7d3cOvm1nMpUVMoGz6ixid9WzQFr3/ RJHpKwzJDPus78P7KSYjX4nuXw1rRe4J4V1FRzM4MmOlIZ9CynIMRf2UFIIFbki5Cs5g cXlvWPdge73nc8GrYqr0+HVpjwImrQfJ5Jl7WX+bmlO7bsMhUuN+lsUhAtGRJvk+5oRq Oqqg== X-Gm-Message-State: AJcUukcIiWIcmDrrOtsRIGm+XUPT2fnDaCq5qwm4fr1vtdN9Ck+n0xUQ e/fobDTmJfN4JwWzy4xuOXqp0Q== X-Google-Smtp-Source: ALg8bN76nyq8M7Sg5QcJGQjwBE43DUnXqHoVOz2Z3DTeJiAQSs9sElJxSKmz75ErILVck4ZLdNUmdQ== X-Received: by 2002:a62:1992:: with SMTP id 140mr7824908pfz.33.1548358137563; Thu, 24 Jan 2019 11:28:57 -0800 (PST) Received: from cakuba.netronome.com ([66.60.152.14]) by smtp.gmail.com with ESMTPSA id m67sm35354728pfb.25.2019.01.24.11.28.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Jan 2019 11:28:57 -0800 (PST) Date: Thu, 24 Jan 2019 11:28:53 -0800 From: Jakub Kicinski To: Daniel Borkmann Cc: alexei.starovoitov@gmail.com, yhs@fb.com, sdf@google.com, brouer@redhat.com, netdev@vger.kernel.org, oss-drivers@netronome.com Subject: Re: [RFC bpf-next] bpf: allow users to opt out of releasing objects when urefs are gone Message-ID: <20190124112853.263aaaa3@cakuba.netronome.com> In-Reply-To: References: <20190121201021.30785-1-jakub.kicinski@netronome.com> Organization: Netronome Systems, Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, 24 Jan 2019 12:17:27 +0100, Daniel Borkmann wrote: > On 01/21/2019 09:10 PM, Jakub Kicinski wrote: > > Commit c9da161c6517 ("bpf: fix clearing on persistent program array maps") > > added protection against dependency loops between programs and maps leading > > to zombie objects which would never be freed. FD maps are flushed when > > last user reference is gone. > > > > This is confusing to users of bpftool, as updates to tail call maps have > > no effect, unless those maps are pinned (or open by another entity). > > Probably would make sense to only allow updates by providing the pinned > map path in case of tail call map (and e.g. not by id)? Hm, yes, or at least print a warning. > > Today, flushing should not be a requirement for privileged user, as root > > has access to GET_FD_BY_ID commends, and therefore can manually flush > > the maps. Add a flag to opt out of automatic flushing. > > > > Signed-off-by: Jakub Kicinski > > Reviewed-by: Quentin Monnet > > --- > > Hi! > > > > I wonder what the reactions to this (untested) patch would be? I don't > > really care strongly, but perhaps others experienced a similar issue? > > My main worry with this is that this might lead to hard to debug memory > consumption issues, for example, once apps start to make wider use of > this flag (and even worse would load maps with BPF progs with circular > references), then they won't be cleaned up on detach and keep holding > potentially huge amount of kernel memory. It's true that similar issues > would happen when long running app leaks tail call map fd or the map > is a stale leftover node in bpf fs, but it feels there's still better > tooling out of user space for tracing back their correlation (e.g. fds, > file access to pinned entry) and given the fact that then there's a > guaranteed flush once urefs are fully dropped. Not having it and scanning > through GET_FD_BY_ID range for such cases to determine a stale tail call > map, its potential origin, and breaking up dependencies seems much harder > (or at least there's proper tooling missing for it today). Makes sense, I'll toss the patch with clear conscience :)