Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1516180rdb; Mon, 2 Oct 2023 11:58:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGJNvtAEwG9jOYmdjLb2qzYlyvBx+ybHLH+mlPaxGxpHKc49AMpyHZCdtvV7OA3HwHU3UDP X-Received: by 2002:a17:902:e883:b0:1c3:dafa:b1e9 with SMTP id w3-20020a170902e88300b001c3dafab1e9mr15375497plg.10.1696273093025; Mon, 02 Oct 2023 11:58:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696273093; cv=none; d=google.com; s=arc-20160816; b=gR+eWfHT0lyD0XBhYOFs5ZYcWNBt8s6Tvzn1ExGZRWUhW7SBGraXmA9Eoqdkku1/Yg rckwmOj2HK5gMHtqlaB2hWLVSfpBK88rPrsc3xLIabtCxRKeUjLj4DeV/SSSMvRg6JuB Vto+6jGNlIGuBFqA3mp6TKO6Xy6pdMpz+rQaGF0fxh/vYw7kvs1N6UyU/VHP2/1m1qJB +Np0thB6gd4oy3QIhEPTb5eUjALLK5VHCaqV6gEugGZbtViuGShCRDc7RBOaUG+9AKun je75ft93EGfzU98yqojh4ObpB8plReCYV4iK49YxFjG96D29H0OThJHWWQpYXoFFbQbf NVhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=7ClwwiYL5MaAd6g9xWmRVME3vEiVZ83RtKSsFLeZH90=; fh=lO88XmBrt1VKrexoG00mDMqKNWeaYV7M083mZrC+Q5c=; b=JDIYu6gWFz/WmbtELED/N9zidXkbPQJJiE4YuzYRETfmjlPUiltZlyS2zfOsYZwF5b mrLuNiTqzPIB2E+q1rXByw6698B5YqJ7xWbM8Mo2bvl0/FMt/BXov0u9ThvFYk4Nl2yS jN8gFnosZxT+910KvM1GFcLuiai5cbBzJMKs6mLzoKPNtAzdvbXUtgXoh+GZuqGQiqZE UxKKrgfE6SgSZ0hSSUU3BExJsH7nsp64YsZD/TOLcwUqzL7duELxRoeKSEpF4ZbnmkLR 2lQYp8hJ+gg7tXBDQCxI5eothcbvCNYVZQWkXZYtj1nArK1wo2sBEyX5tWFk6Hp8gZrJ qrWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=aD+wgnXl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id f4-20020a170902684400b001bbc855a8fcsi25863407pln.488.2023.10.02.11.58.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 11:58:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=aD+wgnXl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id A6DB28068A0C; Mon, 2 Oct 2023 11:41:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238825AbjJBSkt (ORCPT + 99 others); Mon, 2 Oct 2023 14:40:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238819AbjJBSkr (ORCPT ); Mon, 2 Oct 2023 14:40:47 -0400 Received: from omta38.uswest2.a.cloudfilter.net (omta38.uswest2.a.cloudfilter.net [35.89.44.37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B817FF2 for ; Mon, 2 Oct 2023 11:40:39 -0700 (PDT) Received: from eig-obgw-6003a.ext.cloudfilter.net ([10.0.30.151]) by cmsmtp with ESMTP id nLqAqhvgvytxcnNqOq6YGz; Mon, 02 Oct 2023 18:40:36 +0000 Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with ESMTPS id nNqNqw8X8Q6DInNqNqBqEc; Mon, 02 Oct 2023 18:40:35 +0000 X-Authority-Analysis: v=2.4 cv=UalC9YeN c=1 sm=1 tr=0 ts=651b0ea3 a=1YbLdUo/zbTtOZ3uB5T3HA==:117 a=Dx1Zrv+1i3YEdDUMOX3koA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=bhdUkHdE2iEA:10 a=wYkD_t78qR0A:10 a=VwQbUJbxAAAA:8 a=gXLdhW2jAAAA:8 a=MqvWAp6GOtdlVlTrVWUA:9 a=QEXdDO2ut3YA:10 a=AjGcO6oz07-iQ99wixmX:22 a=Dn9eIPSr_RzuO0KTJioD:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=embeddedor.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=7ClwwiYL5MaAd6g9xWmRVME3vEiVZ83RtKSsFLeZH90=; b=aD+wgnXlbRDuzRcV2OZazjH5P4 AqpZWHdIkg+cjMYqvbj8Vr1+wq0saI3cAHD/iPUBuk5J50iVbJFNZoGGu7vihEjTHEOmETr74aR9r pEMGfTzUr+DIc4LwYoiz7+MxyON0MbHV7vRAtNLw/sfZeTnaxSRlg0feSY7l+xTOGWRejO3g2TnmE l77Bp06LIg+h8JTnqgpTPKWX1b99Szb/E1fEDJx5dmTl95llZ3yYeGXW/UGc/WpW6mf5MRWapj7O3 38yTTPShFZCJugG27W/tXCcJHTxeuV7jkL8vGxqlW6z3IBhfGXtSElCkI+6UeyR9h2Mfoqj8FyHLT Jj0YvC6g==; Received: from 94-238-9-39.abo.bbox.fr ([94.238.9.39]:41648 helo=[192.168.1.98]) by gator4166.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1qnNqM-003NdX-1u; Mon, 02 Oct 2023 13:40:34 -0500 Message-ID: <734c7fdf-4c41-2890-dbe7-ddb23fd6bcc7@embeddedor.com> Date: Mon, 2 Oct 2023 20:40:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH][next] PCI/P2PDMA: Fix undefined behavior bug in struct pci_p2pdma_pagemap Content-Language: en-US To: Logan Gunthorpe , "Gustavo A. R. Silva" , Bjorn Helgaas Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org References: <29da763d-1570-7197-2d5a-03c5659b8b52@deltatee.com> From: "Gustavo A. R. Silva" In-Reply-To: <29da763d-1570-7197-2d5a-03c5659b8b52@deltatee.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 94.238.9.39 X-Source-L: No X-Exim-ID: 1qnNqM-003NdX-1u X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 94-238-9-39.abo.bbox.fr ([192.168.1.98]) [94.238.9.39]:41648 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 3 X-Org: HG=hgshared;ORG=hostgator; X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfB2FqVn/wSIbaE4Q729k9TukWIPeenaeD7OIFdycnIU9YqyN8JuovDG/iu8rZHKPGuqNEN1TKG/8qnvJ+wXdKHeI5mX/tH1cbNGJceHp0iZvXu3tLOWC W/oNf5/8a8yejOmRPfbpH/htrOLiOWKXyW4ii8iORSO8vZVXlnO+Q44iykhWgKuIveKikKV0hIY8FQ+K/cePhSAI41GVIlDbtfUy1cE5Ul5GLeSbVg0V5FbE X-Spam-Status: No, score=-2.9 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 02 Oct 2023 11:41:14 -0700 (PDT) On 10/2/23 18:07, Logan Gunthorpe wrote: > > > On 2023-10-01 15:08, Gustavo A. R. Silva wrote: >> `struct dev_pagemap` is a flexible structure, which means that it >> contains a flexible-array member at the bottom. This could potentially >> lead to an overwrite of the objects following `pgmap` in `struct >> pci_p2pdma_pagemap`, when `nr_range > 1`. >> >> Fix this by placing the declaration of object `pgmap` at the end of >> `struct pci_p2pdma_pagemap`. >> >> -Wflex-array-member-not-at-end is coming in GCC-14, and we are getting >> ready to enable it globally. >> >> Fixes: 0afea3814358 ("PCI/P2PDMA: Add provider's pci_dev to pci_p2pdma_pagemap struct") >> Fixes: a6e6fe6549f6 ("PCI/P2PDMA: Introduce private pagemap structure") >> Cc: stable@vger.kernel.org >> Signed-off-by: Gustavo A. R. Silva > > > Makes sense to me, thanks. > > Although, I'm not sure the fixes tags are appropriate. The > flexible-array member was introduced in 5.10 (b7b3c01b19) and both the > "fixed" commits predate that change by a number of releases. You're right. I'll remove those tags. > > Also, it's probably worth noting in the commit message that the p2pdma > code hardcodes nr_ranges to 1 (in pci_p2pdma_add_resource); so there is > no way to actually hit any bug with the current code. Yep. I mention that in this part "This could potentially lead to an overwrite of the objects following `pgmap` in `struct pci_p2pdma_pagemap`, when `nr_range > 1`." > > I totally agree that the patch should be applied to prevent possible > bugs being introduced in the future: > > Reviewed-by: Logan Gunthorpe Thanks for the RB and the feedback. :) -- Gustavo