From 7dd692fc712b84d7d882f23f17af9626afe28b50 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Fri, 14 May 2004 20:21:48 -0700 Subject: [PATCH] [PATCH] calculate NGROUPS_PER_BLOCK from PAGE_SIZE From: Greg Edwards On ia64, EXEC_PAGESIZE (max page size) is 65536, but the default page size is 16k. This results in NGROUPS_PER_BLOCK in include/linux/sched.h being calculated incorrectly when the page size is anything other than 64k. For example, on a 16k page size kernel, a setgroups() call with a gidsetsize of 65536 will end up walking over memory since only 1/4 of the needed pages were allocated for the blocks[] array in the group_info struct. Patch below calculates NGROUPS_PER_BLOCK from PAGE_SIZE instead. --- include/linux/sched.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index aaf9647cdb866..205a17df51aff 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -352,7 +352,7 @@ struct io_context; /* See blkdev.h */ void exit_io_context(void); #define NGROUPS_SMALL 32 -#define NGROUPS_PER_BLOCK ((int)(EXEC_PAGESIZE / sizeof(gid_t))) +#define NGROUPS_PER_BLOCK ((int)(PAGE_SIZE / sizeof(gid_t))) struct group_info { int ngroups; atomic_t usage; -- 2.53.0