Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3877466rwa; Tue, 23 Aug 2022 11:42:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR5coyFXmGXuGzIt3hSgBUEXuPNjoTgYTASqQ+BiZmBCMvlNCUH35boJLY4sciosMDNRqHXX X-Received: by 2002:a17:90b:4c52:b0:1f6:3a26:9f08 with SMTP id np18-20020a17090b4c5200b001f63a269f08mr4547864pjb.206.1661280178625; Tue, 23 Aug 2022 11:42:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661280178; cv=none; d=google.com; s=arc-20160816; b=h+usZxroXmf38WwCo1YsGpggaHtL+fg9lTnlbLnRl6lyIJQMVP9ylBRVAzKQb/s/Km uO49JtGz/a3M5Xez7Qh4agYz70xlsHFFooQLiLnabZDRko1Gv031F9MED9eNIDSrYgdO kspAKVifA+GZv7j23+XQ1P6fA2+bJwuxI4UaK3PFIwBR07hgOOsC9dStacPff598XnXC mdmGrUJN0DTHTvFY5CY9OR/NGQmrPOjbYTMiH8rX4bnf2xoEcnh89+D1duO6QExP3qDV mnSnlgN6OMAkgR+zytFWN2cgAu8vhRPXkymg3gxly5/JYlm+e3tTYzftkOxd/DifHCaU FlEA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=BfVRmRay4uXQoArqInvXLTTOMNpUs+Me9VYD2UKaVHg=; b=HlzUpy+i4PAEjdHctuhs+FfrYf6rSAANrTQjFJiNyhT2XpyDeii6HmcWMl3h9ZPToC rVKOpacR/c5/bbK/dK7kOFMcvP4DqPmCobWkkCHTEHhhziTGFztIEwYVsd5BdJU0dAzC ZLyBqYw3pJ9twIgCd2g77IMIgxLWWh8UkXfLJwFaQeKsOQ1EcWo77Bq+ANJxRkp7xl9E CrquQoxPHB7hZy5E5xroOhexqJPlIrPyOMr6R1FIuDh9TvWiCAXt+rNIKNfgFfDMM2UI qGFltYyjHBuQjch8f/eq1Q/stR3o++3WvodjQ524E3azOik7ZHNsOx0bUIGTmYStUE7k Sq2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nd10-20020a17090b4cca00b001fb395f4814si6051978pjb.180.2022.08.23.11.42.46; Tue, 23 Aug 2022 11:42:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229673AbiHWR0W (ORCPT + 99 others); Tue, 23 Aug 2022 13:26:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234951AbiHWRZl (ORCPT ); Tue, 23 Aug 2022 13:25:41 -0400 Received: from frasgout11.his.huawei.com (frasgout11.his.huawei.com [14.137.139.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56F47B2CD1; Tue, 23 Aug 2022 08:02:07 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.18.147.228]) by frasgout11.his.huawei.com (SkyGuard) with ESMTP id 4MBskk4SdTz9v7GZ; Tue, 23 Aug 2022 22:56:46 +0800 (CST) Received: from huaweicloud.com (unknown [10.204.63.22]) by APP2 (Coremail) with SMTP id GxC2BwBnIhqd6wRjjU5GAA--.52413S5; Tue, 23 Aug 2022 16:01:38 +0100 (CET) From: Roberto Sassu To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, mykolal@fb.com, corbet@lwn.net, dhowells@redhat.com, jarkko@kernel.org, rostedt@goodmis.org, mingo@redhat.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, shuah@kernel.org Cc: bpf@vger.kernel.org, linux-doc@vger.kernel.org, keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, deso@posteo.net, Roberto Sassu , Joanne Koong Subject: [PATCH v13 03/10] bpf: Export bpf_dynptr_get_size() Date: Tue, 23 Aug 2022 17:00:28 +0200 Message-Id: <20220823150035.711534-4-roberto.sassu@huaweicloud.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220823150035.711534-1-roberto.sassu@huaweicloud.com> References: <20220823150035.711534-1-roberto.sassu@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: GxC2BwBnIhqd6wRjjU5GAA--.52413S5 X-Coremail-Antispam: 1UD129KBjvJXoW7tF18XrWrtrWxKrWfKw47XFb_yoW8XF17pa 95C347Jr48tFWIvrWUJws7Z3yjganrWr17GFyvk34F9rWIqF9xur1jgr4xKr90y34DGFW5 ArnrKrWFv3W8JrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBab4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6r1F6r1fM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUWw A2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVWUJVWUCwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6r4UJVWxJr1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2 WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkE bVWUJVW8JwACjcxG0xvY0x0EwIxGrwACI402YVCY1x02628vn2kIc2xKxwCF04k20xvY0x 0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E 7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_WrylIxkGc2Ij64vIr41lIxAIcV C0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwCI42IY 6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aV CY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x07UAkuxUUUUU= X-CM-SenderInfo: purev21wro2thvvxqx5xdzvxpfor3voofrz/1tbiAQANBF1jj4I6SAABsI X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Roberto Sassu Export bpf_dynptr_get_size(), so that kernel code dealing with eBPF dynamic pointers can obtain the real size of data carried by this data structure. Reviewed-by: Joanne Koong Signed-off-by: Roberto Sassu --- include/linux/bpf.h | 1 + kernel/bpf/helpers.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 39bd36359c1e..6041304b402e 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -2576,6 +2576,7 @@ void bpf_dynptr_init(struct bpf_dynptr_kern *ptr, void *data, enum bpf_dynptr_type type, u32 offset, u32 size); void bpf_dynptr_set_null(struct bpf_dynptr_kern *ptr); int bpf_dynptr_check_size(u32 size); +u32 bpf_dynptr_get_size(struct bpf_dynptr_kern *ptr); #ifdef CONFIG_BPF_LSM void bpf_cgroup_atype_get(u32 attach_btf_id, int cgroup_atype); diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index 3c1b9bbcf971..e4637ccb3016 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -1442,7 +1442,7 @@ static void bpf_dynptr_set_type(struct bpf_dynptr_kern *ptr, enum bpf_dynptr_typ ptr->size |= type << DYNPTR_TYPE_SHIFT; } -static u32 bpf_dynptr_get_size(struct bpf_dynptr_kern *ptr) +u32 bpf_dynptr_get_size(struct bpf_dynptr_kern *ptr) { return ptr->size & DYNPTR_SIZE_MASK; } -- 2.25.1