Re: [PATCH net] libceph: Make the input const as per the TODO

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

 



Hi Abhinav,

kernel test robot noticed the following build errors:

[auto build test ERROR on net/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Abhinav-Jain/libceph-Make-the-input-const-as-per-the-TODO/20240812-033900
base:   net/main
patch link:    https://lore.kernel.org/r/20240811193645.1082042-1-jain.abhinav177%40gmail.com
patch subject: [PATCH net] libceph: Make the input const as per the TODO
config: i386-allmodconfig (https://download.01.org/0day-ci/archive/20240812/202408120903.UYNxKoDx-lkp@xxxxxxxxx/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240812/202408120903.UYNxKoDx-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408120903.UYNxKoDx-lkp@xxxxxxxxx/

All error/warnings (new ones prefixed by >>):

>> net/ceph/crypto.c:89:5: error: conflicting types for 'ceph_crypto_key_decode'; have 'int(struct ceph_crypto_key *, const void **, const void *)'
      89 | int ceph_crypto_key_decode(struct ceph_crypto_key *key, const void **p, const void *end)
         |     ^~~~~~~~~~~~~~~~~~~~~~
   In file included from net/ceph/crypto.c:17:
   net/ceph/crypto.h:25:5: note: previous declaration of 'ceph_crypto_key_decode' with type 'int(struct ceph_crypto_key *, void **, void *)'
      25 | int ceph_crypto_key_decode(struct ceph_crypto_key *key, void **p, void *end);
         |     ^~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/array_size.h:5,
                    from include/linux/string.h:6,
                    from include/linux/ceph/ceph_debug.h:7,
                    from net/ceph/crypto.c:3:
   net/ceph/crypto.c: In function 'ceph_crypto_key_decode':
>> net/ceph/crypto.c:93:26: error: passing argument 1 of 'ceph_has_room' from incompatible pointer type [-Werror=incompatible-pointer-types]
      93 |         ceph_decode_need(p, end, 2*sizeof(u16) + sizeof(key->created), bad);
         |                          ^
         |                          |
         |                          const void **
   include/linux/compiler.h:76:45: note: in definition of macro 'likely'
      76 | # define likely(x)      __builtin_expect(!!(x), 1)
         |                                             ^
   net/ceph/crypto.c:93:9: note: in expansion of macro 'ceph_decode_need'
      93 |         ceph_decode_need(p, end, 2*sizeof(u16) + sizeof(key->created), bad);
         |         ^~~~~~~~~~~~~~~~
   In file included from net/ceph/crypto.c:16:
   include/linux/ceph/decode.h:52:41: note: expected 'void **' but argument is of type 'const void **'
      52 | static inline bool ceph_has_room(void **p, void *end, size_t n)
         |                                  ~~~~~~~^
>> net/ceph/crypto.c:93:29: warning: passing argument 2 of 'ceph_has_room' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
      93 |         ceph_decode_need(p, end, 2*sizeof(u16) + sizeof(key->created), bad);
         |                             ^~~
   include/linux/compiler.h:76:45: note: in definition of macro 'likely'
      76 | # define likely(x)      __builtin_expect(!!(x), 1)
         |                                             ^
   net/ceph/crypto.c:93:9: note: in expansion of macro 'ceph_decode_need'
      93 |         ceph_decode_need(p, end, 2*sizeof(u16) + sizeof(key->created), bad);
         |         ^~~~~~~~~~~~~~~~
   include/linux/ceph/decode.h:52:50: note: expected 'void *' but argument is of type 'const void *'
      52 | static inline bool ceph_has_room(void **p, void *end, size_t n)
         |                                            ~~~~~~^~~
>> net/ceph/crypto.c:94:36: error: passing argument 1 of 'ceph_decode_16' from incompatible pointer type [-Werror=incompatible-pointer-types]
      94 |         key->type = ceph_decode_16(p);
         |                                    ^
         |                                    |
         |                                    const void **
   include/linux/ceph/decode.h:31:41: note: expected 'void **' but argument is of type 'const void **'
      31 | static inline u16 ceph_decode_16(void **p)
         |                                  ~~~~~~~^
>> net/ceph/crypto.c:95:26: error: passing argument 1 of 'ceph_decode_copy' from incompatible pointer type [-Werror=incompatible-pointer-types]
      95 |         ceph_decode_copy(p, &key->created, sizeof(key->created));
         |                          ^
         |                          |
         |                          const void **
   include/linux/ceph/decode.h:43:44: note: expected 'void **' but argument is of type 'const void **'
      43 | static inline void ceph_decode_copy(void **p, void *pv, size_t n)
         |                                     ~~~~~~~^
   net/ceph/crypto.c:96:35: error: passing argument 1 of 'ceph_decode_16' from incompatible pointer type [-Werror=incompatible-pointer-types]
      96 |         key->len = ceph_decode_16(p);
         |                                   ^
         |                                   |
         |                                   const void **
   include/linux/ceph/decode.h:31:41: note: expected 'void **' but argument is of type 'const void **'
      31 | static inline u16 ceph_decode_16(void **p)
         |                                  ~~~~~~~^
   net/ceph/crypto.c:97:26: error: passing argument 1 of 'ceph_has_room' from incompatible pointer type [-Werror=incompatible-pointer-types]
      97 |         ceph_decode_need(p, end, key->len, bad);
         |                          ^
         |                          |
         |                          const void **
   include/linux/compiler.h:76:45: note: in definition of macro 'likely'
      76 | # define likely(x)      __builtin_expect(!!(x), 1)
         |                                             ^
   net/ceph/crypto.c:97:9: note: in expansion of macro 'ceph_decode_need'
      97 |         ceph_decode_need(p, end, key->len, bad);
         |         ^~~~~~~~~~~~~~~~
   include/linux/ceph/decode.h:52:41: note: expected 'void **' but argument is of type 'const void **'
      52 | static inline bool ceph_has_room(void **p, void *end, size_t n)
         |                                  ~~~~~~~^
   net/ceph/crypto.c:97:29: warning: passing argument 2 of 'ceph_has_room' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
      97 |         ceph_decode_need(p, end, key->len, bad);
         |                             ^~~
   include/linux/compiler.h:76:45: note: in definition of macro 'likely'
      76 | # define likely(x)      __builtin_expect(!!(x), 1)
         |                                             ^
   net/ceph/crypto.c:97:9: note: in expansion of macro 'ceph_decode_need'
      97 |         ceph_decode_need(p, end, key->len, bad);
         |         ^~~~~~~~~~~~~~~~
   include/linux/ceph/decode.h:52:50: note: expected 'void *' but argument is of type 'const void *'
      52 | static inline bool ceph_has_room(void **p, void *end, size_t n)
         |                                            ~~~~~~^~~
>> net/ceph/crypto.c:98:31: warning: passing argument 2 of 'set_secret' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
      98 |         ret = set_secret(key, *p);
         |                               ^~
   net/ceph/crypto.c:23:58: note: expected 'void *' but argument is of type 'const void *'
      23 | static int set_secret(struct ceph_crypto_key *key, void *buf)
         |                                                    ~~~~~~^~~
>> net/ceph/crypto.c:99:26: warning: passing argument 1 of 'memzero_explicit' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
      99 |         memzero_explicit(*p, key->len);
         |                          ^~
   include/linux/string.h:356:43: note: expected 'void *' but argument is of type 'const void *'
     356 | static inline void memzero_explicit(void *s, size_t count)
         |                                     ~~~~~~^
   net/ceph/crypto.c: In function 'ceph_crypto_key_unarmor':
>> net/ceph/crypto.c:126:43: error: passing argument 2 of 'ceph_crypto_key_decode' from incompatible pointer type [-Werror=incompatible-pointer-types]
     126 |         ret = ceph_crypto_key_decode(key, &p, p + blen);
         |                                           ^~
         |                                           |
         |                                           void **
   net/ceph/crypto.c:89:70: note: expected 'const void **' but argument is of type 'void **'
      89 | int ceph_crypto_key_decode(struct ceph_crypto_key *key, const void **p, const void *end)
         |                                                         ~~~~~~~~~~~~~^
   cc1: some warnings being treated as errors


vim +89 net/ceph/crypto.c

    13	
    14	#include <keys/ceph-type.h>
    15	#include <keys/user-type.h>
    16	#include <linux/ceph/decode.h>
  > 17	#include "crypto.h"
    18	
    19	/*
    20	 * Set ->key and ->tfm.  The rest of the key should be filled in before
    21	 * this function is called.
    22	 */
    23	static int set_secret(struct ceph_crypto_key *key, void *buf)
    24	{
    25		unsigned int noio_flag;
    26		int ret;
    27	
    28		key->key = NULL;
    29		key->tfm = NULL;
    30	
    31		switch (key->type) {
    32		case CEPH_CRYPTO_NONE:
    33			return 0; /* nothing to do */
    34		case CEPH_CRYPTO_AES:
    35			break;
    36		default:
    37			return -ENOTSUPP;
    38		}
    39	
    40		if (!key->len)
    41			return -EINVAL;
    42	
    43		key->key = kmemdup(buf, key->len, GFP_NOIO);
    44		if (!key->key) {
    45			ret = -ENOMEM;
    46			goto fail;
    47		}
    48	
    49		/* crypto_alloc_sync_skcipher() allocates with GFP_KERNEL */
    50		noio_flag = memalloc_noio_save();
    51		key->tfm = crypto_alloc_sync_skcipher("cbc(aes)", 0, 0);
    52		memalloc_noio_restore(noio_flag);
    53		if (IS_ERR(key->tfm)) {
    54			ret = PTR_ERR(key->tfm);
    55			key->tfm = NULL;
    56			goto fail;
    57		}
    58	
    59		ret = crypto_sync_skcipher_setkey(key->tfm, key->key, key->len);
    60		if (ret)
    61			goto fail;
    62	
    63		return 0;
    64	
    65	fail:
    66		ceph_crypto_key_destroy(key);
    67		return ret;
    68	}
    69	
    70	int ceph_crypto_key_clone(struct ceph_crypto_key *dst,
    71				  const struct ceph_crypto_key *src)
    72	{
    73		memcpy(dst, src, sizeof(struct ceph_crypto_key));
    74		return set_secret(dst, src->key);
    75	}
    76	
    77	int ceph_crypto_key_encode(struct ceph_crypto_key *key, void **p, void *end)
    78	{
    79		if (*p + sizeof(u16) + sizeof(key->created) +
    80		    sizeof(u16) + key->len > end)
    81			return -ERANGE;
    82		ceph_encode_16(p, key->type);
    83		ceph_encode_copy(p, &key->created, sizeof(key->created));
    84		ceph_encode_16(p, key->len);
    85		ceph_encode_copy(p, key->key, key->len);
    86		return 0;
    87	}
    88	
  > 89	int ceph_crypto_key_decode(struct ceph_crypto_key *key, const void **p, const void *end)
    90	{
    91		int ret;
    92	
  > 93		ceph_decode_need(p, end, 2*sizeof(u16) + sizeof(key->created), bad);
  > 94		key->type = ceph_decode_16(p);
  > 95		ceph_decode_copy(p, &key->created, sizeof(key->created));
    96		key->len = ceph_decode_16(p);
  > 97		ceph_decode_need(p, end, key->len, bad);
  > 98		ret = set_secret(key, *p);
  > 99		memzero_explicit(*p, key->len);
   100		*p += key->len;
   101		return ret;
   102	
   103	bad:
   104		dout("failed to decode crypto key\n");
   105		return -EINVAL;
   106	}
   107	
   108	int ceph_crypto_key_unarmor(struct ceph_crypto_key *key, const char *inkey)
   109	{
   110		int inlen = strlen(inkey);
   111		int blen = inlen * 3 / 4;
   112		void *buf, *p;
   113		int ret;
   114	
   115		dout("crypto_key_unarmor %s\n", inkey);
   116		buf = kmalloc(blen, GFP_NOFS);
   117		if (!buf)
   118			return -ENOMEM;
   119		blen = ceph_unarmor(buf, inkey, inkey+inlen);
   120		if (blen < 0) {
   121			kfree(buf);
   122			return blen;
   123		}
   124	
   125		p = buf;
 > 126		ret = ceph_crypto_key_decode(key, &p, p + blen);
   127		kfree(buf);
   128		if (ret)
   129			return ret;
   130		dout("crypto_key_unarmor key %p type %d len %d\n", key,
   131		     key->type, key->len);
   132		return 0;
   133	}
   134	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki




[Index of Archives]     [CEPH Users]     [Ceph Large]     [Ceph Dev]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux