From: Jeff Anton <antonlk@hesiod.org>
To: linux-kernel@vger.kernel.org
Subject: PROBLEM: mmap MAP_SHARED does not update mtime or ctime
Date: Sun, 19 Aug 2001 20:48:09 -0700 [thread overview]
Message-ID: <3B808879.3AC05FCE@hesiod.org> (raw)
PROBLEM: mmap MAP_SHARED does not update mtime or ctime
mmap'ing a file with MAP_SHARED and writeable, modifing the memory
then closeing does not update the file mod time or change time
risking that incremental dumps will not dump the file and is
a possible security problem as one can change a file without
changing the mod-time. C program showing the problem follows.
Program has been run only against ext2 filesystems.
This is a regression from the 2.2 series which correctly updates
mtime and ctime. Problem also appeared on 2.4.8
Jeff Anton
Linux chaos 2.4.9 #1 Sun Aug 19 09:29:48 PDT 2001 i586 unknown
Gnu C 2.95.3
Gnu make 3.77
binutils 2.10.1
usage: fdformat [ -n ] device
mount 2.7f
modutils 2.4.1
e2fsprogs 1.19
PPP 2.3.11
Linux C Library 2.2.2
Dynamic linker (ldd) 2.2.2
Linux C++ Library 27.2.8
Linux C++ Library 27.2.8
Procps 1.2.7
Net-tools 1.51
Kbd command
Sh-utils 1.16
Modules Loaded eepro100 binfmt_misc nls_iso8859-1 nls_cp437
msdos fat
_____________
#include <stddef.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <stdio.h>
const char fname[] = "testfile";
void
statfile(const char *f)
{
struct stat sb;
if (stat(f, &sb) < 0)
perror(f);
else {
printf("atime\t%lu\n", sb.st_atime);
printf("mtime\t%lu\n", sb.st_mtime);
printf("ctime\t%lu\n", sb.st_ctime);
}
}
void
createfile(const char *f)
{
int fd = open(f, O_CREAT|O_RDWR, 0666);
if (fd < 0)
perror("open-create");
else {
if (ftruncate(fd, 0x2000) < 0)
perror("ftruncate");
if (close(fd) < 0)
perror("close");
}
}
\x15\x15void
mmapchange(const char *f)
{
int fd = open(f, O_RDWR);
void *a = mmap(NULL, 0x2000, PROT_READ|PROT_WRITE, MAP_SHARED, fd,
0);
if (a) {
long *l = (long *)a;
/* touch the memory */
++*l;
} else
perror("mmap");
if (munmap(a, 0x2000) < 0)
perror("munmap");
if (close(fd) < 0)
perror("close");
}
int
main()
{
createfile(fname);
statfile(fname);
sleep(10);
mmapchange(fname);
statfile(fname);
if (unlink(fname) < 0)
perror("unlink");
return 0;
}
reply other threads:[~2001-08-20 3:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3B808879.3AC05FCE@hesiod.org \
--to=antonlk@hesiod.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox