From patchwork Wed Sep 4 01:12:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Li X-Patchwork-Id: 13789533 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 6C7C963D for ; Wed, 4 Sep 2024 01:03:36 +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=1725411818; cv=none; b=OUSkyA592DNE1ykn3EbwTKkx3Ebw9OM8pHBArfw/lsUxA7IOcI1p9uaEahx0HQf4kY52EiOAM4Z5JfNwXQhZ/grlqg7VgzLsHyJVU3FtVuc7po8Kt7P0OBSY3kI3lBqZiYKL8c7tcxq8rw+BXYxp5JSKTn8Ywn1IzKo7YouLjqQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725411818; c=relaxed/simple; bh=1o3YnR2PbXy92G70R+2eaDUx/Rqcw1icaTtkoUiwrLI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Q5FJfE7qCt1YMHy7T7aScqZ/8uqwfXXDUoS4HLiwI5ACOlS49VtwIEdfB/brTu6DxJF6MMYT/0f7NGJXexG3fl9Tb190xWriI5PssTtQLStFfsMeqtXGapz2ptnWfrSrOI67ipqy+AAfHKCKwtlbGZBZLV1kY51LVysHqOVt12I= 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.252]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Wz42G1JRDzpVQF; Wed, 4 Sep 2024 09:01:42 +0800 (CST) Received: from dggpeml500022.china.huawei.com (unknown [7.185.36.66]) by mail.maildlp.com (Postfix) with ESMTPS id 388781800D2; Wed, 4 Sep 2024 09:03:34 +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:03:33 +0800 From: Hongbo Li To: , , , , CC: , Subject: [PATCH -next 1/2] EDAC: Constify struct kobj_type for edac_device_sysfs Date: Wed, 4 Sep 2024 09:12:01 +0800 Message-ID: <20240904011202.2009727-2-lihongbo22@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240904011202.2009727-1-lihongbo22@huawei.com> References: <20240904011202.2009727-1-lihongbo22@huawei.com> Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500022.china.huawei.com (7.185.36.66) These 'struct kobj_type' are not modified. They are only used in kobject_init_and_add() which takes a 'const struct kobj_type *ktype' parameter. Constifying these structure and moving them to a read-only section (from data --> text), and can increase over all security. ``` [Before] text data bss dec hex filename 3913 768 0 4681 1249 drivers/edac/edac_device_sysfs.o [After] text data bss dec hex filename 4105 640 0 4745 1289 drivers/edac/edac_device_sysfs.o ``` Signed-off-by: Hongbo Li --- drivers/edac/edac_device_sysfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c index fcebc4ffea26..9149e03f9d67 100644 --- a/drivers/edac/edac_device_sysfs.c +++ b/drivers/edac/edac_device_sysfs.c @@ -212,7 +212,7 @@ static void edac_device_ctrl_master_release(struct kobject *kobj) } /* ktype for the main (master) kobject */ -static struct kobj_type ktype_device_ctrl = { +static const struct kobj_type ktype_device_ctrl = { .release = edac_device_ctrl_master_release, .sysfs_ops = &device_ctl_info_ops, .default_groups = device_ctrl_groups, @@ -397,7 +397,7 @@ static struct attribute *device_instance_attrs[] = { ATTRIBUTE_GROUPS(device_instance); /* The 'ktype' for each edac_dev 'instance' */ -static struct kobj_type ktype_instance_ctrl = { +static const struct kobj_type ktype_instance_ctrl = { .release = edac_device_ctrl_instance_release, .sysfs_ops = &device_instance_ops, .default_groups = device_instance_groups, @@ -480,7 +480,7 @@ static struct attribute *device_block_attrs[] = { ATTRIBUTE_GROUPS(device_block); /* The 'ktype' for each edac_dev 'block' */ -static struct kobj_type ktype_block_ctrl = { +static const struct kobj_type ktype_block_ctrl = { .release = edac_device_ctrl_block_release, .sysfs_ops = &device_block_ops, .default_groups = device_block_groups, From patchwork Wed Sep 4 01:12:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Li X-Patchwork-Id: 13789534 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (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 F0D431FC8 for ; Wed, 4 Sep 2024 01:03:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725411819; cv=none; b=Hxf3+rKO3JpciDOzX8BmpDmWsPPUtd1ly/vOWRLQQ6pPu5fZU7l1qKvSQdnDmAlpPFghKVqeZ4U9CnUXGICGKeL5+gCmX06qAJfFVIHRe9y6vCJpMhR/IXzNBkf0N5exUJonk3CvFNt8b4KcMM/GUXztoR1I4YgeUsMwcS8mI88= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725411819; c=relaxed/simple; bh=v7a7wlABZIHS12PkM0wQsHF6Nq+5LLNowLqjAWdk6mo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=G5EufoTiDyewx1XS7slSspQqY75vMCn9Lhwgf9clML+H6c8n58PTjZq9/m1HJ4QuASFFBYboNWbgBUcub90w3aTAZX94oISffwCMLpWe8GuSlkrYlLCV3FuJT2r8KsXRwzKpP9EQ6EnJ7m40Qmg0Y8xyTWzmQzt3OkApb6G0rnI= 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.190 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.88.234]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Wz3yj4qlPz20nKk; Wed, 4 Sep 2024 08:58:37 +0800 (CST) Received: from dggpeml500022.china.huawei.com (unknown [7.185.36.66]) by mail.maildlp.com (Postfix) with ESMTPS id 5108A140158; Wed, 4 Sep 2024 09:03:34 +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:03:34 +0800 From: Hongbo Li To: , , , , CC: , Subject: [PATCH -next 2/2] EDAC: Constify struct kobj_type for edac_pci_sysfs Date: Wed, 4 Sep 2024 09:12:02 +0800 Message-ID: <20240904011202.2009727-3-lihongbo22@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240904011202.2009727-1-lihongbo22@huawei.com> References: <20240904011202.2009727-1-lihongbo22@huawei.com> Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500022.china.huawei.com (7.185.36.66) These 'struct kobj_type' are not modified. They are only used in kobject_init_and_add() which takes a 'const struct kobj_type *ktype' parameter. Constifying these structure (ktype_pci_instance and ktype_edac_pci_main_kobj)and moving them to a read-only (text section) section, and can increase over all security. ``` [Before] text data bss dec hex filename 4357 856 32 5245 147d drivers/edac/edac_pci_sysfs.o [After] text data bss dec hex filename 4485 760 32 5277 149d drivers/edac/edac_pci_sysfs.o ``` Signed-off-by: Hongbo Li --- drivers/edac/edac_pci_sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c index 7b44afcf48db..f00efb06b3dc 100644 --- a/drivers/edac/edac_pci_sysfs.c +++ b/drivers/edac/edac_pci_sysfs.c @@ -143,7 +143,7 @@ static struct attribute *pci_instance_attrs[] = { ATTRIBUTE_GROUPS(pci_instance); /* the ktype for a pci instance */ -static struct kobj_type ktype_pci_instance = { +static const struct kobj_type ktype_pci_instance = { .release = edac_pci_instance_release, .sysfs_ops = &pci_instance_ops, .default_groups = pci_instance_groups, @@ -326,7 +326,7 @@ static void edac_pci_release_main_kobj(struct kobject *kobj) } /* ktype struct for the EDAC PCI main kobj */ -static struct kobj_type ktype_edac_pci_main_kobj = { +static const struct kobj_type ktype_edac_pci_main_kobj = { .release = edac_pci_release_main_kobj, .sysfs_ops = &edac_pci_sysfs_ops, .default_groups = edac_pci_groups,