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 B27F3ECAAD2 for ; Fri, 2 Sep 2022 03:20:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235063AbiIBDUv (ORCPT ); Thu, 1 Sep 2022 23:20:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229804AbiIBDUl (ORCPT ); Thu, 1 Sep 2022 23:20:41 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 424C62DD; Thu, 1 Sep 2022 20:20:39 -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 F28A9B82980; Fri, 2 Sep 2022 03:20:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1C0DC433C1; Fri, 2 Sep 2022 03:20:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662088836; bh=YCJr9iHj+jHwZFgouCTxuRVFKnFA7bJfiUzOTkjxtlU=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=dYSc+wLxPM3Yxq6Tepm+O2b5CE0LnE/uLcuB3UF7dpSrUCNiaq1IjDnAKB3j5h6Od kde0sBLDinZONd4n/Gd2VmnhXEUL8d2coEnSIqCEye2PPPhtpgvRy+JClBsqQ5yD3B uF2QlkmbEr714wxnl/dzRNK95n5BZunlBWJ+bDTJq8br8+Lj1hMlfXwxko4d4Xb7Bv KU5pvdluBstPOvjtNT2SFQYC1zrftKAuMoQhgjnz07Rke5QZcpPvFNtRCcM0XhRDpN kw7U7gYdianibdtrotsZJbh/dB2Tb3elNYjYf+AQxjaD/1vJmD6XhP2IC+uISPj2Mj zhsHiqcmU66AQ== From: Kalle Valo To: Kees Cook Cc: Luca Coelho , "David S. Miller" , Jakub Kicinski , Lee Jones , Johannes Berg , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Andy Lavr , Gregory Greenman , Eric Dumazet , Paolo Abeni , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] iwlwifi: calib: Refactor iwl_calib_result usage for clarity References: <20220901204558.2256458-1-keescook@chromium.org> Date: Fri, 02 Sep 2022 06:20:26 +0300 In-Reply-To: <20220901204558.2256458-1-keescook@chromium.org> (Kees Cook's message of "Thu, 1 Sep 2022 13:45:58 -0700") Message-ID: <87ilm6ea2t.fsf@kernel.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org Kees Cook writes: > In preparation for FORTIFY_SOURCE performing run-time destination buffer > bounds checking for memcpy(), refactor the use of struct iwl_calib_result: > > - Have struct iwl_calib_result contain struct iwl_calib_cmd since > functions expect to operate on the "data" flex array in "cmd", which > follows the "hdr" member. > - Switch argument passing around to use struct iwl_calib_cmd instead of > struct iwl_calib_hdr to prepare functions to see the "data" member. > - Change iwl_calib_set()'s "len" argument to a size_t since it is always > unsigned and is normally receiving the output of sizeof(). > - Add an explicit length sanity check in iwl_calib_set(). > - Adjust the memcpy() to avoid copying across the now visible composite > flex array structure. > > This avoids the future run-time warning: > > memcpy: detected field-spanning write (size 8) of single field "&res->hdr" (size 4) > > Cc: Luca Coelho > Cc: Kalle Valo > Cc: "David S. Miller" > Cc: Jakub Kicinski > Cc: Lee Jones > Cc: Johannes Berg > Cc: linux-wireless@vger.kernel.org > Cc: netdev@vger.kernel.org > Reported-by: Andy Lavr > Signed-off-by: Kees Cook Gregory, as this fixes a future warning can I take this directly to wireless-next? -- https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches