From nobody Tue Dec 16 17:56:04 2025 Received: from msa.smtpout.orange.fr (msa-212.smtpout.orange.fr [193.252.23.212]) (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 C38A583A19; Sat, 20 Jul 2024 10:59:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.252.23.212 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721473192; cv=none; b=WprnkzgVET4/cQRFY1Xd+TP1l94C5p2my3xcCbgqOwxQR63SvEpJiwyI4RxFmA9nLHeWwmiVcwc6BkPtN3il401NlKeqVzw+KkZM3Vhz+dSWlky31tyZgh4uwlhNe1q65yPhB0ASccV7hA0JMajLukZog9BXBFiny79w6ns8LiM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721473192; c=relaxed/simple; bh=3eJP5D2gLY2qGLsJ+PSb5K2vvmVn2tcyQqDbjoG+glw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=jj12rP/MEnegDMP97gSDFgnz/QCLZtid1pMOy+hR8Vbn4yDjT6WLPUtEwfgAsSfjkDfYzGQHfOhtOYXNeabo+VEth5rJU2eYlT+T5M+5uSMlSC6qIYsS3F5ig7aZFG2rdYwRsSZwVzXmAIOu0rRmToaAQCoterVKH8V7+CMnWTM= 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=lngDg7eb; arc=none smtp.client-ip=193.252.23.212 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="lngDg7eb" Received: from fedora.home ([90.11.132.44]) by smtp.orange.fr with ESMTPA id V7oSskCfXOGeaV7oSswaIZ; Sat, 20 Jul 2024 12:59:42 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1721473182; bh=/Oc6zHUJ3PsZDwx3kEOlE52feOVHzNSUSRVZP+ZoPqE=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=lngDg7ebFxzciPH9gWGq9jkDnDew+kqNbMu28oDWUv1HQe3IN0S9BsCR/+QTtMeY8 EoKSnB367Ck8ERNoIVnSt1oBAJYVGpDGjEojaOYuspkdHrXTOwl7lAsehu/V07s/Yf X2/H5N1Mh2gWqdf2drbimqHXj1KKSAjUMfRPyMvF1eIuk1Y47ITg2tjJ44l5ghYcKL QJGxSn3RiBCvt+o4hEhx/dyn0Ta5EAW7GXBGhrPIyob/Bax9L0Qgg92+84lVOu7lNu FuksPrBHgG3C4Bv1IFGdfyN1PdEM702c3n5d5lO4vI7LelG9o9Ct/cvguEhYT5rlJz dTttig84WNQeA== X-ME-Helo: fedora.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 20 Jul 2024 12:59:42 +0200 X-ME-IP: 90.11.132.44 From: Christophe JAILLET To: Jon Mason , Dave Jiang , Allen Hubbe Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , ntb@lists.linux.dev Subject: [PATCH] ntb: Constify struct bus_type Date: Sat, 20 Jul 2024 12:59:36 +0200 Message-ID: <50a28f39b1f0d0201b2645d2a8239e1819dc924b.1721473166.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.45.2 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 bus_type' is not modified in this driver. Constifying this structure 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 69682 4593 152 74427 122bb drivers/ntb/ntb_transport.o 5847 448 32 6327 18b7 drivers/ntb/core.o After: =3D=3D=3D=3D=3D text data bss dec hex filename 69858 4433 152 74443 122cb drivers/ntb/ntb_transport.o 6007 288 32 6327 18b7 drivers/ntb/core.o Signed-off-by: Christophe JAILLET Reviewed-by: Dave Jiang --- Compile tested-only. --- drivers/ntb/core.c | 4 ++-- drivers/ntb/ntb_transport.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/ntb/core.c b/drivers/ntb/core.c index d702bee78082..ed6f4adc6130 100644 --- a/drivers/ntb/core.c +++ b/drivers/ntb/core.c @@ -72,7 +72,7 @@ MODULE_VERSION(DRIVER_VERSION); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESCRIPTION); =20 -static struct bus_type ntb_bus; +static const struct bus_type ntb_bus; static void ntb_dev_release(struct device *dev); =20 int __ntb_register_client(struct ntb_client *client, struct module *mod, @@ -298,7 +298,7 @@ static void ntb_dev_release(struct device *dev) complete(&ntb->released); } =20 -static struct bus_type ntb_bus =3D { +static const struct bus_type ntb_bus =3D { .name =3D "ntb", .probe =3D ntb_probe, .remove =3D ntb_remove, diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c index 77e55debeed6..a79f68e18d3f 100644 --- a/drivers/ntb/ntb_transport.c +++ b/drivers/ntb/ntb_transport.c @@ -314,7 +314,7 @@ static void ntb_transport_bus_remove(struct device *dev) put_device(dev); } =20 -static struct bus_type ntb_transport_bus =3D { +static const struct bus_type ntb_transport_bus =3D { .name =3D "ntb_transport", .match =3D ntb_transport_bus_match, .probe =3D ntb_transport_bus_probe, --=20 2.45.2