Commit 446d64e3e1154806092ac27de198dff1225797d9

Authored by Mimi Zohar
Committed by James Morris
1 parent a2c2c3a71c

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>

Showing 2 changed files with 16 additions and 5 deletions Side-by-side Diff

include/linux/genhd.h
... ... @@ -231,6 +231,12 @@
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)
... ... @@ -718,6 +724,10 @@
718 724 return devt;
719 725 }
720 726  
  727 +static inline int blk_part_pack_uuid(const u8 *uuid_str, u8 *to)
  728 +{
  729 + return -EINVAL;
  730 +}
721 731 #endif /* CONFIG_BLOCK */
722 732  
723 733 #endif /* _LINUX_GENHD_H */
security/integrity/ima/ima_policy.c
... ... @@ -176,7 +176,7 @@
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;
183 183  
... ... @@ -530,14 +530,15 @@
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);