Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

apparmor: ensure WB_HISTORY_SIZE value is a power of 2

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: 136db994852a ("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>

authored by

Ryan Lee and committed by
John Johansen
6c055e62 a949b46e

+3 -1
+2 -1
security/apparmor/include/match.h
··· 137 137 138 138 void aa_dfa_free_kref(struct kref *kref); 139 139 140 - #define WB_HISTORY_SIZE 24 140 + /* This needs to be a power of 2 */ 141 + #define WB_HISTORY_SIZE 32 141 142 struct match_workbuf { 142 143 unsigned int count; 143 144 unsigned int pos;
+1
security/apparmor/match.c
··· 681 681 682 682 #define inc_wb_pos(wb) \ 683 683 do { \ 684 + BUILD_BUG_ON_NOT_POWER_OF_2(WB_HISTORY_SIZE); \ 684 685 wb->pos = (wb->pos + 1) & (WB_HISTORY_SIZE - 1); \ 685 686 wb->len = (wb->len + 1) & (WB_HISTORY_SIZE - 1); \ 686 687 } while (0)