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 952E4CFC53F for ; Mon, 14 Oct 2024 10:32:06 +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: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Iehd1BNUIpWUCUdYEOtgXTd08uhD2ebuXNn5tihq+ko=; b=zMur2SWTmUUxDzCcI/X+z333am NOg85+ygMNy+8g5AfDFiVTH1RUew4f0rcjvXTWWjA3PrbzfFXYMcAdNPPBhdwrVKLZ9NwW445FbGg RhVQohP57gxzPm0UUNBQKAe13DMXLpjLOBLNXO0QWffUi+o8/mq0VKUCcy1NRm9qRkvjQWp1HFKTA XIuci/hI4m6smfo0Skt3PP6SElt7oJrfIFsBQDvJ9L5ax1a491zfYpTO1uLMkMnAQvwLvqUh/CDan ECQEEMhKCqhTqGCUI22TtbHEaFiElbjQio1E5whAYWOaxev6FC1pTIsBQuPptgFvf0f4P6i4owoIy +bVIBnqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0IMn-00000004hla-1HeZ; Mon, 14 Oct 2024 10:31:57 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t0IH7-00000004h3a-237K for linux-arm-kernel@lists.infradead.org; Mon, 14 Oct 2024 10:26:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728901563; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Iehd1BNUIpWUCUdYEOtgXTd08uhD2ebuXNn5tihq+ko=; b=dhpV2hN0s5WByTofJzt9Vzc9MUT6zxFhWSGQCYBL8bNY/K1e8MeNAVeQ4/isJKCvJZlwts lRHGB+rSFDpqhzzw9hfNLkT9FDC9BNb3NqnskENgTMukQfDia01af+MFCwsF5MzJKiaF3n f31UyADwp1tAm9Lo/vAYWTjnSJ7Qpkw= Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-60-5v_8sVTXOEiwiJpl2Yxcyw-1; Mon, 14 Oct 2024 06:26:00 -0400 X-MC-Unique: 5v_8sVTXOEiwiJpl2Yxcyw-1 Received: by mail-pf1-f198.google.com with SMTP id d2e1a72fcca58-71e5a1eefeeso925936b3a.3 for ; Mon, 14 Oct 2024 03:26:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728901559; x=1729506359; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Iehd1BNUIpWUCUdYEOtgXTd08uhD2ebuXNn5tihq+ko=; b=HnL8x+dsdwNjpbSid9Bxp1t7kLKdt4HTLL5In5BmZXqK4DJsxUVShg6BCmdzAySP8n QK1CPjo7fi5o3mEcI8N0C1ORSukbCR4b0ykoP7IOLNgoGtQaGYfiQ5K94uOjxfPiViEJ kMx1IQx0vvxr9MIeH14+AMa4OTURnjiGXxHCO6yuEKRhN/atB9ni19hsyriRudGzt6To LbfcviG/YLKzQQwaA1ha3hoFfkY8pzNX1wC8ezIopgzZcOxMNWbPXuZsXtqfFooLQX01 GhgnmXmjednTFJfBO0Vfluz+LS7dPfPr1Hnci4CDKxT++8NhJX7Jjk/ELVo//QGjT1Vm nERQ== X-Gm-Message-State: AOJu0Yx6ZRlXzFlBxWPYxK06Pjd20+v5qG/CEFKXvKCmc8MTHrjiy/Zp Ndl9qI+z1WmHZjsYE21C+dVQPTDjDucEdVtsIun4doqB5dn/UiD51L4C/4SSofv+/5bvr3XmxED /gynKHZywaeCnqazX0m4KjzG3MtsRwmDFA/nTtXQY0bmT1n0R/Brn18FtLJFwEo+2iY5Wl+vvJt B/b+a9 X-Received: by 2002:a05:6a21:99a2:b0:1d8:abc6:71a4 with SMTP id adf61e73a8af0-1d8c955c952mr12602177637.6.1728901559027; Mon, 14 Oct 2024 03:25:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG4S//5Qp+Gm5n0MIrRdxlFSCJcr23jiAU6pfy10eWEnVFM06aEmjGnFNJFwF+uQsl3N7XTfw== X-Received: by 2002:a05:6a21:99a2:b0:1d8:abc6:71a4 with SMTP id adf61e73a8af0-1d8c955c952mr12602145637.6.1728901558605; Mon, 14 Oct 2024 03:25:58 -0700 (PDT) Received: from [192.168.68.54] ([180.233.125.129]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7ea4495a75asm6524493a12.65.2024.10.14.03.25.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Oct 2024 03:25:58 -0700 (PDT) Message-ID: <2ea2b741-3abd-4fe1-b622-b6a4a3c2a92b@redhat.com> Date: Mon, 14 Oct 2024 20:25:54 +1000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] firmware: arm_ffa: Fix warning caused by export_uuid() To: Sudeep Holla Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, shan.gavin@gmail.com References: <20241014004724.991353-1-gshan@redhat.com> From: Gavin Shan In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241014_032605_625999_20B091E1 X-CRM114-Status: GOOD ( 19.05 ) 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 On 10/14/24 8:08 PM, Sudeep Holla wrote: > On Mon, Oct 14, 2024 at 10:47:24AM +1000, Gavin Shan wrote: >> 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. >> > > Are you observing this just on the upstream or -next as well? There is a > fix in the -next which I haven't sent to soc team yet, will do so soon. > I just tried the upstream when the patch was posted. I just have a try with -next and similar error exists. [root@nvidia-grace-hopper-01 linux-next]# git remote -v origin git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git (fetch) origin git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git (push) [root@nvidia-grace-hopper-01 linux-next]# make W=1 drivers/firmware/arm_ffa/driver.o : In function ‘fortify_memcpy_chk’, inlined from ‘ffa_msg_send_direct_req2’ at drivers/firmware/arm_ffa/driver.c:504:3: ./include/linux/fortify-string.h:580:25: error: call to ‘__read_overflow2_field’ declared with attribute warning: \ detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Werror=attribute-warning] 580 | __read_overflow2_field(q_size_field, size); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Part of the changes included this patch is still needed by -next. Could you please squeeze the changes to that one to be pulled? diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 8dd81db9b071..b14cbdae94e8 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -501,7 +501,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; } Thanks, Gavin