Index: sys/kern/imgact_elf.c =================================================================== --- sys/kern/imgact_elf.c +++ sys/kern/imgact_elf.c @@ -901,12 +901,25 @@ * not actually fault in all the segments pages. */ PROC_LOCK(imgp->proc); - if (data_size > lim_cur(imgp->proc, RLIMIT_DATA) || - text_size > maxtsiz || - total_size > lim_cur(imgp->proc, RLIMIT_VMEM) || - racct_set(imgp->proc, RACCT_DATA, data_size) != 0 || - racct_set(imgp->proc, RACCT_VMEM, total_size) != 0) { + if (data_size > lim_cur(imgp->proc, RLIMIT_DATA)) { PROC_UNLOCK(imgp->proc); + uprintf("Data segment size exceeds process limit\n"); + return (ENOMEM); + } else if (text_size > maxtsiz) { + PROC_UNLOCK(imgp->proc); + uprintf("Text segment size exceeds system limit\n"); + return (ENOMEM); + } else if (total_size > lim_cur(imgp->proc, RLIMIT_VMEM)) { + PROC_UNLOCK(imgp->proc); + uprintf("Total segment size exceeds process limit\n"); + return (ENOMEM); + } else if (racct_set(imgp->proc, RACCT_DATA, data_size) != 0) { + PROC_UNLOCK(imgp->proc); + uprintf("Data segment size exceeds resource limit\n"); + return (ENOMEM); + } else if (racct_set(imgp->proc, RACCT_VMEM, total_size) != 0) { + PROC_UNLOCK(imgp->proc); + uprintf("Total segment size exceeds resource limit\n"); return (ENOMEM); }