tty: fix up atime/mtime mess, take three
We first tried to avoid updating atime/mtime entirely (commitb0de59b573: "TTY: do not update atime/mtime on read/write"), and then limited it to only update it occasionally (commit37b7f3c765: "TTY: fix atime/mtime regression"), but it turns out that this was both insufficient and overkill. It was insufficient because we let people attach to the shared ptmx node to see activity without even reading atime/mtime, and it was overkill because the "only once a minute" means that you can't really tell an idle person from an active one with 'w'. So this tries to fix the problem properly. It marks the shared ptmx node as un-notifiable, and it lowers the "only once a minute" to a few seconds instead - still long enough that you can't time individual keystrokes, but short enough that you can tell whether somebody is active or not. Reported-by: Simon Kirby <sim@hostway.ca> Acked-by: Jiri Slaby <jslaby@suse.cz> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: stable@vger.kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
		
					parent
					
						
							
								08d7676083
							
						
					
				
			
			
				commit
				
					
						b0b885657b
					
				
			
		
					 2 changed files with 5 additions and 2 deletions
				
			
		|  | @ -681,6 +681,9 @@ static int ptmx_open(struct inode *inode, struct file *filp) | ||||||
| 
 | 
 | ||||||
| 	nonseekable_open(inode, filp); | 	nonseekable_open(inode, filp); | ||||||
| 
 | 
 | ||||||
|  | 	/* We refuse fsnotify events on ptmx, since it's a shared resource */ | ||||||
|  | 	filp->f_mode |= FMODE_NONOTIFY; | ||||||
|  | 
 | ||||||
| 	retval = tty_alloc_file(filp); | 	retval = tty_alloc_file(filp); | ||||||
| 	if (retval) | 	if (retval) | ||||||
| 		return retval; | 		return retval; | ||||||
|  |  | ||||||
|  | @ -988,10 +988,10 @@ void start_tty(struct tty_struct *tty) | ||||||
| 
 | 
 | ||||||
| EXPORT_SYMBOL(start_tty); | EXPORT_SYMBOL(start_tty); | ||||||
| 
 | 
 | ||||||
|  | /* We limit tty time update visibility to every 8 seconds or so. */ | ||||||
| static void tty_update_time(struct timespec *time) | static void tty_update_time(struct timespec *time) | ||||||
| { | { | ||||||
| 	unsigned long sec = get_seconds(); | 	unsigned long sec = get_seconds() & ~7; | ||||||
| 	sec -= sec % 60; |  | ||||||
| 	if ((long)(sec - time->tv_sec) > 0) | 	if ((long)(sec - time->tv_sec) > 0) | ||||||
| 		time->tv_sec = sec; | 		time->tv_sec = sec; | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Linus Torvalds
				Linus Torvalds