Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2407965imu; Thu, 24 Jan 2019 12:14:16 -0800 (PST) X-Google-Smtp-Source: ALg8bN6Nyb2Eso8xAPHc6t195WlIgpQtf546JKuJadPwEybbh4nhzUE8r7JGyy22gkkVtuLAtIVe X-Received: by 2002:a62:8a51:: with SMTP id y78mr7851204pfd.35.1548360856441; Thu, 24 Jan 2019 12:14:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548360856; cv=none; d=google.com; s=arc-20160816; b=E3w3wkQ2Ym0ST3fBJl0pMjRePiYdch1su6kRUm3k9fejDV0orCgS/GM2smcd0q3gEs x+MpOkwSLSTYoSQlAzbjkEsFPA5XCPtgz8iJuL6/2FgzfZxVxrA1PIAuKmvyRUhN7f2v rh29/HJHkdQTgj3LP7Rq3g+j9DQ8RDowDBIXtQrTqVwlVgQ/7QVbOpQprHu3pHTDgr5t Bu8mgNfgXRMMhzHHEUfdtLwW6A79LNyZv7ZB+nF5bQKSFEvMofympv7djUIFaExjfvqV 0mk76CCd0QF6MvOoo+MYxlBUWHDES1uXIjZTs6HffSuJU0kvsMDFwX1NLFyqIYSdqUJs ZwAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yMm2aqruuzOLtzBc2Nmc+r/Vt20ufCn65ZeZDgvE57E=; b=fwsBc2IoPinVhojsYHJ7wltAJVQWFDiCoTMi1R3Rq8WejhgTNyiuZrBOsy/qhYkNVO n6Sv5NQPXHqSI7OyfUHB0RKWbXsB7t5QrwCH9Y3Vxn0Q9qDwckOgtUvki0ljRGLNrfj4 8PUxhBJH5vb9Wl0hhrijNgP50qYJMSYeizhWcAtBPEkluaPK5Rw6YY6EbcMiUQalXi/M DZOTiZ/8p1pG5+M0DakJjrktgj3OeuOIxF3C9RWngn0gI5HO2btGgdJe/Az/at9NFNUu 8GcS1HFxLs7X7Pf8zlDoDdldDCRl5wtX3mRTLL7+GL5fwm4rkKMZUcYdMfjWeIMzxExf fjkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=m7Rsdq0j; 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 2si23077920pfd.154.2019.01.24.12.14.01; Thu, 24 Jan 2019 12:14:16 -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; dkim=pass header.i=@kernel.org header.s=default header.b=m7Rsdq0j; 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 S1729498AbfAXUN4 (ORCPT + 99 others); Thu, 24 Jan 2019 15:13:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:51136 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730390AbfAXTZ3 (ORCPT ); Thu, 24 Jan 2019 14:25:29 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AAF5A218FD; Thu, 24 Jan 2019 19:25:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548357929; bh=EvqM6neG0NZVH/lnBNAX0yCUQCR4f40AF/zzRNPZagQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m7Rsdq0jgjfl1DKu3ffixBaFjh2XIyl406q698Tpnmz+4fm9LV3DmdywI3cQz0T8A dJ3ld9BlSEP3QniET4r7xyD5x2LcKBV4CCySwmM51bJaen1AoiASAzZedGNSgIHeUW o8kno/at+0xvOzy2xTEBm2A4QYhEw3w3BMe14GDM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin Blumenstingl , Chao Yu , Jaegeuk Kim , Ben Hutchings Subject: [PATCH 4.4 037/104] f2fs: fix validation of the block count in sanity_check_raw_super Date: Thu, 24 Jan 2019 20:19:26 +0100 Message-Id: <20190124190159.275850593@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190124190154.968308875@linuxfoundation.org> References: <20190124190154.968308875@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Martin Blumenstingl commit 88960068f25fcc3759455d85460234dcc9d43fef upstream. Treat "block_count" from struct f2fs_super_block as 64-bit little endian value in sanity_check_raw_super() because struct f2fs_super_block declares "block_count" as "__le64". This fixes a bug where the superblock validation fails on big endian devices with the following error: F2FS-fs (sda1): Wrong segment_count / block_count (61439 > 0) F2FS-fs (sda1): Can't find valid F2FS filesystem in 1th superblock F2FS-fs (sda1): Wrong segment_count / block_count (61439 > 0) F2FS-fs (sda1): Can't find valid F2FS filesystem in 2th superblock As result of this the partition cannot be mounted. With this patch applied the superblock validation works fine and the partition can be mounted again: F2FS-fs (sda1): Mounted with checkpoint version = 7c84 My little endian x86-64 hardware was able to mount the partition without this fix. To confirm that mounting f2fs filesystems works on big endian machines again I tested this on a 32-bit MIPS big endian (lantiq) device. Fixes: 0cfe75c5b01199 ("f2fs: enhance sanity_check_raw_super() to avoid potential overflows") Signed-off-by: Martin Blumenstingl Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- fs/f2fs/super.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1081,10 +1081,10 @@ static int sanity_check_raw_super(struct return 1; } - if (segment_count > (le32_to_cpu(raw_super->block_count) >> 9)) { + if (segment_count > (le64_to_cpu(raw_super->block_count) >> 9)) { f2fs_msg(sb, KERN_INFO, - "Wrong segment_count / block_count (%u > %u)", - segment_count, le32_to_cpu(raw_super->block_count)); + "Wrong segment_count / block_count (%u > %llu)", + segment_count, le64_to_cpu(raw_super->block_count)); return 1; }