Skip to content

Commit 8291798

Browse files
keesJames Morris
authored andcommitted
TOMOYO: Use designated initializers
Prepare to mark sensitive kernel structures for randomization by making sure they're using designated initializers. These were identified during allyesconfig builds of x86, arm, and arm64, with most initializer fixes extracted from grsecurity. Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: James Morris <james.l.morris@oracle.com>
1 parent e4e55b4 commit 8291798

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

security/tomoyo/file.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ int tomoyo_path_number_perm(const u8 type, const struct path *path,
692692
{
693693
struct tomoyo_request_info r;
694694
struct tomoyo_obj_info obj = {
695-
.path1 = *path,
695+
.path1 = { .mnt = path->mnt, .dentry = path->dentry },
696696
};
697697
int error = -ENOMEM;
698698
struct tomoyo_path_info buf;
@@ -740,7 +740,7 @@ int tomoyo_check_open_permission(struct tomoyo_domain_info *domain,
740740
struct tomoyo_path_info buf;
741741
struct tomoyo_request_info r;
742742
struct tomoyo_obj_info obj = {
743-
.path1 = *path,
743+
.path1 = { .mnt = path->mnt, .dentry = path->dentry },
744744
};
745745
int idx;
746746

@@ -786,7 +786,7 @@ int tomoyo_path_perm(const u8 operation, const struct path *path, const char *ta
786786
{
787787
struct tomoyo_request_info r;
788788
struct tomoyo_obj_info obj = {
789-
.path1 = *path,
789+
.path1 = { .mnt = path->mnt, .dentry = path->dentry },
790790
};
791791
int error;
792792
struct tomoyo_path_info buf;
@@ -843,7 +843,7 @@ int tomoyo_mkdev_perm(const u8 operation, const struct path *path,
843843
{
844844
struct tomoyo_request_info r;
845845
struct tomoyo_obj_info obj = {
846-
.path1 = *path,
846+
.path1 = { .mnt = path->mnt, .dentry = path->dentry },
847847
};
848848
int error = -ENOMEM;
849849
struct tomoyo_path_info buf;
@@ -890,8 +890,8 @@ int tomoyo_path2_perm(const u8 operation, const struct path *path1,
890890
struct tomoyo_path_info buf2;
891891
struct tomoyo_request_info r;
892892
struct tomoyo_obj_info obj = {
893-
.path1 = *path1,
894-
.path2 = *path2,
893+
.path1 = { .mnt = path1->mnt, .dentry = path1->dentry },
894+
.path2 = { .mnt = path2->mnt, .dentry = path2->dentry }
895895
};
896896
int idx;
897897

security/tomoyo/tomoyo.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static int tomoyo_path_truncate(const struct path *path)
165165
*/
166166
static int tomoyo_path_unlink(const struct path *parent, struct dentry *dentry)
167167
{
168-
struct path path = { parent->mnt, dentry };
168+
struct path path = { .mnt = parent->mnt, .dentry = dentry };
169169
return tomoyo_path_perm(TOMOYO_TYPE_UNLINK, &path, NULL);
170170
}
171171

@@ -181,7 +181,7 @@ static int tomoyo_path_unlink(const struct path *parent, struct dentry *dentry)
181181
static int tomoyo_path_mkdir(const struct path *parent, struct dentry *dentry,
182182
umode_t mode)
183183
{
184-
struct path path = { parent->mnt, dentry };
184+
struct path path = { .mnt = parent->mnt, .dentry = dentry };
185185
return tomoyo_path_number_perm(TOMOYO_TYPE_MKDIR, &path,
186186
mode & S_IALLUGO);
187187
}
@@ -196,7 +196,7 @@ static int tomoyo_path_mkdir(const struct path *parent, struct dentry *dentry,
196196
*/
197197
static int tomoyo_path_rmdir(const struct path *parent, struct dentry *dentry)
198198
{
199-
struct path path = { parent->mnt, dentry };
199+
struct path path = { .mnt = parent->mnt, .dentry = dentry };
200200
return tomoyo_path_perm(TOMOYO_TYPE_RMDIR, &path, NULL);
201201
}
202202

@@ -212,7 +212,7 @@ static int tomoyo_path_rmdir(const struct path *parent, struct dentry *dentry)
212212
static int tomoyo_path_symlink(const struct path *parent, struct dentry *dentry,
213213
const char *old_name)
214214
{
215-
struct path path = { parent->mnt, dentry };
215+
struct path path = { .mnt = parent->mnt, .dentry = dentry };
216216
return tomoyo_path_perm(TOMOYO_TYPE_SYMLINK, &path, old_name);
217217
}
218218

@@ -229,7 +229,7 @@ static int tomoyo_path_symlink(const struct path *parent, struct dentry *dentry,
229229
static int tomoyo_path_mknod(const struct path *parent, struct dentry *dentry,
230230
umode_t mode, unsigned int dev)
231231
{
232-
struct path path = { parent->mnt, dentry };
232+
struct path path = { .mnt = parent->mnt, .dentry = dentry };
233233
int type = TOMOYO_TYPE_CREATE;
234234
const unsigned int perm = mode & S_IALLUGO;
235235

@@ -268,8 +268,8 @@ static int tomoyo_path_mknod(const struct path *parent, struct dentry *dentry,
268268
static int tomoyo_path_link(struct dentry *old_dentry, const struct path *new_dir,
269269
struct dentry *new_dentry)
270270
{
271-
struct path path1 = { new_dir->mnt, old_dentry };
272-
struct path path2 = { new_dir->mnt, new_dentry };
271+
struct path path1 = { .mnt = new_dir->mnt, .dentry = old_dentry };
272+
struct path path2 = { .mnt = new_dir->mnt, .dentry = new_dentry };
273273
return tomoyo_path2_perm(TOMOYO_TYPE_LINK, &path1, &path2);
274274
}
275275

@@ -288,8 +288,8 @@ static int tomoyo_path_rename(const struct path *old_parent,
288288
const struct path *new_parent,
289289
struct dentry *new_dentry)
290290
{
291-
struct path path1 = { old_parent->mnt, old_dentry };
292-
struct path path2 = { new_parent->mnt, new_dentry };
291+
struct path path1 = { .mnt = old_parent->mnt, .dentry = old_dentry };
292+
struct path path2 = { .mnt = new_parent->mnt, .dentry = new_dentry };
293293
return tomoyo_path2_perm(TOMOYO_TYPE_RENAME, &path1, &path2);
294294
}
295295

@@ -417,7 +417,7 @@ static int tomoyo_sb_mount(const char *dev_name, const struct path *path,
417417
*/
418418
static int tomoyo_sb_umount(struct vfsmount *mnt, int flags)
419419
{
420-
struct path path = { mnt, mnt->mnt_root };
420+
struct path path = { .mnt = mnt, .dentry = mnt->mnt_root };
421421
return tomoyo_path_perm(TOMOYO_TYPE_UMOUNT, &path, NULL);
422422
}
423423

0 commit comments

Comments
 (0)