Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp417663imu; Fri, 7 Dec 2018 03:17:23 -0800 (PST) X-Google-Smtp-Source: AFSGD/WEiW6yZg2JoeZXgNpsaFfQq0/zJLKrBDL1VrAJBZ5nplkc32YxcHfQquh6CcRgv8d0hEMk X-Received: by 2002:a17:902:b903:: with SMTP id bf3mr1690720plb.289.1544181443681; Fri, 07 Dec 2018 03:17:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544181443; cv=none; d=google.com; s=arc-20160816; b=GMg8WO6MisVONDnb+iYc1huCmQMYMYJHAkFKGKNX8he8Fe1k9C42pAfn+xY0m4QOG3 9qQ6e3A5ApTFpYHNfS6hlUsp0E/kHdQttYxMJhh2S6dErJGn72tfUbHQe4oAQ4I0WBBZ QzF4cL3pX3sPfIt4Kud0knpCsMQoO3kk6LmclX33E6GO8y+9KDTCzy1+UVuFtHweF9c+ 1w3EaR3xsi2yySUU8GO7p3vmxgrWxSHoOQs3ifYTQSDP4uWXDMXaRZJgqyH00DT6QSmx Y9PTiycf7aANHruT7Iv999xF3q4+zxPVyoN3RQt7P6LGEXFMNp2/JuF3X5YEZqq3ILvS bchQ== 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=AUzeGPiOCDmWnYuKbwWVguU0Ar63vc0Go53k4k2KLiQ=; b=L3YI8ug5DePlaMTCc5MtKJllnv14Tcv9axDDKDws8zfVMfY/y1nLndXvdb4n65VSpP +Mej5H2y+snM3miyzIrVbEzyoqD9RHOv5rKLVJbd0fE5OuwVkUF/ec2isFOZWI46kvLO 7CtvHHFPcC3ELZ6CklWwd8FZL8JbMY2m8B7bCU6vkM0EGooZLFRCA5aC3QbyOCwiWRa5 4wGVJOaNTHo0RCGHCZEPRzbz5QEKxT3PZ47pTRSE23G7PlTJCfYadmAZhUsDLuWaUere iv90sgGgLSS6UNOo/dAKBhY2bUHePOMiJZBFeThX+UbUKI4DUUy4bws19efXMh2yLqV2 s69g== 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 w14si2643638plq.145.2018.12.07.03.17.07; Fri, 07 Dec 2018 03:17:23 -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 S1726125AbeLGLO3 (ORCPT + 99 others); Fri, 7 Dec 2018 06:14:29 -0500 Received: from mx2.suse.de ([195.135.220.15]:41566 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725987AbeLGLO3 (ORCPT ); Fri, 7 Dec 2018 06:14:29 -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 5D733ABE7; Fri, 7 Dec 2018 11:14:27 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 8D95E1E0D9D; Fri, 7 Dec 2018 12:14:26 +0100 (CET) Date: Fri, 7 Dec 2018 12:14:26 +0100 From: Jan Kara To: Alexander Lochmann Cc: Jan Kara , viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Horst Schirmeier , linux-block@vger.kernel.org, Jens Axboe Subject: Re: [PATCH] Fix sync. in inode_has_no_xattr() Message-ID: <20181207111426.GG13008@quack2.suse.cz> References: <13eaa1c6-def5-afad-89eb-6f149db90684@tu-dortmund.de> <20181205153254.GD30615@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 Fri 07-12-18 11:24:47, Alexander Lochmann wrote: > Am 05.12.18 um 16:32 schrieb Jan Kara: > > > > Thinking more about this I'm not sure if this is actually the right > > solution. Because for example the write(2) can set S_NOSEC flag wrongly > > when it would race with chmod adding SUID bit. So probably we rather need > > to acquire i_rwsem in blkdev_write_iter() if file does not have S_NOSEC set > > (we don't want to acquire it unconditionally as that would heavily impact > > scalability of block device writes). > > > > Honza > > > Trying to implement your suggestion, I'm not sure which inode to use: > In blkdev_write_iter() there is the "bd_inode = bdev_file_inode(file)". > file_remove_privs() uses "inode = file_inode(file)" as a parameter for > inode_has_no_xattr(). > So, do file->f_mapping->host and f->f_inode refer to the identical inode? Ah, that's a good question and I forgot to warn you. Sorry for that and my respect for noticing this yourself :). For block devices f->f_inode refers to the device inode in the filesystem (i.e., where xattrs are attached to, permissions are stored, etc.). file->f_mapping->host refers to the inode carrying data - this split is needed so that if there are more instances of device inode in the system for the same block device, they see data coherently. So you need to use file_inode(file) for the locking. Thanks! Honza -- Jan Kara SUSE Labs, CR