On Tue, 2006-01-17 at 11:18 +0300, Jan Koss wrote: > Hello. > > I have question about "truncate" function implementation. > > Let's suppose that we have file with 8K size. > > One process (let's call it 'A') open file 'X' for read and write, > and mmap'ed it to memory with "MAP_SHARED" flag. After > that it read content of file, so all data of file go to "page cache". > And after that 'A' wait something. > At this moment another process (let's call it 'B') > call "truncate" function, and truncate 'X' file to 4K length. .. and removes the page from the pagetable. > After that process 'C' create file 'Y' and because of > second block of file 'X' now is free, kernel give it to file 'Y'. > And at last, process 'A' write to second page of file 'X' .. which isn't in the pagetable, and then the kernel notices it's outside the file and causes a SIGBUS. -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/