ceph: use correct index when encoding client supported features
commitfea013e020upstream. Feature bits have to be encoded into the correct locations. This hasn't been an issue so far because the only hole in the feature bits was in bit 10 (CEPHFS_FEATURE_RECLAIM_CLIENT), which is located in the 2nd byte. When adding more bits that go beyond the this 2nd byte, the bug will show up. [xiubli: remove incorrect comment for CEPHFS_FEATURES_CLIENT_SUPPORTED] Fixes:9ba1e22453("ceph: allocate the correct amount of extra bytes for the session features") Signed-off-by: Luís Henriques <lhenriques@suse.de> Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Xiubo Li <xiubli@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
7a327285a7
commit
97cea2cb7c
@@ -1184,14 +1184,17 @@ static int encode_supported_features(void **p, void *end)
|
||||
if (count > 0) {
|
||||
size_t i;
|
||||
size_t size = FEATURE_BYTES(count);
|
||||
unsigned long bit;
|
||||
|
||||
if (WARN_ON_ONCE(*p + 4 + size > end))
|
||||
return -ERANGE;
|
||||
|
||||
ceph_encode_32(p, size);
|
||||
memset(*p, 0, size);
|
||||
for (i = 0; i < count; i++)
|
||||
((unsigned char*)(*p))[i / 8] |= BIT(feature_bits[i] % 8);
|
||||
for (i = 0; i < count; i++) {
|
||||
bit = feature_bits[i];
|
||||
((unsigned char *)(*p))[bit / 8] |= BIT(bit % 8);
|
||||
}
|
||||
*p += size;
|
||||
} else {
|
||||
if (WARN_ON_ONCE(*p + 4 > end))
|
||||
|
||||
Reference in New Issue
Block a user