Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp250689pxx; Wed, 28 Oct 2020 04:06:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoAnI7ZD5f8XU7eE3pdU8duuQaCY4Mrj6SD8JJ8abHw6Zb8rUPQMMdgIQ+parkyYkh0VN8 X-Received: by 2002:a17:906:3997:: with SMTP id h23mr6735210eje.191.1603883212203; Wed, 28 Oct 2020 04:06:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603883212; cv=none; d=google.com; s=arc-20160816; b=EiSAj9EwdW+Iic2gxwc/oVk+QbfpY7fvUavZKhyJ8iza0aYNLXEYAJbeL/Hh37+Ru2 SRvr4TNSV4OfW4p/Yil08H3vkvTTje6RnfbJe7BCVnEZMywmlUCFbhniW8K4B/p2HB2W 83urhH8o5mgStF0zveFMdFoTx0em3eSafibtqUuuYUytYd3YdGUvbkt6Dml1DLF2C7yA gZPbik6Sl2w2l0gKtJ71xABUFfY6v0Qo3fVpA76w9Y5Mv7TYm4Mnp5X1vG0suC5mpdU/ x1qUYudcKJFmPYcgNh1iJ9k0IgXsmyKp4h2yBOL9HTEUypjqbh+E/wBHNkM03aSxy67Y hgUQ== 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=HLTft7pk0IkY010ffwS6fLUrHp0HUe5o4kRk3BCmjjMc9d0pIaeusKQqhV7Wf9IKfG AyZ2gmGqcfzhFZimeHeN5JOTbYcVsxXlIs1pD+Sq4HveehKb19cfNay2FV2QX0YR2GUo yMLaiCAHdcF99tilJyf+PsbUFtWfe6CJf5HF5QsGebE8HY8H3CzMb+psAle0q3K0mmA/ M4hhhXTuYKX27MdF+apURxsvgxTMzd5i7oz65Wl61j5J5+LfZxzUEhVUJbhQdJ/cpi7z 8zXriKROGMfPTpe1pqz2SC3Si4rzT7JUUv6VOfL1KQqIuFc6tmF0LM4iLh+EFo9cG0KK 9NXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gJPreok7; 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 g1si3663191edn.100.2020.10.28.04.06.29; Wed, 28 Oct 2020 04:06:52 -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=gJPreok7; 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 S1784777AbgJ0O7l (ORCPT + 99 others); Tue, 27 Oct 2020 10:59:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:44142 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762733AbgJ0OoT (ORCPT ); Tue, 27 Oct 2020 10:44:19 -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 7360A206B2; Tue, 27 Oct 2020 14:44:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809859; bh=H4z9I9lFOofqBONBWteLXxjLefx9H4vflLddRM0CAnY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gJPreok7Zq8xW6jRA7Hn+PVkGQ/dnEyDpnlaCmHqOEM6n6ljSoqR2CJ3EsB4OSZsH DGVEsz7A00ydsQyH6LMzOLFRuYhauVcVdeFv5U5pcwf4xBdOyzeFRIKL3UOh4En/2+ Dxp2Kd1P7zAlkjIxKpJvKYVIc7Aoa5eutIn3xLBw= 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.4 343/408] mmc: sdio: Check for CISTPL_VERS_1 buffer size Date: Tue, 27 Oct 2020 14:54:41 +0100 Message-Id: <20201027135510.939650079@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@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