Re: arch/arm/crypto/sha1_glue.c:34:8: warning: cast from 'void (*)(u32 *, const unsigned char *, unsigned int)' (aka 'void (*)(unsigned int *, const unsigned char *, unsigned int)') to 'sha1_block_fn *' (aka 'void (*)(struct sha1_state *, const unsigned char ...

From: Ard Biesheuvel
Date: Thu Dec 08 2022 - 13:06:06 EST


On Thu, 8 Dec 2022 at 05:59, Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> wrote:
>
> On Fri, Nov 04, 2022 at 07:33:43PM +0800, kernel test robot wrote:
> >
> > vim +34 arch/arm/crypto/sha1_glue.c
> >
> > f0be44f4fb1fae David McCullough 2012-09-07 23
> > 1f8673d31a999e Jussi Kivilinna 2014-07-29 24 asmlinkage void sha1_block_data_order(u32 *digest,
> > f0be44f4fb1fae David McCullough 2012-09-07 25 const unsigned char *data, unsigned int rounds);
> > f0be44f4fb1fae David McCullough 2012-09-07 26
> > 604682551aa511 Jussi Kivilinna 2014-07-29 27 int sha1_update_arm(struct shash_desc *desc, const u8 *data,
> > f0be44f4fb1fae David McCullough 2012-09-07 28 unsigned int len)
> > f0be44f4fb1fae David McCullough 2012-09-07 29 {
> > 90451d6bdb787e Ard Biesheuvel 2015-04-09 30 /* make sure casting to sha1_block_fn() is safe */
> > 90451d6bdb787e Ard Biesheuvel 2015-04-09 31 BUILD_BUG_ON(offsetof(struct sha1_state, state) != 0);
> > f0be44f4fb1fae David McCullough 2012-09-07 32
> > 90451d6bdb787e Ard Biesheuvel 2015-04-09 33 return sha1_base_do_update(desc, data, len,
> > 90451d6bdb787e Ard Biesheuvel 2015-04-09 @34 (sha1_block_fn *)sha1_block_data_order);
> > f0be44f4fb1fae David McCullough 2012-09-07 35 }
> > 604682551aa511 Jussi Kivilinna 2014-07-29 36 EXPORT_SYMBOL_GPL(sha1_update_arm);
> > f0be44f4fb1fae David McCullough 2012-09-07 37
>
> So clan doesn't like the cast on the assembly function.
>
> Ard, why can't we just change the signature of the assembly
> function instead of casting?
>

We can, as the BUILD_BUG() will catch it if struct sha1_state gets
modified in an incompatible way.