Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2575931imm; Sun, 3 Jun 2018 06:48:09 -0700 (PDT) X-Google-Smtp-Source: ADUXVKICpxe0UrNRQ+UHuxMSfAEYlnuBGu3kGrhLXX9vnBJpNaZ020JUSZ7powfu1nqXMrCjoubs X-Received: by 2002:a17:902:5501:: with SMTP id f1-v6mr9498816pli.108.1528033689401; Sun, 03 Jun 2018 06:48:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528033689; cv=none; d=google.com; s=arc-20160816; b=ciC/Z1GsqHNjjAmAUxh+2FkGBamc0oCp7IRi8aW2aNe+2wg4g1Yfr/UhcJugTBxf5T r4LDJiv6f+8CT8L4QocKX/SeZC03w2hH3HWwDQpFbaW71bJflEwY9/eYJlGm4cXxVt+B Q7EFpf5U75psWaVV2OBTAdZvxiZD1AVyihEQ3dst21yqj3eruewHgBg+6r4DvjAD+Q0S tCWihGkQiWm92WkuJMzYT+QsjtNOtEe98YMmBTMnCkIcHp160teWjhq5q1tA3qjg7Nld mducLdI99/AMrPnh2ZAgwlSkD0gw4F6mx/jgWR0OWIROLOkYtQwusIuWxskhCs8agjI+ qMng== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature:arc-authentication-results; bh=3moqEuAhyuoG6un4hnI5gfgMzZ8DdH3gJ2CCUvain8s=; b=xhUlJA5AR1dN7MHE7bgkaQVUgU0MB3KupdQZTj2Mb2ZhaROHbvXf6ml+DEGfxhaCF0 gQbdhWRKKbC/WECRh+yJEDnUcQ+LQ6h41ehOhxFkv5zhe0KJbKyD6+7nLZtbYgIUyq/J wVllYjnzf3wmLE8sIP/4KgvLXtQ7bVcWc/UEOpt6FIrwQ5My2r7ew5q5dhTqDmNoAzq2 +QYQ+jzQfspuYuPDyQzR5zHwjPU+RwtzViZxdu8NH+a5OBxVbTRrgXSiDTlU/nSfj5ZT YYqBquFaIegd3wIs97GCS9O/JyHvFPem+prtFK6xh5aVBnlUI1Tghaatde7B0OL8NzQr O/qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=g737AKl5; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t186-v6si714442pgd.41.2018.06.03.06.47.29; Sun, 03 Jun 2018 06:48:09 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=g737AKl5; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751343AbeFCNqk (ORCPT + 99 others); Sun, 3 Jun 2018 09:46:40 -0400 Received: from mail-ot0-f195.google.com ([74.125.82.195]:40181 "EHLO mail-ot0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750862AbeFCNqj (ORCPT ); Sun, 3 Jun 2018 09:46:39 -0400 Received: by mail-ot0-f195.google.com with SMTP id n1-v6so34499582otf.7 for ; Sun, 03 Jun 2018 06:46:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=3moqEuAhyuoG6un4hnI5gfgMzZ8DdH3gJ2CCUvain8s=; b=g737AKl5iCfFEKDGHFUoRj97RkcUo5hBFu54K5Zje38+xr9sYYT+I4yo8LS7lBwdhF wxeIN4J/0gL5kLb81YZgQJ+pVCIh+jFVPcgIayGP3GdBnuEGsW6wEPKg865b3qzSDyhW XqeN8D3welyKPzzxn6B33Mnsc/TdUSaEAv50mGhOZ3b2HmtBAm3sWV9IPQ03lJGw5S5s nsjq+nrJ2udSyI1pRUQkUuuvijZ2Axauhhsed5DGUdIBjTq1DF+o+DNWHrkDQpN807AB 339k0sYqDndQ16MjNzTtpK7F3srYnxkQQKe7ZNUnPP+zBX2/Sr6I7ks4EmKvJk15RcE8 0zFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=3moqEuAhyuoG6un4hnI5gfgMzZ8DdH3gJ2CCUvain8s=; b=tLa4hncyxDUQWJ62Os5xnXjfKwAHD1dbhj1NLKyhmvh5jQbaeXN60Yvji3hASFx2Zx bzCS63+y1/lrLzkr8O4zdTCpq7JT0yRB4Dwu2pXdRBTLSf4WVHbaRvBfEDPm55GI5nbt wLqUx6QQJz6EvF9qnOgRWet31D4bVm0MH5OrrxDIE1Arv53ev+3H86XNBBnAlhvLuzy8 N+bpjrigmMzSExj3r0Yvkm7y2YqfM7B1KcHsp2h/SqosGIZAyPli4slj2sGvjf2haa4d qHu/mpiP3v/N/kqdfuNY57maN+IXHQ+ieXEnSH88SjtHCdezGWnzisQW5OZbCV0OL9bT aAow== X-Gm-Message-State: ALKqPwfXg4PGBbtlvkCSOCMkcfv5gcPJu2qOAulW7EtC919mp0/2Ij1p a/BGONxU+vg20thMZDQoD6tlYJsscLmTpFIsxinBcg== X-Received: by 2002:a9d:155a:: with SMTP id z26-v6mr12787374otz.355.1528033598351; Sun, 03 Jun 2018 06:46:38 -0700 (PDT) MIME-Version: 1.0 References: <874lilcu67.fsf@mail.parknet.co.jp> In-Reply-To: <874lilcu67.fsf@mail.parknet.co.jp> From: Anatoly Trosinenko Date: Sun, 3 Jun 2018 16:46:27 +0300 Message-ID: Subject: Re: PROBLEM: [kernel BUG at fs/fat/inode.c:162] when writing to a broken VFAT To: OGAWA Hirofumi Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thank you, it works! =D1=81=D0=B1, 2 =D0=B8=D1=8E=D0=BD. 2018 =D0=B3. =D0=B2 14:19, OGAWA Hirofu= mi : > > Anatoly Trosinenko writes: > > > Description: > > > > Writing to some file on a broken VFAT partition causes kernel bug > > Thanks. This patch should fix this issue. > -- > OGAWA Hirofumi > > > [PATCH] fat: Use fat_fs_error() instead of BUG_ON() in __fat_get_block() > > If file size and FAT cluster chain is not matched (corrupted image), > we can hit BUG_ON(!phys) in __fat_get_block(). > > So, use fat_fs_error() instead. > > Signed-off-by: OGAWA Hirofumi > --- > > fs/fat/inode.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff -puN fs/fat/inode.c~vfat-dont-bugon fs/fat/inode.c > --- linux/fs/fat/inode.c~vfat-dont-bugon 2018-06-02 20:15:04.44192= 0069 +0900 > +++ linux-hirofumi/fs/fat/inode.c 2018-06-02 20:15:04.442920067 +09= 00 > @@ -158,8 +158,13 @@ static inline int __fat_get_block(struct > err =3D fat_bmap(inode, iblock, &phys, &mapped_blocks, create, fa= lse); > if (err) > return err; > + if (!phys) { > + fat_fs_error(sb, > + "invalid FAT chain (i_pos %lld, last_block %= ld)", > + MSDOS_I(inode)->i_pos, last_block); > + return -EIO; > + } > > - BUG_ON(!phys); > BUG_ON(*max_blocks !=3D mapped_blocks); > set_buffer_new(bh_result); > map_bh(bh_result, sb, phys); > _ --=20 Anatoly