Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3335889imu; Sun, 11 Nov 2018 12:38:50 -0800 (PST) X-Google-Smtp-Source: AJdET5ePOSzIwL5ubipZUI61520e/S58WwVoiKGCSfd0Pw6O46z55aLi0hx/HV68MdP7ZvfaNTzz X-Received: by 2002:a62:6241:: with SMTP id w62-v6mr5529834pfb.69.1541968730922; Sun, 11 Nov 2018 12:38:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541968730; cv=none; d=google.com; s=arc-20160816; b=kL5NdCVErWoAKGxpnvCSREJ1jUTeAk6vuOGiNtMlU1afsE6VHIGY82Qg1lHCg7U84v q/niOG9vK0K4BIDHk117FJk92lpAWFQn9MHMzMXVVyWp5J68TZxKRHM3xAJFbmecooRd lq7vjn9jQaBJ+5oaNzUHrzVlpEDs5xFxhafiY9tmFJgrZEmcSAegobjdOT0W7Hp87Heq Ioh/TvgqrQy+/CVAgW6HPvj/v/8Gj/ncdo0LDPHhseBdUgDccODLBKjlXmCPgSxgcBK8 1mz6ntggBzIPJKYtW+UdRFyYOz0sy7DHk7OGZfV1aOZiuBLva2TuSWMnCh98gJyDFNpw 6XOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=w0MIqoEoXagooRxr9/7l/sHFEtbNauZqMvSnnXImZsM=; b=afyK7YlKAlMfCeiC3aK49pp51Je4ToLQUiGpm8avbObo1oMJXGiPFL5vZ14VViR09H AmJvdYJA00yKqHCEGDeq2Gz/OfyMw6jSVwyjgzh5u5q9GJypythHweLMnZ3ukuhU5TiL ezFkjB2OVvRMtOnHterv717nIryeHpqTr/G9mMvnTLFmEDUcDYDmuQxA9sidZ4HZHvi1 947FV9n8iwRBThgKVNYbX7TKN124gk35BS+aZty89rDgiRnB5smK1EJlx6I200K4QYlf khd91YsmmJBC26SU4w75Rxh4Suu/1XnrI5VDgEzRKT45/VH3deVXR64ddlSdq0etThUQ aXqw== ARC-Authentication-Results: i=1; mx.google.com; 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 y35-v6si14024349pgl.14.2018.11.11.12.38.35; Sun, 11 Nov 2018 12:38:50 -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; 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 S1730050AbeKLFsJ (ORCPT + 99 others); Mon, 12 Nov 2018 00:48:09 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:49516 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729976AbeKLFsH (ORCPT ); Mon, 12 Nov 2018 00:48:07 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvsT-0000oN-CB; Sun, 11 Nov 2018 19:58:37 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsS-0001Zu-Sv; Sun, 11 Nov 2018 19:58:36 +0000 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, "Jan Kara" , "Anatoly Trosinenko" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 157/366] udf: Detect incorrect directory size In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Jan Kara commit fa65653e575fbd958bdf5fb9c4a71a324e39510d upstream. Detect when a directory entry is (possibly partially) beyond directory size and return EIO in that case since it means the filesystem is corrupted. Otherwise directory operations can further corrupt the directory and possibly also oops the kernel. CC: Anatoly Trosinenko Reported-and-tested-by: Anatoly Trosinenko Signed-off-by: Jan Kara Signed-off-by: Ben Hutchings --- fs/udf/directory.c | 3 +++ 1 file changed, 3 insertions(+) --- a/fs/udf/directory.c +++ b/fs/udf/directory.c @@ -151,6 +151,9 @@ struct fileIdentDesc *udf_fileident_read sizeof(struct fileIdentDesc)); } } + /* Got last entry outside of dir size - fs is corrupted! */ + if (*nf_pos > dir->i_size) + return NULL; return fi; }