Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1ozwzb-0004oM-Id for mharc-grub-devel@gnu.org; Tue, 29 Nov 2022 04:33:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ozwzR-0004nE-37 for grub-devel@gnu.org; Tue, 29 Nov 2022 04:33:25 -0500 Received: from szxga03-in.huawei.com ([45.249.212.189]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ozwzO-000492-MQ for grub-devel@gnu.org; Tue, 29 Nov 2022 04:33:20 -0500 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NLxrH2phJzJp0k; Tue, 29 Nov 2022 17:29:51 +0800 (CST) Received: from kwepemm600019.china.huawei.com (7.193.23.64) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 29 Nov 2022 17:33:13 +0800 Received: from [10.136.112.228] (10.136.112.228) by kwepemm600019.china.huawei.com (7.193.23.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 29 Nov 2022 17:33:12 +0800 Subject: Re: Possible memory fault in fs/iso9660 (correction) To: Thomas Schmitt , References: <20221124131740.mioaqoewv6gnag5i@tomti.i.net-space.pl> <29109400204265589390@scdbackup.webframe.org> CC: Daniel Kiper , From: "Fengtao (fengtao, Euler)" Message-ID: <3ad04de3-aece-fa0a-278f-cf30210722b4@huawei.com> Date: Tue, 29 Nov 2022 17:32:56 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <29109400204265589390@scdbackup.webframe.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.136.112.228] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600019.china.huawei.com (7.193.23.64) X-CFilter-Loop: Reflected Received-SPF: pass client-ip=45.249.212.189; envelope-from=fengtao40@huawei.com; helo=szxga03-in.huawei.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-0.257, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Nov 2022 09:33:25 -0000 Hi, Thomas Sorry for the delay, I am also not familiar with ISO format. But, i have check the cdrkit src-code[1] and syslinux src-code[2] I think: (char *) entry < (char *) sua + sua_size - 3 && entry->len > 0 is ok, or: (char *) entry <= (char *) sua + sua_size - 4 && entry->len > 0 [1]:https://github.com/Distrotech/cdrkit/blob/distrortech-cdrkit/genisoimage/diag/isoinfo.c#L373 [2]:https://github.com/geneC/syslinux/blob/master/core/fs/iso9660/susp_rr.c#L145 On 2022/11/24 23:16, Thomas Schmitt wrote: > Hi, > > (Again i Cc t.feng in the hope that the review is not finished yet. :)) > > Daniel Kiper wrote: >> I am not an ISO format expert but your thinking LGTM. > > So you agree that "3" is really the right number if any remaining bytes > fewer than 4 shall be ignored ? > (I don't trust myself, although i made an example with finger counting.) > > >> could you send a patch fixing this issue? > > This should be possible. But how to test ? > > Normal ISOs made with GNU/Linux will cause (entry == sua + sua_size) at > the end of the SUSP data. So provoking the problem and checking whether > it is solved will need a hacked ISO. > I will think about creating such an ISO by help of xorriso and dd. > > > While exploring the SUSP/RRIP entry types which are interpreted by GRUB, > i got to more credulence towards the ISO producer. > E.g. in grub-core/fs/iso9660.c line 404 ff. > > /* The 2nd data byte stored how many bytes are skipped every time > to get to the SUA (System Usage Area). */ > data->susp_skip = entry->data[2]; > > This is a memory fault if (sua_size < 7). I see no check between > sua = grub_malloc (sua_size); > and the read access to entry->data[2]. > > Another example: > grub_iso9660_susp_iterate() calls its parameter hook() without checking > that the alleged entry size is within the range of sua_size. The hook() > function does not get sua_size to check on its own. > > In general: > How mistrusting should GRUB be towards the bytes in the filesystem ? > > > Have a nice day :) > > Thomas > > . >