Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1859604pxu; Sun, 6 Dec 2020 09:40:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJw6AiXepT7r8ciNJ9D5EMI+neihL0xkIfeP8v2x1Y4p7x1L99jLqKukI0eM4WMOjnHmpacW X-Received: by 2002:a17:907:d28:: with SMTP id gn40mr12751155ejc.33.1607276438058; Sun, 06 Dec 2020 09:40:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607276438; cv=none; d=google.com; s=arc-20160816; b=FKjO2yjNZimc+3wOOGFkj/cAc0QZQMzHhYFqH/pVSsE/IS35Swg4Wb5UnU3RIGS7R3 jkdGaChYtDSEMxHASpBWfyJ/ZvWJxC8oooitOrd8KygSbKkYa3S0Jyyq6eFLP8/d2UyM 4EDc9O8LauHu9+/pr3UD1OfiM4H/O+Vn5QBVI5UdFNrx0p1hZDNskfevNsVROUVJnnRn /dHG8yhYu8v033XesXAiYNEwVQbQeEI7gQEmq8CqfveNfFUaPdnfi/1BopoZeawp4Sos O4a7QOHE2FNXYT4+lk6ZShIDnTCUphXc/gekylo4M0g9O9aaHsAK+AoF3W6iQ+N63L3f SaMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=0T+YlHcPwjLQBGz2zlCxS7Yt4U7nMoSbR3CLbZI4aik=; b=gi3ghPFd5PckMG3jhgX4/0ORpAS+y+5UHlVMLvdCISMwGbZBsg+9jSGvN/3TF3bmoY VUi9Z+JKFF2v6hnqsmp3qCdvMR0qY1FLOSbn+4SVSZ8CB+WQCDMaYyxR7Jje1zRPRU2B HX4c6FpJpC6pv7Kb9MOMVFEQkjc6+lM9FZ56xrwVeilIixy85BCWCwBfrv5BXeSdqp0Y 9p8RkCmTpH9UQHpy77s/0S1D1FUywUb7Iey4VZFmCrxg/4VWN6CjGqQHt9G2PVM2iKeG I4vfyTOl2f5AVbj50LV4uG4zLAAQQzybK7Zar6RdB1hrgFuWlfYSmA90IB4R3lnYjPNU 35/A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id co9si6381782edb.379.2020.12.06.09.39.36; Sun, 06 Dec 2020 09:40:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726609AbgLFRic (ORCPT + 99 others); Sun, 6 Dec 2020 12:38:32 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:38672 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726043AbgLFRic (ORCPT ); Sun, 6 Dec 2020 12:38:32 -0500 Received: from 139.35.155.90.in-addr.arpa ([90.155.35.139] helo=riva.pelham.vpn.ucam.org) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1klxyl-0006xS-Hi; Sun, 06 Dec 2020 17:37:47 +0000 Received: from ns1.pelham.vpn.ucam.org ([172.20.153.2] helo=riva.ucam.org) by riva.pelham.vpn.ucam.org with esmtp (Exim 4.92) (envelope-from ) id 1klxyk-0005bT-Pp; Sun, 06 Dec 2020 17:37:46 +0000 Date: Sun, 6 Dec 2020 17:37:46 +0000 From: Colin Watson To: "Theodore Y. Ts'o" Cc: Paul Menzel , Andreas Dilger , linux-ext4@vger.kernel.org, Dimitri John Ledkov Subject: Re: ext4: Funny characters appended to file names Message-ID: <20201206173746.GN13361@riva.ucam.org> References: <20201204152802.GQ441757@mit.edu> <93fab357-5ed2-403d-3371-6580aedecaf4@molgen.mpg.de> <20201204180541.GC577125@mit.edu> <51a1939c-2a99-e86a-1799-c31248e21d89@molgen.mpg.de> <20201206144416.GM13361@riva.ucam.org> <20201206151527.GE577125@mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201206151527.GE577125@mit.edu> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Sun, Dec 06, 2020 at 10:15:27AM -0500, Theodore Y. Ts'o wrote: > On Sun, Dec 06, 2020 at 02:44:16PM +0000, Colin Watson wrote: > > Now that I look at it more closely, some of the changes to > > clean_grub_dir_real look suspicious: > > > > + char *srcf = grub_util_path_concat (2, di, de->d_name); > > + > > + if (mode == CREATE_BACKUP) > > + { > > + char *dstf = grub_util_path_concat_ext (2, di, de->d_name, "-"); > > + if (grub_util_rename (srcf, dstf) < 0) > > + grub_util_error (_("cannot backup `%s': %s"), srcf, > > + grub_util_fd_strerror ()); > > + free (dstf); > > + } > > ... however, if I'm understanding the code correctly, this is the > codepath used to create the backup file (e.g., the previous version of > boot.img). So shouldn't there be a "boot.img" file in > /boot/grub/i386-pc which would be the newly installed version of that > file, and so the system would actually be booting correctly? Not quite. What's described here as "backup/restore" thing is used as follows: * rename old modules aside as a backup * do the rest of the installation (writing to the MBR or similar, as well as copying in new modules) * if installation succeeds, remove the backup files * if installation fails, then: * remove the newly-created modules * move the backup files back into place But if the restored file names are computed wrongly, then this leaves the system in a bad state as Paul described. I don't know why Dimitri chose to explicitly remove the new files first rather than just renaming over the top and then removing any leftovers at the end; that seems unnecessarily risky. Though this is code that's apparently supposed to work on Windows as well, and the MoveFile function that's used to implement grub_util_rename there requires the destination file not to exist (sigh), so maybe it had something to do with that. > Essentially, there are three possibilities: > > 1) A hardware corruption which corrupted the directory. > > 2) A kernel bug which corrupted the directory. > > 3) The file system isn't actually corrupted, but the filename with the > random garbage in the filename was created because a userspace > application so requested it. > > The fact that all of the filenames have the a similar pattern of > corruption to them would tend to rule out #1. And the fact that > e2fsck didn't notice any other corruptions would tend to argue against > #1 and #2. So #3 does seem to be the most likely. Yep. -- Colin Watson (he/him) [cjwatson@ubuntu.com]