Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp5517082rwe; Tue, 18 Apr 2023 07:55:00 -0700 (PDT) X-Google-Smtp-Source: AKy350YnC2QhJSXWAJnPL50H4viPsDT6a7ZpfaDSMrYY/5TjQY/q3Ay8NgLb42EYDdnWAT0ZH3FV X-Received: by 2002:a05:6a00:2e0b:b0:63b:7af1:47d5 with SMTP id fc11-20020a056a002e0b00b0063b7af147d5mr96309pfb.9.1681829700371; Tue, 18 Apr 2023 07:55:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681829700; cv=none; d=google.com; s=arc-20160816; b=GCO86KmQDKFPAS0+a5S7on16f2y7uss42+KSkjClhh/NngpuZw9pRBmx6cLO2oD6CH jQ7Ls+icmw1fMKnFv0wWVNjfSVkzwSFp3SGzXfNe+GRRZQqa6JrP8vhHdYJ6KIXMyH8M EoDlrE7VDmKEpoCg3O+8VJ8EbeRuucLBDkiHhP78zrYag7YWTProCBMYWkXPqV4LEttG /uyfUAvZ4G9E4vKkAEJgHo0iidhSZ/l8dYc1PT8CEzkULGmN83NVvngJVT1Z2ospkL0n 2X++n20rewdA/dQ7vkAAjXQXs3wMGiM9gMZtAYWPZq7lJJeun0GHlZ2KYKboFv9QAOQ1 rqgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=zgsQTXRwQZZl6pn/o91z4oDhbS6AdTHiGnBjka4kxE8=; b=Mxsbxtvk+H2zwH1Ov/BkP4+l2/MpWHfsL5CjMUiSeu2SQ2VBlXqJLsXqWRVT7VOW6w 0hPEgf5qJf+GCzRBjohSpUCspuxSJa0bd1Il9FX4wKODAPUGiFFM5ZD8XY7JCJ93RZJX zoug3jxm5qmmz22vGTIyIfzmv5ZGb/FVJrA0JpdYEAPopwCDJlvPF87mFAO4gAvBwsnN um3AufDHshbDjV4GsEk9DmHztQR2yy+A4uXC7NR+9rID2wTUo/Vq71StzYBTIQAaFJSe 8/htbK1GTWg/d5gerz06rwhKa6sRn18C47dbfPxzjrB/IqrvY5HbtCCGOdzS195lTMlP 0ldw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=XPZKTMDR; 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=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i12-20020a65484c000000b0051b37c000dcsi13689443pgs.81.2023.04.18.07.54.50; Tue, 18 Apr 2023 07:55:00 -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=@sipsolutions.net header.s=mail header.b=XPZKTMDR; 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=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231946AbjDROnv (ORCPT + 64 others); Tue, 18 Apr 2023 10:43:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232010AbjDROnt (ORCPT ); Tue, 18 Apr 2023 10:43:49 -0400 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 136D314479 for ; Tue, 18 Apr 2023 07:43:36 -0700 (PDT) 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=zgsQTXRwQZZl6pn/o91z4oDhbS6AdTHiGnBjka4kxE8=; t=1681829017; x=1683038617; b=XPZKTMDR0uIZvgb08oKcc5CdoKqTjeOtI9XQLeYzkrxgLZp /NkI+gqOVNVrKwrutM140QxMYBP2UtFF7UzMOamz71Z8sxIwcapZ/Sdo+8N+igrKmP68zTno9SkxN K5ZdMIoWZoD9mMSkSr/Dmb3Z2Fv3fQcyZjNGXhscxFiqrYfGzGu61eRxGuOgq/5pNrfyhxM9tGrB/ ZMLXiyIUasKR00Ol4pYMP6TGTTw09J5wdZFvifQvwA2hCO/s2TG5qb3LnoyZVH+qvDV0o+vc+50rf 5h63RuhA9W0bEX0Fr24CBNWwl4CS6lwsVifmpCyyOyMT1YBGfQIG/iYqwywGtDZA==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1pomYB-001fVt-0J; Tue, 18 Apr 2023 16:43:19 +0200 Message-ID: <9619692082caef649e236eb154129e922c46b547.camel@sipsolutions.net> Subject: Re: [PATCH] wifi: iwlwifi: dvm: Fix memcpy: detected field-spanning write backtrace From: Johannes Berg To: Hans de Goede , Gregory Greenman , Kalle Valo Cc: linux-wireless@vger.kernel.org, Kees Cook Date: Tue, 18 Apr 2023 16:43:18 +0200 In-Reply-To: <20230418132546.45297-1-hdegoede@redhat.com> References: <20230418132546.45297-1-hdegoede@redhat.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 (3.46.4-1.fc37) MIME-Version: 1.0 X-malware-bazaar: not-scanned X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On Tue, 2023-04-18 at 15:25 +0200, Hans de Goede wrote: > A received TKIP key may be up to 32 bytes because it may contain > MIC rx/tx keys too. These are not used by iwl and copying these > over overflows the iwl_keyinfo.key field. Thanks for doing (and more importantly testing) this :) > - memcpy(sta_cmd.key.key, keyconf->key, keyconf->keylen); > + /* keyconf may contain MIC rx/tx keys which iwl does not use */ > + to_copy =3D min_t(size_t, sizeof(sta_cmd.key.key), keyconf->keylen); > + memcpy(sta_cmd.key.key, keyconf->key, to_copy); >=20 I'd kind of argue that just hardcoding 16 is fine here, keylen _looks_ variable so the compiler can't optimize it away, but in reality keylen always must be 32 and sizeof() must be always 16 :) But it also really doesn't matter. Reviewed-by: Johannes Berg Should we Cc stable on this? johannes