Re: [PATCH] KEYS: Print digitalSignature and CA link errors

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

 



Hi,

Hopefully this is pretty self explanatory, it just increases the
diagnostic capabilities of using the keyring erroneously.  How do I
get someone to look at it?

Regards,
Kevin


On Thu, Aug 1, 2024 at 2:02 PM Kevin Bowling <kevin.bowling@xxxxxxxxxx> wrote:
>
> ENOKEY is overloaded for several different failure types in these link
> functions.  In addition, by the time we are consuming the return several
> other methods can return ENOKEY.  Add some error prints to help diagnose
> fundamental certificate issues.
>
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Kevin Bowling <kevin.bowling@xxxxxxxxxx>
> ---
>  crypto/asymmetric_keys/restrict.c | 24 ++++++++++++++++++------
>  1 file changed, 18 insertions(+), 6 deletions(-)
>
> diff --git a/crypto/asymmetric_keys/restrict.c b/crypto/asymmetric_keys/restrict.c
> index afcd4d101ac5..472561e451b3 100644
> --- a/crypto/asymmetric_keys/restrict.c
> +++ b/crypto/asymmetric_keys/restrict.c
> @@ -140,14 +140,20 @@ int restrict_link_by_ca(struct key *dest_keyring,
>         pkey = payload->data[asym_crypto];
>         if (!pkey)
>                 return -ENOPKG;
> -       if (!test_bit(KEY_EFLAG_CA, &pkey->key_eflags))
> +       if (!test_bit(KEY_EFLAG_CA, &pkey->key_eflags)) {
> +               pr_err("Missing CA usage bit\n");
>                 return -ENOKEY;
> -       if (!test_bit(KEY_EFLAG_KEYCERTSIGN, &pkey->key_eflags))
> +       }
> +       if (!test_bit(KEY_EFLAG_KEYCERTSIGN, &pkey->key_eflags)) {
> +               pr_err("Missing keyCertSign usage bit\n");
>                 return -ENOKEY;
> +       }
>         if (!IS_ENABLED(CONFIG_INTEGRITY_CA_MACHINE_KEYRING_MAX))
>                 return 0;
> -       if (test_bit(KEY_EFLAG_DIGITALSIG, &pkey->key_eflags))
> +       if (test_bit(KEY_EFLAG_DIGITALSIG, &pkey->key_eflags)) {
> +               pr_err("Unexpected digitalSignature usage bit\n");
>                 return -ENOKEY;
> +       }
>
>         return 0;
>  }
> @@ -183,14 +189,20 @@ int restrict_link_by_digsig(struct key *dest_keyring,
>         if (!pkey)
>                 return -ENOPKG;
>
> -       if (!test_bit(KEY_EFLAG_DIGITALSIG, &pkey->key_eflags))
> +       if (!test_bit(KEY_EFLAG_DIGITALSIG, &pkey->key_eflags)) {
> +               pr_err("Missing digitalSignature usage bit\n");
>                 return -ENOKEY;
> +       }
>
> -       if (test_bit(KEY_EFLAG_CA, &pkey->key_eflags))
> +       if (test_bit(KEY_EFLAG_CA, &pkey->key_eflags)) {
> +               pr_err("Unexpected CA usage bit\n");
>                 return -ENOKEY;
> +       }
>
> -       if (test_bit(KEY_EFLAG_KEYCERTSIGN, &pkey->key_eflags))
> +       if (test_bit(KEY_EFLAG_KEYCERTSIGN, &pkey->key_eflags)) {
> +               pr_err("Unexpected keyCertSign usage bit\n");
>                 return -ENOKEY;
> +       }
>
>         return restrict_link_by_signature(dest_keyring, type, payload,
>                                           trust_keyring);
> --
> 2.46.0
>





[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux