Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1728374pxj; Wed, 19 May 2021 12:28:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuOouO9z8Hq3y9St1MC8hKaH5LmNZCAIDNj+FyJlBNOj37NHzmbzpXoElK8SGSOnHir1P9 X-Received: by 2002:a5e:a50c:: with SMTP id 12mr1241606iog.206.1621452490328; Wed, 19 May 2021 12:28:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621452490; cv=none; d=google.com; s=arc-20160816; b=c+5SiwWrXeJvbtbqnsOyi6vACZNajwU1t4wNNvlV7am6pNmrLwdmtyvfjZzB6ktS/7 IgEVKhN3g5yoNvTWXYOu2qmB53V66lFJFH2O8jFtb0fW6LtwpPxrJ9gAxwMuYBmJ/o4B NCjmczT5ESqyrZRiownfRQglAePhheQifMKcOfqux9uz5kLAKLViBeYUQv3omhhf89XF rX06eicAQTPjX14Xf+5VgV4rWf+Q3ZGYqLMtcTcuSyVQ87ok3NVPun5qyA6YPYkKx6KE xIU25S5ux3/izATU3bqBVptTvgEpP0EAnOCPBqc9csOM5U9Tn4Dngi7z9fuEUok+gb8W iSog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=aFTFWpoVJnemd26JPyMF9NefN4HJms0tJ9SpI4ar8Ww=; b=QnT2Znvpa4eibbtyFeaSfzsnZHWb8oxlyKGPQwn3Iq2QF/q8feNHGFHYMRjoWhLmEP LtC9S3S9MQaAhYiNxnz6zCCqk634L2l1fjd9qAh2I2kJsJZQigkTNICoBQjd2FJT+lqS QuB9QM9aXIAH28VavvI2n7JBaOaiSU3/moa2uMGb50nSVEEkUk9d+UCTgAspnw89oMOQ 6OLpChYY+5ZinWuuwgcC/TrIYYdG+Y8aty1hFEkarOq6lTFVEPn7wyz8y75NonYbX4B1 o4yZaTPqt7TR8IeIcloDce0MKCjV0nNdcea9PqJlieoJn+LyAy0QztiFoaK0xQl8lWsY kMBw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a13si156468iok.48.2021.05.19.12.27.58; Wed, 19 May 2021 12:28:10 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239529AbhESKzy (ORCPT + 99 others); Wed, 19 May 2021 06:55:54 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:54828 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238667AbhESKzx (ORCPT ); Wed, 19 May 2021 06:55:53 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1ljJqL-0000Tq-4b; Wed, 19 May 2021 10:54:25 +0000 From: Colin King To: Jaroslav Kysela , Takashi Iwai , David Henningsson , alsa-devel@alsa-project.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] ALSA: rawmidi: fix incorrect array bounds check on clock_names Date: Wed, 19 May 2021 11:54:24 +0100 Message-Id: <20210519105424.55221-1-colin.king@canonical.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King The array bounds check on clock_names is currently checking the size of the entire array rather than the number of elements in the array leading to a potential array bounds read error. Fix this by using the ARRAY_SIZE macro instead of sizeof. Addresses-Coverity: ("Out-of-bounds read") Fixes: 08fdced60ca0 ("ALSA: rawmidi: Add framing mode") Signed-off-by: Colin Ian King --- sound/core/rawmidi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index 4a6534db77d6..6c0a4a67ad2e 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -1679,7 +1679,7 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry, buffer_size, avail, xruns); if (substream->framing == SNDRV_RAWMIDI_MODE_FRAMING_TSTAMP) { clock_type = substream->clock_type >> SNDRV_RAWMIDI_MODE_CLOCK_SHIFT; - if (!snd_BUG_ON(clock_type >= sizeof(clock_names))) + if (!snd_BUG_ON(clock_type >= ARRAY_SIZE(clock_names))) snd_iprintf(buffer, " Framing : tstamp\n" " Clock type : %s\n", -- 2.31.1