From nobody Fri Nov 29 19:39:08 2024 Received: from msa.smtpout.orange.fr (out-69.smtpout.orange.fr [193.252.22.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9EF9838DD1 for ; Sun, 15 Sep 2024 16:22:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.252.22.69 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726417336; cv=none; b=aKLCtAIXVzQKrqkZgkVZdTUdoPq76vHp/xIik78aFgt9giyI6nIwpPeE8CQIjGZnxbhsoQq+uju/8b4075ZTEV3eR4RKvCJLKXOxThplH/lS97KNyWXE8FCZRv1JFrgAqKv/+541A3JkcdJOiMhn8ovesxHq1CYk6bdXUfPMzXw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726417336; c=relaxed/simple; bh=iP5KDxcrGXOfBoGJGJ0pumZ3z5ExNyCE/KMQVZalkLk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=PJ24vFZpeeEjjWwmf+2llU9Twyel/QjnPprulhVw865ic5jimLp1m4CYJv2Xjt8Xt66AFoBLykXCvuHnFlB2eD18b+7B3qqzGgNPiBwJz7N26chIO1aA2t17F2f3zE611McZHAZh14ccpCpD2TxW4VY7/Pib+D6MfTZH5lQHzLs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr; spf=pass smtp.mailfrom=wanadoo.fr; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b=QfDlyRZl; arc=none smtp.client-ip=193.252.22.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="QfDlyRZl" Received: from fedora.home ([90.11.132.44]) by smtp.orange.fr with ESMTPA id ps0hs0twFsBGNps0hsCwLZ; Sun, 15 Sep 2024 18:22:04 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1726417324; bh=TkpQY2gkdM9Y4uSBD/xLgQaqvbdgPYywQWgtIu56p6w=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=QfDlyRZlRfeL1VuQOzwaFDgvuOr22XTTOBc2GzrHsNFsbdXmaAki92zGGU5D5IoQP EdGH8u9i+4AphxszaSbzBjBRQuRpq6anu7Gb1eAZQrLb4Ibzj5BK2F3q+AaPDeJqIR MjohFkRNSM1CYYiO9vl0nKWP3VCEoRjOJwC4lNCwjYRhDhSVkftodZo9mY1YhP1DhM KMF7/Bu9GWnIUuI7vckG3ABNTRdo4wUY1WWfAebQuIQuLBYJXNfcaNyoKCXSB8gbkA FKHqVbQ03Ytyx31bEmPEwvTfxNHNBOiaz2bgPOHwgW4YAUyrtP/4KvlGzDEQBbCfro zPG6AcA4Yac+A== X-ME-Helo: fedora.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 15 Sep 2024 18:22:04 +0200 X-ME-IP: 90.11.132.44 From: Christophe JAILLET To: Martin KaFai Lau , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , bpf@vger.kernel.org Subject: [PATCH] bpf: Constify struct btf_kind_operations Date: Sun, 15 Sep 2024 18:21:54 +0200 Message-ID: <9192ab72b2e9c66aefd6520f359a20297186327f.1726417289.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.46.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 'struct btf_kind_operations' are not modified in this driver. Constifying this structures moves some data to a read-only section, so increase overall security, especially when the structure holds some function pointers. On a x86_64, with allmodconfig: Before: =3D=3D=3D=3D=3D=3D text data bss dec hex filename 184320 7091 548 191959 2edd7 kernel/bpf/btf.o After: =3D=3D=3D=3D=3D text data bss dec hex filename 184896 6515 548 191959 2edd7 kernel/bpf/btf.o Signed-off-by: Christophe JAILLET --- Compile tested-only. --- kernel/bpf/btf.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index d2f87db9131e..432eda0f6550 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -2808,7 +2808,7 @@ static void btf_ref_type_log(struct btf_verifier_env = *env, btf_verifier_log(env, "type_id=3D%u", t->type); } =20 -static struct btf_kind_operations modifier_ops =3D { +static const struct btf_kind_operations modifier_ops =3D { .check_meta =3D btf_ref_type_check_meta, .resolve =3D btf_modifier_resolve, .check_member =3D btf_modifier_check_member, @@ -2817,7 +2817,7 @@ static struct btf_kind_operations modifier_ops =3D { .show =3D btf_modifier_show, }; =20 -static struct btf_kind_operations ptr_ops =3D { +static const struct btf_kind_operations ptr_ops =3D { .check_meta =3D btf_ref_type_check_meta, .resolve =3D btf_ptr_resolve, .check_member =3D btf_ptr_check_member, @@ -2858,7 +2858,7 @@ static void btf_fwd_type_log(struct btf_verifier_env = *env, btf_verifier_log(env, "%s", btf_type_kflag(t) ? "union" : "struct"); } =20 -static struct btf_kind_operations fwd_ops =3D { +static const struct btf_kind_operations fwd_ops =3D { .check_meta =3D btf_fwd_check_meta, .resolve =3D btf_df_resolve, .check_member =3D btf_df_check_member, @@ -3109,7 +3109,7 @@ static void btf_array_show(const struct btf *btf, con= st struct btf_type *t, __btf_array_show(btf, t, type_id, data, bits_offset, show); } =20 -static struct btf_kind_operations array_ops =3D { +static const struct btf_kind_operations array_ops =3D { .check_meta =3D btf_array_check_meta, .resolve =3D btf_array_resolve, .check_member =3D btf_array_check_member, @@ -4185,7 +4185,7 @@ static void btf_struct_show(const struct btf *btf, co= nst struct btf_type *t, __btf_struct_show(btf, t, type_id, data, bits_offset, show); } =20 -static struct btf_kind_operations struct_ops =3D { +static const struct btf_kind_operations struct_ops =3D { .check_meta =3D btf_struct_check_meta, .resolve =3D btf_struct_resolve, .check_member =3D btf_struct_check_member, @@ -4353,7 +4353,7 @@ static void btf_enum_show(const struct btf *btf, cons= t struct btf_type *t, btf_show_end_type(show); } =20 -static struct btf_kind_operations enum_ops =3D { +static const struct btf_kind_operations enum_ops =3D { .check_meta =3D btf_enum_check_meta, .resolve =3D btf_df_resolve, .check_member =3D btf_enum_check_member, @@ -4456,7 +4456,7 @@ static void btf_enum64_show(const struct btf *btf, co= nst struct btf_type *t, btf_show_end_type(show); } =20 -static struct btf_kind_operations enum64_ops =3D { +static const struct btf_kind_operations enum64_ops =3D { .check_meta =3D btf_enum64_check_meta, .resolve =3D btf_df_resolve, .check_member =3D btf_enum_check_member, @@ -4534,7 +4534,7 @@ static void btf_func_proto_log(struct btf_verifier_en= v *env, btf_verifier_log(env, ")"); } =20 -static struct btf_kind_operations func_proto_ops =3D { +static const struct btf_kind_operations func_proto_ops =3D { .check_meta =3D btf_func_proto_check_meta, .resolve =3D btf_df_resolve, /* @@ -4592,7 +4592,7 @@ static int btf_func_resolve(struct btf_verifier_env *= env, return 0; } =20 -static struct btf_kind_operations func_ops =3D { +static const struct btf_kind_operations func_ops =3D { .check_meta =3D btf_func_check_meta, .resolve =3D btf_func_resolve, .check_member =3D btf_df_check_member, --=20 2.46.0