Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp463234pxx; Wed, 28 Oct 2020 08:55:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5tsVMrVkYf9ThS2FI6AiiVRGXeA6P6cbiA2u/Vnm2ISjJuoaNsiVM4F9w01FVUyDXxMtG X-Received: by 2002:a17:907:212d:: with SMTP id qo13mr8095858ejb.288.1603900529717; Wed, 28 Oct 2020 08:55:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603900529; cv=none; d=google.com; s=arc-20160816; b=O432EpXfxz+LZVy6jS0fspcnn5pijyzK9N0uXQ4iIElwuEUEvHb4l+wnwiVu4mxPCR ba/IcOn45rIy31CQ0JLw1QKFI45xmG9m27oXNJaxpwbQ7c8AU/Ti6+r/iwJaMR931AVF 34VPjXaIESCpPvU9RjwTVZh1ZmUfzQRwjQCILC0zk4+UHXuGSNo7j0L1/0it0OLpmyQC 4GPkwTQnS60e49z2bfobRHnhBd1EBtPBKuWQMp8puuOhTao/Vs+fITQtfrFbWje1qVAL eVXCXabK+jiTGV0Fzo9mx0N/MUDcqAJRZWdoFi5VtcxV9pWXu2UZpRIMFpD7mIGHeHOA paZw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CqSShO00HeMjaqnB5S5yWfLyOXHu4mptZtFRaQGxAiY=; b=rNEouugN3dw8ktbmXUF6pe6E0Widq3ie+PD702KcASFR398f0ljUpeSqZVVS8uLSKX JoFkI+gik2mAZ3/JE5W1x6o632BGRguNb0C/cSdUCBwbiIekGqYbP53Zp28E532xYkT0 N/JNl7v3amnaUYdEjwz23r0ZME+riw/WX0BckWNC90voEi+VNjVd7UPxuP2vBDrc+wNv ORCBA4faGeY4VUAkh0tWvKiQqxZV/aSzlf0DoADKFhdUJ+qssRwwEvumvEK6q6GiACuw Ml3/z1hwoAqZU4mko3g9qjfEwII3ObeLClTHstdHs0QUqhfsK+cxjTd2NjpDUXrIfjiT A37A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XIdOmZJB; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs17si3022913ejb.543.2020.10.28.08.55.07; Wed, 28 Oct 2020 08:55:29 -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.org header.s=default header.b=XIdOmZJB; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1813472AbgJ0QuT (ORCPT + 99 others); Tue, 27 Oct 2020 12:50:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:51848 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1794990AbgJ0POs (ORCPT ); Tue, 27 Oct 2020 11:14:48 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CAFF420657; Tue, 27 Oct 2020 15:14:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811687; bh=H4z9I9lFOofqBONBWteLXxjLefx9H4vflLddRM0CAnY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XIdOmZJBWZ4fiUTFik77Em3YvPjYRFt1FQzQ0WvFhNCJpLrX166uSXwq+fa3Xbu2M 8O6DIuoFMD4+n5AfXV0kIUeVr0dcZR5/XZijRvXkOGWsuJZrcRXjai0CjlCDUB4X43 Q6OkHNM7jLFCOoYExCAMyO77HWgA3ieef4eLvl1c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , Ulf Hansson , Sasha Levin Subject: [PATCH 5.8 550/633] mmc: sdio: Check for CISTPL_VERS_1 buffer size Date: Tue, 27 Oct 2020 14:54:53 +0100 Message-Id: <20201027135548.598292809@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 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: Pali Rohár [ Upstream commit 8ebe2607965d3e2dc02029e8c7dd35fbe508ffd0 ] Before parsing CISTPL_VERS_1 structure check that its size is at least two bytes to prevent buffer overflow. Signed-off-by: Pali Rohár Link: https://lore.kernel.org/r/20200727133837.19086-2-pali@kernel.org Signed-off-by: Ulf Hansson Signed-off-by: Sasha Levin --- drivers/mmc/core/sdio_cis.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mmc/core/sdio_cis.c b/drivers/mmc/core/sdio_cis.c index e0655278c5c32..3efaa9534a777 100644 --- a/drivers/mmc/core/sdio_cis.c +++ b/drivers/mmc/core/sdio_cis.c @@ -26,6 +26,9 @@ static int cistpl_vers_1(struct mmc_card *card, struct sdio_func *func, unsigned i, nr_strings; char **buffer, *string; + if (size < 2) + return 0; + /* Find all null-terminated (including zero length) strings in the TPLLV1_INFO field. Trailing garbage is ignored. */ buf += 2; -- 2.25.1