diff mbox series

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

Message ID 20240811193645.1082042-1-jain.abhinav177@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net] libceph: Make the input const as per the TODO | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present fail Series targets non-next tree, but doesn't contain any Fixes tags
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 29 this patch: 24
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang fail Errors and warnings before: 29 this patch: 26
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 29 this patch: 24
netdev/checkpatch warning WARNING: line length of 83 exceeds 80 columns WARNING: line length of 88 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Abhinav Jain Aug. 11, 2024, 7:36 p.m. UTC
Modify arguments to const in ceph_crypto_key_decode().
Modify ceph_key_preparse() in accordance with the changes.

Signed-off-by: Abhinav Jain <jain.abhinav177@gmail.com>
---
 net/ceph/crypto.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Abhinav Jain Aug. 11, 2024, 8:57 p.m. UTC | #1
I realised that I made a bit of mistakes while sending this patch and hence
I have sent a v2. Kindly check v2 here:

lore.kernel.org/all/20240811205509.1089027-1-jain.abhinav177@gmail.com
---
kernel test robot Aug. 11, 2024, 11:42 p.m. UTC | #2
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-buildonly-randconfig-002-20240812 (https://download.01.org/0day-ci/archive/20240812/202408120724.pyUdMxWP-lkp@intel.com/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240812/202408120724.pyUdMxWP-lkp@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408120724.pyUdMxWP-lkp@intel.com/

All errors (new ones prefixed by >>):

>> net/ceph/crypto.c:89:5: error: conflicting types for 'ceph_crypto_key_decode'
      89 | int ceph_crypto_key_decode(struct ceph_crypto_key *key, const void **p, const void *end)
         |     ^
   net/ceph/crypto.h:25:5: note: previous declaration is here
      25 | int ceph_crypto_key_decode(struct ceph_crypto_key *key, void **p, void *end);
         |     ^
>> net/ceph/crypto.c:93:19: error: passing 'const void **' to parameter of type 'void **' discards qualifiers in nested pointer types [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
      93 |         ceph_decode_need(p, end, 2*sizeof(u16) + sizeof(key->created), bad);
         |                          ^
   include/linux/ceph/decode.h:59:29: note: expanded from macro 'ceph_decode_need'
      59 |                 if (!likely(ceph_has_room(p, end, n)))          \
         |                                           ^
   include/linux/compiler.h:76:40: note: expanded from macro 'likely'
      76 | # define likely(x)      __builtin_expect(!!(x), 1)
         |                                             ^
   include/linux/ceph/decode.h:52:41: note: passing argument to parameter 'p' here
      52 | static inline bool ceph_has_room(void **p, void *end, size_t n)
         |                                         ^
>> net/ceph/crypto.c:93:22: error: passing 'const void *' to parameter of type 'void *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
      93 |         ceph_decode_need(p, end, 2*sizeof(u16) + sizeof(key->created), bad);
         |                             ^~~
   include/linux/ceph/decode.h:59:32: note: expanded from macro 'ceph_decode_need'
      59 |                 if (!likely(ceph_has_room(p, end, n)))          \
         |                                              ^~~
   include/linux/compiler.h:76:40: note: expanded from macro 'likely'
      76 | # define likely(x)      __builtin_expect(!!(x), 1)
         |                                             ^
   include/linux/ceph/decode.h:52:50: note: passing argument to parameter 'end' here
      52 | static inline bool ceph_has_room(void **p, void *end, size_t n)
         |                                                  ^
   net/ceph/crypto.c:94:29: error: passing 'const void **' to parameter of type 'void **' discards qualifiers in nested pointer types [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
      94 |         key->type = ceph_decode_16(p);
         |                                    ^
   include/linux/ceph/decode.h:31:41: note: passing argument to parameter 'p' here
      31 | static inline u16 ceph_decode_16(void **p)
         |                                         ^
   net/ceph/crypto.c:95:19: error: passing 'const void **' to parameter of type 'void **' discards qualifiers in nested pointer types [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
      95 |         ceph_decode_copy(p, &key->created, sizeof(key->created));
         |                          ^
   include/linux/ceph/decode.h:43:44: note: passing argument to parameter 'p' here
      43 | static inline void ceph_decode_copy(void **p, void *pv, size_t n)
         |                                            ^
   net/ceph/crypto.c:96:28: error: passing 'const void **' to parameter of type 'void **' discards qualifiers in nested pointer types [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
      96 |         key->len = ceph_decode_16(p);
         |                                   ^
   include/linux/ceph/decode.h:31:41: note: passing argument to parameter 'p' here
      31 | static inline u16 ceph_decode_16(void **p)
         |                                         ^
   net/ceph/crypto.c:97:19: error: passing 'const void **' to parameter of type 'void **' discards qualifiers in nested pointer types [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
      97 |         ceph_decode_need(p, end, key->len, bad);
         |                          ^
   include/linux/ceph/decode.h:59:29: note: expanded from macro 'ceph_decode_need'
      59 |                 if (!likely(ceph_has_room(p, end, n)))          \
         |                                           ^
   include/linux/compiler.h:76:40: note: expanded from macro 'likely'
      76 | # define likely(x)      __builtin_expect(!!(x), 1)
         |                                             ^
   include/linux/ceph/decode.h:52:41: note: passing argument to parameter 'p' here
      52 | static inline bool ceph_has_room(void **p, void *end, size_t n)
         |                                         ^
   net/ceph/crypto.c:97:22: error: passing 'const void *' to parameter of type 'void *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
      97 |         ceph_decode_need(p, end, key->len, bad);
         |                             ^~~
   include/linux/ceph/decode.h:59:32: note: expanded from macro 'ceph_decode_need'
      59 |                 if (!likely(ceph_has_room(p, end, n)))          \
         |                                              ^~~
   include/linux/compiler.h:76:40: note: expanded from macro 'likely'
      76 | # define likely(x)      __builtin_expect(!!(x), 1)
         |                                             ^
   include/linux/ceph/decode.h:52:50: note: passing argument to parameter 'end' here
      52 | static inline bool ceph_has_room(void **p, void *end, size_t n)
         |                                                  ^
   net/ceph/crypto.c:98:24: error: passing 'const void *' to parameter of type 'void *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
      98 |         ret = set_secret(key, *p);
         |                               ^~
   net/ceph/crypto.c:23:58: note: passing argument to parameter 'buf' here
      23 | static int set_secret(struct ceph_crypto_key *key, void *buf)
         |                                                          ^
   net/ceph/crypto.c:99:19: error: passing 'const void *' to parameter of type 'void *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
      99 |         memzero_explicit(*p, key->len);
         |                          ^~
   include/linux/string.h:356:43: note: passing argument to parameter 's' here
     356 | static inline void memzero_explicit(void *s, size_t count)
         |                                           ^
   net/ceph/crypto.c:315:37: error: passing 'const void **' to parameter of type 'void **' discards qualifiers in nested pointer types [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
     315 |         ret = ceph_crypto_key_decode(ckey, &p, (const char *)prep->data + datalen);
         |                                            ^~
   net/ceph/crypto.h:25:64: note: passing argument to parameter 'p' here
      25 | int ceph_crypto_key_decode(struct ceph_crypto_key *key, void **p, void *end);
         |                                                                ^
>> net/ceph/crypto.c:315:41: error: passing 'const char *' to parameter of type 'void *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
     315 |         ret = ceph_crypto_key_decode(ckey, &p, (const char *)prep->data + datalen);
         |                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/ceph/crypto.h:25:73: note: passing argument to parameter 'end' here
      25 | int ceph_crypto_key_decode(struct ceph_crypto_key *key, void **p, void *end);
         |                                                                         ^
   12 errors generated.


vim +/ceph_crypto_key_decode +89 net/ceph/crypto.c

    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
kernel test robot Aug. 12, 2024, 2:15 a.m. UTC | #3
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@intel.com/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@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408120903.UYNxKoDx-lkp@intel.com/

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
diff mbox series

Patch

diff --git a/net/ceph/crypto.c b/net/ceph/crypto.c
index 051d22c0e4ad..cfd485d6d3c5 100644
--- a/net/ceph/crypto.c
+++ b/net/ceph/crypto.c
@@ -86,7 +86,7 @@  int ceph_crypto_key_encode(struct ceph_crypto_key *key, void **p, void *end)
 	return 0;
 }
 
-int ceph_crypto_key_decode(struct ceph_crypto_key *key, void **p, void *end)
+int ceph_crypto_key_decode(struct ceph_crypto_key *key, const void **p, const void *end)
 {
 	int ret;
 
@@ -300,7 +300,7 @@  static int ceph_key_preparse(struct key_preparsed_payload *prep)
 	struct ceph_crypto_key *ckey;
 	size_t datalen = prep->datalen;
 	int ret;
-	void *p;
+	const void *p;
 
 	ret = -EINVAL;
 	if (datalen <= 0 || datalen > 32767 || !prep->data)
@@ -311,9 +311,8 @@  static int ceph_key_preparse(struct key_preparsed_payload *prep)
 	if (!ckey)
 		goto err;
 
-	/* TODO ceph_crypto_key_decode should really take const input */
-	p = (void *)prep->data;
-	ret = ceph_crypto_key_decode(ckey, &p, (char*)prep->data+datalen);
+	p = prep->data;
+	ret = ceph_crypto_key_decode(ckey, &p, (const char *)prep->data + datalen);
 	if (ret < 0)
 		goto err_ckey;