Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1951904imm; Thu, 24 May 2018 03:30:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpI9NaMoC17ckdI8Zl7uIfX5ur8XmhsDwwfVsJMuU3J1wIDgwUB7qGXOpmq6ao7ox1kfHp6 X-Received: by 2002:a17:902:274a:: with SMTP id j10-v6mr6944789plg.393.1527157829931; Thu, 24 May 2018 03:30:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527157829; cv=none; d=google.com; s=arc-20160816; b=Kix3OSEHcjwxrN9M5z3Ys1m23BFwP6rQSba5Ul5r4rNrCFRwY8brBKakmaDW1T0AFw ckgZHQIsqdm/55p0+yJ4+uAAMYYR8smfHPfw8midv4+B5GrJuFxMF/aKVkKjez46NpDK ePVAaXc7fU9eOXtBiNm+2zEwWw+1ZHg1Je2ooigF2bTm/teTCv+kftIbcSRNflwkOJzh fvgRuaKvwucth6ROm3IGWoKLdRP0JT8CMtOGyEsHihNBuHy/GxmsDRS+kmE/4+oASfan TyliKlx5WUlOJpfyaz/zhXfqeEXWhkMyEzUCoGYXAv0s7LihuGSGt3F+IzSGtVBmD5tU J8Wg== 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=yY+ofUSgldrphUKQ1XGAOk4KsZ2IovRzY8YpE9BOqVg=; b=xE40Ea0wwDPDQZ6QFS5qM1jVRN2vgfqvBDibBhg44aSGmFsNzXFa85x4ZHhZ6sW0qh cnV/U9yGPClucJhDaztW1F6vX2Qb/z9MLm6oXYgQfXoKy4Dxuj3j6gKvuR2zwmSQ4Zim sWOxDw9mN1scY12AaYrlUonwB3Rqrg+coYRj9V8wfYapDSCaJohfywXGJHaTEQFpU9qk 7j8UBotoZFJt3gaG5jbVNqypTRR8uqsaFAZcpPyb4ug3cNG126CUGPsbir+90bYiozjL lhXQuHy2UTB+LWcLuY6W1YD5uzhs7zT9dzPI9RKaXkMvYbxcbGBnu78THq2Sws1xxBlN Oa3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EWfPtR1F; 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 z26-v6si22906700pfl.209.2018.05.24.03.30.15; Thu, 24 May 2018 03:30:29 -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=EWfPtR1F; 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 S1032116AbeEXK3P (ORCPT + 99 others); Thu, 24 May 2018 06:29:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:40672 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030995AbeEXK3L (ORCPT ); Thu, 24 May 2018 06:29:11 -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 7941E20847; Thu, 24 May 2018 10:29:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527157751; bh=F1fBLbVNLZb5sNYqiDSDdnUFPxSVY2m1nCksiti1SK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EWfPtR1FfacufqeZVWgeM+4165IniiUpmbiiG/kIKW+OnjtWBiKjPcZQEL70DwpNp Hn+VudDz+7TpE+8hB8nCVOgkDu3PTYc0qUEWjxlZfAd7xdwNEc1h0dQhkVeyKp6x8f F6gAR12UAGyXpOWMdulXINUA+Gor3vl9DWvq0l4U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Viro Subject: [PATCH 4.9 08/96] ext2: fix a block leak Date: Thu, 24 May 2018 11:37:51 +0200 Message-Id: <20180524093606.086245224@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093605.602125311@linuxfoundation.org> References: <20180524093605.602125311@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.9-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 @@ -1258,21 +1258,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);