From patchwork Tue Jan 26 18:35:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florent Revest X-Patchwork-Id: 12048541 X-Patchwork-Delegate: bpf@iogearbox.net 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=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT 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 84660C433DB for ; Tue, 26 Jan 2021 22:53:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A4742065D for ; Tue, 26 Jan 2021 22:53:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727877AbhAZWxT (ORCPT ); Tue, 26 Jan 2021 17:53:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389662AbhAZSiW (ORCPT ); Tue, 26 Jan 2021 13:38:22 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9863CC0617AA for ; Tue, 26 Jan 2021 10:36:08 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id c12so17579477wrc.7 for ; Tue, 26 Jan 2021 10:36:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NmVEUkooFz5Tfz1+fj+rLfrC74ZA/wXoG61R5qDLmbU=; b=DVbwGC8thxi+LMqdMJaD5FDz+72wUPoAX9YrH2g8z65x+Y/7wxfxy+7jVJZ0LnlQfl 6TGvJhHAZtPCuzaw9l1U4g2fTEkckLxTLtMIG5qLTq8pL3p66gRZwfPzdrsrYTP6o4bp 9C2ZIZVOzaoNja8akpTcC9Rt20vjoG1A512BA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NmVEUkooFz5Tfz1+fj+rLfrC74ZA/wXoG61R5qDLmbU=; b=h7lU4Z2c3+2M3rir4DHw25Crz5vz0gY5gGAgnKu2f3QxGY4Re6lca8fdXYzVcCW0M5 JQnAdJ7rojE+AsdNht5LnA1g0ZvK8hIsKaFMu3eCceb+KujHkv1VtsleeNNFmgwSpG5C t3wv0zkFiyBBrT2dpfE4nghOlQq8mEPNIENJAePY/K4N5HkvxQ0dtig30Kztnoqv1rmg EKjSD9a6iYqsPQU4NsaYOz4MbJ5izGNYq3yOINiBVIU5bUbacs71iPqcbs5QPYfJG4dl bGEeoHQlogTDmtvgq9cQ/98+zXpa2exgOgQL04v1xAJ1chCdYlFFyEiMZfO/8BwJT94w QWyA== X-Gm-Message-State: AOAM531ducqZojBNHm+l1Jqnr8gfeTdmdUx2kAL3cvjvQn+ZRw3KNnyK t7mE0FOnvfHV9L+5VEWUzREvkjxsEbKoOA== X-Google-Smtp-Source: ABdhPJzXdwv/c9GLOmKOtZ+ecBeub/zi4Knq2tTYbBTvcCvgxl0qC5VJ3WgT2IULsq08r4A6ADxHQg== X-Received: by 2002:a5d:47a2:: with SMTP id 2mr7499442wrb.393.1611686167020; Tue, 26 Jan 2021 10:36:07 -0800 (PST) Received: from revest.zrh.corp.google.com ([2a00:79e0:42:204:deb:d0ec:3143:2380]) by smtp.gmail.com with ESMTPSA id d13sm28339354wrx.93.2021.01.26.10.36.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jan 2021 10:36:06 -0800 (PST) From: Florent Revest To: bpf@vger.kernel.org Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, kpsingh@chromium.org, linux-kernel@vger.kernel.org, Florent Revest , KP Singh Subject: [PATCH bpf-next v6 1/5] bpf: Be less specific about socket cookies guarantees Date: Tue, 26 Jan 2021 19:35:55 +0100 Message-Id: <20210126183559.1302406-1-revest@chromium.org> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Since "92acdc58ab11 bpf, net: Rework cookie generator as per-cpu one" socket cookies are not guaranteed to be non-decreasing. The bpf_get_socket_cookie helper descriptions are currently specifying that cookies are non-decreasing but we don't want users to rely on that. Reported-by: Daniel Borkmann Signed-off-by: Florent Revest Acked-by: KP Singh --- include/uapi/linux/bpf.h | 8 ++++---- tools/include/uapi/linux/bpf.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index c001766adcbc..0b735c2729b2 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -1656,22 +1656,22 @@ union bpf_attr { * networking traffic statistics as it provides a global socket * identifier that can be assumed unique. * Return - * A 8-byte long non-decreasing number on success, or 0 if the - * socket field is missing inside *skb*. + * A 8-byte long unique number on success, or 0 if the socket + * field is missing inside *skb*. * * u64 bpf_get_socket_cookie(struct bpf_sock_addr *ctx) * Description * Equivalent to bpf_get_socket_cookie() helper that accepts * *skb*, but gets socket from **struct bpf_sock_addr** context. * Return - * A 8-byte long non-decreasing number. + * A 8-byte long unique number. * * u64 bpf_get_socket_cookie(struct bpf_sock_ops *ctx) * Description * Equivalent to **bpf_get_socket_cookie**\ () helper that accepts * *skb*, but gets socket from **struct bpf_sock_ops** context. * Return - * A 8-byte long non-decreasing number. + * A 8-byte long unique number. * * u32 bpf_get_socket_uid(struct sk_buff *skb) * Return diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index c001766adcbc..0b735c2729b2 100644 --- a/tools/include/uapi/linux/bpf.h +++ b/tools/include/uapi/linux/bpf.h @@ -1656,22 +1656,22 @@ union bpf_attr { * networking traffic statistics as it provides a global socket * identifier that can be assumed unique. * Return - * A 8-byte long non-decreasing number on success, or 0 if the - * socket field is missing inside *skb*. + * A 8-byte long unique number on success, or 0 if the socket + * field is missing inside *skb*. * * u64 bpf_get_socket_cookie(struct bpf_sock_addr *ctx) * Description * Equivalent to bpf_get_socket_cookie() helper that accepts * *skb*, but gets socket from **struct bpf_sock_addr** context. * Return - * A 8-byte long non-decreasing number. + * A 8-byte long unique number. * * u64 bpf_get_socket_cookie(struct bpf_sock_ops *ctx) * Description * Equivalent to **bpf_get_socket_cookie**\ () helper that accepts * *skb*, but gets socket from **struct bpf_sock_ops** context. * Return - * A 8-byte long non-decreasing number. + * A 8-byte long unique number. * * u32 bpf_get_socket_uid(struct sk_buff *skb) * Return