Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4399462pxu; Tue, 1 Dec 2020 04:09:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJxXVh38xLmCxbmb1w6bATJpL0sCI/HkjmMeDWzCI8UGEwH4ZCePkKCMX/mlvsMf1Rhmepdi X-Received: by 2002:a17:906:1695:: with SMTP id s21mr2711028ejd.31.1606824560955; Tue, 01 Dec 2020 04:09:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606824560; cv=none; d=google.com; s=arc-20160816; b=McMPluPxX8qNzaHuvV1nZ0Tvrpcca/X3IJiRaUeF8yJ/qFkjMXWV8RIgzciNcow4z7 HTxMJLNSlutxj2rw1V8SDCwpsTvDAYTfvjvVcrq/DGuCM0lR1tIsVzMtCSWzCu0DVeAW A3qYoqvlNtGKN78IwhswwO9eg0V5XKdym20J4bg4ZeuFKAjsMfTeHcTJ4fKPE1rzglGy EakL+DnEZkHzmXajHA1t1INupJiFlD3mU8bWs/BThZVyQv99/TvirwDW4+7vjNgwdnmq MO3h+oYTjJPnBSVRO9wAGll0G119vG3pHT3fJ+Wf7yaaU1xTS2fl+gPHprpxBRFEQGAQ f5OA== 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:date:cc:to:from:subject :message-id; bh=dMiugdALr6J2VdsgGujzOEQbrL+7O1+tCfBzhe/fRDU=; b=DOGX5vsmQGsjlN9BOI8CjITukoF81DpA5xxfSi6GWmsh+LLWnbXFm+V6h9CkziQXOB GQSU9xA//Sy3JjlIOXQhrGhg+BsmI/v+qPiPS3CvWolKwP8l0Qlc8kGTs3bLVRh92p9j FhcQuBv8WC5WjabgQGJF6jIOJVTN8BWfoZ0j7e6Ngj7xXHoj+hY01lZsLz6jsxRw8IKq tXXQWTqSA88uxjhTTiTpSzDD7/O4UE20IFSO+evjWnTE3QXrRDPSqCe5IcBpmocjyGX8 8sB2b/An8CqeC8OTcNqZH7R/70SPs14b9U1/5e8Jy9N3HIlDv/BA5pCxvOY6FSOgcPvt ePPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hp17si833410ejc.31.2020.12.01.04.08.53; Tue, 01 Dec 2020 04:09:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387442AbgLAMHF (ORCPT + 99 others); Tue, 1 Dec 2020 07:07:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726862AbgLAMHF (ORCPT ); Tue, 1 Dec 2020 07:07:05 -0500 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEAE9C0613D2; Tue, 1 Dec 2020 04:06:24 -0800 (PST) Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94) (envelope-from ) id 1kk4QB-000UkK-Gu; Tue, 01 Dec 2020 13:06:15 +0100 Message-ID: Subject: Re: [PATCH] net: mac80211: cfg: enforce sanity checks for key_index in ieee80211_del_key() From: Johannes Berg To: Anant Thazhemadam , "David S. Miller" , Jakub Kicinski Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+49d4cab497c2142ee170@syzkaller.appspotmail.com Date: Tue, 01 Dec 2020 13:06:01 +0100 In-Reply-To: <1e5e4471-5cf4-6d23-6186-97f764f4d25f@gmail.com> (sfid-20201201_125644_293555_F8FBDA46) References: <20201201095639.63936-1-anant.thazhemadam@gmail.com> <3025db173074d4dfbc323e91d3586f0e36426cf0.camel@sipsolutions.net> <1e5e4471-5cf4-6d23-6186-97f764f4d25f@gmail.com> (sfid-20201201_125644_293555_F8FBDA46) Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-1.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-malware-bazaar: not-scanned Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Tue, 2020-12-01 at 17:26 +0530, Anant Thazhemadam wrote: > On 01/12/20 3:30 pm, Johannes Berg wrote: > > On Tue, 2020-12-01 at 15:26 +0530, Anant Thazhemadam wrote: > > > Currently, it is assumed that key_idx values that are passed to > > > ieee80211_del_key() are all valid indexes as is, and no sanity checks > > > are performed for it. > > > However, syzbot was able to trigger an array-index-out-of-bounds bug > > > by passing a key_idx value of 5, when the maximum permissible index > > > value is (NUM_DEFAULT_KEYS - 1). > > > Enforcing sanity checks helps in preventing this bug, or a similar > > > instance in the context of ieee80211_del_key() from occurring. > > I think we should do this more generally in cfg80211, like in > > nl80211_new_key() we do it via cfg80211_validate_key_settings(). > > > > I suppose we cannot use the same function, but still, would be good to > > address this generally in nl80211 for all drivers. > > Hello, > > This gave me the idea of trying to use cfg80211_validate_key_settings() > directly in ieee80211_del_key(). I did try that out, tested it, and this bug > doesn't seem to be getting triggered anymore. > If this is okay, then I can send in a v2 soon. :) > > If there is any reason that I'm missing as to why cfg80211_validate_key_settings() > cannot be used in this context, please let me know. If it works then I guess that's OK. I thought we didn't have all the right information, e.g. whether a key is pairwise or not? johannes