Re: [PATCH -next] security/integrity/ima: make part_pack_uuid() always visible

Mimi Zohar
2013-02-20T20:39:20Z

On Wed, 2013-02-20 at 11:30 -0800, Randy Dunlap wrote:
> On 02/20/13 08:50, Mimi Zohar wrote:
> > On Tue, 2013-02-19 at 16:28 -0800, Randy Dunlap wrote:
> >> On 02/18/13 22:03, Stephen Rothwell wrote:
> >>> Hi all,
> >>>
> >>> Changes since 20130218:
> >>>
> >>
> >> on x86_64:
> >>
> >> CC security/integrity/ima/ima_policy.o
> >> security/integrity/ima/ima_policy.c: In function 'ima_parse_rule':
> >> security/integrity/ima/ima_policy.c:538:4: error: implicit declaration of function 'part_pack_uuid' [-Werror=implicit-function-declaration]
> >> cc1: some warnings being treated as errors
> >> make[4]: *** [security/integrity/ima/ima_policy.o] Error 1
> >>
> >>
> >> Full randconfig file is attached.
> >
> > part_pack_uuid() is only defined for CONFIG_BLOCK in
> > include/linux/genhd.h. One solution would be to add a stub function
> > definition in include/linux/genhd.h, the other option would be to ifndef
> > CONFIG_BLOCK in C code.
>
> ITYM #ifdef CONFIG_BLOCK to call part_pack_uuid().
> Yes, either of those would work.
> How about a third option -- just make part_pack_uuid() always visible
> and not just a stub? Patch is below.

That works too.

Acked-by: Mimi Zohar <zohar@linux.vnet.ibm.com>

thanks,

Mimi

> ---
> From: Randy Dunlap <rdunlap@infradead.org>
>
> Fix build error when CONFIG_BLOCK is not enabled
> by making the static inline function part_pack_uuid()
> visible independent of CONFIG_BLOCK's setting.
>
> security/integrity/ima/ima_policy.c:538:4: error: implicit declaration of function 'part_pack_uuid' [-Werror=implicit-function-declaration]
>
> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> Cc: Mimi Zohar <zohar@us.ibm.com>
> ---
> include/linux/genhd.h | 36 ++++++++++++++++++------------------
> 1 file changed, 18 insertions(+), 18 deletions(-)
>
> --- linux-next-20130220.orig/include/linux/genhd.h
> +++ linux-next-20130220/include/linux/genhd.h
> @@ -213,24 +213,6 @@ static inline struct gendisk *part_to_di
> return NULL;
> }
>
> -static inline void part_pack_uuid(const u8 *uuid_str, u8 *to)
> -{
> - int i;
> - for (i = 0; i < 16; ++i) {
> - *to++ = (hex_to_bin(*uuid_str) << 4) |
> - (hex_to_bin(*(uuid_str + 1)));
> - uuid_str += 2;
> - switch (i) {
> - case 3:
> - case 5:
> - case 7:
> - case 9:
> - uuid_str++;
> - continue;
> - }
> - }
> -}
> -
> static inline int disk_max_parts(struct gendisk *disk)
> {
> if (disk->flags & GENHD_FL_EXT_DEVT)
> @@ -720,4 +702,22 @@ static inline dev_t blk_lookup_devt(cons
>
> #endif /* CONFIG_BLOCK */
>
> +static inline void part_pack_uuid(const u8 *uuid_str, u8 *to)
> +{
> + int i;
> + for (i = 0; i < 16; ++i) {
> + *to++ = (hex_to_bin(*uuid_str) << 4) |
> + (hex_to_bin(*(uuid_str + 1)));
> + uuid_str += 2;
> + switch (i) {
> + case 3:
> + case 5:
> + case 7:
> + case 9:
> + uuid_str++;
> + continue;
> + }
> + }
> +}
> +
> #endif /* _LINUX_GENHD_H */
>