Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1309334rwi; Thu, 13 Oct 2022 11:50:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM796tX/2rNpavngF6JxdUVaBf+lNXjTdtbMHpQPmQ6iZC8jR5N3mzpf397/f6lXuiKIUw8J X-Received: by 2002:aa7:8e8c:0:b0:562:a549:efc5 with SMTP id a12-20020aa78e8c000000b00562a549efc5mr1116224pfr.20.1665687014644; Thu, 13 Oct 2022 11:50:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665687014; cv=none; d=google.com; s=arc-20160816; b=DGinVFZOznxAP59y8p0gpEljQ4fu0vd7QgJo43ucxidXaVTNRYRTx2xgVp8h7/3iTO ixcaxEweOUQBd8wPPkxmA0Pe0mEkzZMQGlC13Kv9bZlgc07q6MmjGqAfOXSc4TfXe1QS uMZuChpUMY2kSEYvGTN3zpIbLfBdqOvNTY2m1EcQ/RCq8dwKNPfOXiPpaqBc4ZtXevyA PW2YNqT3g6bsX0yJ6qUDYsrHoBODt8y2tzCwnHqZRJ3CPrOFnlOu4bqHbvp0Kp+3narT QkCgJkSa8BCXjarsHIA8U/Qr/iHZg26Yt+d71AG8dv32dQFOmvVR4a8tQQcNVb7Elx3d Ej3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zA4hmFjbp1+Z1cJgLhJ7yUJxLdNmtdAgfhPM66Q/sd8=; b=OgTI4mjIXaQdMzwObX3006aUsxSODKzx74iOjn2svv4BGINJpd9oy4V2LGvlAyQmY3 FLcHtfE8FHGAXCHxLTsn/WXLn6lD/6Ywg9oMPTsv3FVsvkkL2LMMyYV2FgvoGlLEO2xK Ik8E7ZqemAWY+aZtvrVcrqmKdstGBfcLqKLR/rQDJzHAYNPzo4yI4qLwBeoJdoD2DZFo 7bnlR/KMfkhl6DSJKiGKw07KsZQF7+BWjHGjtQrkyW44r+5V+LY6Hhr1ah3QfN+ilIe3 lf0d/23oXeIpuR6v+nXu2N3oCteCc+ZpWcE2octEHditTH/zAz0PYPuYwKruImHYIIuR /rbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JCt9YA7+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q197-20020a632ace000000b004276c7b2253si113177pgq.584.2022.10.13.11.50.02; Thu, 13 Oct 2022 11:50:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b=JCt9YA7+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230411AbiJMSCA (ORCPT + 99 others); Thu, 13 Oct 2022 14:02:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230371AbiJMSBn (ORCPT ); Thu, 13 Oct 2022 14:01:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 595BD11A96A; Thu, 13 Oct 2022 11:01:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AD40FB8203D; Thu, 13 Oct 2022 17:57:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A044DC433C1; Thu, 13 Oct 2022 17:57:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683874; bh=CK8zW69mYsVe631d9uSwXr4sBV2nDL15Y8aevweb+n8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JCt9YA7+mf3S6njE2rQl7Bm65YRMAyKRMa9Me5sOecoUmN7OrO16PutpNAz1byaw1 ma0RZX1AVsW7WNjZAFRY0CmYH4/ZiSWLM8f8YnRBUuHoHpXL/yppil0uTz8FS1N5hu 0ycLRGyOvQcwJradcGk+qCkMNfBO2l03+pbB6QgE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?S=C3=B6nke=20Huster?= , Johannes Berg Subject: [PATCH 5.15 20/27] wifi: cfg80211: avoid nontransmitted BSS list corruption Date: Thu, 13 Oct 2022 19:52:49 +0200 Message-Id: <20221013175144.290858350@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-kernel@vger.kernel.org From: Johannes Berg commit bcca852027e5878aec911a347407ecc88d6fff7f upstream. If a non-transmitted BSS shares enough information (both SSID and BSSID!) with another non-transmitted BSS of a different AP, then we can find and update it, and then try to add it to the non-transmitted BSS list. We do a search for it on the transmitted BSS, but if it's not there (but belongs to another transmitted BSS), the list gets corrupted. Since this is an erroneous situation, simply fail the list insertion in this case and free the non-transmitted BSS. This fixes CVE-2022-42721. Reported-by: Sönke Huster Tested-by: Sönke Huster Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning") Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/wireless/scan.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -425,6 +425,15 @@ cfg80211_add_nontrans_list(struct cfg802 rcu_read_unlock(); + /* + * This is a bit weird - it's not on the list, but already on another + * one! The only way that could happen is if there's some BSSID/SSID + * shared by multiple APs in their multi-BSSID profiles, potentially + * with hidden SSID mixed in ... ignore it. + */ + if (!list_empty(&nontrans_bss->nontrans_list)) + return -EINVAL; + /* add to the list */ list_add_tail(&nontrans_bss->nontrans_list, &trans_bss->nontrans_list); return 0;