Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp3044528pxb; Tue, 12 Jan 2021 05:08:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJxlTyXTGTr6en8/BQ4d8PJ2aB1ZmVoxVQ9yLV4qzkg3NFu+BQlcHDlwy0MdgRJK+O1nxXc2 X-Received: by 2002:a05:6402:1b1e:: with SMTP id by30mr3310862edb.75.1610456895130; Tue, 12 Jan 2021 05:08:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610456895; cv=none; d=google.com; s=arc-20160816; b=eNTanl0oCUhg26dTiJZnuRk56jJf4qIPKEy58TipkSfjaAkP1+nSJO3OqURjgquCUj Hjwfl8cw844U977zYA/JaF6V8vC/tVpzgglvhlDRnGLcce2UqaNxD/LpjgdgAu5Ii2TX J37T3rgRrRUBaJYf/vG7YsYbmDRN3jfpAA6c6PU9UIZF9oFEH251m+NCZsDSfYWkDJS0 xhpytioVmlvorit4Ew+lr4quNkhWfAvZPD9mRz8IG33OV0KMsoJRE94bxbWEEVe5VqRG 5/ZR8l5BN9gQ0q8SGARXEPJzd7yjcJ+gzVimyXYVfr34Cmsvaq3J/LzZsdqp2Smey7zM bnEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :sender:dkim-signature; bh=pU2TD0vHzJMOEXt8gPn4RurzqWNYxl51610uNTFZEgc=; b=qoD2A94WTwMr/MGsJ1rmxHUkmR6Pk5/Wn3TMJz/JQRrgdrShx488MIPCPTQCnq6h61 vJgr2GQ15KXdvowKQXokvuWo7dxLBXKoN1AmAmttZWEO4eRVdIlMtXf0l63vtFibDU31 5JHAlniYWZHK/8nebvpJj2p1guqr0ZSkQArk++Gbrej6NofP9xzTnOqK7kITcjnjQHdD HFsnIByFQo1+fLqQeDCIuby2l8NOTJz+Sg1lCsUiMIxEwqvM1vhg3o5ZZm9mvqyjcK+i MFfTpymM8DoDOdJlTUQRecPl/vwGKRHcRG8nKp4rLpwh3FOcOp5Y4odlRw6fTTXiwaHq eIlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FpRsluB+; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rk15si1094181ejb.170.2021.01.12.05.07.49; Tue, 12 Jan 2021 05:08:15 -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=@google.com header.s=20161025 header.b=FpRsluB+; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728809AbhALMfX (ORCPT + 99 others); Tue, 12 Jan 2021 07:35:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726501AbhALMfW (ORCPT ); Tue, 12 Jan 2021 07:35:22 -0500 Received: from mail-wm1-x34a.google.com (mail-wm1-x34a.google.com [IPv6:2a00:1450:4864:20::34a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 026E9C061575 for ; Tue, 12 Jan 2021 04:34:42 -0800 (PST) Received: by mail-wm1-x34a.google.com with SMTP id w204so445931wmb.1 for ; Tue, 12 Jan 2021 04:34:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=pU2TD0vHzJMOEXt8gPn4RurzqWNYxl51610uNTFZEgc=; b=FpRsluB+WQNzSpcn2oBDxF4pnB7gSgIte+V69x6+EXwPE9aAwIfjrCtScG7gBxwfuh cC9EZH6eRaOenzBj8p5IvQ8KpokVaV/5rDVvuxgPjh+TtgimAbcZUCDtip1k+YtlCuys 51gLgakYwh0MvLiITSMHNI6bOO3wQPKziNYpxfIpYerqK/Zm18mmNScXxi2dxin+rQMr eb2YIeH084l1rvj4OgGWpP3eQ3RZ8uGLlO/LtL8a2fpPhH4YW6bu2isnSYX+482HmpTH pmoOR8z7htAckAZ5wItUZ3PUtNrUvv22bXjYXD9q4Qx++ghRotqEYcRrwIEXwe8bBEJC C84w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=pU2TD0vHzJMOEXt8gPn4RurzqWNYxl51610uNTFZEgc=; b=Z0h/9L1dMcPDZg5tsx9oIUhW4eJXYi+TCNWJyBx5/KchoS7HouZozKX09dbgcLaMuK a0OoDx2/799udDgkxSXqZcTMwBOyL6fFwQuc4LVicv9b+bGfMQQXE0oFla2nLFoPMBQk BSrYWz3wRb5SXEs4Ap6o7gqg3B0HNOmH9PAXr9Mjnn1Z0q0Y1p79/+2nSv6twVahKqor KOjSEfg75W0zPQUfQExXOTlumpdFwu7PoLJAFW2WHpMlKyE6mtWDEAN5zUkHJi3njHwT fvtPs3yjs3JG+xI0LvorE6gRvitb2jOTkl3VyR+eyLNK2JgmKGfit4lZyBTjWPQJr+BJ 8XCQ== X-Gm-Message-State: AOAM533ttnLRg4VNQ9teEi02VmDILqJUUP4+hgKPEkwHv2kPhzvE2rpf zn1qgNT4QU/W0G1Sn43PgkIhFZE+r8IsrQ== Sender: "jackmanb via sendgmr" X-Received: from beeg.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:11db]) (user=jackmanb job=sendgmr) by 2002:a7b:c2e8:: with SMTP id e8mr3341182wmk.103.1610454880590; Tue, 12 Jan 2021 04:34:40 -0800 (PST) Date: Tue, 12 Jan 2021 12:34:22 +0000 Message-Id: <20210112123422.2011234-1-jackmanb@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog Subject: [PATCH bpf-next] bpf: Clarify return value of probe str helpers From: Brendan Jackman To: bpf@vger.kernel.org Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , KP Singh , Florent Revest , linux-kernel@vger.kernel.org, Brendan Jackman Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the buffer is too small to contain the input string, these helpers return the length of the buffer, not the length of the original string. This tries to make the docs totally clear about that, since "the length of the [copied ]string" could also refer to the length of the input. Signed-off-by: Brendan Jackman --- include/uapi/linux/bpf.h | 10 +++++----- tools/include/uapi/linux/bpf.h | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index 77d7c1bb2923..a1ad32456f89 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -2993,10 +2993,10 @@ union bpf_attr { * string length is larger than *size*, just *size*-1 bytes are * copied and the last byte is set to NUL. * - * On success, the length of the copied string is returned. This - * makes this helper useful in tracing programs for reading - * strings, and more importantly to get its length at runtime. See - * the following snippet: + * On success, returns the number of bytes that were written, + * including the terminal NUL. This makes this helper useful in + * tracing programs for reading strings, and more importantly to + * get its length at runtime. See the following snippet: * * :: * @@ -3024,7 +3024,7 @@ union bpf_attr { * **->mm->env_start**: using this helper and the return value, * one can quickly iterate at the right offset of the memory area. * Return - * On success, the strictly positive length of the string, + * On success, the strictly positive length of the output string, * including the trailing NUL character. On error, a negative * value. * diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index 77d7c1bb2923..a1ad32456f89 100644 --- a/tools/include/uapi/linux/bpf.h +++ b/tools/include/uapi/linux/bpf.h @@ -2993,10 +2993,10 @@ union bpf_attr { * string length is larger than *size*, just *size*-1 bytes are * copied and the last byte is set to NUL. * - * On success, the length of the copied string is returned. This - * makes this helper useful in tracing programs for reading - * strings, and more importantly to get its length at runtime. See - * the following snippet: + * On success, returns the number of bytes that were written, + * including the terminal NUL. This makes this helper useful in + * tracing programs for reading strings, and more importantly to + * get its length at runtime. See the following snippet: * * :: * @@ -3024,7 +3024,7 @@ union bpf_attr { * **->mm->env_start**: using this helper and the return value, * one can quickly iterate at the right offset of the memory area. * Return - * On success, the strictly positive length of the string, + * On success, the strictly positive length of the output string, * including the trailing NUL character. On error, a negative * value. * base-commit: e22d7f05e445165e58feddb4e40cc9c0f94453bc -- 2.30.0.284.gd98b1dd5eaa7-goog