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 X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DB93C4320A for ; Sat, 21 Aug 2021 17:16:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 42B0D60FE8 for ; Sat, 21 Aug 2021 17:16:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231564AbhHURQt (ORCPT ); Sat, 21 Aug 2021 13:16:49 -0400 Received: from so254-9.mailgun.net ([198.61.254.9]:18533 "EHLO so254-9.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230347AbhHURQs (ORCPT ); Sat, 21 Aug 2021 13:16:48 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1629566169; h=Date: Message-Id: Cc: To: References: In-Reply-To: From: Subject: Content-Transfer-Encoding: MIME-Version: Content-Type: Sender; bh=MLXw2kAV40fUYj05/3m6TBzD/fnzpbaaqB86lj9wxNQ=; b=YvaqIFhphguctGSq56BKs4BmSIy/xNl4MbUloieGT9XE2aefVeVVpm/cULdo6m1+TB8TvUQC ZhRjmmW1j87ubspSAoId7Gjwb39JO0XautDjbZB/k80Fv072f1gxaVcx2jpuM/Ul64v21xYT zfGRy8pnKLYz0P5/siO2+tCxOYU= X-Mailgun-Sending-Ip: 198.61.254.9 X-Mailgun-Sid: WyIyNzljNCIsICJsaW51eC1oYXJkZW5pbmdAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n02.prod.us-east-1.postgun.com with SMTP id 612134cb89fbdf3ffe78282a (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Sat, 21 Aug 2021 17:15:55 GMT Sender: kvalo=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 398BEC43619; Sat, 21 Aug 2021 17:15:54 +0000 (UTC) Received: from tykki.adurom.net (tynnyri.adurom.net [51.15.11.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: kvalo) by smtp.codeaurora.org (Postfix) with ESMTPSA id AEA07C4360C; Sat, 21 Aug 2021 17:15:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.codeaurora.org AEA07C4360C Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=codeaurora.org Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [PATCH 1/3] ipw2x00: Avoid field-overflowing memcpy() From: Kalle Valo In-Reply-To: <20210819202825.3545692-2-keescook@chromium.org> References: <20210819202825.3545692-2-keescook@chromium.org> To: Kees Cook Cc: netdev@vger.kernel.org, Kees Cook , Stanislav Yakovlev , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, Saeed Mahameed , Leon Romanovsky , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, bpf@vger.kernel.org, linux-hardening@vger.kernel.org User-Agent: pwcli/0.1.0-git (https://github.com/kvalo/pwcli/) Python/3.7.3 Message-Id: <20210821171554.398BEC43619@smtp.codeaurora.org> Date: Sat, 21 Aug 2021 17:15:54 +0000 (UTC) Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org Kees Cook wrote: > In preparation for FORTIFY_SOURCE performing compile-time and run-time > field bounds checking for memcpy(), memmove(), and memset(), avoid > intentionally writing across neighboring fields. > > libipw_read_qos_param_element() copies a struct libipw_info_element > into a struct libipw_qos_information_element, but is actually wanting to > copy into the larger struct libipw_qos_parameter_info (the contents of > ac_params_record[] is later examined). Refactor the routine to perform > centralized checks, and copy the entire contents directly (since the id > and len members match the elementID and length members): > > struct libipw_info_element { > u8 id; > u8 len; > u8 data[]; > } __packed; > > struct libipw_qos_information_element { > u8 elementID; > u8 length; > u8 qui[QOS_OUI_LEN]; > u8 qui_type; > u8 qui_subtype; > u8 version; > u8 ac_info; > } __packed; > > struct libipw_qos_parameter_info { > struct libipw_qos_information_element info_element; > u8 reserved; > struct libipw_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM]; > } __packed; > > Cc: Stanislav Yakovlev > Cc: Kalle Valo > Cc: "David S. Miller" > Cc: Jakub Kicinski > Cc: linux-wireless@vger.kernel.org > Cc: netdev@vger.kernel.org > Signed-off-by: Kees Cook 2 patches applied to wireless-drivers-next.git, thanks. d6b6d1bb80be ipw2x00: Avoid field-overflowing memcpy() 92276c592a6b ray_cs: Split memcpy() to avoid bounds check warning -- https://patchwork.kernel.org/project/linux-wireless/patch/20210819202825.3545692-2-keescook@chromium.org/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches