Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp933181lqs; Fri, 14 Jun 2024 09:35:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXz/u2Xi6qbkiT7HesLt2q40r5SVhVKCYaJQD1QbnKOUZ6dx9gMHZTnjjG8m3OKDc61KKr3PXq9V/ZnzCVVlRGpFtax35dGkj79vr8Kkg== X-Google-Smtp-Source: AGHT+IEFzKE2QicNWu9ipFPM17932gEF4huVIR8eA26QFSpACkJORfTjusgf79SxUhLWaEe2DxmG X-Received: by 2002:a05:6402:174b:b0:57c:bec1:ff4b with SMTP id 4fb4d7f45d1cf-57cbec1ffeamr1953635a12.10.1718382957822; Fri, 14 Jun 2024 09:35:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718382957; cv=pass; d=google.com; s=arc-20160816; b=lor1w6u28cMC4ohqZZjAW5rZWmQyTYQHpHQghMGoY9gQOXHiOZNpJPYJQwaD49hM1g VoX1AyVBxFZ/HhXo+UxLZb7VqVHnGK1osZsDfFUbyihD3oT4VipduowqvkCw3Cypu9nQ kKYbpGMHqLzfEMcLw/Qyt4q7RDZm1rDkpZK6AbM9kdd1wmBKP7pYWJZrN8wLDhDkdqLN KxAmuZShIv/u1dIyzxO382umcV9W5nfx/5x5GO9uAP669bx3xjoK0gu05zGMgbkeylN2 ec8Ekq9zEZWazMj+3E8nb5iL3Ni6Vwk/CVO6uRAhRBSDW5T/Kdy8qY+x+ZEQxRG4KZTY cygg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=bro9slh5+EDW+lc1vukt0zA8l5VUvTm2syfdLEd7QbY=; fh=qtt+voUSGGN2b+47UokqQ5acBllqmPsKrUdF1Rh34YU=; b=BOk0Eyv6DO3XZBDZL6ys/7r4cPDjkGpRQDwHYuvg9ujaJvZkqHlpLsp0QTyOYB2bwz KCNxcpULvsRLgTVvgxjnaeXyTAyFf7PkoWZSTUc06P/dSbuNxQqi0wunQ7wgR2hpTMtz P+WgagjwVBQWnbRrk6UshHCfyjLaJJQ61umx92SWQWwm8D9Tv4L+VFuD+igFn62vOnol 4VuZiSaa5A1EtxOIG2AqfU9YHBIupyKlyiY3ZQ59awVIzTmbeMktaUxJTyujHUC3cTo+ MPCR10emwQC1tLXJGwcz2hz7IjxGhb/O224jXN/WVw5QSXloRwGyoDMRuhijq9ufwYAt 6zCg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=NtWiVGJR; arc=pass (i=1 spf=pass spfdomain=wanadoo.fr dkim=pass dkdomain=wanadoo.fr dmarc=pass fromdomain=wanadoo.fr); spf=pass (google.com: domain of linux-kernel+bounces-215266-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215266-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=wanadoo.fr Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57cb72d6b3esi2025613a12.2.2024.06.14.09.35.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 09:35:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-215266-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=NtWiVGJR; arc=pass (i=1 spf=pass spfdomain=wanadoo.fr dkim=pass dkdomain=wanadoo.fr dmarc=pass fromdomain=wanadoo.fr); spf=pass (google.com: domain of linux-kernel+bounces-215266-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215266-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8848B1F23C7C for ; Fri, 14 Jun 2024 16:35:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0DB1819EEC1; Fri, 14 Jun 2024 16:33:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="NtWiVGJR" Received: from smtp.smtpout.orange.fr (smtp-26.smtpout.orange.fr [80.12.242.26]) (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 95E5219E7C0; Fri, 14 Jun 2024 16:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.12.242.26 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718382824; cv=none; b=WGZR4mifcyoTqLoIHPBVzZHmyCnZahHEI2KlLX00S4nEzTwjVDa6nrzGHGEQgX4uFhGjnpuCuZ1pcw0NIvPXYDh2YcgRmljhNXp5JI3yabYkrjoFRli9ykGnz2X1oPXjotiBd8WnIJYHd+JfTaAAjz5mQ9QN99+wDK5ZkRxr1YY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718382824; c=relaxed/simple; bh=1JP+d9DTdvRLjHMvjKA/7X/zFiYpxE5Qp6pWEK6Iypg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=l+Eaa56H4OuHOrqXlTHzf5CS3hPHHRyw2+SJ65s84dUvGf9xjhlhCXwAS5wIovxZiMLtyLIlRd6RFJ0+iwr713o394sf+HnpvDzKCt402pdrdBAgKNuuCmuQbHLpGZWcm6V3pq4I8cTarLamXmonWTxL5zqaq3i18xI37YcyBCo= 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=NtWiVGJR; arc=none smtp.client-ip=80.12.242.26 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 Received: from fedora.home ([86.243.222.230]) by smtp.orange.fr with ESMTPA id I9qmsh97rXS9AI9qmsrRKe; Fri, 14 Jun 2024 18:32:32 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1718382752; bh=bro9slh5+EDW+lc1vukt0zA8l5VUvTm2syfdLEd7QbY=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=NtWiVGJRnX0N0vQRD/f8okKtk/cYLhfwJ1ZBBbg+NPe/J9u0xszloqPqDHZ6Y26bY swjKE/40tm8cSteBDJq/gwM/zH3uZ0iHv/lyqMIarMV+zXbRQUgj3H0+6XdrjWEzY0 2VGQX5SjonUd663BMB6b9r4MCmKKuhLudv3WC40pQMjuvA3fFbv6EcfuNidTiBenkD XkW5L8TxLrluteVX/W6gdnN5geuB6kKZYLxLZlIEbQSP1Xw1DNxCoNjXXuVyBlA1/I 63W/IxDzYC35goyKZICQx7QsCx5hAD3Lo1sNeALCQ5KnuQYIfNxVmGsvmzwHWHLBBR jvxljyd8OZOdw== X-ME-Helo: fedora.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 14 Jun 2024 18:32:32 +0200 X-ME-IP: 86.243.222.230 From: Christophe JAILLET To: Mark Fasheh , Joel Becker , Joseph Qi Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , ocfs2-devel@lists.linux.dev Subject: [PATCH] ocfs2: Constify struct ocfs2_lock_res_ops Date: Fri, 14 Jun 2024 18:25:07 +0200 Message-ID: <43d3e2ae3a97d3cbe93d6ba6ce48ae5ec04d7526.1718382288.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: 8bit "struct ocfs2_lock_res_ops" are not modified in this driver. Constifying this structure moves some data to a read-only section, so increase overall security. In order to do it, "struct ocfs2_lock_res" also needs to be adjusted to this new const qualifier. On a x86_64, with allmodconfig: Before: ====== text data bss dec hex filename 83038 2632 400 86070 15036 fs/ocfs2/dlmglue.o After: ===== text data bss dec hex filename 83806 1992 272 86070 15036 fs/ocfs2/dlmglue.o Signed-off-by: Christophe JAILLET --- fs/ocfs2/dlmglue.c | 28 ++++++++++++++-------------- fs/ocfs2/ocfs2.h | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index cb40cafbc062..da78a04d6f0b 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c @@ -221,12 +221,12 @@ struct ocfs2_lock_res_ops { */ #define LOCK_TYPE_USES_LVB 0x2 -static struct ocfs2_lock_res_ops ocfs2_inode_rw_lops = { +static const struct ocfs2_lock_res_ops ocfs2_inode_rw_lops = { .get_osb = ocfs2_get_inode_osb, .flags = 0, }; -static struct ocfs2_lock_res_ops ocfs2_inode_inode_lops = { +static const struct ocfs2_lock_res_ops ocfs2_inode_inode_lops = { .get_osb = ocfs2_get_inode_osb, .check_downconvert = ocfs2_check_meta_downconvert, .set_lvb = ocfs2_set_meta_lvb, @@ -234,50 +234,50 @@ static struct ocfs2_lock_res_ops ocfs2_inode_inode_lops = { .flags = LOCK_TYPE_REQUIRES_REFRESH|LOCK_TYPE_USES_LVB, }; -static struct ocfs2_lock_res_ops ocfs2_super_lops = { +static const struct ocfs2_lock_res_ops ocfs2_super_lops = { .flags = LOCK_TYPE_REQUIRES_REFRESH, }; -static struct ocfs2_lock_res_ops ocfs2_rename_lops = { +static const struct ocfs2_lock_res_ops ocfs2_rename_lops = { .flags = 0, }; -static struct ocfs2_lock_res_ops ocfs2_nfs_sync_lops = { +static const struct ocfs2_lock_res_ops ocfs2_nfs_sync_lops = { .flags = 0, }; -static struct ocfs2_lock_res_ops ocfs2_trim_fs_lops = { +static const struct ocfs2_lock_res_ops ocfs2_trim_fs_lops = { .flags = LOCK_TYPE_REQUIRES_REFRESH|LOCK_TYPE_USES_LVB, }; -static struct ocfs2_lock_res_ops ocfs2_orphan_scan_lops = { +static const struct ocfs2_lock_res_ops ocfs2_orphan_scan_lops = { .flags = LOCK_TYPE_REQUIRES_REFRESH|LOCK_TYPE_USES_LVB, }; -static struct ocfs2_lock_res_ops ocfs2_dentry_lops = { +static const struct ocfs2_lock_res_ops ocfs2_dentry_lops = { .get_osb = ocfs2_get_dentry_osb, .post_unlock = ocfs2_dentry_post_unlock, .downconvert_worker = ocfs2_dentry_convert_worker, .flags = 0, }; -static struct ocfs2_lock_res_ops ocfs2_inode_open_lops = { +static const struct ocfs2_lock_res_ops ocfs2_inode_open_lops = { .get_osb = ocfs2_get_inode_osb, .flags = 0, }; -static struct ocfs2_lock_res_ops ocfs2_flock_lops = { +static const struct ocfs2_lock_res_ops ocfs2_flock_lops = { .get_osb = ocfs2_get_file_osb, .flags = 0, }; -static struct ocfs2_lock_res_ops ocfs2_qinfo_lops = { +static const struct ocfs2_lock_res_ops ocfs2_qinfo_lops = { .set_lvb = ocfs2_set_qinfo_lvb, .get_osb = ocfs2_get_qinfo_osb, .flags = LOCK_TYPE_REQUIRES_REFRESH | LOCK_TYPE_USES_LVB, }; -static struct ocfs2_lock_res_ops ocfs2_refcount_block_lops = { +static const struct ocfs2_lock_res_ops ocfs2_refcount_block_lops = { .check_downconvert = ocfs2_check_refcount_downconvert, .downconvert_worker = ocfs2_refcount_convert_worker, .flags = 0, @@ -510,7 +510,7 @@ static inline void ocfs2_init_start_time(struct ocfs2_mask_waiter *mw) static void ocfs2_lock_res_init_common(struct ocfs2_super *osb, struct ocfs2_lock_res *res, enum ocfs2_lock_type type, - struct ocfs2_lock_res_ops *ops, + const struct ocfs2_lock_res_ops *ops, void *priv) { res->l_type = type; @@ -553,7 +553,7 @@ void ocfs2_inode_lock_res_init(struct ocfs2_lock_res *res, unsigned int generation, struct inode *inode) { - struct ocfs2_lock_res_ops *ops; + const struct ocfs2_lock_res_ops *ops; switch(type) { case OCFS2_LOCK_TYPE_RW: diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h index 8fe826143d7b..51c52768132d 100644 --- a/fs/ocfs2/ocfs2.h +++ b/fs/ocfs2/ocfs2.h @@ -154,7 +154,7 @@ struct ocfs2_lock_stats { struct ocfs2_lock_res { void *l_priv; - struct ocfs2_lock_res_ops *l_ops; + const struct ocfs2_lock_res_ops *l_ops; struct list_head l_blocked_list; -- 2.45.2