--- freem/src/mumps.c 2025/04/15 16:49:36 1.22 +++ freem/src/mumps.c 2025/04/16 05:37:06 1.24 @@ -1,5 +1,5 @@ /* - * $Id: mumps.c,v 1.22 2025/04/15 16:49:36 snw Exp $ + * $Id: mumps.c,v 1.24 2025/04/16 05:37:06 snw Exp $ * main module of freem * * @@ -24,6 +24,12 @@ * along with FreeM. If not, see . * * $Log: mumps.c,v $ + * Revision 1.24 2025/04/16 05:37:06 snw + * Refine FreeBSD ASLR fix + * + * Revision 1.23 2025/04/16 05:33:15 snw + * Try to use procctl function to fix ASLR problem on FreeBSD + * * Revision 1.22 2025/04/15 16:49:36 snw * Make use of logprintf throughout codebase * @@ -116,7 +122,9 @@ #include #include #include "log.h" - +#if defined(__FreeBSD__) +# include +#endif #if defined(HAVE_GETOPT_H) # include #endif @@ -210,6 +218,9 @@ int main (int argc, char **argv, char ** strcpy (stack0, argv[0]); stcnv_c2m (stack0); +#if defined(__FreeBSD__) + int prcdta = PROC_ASLR_FORCE_DISABLE; +#endif /* strncpy (config_file, SYSCONFDIR"/freem.conf", 100); */ @@ -751,6 +762,13 @@ int main (int argc, char **argv, char ** } } +#if defined(__FreeBSD__) + if ((first_process == FALSE) && (procctl (P_PID, getpid (), PROC_ASLR_CTL, &prcdta) == -1)) { + fprintf (stderr, "freem: could not disable address space layout randomization for pid %ld; program operation may be unreliable [error %s]\n", getpid(), strerror (errno)); + } +#endif + + if (first_process == TRUE) { char verstr[500];