Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp375873ybv; Sat, 22 Feb 2020 05:27:33 -0800 (PST) X-Google-Smtp-Source: APXvYqzTm/WiFQEzr8lM4lnOTqvYZ8ofm6ZNrAZUZQKR//9m1m5RqJ66xBbVJzcADn5qW6D2D0+h X-Received: by 2002:a05:6830:1e6b:: with SMTP id m11mr33859954otr.293.1582378053433; Sat, 22 Feb 2020 05:27:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582378053; cv=none; d=google.com; s=arc-20160816; b=kBrWkkzGJjxPbFwKpjrkSjDi469MPR0cUvJHQqVbBDHRysqU0fMSdVWQIqznMf8HDQ UASsmePHUJUlZBKE0s07d2THta5a5wzqYK9CZcu0ydQ0TixdbLqBvTjtB9TbShwQEwRP IsOrwLw1ejxKC/wJbR/faXC7LmdWOvlCLmA2KVhrlnojoHg4MXMxLCaDs9yN0nxWzamx CunPVCVWxo8cggwlZBcnCQeNYuxpNSUqXpXm2BZr1S8l6zZV1kpQD/yOB9FlvfzaTu38 1JyMRTlbWwO5C17twCZo2WQfPpHMQueuJui1vvAZhBFuma51SulNfNh/dMoZIxhyff0g fsvw== 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 :message-id:date:subject:cc:to:from:dmarc-filter:dkim-signature; bh=uGb4PD3+QgbOk5IT0XjgVnounPn0xPFqQJE3vMqnfvs=; b=egJkyWhM0yB9e44SKzX0enMkp3pYF2bytZJ1VhL/aAYu8bHyJifAmgr2nmHZccHmFc bE0rA9O+AirO20Sye4+CQ4eKKrSo9R2N9y0AlRZRKMIkSw85e6x4eC/AvlNaRKk1/ONL vPrP89jQpL0FBgS82Lq9Sku3/BaNZjDYhoxnB+UtPYpsAtxORIafccBSg66JgZ8SdjOq xXTi0g/i0fsS4kcck/kOxUzIuBazoBikGzqJKp6wJHxdweIYVJ6M1gW933Wj9v5Hw6eE i/CMZvgHsDFSRMZVWOX+narL2L17Y35K8f+veIxqMxzA5936wspzH3SqG+4RX3va8KnI p0Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=ipJzOaWF; 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 z73si2534631oia.40.2020.02.22.05.27.22; Sat, 22 Feb 2020 05:27:33 -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; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=ipJzOaWF; 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 S1727030AbgBVN1R (ORCPT + 99 others); Sat, 22 Feb 2020 08:27:17 -0500 Received: from mail27.static.mailgun.info ([104.130.122.27]:52818 "EHLO mail27.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726839AbgBVN1Q (ORCPT ); Sat, 22 Feb 2020 08:27:16 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1582378036; h=Content-Transfer-Encoding: MIME-Version: Message-Id: Date: Subject: Cc: To: From: Sender; bh=uGb4PD3+QgbOk5IT0XjgVnounPn0xPFqQJE3vMqnfvs=; b=ipJzOaWFsgGW9zCKHZHqMcv3xZP4Sk1MqtYQLyqY5cS1HdFyS82NNiLs06+0olzzsAyvNTFN rkYfft78s3aMpTrQgfZ79S2CeKNJz1ltuZDLU+Q3SI2aPrw/3DVXRfiMbpaS+u54JAgh1vq7 UA17RXF4RNeN/VzBRHiTid9WHMo= X-Mailgun-Sending-Ip: 104.130.122.27 X-Mailgun-Sid: WyI3YTAwOSIsICJsaW51eC13aXJlbGVzc0B2Z2VyLmtlcm5lbC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e512c2b.7fe2ead8dce0-smtp-out-n01; Sat, 22 Feb 2020 13:27:07 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id BD5E4C4479C; Sat, 22 Feb 2020 13:27:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from jouni.codeaurora.org (176-93-35-56.bb.dnainternet.fi [176.93.35.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: jouni) by smtp.codeaurora.org (Postfix) with ESMTPSA id 305E4C43383; Sat, 22 Feb 2020 13:27:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 305E4C43383 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=jouni@codeaurora.org From: Jouni Malinen To: Johannes Berg Cc: linux-wireless@vger.kernel.org, Jouni Malinen Subject: [PATCH 1/7] cfg80211: More error messages for key addition failures Date: Sat, 22 Feb 2020 15:25:42 +0200 Message-Id: <20200222132548.20835-1-jouni@codeaurora.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org These were helpful while working with extensions to NL80211_CMD_NEW_KEY, so add more explicit error reporting for additional cases that can fail while that command is being processed. Signed-off-by: Jouni Malinen --- net/wireless/nl80211.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index f0112dabe21e..447c388b5905 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -3980,8 +3980,10 @@ static int nl80211_new_key(struct sk_buff *skb, struct genl_info *info) if (err) return err; - if (!key.p.key) + if (!key.p.key) { + GENL_SET_ERR_MSG(info, "no key"); return -EINVAL; + } if (info->attrs[NL80211_ATTR_MAC]) mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); @@ -3995,8 +3997,10 @@ static int nl80211_new_key(struct sk_buff *skb, struct genl_info *info) /* for now */ if (key.type != NL80211_KEYTYPE_PAIRWISE && - key.type != NL80211_KEYTYPE_GROUP) + key.type != NL80211_KEYTYPE_GROUP) { + GENL_SET_ERR_MSG(info, "key type not pairwise or group"); return -EINVAL; + } if (key.type == NL80211_KEYTYPE_GROUP && info->attrs[NL80211_ATTR_VLAN_ID]) @@ -4007,15 +4011,22 @@ static int nl80211_new_key(struct sk_buff *skb, struct genl_info *info) if (cfg80211_validate_key_settings(rdev, &key.p, key.idx, key.type == NL80211_KEYTYPE_PAIRWISE, - mac_addr)) + mac_addr)) { + GENL_SET_ERR_MSG(info, "key setting validation failed"); return -EINVAL; + } wdev_lock(dev->ieee80211_ptr); err = nl80211_key_allowed(dev->ieee80211_ptr); - if (!err) + if (err) + GENL_SET_ERR_MSG(info, "key not allowed"); + if (!err) { err = rdev_add_key(rdev, dev, key.idx, key.type == NL80211_KEYTYPE_PAIRWISE, mac_addr, &key.p); + if (err) + GENL_SET_ERR_MSG(info, "key addition failed"); + } wdev_unlock(dev->ieee80211_ptr); return err; -- 2.20.1