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

Configure Feed

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

logfs: Prevent memory corruption

This is a bad one. I wonder whether we were so far protected by
no_free_segments(sb) usually being smaller than LOGFS_NO_AREAS.

Found by Dan Carpenter <dan.carpenter@oracle.com> using smatch.

Signed-off-by: Joern Engel <joern@logfs.org>
Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>

authored by

Joern Engel and committed by
Prasad Joshi
934eed39 96150606

+1 -1
+1 -1
fs/logfs/gc.c
··· 367 367 int i, max_dist; 368 368 struct gc_candidate *cand = NULL, *this; 369 369 370 - max_dist = min(no_free_segments(sb), LOGFS_NO_AREAS); 370 + max_dist = min(no_free_segments(sb), LOGFS_NO_AREAS - 1); 371 371 372 372 for (i = max_dist; i >= 0; i--) { 373 373 this = first_in_list(&super->s_low_list[i]);