Skip to content

Commit 136db99

Browse files
committed
apparmor: increase left match history buffer size
There have been cases reported where a history buffer size of 8 was not enough to resolve conflict overlaps. Increase the buffer to and get rid of the size element which is currently just storing the constant WB_HISTORY_SIZE. Signed-off-by: John Johansen <[email protected]>
1 parent 8ac2ca3 commit 136db99

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

security/apparmor/include/match.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ unsigned int aa_dfa_matchn_until(struct aa_dfa *dfa, unsigned int start,
138138

139139
void aa_dfa_free_kref(struct kref *kref);
140140

141-
#define WB_HISTORY_SIZE 8
141+
#define WB_HISTORY_SIZE 24
142142
struct match_workbuf {
143143
unsigned int count;
144144
unsigned int pos;
@@ -151,7 +151,6 @@ struct match_workbuf N = { \
151151
.count = 0, \
152152
.pos = 0, \
153153
.len = 0, \
154-
.size = WB_HISTORY_SIZE, \
155154
}
156155

157156
unsigned int aa_dfa_leftmatch(struct aa_dfa *dfa, unsigned int start,

security/apparmor/match.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,8 @@ unsigned int aa_dfa_matchn_until(struct aa_dfa *dfa, unsigned int start,
620620

621621
#define inc_wb_pos(wb) \
622622
do { \
623-
wb->pos = (wb->pos + 1) & (wb->size - 1); \
624-
wb->len = (wb->len + 1) & (wb->size - 1); \
623+
wb->pos = (wb->pos + 1) & (WB_HISTORY_SIZE - 1); \
624+
wb->len = (wb->len + 1) & (WB_HISTORY_SIZE - 1); \
625625
} while (0)
626626

627627
/* For DFAs that don't support extended tagging of states */
@@ -640,7 +640,7 @@ static bool is_loop(struct match_workbuf *wb, unsigned int state,
640640
return true;
641641
}
642642
if (pos == 0)
643-
pos = wb->size;
643+
pos = WB_HISTORY_SIZE;
644644
pos--;
645645
}
646646

0 commit comments

Comments
 (0)