From patchwork Mon May 11 13:05:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 6376501 Return-Path: X-Original-To: patchwork-linux-wireless@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 63E0ABEEE1 for ; Mon, 11 May 2015 13:05:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7DFC9203F4 for ; Mon, 11 May 2015 13:05:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 990392026D for ; Mon, 11 May 2015 13:05:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753469AbbEKNFX (ORCPT ); Mon, 11 May 2015 09:05:23 -0400 Received: from mail-la0-f42.google.com ([209.85.215.42]:34350 "EHLO mail-la0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752023AbbEKNFW (ORCPT ); Mon, 11 May 2015 09:05:22 -0400 Received: by laat2 with SMTP id t2so92606063laa.1 for ; Mon, 11 May 2015 06:05:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tieto.com; s=google; h=from:to:cc:subject:date:message-id; bh=XKM8kMw4lA0UljcrLYbDUDN36R17jhOXqRkFqoQ+gqY=; b=MZApkXSnZi+WoOg++p9kyYCWnGiTXxA30Dz6OCS6Y8tYlvm67uqJ1Dzl9RcocG7zpN JVguW+CyPxVlhfwjMpe3Jk6qYTeh2AVQHRPFcykYzbj5Pzq8MaSmwMppGxj+zHX8Ve+c /4niw5/ktp0cgwVfwQLah0Gu76HhdOuPz9y/Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=XKM8kMw4lA0UljcrLYbDUDN36R17jhOXqRkFqoQ+gqY=; b=kMbKJyeMiRTJlJNsXrMOnDvHi8IG2d+QHIM+jRdJBBV7zmNdMMz5hYlusWs2IvhQVS i75/cWK4CkuD2135a4082fDzRY7b6jf/7dNwI0ot4zmigcBSWRBlMI8BQyJtJ2I6yMCI nKj6nLLfJys43Ivi6HvyEFYeptkjqotLTtoh92wbEcx++hyngqibl5MNDh9auwVSBZyi aP7wyXC9CV9bD/Uq1yBIB9B+725TnrESFrj2GIXufBi+9VsBizmyazlETBOKi1gpyTlk oKjY4t9KP9Qdk2YwAGzDGob9E2cvx5scL33SCr63r+cRgIZssmaZS8WlHHqkwGPAXneb LchQ== X-Gm-Message-State: ALoCoQmqxE4CzC7prysEYdz3POgDZyplYUPyiAs8z8yb0uNC9fx9/hb9j1dogh7OgEDR492wlzuzZehpP+varAHRGHQ5JvO0KRsBImbzvmVbSaRFWDsGuIYiWelRIuZIH6rIQEyX+m/NX8/X6x/dV6sfzOltKBCJjYow8BJnnDxrZ/YM4IVVZx3JoYIbEkTM7eKzSYPpqQkf X-Received: by 10.112.78.105 with SMTP id a9mr7961903lbx.70.1431349520879; Mon, 11 May 2015 06:05:20 -0700 (PDT) Received: from localhost.localdomain ([91.198.246.8]) by mx.google.com with ESMTPSA id zf3sm3042558lbb.2.2015.05.11.06.05.19 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 May 2015 06:05:19 -0700 (PDT) From: Michal Kazior To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, Michal Kazior Subject: [PATCH] mac80211: fix AP_VLAN crypto tailroom calculation Date: Mon, 11 May 2015 13:05:03 +0000 Message-Id: <1431349503-5461-1-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 2.1.4 X-DomainID: tieto.com Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham 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 AP_VLANs may inherit crypto keys from parent AP. Moreover AP_VLANs may have PTK keys of their own. Hence both AP_VLAN sdata and AP sdata must be inspected. Some splats I was seeing: (a) WARNING: CPU: 1 PID: 0 at /devel/src/linux/net/mac80211/wep.c:102 ieee80211_wep_add_iv (b) WARNING: CPU: 1 PID: 0 at /devel/src/linux/net/mac80211/wpa.c:73 ieee80211_tx_h_michael_mic_add (c) WARNING: CPU: 3 PID: 0 at /devel/src/linux/net/mac80211/wpa.c:433 ieee80211_crypto_ccmp_encrypt I've seen (a) and (b) with ath9k hw crypto and (c) with ath9k sw crypto. All of them were related to insufficient skb tailroom and I was able to trigger these with ping6 program. This patch effectively fixes Tx when using AP_VLANs with WEP and WPA in some setups. Signed-off-by: Michal Kazior --- net/mac80211/tx.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 8df134213adf..0887d6e5c424 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -1593,6 +1593,25 @@ static bool ieee80211_tx(struct ieee80211_sub_if_data *sdata, /* device xmit handlers */ +static bool +ieee80211_need_crypto_tx_tailroom(struct ieee80211_sub_if_data *sdata) +{ + struct ieee80211_sub_if_data *parent_sdata; + + if (sdata->crypto_tx_tailroom_needed_cnt) + return true; + + if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN && sdata->bss) { + parent_sdata = container_of(sdata->bss, + struct ieee80211_sub_if_data, + u.ap); + if (parent_sdata->crypto_tx_tailroom_needed_cnt) + return true; + } + + return false; +} + static int ieee80211_skb_resize(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, int head_need, bool may_encrypt) @@ -1600,7 +1619,7 @@ static int ieee80211_skb_resize(struct ieee80211_sub_if_data *sdata, struct ieee80211_local *local = sdata->local; int tail_need = 0; - if (may_encrypt && sdata->crypto_tx_tailroom_needed_cnt) { + if (may_encrypt && ieee80211_need_crypto_tx_tailroom(sdata)) { tail_need = IEEE80211_ENCRYPT_TAILROOM; tail_need -= skb_tailroom(skb); tail_need = max_t(int, tail_need, 0);