mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux-stable.git
synced 2025-09-13 11:07:46 +10:00
apparmor: ensure WB_HISTORY_SIZE value is a power of 2
[ Upstream commit6c055e6256
] WB_HISTORY_SIZE was defined to be a value not a power of 2, despite a comment in the declaration of struct match_workbuf stating it is and a modular arithmetic usage in the inc_wb_pos macro assuming that it is. Bump WB_HISTORY_SIZE's value up to 32 and add a BUILD_BUG_ON_NOT_POWER_OF_2 line to ensure that any future changes to the value of WB_HISTORY_SIZE respect this requirement. Fixes:136db99485
("apparmor: increase left match history buffer size") Signed-off-by: Ryan Lee <ryan.lee@canonical.com> Signed-off-by: John Johansen <john.johansen@canonical.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
74a87aca09
commit
69e83e5527
@ -141,7 +141,8 @@ unsigned int aa_dfa_matchn_until(struct aa_dfa *dfa, unsigned int start,
|
||||
|
||||
void aa_dfa_free_kref(struct kref *kref);
|
||||
|
||||
#define WB_HISTORY_SIZE 24
|
||||
/* This needs to be a power of 2 */
|
||||
#define WB_HISTORY_SIZE 32
|
||||
struct match_workbuf {
|
||||
unsigned int count;
|
||||
unsigned int pos;
|
||||
|
@ -672,6 +672,7 @@ unsigned int aa_dfa_matchn_until(struct aa_dfa *dfa, unsigned int start,
|
||||
|
||||
#define inc_wb_pos(wb) \
|
||||
do { \
|
||||
BUILD_BUG_ON_NOT_POWER_OF_2(WB_HISTORY_SIZE); \
|
||||
wb->pos = (wb->pos + 1) & (WB_HISTORY_SIZE - 1); \
|
||||
wb->len = (wb->len + 1) & (WB_HISTORY_SIZE - 1); \
|
||||
} while (0)
|
||||
|
Loading…
Reference in New Issue
Block a user