Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1952072imm; Thu, 24 May 2018 03:30:36 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrFNZBo4krNgT+dk9FqRS4oKPamVsxXefpM12cTRVQYnaMdveR3eEiOTVqbsJVs4ECP4IpA X-Received: by 2002:a62:e211:: with SMTP id a17-v6mr6539829pfi.126.1527157836900; Thu, 24 May 2018 03:30:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527157836; cv=none; d=google.com; s=arc-20160816; b=cwzFAAXPvTIWXrhGynQy2aJysH/thh75Zh8cFpnpnkA759AEZsfDEeiQXfGrjjIKKF xWMcdgy2Z1SYmc4X9cah74ToaZYqWn98GX/mqVw3yRSa4xCWx7AdQrMnIanSV7qXRC9w udMWI3ABc6GPJ4cx+OK0Q2FZfxicLsACW3UqAHFHUmIYVrInwbqFEHqAmNeVz/g9s0ja HSYpSxRlcCw/XLULiYqaMpJD0prLrtUVK4RaJPbsPMj1Id3EQZMoL33rjDzUwXaNYDoe MDcNAP1PZF4XErK90m5+rtlVd4uM4VMOfuFqmYv+SnutZQRzfM4c40JiNkc+ZPkcEPkI hqYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=u80s+RbabLXBU6Ju0k81ByUEXJ56k653XlzSto9osKs=; b=J098zry3m8O9ZWB+9YOMBxLhp/tvPPeXz262gsyYWVQVSIYKkqrYPvS1I/Vc2+N74u 6t0mKmxFM0CBoL10oUjUI/FA8fwh+DdMfG12TnfpdZjgBMC7jKUP/TLLCW8kU22w2UxN wh0Z9KiVXhsNuNI0K0fl2ybvnuQJg2CIVkheZr8CcHoGp9ZlJAGldltMGKwO3GmrwmJJ uMVxfSn6+99GpOP7AsWPSY6v39h8/WQWUwchapq0GVjQzDDUDk7QWrdejM2O6jvyt1jL TiByu2S53IRJdChcPt1mkb+tOWjPtFn6FPW6nHYRzvOyCzcXOuHs8oybslq07pwmbJ4M d47A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lB4qlxA1; 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 e1-v6si21488849pln.445.2018.05.24.03.30.22; Thu, 24 May 2018 03:30:36 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=lB4qlxA1; 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 S1032139AbeEXK3k (ORCPT + 99 others); Thu, 24 May 2018 06:29:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:40904 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030972AbeEXK3f (ORCPT ); Thu, 24 May 2018 06:29:35 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B724220020; Thu, 24 May 2018 10:29:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527157775; bh=RDCUVyjFbCOW0svwKrbSE0SMdL/9rGtUhhhzgxGWeuw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lB4qlxA18LlwxejCb4PqkJMAy6C4cyrv0hgwHD7X5nMaQVPKLMBgX/1eRpx+/R2p/ pRbHmB9EEoj7hFCnJ9r120oFDBsJOrS/yweyVClXce+YIaWz9lYorMBou6zsINt1My dmCTzfHYdcDzhFAnKvpKTpK3Xb1J5nrn7nooHAgw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Viro Subject: [PATCH 4.16 034/161] ext2: fix a block leak Date: Thu, 24 May 2018 11:37:39 +0200 Message-Id: <20180524093022.449554719@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093018.331893860@linuxfoundation.org> References: <20180524093018.331893860@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Al Viro commit 5aa1437d2d9a068c0334bd7c9dafa8ec4f97f13b upstream. open file, unlink it, then use ioctl(2) to make it immutable or append only. Now close it and watch the blocks *not* freed... Immutable/append-only checks belong in ->setattr(). Note: the bug is old and backport to anything prior to 737f2e93b972 ("ext2: convert to use the new truncate convention") will need these checks lifted into ext2_setattr(). Cc: stable@kernel.org Signed-off-by: Al Viro Signed-off-by: Greg Kroah-Hartman --- fs/ext2/inode.c | 10 ---------- 1 file changed, 10 deletions(-) --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -1261,21 +1261,11 @@ do_indirects: static void ext2_truncate_blocks(struct inode *inode, loff_t offset) { - /* - * XXX: it seems like a bug here that we don't allow - * IS_APPEND inode to have blocks-past-i_size trimmed off. - * review and fix this. - * - * Also would be nice to be able to handle IO errors and such, - * but that's probably too much to ask. - */ if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))) return; if (ext2_inode_is_fast_symlink(inode)) return; - if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) - return; dax_sem_down_write(EXT2_I(inode)); __ext2_truncate_blocks(inode, offset);