Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1952435imm; Thu, 24 May 2018 03:30:56 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqLOvZwOsFg1QA+e0bFjGM4aEj+nw1NqZZolEMMMlcbGHCwgMg5itZTnAS48Bx0rbS/+Nao X-Received: by 2002:a17:902:7c03:: with SMTP id x3-v6mr6559366pll.237.1527157856848; Thu, 24 May 2018 03:30:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527157856; cv=none; d=google.com; s=arc-20160816; b=u0LEVhJgS5ZEZ7MVsl0AOk3nDdu2FWxjotg9Ji5bJQMgOziCqb9fwaeAnGdHOHuwFr z4BgGMB3m0Q8KKdee5uWAkOFabhpH1HPUklVmYkrAsq6O8F7BOtxoKZQHfApcnqFdRdM 9XCHgIkH27A+ymNpPfR308WVE/QM3Sv7midR1QWUSW1666cHLHVIKt9unergZZ8xWcmC 5t4/9fBeO+uujKhOvamwbuoLStEWjmqApAlCG0xa4ZvUsN7DEWVEVIF2XjaLOYbXqGR2 8O9moBGYdQhXJb5Ls5QJUGrpFJGrUv2hgOB/qfgZh3NoGpoCAXXslGGVqa7s5ODWj6Y9 HrDA== 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=HGeW5hPNPp4dBzJ0NeAMAkyaIkRma5dTtDTfOyHichY=; b=Lwr5vEpd4KPgAMDQim/lI1DaDlk+f6lyMk0rxjB2k2l2Nndbq5MqxGgwdPLU3jV8kE bAQNoBOpqjHlTQ6MKLcdvE4+QJWnIFQESWda+MnehbsRWyoL19ZoXpMrFzOgeWQtD5ou n4Ww8wiXXX5+x6i8Zt01Ou/6K2t1qEQCnFud20/21cMF0rZrh1ccmcdXzklux9UW5FeE F71TAwdnlvHiQVmaO8VTJL6uQlUfylfSMjqb6VCZhXs48GBNLGjVKDi+9cBWUql9XGcy MfeXlB0v50eGwYSd9ER9tEpX7Qumg8mSPQqinYwWYF844pRQ139hUGH6WUiPC4w4GkwU w/TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=B0YPBiya; 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 q68-v6si5023165pga.217.2018.05.24.03.30.42; Thu, 24 May 2018 03:30:56 -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=B0YPBiya; 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 S1032187AbeEXK34 (ORCPT + 99 others); Thu, 24 May 2018 06:29:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:40720 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032107AbeEXK3O (ORCPT ); Thu, 24 May 2018 06:29:14 -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 2EFDD2088E; Thu, 24 May 2018 10:29:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527157753; bh=kEGpBob5/zcvDnhbTZxPqZpB4xtdOqYZe6dpkH/lihw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B0YPBiyaxypVTAc8bgBUOtZsgDgHsMqIuJlbC2vE/td4svoikrw1GFAducUEtX+76 21lY78D/Ag9CtePXkhJJqnzGbkQVbwDaSBrnGRH40vQTNVXQRITFxEWd/U9JIvg2S1 e4YrVsTCF3MhWiOsaTj2lXoAlPrq8eM7DCbPrYl8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Viro Subject: [PATCH 4.14 036/165] ext2: fix a block leak Date: Thu, 24 May 2018 11:37:22 +0200 Message-Id: <20180524093623.432369640@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093621.979359379@linuxfoundation.org> References: <20180524093621.979359379@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.14-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);