From nobody Fri Dec 19 13:53:13 2025 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB36B10F7 for ; Wed, 4 Sep 2024 01:13:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725412414; cv=none; b=lpMxVoppZDYdFSgiF/QgSCNk41N6uzRE4ZovRgc/d9j1T22Q/EMbCYZsk68joJmM1ugDfWI8EaMJVr94YpDGIjVhZ9gdTwdCU+jCJk9vOt4YCuyOSNXtIiq1+rNFxMwLTtSG6ekhDXrzjiGDZKwTtonQtaZOBsNR/yT6P/0ux8s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725412414; c=relaxed/simple; bh=BDgdnVMogk09jOfCq18EJNffj79Z6DznqgJQHqINZxw=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=ZzW5u8qXR4c+WQmppbKZT5008qiZrHcKl3oWUFT2ccXEKAlaf4L0zQgyu5hBCBgUchclwMnrpXNFulO5RUVHhfPXUV1Tln86ufm9Hky6/wd/Q2WSJbxO0oOchCnKRM1dTcH3gafy0Dpg9/OxCTI5wGktNRC12odzUfJHzG+Qe2U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Wz4Fh5qR7zpVGK; Wed, 4 Sep 2024 09:11:36 +0800 (CST) Received: from dggpeml500022.china.huawei.com (unknown [7.185.36.66]) by mail.maildlp.com (Postfix) with ESMTPS id D8F28140414; Wed, 4 Sep 2024 09:13:28 +0800 (CST) Received: from huawei.com (10.90.53.73) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Wed, 4 Sep 2024 09:13:28 +0800 From: Hongbo Li To: CC: , Subject: [PATCH -next] uio: Constify struct kobj_type Date: Wed, 4 Sep 2024 09:22:00 +0800 Message-ID: <20240904012200.2010916-1-lihongbo22@huawei.com> X-Mailer: git-send-email 2.34.1 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 X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500022.china.huawei.com (7.185.36.66) Content-Type: text/plain; charset="utf-8" These 'struct kobj_type' are not modified. They are only used in kobject_init() which takes a 'const struct kobj_type *ktype' parameter. Constifying these structure and moving them to a read-only section (from data to text), and can increase over all security. ``` [Before] text data bss dec hex filename 10330 1908 20 12258 2fe2 drivers/uio/uio.o [After] text data bss dec hex filename 10458 1844 20 12322 3022 drivers/uio/uio.o ``` Signed-off-by: Hongbo Li --- drivers/uio/uio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 20d2a55cb40b..004a549c6c7d 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -118,7 +118,7 @@ static const struct sysfs_ops map_sysfs_ops =3D { .show =3D map_type_show, }; =20 -static struct kobj_type map_attr_type =3D { +static const struct kobj_type map_attr_type =3D { .release =3D map_release, .sysfs_ops =3D &map_sysfs_ops, .default_groups =3D map_groups, @@ -207,7 +207,7 @@ static const struct sysfs_ops portio_sysfs_ops =3D { .show =3D portio_type_show, }; =20 -static struct kobj_type portio_attr_type =3D { +static const struct kobj_type portio_attr_type =3D { .release =3D portio_release, .sysfs_ops =3D &portio_sysfs_ops, .default_groups =3D portio_groups, --=20 2.34.1