NVIDIA / NVIDIA/fission

An mmap() of a file in examples/* will crash on first mapped access

Open
#18 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
12
Forks
7
PR merge metrics
No merged PRs in 30d

Description

The following code, when executed with fission-hellofs against mount_point/hello (the only file in the read-only filesystem of fission-hellofs) will crash when doing the read (via the printf("%s\n", region) line):

#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <unistd.h>

const char *line = "Hello World\n";

char *str_concat(char *s1, char *s2) {
  char *to_return = malloc(strlen(s1) + strlen(s2));
  if (NULL != to_return) {
    (void)sprintf(to_return, "%s%s", s1, s2);
  }
  return to_return;
}

int main(int argc, char **argv) {
  int fd = open(argv[1], O_RDONLY, 0);
  if (fd < 0) {
    perror(str_concat("Cound not open ", argv[1]));
    return 1;
  }

  char *region = mmap(NULL, strlen(line), PROT_READ, MAP_SHARED, fd, 0);
  if (region == MAP_FAILED) {
    perror(str_concat("Could not mmap ", argv[1]));
    return 1;
  }

  if (close(fd) != 0) {
    perror(str_concat("Could not close ", argv[1]));
    return 1;
  }

  printf("About to call printf() on contents of %s\n", argv[1]);
  printf("%s\n", region);
  printf("Back from successful call to printf() on contents of %s\n", argv[1]);

  if (munmap(region, strlen(line)) != 0) {
    perror(str_concat("Could not unmap ", argv[1]));
    return 1;
  };

  return 0;
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproducer in examples/*, running it against fission-hellofs and mount_point/hello. Trace the mmap implementation and the first mapped access, then verify that printf("%s\n", region) no longer crashes and that the reproducer completes through munmap.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, go
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.