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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 69D64ECE579 for ; Mon, 9 Sep 2024 09:10:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=1GaEI+CQGKFy7fU3uxuB0QBhEfP+xZFGVT3un/9IooU=; b=K9gHsggxm2Gm6N5fMhp9yepNtn wQ7qSXcEbC66itxHFeZsDO8L8fo9nF9Aw1TzcBzOvJl58IqcibEl5deSRymNph/nR0FyyaH5dLYJB upMJRrKmsfzj4qgh8lK3KigvZ3cdRb+2DlZ/lCW/4EEv7c/vhUzb4BquOQcpQ00U1t2Ite61hIT2p LnEIPCPV5776IJfOZ2hqGyUiMG0QrsaLdpogwCS0BWdbHSCum1cCyWit4Ttlht4TUEbdFKtFl4YW0 lLJtCn96oN/Oj7YmBXpCL6FMZYxwp3344nJcuLLKGWVpxG2+LlIDxMeT/Ssg8egTjKGMivla8Ixb0 T3clTVRw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1snaPa-00000001F87-1RO9; Mon, 09 Sep 2024 09:10:18 +0000 Received: from nyc.source.kernel.org ([147.75.193.91]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1snaOZ-00000001Ey7-1PyH for linux-arm-kernel@lists.infradead.org; Mon, 09 Sep 2024 09:09:16 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id E3BE5A42961; Mon, 9 Sep 2024 09:09:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCB8DC4CEC5; Mon, 9 Sep 2024 09:09:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725872954; bh=fQ8Bq1F9OXzG4iPevCpwDBqQjYesBe5uPmyI+M/cVmU=; h=From:To:Cc:Subject:Date:From; b=RthFmalhEtdBVXTRCy4QLe1Z57VQK3yfHEnKvJIi0wIUQPa/ZJrulhusricxDKkPS l2i0Y3lUEjjX5d5Ex2iOKTuhv+VqOOFA0uL27H3unAaYITSJl5sf/bl/Hy3wmr5ZWq ivBwnwjeW8zBIyIE0t49f+8jBqX0ykKtPA6yF8FHqewHTuc3OGn/J5hqPuOVLQy9g7 tqA1tQF7pZAK1p1ICUijqxc/CE6vghEmW4ajAwSKwr9931ea8Yj9FXxawqnp1YC/54 EmRd0KDwCklC12YOAXhBh3+/HKao9/+ftTaB+gssxxwnNPet3MdakEc2h/P1/ufv3w q8J32hWTywf6A== From: Arnd Bergmann To: Sudeep Holla Cc: Arnd Bergmann , Cristian Marussi , Jens Wiklander , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] firmware: arm_ffa: avoid string-fortify warningn in export_uuid() Date: Mon, 9 Sep 2024 11:09:05 +0000 Message-Id: <20240909110909.247937-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240909_020915_465348_9358E71D X-CRM114-Status: GOOD ( 14.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Arnd Bergmann Copying to a 16 byte structure into an 8-byte struct member causes a compile-time warning: In file included from drivers/firmware/arm_ffa/driver.c:25: In function 'fortify_memcpy_chk', inlined from 'export_uuid' at include/linux/uuid.h:88:2, inlined from 'ffa_msg_send_direct_req2' at drivers/firmware/arm_ffa/driver.c:488:2: include/linux/fortify-string.h:571:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning] 571 | __write_overflow_field(p_size_field, size); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Use a union for the conversion instead and make sure the byte order is fixed in the process. Fixes: aaef3bc98129 ("firmware: arm_ffa: Add support for FFA_MSG_SEND_DIRECT_{REQ,RESP}2") Signed-off-by: Arnd Bergmann --- Not sure how endianess is handled in the ABI, adding the conversion seemed sensible here to allow big-endian kernels on a little-endian firmware, but it's possible that ff-a is already required to do the byte swapping in this case. --- drivers/firmware/arm_ffa/driver.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 4d231bc375e0..8dd81db9b071 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -481,11 +481,16 @@ static int ffa_msg_send_direct_req2(u16 src_id, u16 dst_id, const uuid_t *uuid, struct ffa_send_direct_data2 *data) { u32 src_dst_ids = PACK_TARGET_INFO(src_id, dst_id); + union { + uuid_t uuid; + __le64 regs[2]; + } uuid_regs = { .uuid = *uuid }; ffa_value_t ret, args = { - .a0 = FFA_MSG_SEND_DIRECT_REQ2, .a1 = src_dst_ids, + .a0 = FFA_MSG_SEND_DIRECT_REQ2, + .a1 = src_dst_ids, + .a2 = le64_to_cpu(uuid_regs.regs[0]), + .a3 = le64_to_cpu(uuid_regs.regs[1]), }; - - export_uuid((u8 *)&args.a2, uuid); memcpy((void *)&args + offsetof(ffa_value_t, a4), data, sizeof(*data)); invoke_ffa_fn(args, &ret); -- 2.39.2