Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1952940imm; Thu, 24 May 2018 03:31:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqfsP0YplHI0vJK6bVq3XqGuRpotVqoADLWLndZiKY7k6j2Yzu3VoDurM1PtPJfiknF+o/c X-Received: by 2002:a63:7d47:: with SMTP id m7-v6mr5386387pgn.443.1527157884834; Thu, 24 May 2018 03:31:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527157884; cv=none; d=google.com; s=arc-20160816; b=lcFtvf8KKTaYTk9AwIC50pkSyhqAUbgSYcg8SU9qDnWy3tHfYqOs7YoB5Wu43sPAv/ 6XujmqsB8Kgr4nFTGyw5ZIyGlFRahZbZQQm0BeBMYL6AkLWLnCkSAG33wo5Tr00745bs jqfdxF+ZhMT4tpDVKNnrIsoAbaFQ3ac3nSkwwdcjy+mykH0wPz5bNB7gGfarwH38VMcQ 5rQeCmnnyZTLPaxXMMeUUurw3f74QepTS/NyAte9+1ZtApE+s8pD+e4OXkMsNWkP2/t9 avhGyZ5u4WUhIYiZdhM4eaweJgsq3Cm/sR/d9B2oHKUDnuMArApcidKATtjbxepBffle NGPQ== 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=YRjtHw/XfLADdKo2haoHdA/Z+ejsp7HtjuBXNscbTtk=; b=mDR3KPf7fNXaxUJ1N3S768LSGx5cL9lja5B+XKiE6OQeJTXNSpzhoZ4bpo/diwzUjF p0VuCa1RnrdtUbd3643N44rRe4kd1bPcvF87zks29ravdp/fguwG0q4w5Lw4VRly8c9x 0fDfQj+Pwp7x71bkpOTKMlZFuRjLZrGxderOmEA6+G8Iv45xaLOkKcXAHtghgCttDDXQ ejqkTplO+UlQWpkDk5IQ8+ZtaShROC2S4yACTsOzE9OerRC5l+CgWlxceA6TuN+/QNTI gbnUuHDYUY7AIs2oAFctM1C05yqWcPKiz0PckFpB08MvSYkAIy/B1ku8QgvLV/tl2MB7 zoFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aTWRClCp; 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 l81-v6si21337607pfj.127.2018.05.24.03.31.10; Thu, 24 May 2018 03:31:24 -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=aTWRClCp; 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 S1032128AbeEXK3S (ORCPT + 99 others); Thu, 24 May 2018 06:29:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:40630 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032103AbeEXK3I (ORCPT ); Thu, 24 May 2018 06:29:08 -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 C26142077A; Thu, 24 May 2018 10:29:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527157748; bh=IZ7B4fpbQAJp/rrELAdqF8S8YWAVwUo0u4nmUVe/OqA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aTWRClCp4gRG+ZjSwJ9ibVKe3gr63tRlWTrrtRlR7OqEY1GxCoBFb5Um5hwUj6dpS Dj8Dzw5pnmXSNQym7UO5dQMFc3dvP6YWUTW5PsZvgH+tuKKdTf6N7MgkjBE9KZVp11 4/rN3iH4uCLFbCGvi0YbWguqPLnEYjS2nPXE5e2k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Viro Subject: [PATCH 4.4 75/92] ext2: fix a block leak Date: Thu, 24 May 2018 11:38:52 +0200 Message-Id: <20180524093206.489170520@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093159.286472249@linuxfoundation.org> References: <20180524093159.286472249@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.4-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 @@ -1175,21 +1175,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);