Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4564479pxv; Tue, 6 Jul 2021 04:10:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqkP4AtdPJCiffENsPJAlsIFrFyOeoesyRlY+QOLxnrRUkrz3N6gYxTuMGTLi7KKBxuc3/ X-Received: by 2002:a17:906:5a73:: with SMTP id my51mr16419230ejc.319.1625569817288; Tue, 06 Jul 2021 04:10:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625569817; cv=none; d=google.com; s=arc-20160816; b=ARdFcI+Uq83kYkBGkBRY3i7Pweo7KvDZzc48MTkGEj7G7Vb1FxkTUQXmxutSQAwNK2 +9l/+ANIzSI/SD0OFxGhb7ayxX8vAv1oTAf4jSk/RpNHysLuiV7BTCsFbX4Sqj5wPeXj LkL8OsXmDZsle20udoYywHyCHCYNWh80y991jDzvxLavkHdJmPhnlh09yuN7qsHimoi8 6jwrFS7Lx7nRyczribftteoVGprwM0Qs8lW2YtcvsdVVM0kYEbz/AnxXeUGSe7A9XrNU xs/xZS+UXuTI1wKBMNX+XwIu1/MsaytASmKYMLbmiqvWnfCJTLRMLk/YOn3MVhoRXXmJ 5tow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ujhsZIEffiBU8YDQW2JxEemVJB22hCG0N5jEdqMO6sY=; b=blJIQA+RqIDELw4Qnzu2SpofdNin0mBKChAsxRrjnfZCntSlw2Q0QqzJiEoa9XYUdR RoEoljuMVnUFAhl0hR9LQDelJTLAEzBNKuuCozMpTY6javyWz468JAIQeOeks3wHnvJX ql8i4By+RmxxS6a8oCH5gLRlBLUlCLviBTDdHmxQBPdmL6AEXRXSpuY0jL/ot4OWtqwC /5esaGtLpJSP1AtyhYPL/l32+8xm4y4rO8uYAvcxDbKFIBQTIMMB1xa0ZUsiYx954KET TOpABXMReEuZG4IRPi7h+5L5XlfgTLmatk92UEeVixgoznNzW2L8g++jUBnZNDBK+V4v VwxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=oHTNsFlv; 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 f11si14508889ejk.138.2021.07.06.04.09.53; Tue, 06 Jul 2021 04:10:17 -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=@infradead.org header.s=casper.20170209 header.b=oHTNsFlv; 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 S231727AbhGFLLW (ORCPT + 99 others); Tue, 6 Jul 2021 07:11:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229834AbhGFLLV (ORCPT ); Tue, 6 Jul 2021 07:11:21 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EBEDC061574; Tue, 6 Jul 2021 04:08:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=ujhsZIEffiBU8YDQW2JxEemVJB22hCG0N5jEdqMO6sY=; b=oHTNsFlvR32AIvh3SJZS+oIKYM N/D7UTCrnz4Efptg6IgjxFJNuVX2VsZi7A3VcMx6bXy0bebWiNRzvO2KaS90p4FO1Qo6X+pCW1pRi DX9Uk+MWeLXpIIYqyAr7Id0a5+LVsVefLII4v9w8UX7eQfXKW4LOr+R5/Zgh8CtO3R7LyiZJruzhq fTaDV4JxeCigEKhsRnIA9gGuZmhICV/SRALP2ToY3GPALHUI7tZaVCoNvPeFPY5q1sPYom1YyjUK3 yAYq8hLUFi0BP7Oox2P6guqXozOFtzV/yaLDhqYbKtXBZM1RgraQ7udD/VaRolaydb40+hbAFZvd6 f2Y9xEWg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m0iw2-00BAUP-KO; Tue, 06 Jul 2021 11:08:17 +0000 Date: Tue, 6 Jul 2021 12:08:14 +0100 From: Matthew Wilcox To: "Leizhen (ThunderTown)" Cc: Christoph Hellwig , "Darrick J . Wong" , linux-xfs , linux-fsdevel , linux-kernel Subject: Re: [PATCH -next 1/1] iomap: Fix a false positive of UBSAN in iomap_seek_data() Message-ID: References: <20210702092109.2601-1-thunder.leizhen@huawei.com> <492c7a7b-6f2e-de45-c733-51c80422305e@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <492c7a7b-6f2e-de45-c733-51c80422305e@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 05, 2021 at 11:35:08AM +0800, Leizhen (ThunderTown) wrote: > > > 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. We use -fwrapv on the gcc command line: '-fwrapv' This option instructs the compiler to assume that signed arithmetic overflow of addition, subtraction and multiplication wraps around using twos-complement representation. This flag enables some optimizations and disables others. > lseek(r1, 0x8000000000000000, 0x3) I'll see about adding this to xfstests ...