Re: [bug report] crypto: spacc - Add SPAcc Skcipher support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Dan,
   This is a counter width check. The counter widths can be 8,16,32,64 bits.
That check is a bug and not dead code, I am pushing a patch for that.

Warm regards,
PK


On Thu, Aug 15, 2024 at 2:57 AM Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:
>
> Hello Pavitrakumar M,
>
> Commit c8981d9230d8 ("crypto: spacc - Add SPAcc Skcipher support")
> from Jul 29, 2024 (linux-next), leads to the following Smatch static
> checker warning:
>
>         drivers/crypto/dwc-spacc/spacc_skcipher.c:458 spacc_cipher_process()
>         warn: bitwise AND condition is false here
>
> drivers/crypto/dwc-spacc/spacc_skcipher.c
>     441                 } else if (readl(device_h->regmap + SPACC_REG_VERSION_EXT_3)
>     442                            & (0x1)) { /* 16-bit counter width */
>     443
>     444                         for (i = 14; i < 16; i++) {
>     445                                 num_iv <<= 8;
>     446                                 num_iv |= ivc1[i];
>     447                         }
>     448
>     449                         diff = SPACC_CTR_IV_MAX16 - num_iv;
>     450
>     451                         if (len > diff) {
>     452                                 name = salg->calg->cra_name;
>     453                                 ret = spacc_skcipher_fallback(name,
>     454                                                               req, enc_dec);
>     455                                 return ret;
>     456                         }
>     457                 } else if (readl(device_h->regmap + SPACC_REG_VERSION_EXT_3)
> --> 458                            & (0x0)) { /* 8-bit counter width */
>                                    ^^^^^^^
> What the deal here?  Generally in the kernel we don't allow dead code.  If it's
> necessary then we can add it later.
>
>     459
>     460                         for (i = 15; i < 16; i++) {
>     461                                 num_iv <<= 8;
>     462                                 num_iv |= ivc1[i];
>     463                         }
>     464
>     465                         diff = SPACC_CTR_IV_MAX8 - num_iv;
>     466
>     467                         if (len > diff) {
>     468                                 name = salg->calg->cra_name;
>     469                                 ret = spacc_skcipher_fallback(name,
>     470                                                               req, enc_dec);
>     471                                 return ret;
>     472                         }
>     473                 }
>     474         }
>
> regards,
> dan carpenter





[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux