Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1423717lqo; Sat, 18 May 2024 02:36:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW///Zyv6+r6KmkO7pvI0eI+iP5C+OwvlKGHJ+RPkbZRwrr3j2v39qtBQ8NDo30RPI3IGSZ684iqUX3bX7EP9uFtv+yDqYeFoiZsE6uFg== X-Google-Smtp-Source: AGHT+IE6LhpewsNGROG4FkYL1CoLQnKlUAjHsKjnMIcVkLc7UNn1rGXElGWLqOYWp2O/k8A1zjCU X-Received: by 2002:ad4:51c6:0:b0:6a3:570d:31a9 with SMTP id 6a1803df08f44-6a3570d3504mr92081656d6.7.1716024989581; Sat, 18 May 2024 02:36:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716024989; cv=pass; d=google.com; s=arc-20160816; b=i+L2+5ReFNN+TzLOi+DJdrhen2qFjJz3Tvg4QNp/HCDvit8R/aj4UqSfpOdAKRQ0zm pkXWVil+VNf9OabGBkhS/yq84VbTTYjUV7cEWqe9Ju2C46IVIiTOeK5KmF++l65JxZJ9 uAqyQlJcnEz0y7R2FFp9N/eWx1gqXWutEK7igPIwMhpEVlsOvsnp0roTNxcnoggdvWe+ gRyMnrDsX24vkyH8E4/EghgsW0gCH5+H9V2jyNT2uTFOwU3Xs62OXqbpTqAJjDpwxtY5 GJUGv2bp+cEjd2QC34vnN9aCNNnAd2uGxhhgNcyhkbyB6pPK3anVVc3zzwdoIrDu0NN8 OudA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=iY9and2fRgy70/SkFGL1EiobywiSyLTQmpLGJth6Z1E=; fh=qiui141uGvWOybuJy1KO/6uoezvU5QHUJVXmJWttYWQ=; b=Ai24B6Qzovz6fW8kAGxpy8mWaW+iqKPcsI1lkO1a9yg4HjoT980n1T6S07i5geTWKE 7t89pEyu53suoSs9WqarwgCk9BFY5Q7F0NHqc0qnNE7Ca6oR5N3HLQw7U5+r00embuFP 9sA25WcX9EUMFo/iwPh/NOAnIdcQV5MGWWEVd+mjbedDthl3xFgRqaxrzih3f/Ooy5IW 1xP7D8R2+42ZCH3NZLR4gTZgo5UPSzR109ebC/vMRwkF9mxhfkgMXrG6icj8QUJTj4BV 4QDrzOQQNU05N43mhwtn3DR8Q2zTUsUy/o1gplPD8PTk13TGcL2agvHHB4+WcK4JF8lA 9RFQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@wp.pl header.s=1024a header.b=pnOYrEe0; arc=pass (i=1 spf=pass spfdomain=wp.pl dkim=pass dkdomain=wp.pl dmarc=pass fromdomain=wp.pl); spf=pass (google.com: domain of linux-wireless+bounces-7820-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-7820-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wp.pl Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6a15f306ec5si211907276d6.585.2024.05.18.02.36.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 May 2024 02:36:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-7820-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@wp.pl header.s=1024a header.b=pnOYrEe0; arc=pass (i=1 spf=pass spfdomain=wp.pl dkim=pass dkdomain=wp.pl dmarc=pass fromdomain=wp.pl); spf=pass (google.com: domain of linux-wireless+bounces-7820-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-7820-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wp.pl Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3D5CE1C20DB6 for ; Sat, 18 May 2024 09:36:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5D8E0DDDF; Sat, 18 May 2024 09:36:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=wp.pl header.i=@wp.pl header.b="pnOYrEe0" X-Original-To: linux-wireless@vger.kernel.org Received: from mx4.wp.pl (mx4.wp.pl [212.77.101.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 349368BEA for ; Sat, 18 May 2024 09:36:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.77.101.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716024986; cv=none; b=V39K+9+r3fBypNgdOO5Ai4cK/SmNZPBTMZKSb+st2XgSqBbdg6wQO4O966lUbUczdsP153+JTjOG9QGj45p0RdAGcU9NNI6EgVGl+r1XV9pZVnrYMKDKgo8SuwAhyTPUyn0fICqGXAY3JTf8NLeRS0F8g0BLYQIDR9/CtXOYVjs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716024986; c=relaxed/simple; bh=/ff+y6N/bVLEJkZA7IjiDKP1wE0nrhWuCxMNrhj4rx4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qtnzU+rsWV6mCAOFCbiOr+k0Acw5SrLVF9pM92Iuh9MzJOyRBr/MyMp3N3oa2dwhJGWv8dsFtn3mQpJ7+UzvMiF3KfIwsq9X98gJNmqpP4TozVtMWxiBmNqHpRxMQtMoAvGcn4AlBW3xYauTwIt5f9+Gor+lgIyr3MaeX4Z6Upw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wp.pl; spf=pass smtp.mailfrom=wp.pl; dkim=pass (1024-bit key) header.d=wp.pl header.i=@wp.pl header.b=pnOYrEe0; arc=none smtp.client-ip=212.77.101.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wp.pl Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wp.pl Received: (wp-smtpd smtp.wp.pl 12094 invoked from network); 18 May 2024 11:29:40 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=1024a; t=1716024580; bh=iY9and2fRgy70/SkFGL1EiobywiSyLTQmpLGJth6Z1E=; h=From:To:Cc:Subject; b=pnOYrEe04rgwoi5hrFGpXBXtYJockzJPNcQtQEZhmn5PI3VQ1F0ZH8uMbQqw8ahuT kzZ30+U6mXVF7jBhZiUUbgmD+p3u8DHStYvgEafPOPdp/BW8ESq8U9W1PxrQW5gGnR i3r87zXrMkWEyAFRmrlcg7OeIN3K1jQp06HlnedY= Received: from 89-64-9-76.dynamic.chello.pl (HELO localhost) (stf_xl@wp.pl@[89.64.9.76]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 18 May 2024 11:29:40 +0200 Date: Sat, 18 May 2024 11:29:39 +0200 From: Stanislaw Gruszka To: Xose Vazquez Perez Cc: linux-wireless@vger.kernel.org, Kees Cook Subject: Re: [WARNING] memcpy: detected field-spanning write (size 1005) of single field "&out_cmd->cmd.payload" at drivers/net/wireless/intel/iwlegacy/common.c:3173 (size 320) Message-ID: <20240518092939.GA643846@wp.pl> References: <2c534d01-449a-43f4-9216-eacdb3b35577@gmail.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2c534d01-449a-43f4-9216-eacdb3b35577@gmail.com> X-WP-MailID: e9b5917407e67f223ec504bc876e22cb X-WP-AV: skaner antywirusowy Poczty Wirtualnej Polski X-WP-SPAM: NO 0000002 [AVHg] Hi On Fri, Apr 12, 2024 at 07:48:39PM +0200, Xose Vazquez Perez wrote: > Hi, > > In Fedora kernel 6.8.5-301.fc40.x86_64, dmesg shows: > > [ device: 03:00.0 Network controller [0280]: Intel Corporation PRO/Wireless 4965 AG or AGN [Kedron] Network Connection [8086:4230] (rev 61) ] > > Thanks. > > [ 53.407607] ------------[ cut here ]------------ > [ 53.407622] memcpy: detected field-spanning write (size 1005) of single field "&out_cmd->cmd.payload" at drivers/net/wireless/intel/iwlegacy/common.c:3173 (size 320) > [ 53.407721] WARNING: CPU: 1 PID: 1632 at drivers/net/wireless/intel/iwlegacy/common.c:3173 il_enqueue_hcmd+0x477/0x560 [iwlegacy] For CMD_SIZE_HUGE we have allocated 4k, so we do not do anything wrong. Except maybe code is convoluted, since we use same structure for huge and small il_device_cmd allocations. But I'm thinking how to fix this fortify warning without refactoring and some extra runtime cost ... Xose, could you test below patch? I did not tested it, but I think it should make this particular warning gone and does not break anything. But maybe it will trigger some others fortify warnings. Regards Stanislaw diff --git a/drivers/net/wireless/intel/iwlegacy/common.c b/drivers/net/wireless/intel/iwlegacy/common.c index 9d33a66a49b5..c4ccc5df6419 100644 --- a/drivers/net/wireless/intel/iwlegacy/common.c +++ b/drivers/net/wireless/intel/iwlegacy/common.c @@ -3170,7 +3170,7 @@ il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) out_meta->callback = cmd->callback; out_cmd->hdr.cmd = cmd->id; - memcpy(&out_cmd->cmd.payload, cmd->data, cmd->len); + memcpy(&out_cmd->hdr.data, cmd->data, cmd->len); /* At this point, the out_cmd now has all of the incoming cmd * information */