netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2] libceph: Make the arguments const as per the TODO
@ 2024-08-11 20:55 Abhinav Jain
  2024-08-12  7:09 ` kernel test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Abhinav Jain @ 2024-08-11 20:55 UTC (permalink / raw)
  To: idryomov, xiubli, davem, edumazet, kuba, pabeni, ceph-devel,
	netdev, linux-kernel
  Cc: skhan, javier.carrasco.cruz, Abhinav Jain

net/ceph/crypto.c:
Modify arguments to const in ceph_crypto_key_decode().
Modify ceph_key_preparse() and ceph_crypto_key_unarmor()
in accordance with the changes.

net/ceph/crypto.h:
Add changes in the prototype of ceph_crypto_key_decode().

net/ceph/auth_x.c:
Modify the arguments to function ceph_crypto_key_decode()
being called in the function process_one_ticket().

v1:
lore.kernel.org/all/20240811193645.1082042-1-jain.abhinav177@gmail.com

Changes since v1:
 - Incorrect changes made in v1 fixed.
 - Found the other files where the change needed to be made.

Signed-off-by: Abhinav Jain <jain.abhinav177@gmail.com>
---
 net/ceph/auth_x.c |  4 +++-
 net/ceph/crypto.c | 15 ++++++++-------
 net/ceph/crypto.h |  2 +-
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/net/ceph/auth_x.c b/net/ceph/auth_x.c
index b71b1635916e..81272603f981 100644
--- a/net/ceph/auth_x.c
+++ b/net/ceph/auth_x.c
@@ -204,7 +204,9 @@ static int process_one_ticket(struct ceph_auth_client *ac,
 	if (tkt_struct_v != 1)
 		goto bad;
 
-	ret = ceph_crypto_key_decode(&new_session_key, &dp, dend);
+	ret = ceph_crypto_key_decode(&new_session_key, \
+		(const void **)&dp, (const void *)dend);
+
 	if (ret)
 		goto out;
 
diff --git a/net/ceph/crypto.c b/net/ceph/crypto.c
index 051d22c0e4ad..905b80d738b1 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;
 
@@ -109,7 +109,8 @@ int ceph_crypto_key_unarmor(struct ceph_crypto_key *key, const char *inkey)
 {
 	int inlen = strlen(inkey);
 	int blen = inlen * 3 / 4;
-	void *buf, *p;
+	void *buf;
+	const void *p;
 	int ret;
 
 	dout("crypto_key_unarmor %s\n", inkey);
@@ -123,7 +124,7 @@ int ceph_crypto_key_unarmor(struct ceph_crypto_key *key, const char *inkey)
 	}
 
 	p = buf;
-	ret = ceph_crypto_key_decode(key, &p, p + blen);
+	ret = ceph_crypto_key_decode(key, &p, (const void *)((const char *)p + blen));
 	kfree(buf);
 	if (ret)
 		return ret;
@@ -300,7 +301,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 +312,9 @@ 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 void *)((const char *)prep->data + datalen));
 	if (ret < 0)
 		goto err_ckey;
 
diff --git a/net/ceph/crypto.h b/net/ceph/crypto.h
index 13bd526349fa..ba57376fa635 100644
--- a/net/ceph/crypto.h
+++ b/net/ceph/crypto.h
@@ -22,7 +22,7 @@ struct ceph_crypto_key {
 int ceph_crypto_key_clone(struct ceph_crypto_key *dst,
 			  const struct ceph_crypto_key *src);
 int ceph_crypto_key_encode(struct ceph_crypto_key *key, void **p, void *end);
-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 ceph_crypto_key_unarmor(struct ceph_crypto_key *key, const char *in);
 void ceph_crypto_key_destroy(struct ceph_crypto_key *key);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-08-12 15:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-11 20:55 [PATCH net v2] libceph: Make the arguments const as per the TODO Abhinav Jain
2024-08-12  7:09 ` kernel test robot
2024-08-12 15:26 ` kernel test robot
2024-08-12 15:46 ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).