From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938841AbdAFUzU (ORCPT ); Fri, 6 Jan 2017 15:55:20 -0500 Received: from mailrelay112.isp.belgacom.be ([195.238.20.139]:31101 "EHLO mailrelay112.isp.belgacom.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161876AbdAFUy6 (ORCPT ); Fri, 6 Jan 2017 15:54:58 -0500 X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2DJAgADA3BY/2ZisVteHQEFAQsBgzkBA?= =?us-ascii?q?QEBAR9AgSuNV3KRVgGScIIPggmGIgKBVUAUAQIBAQEBAQEBYyiEaQYnLyMQGSY?= =?us-ascii?q?SOR4GE4hjEbI0OoofAQEIKIZFjw0FmxWRRwKQWUiSCR84gSEYGIZaPTWIZgEBA?= =?us-ascii?q?Q?= X-IPAS-Result: =?us-ascii?q?A2DJAgADA3BY/2ZisVteHQEFAQsBgzkBAQEBAR9AgSuNV3K?= =?us-ascii?q?RVgGScIIPggmGIgKBVUAUAQIBAQEBAQEBYyiEaQYnLyMQGSYSOR4GE4hjEbI0O?= =?us-ascii?q?oofAQEIKIZFjw0FmxWRRwKQWUiSCR84gSEYGIZaPTWIZgEBAQ?= From: Fabian Frederick To: Jan Kara Cc: fabf@skynet.be, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 12/12 linux-next] udf: check partition reference in udf_read_inode() Date: Fri, 6 Jan 2017 21:54:43 +0100 Message-Id: <1483736083-25193-3-git-send-email-fabf@skynet.be> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1483736083-25193-1-git-send-email-fabf@skynet.be> References: <1483736037-25111-1-git-send-email-fabf@skynet.be> <1483736083-25193-1-git-send-email-fabf@skynet.be> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We were checking block number without checking partition. sbi->s_partmaps[iloc->partitionReferenceNum] could lead to bad memory access. See udf_nfs_get_inode() path for instance. Signed-off-by: Fabian Frederick --- fs/udf/inode.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/udf/inode.c b/fs/udf/inode.c index 47638eb..3926973 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -1276,6 +1276,12 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode) int ret = -EIO; reread: + if (iloc->partitionReferenceNum >= sbi->s_partitions) { + udf_debug("partition reference: %d > logical volume partitions: %d\n", + iloc->partitionReferenceNum, sbi->s_partitions); + return -EIO; + } + if (iloc->logicalBlockNum >= sbi->s_partmaps[iloc->partitionReferenceNum].s_partition_len) { udf_debug("block=%d, partition=%d out of range\n", -- 2.7.4