Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gossmap: fix OpenBSD crash. #7112

Merged
merged 2 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .github/workflows/ci_build.yml

This file was deleted.

7 changes: 7 additions & 0 deletions common/gossmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,9 +690,13 @@ static bool load_gossip_store(struct gossmap *map)
{
map->map_size = lseek(map->fd, 0, SEEK_END);
map->local = NULL;

/* gossipd uses pwritev(), which is not consistent with mmap on OpenBSD! */
#ifndef __OpenBSD__
/* If this fails, we fall back to read */
map->mmap = mmap(NULL, map->map_size, PROT_READ, MAP_SHARED, map->fd, 0);
if (map->mmap == MAP_FAILED)
#endif /* __OpenBSD__ */
map->mmap = NULL;

/* We only support major version 0 */
Expand Down Expand Up @@ -994,8 +998,11 @@ bool gossmap_refresh_mayfail(struct gossmap *map, bool *updated)
if (map->mmap)
munmap(map->mmap, map->map_size);
map->map_size = len;
/* gossipd uses pwritev(), which is not consistent with mmap on OpenBSD! */
#ifndef __OpenBSD__
map->mmap = mmap(NULL, map->map_size, PROT_READ, MAP_SHARED, map->fd, 0);
if (map->mmap == MAP_FAILED)
#endif /* __OpenBSD__ */
map->mmap = NULL;

return map_catchup(map, updated);
Expand Down
Loading