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=-0.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 52F2CC433E0 for ; Mon, 8 Jun 2020 19:45:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2388C2068D for ; Mon, 8 Jun 2020 19:45:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="h2+IFRrT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726431AbgFHTpB (ORCPT ); Mon, 8 Jun 2020 15:45:01 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:45592 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726406AbgFHTpB (ORCPT ); Mon, 8 Jun 2020 15:45:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591645499; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VaxVZkjnEZYrrPi0S56z9hliQp1tI96IZ+GgYvyZSpw=; b=h2+IFRrTZN6xbjTnnYqGZnEMZ5d8BpXHfNSdoVVdhnTN4ItY1ekLqE2QacCIjxqTGyYK7f lb22kKp+GaTCiTOqxVeQNtXuDSVnG5Ib2rjodcKFZiPpSHHn2+6c2Zygphxlgr4ZFZuZS7 gRQwloUEnVwL64tRsha8uxhS3ip1Z98= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-343-nq1Dq9QyM06uvBumsB0RcQ-1; Mon, 08 Jun 2020 15:44:46 -0400 X-MC-Unique: nq1Dq9QyM06uvBumsB0RcQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C517918FE860; Mon, 8 Jun 2020 19:44:44 +0000 (UTC) Received: from carbon (unknown [10.40.208.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 715E1768B4; Mon, 8 Jun 2020 19:44:39 +0000 (UTC) Date: Mon, 8 Jun 2020 21:44:37 +0200 From: Jesper Dangaard Brouer To: Andrii Nakryiko Cc: David Ahern , bpf , Alexei Starovoitov , Networking , Daniel Borkmann , Lorenzo Bianconi , brouer@redhat.com Subject: Re: [PATCH bpf 1/3] bpf: syscall to start at file-descriptor 1 Message-ID: <20200608214437.5f7766ab@carbon> In-Reply-To: References: <159163498340.1967373.5048584263152085317.stgit@firesoul> <159163507753.1967373.62249862728421448.stgit@firesoul> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Mon, 8 Jun 2020 11:36:33 -0700 Andrii Nakryiko wrote: > On Mon, Jun 8, 2020 at 9:51 AM Jesper Dangaard Brouer wrote: > > > > This patch change BPF syscall to avoid returning file descriptor value zero. > > > > As mentioned in cover letter, it is very impractical when extending kABI > > that the file-descriptor value 'zero' is valid, as this requires new fields > > must be initialised as minus-1. First step is to change the kernel such that > > BPF-syscall simply doesn't return value zero as a FD number. > > > > This patch achieves this by similar code to anon_inode_getfd(), with the > > exception of getting unused FD starting from 1. The kernel already supports > > starting from a specific FD value, as this is used by f_dupfd(). It seems > > simpler to replicate part of anon_inode_getfd() code and use this start from > > offset feature, instead of using f_dupfd() handling afterwards. > > Wouldn't it be better to just handle that on libbpf side? That way it > works on all kernels and doesn't require this duplication of logic > inside kernel? IMHO this is needed on the kernel side, to pair it with the API change. I don't see how doing this in libbpf can cover all cases. First of all, some users might not be using libbpf. Second, a userspace application could be using an older version of libbpf on a newer kernel. (Notice this is not only due to older distros, but also because projects using git submodule libbpf will freeze at some point in time that worked). -- Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer