Skip to content

Commit

Permalink
netlabel: fix shift wrapping bug in netlbl_catmap_setlong()
Browse files Browse the repository at this point in the history
[ Upstream commit b403643 ]

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: Dmitry Mastykin <dmastykin@astralinux.ru>
Acked-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
mastykin-astra authored and gregkh committed Sep 13, 2023
1 parent 78ef22f commit 179b9b0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/netlabel/netlabel_kapi.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit 179b9b0

Please sign in to comment.