Skip to content

Commit 3ebe69c

Browse files
tititiou36akpm00
authored andcommitted
ocfs2: constify struct ocfs2_lock_res_ops
"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 Link: https://lkml.kernel.org/r/43d3e2ae3a97d3cbe93d6ba6ce48ae5ec04d7526.1718382288.git.christophe.jaillet@wanadoo.fr Signed-off-by: Christophe JAILLET <[email protected]> Cc: Mark Fasheh <[email protected]> Cc: Joel Becker <[email protected]> Cc: Junxiao Bi <[email protected]> Cc: Joseph Qi <[email protected]> Cc: Changwei Ge <[email protected]> Cc: Gang He <[email protected]> Cc: Jun Piao <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent c8dab79 commit 3ebe69c

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

fs/ocfs2/dlmglue.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -221,63 +221,63 @@ struct ocfs2_lock_res_ops {
221221
*/
222222
#define LOCK_TYPE_USES_LVB 0x2
223223

224-
static struct ocfs2_lock_res_ops ocfs2_inode_rw_lops = {
224+
static const struct ocfs2_lock_res_ops ocfs2_inode_rw_lops = {
225225
.get_osb = ocfs2_get_inode_osb,
226226
.flags = 0,
227227
};
228228

229-
static struct ocfs2_lock_res_ops ocfs2_inode_inode_lops = {
229+
static const struct ocfs2_lock_res_ops ocfs2_inode_inode_lops = {
230230
.get_osb = ocfs2_get_inode_osb,
231231
.check_downconvert = ocfs2_check_meta_downconvert,
232232
.set_lvb = ocfs2_set_meta_lvb,
233233
.downconvert_worker = ocfs2_data_convert_worker,
234234
.flags = LOCK_TYPE_REQUIRES_REFRESH|LOCK_TYPE_USES_LVB,
235235
};
236236

237-
static struct ocfs2_lock_res_ops ocfs2_super_lops = {
237+
static const struct ocfs2_lock_res_ops ocfs2_super_lops = {
238238
.flags = LOCK_TYPE_REQUIRES_REFRESH,
239239
};
240240

241-
static struct ocfs2_lock_res_ops ocfs2_rename_lops = {
241+
static const struct ocfs2_lock_res_ops ocfs2_rename_lops = {
242242
.flags = 0,
243243
};
244244

245-
static struct ocfs2_lock_res_ops ocfs2_nfs_sync_lops = {
245+
static const struct ocfs2_lock_res_ops ocfs2_nfs_sync_lops = {
246246
.flags = 0,
247247
};
248248

249-
static struct ocfs2_lock_res_ops ocfs2_trim_fs_lops = {
249+
static const struct ocfs2_lock_res_ops ocfs2_trim_fs_lops = {
250250
.flags = LOCK_TYPE_REQUIRES_REFRESH|LOCK_TYPE_USES_LVB,
251251
};
252252

253-
static struct ocfs2_lock_res_ops ocfs2_orphan_scan_lops = {
253+
static const struct ocfs2_lock_res_ops ocfs2_orphan_scan_lops = {
254254
.flags = LOCK_TYPE_REQUIRES_REFRESH|LOCK_TYPE_USES_LVB,
255255
};
256256

257-
static struct ocfs2_lock_res_ops ocfs2_dentry_lops = {
257+
static const struct ocfs2_lock_res_ops ocfs2_dentry_lops = {
258258
.get_osb = ocfs2_get_dentry_osb,
259259
.post_unlock = ocfs2_dentry_post_unlock,
260260
.downconvert_worker = ocfs2_dentry_convert_worker,
261261
.flags = 0,
262262
};
263263

264-
static struct ocfs2_lock_res_ops ocfs2_inode_open_lops = {
264+
static const struct ocfs2_lock_res_ops ocfs2_inode_open_lops = {
265265
.get_osb = ocfs2_get_inode_osb,
266266
.flags = 0,
267267
};
268268

269-
static struct ocfs2_lock_res_ops ocfs2_flock_lops = {
269+
static const struct ocfs2_lock_res_ops ocfs2_flock_lops = {
270270
.get_osb = ocfs2_get_file_osb,
271271
.flags = 0,
272272
};
273273

274-
static struct ocfs2_lock_res_ops ocfs2_qinfo_lops = {
274+
static const struct ocfs2_lock_res_ops ocfs2_qinfo_lops = {
275275
.set_lvb = ocfs2_set_qinfo_lvb,
276276
.get_osb = ocfs2_get_qinfo_osb,
277277
.flags = LOCK_TYPE_REQUIRES_REFRESH | LOCK_TYPE_USES_LVB,
278278
};
279279

280-
static struct ocfs2_lock_res_ops ocfs2_refcount_block_lops = {
280+
static const struct ocfs2_lock_res_ops ocfs2_refcount_block_lops = {
281281
.check_downconvert = ocfs2_check_refcount_downconvert,
282282
.downconvert_worker = ocfs2_refcount_convert_worker,
283283
.flags = 0,
@@ -510,7 +510,7 @@ static inline void ocfs2_init_start_time(struct ocfs2_mask_waiter *mw)
510510
static void ocfs2_lock_res_init_common(struct ocfs2_super *osb,
511511
struct ocfs2_lock_res *res,
512512
enum ocfs2_lock_type type,
513-
struct ocfs2_lock_res_ops *ops,
513+
const struct ocfs2_lock_res_ops *ops,
514514
void *priv)
515515
{
516516
res->l_type = type;
@@ -553,7 +553,7 @@ void ocfs2_inode_lock_res_init(struct ocfs2_lock_res *res,
553553
unsigned int generation,
554554
struct inode *inode)
555555
{
556-
struct ocfs2_lock_res_ops *ops;
556+
const struct ocfs2_lock_res_ops *ops;
557557

558558
switch(type) {
559559
case OCFS2_LOCK_TYPE_RW:

fs/ocfs2/ocfs2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ struct ocfs2_lock_stats {
154154

155155
struct ocfs2_lock_res {
156156
void *l_priv;
157-
struct ocfs2_lock_res_ops *l_ops;
157+
const struct ocfs2_lock_res_ops *l_ops;
158158

159159

160160
struct list_head l_blocked_list;

0 commit comments

Comments
 (0)