Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp176364pxx; Wed, 28 Oct 2020 01:41:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyd/+mxreC1vcwnuXEjqsbltT9xRcXscHPd+m4K8w9vCqFbxRXV9ETQVnZKE0X/POLSio5P X-Received: by 2002:a17:906:2f97:: with SMTP id w23mr6780168eji.54.1603874480425; Wed, 28 Oct 2020 01:41:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603874480; cv=none; d=google.com; s=arc-20160816; b=yR4SnRshl/ifQxw8Dcxn6q/pwWFNZyG4LIlteCPZIc+rJMS67UnTNofyXaYfAiK/+5 Mzxwm/0ppZZt7yPi3i7vpWrQ+6U/gQjfm57tvpPtRx0AI6PzvdgND9Evo2w2joI9fMQN 9tXPwvtYGfb0aetmhMW8PLi8pVcUWAdGsl3oXvc8i5rY88ZGDSbgXgjwUsP6cwbp9NGB fHPweZaicB7pkKDBlf9IA2z8Ix7DL+EalnSVniHE8YRJ66qJ77rnamvug8G72UDlWb2b P5oQrB+Zv2PAZwvtJvWnH5nVP/qOv+2rjOabNk7nM8s5oM7NAGEEL5+vUVVBDu9sMQlR 1zsw== 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=LMNiSKV97MG/71LGcrVp2C8TEGFX50IECCvjAlStbIk=; b=D0IjsanHcDY0zMDljhWOz5kRxEB59R4HLyFyfvbPpNdSFvAPBLBXggx6lflit52cfl R+vVNV4y17NB+KRF3ZRrvUzkHi9DNP3YKDTReDZDI4pn7xfiprWm6tFtNIymG16uzqyL BKyAXo0aBJaWtEGJYqwuzh8RVPd8AO0QVNhekaGfrvH3+doYflM128BnQmNwwKx0Ib10 wNlpMA6b4nMrCCXaHs7ENu5SH1RGDepCn2/pja5mTaEprHCka39sTH72oI82IhyqrNw0 zdikSDFCXS1KYRiurK4rtOxZplhTODYC0PUTHud7RHVBgW9cC7PjoXvRINTfHQh5kl1N NxJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IX7MqYst; 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 jr1si3058858ejb.164.2020.10.28.01.40.58; Wed, 28 Oct 2020 01:41:20 -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=IX7MqYst; 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 S1754991AbgJ0OH7 (ORCPT + 99 others); Tue, 27 Oct 2020 10:07:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:56696 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754946AbgJ0OHq (ORCPT ); Tue, 27 Oct 2020 10:07:46 -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 EE3B620757; Tue, 27 Oct 2020 14:07:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807666; bh=KkQt/FvxAA+fdzfTN8UhQWHaftWivf3zZK6bppI139Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IX7MqYst+m1OGZ5xENwgQCb3zQXvbVsTE6FvmcR/o6EM5uHn5g+Qi2rGT80fX0sy4 ofdGQSttip5/qLslxH4rcQu6wz4cN55hCebF94v0NsUTDI730m/ILbmAIKxoZeYz7r snKWOCqZAr27clVkKuOcqg+PBU53dA8aOif09txI= 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 4.9 106/139] mmc: sdio: Check for CISTPL_VERS_1 buffer size Date: Tue, 27 Oct 2020 14:50:00 +0100 Message-Id: <20201027134907.165862669@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134902.130312227@linuxfoundation.org> References: <20201027134902.130312227@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 dcb3dee59fa5f..934c4816d78bf 100644 --- a/drivers/mmc/core/sdio_cis.c +++ b/drivers/mmc/core/sdio_cis.c @@ -30,6 +30,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