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=-5.3 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 759F8C07E9A for ; Mon, 5 Jul 2021 03:35:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 55401613E7 for ; Mon, 5 Jul 2021 03:35:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229770AbhGEDht (ORCPT ); Sun, 4 Jul 2021 23:37:49 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:10252 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229700AbhGEDhr (ORCPT ); Sun, 4 Jul 2021 23:37:47 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4GJB542Ccsz1CFNh; Mon, 5 Jul 2021 11:29:44 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) 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.2176.2; Mon, 5 Jul 2021 11:35:09 +0800 Received: from [127.0.0.1] (10.174.179.0) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 5 Jul 2021 11:35:09 +0800 Subject: Re: [PATCH -next 1/1] iomap: Fix a false positive of UBSAN in iomap_seek_data() To: Matthew Wilcox CC: Christoph Hellwig , "Darrick J . Wong" , linux-xfs , linux-fsdevel , linux-kernel References: <20210702092109.2601-1-thunder.leizhen@huawei.com> From: "Leizhen (ThunderTown)" Message-ID: <492c7a7b-6f2e-de45-c733-51c80422305e@huawei.com> Date: Mon, 5 Jul 2021 11:35:08 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.0] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/7/3 3:56, Matthew Wilcox wrote: > On Fri, Jul 02, 2021 at 05:21:09PM +0800, Zhen Lei wrote: >> Move the evaluation expression "size - offset" after the "if (offset < 0)" >> judgment statement to eliminate a false positive produced by the UBSAN. >> >> No functional changes. >> >> ========================================================================== >> UBSAN: Undefined behaviour in fs/iomap.c:1435:9 >> signed integer overflow: >> 0 - -9223372036854775808 cannot be represented in type 'long long int' > > I don't understand. I thought we defined the behaviour of signed > integer overflow in the kernel with whatever-the-gcc-flag-is? -9223372036854775808 ==> 0x8000000000000000 ==> -0 I don't fully understand what you mean. This is triggered by explicit error injection '-0' at runtime, which should not be detected by compilation options. lseek(r1, 0x8000000000000000, 0x3) > > > . >