All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs: clear file set[ug]id when writing via mmap
@ 2015-11-20  0:10 ` Kees Cook
  0 siblings, 0 replies; 21+ messages in thread
From: Kees Cook @ 2015-11-20  0:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andrew Morton, Dave Chinner, Andy Lutomirski, Jan Kara,
	Kirill A. Shutemov, Mel Gorman, Johannes Weiner, Rik van Riel,
	Matthew Wilcox, Shachar Raindel, Boaz Harrosh, Michal Hocko,
	Haggai Eran, Theodore Tso, Willy Tarreau, Dirk Steinmetz,
	Michael Kerrisk-manpages, Serge Hallyn, Seth Forshee,
	Alexander Viro, Linux FS Devel, LKML, Eric W . Biederman,
	Serge Hallyn, linux-mm

Normally, when a user can modify a file that has setuid or setgid bits,
those bits are cleared when they are not the file owner or a member of the
group. This is enforced when using write() directly but not when writing
to a shared mmap on the file. This could allow the file writer to gain
privileges by changing the binary without losing the setuid/setgid bits.

Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: stable@vger.kernel.org
---
 mm/memory.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/memory.c b/mm/memory.c
index deb679c31f2a..4c970a4e0057 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2036,6 +2036,7 @@ static inline int wp_page_reuse(struct mm_struct *mm,
 
 		if (!page_mkwrite)
 			file_update_time(vma->vm_file);
+		file_remove_privs(vma->vm_file);
 	}
 
 	return VM_FAULT_WRITE;
-- 
1.9.1


-- 
Kees Cook
Chrome OS Security

^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2015-12-02 23:55 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-20  0:10 [PATCH] fs: clear file set[ug]id when writing via mmap Kees Cook
2015-11-20  0:10 ` Kees Cook
2015-11-20  0:41 ` Andrew Morton
2015-11-20  0:41   ` Andrew Morton
2015-11-20  0:52   ` Kees Cook
2015-11-20  0:52     ` Kees Cook
2015-11-20  1:00 ` Willy Tarreau
2015-11-20  1:00   ` Willy Tarreau
2015-11-20  1:03   ` Willy Tarreau
2015-11-20  1:03     ` Willy Tarreau
2015-11-20  1:03   ` Kees Cook
2015-11-20  1:03     ` Kees Cook
2015-11-20  1:06     ` Willy Tarreau
2015-11-20  1:06       ` Willy Tarreau
2015-11-23 12:26 ` Jan Kara
2015-11-23 12:26   ` Jan Kara
2015-11-23 12:34   ` Eric W. Biederman
2015-11-23 12:34     ` Eric W. Biederman
2015-11-23 12:34     ` Eric W. Biederman
2015-12-02 23:55   ` Kees Cook
2015-12-02 23:55     ` Kees Cook

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.