From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753317AbbKOCHo (ORCPT ); Sat, 14 Nov 2015 21:07:44 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:35132 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751998AbbKOCEt (ORCPT ); Sat, 14 Nov 2015 21:04:49 -0500 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Richard Weinberger" , "David Gstir" Date: Sun, 15 Nov 2015 01:45:45 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.2 08/60] UBI: Validate data_size In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.247 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.2.73-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Richard Weinberger commit 281fda27673f833a01d516658a64d22a32c8e072 upstream. Make sure that data_size is less than LEB size. Otherwise a handcrafted UBI image is able to trigger an out of bounds memory access in ubi_compare_lebs(). Signed-off-by: Richard Weinberger Reviewed-by: David Gstir [bwh: Backported to 3.2: drop first argument to ubi_err()] Signed-off-by: Ben Hutchings --- drivers/mtd/ubi/io.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/mtd/ubi/io.c +++ b/drivers/mtd/ubi/io.c @@ -943,6 +943,11 @@ static int validate_vid_hdr(const struct goto bad; } + if (data_size > ubi->leb_size) { + ubi_err("bad data_size"); + goto bad; + } + if (vol_type == UBI_VID_STATIC) { /* * Although from high-level point of view static volumes may