Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3735637pxv; Mon, 5 Jul 2021 04:35:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCZsV9AT46ujZXhxxQbVnEHBqf7LGEPPdX/ObeUaUwgayaqTH8+XLRCEPe+woxXcUhuaoW X-Received: by 2002:a17:906:c208:: with SMTP id d8mr12959082ejz.67.1625484910011; Mon, 05 Jul 2021 04:35:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625484910; cv=none; d=google.com; s=arc-20160816; b=VJsZuZs/EGaRaQEJb/bjHMaBIUZ/7kQJPk0Y0atHjhGoOeBT0tWa7No+1bxVJvcrv/ r/ynJn+j7VWmsihd7fzE03RTSsb0G1Am3Bta6DyJpDYipmCbuTfJ0Ma1qLKEMRLJhfCu AOW0IMlNlafT80/TQogdIz+f+DgpAydsgroQSJLTAQwrRTyxbhJvTnrvmX5QPSg6beKJ 3hX8m22EU6M9GMOZZ3/QsdjH+kS3+AbmeuFMV4A6XaNNwlS0wld/cV6WWceFecly2MtP NOX+TM8/sNEHEz97eINSlyAMWycjROMKef8SX2U8foA56HOWv4Cr0+H0nNl1hFfRgkMq 14QQ== 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 :dkim-signature:dkim-signature; bh=6J7FT459w1mR+ClPDnP6dAqMfQqmMt7HkiwXcKAL8XI=; b=QfeH8+hPT/EXZeWDMVKJ6dKJ2Ofy3b9CnCB3CaNZQTUYZaF34hMlNr6LKH7P369hQC FqDfQBjWVxZpPRK9EJJZkngTu7qofKXq+5E1YL/XBVJcvL0Ddy0xVKrEIMz+3MoEAgWy bhTDXYNrwuZMnVsvc9adlQiXxMBS3IfWh87PbzlWTad+iyb3Jy08/BNT8vKHHoLV0dWf fTcaw00u4jOdlSuBh+x4PnAVT2pTPvVHH3aE5e+8/oRQ3YfYCWn2i/ftEo3CRVeyTqO1 HmXQBvHmanRXRQEsV2hxFD0RqfFDMC4IO+utUntY3/QcIkwSyKkAulXKbQjpJHGug6Fx oCLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=SoLAuhDi; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b="FCGD4j/J"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 18si11396488ejj.476.2021.07.05.04.34.46; Mon, 05 Jul 2021 04:35:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=SoLAuhDi; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b="FCGD4j/J"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231292AbhGELgH (ORCPT + 99 others); Mon, 5 Jul 2021 07:36:07 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:56158 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231126AbhGELgH (ORCPT ); Mon, 5 Jul 2021 07:36:07 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 4F8EC21CAE; Mon, 5 Jul 2021 11:33:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1625484809; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6J7FT459w1mR+ClPDnP6dAqMfQqmMt7HkiwXcKAL8XI=; b=SoLAuhDilZO3LZtpt4jux0RYpV8oPebH+RX8X18PzGZv5kY1MJPsmYI5qgSSVgI/o6P8Ww 2zDNZ+tEgEasyx2UslzKa+2A72QjB5mDbsbz5cVliVnZWxzWlZk5GccbhseeWUHc3C7H1X Jnn3qQe7LBsdeNq7ifY8aZuaigMbyNM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1625484809; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6J7FT459w1mR+ClPDnP6dAqMfQqmMt7HkiwXcKAL8XI=; b=FCGD4j/JA9AbbAcGHJZJIvK176cGAglcunPYzX8aqLIV8Yi6FnFew7rQ10B3CHdyUeFhuI EHHnJseAY3sdGGAA== Received: from quack2.suse.cz (unknown [10.163.43.118]) by relay2.suse.de (Postfix) with ESMTP id 4142CA3B8A; Mon, 5 Jul 2021 11:33:29 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 1C1911E1139; Mon, 5 Jul 2021 13:33:29 +0200 (CEST) Date: Mon, 5 Jul 2021 13:33:29 +0200 From: Jan Kara To: Shreyansh Chouhan Cc: jack@suse.cz, rkovhaev@gmail.com, reiserfs-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: Verify the items that we read from blocks Message-ID: <20210705113329.GE15373@quack2.suse.cz> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello! On Fri 02-07-21 20:35:41, Shreyansh Chouhan wrote: > I was trying to work on this[1] bug. After a lot of reading the code and > running it under gdb, I found out that the error happens because > syzkaller creates a segment with raw binary data in the reproducer[2], > that has the wrong deh_location for the `..` directory item. (The value > is 0x5d (93), where as it should have been 0x20 (32).) First, I'd like to note that reiserfs is a legacy filesystem which gets little maintenance and I think distributions are close to disabling it in their default kernels if they didn't do it already. So I'm not sure how much is it worth it to do any larger fixes to it. But if you have a personal passion for reiserfs feel free to go ahead and try to fix these issues. > I think that the solution would involve checking the items that we read, > and verify that they are actually valid. But this check could actually > happen in two places: > > - First idea would be to check as soon as we read a > block, and one way of doing that would be adding a wrapper around > ll_rw_block that validates the leaf node blocks that we read. The > benifits to this would be that since we're solving the problem at it's > root, very few functions would have to be changed. But I don't know > how much of a performance hit would it be. It depends on how heavy the checks are going to be but generally checking when loading from the disk is the way how most filesystems handle this. > - Second idea would be to do these validation checks lazily. This should > be faster than the first idea, but this would involve changing the > code at more places than in the first idea. > > For how the validation happens, the first idea that comes to mind is > reading the item headers from the block that we read and verifying if > the header is valid, and if the items themselves are valid according to > the header. Looks sound. Honza -- Jan Kara SUSE Labs, CR