Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp3081247pxb; Tue, 12 Jan 2021 06:02:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJycjDUi8O4SMou49i/ozhUjTOnBq4K4Tqy+mzECllW/ijZWbyh9r3iJnfMEU8LIA1LQ9kNh X-Received: by 2002:a17:906:a115:: with SMTP id t21mr3290993ejy.549.1610460155479; Tue, 12 Jan 2021 06:02:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610460155; cv=none; d=google.com; s=arc-20160816; b=tqen0X+ZuVpJS2TmfWexNbAU2bB7Yu0FrDdQ1SB8DjQMeIuhhFkyC2RsMHBDwS6dpb EUBUYtnygQAIQojxShXAeCsnap9Yc5C+EzzITMAtclAFvdmJckLf47sXTjgmI9xHYvnD CbTq+p4j07Vu5XsO/deFzVznIiuscNKF2vayC6kmMxIDiRRhay0tYefXapMV9/TRbFQX wZQ7YFwgIxiu1GOguREgQm+VBz02eDWbl9q97Xpd+3XJfyssFtl35WwH6FOQuxrLNjaB Y4GWzf1o8XkZDo546zlN9iX7iuSHxRDuvc2NJjJsPkN4anVq3d1AVBA9GaV4dZfKNLE4 QJ7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date; bh=xXSQX1itjz2lqFiaU5bfEJvwhC+XhvBXEfdxEab317c=; b=ePkeZAkolHJ8Sftz432pAlGekdf/DXPBf3EH2YoUn1u5R32VWywdWkNqHY4XPtWVSy vh76lLWYnP1kRKToqW21ws+g8YyY0GuSqF7sgP798hPDiWBvIYB87rZSArl/5wb/Syaq 2vqiihLQU5B2xDJZpZNxZMenn0YZHsLRvwE11/V/5fPFJN8UfWU6ot4mRV8OtJQ89ARX SULkctz1wpjgycXHYGAKeJmCWFvMLABBiQR8DdJKobLvt5loVaTzdzSXtPrZzr9w+QEB j/CgVVeoOpjo8a9TqShMg2LjDevAALQk/9nU6xBjm1o1kou4NrZ1m4k0n9O3SSixOAbZ PkJQ== ARC-Authentication-Results: i=1; mx.google.com; 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 cq20si1346292edb.563.2021.01.12.06.02.09; Tue, 12 Jan 2021 06:02:35 -0800 (PST) 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; 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 S1729647AbhALN72 (ORCPT + 99 others); Tue, 12 Jan 2021 08:59:28 -0500 Received: from mx2.suse.de ([195.135.220.15]:60202 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726389AbhALN72 (ORCPT ); Tue, 12 Jan 2021 08:59:28 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 0B353AC8F; Tue, 12 Jan 2021 13:58:47 +0000 (UTC) Date: Tue, 12 Jan 2021 14:58:47 +0100 Message-ID: From: Takashi Iwai To: Geert Uytterhoeven Cc: Clemens Ladisch , Takashi Sakamoto , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH/RFC 2/2] ALSA: firewire-tascam: Fix integer overflow in midi_port_work() In-Reply-To: <20210111130251.361335-3-geert+renesas@glider.be> References: <20210111130251.361335-1-geert+renesas@glider.be> <20210111130251.361335-3-geert+renesas@glider.be> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 11 Jan 2021 14:02:51 +0100, Geert Uytterhoeven wrote: > > As snd_fw_async_midi_port.consume_bytes is unsigned int, and > NSEC_PER_SEC is 1000000000L, the second multiplication in > > port->consume_bytes * 8 * NSEC_PER_SEC / 31250 > > always overflows on 32-bit platforms, truncating the result. Fix this > by precalculating "NSEC_PER_SEC / 31250", which is an integer constant. > > Note that this assumes port->consume_bytes <= 16777. > > Fixes: 531f471834227d03 ("ALSA: firewire-lib/firewire-tascam: localize async midi port") > Signed-off-by: Geert Uytterhoeven > --- > Compile-tested only. > > I don't know the maximum transfer length of MIDI, but given it's an old > standard, I guess it's rather small. If it is larger than 16777, the > constant "8" should be replaced by "8ULL", to force 64-bit arithmetic. Applied now. Thanks. Takashi