From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A832AC43217 for ; Fri, 18 Nov 2022 21:05:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230187AbiKRVFY (ORCPT ); Fri, 18 Nov 2022 16:05:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229552AbiKRVFV (ORCPT ); Fri, 18 Nov 2022 16:05:21 -0500 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A713976DA; Fri, 18 Nov 2022 13:05:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=MIME-Version:Content-Transfer-Encoding: Content-Type:References:In-Reply-To:Date:Cc:To:From:Subject:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=P6rXaBfeIINbzRWSy2AGyxu2PyTieOunm5ts0qSAvmk=; t=1668805520; x=1670015120; b=Rwcu1xEWim0khPiqff3ufgdDSs2XzssqGHz27HbBwqHSLMU T3KXiXKHJlqSDkKEgy2vUilE76Bd7EUsKBv4uuLTGsgYyGKBxlSetbMKLKHxPeUoARwgnA5DI2d7H AIb+ZQMnlr5N7JXQyYwLyoxDENkUxH4r9gTiQtmZdCt/HfoogHbktZW8tDe+BwOLWd2s7pDBh8ZhV MC6/NQ53iEU4plgmzDgT+piLGOYl/F5ZS+cb9fWCZqh+7Ecxup1ZgaAAqOw0XHC2qlE8szvS31hZ6 wmN6TzrQbxq0OUtJev05udKet0wc/lIy6kWbL9WBVRoHUPZcy8qJExkTfX53V9Jg==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1ow8XQ-003CYt-07; Fri, 18 Nov 2022 22:04:40 +0100 Message-ID: Subject: Re: Coverity: iwl_mvm_sec_key_add(): Memory - corruptions From: Johannes Berg To: coverity-bot Cc: Luca Coelho , Haim Dreyfuss , Miri Korenblit , Petr Stourac , linux-kernel@vger.kernel.org, Mordechay Goodstein , Jakub Kicinski , Eric Dumazet , Nathan Errera , Paolo Abeni , Shaul Triebitz , netdev@vger.kernel.org, Gregory Greenman , Abhishek Naik , Jose Ignacio Tornos Martinez , Ayala Beker , "David S. Miller" , linux-wireless@vger.kernel.org, Sriram R , Kalle Valo , Mike Golant , Emmanuel Grumbach , "Gustavo A. R. Silva" , linux-next@vger.kernel.org, linux-hardening@vger.kernel.org Date: Fri, 18 Nov 2022 22:04:38 +0100 In-Reply-To: <202211180854.CD96D54D36@keescook> References: <202211180854.CD96D54D36@keescook> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4 (3.44.4-2.fc36) MIME-Version: 1.0 X-malware-bazaar: not-scanned Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, 2022-11-18 at 08:54 -0800, coverity-bot wrote: >=20 > *** CID 1527370: Memory - corruptions (OVERRUN) > drivers/net/wireless/intel/iwlwifi/mvm/mld-key.c:123 in iwl_mvm_sec_key_a= dd() > 117 > 118 if (WARN_ON(keyconf->keylen > sizeof(cmd.u.add.key))) > 119 return -EINVAL; > 120 > 121 if (keyconf->cipher =3D=3D WLAN_CIPHER_SUITE_WEP40 || > 122 keyconf->cipher =3D=3D WLAN_CIPHER_SUITE_WEP104) > vvv CID 1527370: Memory - corruptions (OVERRUN) > vvv Overrunning buffer pointed to by "cmd.u.add.key + 3" of 32 bytes = by passing it to a function which accesses it at byte offset 34 using argum= ent "keyconf->keylen" (which evaluates to 32). [Note: The source code imple= mentation of the function has been overridden by a builtin model.] > 123 memcpy(cmd.u.add.key + IWL_SEC_WEP_KEY_OFFSET, keyconf->key, > 124 keyconf->keylen); > 125 else > 126 memcpy(cmd.u.add.key, keyconf->key, keyconf->keylen); > 127 > 128 if (keyconf->cipher =3D=3D WLAN_CIPHER_SUITE_TKIP) { >=20 > If this is a false positive, please let us know so we can mark it as > such, or teach the Coverity rules to be smarter. If not, please make > sure fixes get into linux-next. :) For patches fixing this, please > include these lines (but double-check the "Fixes" first): >=20 Well, I don't think you can teach coverity this easily, but the WARN_ON() check there is not really meant to protect this - WEP keys must have a length of either 5 or 13 bytes (40 or 104 bits!). So there's no issue here, but I'm not surprised that coverity wouldn't be able to figure that out through the stack. johannes