From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C55BC433DB for ; Thu, 24 Dec 2020 01:15:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 15BCE22517 for ; Thu, 24 Dec 2020 01:15:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728515AbgLXBPP (ORCPT ); Wed, 23 Dec 2020 20:15:15 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:9921 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728141AbgLXBPP (ORCPT ); Wed, 23 Dec 2020 20:15:15 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4D1XCH4kqdz7KN4; Thu, 24 Dec 2020 09:13:47 +0800 (CST) Received: from [10.174.176.185] (10.174.176.185) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.498.0; Thu, 24 Dec 2020 09:14:21 +0800 Subject: Re: [PATCH v2] ubifs: Fix read out-of-bounds in ubifs_jnl_write_inode() To: Richard Weinberger , Chengsong Ke CC: Sascha Hauer , linux-mtd , linux-kernel , wangfangpeng1 References: <20201223121536.6244-1-kechengsong@huawei.com> <244303467.160590.1608764840819.JavaMail.zimbra@nod.at> From: Zhihao Cheng Message-ID: Date: Thu, 24 Dec 2020 09:14:20 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <244303467.160590.1608764840819.JavaMail.zimbra@nod.at> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.176.185] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2020/12/24 7:07, Richard Weinberger 写道: >> Reproducer: >> 0. config KASAN && apply print.patch >> 1. mount ubifs on /root/temp >> 2. run test.sh > > What does test.sh do? Go to Link: https://bugzilla.kernel.org/show_bug.cgi?id=210865. test.sh creates a very long path file test_file, and then create a symbol link link_file for test_file, so ubifs inode for link_file will be assigned a big value for ui->data_len. When we change atime for link_file, ubifs_jnl_write_inode will be executed by wb_writeback. By this way, write_len could be not aligned with 8 bytes. > >> 3. cd /root/temp && ls // change atime for link_file >> 4. wait 1~2 minutes >> >> In order to solve the read oob problem in ubifs_wbuf_write_nolock, just align >> the write_len to >> 8 bytes when alloc the memory. So that this patch will not affect the use of >> write_len in other >> functions, such as ubifs_jnl_write_inode->make_reservation and >> ubifs_jnl_write_inode->ubifs_node_calc_hash. > > I gave this a second thought and I'm not so sure anymore what exactly is going on. > The problem is real, I fully agree with you but I need to dig deeper into > the journal and wbuf code to double check that we really fix the right thing > and not just paper other something. > > Thanks, > //richard > . >