Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp2248664rwo; Thu, 3 Aug 2023 06:58:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlFXz+/FT9eIw4rB4wjAbkfzFVIuh8M/9Pd2nTiQuIyUiuoM48gXaAkpuHL26lND29EYYCLw X-Received: by 2002:ac2:5e73:0:b0:4fe:c55:4861 with SMTP id a19-20020ac25e73000000b004fe0c554861mr6503040lfr.53.1691071109133; Thu, 03 Aug 2023 06:58:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691071109; cv=none; d=google.com; s=arc-20160816; b=opTKXwlpaBWwu1wHH+3LtIsLZSlT/xmYFD+CZYMjwi0OqNrp0/sZ7+kcQSs8nO7bGQ PzNQNN5cbp3qglWdlXMBHlvU5CY9iEsoImlx0LoZcLg0aHqukZyg4Hif0E2qK9rXx8rB apq35kGvv1tayvh3ZFHzAENFnan+DtNAeOKVHJDz1E2vbDhwRj4s+F0ZcL3O1eMBVzf5 p7Lo06QTPm2d33upviRoEDcCHtt5JbphVk8km4rjt3U251N1CDwxqWjRvJD/41C4r7Hg RwiABiLMAlSot+yZu+IDvhJ1MDQdoVW+6MqlzsPbpbUjDlgO62nhl4oAm9nPXT02ekPF E8Eg== 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:message-id:in-reply-to:date:references:subject:cc:to :from:dkim-signature; bh=x3yaLKFIzXGp1xxHd5ZPqyMMNFd1Dn9vPKSGA5N/Kjg=; fh=z1BsgjoM1z0u5YyrWCA4lIsqA9bceM+p9qRB4kMUvUE=; b=vt5Ti180wstAIYPDttl8TF0+GnQ2bpJFruQgubjrCZ6LAQ3s0fA+2IVH+SAyl2D3Nu vkshFJwQJkBKRFuNV2CGrcaKTqgpaRZwMS0Dh3U5vzMAcW3StoCJ7qlkoitExMUMN1Aa FRfZOJ6Ybh3Idm5XjCUsBjlWQOFwLVS48NEIMQRRkaTCO/AnDvwEXdofoPxp7qHidQ2v UHK1lMqZlYOGxUKLGtu9Fn3PWubPJ9s8aUxTZmnrjdsVhcNCQjKBpQLk9cDf8THQMb8R gKxuQ4erytYVbfolUDIyQb4D/FjOEyS43ZTJShZksL+OPfGrzhgnNLd/7BobMIayAsTS 8IoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eljg5XsE; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o5-20020aa7c505000000b00522414e0582si11879996edq.371.2023.08.03.06.58.10; Thu, 03 Aug 2023 06:58:29 -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=@kernel.org header.s=k20201202 header.b=eljg5XsE; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235294AbjHCNyI (ORCPT + 58 others); Thu, 3 Aug 2023 09:54:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235193AbjHCNyH (ORCPT ); Thu, 3 Aug 2023 09:54:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 114861722 for ; Thu, 3 Aug 2023 06:54:05 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 66F6F61DAC for ; Thu, 3 Aug 2023 13:54:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F02E8C433C9; Thu, 3 Aug 2023 13:54:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691070843; bh=2zndGpTW3ZG0uaaqaVtbSxN+xzTy4HQzh1W7lEh+UII=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=eljg5XsEByTElk9FWxj66hON4KRf6wEx9aq3ngYXSAXGcf2vNMayxyi6a/SHGOcdC a8m7uupwp3lOjgnQWZdfVH3cKYA/ywYFURVYOzEcBOkWGwVrVxM/WjuZ585h/so7IB 9Ne+6Kfw1beI3wJndMEJ5qIHEOod3JlT9GuICdZBMEs/000Xq15Q2WwpEPYpejEICg Kimp8m4jHbFGYqtoN+7f9aY5VYzHH338g4XQfoQfcGLK7jPzPCNXcJvYDS++UBh+Cm zYb+K4+++6gec3sqhlYvg9Zinj2r/huvzJqN56M/W3wdfI71FCpp8T8ME4JrLxHdtx nowha7IAQeFmQ== From: Kalle Valo To: Dmitry Antipov Cc: linux-wireless@vger.kernel.org, ath12k@lists.infradead.org Subject: Re: ath12k: memcpy() source buffer overread References: <5c114ed7-6e8a-76a7-c0da-4193d1288686@yandex.ru> Date: Thu, 03 Aug 2023 16:54:00 +0300 In-Reply-To: <5c114ed7-6e8a-76a7-c0da-4193d1288686@yandex.ru> (Dmitry Antipov's message of "Tue, 20 Jun 2023 09:18:03 +0300") Message-ID: <875y5wteo7.fsf@kernel.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 + ath12k list Dmitry Antipov writes: > When compiling with gcc 13.1 and CONFIG_FORTIFY_SOURCE=3Dy, I've noticed = the following: > > ... > In function =E2=80=98fortify_memcpy_chk=E2=80=99, > inlined from =E2=80=98ath12k_peer_assoc_h_he=E2=80=99 at drivers/net/= wireless/ath/ath12k/mac.c:1640:2, > inlined from =E2=80=98ath12k_peer_assoc_prepare=E2=80=99 at drivers/n= et/wireless/ath/ath12k/mac.c:2027:2: > ./include/linux/fortify-string.h:529:25: warning: call to =E2=80=98__read= _overflow2_field=E2=80=99 declared with > attribute warning: detected read beyond size of field (2nd parameter); ma= ybe use struct_group()? > [-Wattribute-warning] > 529 | __read_overflow2_field(q_size_field, size= ); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > In function =E2=80=98fortify_memcpy_chk=E2=80=99, > inlined from =E2=80=98ath12k_peer_assoc_h_he=E2=80=99 at drivers/net/= wireless/ath/ath12k/mac.c:1643:2, > inlined from =E2=80=98ath12k_peer_assoc_prepare=E2=80=99 at drivers/n= et/wireless/ath/ath12k/mac.c:2027:2: > ./include/linux/fortify-string.h:529:25: warning: call to =E2=80=98__read= _overflow2_field=E2=80=99 declared with > attribute warning: detected read beyond size of field (2nd parameter); ma= ybe use struct_group()? > [-Wattribute-warning] > 529 | __read_overflow2_field(q_size_field, size= ); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ... > > And this seems correct because: > > /* dst: u32[2], src: u8[6], size: 8 so 2 byte source overread */ > memcpy(&arg->peer_he_cap_macinfo, he_cap->he_cap_elem.mac_cap_info, > sizeof(arg->peer_he_cap_macinfo)); > > and: > > /* dst: u32[3], src: u8[11], size: 12 so 1 byte source overread */ > memcpy(&arg->peer_he_cap_phyinfo, he_cap->he_cap_elem.phy_cap_info, > sizeof(arg->peer_he_cap_phyinfo)); Arnd fixed this: https://git.kernel.org/kvalo/ath/c/603cf6c2fcdc --=20 https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatc= hes