From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ig0-f173.google.com (mail-ig0-f173.google.com [209.85.213.173]) by kanga.kvack.org (Postfix) with ESMTP id 2C8376B0038 for ; Thu, 10 Dec 2015 14:47:19 -0500 (EST) Received: by igcto18 with SMTP id to18so23177665igc.0 for ; Thu, 10 Dec 2015 11:47:19 -0800 (PST) Received: from mail-io0-x22b.google.com (mail-io0-x22b.google.com. [2607:f8b0:4001:c06::22b]) by mx.google.com with ESMTPS id bf10si343876igb.49.2015.12.10.11.47.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Dec 2015 11:47:18 -0800 (PST) Received: by ioc74 with SMTP id 74so103765065ioc.2 for ; Thu, 10 Dec 2015 11:47:18 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <20151210193351.GE20997@ZenIV.linux.org.uk> References: <20151209225148.GA14794@www.outflux.net> <20151210070635.GC31922@1wt.eu> <20151210181611.GB32083@1wt.eu> <20151210193351.GE20997@ZenIV.linux.org.uk> Date: Thu, 10 Dec 2015 11:47:18 -0800 Message-ID: Subject: Re: [PATCH v5] fs: clear file privilege bits when mmap writing From: Kees Cook Content-Type: text/plain; charset=UTF-8 Sender: owner-linux-mm@kvack.org List-ID: To: Al Viro Cc: Willy Tarreau , Andrew Morton , Jan Kara , yalin wang , "Eric W. Biederman" , "linux-fsdevel@vger.kernel.org" , Linux-MM , LKML On Thu, Dec 10, 2015 at 11:33 AM, Al Viro wrote: > On Thu, Dec 10, 2015 at 07:16:11PM +0100, Willy Tarreau wrote: > >> > Is f_flags safe to write like this without holding a lock? >> >> Unfortunately I have no idea. I've seen places where it's written without >> taking a lock such as in blkdev_open() and I don't think that this one is >> called with a lock held. > > In any ->open() we obviously have nobody else able to find that struct file, > let alone modify it, so there the damn thing is essentially caller-private > and no locking is needed. In open, sure, but what about under mm/memory.c where we're trying to twiddle it from vma->file->f_flags as in my patch? That seemed like it would want atomic safety. -Kees -- Kees Cook Chrome OS & Brillo Security -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org