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 0E184C27C4F for ; Sun, 30 Jun 2024 13:29:37 +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:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nPm4J6tD3u++zkElLlv3LDbcRnJ1HXt4ilQ34y74f+A=; b=H/7Cm915o9ZHH1zK+J7lPKdnFe 6OP3AGHMGpMoaOugWT6hwMbpMenQaZD2NTtitJQofdptoV8jl4hfD7JGJLTBkwh8yK82FEbut0hW7 TmBhTuN6Gtkrx2lvo6z7ArQkBtZmD8l5SJZFo+Vo8rl3RlSyyk25Wygg1UsVFSRHZpdWhKLGjdyK6 zIOzNCvs7qVYjdOxp336TpxF0Qwtn16YcnJaCuEje4FDqfipxBLfAw9z1QZPjfasaMpSGfmBqbsY2 vPNssUSxVL6CZeywttm58fLZuN+PwCBqCcrur/qtrXxHZa5Ph8A8XsdpOPAuYtd0sOeDcOxLuvIMr atyKsZ+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sNucI-00000000RMU-1O6V; Sun, 30 Jun 2024 13:29:18 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sNuc8-00000000RKQ-04ui for linux-arm-kernel@lists.infradead.org; Sun, 30 Jun 2024 13:29:09 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 7D71960BE9; Sun, 30 Jun 2024 13:29:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94DADC2BD10; Sun, 30 Jun 2024 13:29:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719754146; bh=ChFb8w15BttkA8Gd38P/acg2lX8jxg3AeR6dCf7FnUk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ifzeGgc1XPqx+MtSb9wIhYQKdSYS+/J+fwqGorROaN67YFRM/STdky6UuWpNhVyLw z8GC43AJg4Im2K/Ryq0gJG2Pyu32+fx49gEeQnQRCPPCWA+7b0HvR367HICrhYrdbu hs2MwLJhopRfIyNColSNZ5x5W1OjkUQ1Kzxc7XD5/14Z1Bgi3tUB18SX48HBLS6TrN tuyw5sk9l5P13hiWKilWIwQekNuQJ8c0tGUD3VF5ajg94CmRe1EU6qjYYdAROTsarG 695L5QuZsPICkubKeh5Wl45ajosLI9iRdkXL1Keg2/r5NegBHWHpJZfAOpj/ue7OxN QulWDHuDUXqoA== Date: Sun, 30 Jun 2024 14:28:59 +0100 From: Simon Horman To: David Woodhouse Cc: Peter Hilber , linux-kernel@vger.kernel.org, virtualization@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-rtc@vger.kernel.org, "Ridoux, Julien" , virtio-dev@lists.linux.dev, "Luu, Ryan" , "Christopher S. Hall" , Jason Wang , John Stultz , "Michael S. Tsirkin" , netdev@vger.kernel.org, Richard Cochran , Stephen Boyd , Thomas Gleixner , Xuan Zhuo , Marc Zyngier , Mark Rutland , Daniel Lezcano , Alessandro Zummo , Alexandre Belloni , Kees Cook , linux-hardening@vger.kernel.org Subject: Re: [RFC PATCH v2] ptp: Add vDSO-style vmclock support Message-ID: <20240630132859.GC17134@kernel.org> References: <20231218073849.35294-1-peter.hilber@opensynergy.com> <684eac07834699889fdb67be4cee09319c994a42.camel@infradead.org> <671a784b-234f-4be6-80bf-5135e257ed40@opensynergy.com> <4a0a240dffc21dde4d69179288547b945142259f.camel@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4a0a240dffc21dde4d69179288547b945142259f.camel@infradead.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240630_062908_228297_9FE4A805 X-CRM114-Status: GOOD ( 20.03 ) 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 + Kees Cook, linux-hardening On Tue, Jun 25, 2024 at 08:01:56PM +0100, David Woodhouse wrote: > From: David Woodhouse > > The vmclock "device" provides a shared memory region with precision clock > information. By using shared memory, it is safe across Live Migration. > > Like the KVM PTP clock, this can convert TSC-based cross timestamps into > KVM clock values. Unlike the KVM PTP clock, it does so only when such is > actually helpful. > > The memory region of the device is also exposed to userspace so it can be > read or memory mapped by application which need reliable notification of > clock disruptions. > > Signed-off-by: David Woodhouse ... > diff --git a/drivers/ptp/ptp_vmclock.c b/drivers/ptp/ptp_vmclock.c ... > +static int vmclock_probe(struct platform_device *pdev) > +{ ... > + /* If there is valid clock information, register a PTP clock */ > + if (st->cs_id) { > + st->ptp_clock_info = ptp_vmclock_info; > + strncpy(st->ptp_clock_info.name, st->name, sizeof(st->ptp_clock_info.name)); Hi David, W=1 allmodconfig builds with gcc-13 flag the following. Reading the documentation of strncpy() in fortify-string.h, I wonder if strscpy() would be more appropriate in this case. In file included from ./include/linux/string.h:374, from ./include/linux/bitmap.h:13, from ./include/linux/cpumask.h:13, from ./arch/x86/include/asm/paravirt.h:21, from ./arch/x86/include/asm/cpuid.h:62, from ./arch/x86/include/asm/processor.h:19, from ./include/linux/sched.h:13, from ./include/linux/ratelimit.h:6, from ./include/linux/dev_printk.h:16, from ./include/linux/device.h:15, from drivers/ptp/ptp_vmclock.c:8: In function 'strncpy', inlined from 'vmclock_probe' at drivers/ptp/ptp_vmclock.c:480:3: ./include/linux/fortify-string.h:125:33: warning: '__builtin_strncpy' specified bound 32 equals destination size [-Wstringop-truncation] 125 | #define __underlying_strncpy __builtin_strncpy | ^ ./include/linux/fortify-string.h:205:16: note: in expansion of macro '__underlying_strncpy' 205 | return __underlying_strncpy(p, q, size); ...