Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp28268pxb; Wed, 29 Sep 2021 20:07:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKMsYDIofWcPg5ozqFKPFRmjn/HFQVV4FmxkGtjmztyjPqSyicd2ooir7KgAdC+MKGeYVe X-Received: by 2002:a17:907:20f8:: with SMTP id rh24mr3858636ejb.526.1632971236635; Wed, 29 Sep 2021 20:07:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632971236; cv=none; d=google.com; s=arc-20160816; b=Trb1+GRfW49r+un2QHepcVCLWSXzURb+h1U7UUrvK7ZMBe7W0LkJTk0ISOje8G/hel TKszXEnY784wXspnU1C9bhNaq01m6TYADuWwszs5i9gKqZGDrvNzUvk2ZRRXLRDdTqlp AKokf03BIjEQEJ4XU18wMGHl7mJ8iFzVDrce2TTjjTZsutvLFCr++AJJjy8p29+BEd7I pesLXLeWoswH3tkMw0MYiqA7UoAEyHlEzX8QIK9r9vHReHo1Vs23d1OUDCqiyMTmzVDY 1+jbTp+ywbMTTUFlt9wZ7uisLUP0wX2M5C6eOmhGEpGGcbneeP8HeWgVU57EWfmOyDrs 6j3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=C3icfHV8rziphpmZsPVo5VvYUU+r4uhS/fnY11daDVU=; b=Z+AREm2vMf16WgsJOB3ltqT67TPvBolNL/eeu7thLW5JkFpVZEKNvVbVS+3R3JfdrA Oy7MDbuD7kRCxvwxgiI/Ng0i+/JGZWL+nOKbUat5T36QDzdpNm3TO25y0Z/Wfsyv3IAf wuq32p4g4ndRp+0L4Rmy3eZ0KA0H3uIxmWDv4kvIZWjZpEWc+TCKOn8eA7knBV7U1pL1 fq78tUdQszwRnI8px1iMm2EcQW1UxIj123fNyL+WUz+CVo7HMk5oMJ+8EZ80VSoKPe9D 2HUx6p9e/ICfxBoUwP8ipPev87c+TDwdVRlENridJ01o0x5iQAQsdZQr8HBEIGf4spWz hh3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20210112.gappssmtp.com header.s=20210112 header.b=BsTyfe3M; 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 ca23si2503837edb.35.2021.09.29.20.06.53; Wed, 29 Sep 2021 20:07:16 -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=@kernel-dk.20210112.gappssmtp.com header.s=20210112 header.b=BsTyfe3M; 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 S1347819AbhI3Cdw (ORCPT + 99 others); Wed, 29 Sep 2021 22:33:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347759AbhI3Cdv (ORCPT ); Wed, 29 Sep 2021 22:33:51 -0400 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06C2AC06161C for ; Wed, 29 Sep 2021 19:32:10 -0700 (PDT) Received: by mail-io1-xd2d.google.com with SMTP id i62so5690986ioa.6 for ; Wed, 29 Sep 2021 19:32:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20210112.gappssmtp.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=C3icfHV8rziphpmZsPVo5VvYUU+r4uhS/fnY11daDVU=; b=BsTyfe3MEXlmmuEqY2A0DBWVcv0KQjH3UQvRb8ylvQxdS36BVtLsKP0cgaKrxAidUp DlMFioCBU5rx+XarWdBaMaDbdQNQ+ory9j1MY1WTUqtUfzI+hAX2JqKgATC3HqLy8eIe 565U9RN9A5bOj+Jxy+QoPe8STtb0kcULmBDw+Nxi64SivK9o6Os3cEUQZEUnJUq3Nef5 kstwOVz7C1xHXkJjnnydbcySksgU1F11XpF3l/P0YDgVoC/dNFh+ZRdhk6JnP5gm9dwA GLC+SmvjYAXoNlpFnBm3p5D1xIu1Ei9qoaJEHAT0H7AMGrlQEiOa0G+/bjDdQ5VS79Fu WBuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=C3icfHV8rziphpmZsPVo5VvYUU+r4uhS/fnY11daDVU=; b=jz45oVsP5kqznhSs/DcqKiwjD8cNys+LoEzTeW8jBlGPOaAtxnpBQfvYOP5i23iF5/ GOtcHrNw/ezmNJ+E2p/umggiiluRcBgD5RMLl2+Ps7ZPKzJy0bYWJQxi/xl/129hjakp ui7V82ufS4HNhzR4p9+lDWrfWroRAsaPKq2E1IIBf8MFjn3u9XNbVXRCU5dtct3XhXSE a5U3NdZ5vsGbGsZ+kHCFIitAFQu4ysyNnC2UznjfB+sJLYr/5SKk51I0oTYDiyZRY8+V rgUixRnhBy4LaR+SBD/SqSj0oNgFam0q72D5TZidpaSmmK8P1aQ5uciGeM+6mGjOr0N4 uQVw== X-Gm-Message-State: AOAM533GFVtnYHjMasOpJFvCrhg5TmobmxUSMjJbSwKCyjy0g3mvlDC9 sqIjdJctgQPA6gVg7lxZo7SFkw== X-Received: by 2002:a02:cd17:: with SMTP id g23mr2644168jaq.29.1632969129295; Wed, 29 Sep 2021 19:32:09 -0700 (PDT) Received: from [192.168.1.116] ([66.219.217.159]) by smtp.gmail.com with ESMTPSA id o9sm876691iob.15.2021.09.29.19.32.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Sep 2021 19:32:08 -0700 (PDT) Subject: Re: [PATCH] nbd: use shifts rather than multiplies To: Nick Desaulniers , Josef Bacik Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Rasmus Villemoes , Naresh Kamboju , Nathan Chancellor , Stephen Rothwell , Kees Cook , Linus Torvalds , Pavel Machek , linux-block@vger.kernel.org, nbd@other.debian.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev References: <20210920232533.4092046-1-ndesaulniers@google.com> From: Jens Axboe Message-ID: Date: Wed, 29 Sep 2021 20:32:07 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210920232533.4092046-1-ndesaulniers@google.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/20/21 5:25 PM, Nick Desaulniers wrote: > commit fad7cd3310db ("nbd: add the check to prevent overflow in > __nbd_ioctl()") raised an issue from the fallback helpers added in > commit f0907827a8a9 ("compiler.h: enable builtin overflow checkers and > add fallback code") > > ERROR: modpost: "__divdi3" [drivers/block/nbd.ko] undefined! > > As Stephen Rothwell notes: > The added check_mul_overflow() call is being passed 64 bit values. > COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW is not set for this build (see > include/linux/overflow.h). > > Specifically, the helpers for checking whether the results of a > multiplication overflowed (__unsigned_mul_overflow, > __signed_add_overflow) use the division operator when > !COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW. This is problematic for 64b > operands on 32b hosts. > > This was fixed upstream by > commit 76ae847497bc ("Documentation: raise minimum supported version of > GCC to 5.1") > which is not suitable to be backported to stable. > > Further, __builtin_mul_overflow() would emit a libcall to a > compiler-rt-only symbol when compiling with clang < 14 for 32b targets. > > ld.lld: error: undefined symbol: __mulodi4 > > In order to keep stable buildable with GCC 4.9 and clang < 14, modify > struct nbd_config to instead track the number of bits of the block size; > reconstructing the block size using runtime checked shifts that are not > problematic for those compilers and in a ways that can be backported to > stable. > > In nbd_set_size, we do validate that the value of blksize must be a > power of two (POT) and is in the range of [512, PAGE_SIZE] (both > inclusive). > > This does modify the debugfs interface. Applied, thanks. -- Jens Axboe