Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F108569466
D46911.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D46911.diff
View Options
diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c
--- a/sys/kern/kern_prot.c
+++ b/sys/kern/kern_prot.c
@@ -811,7 +811,7 @@
int
sys_setgroups(struct thread *td, struct setgroups_args *uap)
{
- gid_t smallgroups[XU_NGROUPS];
+ gid_t smallgroups[CRED_SMALLGROUPS_NB];
gid_t *groups;
int gidsetsize, error;
@@ -819,7 +819,7 @@
if (gidsetsize > ngroups_max + 1 || gidsetsize < 0)
return (EINVAL);
- if (gidsetsize > XU_NGROUPS)
+ if (gidsetsize > CRED_SMALLGROUPS_NB)
groups = malloc(gidsetsize * sizeof(gid_t), M_TEMP, M_WAITOK);
else
groups = smallgroups;
@@ -828,7 +828,7 @@
if (error == 0)
error = kern_setgroups(td, gidsetsize, groups);
- if (gidsetsize > XU_NGROUPS)
+ if (gidsetsize > CRED_SMALLGROUPS_NB)
free(groups, M_TEMP);
return (error);
}
diff --git a/sys/sys/ucred.h b/sys/sys/ucred.h
--- a/sys/sys/ucred.h
+++ b/sys/sys/ucred.h
@@ -42,6 +42,14 @@
#define XU_NGROUPS 16
+#if defined(_KERNEL) || defined(_WANT_UCRED)
+/*
+ * Number of groups inlined in 'struct ucred'. It must stay reasonably low as
+ * it is also used by some functions to allocate an array of this size on the
+ * stack.
+ */
+#define CRED_SMALLGROUPS_NB 16
+
/*
* Credentials.
*
@@ -55,7 +63,6 @@
*
* See "Credential management" comment in kern_prot.c for more information.
*/
-#if defined(_KERNEL) || defined(_WANT_UCRED)
struct ucred {
struct mtx cr_mtx;
long cr_ref; /* (c) reference count */
@@ -78,7 +85,8 @@
struct label *cr_label; /* MAC label */
gid_t *cr_groups; /* groups */
int cr_agroups; /* Available groups */
- gid_t cr_smallgroups[XU_NGROUPS]; /* storage for small groups */
+ /* storage for small groups */
+ gid_t cr_smallgroups[CRED_SMALLGROUPS_NB];
};
#define NOCRED ((struct ucred *)0) /* no credential available */
#define FSCRED ((struct ucred *)-1) /* filesystem credential */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 27, 11:21 AM (4 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16194920
Default Alt Text
D46911.diff (1 KB)
Attached To
Mode
D46911: cred: Separate constant for the number of inlined groups
Attached
Detach File
Event Timeline
Log In to Comment