Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

block: fix part_pack_uuid() build error

Commit "85865c1 ima: add policy support for file system uuid"
introduced a CONFIG_BLOCK dependency. This patch defines a
wrapper called blk_part_pack_uuid(), which returns -EINVAL,
when CONFIG_BLOCK is not defined.

security/integrity/ima/ima_policy.c:538:4: error: implicit declaration
of function 'part_pack_uuid' [-Werror=implicit-function-declaration]

Changelog v2:
- Reference commit number in patch description
Changelog v1:
- rename ima_part_pack_uuid() to blk_part_pack_uuid()
- resolve scripts/checkpatch.pl warnings
Changelog v0:
- fix UUID scripts/Lindent msgs

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Reported-by: David Rientjes <rientjes@google.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Acked-by: David Rientjes <rientjes@google.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: James Morris <james.l.morris@oracle.com>

authored by

Mimi Zohar and committed by
James Morris
446d64e3 a2c2c3a7

+16 -5
+10
include/linux/genhd.h
··· 231 231 } 232 232 } 233 233 234 + static inline int blk_part_pack_uuid(const u8 *uuid_str, u8 *to) 235 + { 236 + part_pack_uuid(uuid_str, to); 237 + return 0; 238 + } 239 + 234 240 static inline int disk_max_parts(struct gendisk *disk) 235 241 { 236 242 if (disk->flags & GENHD_FL_EXT_DEVT) ··· 724 718 return devt; 725 719 } 726 720 721 + static inline int blk_part_pack_uuid(const u8 *uuid_str, u8 *to) 722 + { 723 + return -EINVAL; 724 + } 727 725 #endif /* CONFIG_BLOCK */ 728 726 729 727 #endif /* _LINUX_GENHD_H */
+6 -5
security/integrity/ima/ima_policy.c
··· 176 176 && rule->fsmagic != inode->i_sb->s_magic) 177 177 return false; 178 178 if ((rule->flags & IMA_FSUUID) && 179 - memcmp(rule->fsuuid, inode->i_sb->s_uuid, sizeof(rule->fsuuid))) 179 + memcmp(rule->fsuuid, inode->i_sb->s_uuid, sizeof(rule->fsuuid))) 180 180 return false; 181 181 if ((rule->flags & IMA_UID) && !uid_eq(rule->uid, cred->uid)) 182 182 return false; ··· 530 530 ima_log_string(ab, "fsuuid", args[0].from); 531 531 532 532 if (memchr_inv(entry->fsuuid, 0x00, 533 - sizeof(entry->fsuuid))) { 533 + sizeof(entry->fsuuid))) { 534 534 result = -EINVAL; 535 535 break; 536 536 } 537 537 538 - part_pack_uuid(args[0].from, entry->fsuuid); 539 - entry->flags |= IMA_FSUUID; 540 - result = 0; 538 + result = blk_part_pack_uuid(args[0].from, 539 + entry->fsuuid); 540 + if (!result) 541 + entry->flags |= IMA_FSUUID; 541 542 break; 542 543 case Opt_uid: 543 544 ima_log_string(ab, "uid", args[0].from);