Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp4002129imj; Tue, 12 Feb 2019 08:12:00 -0800 (PST) X-Google-Smtp-Source: AHgI3Iap4kz1nwQgAcY7Yf+gE8J2Co76AxISwCxbg3dwB0lelr7Gyz2e2H8hTCJrZMnpROJxeN0X X-Received: by 2002:a63:2bcd:: with SMTP id r196mr2790401pgr.355.1549987920116; Tue, 12 Feb 2019 08:12:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549987920; cv=none; d=google.com; s=arc-20160816; b=z2O/ZecMMKuuwS7FuRvLqYelD0uCO0hFILHx/OgP5/0tA0tA0wNnnE7uTt/YqEA/wc icWlDqwt4d9X4jGNnHsXSGaz8HXvRQWFuwYPuyyEVVSWcJyG28stbUOVewtdk/xUc77t uvLvemzJQakCENqDqqcY92oY39jcnY7MFjFSt0jRnha8RThnMUjPGfFsncwJB+cdUc+z lqyo7hpg7T6qEUoN3Cn6f2w5TrnlRQ+oJBq/FPJyxjf+klbHCHM0JCAJmI7sxt8nDLkZ DJpW/3VsJ7AmTwLTrXdhxK8BFlRWX4ilVbGg5M1VkqL59X/5u/B6HqIzwXRgsr2qPNkc VokQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=F5WcybsCTNQTJfv+OYCv9JR/BARUFJhxttVpK3OFJ78=; b=yjY+Cp5HHv+31hhth1UqmKeNoDhOLhlZ2cEj6iHfdl5jYLmayzIawD0IU6bKftjkfj Cqrad5+4aPFEj6SiPbQGhYU1lmbdnw/xYwnMrgTnYzh6SjDguC+lMKdjctOqSQ/ibTpd 5/8JUB9b0q1vtYmKBx4y+maQ8lpU4153aEQmlWGQ5yqvbb3Ei34s+sX0EDUkNXm7ZEmn wQBIKt7NzQw6kAnGfB7S3dBtKR8mFe5jdfQyXi0fND5mXP/OuzAbwtf7y4zXCB6FJVzs gdDipz27dP07jBxYD9vOraE2hzNPlseuk7vYsnwzUL8KiVZotKDXmppqZ1fp2IuVjRKX dxxg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j11si980697plb.253.2019.02.12.08.11.43; Tue, 12 Feb 2019 08:12:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730882AbfBLQLL (ORCPT + 99 others); Tue, 12 Feb 2019 11:11:11 -0500 Received: from mx2.suse.de ([195.135.220.15]:60162 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730461AbfBLQLK (ORCPT ); Tue, 12 Feb 2019 11:11:10 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 4E297B02F; Tue, 12 Feb 2019 16:11:08 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id C4E0D1E09C5; Tue, 12 Feb 2019 17:11:07 +0100 (CET) Date: Tue, 12 Feb 2019 17:11:07 +0100 From: Jan Kara To: Amir Goldstein Cc: Jan Kara , Miklos Szeredi , linux-fsdevel , linux-kernel , syzkaller-bugs@googlegroups.com, Al Viro , syzbot , overlayfs Subject: Re: possible deadlock in pipe_lock (2) Message-ID: <20190212161107.GB19076@quack2.suse.cz> References: <000000000000701c3305818e4814@google.com> <20190212111402.GU19029@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 12-02-19 15:39:38, Amir Goldstein wrote: > > > My other thought is that perhaps sb_start_write() should invoke > > > s_ops->start_write() so that overlay can do the freeze protection on > > > the upper early. > > > > So my understanding of overlayfs is pretty basic so I'm sorry if I miss > > something. If I'm right, we have three superblocks here: ovl, upper, lower. > > Now 'lower' is read-only so for freezing purposes we can just forget about > > it. 'upper' is where the real changes are going into and 'ovl' is a wrapper > > virtual superblock that handles merging of 'lower' and 'upper'. Correct so > > far? > > Yes. > > > > > And the problem seems to be that when you acquire freeze protection for the > > 'ovl' superblock, you in fact want to acquire freeze protection for the > > 'upper' (as 'ovl' is just virtual and has no disk state to protect). So I > > There are use case for freezing ovl (i.e. ovl snapshots) but it is not > implemented > at the moment. > > Overlayfs already gets upper freeze protection internally before any > modification > to upper. > The problem that locking order of upper freeze is currently under overlay > inode mutex. And that brings a problem with the above pipe case. > > > agree that a callback to allow overlayfs to acquire freeze protection on > > 'upper' right away would be one solution. Or we could make s_writers a > > pointer and redirect ovl->s_writers to upper->s_writers. Then VFS should do > > the right thing from the start unless overlayfs calls back into operations > > on 'upper' that will try to acquire the freeze protection again. Thoughts? > > Overlayfs definitely calls into operations on upper and upper certainly > acquires several levels of s_writers itself. > > The problem with the proposal to change locking order to > ovl freeze -> upper freeze -> ovl inode -> upper inode > is that for some non-write operations (e.g. lookup, readdir) > overlay may end up updating xattrs on upper, so will need > to take upper freeze after ovl inode lock without ovl freeze > being called by vfs. > > I suggested that we may use upper freeze trylock in those > cases and skip xattr update if trylock fails. Yes, that's what VFS does as well e.g. for atime updates. In fact I don't see other sensible possibility since blocking read operation on frozen filesystem is surprising to the user. > Not sure if my assumption is correct that this would be ok > w.r.t locking rules? It should be fine AFAICT. > Not sure if we can get away with trylock in all the cases that > we need to modify upper. I don't know overlayfs enough to be able to tell :). Honza -- Jan Kara SUSE Labs, CR