diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2025-01-11 12:25:15 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2025-01-11 12:25:43 +0100 |
commit | bf24996d891966454b3395ab965b87c033b21d7d (patch) | |
tree | 76fd5567a23fb0b3b3db6f1841a926fed4a6b867 | |
parent | d580a97c6c8a1e1419cc7c21f6dd9d1d12b79f92 (diff) | |
download | hurd-bf24996d891966454b3395ab965b87c033b21d7d.tar.gz hurd-bf24996d891966454b3395ab965b87c033b21d7d.tar.bz2 hurd-bf24996d891966454b3395ab965b87c033b21d7d.zip |
libdiskfs: catch mmap failure
Just backtrace for now
-rw-r--r-- | ext2fs/dir.c | 5 | ||||
-rw-r--r-- | ext2fs/hyper.c | 2 | ||||
-rw-r--r-- | libdiskfs/boot-start.c | 15 | ||||
-rw-r--r-- | libdiskfs/file-get-trans.c | 25 | ||||
-rw-r--r-- | libdiskfs/file-getfh.c | 7 | ||||
-rw-r--r-- | libdiskfs/io-read.c | 1 |
6 files changed, 42 insertions, 13 deletions
diff --git a/ext2fs/dir.c b/ext2fs/dir.c index faed301e..256f3d36 100644 --- a/ext2fs/dir.c +++ b/ext2fs/dir.c @@ -965,7 +965,10 @@ diskfs_get_directs (struct node *dp, allocsize = round_page (bufsiz); if (allocsize > *datacnt) - *data = mmap (0, allocsize, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + { + *data = mmap (0, allocsize, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + assert_backtrace (*data != MAP_FAILED); + } /* Set bufp appropriately */ bufp = buf; diff --git a/ext2fs/hyper.c b/ext2fs/hyper.c index 82b06d17..d2440dc0 100644 --- a/ext2fs/hyper.c +++ b/ext2fs/hyper.c @@ -46,7 +46,7 @@ allocate_mod_map (void) mod_map_size = le32toh (sblock->s_blocks_count) >> 3; modified_global_blocks = mmap (0, mod_map_size, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); - assert_backtrace (modified_global_blocks != (void *) -1); + assert_backtrace (modified_global_blocks != MAP_FAILED); } else modified_global_blocks = 0; diff --git a/libdiskfs/boot-start.c b/libdiskfs/boot-start.c index 19967ef3..be47e1b8 100644 --- a/libdiskfs/boot-start.c +++ b/libdiskfs/boot-start.c @@ -374,14 +374,20 @@ diskfs_S_exec_startup_get_info (struct bootinfo *upt, *flags = EXEC_STACK_ARGS; if (*portarraylen < INIT_PORT_MAX) - *portarrayP = mmap (0, INIT_PORT_MAX * sizeof (mach_port_t), - PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + { + *portarrayP = mmap (0, INIT_PORT_MAX * sizeof (mach_port_t), + PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + assert_backtrace (*portarrayP != MAP_FAILED); + } portarray = *portarrayP; *portarraylen = INIT_PORT_MAX; if (*dtablelen < 3) - *dtableP = mmap (0, 3 * sizeof (mach_port_t), PROT_READ|PROT_WRITE, - MAP_ANON, 0, 0); + { + *dtableP = mmap (0, 3 * sizeof (mach_port_t), PROT_READ|PROT_WRITE, + MAP_ANON, 0, 0); + assert_backtrace (*dtableP != MAP_FAILED); + } dtable = *dtableP; *dtablelen = 3; dtable[0] = dtable[1] = dtable[2] = get_console (); /* XXX */ @@ -627,6 +633,7 @@ diskfs_S_fsys_init (struct diskfs_control *pt, unsigned int i; portarray = mmap (0, INIT_PORT_MAX * sizeof *portarray, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + assert_backtrace (portarray != MAP_FAILED); if (MACH_PORT_NULL != (mach_port_t) 0) for (i = 0; i < INIT_PORT_MAX; ++i) portarray[i] = MACH_PORT_NULL; diff --git a/libdiskfs/file-get-trans.c b/libdiskfs/file-get-trans.c index 7b204b76..4d8059fb 100644 --- a/libdiskfs/file-get-trans.c +++ b/libdiskfs/file-get-trans.c @@ -45,7 +45,10 @@ diskfs_S_file_get_translator (struct protid *cred, if (!err) { if (len > *translen) - *trans = mmap (0, len, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + { + *trans = mmap (0, len, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + assert_backtrace (*trans != MAP_FAILED); + } memcpy (*trans, string, len); *translen = len; free (string); @@ -58,7 +61,10 @@ diskfs_S_file_get_translator (struct protid *cred, mach_msg_type_number_t amt; assert_backtrace (diskfs_shortcut_symlink); if (len > *translen) - *trans = mmap (0, len, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + { + *trans = mmap (0, len, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + assert_backtrace (*trans != MAP_FAILED); + } memcpy (*trans, _HURD_SYMLINK, sizeof _HURD_SYMLINK); if (diskfs_read_symlink_hook) @@ -98,7 +104,10 @@ diskfs_S_file_get_translator (struct protid *cred, buflen++; /* terminating nul */ if (buflen > *translen) - *trans = mmap (0, buflen, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + { + *trans = mmap (0, buflen, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + assert_backtrace (*trans != MAP_FAILED); + } memcpy (*trans, buf, buflen); free (buf); *translen = buflen; @@ -110,7 +119,10 @@ diskfs_S_file_get_translator (struct protid *cred, len = sizeof _HURD_FIFO; if (len > *translen) - *trans = mmap (0, len, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + { + *trans = mmap (0, len, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + assert_backtrace (*trans != MAP_FAILED); + } memcpy (*trans, _HURD_FIFO, sizeof _HURD_FIFO); *translen = len; err = 0; @@ -121,7 +133,10 @@ diskfs_S_file_get_translator (struct protid *cred, len = sizeof _HURD_IFSOCK; if (len > *translen) - *trans = mmap (0, len, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + { + *trans = mmap (0, len, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + assert_backtrace (*trans != MAP_FAILED); + } memcpy (*trans, _HURD_IFSOCK, sizeof _HURD_IFSOCK); *translen = len; err = 0; diff --git a/libdiskfs/file-getfh.c b/libdiskfs/file-getfh.c index 140373c4..2ff066b5 100644 --- a/libdiskfs/file-getfh.c +++ b/libdiskfs/file-getfh.c @@ -45,8 +45,11 @@ diskfs_S_file_getfh (struct protid *cred, data_t *fh, pthread_mutex_lock (&node->lock); if (*fh_len < sizeof (union diskfs_fhandle)) - *fh = mmap (0, sizeof (union diskfs_fhandle), PROT_READ|PROT_WRITE, - MAP_ANON, 0, 0); + { + *fh = mmap (0, sizeof (union diskfs_fhandle), PROT_READ|PROT_WRITE, + MAP_ANON, 0, 0); + assert_backtrace (*fh != MAP_FAILED); + } *fh_len = sizeof *f; f = (union diskfs_fhandle *) *fh; diff --git a/libdiskfs/io-read.c b/libdiskfs/io-read.c index a706d677..9ce06dde 100644 --- a/libdiskfs/io-read.c +++ b/libdiskfs/io-read.c @@ -61,6 +61,7 @@ diskfs_S_io_read (struct protid *cred, { ourbuf = 1; buf = mmap (0, maxread, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + assert_backtrace (buf != MAP_FAILED); *data = buf; } else |