Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp164622pxx; Wed, 28 Oct 2020 01:16:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx94RQ/woxpbY4phBCmOBV9t3agJSha85MtJwAivQlE6+23mS1Pn4g9tmG47a1rVwdQZu04 X-Received: by 2002:aa7:c490:: with SMTP id m16mr6421338edq.298.1603873015250; Wed, 28 Oct 2020 01:16:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603873015; cv=none; d=google.com; s=arc-20160816; b=Nmu6T90NGAN40RKEkTthfJcazP+V0X+zODzlvMv/ER5oiLXHW0HL9KyDm5+lYngCcW 1Di4rBbvpXa7PDUGeRjueOQ445dqaq5vVpysQB29LP6vWMPdeKwHixGSpv+fXUvq2S3n jugeC7qBsCz8jV4AsT/SfIneB1LW9uvArXgf/zIUNnahnygOMnRlz1/kdjswSWR2M5t7 QMCCALIOewKzw9X532WWelKXBP5TNZSD8JurQO3b7rt9Hon7QZq4kdT8sFRaA0Cy4DJ+ uvR8LBwyymxN3V96X1PUP/yI1aUBUpVgaV4CnPxwmlCuYLgtgo/pTJBZa0V9VADY92Jk PulQ== 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=UbUkIAju4RsDzIsDLIx1Q5vI8tYRNla1metJzFpyYo8=; b=B1tjfgWlX/Sb6HpbCXzW+9ZOHyXb4Gwz73AZ1BBPeVXc64YfPwcJKr4VKaQT6gOw3m 74g1aMI3YiObaabYDYDAPMSg23nDLy4OS6uoWD9NvFfybn4pzTdOk3nPI5kL9KlFEF2U zr8cyYYm9ICnR1v2aH3u63dwf1hIJZKfYIvs48q0BiV4ROGKF1TRH/tbnctqaHLdsUR8 mqQgyuCz4c0KMefvV/oy3Mp8wYdiUzuBaKIqrJmqnK4qOM2iUqGkKEw5DsNtScGOQn3M KFPorEH03fnkKw4JEd4pCsrG6UH5jfPXPYc/FJiLNh6n1mhSgIYIlasy8wmtej1Zfl9k YSuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=n15kv+Wc; 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 p90si2749641edd.284.2020.10.28.01.16.33; Wed, 28 Oct 2020 01:16:55 -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=n15kv+Wc; 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 S1753681AbgJ0OB1 (ORCPT + 99 others); Tue, 27 Oct 2020 10:01:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:47716 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753574AbgJ0OAR (ORCPT ); Tue, 27 Oct 2020 10:00:17 -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 BCF7C2068D; Tue, 27 Oct 2020 14:00:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807217; bh=CO+FUODqhobCGWD5uWt+v0rTAV+RLiKHYwAG7UiGCoc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n15kv+WcvZQGIqg4KfYHVGC6u5cgO3NfmfITvCQJS6w10UHvmJXrQB2j0/zb7dKKK tne9f8IaBnlJQK6P1G75/7QDs3i0xhiM2dD0nxgtt+tvNdeOMLgj1wkrEwHiPPuJIb pisFZNKbVu6IgQwr+ZhiZeQNHWrSv7s/EceHu94M= 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.4 085/112] mmc: sdio: Check for CISTPL_VERS_1 buffer size Date: Tue, 27 Oct 2020 14:49:55 +0100 Message-Id: <20201027134904.567636192@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134900.532249571@linuxfoundation.org> References: <20201027134900.532249571@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 8e94e555b788d..8651bd30863d4 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