From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 06CE12C83 for ; Mon, 11 Oct 2021 20:56:25 +0000 (UTC) Received: by mail-ed1-f41.google.com with SMTP id d9so48600401edh.5 for ; Mon, 11 Oct 2021 13:56:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:from:subject:to:cc :references:content-language:in-reply-to:content-transfer-encoding; bh=ou+xUmJ66fQiXPaSvBFHMERJHyRQrKzeVENEuBhsFMw=; b=owW+fhG7GjuwP1vy5pweOXYMtVFuNOKqE9mr2LzmYD4pTxTYggUcNvNs6W/f9y13ep TUYNkj1dOWPbHbdVzOFqUuhKpi4c3SbGhqyy3lqk0HNSmtCmfePBAEwlTbjweruk0CB/ My+jLK+fAhlao8lNRgqVtHqldCwin7KnF0nYQYvZcR8Dr1OSl8HVaex9m/+VkQS8C6V+ mpnNQ+CG3fOUqMOWrOx3uf79IowRQJheFfAQCbsmhw/yn+3Xc4HoU3dnnd9n+FvaCOMk vtiaipsQZxce2wfvh0I+UiXp//NSxEd1ree+UKYvuTWL+4IdG2mxqUT/OACB3Au+IWZ7 Wwqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:from :subject:to:cc:references:content-language:in-reply-to :content-transfer-encoding; bh=ou+xUmJ66fQiXPaSvBFHMERJHyRQrKzeVENEuBhsFMw=; b=ZcDDDftMV60bDLhzsd6X4G5vnqsSgNaeW4H/7SlovQ3KW4Wm0vqsDOiI4YFXr9UfiL e2xtEctKxG40w2zwewhEMA+/d17ElLleKgrk+27nTago6h+FYQJLyt/tdQj9FYEwiFrc S+ujxrg2JSOqnD+/gLeJY2hj20tqd6njt9YBJ9B9/GEVWTosIFK+msILviJ/PGTmUcQC UBzNJui0YJX75fIA8JcIGjcaSxd0tQJIA2vAs4MR3pRCMLtI6Fs9PtcSdxkdeXSWz3H+ 7S8tmrWw4qeMdxxiEScQiuDOeisOuYf8VZpxEyDTtQ+KNL5S7hpjOjG8XpjUJWSvHnuf UeRQ== X-Gm-Message-State: AOAM533KYx0xkqBkbpugkYmyqy5bIOBmJp0OmbWzWof5kkHO+I4WHEnY FEDXApLJv8eU/d0kV3pXIbk= X-Google-Smtp-Source: ABdhPJwSODPcwmzd88n3/Iui5Rdwmxb8aTTUKUAVsLOv+cz4qEqxxTdTPz0CbDqbLD5vNGYWb7JmUQ== X-Received: by 2002:a05:6402:5189:: with SMTP id q9mr19506883edd.94.1633985784310; Mon, 11 Oct 2021 13:56:24 -0700 (PDT) Received: from [192.168.0.163] ([37.239.218.34]) by smtp.gmail.com with ESMTPSA id n6sm4772657eds.10.2021.10.11.13.56.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 11 Oct 2021 13:56:24 -0700 (PDT) Message-ID: <0021ec0c-737a-398f-53ca-8daa284744b6@gmail.com> Date: Mon, 11 Oct 2021 23:56:22 +0300 Precedence: bulk X-Mailing-List: ntfs3@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.2 From: Mohammad Rasim Subject: Re: [PATCH] fs/ntfs3: Check for NULL if ATTR_EA_INFO is incorrect To: Konstantin Komarov Cc: ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Kari Argillander References: <227c13e3-5a22-0cba-41eb-fcaf41940711@paragon-software.com> <20211003175036.ly4m3lw2bjoippsh@kari-VirtualBox> <2998a9b9-8ea0-6a44-7093-66c7a08dcab2@gmail.com> <7e5b8dc9-9989-0e8a-9e8d-ae26b6e74df4@paragon-software.com> Content-Language: en-US In-Reply-To: <7e5b8dc9-9989-0e8a-9e8d-ae26b6e74df4@paragon-software.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 10/11/21 19:55, Konstantin Komarov wrote: > Hello. > > Presumably we found the code, that panics. > But it panics in place, where pointer must be always not NULL. > Please try patch provided below. > If it helps (there is no panic), then check dmesg for > message "Looks like internal error". > And please compare copied folders. > This way it will be clear what file / folder cause this logic error. > > Thanks for all your help so far. Ok, This helped, unfortunately the error is sporadic and i can't easily track down which file caused the crash . In one test it seemd it was caused by files in three directories "package", "system" , "support" (all these directories are from the "buildroot" tree, most of the files that failed to copy were symlinks, don't know if that makes a difference)  but after rebooting and loading the unpatched ntfs3.ko i was able to copy these files without a crash! It seems that the crash happens when copying large number of files so even a failed file can be copied if it was copied alone (I might be very wrong in my conclusion here) anyways, i did multiple tests. in the first a few it copied without a crash and skipped a few files( the dmesg didn't contain the "Looks like internal error" message). on subsequent tests i did get that message like so: [  186.295722] ntfs3: sdb1: ino=1a, Looks like internal error [  186.296219] ntfs3: sdb1: ntfs3_write_inode r=1a failed, -22 That "ino=1a" looks wrong to me !  I will try to do more tests if i can but it's a bit annoying because each crash causes the file system to be corrupted and "ntfsfix" can't fix these errors so i have to reboot to windows os to be able to use "chkdsk" to fix the filesystem before doing the next test. It would be nice if Paragon  releases "fsck.ntfs" that works well in these situations so we don't need to boot to windows to fix them Regards > > [PATCH] fs/ntfs3: Check for NULL pointers in ni_try_remove_attr_list > > All these checks must be redundant. > If this commit helps, then there is bug in code. > > Signed-off-by: Konstantin > Komarov > --- > fs/ntfs3/frecord.c | 23 ++++++++++++++++++++++- > 1 file changed, 22 insertions(+), 1 deletion(-) > > diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c > index ecb965e4afd0..37e19fe7d496 100644 > --- a/fs/ntfs3/frecord.c > +++ b/fs/ntfs3/frecord.c > @@ -705,18 +705,35 @@ static int ni_try_remove_attr_list(struct > ntfs_inode *ni) > continue; > mi = ni_find_mi(ni, ino_get(&le->ref)); > + if (!mi) { > + /* Should never happened, 'cause already checked. */ > + goto bad; > + } > attr = mi_find_attr(mi, NULL, le->type, le_name(le), > le->name_len, &le->id); > + if (!attr) { > + /* Should never happened, 'cause already checked. */ > + goto bad; > + } > asize = le32_to_cpu(attr->size); > /* Insert into primary record. */ > attr_ins = mi_insert_attr(&ni->mi, le->type, le_name(le), > le->name_len, asize, > le16_to_cpu(attr->name_off)); > - id = attr_ins->id; > + if (!attr_ins) { > + /* > + * Internal error. > + * Either no space in primary record (already checked). > + * Either tried to insert another > + * non indexed attribute (logic error). > + */ > + goto bad; > + } > /* Copy all except id. */ > + id = attr_ins->id; > memcpy(attr_ins, attr, asize); > attr_ins->id = id; > @@ -732,6 +749,10 @@ static int ni_try_remove_attr_list(struct > ntfs_inode *ni) > ni->attr_list.dirty = false; > return 0; > +bad: > + ntfs_inode_err(&ni->vfs_inode, "Looks like internal error"); > + make_bad_inode(&ni->vfs_inode); > + return -EINVAL; > } > /*