lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sun,  9 Aug 2020 22:02:10 -0300
From:   Mauricio Faria de Oliveira <mfo@...onical.com>
To:     Jan Kara <jack@...e.cz>
Cc:     linux-ext4@...r.kernel.org,
        dann frazier <dann.frazier@...onical.com>,
        Mauricio Faria de Oliveira <mauricio.foliveira@...il.com>,
        Jan Kara <jack@...e.com>
Subject: [RFC PATCH v2/TEST CASE]

#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#include <sys/mman.h>

int main() {
	int fd, rc;
	char *addr;
	const int PAGE_SIZE = sysconf(_SC_PAGESIZE);

	rc = unlink("file");
	if (rc < 0 && errno != ENOENT ) {
		perror("unlink");
		return 1;
	}

	fd = open("file", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
	if (fd < 0) {
		perror("open");
		return 1;
	}

	addr = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
	if (addr < 0) {
		perror("mmap");
		return 1;
	}

	rc = pwrite(fd, "a", 1, 0);
	if (rc < 0) {
		perror("pwrite");
		close(fd);
		return 1;
	}

	addr[0] = 'B';
	addr[1] = 'U';
	addr[2] = 'G';

	while (1) {
		printf("Press enter to change buffer contents\n");
		getchar();
		addr[3]++;
		printf("Buffer contents changed\n");
	}

	// This is not reached.
	rc = munmap(addr, PAGE_SIZE);
	if (rc < 0) {
		perror("munmap");
		return 1;
	}

	close(fd);
	return 0;
}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ