[PATCH 1/3] ceph: add BUG_ON check to ceph_pagelist_encode_string() for safety

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

 



ceph_pagelist_encode_string() should only handle string which is not
longer than U32_MAX. However, the type size_t in 64bit environment
will be 64bit unsigned long. So add a BUG_ON check just for safety.

Signed-off-by: Chengguang Xu <cgxu519@xxxxxxx>
---
 include/linux/ceph/pagelist.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/ceph/pagelist.h b/include/linux/ceph/pagelist.h
index 7edcded07641..0120af5cd1d4 100644
--- a/include/linux/ceph/pagelist.h
+++ b/include/linux/ceph/pagelist.h
@@ -70,7 +70,10 @@ static inline int ceph_pagelist_encode_8(struct ceph_pagelist *pl, u8 v)
 static inline int ceph_pagelist_encode_string(struct ceph_pagelist *pl,
 					      char *s, size_t len)
 {
-	int ret = ceph_pagelist_encode_32(pl, len);
+	int ret;
+
+	BUG_ON(len > U32_MAX);
+	ret = ceph_pagelist_encode_32(pl, len);
 	if (ret)
 		return ret;
 	if (len)
-- 
2.17.1

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



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

  Powered by Linux