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 4B4F1ECAAD3 for ; Wed, 7 Sep 2022 07:16:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229767AbiIGHQu (ORCPT ); Wed, 7 Sep 2022 03:16:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229702AbiIGHQp (ORCPT ); Wed, 7 Sep 2022 03:16:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD1AEA2DBE; Wed, 7 Sep 2022 00:16:42 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 4511A6160B; Wed, 7 Sep 2022 07:16:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5AC0AC433D7; Wed, 7 Sep 2022 07:16:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662535001; bh=MrpRDWXHho8O9dUoFZ11Bt8djGB4NUss+3ZdVZoSHVc=; h=Subject:From:In-Reply-To:References:To:Cc:Date:From; b=hihLo+HAEXzylR9hMj7Sf4Vq9G0K8zZGgAT0/kM0VQkxGK0fvoJ9pKznCrPla8ole eWgdfNNzUGuaUOOzisB8KLGko3WSU0XVphWKKPGBqABR0KVhn7q2kAKLSh3aYtFif7 JZwXS3HX3cXrfxFPdZT+jBp0H3vLMiybGeVdCMpy1gyjILedkIqapFPcs0jtGsHo5V YYs9J9vOr+8k9wvMmmt8nJz3H7Hj826/sAk58HAeTxDI1nI7hPvuwej/9X/sGrhusP AznfQWq38y24d6lV6QPF/9uL91EYADu8fxAvMfBhnlb7kFBMa7eC49SI0X0OUVhTKe kNVGTZvhpp2aw== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: wifi: iwlwifi: calib: Refactor iwl_calib_result usage for clarity From: Kalle Valo In-Reply-To: <20220901204558.2256458-1-keescook@chromium.org> References: <20220901204558.2256458-1-keescook@chromium.org> To: Kees Cook Cc: Luca Coelho , Kees Cook , Kalle Valo , "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 User-Agent: pwcli/0.1.1-git (https://github.com/kvalo/pwcli/) Python/3.7.3 Message-ID: <166253499319.23292.401375353887849776.kvalo@kernel.org> Date: Wed, 7 Sep 2022 07:16:38 +0000 (UTC) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Kees Cook wrote: > 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 Patch applied to wireless-next.git, thanks. 0d24201f47c4 wifi: iwlwifi: calib: Refactor iwl_calib_result usage for clarity -- https://patchwork.kernel.org/project/linux-wireless/patch/20220901204558.2256458-1-keescook@chromium.org/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches