From patchwork Fri Aug 12 10:12:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salah Triki X-Patchwork-Id: 9276679 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 337EB60752 for ; Fri, 12 Aug 2016 10:13:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23C9928916 for ; Fri, 12 Aug 2016 10:13:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1862428927; Fri, 12 Aug 2016 10:13:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 175ED2891D for ; Fri, 12 Aug 2016 10:13:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751959AbcHLKM4 (ORCPT ); Fri, 12 Aug 2016 06:12:56 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:33867 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751254AbcHLKMm (ORCPT ); Fri, 12 Aug 2016 06:12:42 -0400 Received: by mail-wm0-f66.google.com with SMTP id q128so1991510wma.1; Fri, 12 Aug 2016 03:12:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=1lHGukFI/qG5kaz4J9QQU2wHfFXQeu3cMqc7BHzFkxM=; b=XvWfF/QjXt+0ZO46gsUmtsFyLHofktSy62E/rVtkMyUKYRTebE8zvq0DLHh/2NwaLk Td/hNfykgyNyZq0FniwGx8HAKhjrCHWy0qgMUHr9cKCpBtJ78d9tmAVn4uFJH9TP6pvx /sPckm1mrf5tJ/2Cgz6IhKZEcK7yb2QP+O+A2KHSHJd4Dggo9UPwFLZuoaCBtrwVZ8Qt /STHvYVhpY90+IFYFDzha9SlR99W2HoNC4v+XmdyYLGSu5l/6CvMIz9WYGiBMg0aNj+o 9xFlNqz4dJefc4Vg5Yk+QQbxNzIrkZTe3mKyDdao8N9z+zK+vSOEa6sIz5jGL14XDeKf GMqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=1lHGukFI/qG5kaz4J9QQU2wHfFXQeu3cMqc7BHzFkxM=; b=LXblGR90erIh5cWEpNbo9M+Ta9Q8m3IPxep1KvpjMu+fPLO8iQha8y6Xko24LWO1RG vZmEk7Cn1utQXvWS9OMwNBtepI9zNm1bYW2Kdclc39Mz/ZC3jbKETr0nklZvHKWrCflN APdjUNSVbmzhjikmHPstz4Gd0hJq5aUU4jbFrNpsXJBssROHRs62Dct1Mk+xDLjdyV7W jIrsQsTyTGXWxqMpaCHWFTI3G/d2JiKfkUEvnsUqg7FKQQHVTRcnQiobyVjmQgdikn48 55HUkjprJtILhDiaUwXZtbiEHl8Cenn/IGRczm+c3r6X2KXREe94egoDh2QHc/+9/clL L7Iw== X-Gm-Message-State: AEkoouti/3V94AzRDQxYQSX7QgW9WHxUsVzDvLaAQSgaaskTf9bpJt2e5uI3oRGlYpqPNg== X-Received: by 10.28.51.210 with SMTP id z201mr2234584wmz.98.1470996761067; Fri, 12 Aug 2016 03:12:41 -0700 (PDT) Received: from localhost.localdomain ([165.50.75.145]) by smtp.gmail.com with ESMTPSA id x133sm1836876wmf.16.2016.08.12.03.12.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Aug 2016 03:12:40 -0700 (PDT) From: Salah Triki To: akpm@linux-foundation.org, viro@zeniv.linux.org.uk, luisbg@osg.samsung.com Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, salah.triki@gmail.com Subject: [PATCH] befs: return BEFS_ERR if validation of ag_shift fails Date: Fri, 12 Aug 2016 11:12:31 +0100 Message-Id: <1470996751-18466-1-git-send-email-salah.triki@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ag_shift is used by blockno2iaddr() to get allocation group number from block. If ag_shift is inconsistent with block_per_ag, an out of bounds allocation group may occur [1]. So add return BEFS_ERR and update comment and error message to reflect this change. [1] https://lkml.org/lkml/2016/8/12/42 Signed-off-by: Salah Triki Nacked-by: Luis de Bethencourt --- fs/befs/super.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/befs/super.c b/fs/befs/super.c index 7c50025..2e3a3fd 100644 --- a/fs/befs/super.c +++ b/fs/befs/super.c @@ -101,10 +101,13 @@ befs_check_sb(struct super_block *sb) /* ag_shift also encodes the same information as blocks_per_ag in a - * different way, non-fatal consistency check + * different way as a consistency check. */ - if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag) - befs_error(sb, "ag_shift disagrees with blocks_per_ag."); + if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag) { + befs_error(sb, "ag_shift disagrees with blocks_per_ag. " + "Corruption likely."); + return BEFS_ERR; + } if (befs_sb->log_start != befs_sb->log_end || befs_sb->flags == BEFS_DIRTY) {