struct statvfs is too large for stack. Use malloc(9) instead.

XXX
Switch to kmem(9) for entire this file.

Frame size, e.g. for m68k, becomes:
    3292 --> 12
This commit is contained in:
rin 2020-05-31 08:38:54 +00:00
parent 851ed85132
commit 46b290a0c3
1 changed files with 7 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: procfs_linux.c,v 1.83 2020/05/23 23:42:43 ad Exp $ */ /* $NetBSD: procfs_linux.c,v 1.84 2020/05/31 08:38:54 rin Exp $ */
/* /*
* Copyright (c) 2001 Wasabi Systems, Inc. * Copyright (c) 2001 Wasabi Systems, Inc.
@ -36,7 +36,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.83 2020/05/23 23:42:43 ad Exp $"); __KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.84 2020/05/31 08:38:54 rin Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -611,18 +611,19 @@ procfs_domounts(struct lwp *curl, struct proc *p,
struct mount *mp; struct mount *mp;
int error = 0, root = 0; int error = 0, root = 0;
struct cwdinfo *cwdi = curl->l_proc->p_cwdi; struct cwdinfo *cwdi = curl->l_proc->p_cwdi;
struct statvfs *sfs;
bf = malloc(LBFSZ, M_TEMP, M_WAITOK); bf = malloc(LBFSZ, M_TEMP, M_WAITOK);
sfs = malloc(sizeof(*sfs), M_TEMP, M_WAITOK);
mountlist_iterator_init(&iter); mountlist_iterator_init(&iter);
while ((mp = mountlist_iterator_next(iter)) != NULL) { while ((mp = mountlist_iterator_next(iter)) != NULL) {
struct statvfs sfs; if ((error = dostatvfs(mp, sfs, curl, MNT_WAIT, 0)) == 0)
if ((error = dostatvfs(mp, &sfs, curl, MNT_WAIT, 0)) == 0)
root |= procfs_format_sfs(&mtab, &mtabsz, bf, LBFSZ, root |= procfs_format_sfs(&mtab, &mtabsz, bf, LBFSZ,
&sfs, curl, 0); sfs, curl, 0);
} }
mountlist_iterator_destroy(iter); mountlist_iterator_destroy(iter);
free(sfs, M_TEMP);
/* /*
* If we are inside a chroot that is not itself a mount point, * If we are inside a chroot that is not itself a mount point,