Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2853664rwd; Fri, 2 Jun 2023 16:07:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4VJCJ4qHZXgRvxE16nVPLrAhQZkInOBO6hL7UsdaG4A5QhRPb1nny2OD7zI4lsGQKLJ4y/ X-Received: by 2002:a17:90a:664d:b0:252:977e:c257 with SMTP id f13-20020a17090a664d00b00252977ec257mr864719pjm.23.1685747240511; Fri, 02 Jun 2023 16:07:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685747240; cv=none; d=google.com; s=arc-20160816; b=VWchAZ4SdGh6KzqD1/U0G2Nt3/KSqoHt+/+irzq4frtGOZRggR9UXkkovy7cSakALb tofhgS1PRpit8DPHMpqjv3q/8bJHMB1qu4d3Oh5wpxwCmDIDGdVkli+LS5T3aX2qMZVh Dz0/mJhvi6MEC9yYi9DzeskaXU+1HBMP3Diw7eZetwYzaX6FAk8LjVffncRfegSz1Bvg UDKIjh/ibVpGv/ZzPpkI1wvd9En2C9Zw2ObdHxc2Y0Tq5sI9LFaKF4reRS+NUIpH+wVh i9GEt+SKe+CFQf77LXRK7HGgW131jByJTXoUeHWprQnZQ/FR1zoQ+C1YxzczicO0qdAA 6+UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=3ZyKSFX9mbFEpxkW7+RsW7XcjXG7U8cVIRswtejyB9g=; b=hMh03jE9FZII5rGpxkyPMv5lSG1YPmhRoBBeS/8eyXWgHTkt4Drmm11OJUvEPgbBF6 eYvsjkRXqA8XIe8Nl4vXiLuzvR3x3ESYB3V3TrpOMvX36apqgdGVN35PDXyGVayBcVAl qh0M1TmlX0vnvEuDImXolfE+NRXwxXHNI9RqG20WVDro7KOCxzSESX7QDlXI03jvf5BK ivKFJfBeDyz4qm4OCHMjokv0+8hnvk8fIzcXLH+mzcQ+iaCyZ2KrIJlcbMIXwarJCDID FBDinGnfao2TmotrvpxV1oNTMB9hubAzS/uNJt7K1qU9/63dyecciLt+vnZx3E2Uz0iT 5R/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=2pzXrZil; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y15-20020a17090a644f00b0025678db4f6fsi1766428pjm.76.2023.06.02.16.07.06; Fri, 02 Jun 2023 16:07:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=2pzXrZil; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236720AbjFBW6f (ORCPT + 64 others); Fri, 2 Jun 2023 18:58:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236675AbjFBW6c (ORCPT ); Fri, 2 Jun 2023 18:58:32 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FAB7E40 for ; Fri, 2 Jun 2023 15:58:31 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-ba81b24b878so3553887276.3 for ; Fri, 02 Jun 2023 15:58:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685746710; x=1688338710; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=3ZyKSFX9mbFEpxkW7+RsW7XcjXG7U8cVIRswtejyB9g=; b=2pzXrZilZ7Bcom6WaEPYFcREl/2z+mMdTIIoCasFOVp9elYTIBqUsvNruRF80xUTQl UYILmU4EAjQ/LBj98zr08NdA1slg/dEucypM65FWCKjN4/kmu/x1LttRWgcf5UMI/VXM 4TGtOTT8so+PXbZU+JvNwM32WfRiVmyGWpS9PZfaCE3/Chv9b9+z02bZdk3wl+5olaj+ No1xbklWaYq4CvHLQvb73CFx4ybbBq6a8xuFfOOsLPDEXHbKJZKSiXMyP9inSmeIU/Vh uleJ3m8sg5mVBnQLbSSn09+BqgcWDzeOFHSPTQwltSAXX2AejOYSeyBKHUo9RiQ9QR6p czCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685746710; x=1688338710; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=3ZyKSFX9mbFEpxkW7+RsW7XcjXG7U8cVIRswtejyB9g=; b=S0Ads+sBKPOUHRPp3FyDhC65BZm4pEHPfhn7JCXyxqppO3zowvpuLnnGVkG0ugaeWZ xkz31wcdIhkB7bKOPpNYYrapChfe8M8MsVFJQ9F4oafiW8XnIDXo9iaUueaZ9vZJ1H8N C7QrpbYsA8/r0khhjRcgr+rE8PhHfCjLGeIfPGo/UBPhk9CeRyqHBtqXOQ3Gr/SA9ygH sBWTk4rtlugkMMg/bsaKXluC83Jkok2V/8/38nl3whgeaN5KvykLraQHEI7mqck3LIy6 uOODy+g7/ruEOwsORDtEenqlQV7SGACqmsYMwyMWRC4HrfC67MMyi/sZSscf+OqLyADp XVbQ== X-Gm-Message-State: AC+VfDzCt85qDKRRondye6AVi86vLeX6HeYoAxo0y3xtGur/M6VdiLdR w8Qd77c41pWmv6G/krgcTgPxI3OPP7I= X-Received: from kglund1.bld.corp.google.com ([2620:15c:183:200:a5cd:5418:e5f2:aca5]) (user=kglund job=sendgmr) by 2002:a25:e443:0:b0:ba8:1e5f:850f with SMTP id b64-20020a25e443000000b00ba81e5f850fmr1465907ybh.10.1685746710076; Fri, 02 Jun 2023 15:58:30 -0700 (PDT) Date: Fri, 2 Jun 2023 16:57:50 -0600 Mime-Version: 1.0 X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog Message-ID: <20230602225751.164525-1-kglund@google.com> Subject: [PATCH 1/2] wifi: cfg80211: Reject (re-)association to the same BSSID From: Kevin Lund To: johannes@sipsolutions.net, linux-wireless@vger.kernel.org Cc: Kevin Lund Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Within cfg80211_connect, reject the (re-)association request if we are already connected to the exact BSSID which is being requested. This prevents an unnecessary attempt to connect which in the best case leaves us back where we started. There is precedent for behaving this way over on the userspace SME side of things in cfg80211_mlme_auth. Further, cfg80211_connect already makes several basic checks to ensure the connection attempt is reasonable, so this fits in that context. Signed-off-by: Kevin Lund --- net/wireless/sme.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/wireless/sme.c b/net/wireless/sme.c index 7bdeb8eea92dc..8f88e66bc85fc 100644 --- a/net/wireless/sme.c +++ b/net/wireless/sme.c @@ -1442,7 +1442,8 @@ int cfg80211_connect(struct cfg80211_registered_device *rdev, /* * If connected, reject (re-)association unless prev_bssid - * matches the current BSSID. + * matches the current BSSID. Also reject if the current BSSID matches + * the desired BSSID. */ if (wdev->connected) { if (!prev_bssid) @@ -1450,6 +1451,9 @@ int cfg80211_connect(struct cfg80211_registered_device *rdev, if (!ether_addr_equal(prev_bssid, wdev->u.client.connected_addr)) return -ENOTCONN; + if (ether_addr_equal(wdev->current_bss->pub.bssid, + connect->bssid)) + return -EALREADY; } /* -- 2.39.2