From patchwork Wed Jul 1 11:18:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalle Valo X-Patchwork-Id: 6702831 Return-Path: X-Original-To: patchwork-ath10k@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D0409C05AC for ; Wed, 1 Jul 2015 11:18:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 240E12066E for ; Wed, 1 Jul 2015 11:18:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 547A02066C for ; Wed, 1 Jul 2015 11:18:52 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZAG2Q-0007uy-Lq; Wed, 01 Jul 2015 11:18:46 +0000 Received: from sabertooth01.qualcomm.com ([65.197.215.72]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZAG2P-0007tJ-B3 for ath10k@lists.infradead.org; Wed, 01 Jul 2015 11:18:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=qca.qualcomm.com; i=@qca.qualcomm.com; q=dns/txt; s=qcdkim; t=1435749525; x=1467285525; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=AoAH6Jsfcw/kQ3XeoVHgvQ87ZbmUxwdfpUzU6zYObrw=; b=Q4tZP3i9S9nWU8laDrafsux8tHKPP4L+lIyGw58xy9si/mpSD1GB5dJg vdqXlNRCOX9eo14g8ExG6XKTyOZ2K4s7fqpSPnXSh1zYi+OPIfmCIPbbI 6nJScF4pxcdz1dQGCNbdTCE9It4eWI+U0PCQ5t3dekt+dZQc/LrwGM99x k=; X-IronPort-AV: E=McAfee;i="5700,7163,7848"; a="91839182" Received: from ironmsg01-lv.qualcomm.com ([10.47.202.180]) by sabertooth01.qualcomm.com with ESMTP; 01 Jul 2015 04:18:24 -0700 X-IronPort-AV: E=Sophos;i="5.15,385,1432623600"; d="scan'208";a="33460304" Received: from nasanexm01g.na.qualcomm.com ([10.85.0.33]) by ironmsg01-lv.qualcomm.com with ESMTP/TLS/RC4-SHA; 01 Jul 2015 04:18:24 -0700 Received: from potku.adurom.net (10.80.80.8) by NASANEXM01G.na.qualcomm.com (10.85.0.33) with Microsoft SMTP Server (TLS) id 15.0.1076.9; Wed, 1 Jul 2015 04:18:22 -0700 From: Kalle Valo To: Raja Mani Subject: Re: [PATCH v2 1/8] ath10k: enhance swba event handler to adapt different size tim bitmap References: <1434984747-24294-1-git-send-email-rmani@qti.qualcomm.com> <1434984747-24294-2-git-send-email-rmani@qti.qualcomm.com> <87h9poxjvs.fsf@kamboji.qca.qualcomm.com> <87d20cxjc0.fsf@kamboji.qca.qualcomm.com> Date: Wed, 1 Jul 2015 14:18:15 +0300 In-Reply-To: <87d20cxjc0.fsf@kamboji.qca.qualcomm.com> (Kalle Valo's message of "Wed, 1 Jul 2015 13:28:47 +0300") Message-ID: <87zj3gw2h4.fsf@kamboji.qca.qualcomm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: NASANEXM01B.na.qualcomm.com (10.85.0.82) To NASANEXM01G.na.qualcomm.com (10.85.0.33) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150701_041845_477690_92D0C7B2 X-CRM114-Status: GOOD ( 13.59 ) X-Spam-Score: -7.6 (-------) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-wireless@vger.kernel.org, ath10k@lists.infradead.org Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Kalle Valo writes: > Kalle Valo writes: > >>> /* if next SWBA has no tim_changed the tim_bitmap is garbage. >>> * we must copy the bitmap upon change and reuse it later */ >>> if (__le32_to_cpu(tim_info->tim_changed)) { >>> int i; >>> >>> - BUILD_BUG_ON(sizeof(arvif->u.ap.tim_bitmap) != >>> - sizeof(tim_info->tim_bitmap)); >>> + WARN_ON(sizeof(arvif->u.ap.tim_bitmap) < tim_len); >> >> I'm worried that this WARN_ON() spams too much so I changed it to: >> >> --- a/drivers/net/wireless/ath/ath10k/wmi.c >> +++ b/drivers/net/wireless/ath/ath10k/wmi.c >> @@ -2893,7 +2893,7 @@ static void ath10k_wmi_update_tim(struct ath10k *ar, >> if (__le32_to_cpu(tim_info->tim_changed)) { >> int i; >> >> - WARN_ON(sizeof(arvif->u.ap.tim_bitmap) < tim_len); >> + WARN_ON_ONCE(sizeof(arvif->u.ap.tim_bitmap) < tim_len); >> >> for (i = 0; i < tim_len; i++) { >> t = tim_info->tim_bitmap[i / 4]; > > Actually I got more worried about this. If tim_len > > sizeof(arvif->u.ap.tim_bitmap) don't we read out of bounds? So we should > actually add return for that case or am I missing something? > > Full code: > > WARN_ON_ONCE(sizeof(arvif->u.ap.tim_bitmap) < tim_len); > > for (i = 0; i < tim_len; i++) { > t = tim_info->tim_bitmap[i / 4]; > v = __le32_to_cpu(t); > arvif->u.ap.tim_bitmap[i] = (v >> ((i % 4) * 8)) & 0xFF; > } I talked with Raja and I changed this now to: --- a/drivers/net/wireless/ath/ath10k/wmi.c +++ b/drivers/net/wireless/ath/ath10k/wmi.c @@ -2893,7 +2893,11 @@ static void ath10k_wmi_update_tim(struct ath10k *ar, if (__le32_to_cpu(tim_info->tim_changed)) { int i; - WARN_ON_ONCE(sizeof(arvif->u.ap.tim_bitmap) < tim_len); + if (sizeof(arvif->u.ap.tim_bitmap) < tim_len) { + ath10k_warn(ar, "SWBA TIM field is too big (%d), truncated it to %d", + tim_len, sizeof(arvif->u.ap.tim_bitmap)); + tim_len = sizeof(arvif->u.ap.tim_bitmap); + } for (i = 0; i < tim_len; i++) { t = tim_info->tim_bitmap[i / 4];