Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3978050pxu; Wed, 9 Dec 2020 05:35:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwx7qyyUeIVBWJMt5L8+2wjqWqEdv6GeJpc/tXwErPJacwNL5/g+M/9aKV+OZ/lJXlTx2PZ X-Received: by 2002:a17:906:cc9c:: with SMTP id oq28mr2114657ejb.224.1607520920295; Wed, 09 Dec 2020 05:35:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607520920; cv=none; d=google.com; s=arc-20160816; b=KZDAQTnyKfK4KR4ZOZRpkbN7cnI4pXCA4pJ/X8AHPY9wVZfTzDm8MqEhmeDASswJ49 QOX9TvZXUGBhZRtz729UT8N37Ry41QPG0P1QcUCEO3Iy3x6krt9P35JgpzH9sZFD+GuV 2wqaYx9SnSJWYCaO3Rt2QXlodEVrZ30bNg0MW2AhcLJKZo7hgSjY96dZrKKdT8C6fRoQ c225wslqBGGmvumNj/P4GXnCGiYBA3vk1KGfJN957zpP4UIELnlK+SSrtFHfTflZ/+O/ JrTcm8wWQGdDf1tiMRi/qIwdYUgvItz4U5UVmB4fdWE/y86TMO5gSeonuhZb6LzV2Qzw zJgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=4DYUQu0RnUP+8Pjc8kSEgv+OIMP/f6lYTVbWVeSCUVU=; b=kCB3+vc3NogTR5t26GQu/tQh3s6oLyR9Pld5R34Iq21H7zBVN3zLOLz997HhpeL8+L Nnxh1sbsBSGq8H9POOo4LU37QFuCXCB4X6iC5UNyN0looc+jjbsceXov9m3hQhXRCilk zyjxU/Y4OlyJrLNt3FQuRVu+oTfWmnMfxVPTAe6t84XOpvrCh3gJy8oL/xlAHuSpR1pP x7x0ttaLB1qlHyT94KeRdjHVhuxkxZVeo4rEfRgh1+3XvJLZ4+8wKJrQGZcx+WBPTIZf U4amsSLYTFaujrk4ccBE+ezcvVXDEAqNP8EeQ5qCiu4x0UqUUZxn6ipIp+WfC/fafo3p tWNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cUVqsj5L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v5si1082931edi.183.2020.12.09.05.34.57; Wed, 09 Dec 2020 05:35:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cUVqsj5L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732321AbgLIN1V (ORCPT + 99 others); Wed, 9 Dec 2020 08:27:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729522AbgLIN1U (ORCPT ); Wed, 9 Dec 2020 08:27:20 -0500 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FB61C0613CF for ; Wed, 9 Dec 2020 05:26:40 -0800 (PST) Received: by mail-wm1-x344.google.com with SMTP id g185so1667042wmf.3 for ; Wed, 09 Dec 2020 05:26:40 -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=4DYUQu0RnUP+8Pjc8kSEgv+OIMP/f6lYTVbWVeSCUVU=; b=cUVqsj5LFdc+s2n2frLO3T8S38RQsoBLeYHX17kARTFQTCge3mWtrw2y4Fax8dMg4m xzZldvYLG8rhEQg+Ix+NJOhdwlSXZM/ngCJMgA5oEuWDYfqMW5nZPKFbX9ItrjzeBmpf OHBBK6ogpwYle2XEzAhaKeA3kXmwNkwURGvWw= 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=4DYUQu0RnUP+8Pjc8kSEgv+OIMP/f6lYTVbWVeSCUVU=; b=pxCMB/ZowP5pcBwCqBsC+e4luFvm40ZwFKNqDwIuOEzdYg4RMFZ2hG77JASZMvSY6Y +GGIWxr3v2gL4UmH88whzytxLghJ3XDEsl5Sc1VUEL2gF2c4orQCLfNvAEoLuwMlInSI rdk8EA88U+ChaktbMaDwH+1FxcwXhm+E8ZUmMr5Y2IK85Uc4yWA8dajzY34HZiSZSJI2 vx+GNkWkSHJO8/quU/lTeA+a7sGhZJ9H/JNHmkUZ3lRAAi6/0fuoENtoG9rt5ZFeuREK RihsECY/yxS0/fCvVPKCu7q+jseagBh2HhNEiMGS/rmt+oTWx+2so1wyMc9BtIq/wRc5 PX0A== X-Gm-Message-State: AOAM532ahyZauoKZmOFoNyMpx7Ru+0bEAwygHLotTWrcR2L/ebLf6kuc Ud0u3PjAOoYork9bUP4M0adqhw== X-Received: by 2002:a7b:c205:: with SMTP id x5mr2903826wmi.115.1607520399095; Wed, 09 Dec 2020 05:26:39 -0800 (PST) Received: from revest.zrh.corp.google.com ([2a00:79e0:42:204:f693:9fff:fef4:a569]) by smtp.gmail.com with ESMTPSA id t16sm3631490wri.42.2020.12.09.05.26.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 05:26:38 -0800 (PST) From: Florent Revest To: bpf@vger.kernel.org Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, kpsingh@chromium.org, kafai@fb.com, linux-kernel@vger.kernel.org, Florent Revest Subject: [PATCH bpf-next v4 1/4] bpf: Be less specific about socket cookies guarantees Date: Wed, 9 Dec 2020 14:26:33 +0100 Message-Id: <20201209132636.1545761-1-revest@chromium.org> X-Mailer: git-send-email 2.29.2.576.ga3fc446d84-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 30b477a26482..ba59309f4d18 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -1650,22 +1650,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 30b477a26482..ba59309f4d18 100644 --- a/tools/include/uapi/linux/bpf.h +++ b/tools/include/uapi/linux/bpf.h @@ -1650,22 +1650,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 -- 2.29.2.576.ga3fc446d84-goog