[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <s5hturmqmt0.wl-tiwai@suse.de>
Date:   Tue, 12 Jan 2021 14:58:35 +0100
From:   Takashi Iwai <tiwai@...e.de>
To:     Geert Uytterhoeven <geert+renesas@...der.be>
Cc:     Clemens Ladisch <clemens@...isch.de>,
        Takashi Sakamoto <o-takashi@...amocchi.jp>,
        Jaroslav Kysela <perex@...ex.cz>,
        Takashi Iwai <tiwai@...e.com>, alsa-devel@...a-project.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH/RFC 1/2] ALSA: fireface: Fix integer overflow in transmit_midi_msg()
On Mon, 11 Jan 2021 14:02:50 +0100,
Geert Uytterhoeven wrote:
> 
> As snd_ff.rx_bytes[] is unsigned int, and NSEC_PER_SEC is 1000000000L,
> the second multiplication in
> 
>     ff->rx_bytes[port] * 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 ff->rx_bytes[port] <= 16777.
> 
> Fixes: 19174295788de77d ("ALSA: fireface: add transaction support")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@...der.be>
> ---
> 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
Powered by blists - more mailing lists
 
