Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2994285imm; Sun, 1 Jul 2018 09:56:11 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcTbsaJI2coeI+0T2zKOIhVZHg31h0dlcUMeFho7S1VwSa+bsxDMe9mqkLbxhTg8dmUhiRj X-Received: by 2002:a62:be0a:: with SMTP id l10-v6mr21796491pff.180.1530464171868; Sun, 01 Jul 2018 09:56:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530464171; cv=none; d=google.com; s=arc-20160816; b=sM1TJIGz62F2XCVTqj9IQT66guF/+R3EhV4yG1whHabPPWi2/AzKDdHw/vD+4ExQLm 91o/MjltCe7bkv5hWmdc5TP5uNxCEnBSVkt6SAyOkMI3/UD8bNKgZRd0cqpV9l8HV20u idM2nDAaJd6U10vD5jKsQSE1Fw5oSBtaCkgThDiDwF/EIxNy/wIZUwonyFZiyjO4yuEI hc/3c9Te3UrzeoFATMcxfWxfyvCjXjJlbWejDqP52OqM0ynojPaeR+WolNog0UnsLa+5 isCmEt5N8eKPLQ29V9BzwIpYLYg3fjjk7bacElzChEWz4obqFD9zcsYWqQTOw5ytwcHb /NrQ== 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 :arc-authentication-results; bh=uxOFBWLtZJEWcUt23EfQMdTU8hscXCMaSx0zDEeDnQw=; b=XE9aqsndbJwb19AbZcs0e5ajrTm/BzBiZ2+REFc8qwVBbReha8PdO9IICANzAbvW0w lb7OJu+ls/8UIOdISs6b1J6161dOdi3FiyU9iRJjblWl7y0FfNu4y4d585ZqlwgVwC6C h8AIyAs5tId6H5/DdJmoO69+18HEB7XgE1u6J18uJmYpVimAfYvqw95HeLArfZPUHo/n pI+giuk4j9jJogOUoXzNPC0ZCmDBU8oVzCwGwjqxyoqubcwTQ5gRmUb+RMXjtntN8GbO HVz/s5a5BI4MWpzGH2UqzHCggw0Ijz+NIlha7+Z4SgWvjqDu34MKifwenGOu38XsUJ4f IiXg== 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 w21-v6si14792727pll.96.2018.07.01.09.55.57; Sun, 01 Jul 2018 09:56:11 -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; 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 S1753627AbeGAQxt (ORCPT + 99 others); Sun, 1 Jul 2018 12:53:49 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:38224 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964788AbeGAQp3 (ORCPT ); Sun, 1 Jul 2018 12:45:29 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4E137A73; Sun, 1 Jul 2018 16:45:28 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anatoly Trosinenko , Jan Kara Subject: [PATCH 4.17 195/220] udf: Detect incorrect directory size Date: Sun, 1 Jul 2018 18:23:39 +0200 Message-Id: <20180701160916.330434753@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@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.17-stable 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 CC: stable@vger.kernel.org Reported-and-tested-by: Anatoly Trosinenko Signed-off-by: Jan Kara Signed-off-by: Greg Kroah-Hartman --- fs/udf/directory.c | 3 +++ 1 file changed, 3 insertions(+) --- a/fs/udf/directory.c +++ b/fs/udf/directory.c @@ -152,6 +152,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; }