Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3468137imu; Sun, 11 Nov 2018 15:47:57 -0800 (PST) X-Google-Smtp-Source: AJdET5dJ6yqZm3umvN4l03j0kkKge4lB9uS87wn8J4KrxqhfeAZDgh7X51e9uel7jBnNKOuN/hqe X-Received: by 2002:a63:8742:: with SMTP id i63mr15405334pge.298.1541980077234; Sun, 11 Nov 2018 15:47:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541980077; cv=none; d=google.com; s=arc-20160816; b=bRFGX4QbAS16oKJ85htd1m/jOZSX3QWVCz8HLOXu+/BZCbdLO5tnllmLipGfluGQ4Z nikahTsLWBBrkrILkwhqH+NKkoW0CUtPUsNLcFIBlExrBYx1CK18gtZ64l6UhKl2YIET LvYL0aqGRwwbP3puPBhDjVYy8aBara9kPo/F9PzcRyv3/aqHpEV13sNaVObNL225qCFY 6gIccr3O5gBxSQFOzOqxbPe3+IcBzeQSc/2xPmEu0K7TN7Lvrns8mPZKeRJfhN4+8YUs 5amOZrx5A0pur/wz9Vbnt4hmpIWyozjqRyf0ajH7yKNRifywVpy3ObtMQ24V+rAhuFZd /25A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fTU8gavCGS3T/ix2h6Tyh7Ex1uNZON1zemC2JY5EsCM=; b=p1CD+q8Z2SNLCGjk2McnCHn58YqDfhKHXiy5CEZMhtNCezW477I8f0zJpJnxBDPJUF TkDtbEhSoz+aw50CAahDe2Itzhf5aEnCeHXH1jz93mku1rVdq27SazklAEAGJPaEwjp+ OCwmMakhBQ55/aFkEh4Cu+U6jhFrNv7TOk/A5vZp9slfxhgna2MepGiPHXltjZxM5Z/s hBPRsdGVSom9Bc/j4fCkP/pLfM/tZc2qqOuLpFlUN+ed+MIORLt5yzrfgAL0a47romwM t7nOSmFRH96COGB3FGtdwxEc3ApxFNloqk5WxHJExBE1GIRKbaCIvUUJq44m6dwwic8R tY9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=waJBk+bD; 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 go18si1796498plb.130.2018.11.11.15.47.42; Sun, 11 Nov 2018 15:47:57 -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; dkim=pass header.i=@kernel.org header.s=default header.b=waJBk+bD; 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 S1733298AbeKLITD (ORCPT + 99 others); Mon, 12 Nov 2018 03:19:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:39756 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730141AbeKLITC (ORCPT ); Mon, 12 Nov 2018 03:19:02 -0500 Received: from localhost (unknown [206.108.79.134]) (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 AD7B7208A3; Sun, 11 Nov 2018 22:29:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975346; bh=9pngn7uTd3zj3cjUMGLIXko+aNUXNOrkM50kiDFXR40=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=waJBk+bD71hfia9aBdYOEVvFGZRVdcsWnfjsA2LHPSpd/mzx0kQlB+FwkyYxw3SQg iL5S98otnP3wue5y0dLN0qSvxVUNLIZNIb6Han8vClwiHsYFCk11zSPJRUFgiSgSUu uNvyJbPOxg6vv0joho2HqLYLfkeQLM4AIOqkD1Fk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anatoly Trosinenko , Nicolas Pitre Subject: [PATCH 4.19 318/361] Cramfs: fix abad comparison when wrap-arounds occur Date: Sun, 11 Nov 2018 14:21:05 -0800 Message-Id: <20181111221658.861472266@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nicolas Pitre commit 672ca9dd13f1aca0c17516f76fc5b0e8344b3e46 upstream. It is possible for corrupted filesystem images to produce very large block offsets that may wrap when a length is added, and wrongly pass the buffer size test. Reported-by: Anatoly Trosinenko Signed-off-by: Nicolas Pitre Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/cramfs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/fs/cramfs/inode.c +++ b/fs/cramfs/inode.c @@ -202,7 +202,8 @@ static void *cramfs_blkdev_read(struct s continue; blk_offset = (blocknr - buffer_blocknr[i]) << PAGE_SHIFT; blk_offset += offset; - if (blk_offset + len > BUFFER_SIZE) + if (blk_offset > BUFFER_SIZE || + blk_offset + len > BUFFER_SIZE) continue; return read_buffers[i] + blk_offset; }