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 8A88DECE579 for ; Mon, 9 Sep 2024 09:11:26 +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=PgvZX+2maSk4V2uefTHqwoZJ/+ Na4mahxtkRYS7cKENIGV6DHxrEiORnrz696hE16MxVortP0wCu1NsGj1Zraw40fZ1YVaWMp4O4QCj 9jIh5bfV3VyagL6FbA8K9PEY/5vvtT43gUV7N9fk40oTyOMs/EQrB9JiqNvjHwh9rmFxJ2Ht2exdV 0D5SCgC5fh7VVecWsnhNXxf7ofE9zakI2f0FGlDY5Wll9acduXSjk06RROjJyyxPRQz7D4OZbO1TK n20ubzAbxgujIE0YNGKRJMV947PzwHuIwDoRCBBSoHasYnPFTqmpCJFeNNsYHbYHF0x3lBq8iweZV MN8GK7Lw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1snaQY-00000001FGi-0jLw; Mon, 09 Sep 2024 09:11:18 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1snaPH-00000001F3s-3Q5F for linux-arm-kernel@lists.infradead.org; Mon, 09 Sep 2024 09:10:01 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 900E45C0047; Mon, 9 Sep 2024 09:09:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D291C4CEC5; Mon, 9 Sep 2024 09:09:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725872998; bh=fQ8Bq1F9OXzG4iPevCpwDBqQjYesBe5uPmyI+M/cVmU=; h=From:To:Cc:Subject:Date:From; b=HmovxtfSJlFXdTT4c965EOv+RUXltuPyRNc4Idn6x2ZoBFrQmLqzk781MXosQN30U shUk63obARmxyQY3ZYqayCmYy7/6lrc07rc42OjHbmZsZ9na1yepUkwy8ClrF97OXm DvOXHh9kMUdh8YWk2eSDdyYb0dj5i9I95FpVD8O2PApIJUmaxMqM4Jhfp9BH6TPxSS FAwWqqMjKEEAzq0dVeShe+FJobXFEO8HhKbuoon1hHR7f66vhD1RXxuNPVddeVDs9V gJqwWsu0iuxEAdo3P4osa5VsdTo+Y8Ke1KNtBU9momzI+Stc6xj5uFdgeDxUltt5j8 uXer5mEnmoTjA== 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:24 +0000 Message-Id: <20240909110938.247976-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_020959_912285_97B22A41 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