From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753483AbbKHCCY (ORCPT ); Sat, 7 Nov 2015 21:02:24 -0500 Received: from imap.thunk.org ([74.207.234.97]:48009 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751802AbbKHCCU (ORCPT ); Sat, 7 Nov 2015 21:02:20 -0500 Date: Sat, 7 Nov 2015 21:02:06 -0500 From: "Theodore Ts'o" To: Kees Cook Cc: Andy Lutomirski , Theodore Tso , Willy Tarreau , Dirk Steinmetz , Michael Kerrisk-manpages , Serge Hallyn , Seth Forshee , Alexander Viro , Linux FS Devel , LKML , "Eric W . Biederman" , Serge Hallyn , "security@kernel.org" Subject: Re: [RFC] namei: prevent sgid-hardlinks for unmapped gids Message-ID: <20151108020206.GA3880@thunk.org> Mail-Followup-To: Theodore Ts'o , Kees Cook , Andy Lutomirski , Theodore Tso , Willy Tarreau , Dirk Steinmetz , Michael Kerrisk-manpages , Serge Hallyn , Seth Forshee , Alexander Viro , Linux FS Devel , LKML , "Eric W . Biederman" , Serge Hallyn , "security@kernel.org" References: <20151104002132.010ccd1d@rsjtdrjgfuzkfg.com> <20151104065820.GF21740@1wt.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@thunk.org X-SA-Exim-Scanned: No (on imap.thunk.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 06, 2015 at 09:05:57PM -0800, Kees Cook wrote: > >>>> They're certainly not used early enough -- we need to remove suid when > >>>> the page becomes writable via mmap (wp_page_shared), not when > >>>> writeback happens, or at least not only when writeback happens. > >>> > >>> Well, I'm shy about the change there. For example, we don't strip in > >>> on open(RDWR), just on write(). > >> > >> I take it back. Hooking wp_page_shared looks expensive. :) Maybe we do > >> need to hook the mmap? > > > > But file_update_time already pokes at the same (or nearby) cachelines, > > I think -- why would it be expensive? The whole thing could be > > guarded by if (unlikely(is setuid)), right? > > Yeah, true. I added file_remove_privs calls near all the > file_update_time calls, to no effect. Added to wp_page_shared too, > nothing. Hmmm. Why not put the the should_remove_suid() call in filemap_page_mkwrite(), or maybe do_page_mkwrite()? Cheers, - Ted