Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2172551ybl; Thu, 9 Jan 2020 08:06:19 -0800 (PST) X-Google-Smtp-Source: APXvYqx5aYYlMp8N4cbKwcELje2P4SSfVe5AvbO9IGZ2UxMuHu5D/YCc6I1ZaabKrX3SeByHj1/E X-Received: by 2002:a9d:6196:: with SMTP id g22mr9378884otk.204.1578585979226; Thu, 09 Jan 2020 08:06:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578585979; cv=none; d=google.com; s=arc-20160816; b=al0DaUqijmz9CtAy3WXc6YKkqwdQ/g1UbCAoMhaZzmAazC6vCn+8Kuo472fCRxD5l+ D9ZhvR1rssAF18RrPwOPLDqqe3e7AxbFY0ZeEqlToULMQ3QZ4hXzulAA6Rms1rbK2MoT Ur2nD3NxgSnualQVwog8T2KM1qNLh86qTim7Nd6B5qFkbGw6wm35Jmsww5XGfXkD56mv qMapEwdDUNwyaXGFRJCWmvtCN2fpuN2GH+aG4W0uQZeRunOPE52hPndz4DzLb82KioAt S8lK/fhku2pVnKWxMPlIhgVvE2OZXCiFO2m23Th0RmIjZcFNJSgFZl+IHU6L07FL/kse SLfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:message-id:date:in-reply-to:subject:cc:to:from; bh=vNJ7xxHp6G7KOZQAlP+LTJPVKsD0NggjzwTRBeP1UK0=; b=0/ZIZrzyHYwN2nyS/FXSt/1lL3HQT9LXfsNmOQ/h4zcCfiTVKDs0A40XrsXay1VaCQ LZGwQ/WvYDQ6/IPo9LOVSqJZgdmpZ9aSxly3pXDWyYVQkxjMMWlRYd/3K7cvsIFcvEv2 eDjsiom7OY6NKsYHbW6wg2NLoWq0kCFo99rTdpg7s4X/Rp/5tDAWWCTmvP/aVienaPJ/ yHdiiRkYfe0edoPd3azuJxr4pXLXSSvD4/MHaXlFsilEJENPxZdaLytfLRZiM1ZozmFe 4prlug8oP59mDuSL95o/i2GOzvvfgvOgCDTgRDSy/4vJj2e3wCTfpVsosu+WaZcwjL9f tWnQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f4si4174712oto.169.2020.01.09.08.05.52; Thu, 09 Jan 2020 08:06:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731539AbgAIOMd convert rfc822-to-8bit (ORCPT + 99 others); Thu, 9 Jan 2020 09:12:33 -0500 Received: from mx2.suse.de ([195.135.220.15]:48312 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731527AbgAIOMd (ORCPT ); Thu, 9 Jan 2020 09:12:33 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id BEE25B2F31; Thu, 9 Jan 2020 14:12:25 +0000 (UTC) From: Nicolai Stange To: Kalle Valo Cc: huangwenabc@gmail.com, linux-wireless@vger.kernel.org, Takashi Iwai , Nicolai Stange , Miroslav Benes Subject: Re: [PATCH] libertas: Fix two buffer overflows at parsing bss descriptor In-Reply-To: <20191122052917.11309-1-huangwenabc@gmail.com> Date: Thu, 09 Jan 2020 15:12:24 +0100 Message-ID: <87woa04t2v.fsf@suse.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Hi, the patch queued as e5e884b42639 ("libertas: Fix two buffer overflows at parsing bss descriptor") at the wireless tree doesn't look completely correct to me. This hunk here... diff --git a/drivers/net/wireless/marvell/libertas/cfg.c b/drivers/net/wireless/marvell/libertas/cfg.c index 57edfada0665..c9401c121a14 100644 --- a/drivers/net/wireless/marvell/libertas/cfg.c +++ b/drivers/net/wireless/marvell/libertas/cfg.c @@ -1775,9 +1782,12 @@ static int lbs_ibss_join_existing(struct lbs_private *priv, if (!rates_eid) { lbs_add_rates(cmd.bss.rates); } else { - int hw, i; - u8 rates_max = rates_eid[1]; - u8 *rates = cmd.bss.rates; + rates_max = rates_eid[1]; + if (rates_max > MAX_RATES) { + lbs_deb_join("invalid rates"); + goto out; ... makes the error path skip over the rcu_read_unlock() following later in the code and leaves the RCU read section unbalanced. Also, I'm wondering if ret should perhaps get set to some -Exxxx in case of rates_max > MAX_RATES? Thanks, Nicolai + } + rates = cmd.bss.rates; for (hw = 0; hw < ARRAY_SIZE(lbs_rates); hw++) { u8 hw_rate = lbs_rates[hw].bitrate / 5; for (i = 0; i < rates_max; i++) { -- SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg), GF: Felix Imendörffer