Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c1ce2f09 authored by Dmitry Mastykin's avatar Dmitry Mastykin Committed by Greg Kroah-Hartman
Browse files

netlabel: fix shift wrapping bug in netlbl_catmap_setlong()



[ Upstream commit b403643d154d15176b060b82f7fc605210033edd ]

There is a shift wrapping bug in this code on 32-bit architectures.
NETLBL_CATMAP_MAPTYPE is u64, bitmap is unsigned long.
Every second 32-bit word of catmap becomes corrupted.

Signed-off-by: default avatarDmitry Mastykin <dmastykin@astralinux.ru>
Acked-by: default avatarPaul Moore <paul@paul-moore.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 499eb477
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -857,7 +857,8 @@ int netlbl_catmap_setlong(struct netlbl_lsm_catmap **catmap,

	offset -= iter->startbit;
	idx = offset / NETLBL_CATMAP_MAPSIZE;
	iter->bitmap[idx] |= bitmap << (offset % NETLBL_CATMAP_MAPSIZE);
	iter->bitmap[idx] |= (NETLBL_CATMAP_MAPTYPE)bitmap
			     << (offset % NETLBL_CATMAP_MAPSIZE);

	return 0;
}