Page MenuHomeFreeBSD

D46911.diff
No OneTemporary

D46911.diff

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
@@ -38,8 +38,6 @@
#endif
#include <bsm/audit.h>
-#define XU_NGROUPS 16
-
#if defined(_KERNEL) || defined(_WANT_UCRED)
struct loginclass;
@@ -48,6 +46,13 @@
*/
#define CRED_FLAG_CAPMODE 0x00000001 /* In capability mode. */
+/*
+ * 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.
*
@@ -83,12 +88,15 @@
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 */
#endif /* _KERNEL || _WANT_UCRED */
+#define XU_NGROUPS 16
+
/*
* This is the external representation of struct ucred.
*/

File Metadata

Mime Type
text/plain
Expires
Sat, Oct 5, 9:12 PM (21 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
13677702
Default Alt Text
D46911.diff (1 KB)

Event Timeline