From patchwork Mon Oct 14 00:47:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 13834061 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 0EBBFCF258E for ; Mon, 14 Oct 2024 00:49:25 +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:Content-Type:Message-ID:Date:Subject:Cc:To:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=X05hnwmFfahTamUd2ZyCmOrUz5+WC9QCz0YioOU37gU=; b=vmtR+GFYmWCNoE5NB5lIFeOX00 LTXQLsa3L57vDMNhS8ZQMip+GJxUfleKkC2QeCJRlbzb+kaCTGlm0lOx2dhkuipgOTC2mwJ8ZQmhe LfBcd3fqRJafW/k7++E6BEJSQmlq1e8MssKHZVolvYgwmJLZmftOeaZdeYyjhUPQJAwFuc5xKmMgD bFf+Nk+EziDmSeatoVi86UzU+ieuBuqgN9jMVPrWHKaMZkfXDpYiufp6A3Q9yqkqXDw9poobR1UZ+ ok0XEsFVIwAWu8NPi2Haw70KD/tT7aRM3EH2k6Ps7MM0qYLCG7qLRstNHkNnrrtHsCYELq1J9xBVc icMhqUJA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t09Gq-00000003Rj5-29RB; Mon, 14 Oct 2024 00:49:12 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t09FR-00000003RaE-3HeI for linux-arm-kernel@lists.infradead.org; Mon, 14 Oct 2024 00:47:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728866863; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=X05hnwmFfahTamUd2ZyCmOrUz5+WC9QCz0YioOU37gU=; b=hRXK32rKhCvlxsm4YfZwqVrhZIpEQxBK/zn+dZ3EXPKftlA8AzP0GvG3tu59HEKlQHxpLO q3v7GJriYlm7e4LHy+ushNbrq7G4ANmuvLDanI90/WN9dKo/AtYLfbeK+UwrrolnVxswpH p/oElepah94JH+DTOrepLKgy7q0nFps= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-451-_PDTQTuXM4ixcBjULnFfOg-1; Sun, 13 Oct 2024 20:47:41 -0400 X-MC-Unique: _PDTQTuXM4ixcBjULnFfOg-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4DE7A19560AA; Mon, 14 Oct 2024 00:47:40 +0000 (UTC) Received: from gshan-thinkpadx1nanogen2.remote.csb (unknown [10.64.136.10]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7F45B19560AA; Mon, 14 Oct 2024 00:47:36 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, sudeep.holla@arm.com, shan.gavin@gmail.com Subject: [PATCH] firmware: arm_ffa: Fix warning caused by export_uuid() Date: Mon, 14 Oct 2024 10:47:24 +1000 Message-ID: <20241014004724.991353-1-gshan@redhat.com> MIME-Version: 1.0 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241013_174745_928413_1CF210C8 X-CRM114-Status: GOOD ( 13.08 ) 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 Run into build warning caused by export_uuid() where the UUID's length exceeds that of ffa_value_t::a2, as the following warning messages indicate. 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); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fix it by not passing a plain buffer to memcpy() to avoid the overflow and underflow warning, similar to what have been done to copy over the struct ffa_send_direct_data2. Fixes: aaef3bc98129 ("firmware: arm_ffa: Add support for FFA_MSG_SEND_DIRECT_{REQ,RESP}2") Signed-off-by: Gavin Shan Signed-off-by: Gavin Shan Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 4d231bc375e0..154777e89f04 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -485,7 +485,7 @@ static int ffa_msg_send_direct_req2(u16 src_id, u16 dst_id, const uuid_t *uuid, .a0 = FFA_MSG_SEND_DIRECT_REQ2, .a1 = src_dst_ids, }; - export_uuid((u8 *)&args.a2, uuid); + memcpy((void *)&args + offsetof(ffa_value_t, a2), uuid, sizeof(*uuid)); memcpy((void *)&args + offsetof(ffa_value_t, a4), data, sizeof(*data)); invoke_ffa_fn(args, &ret); @@ -496,7 +496,7 @@ static int ffa_msg_send_direct_req2(u16 src_id, u16 dst_id, const uuid_t *uuid, return ffa_to_linux_errno((int)ret.a2); if (ret.a0 == FFA_MSG_SEND_DIRECT_RESP2) { - memcpy(data, &ret.a4, sizeof(*data)); + memcpy(data, (void *)&ret + offsetof(ffa_value_t, a4), sizeof(*data)); return 0; }