Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp3817962ybk; Tue, 19 May 2020 13:44:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfWXncfy2ODfeT0/VSbwelC1JixZ1nJFLnki/U7uYAsM4uq3dR5+pxTSLI+ljTWifRVCQh X-Received: by 2002:a50:e70a:: with SMTP id a10mr612515edn.38.1589921054435; Tue, 19 May 2020 13:44:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589921054; cv=none; d=google.com; s=arc-20160816; b=s+j+j2bDKk1pVbSqDI1sOmzErVbmNRph+viqTPzSICZ+ENJbQG2B45TLWd31BoD5WM 2Ay59VdZpck7cx6csba6UuVsqt6+Iq1su+4nd0ugpiG0hj3wQxrSPoQjFrbQzQHmVyRy xGadjZmCE0LvoYvyX0kTdYmpwlt5X7BhiyGY+8hGIAD4Sm4GlQ46em9BFTS5UwXTCzYa INdaXkNfnryZHecMt7iaXWQjhksSZWy/CVTO42VMjcV1iB+Y3o8+yFExivHxhzd0siE5 OxFhk3GN2agEPlrcnzHEY9o6KI7nINXMDFnMiQt3Fa3V5Sk/lg5684Oeu4yNRlvDGDtR a6zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=8vXABvG11zmJXZu8TGbHZpzwWNurCc7kUYEDOv40sps=; b=AFU+roRoA9/7mtR76sU0JjgTFEO5nRMwvGvCmRGCUc2fT5SwW1swlwRuqnHF1ShZLd a8sMpz/xOzX5zwnOS8CiJC/yhOXKMCWjTD7mDdozrtKTHb0OjoFEtibrim0EGSsh6tPQ Q3cY2btnw0+vaPOuGWwxyHuJPxhoOObQKRV0us7zDnpxtDgtdUNuAVx625VsxVCSEtx7 8skeMd2X1yzBbFzzU9AcB3gA0pkQK7PhgwUEjCrDaDxyv7QVzzNSFbGJ/AWabxOIzS+t US6cqLNaZFYja2yoxCXp5GXLmGgM29SBA8gGDljmwMFQfUqvgT/lX97IC7/+eWH5JGn/ U2Hw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l16si287277edv.461.2020.05.19.13.43.51; Tue, 19 May 2020 13:44:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727065AbgESUls (ORCPT + 99 others); Tue, 19 May 2020 16:41:48 -0400 Received: from brightrain.aerifal.cx ([216.12.86.13]:59274 "EHLO brightrain.aerifal.cx" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726318AbgESUlr (ORCPT ); Tue, 19 May 2020 16:41:47 -0400 Date: Tue, 19 May 2020 16:41:44 -0400 From: Rich Felker To: Adhemerval Zanella Cc: Arnd Bergmann , Vincenzo Frascino , Russell King - ARM Linux , Will Deacon , Jack Schmidt , Linux ARM , Linux Kernel Mailing List , Szabolcs Nagy , Thomas Gleixner , Stephen Boyd Subject: Re: clock_gettime64 vdso bug on 32-bit arm, rpi-4 Message-ID: <20200519204143.GG1079@brightrain.aerifal.cx> References: <0c2abcd1-7da8-2559-1e93-4c3bdd38dec1@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0c2abcd1-7da8-2559-1e93-4c3bdd38dec1@linaro.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 19, 2020 at 05:24:18PM -0300, Adhemerval Zanella wrote: > > > On 19/05/2020 16:54, Arnd Bergmann wrote: > > Jack Schmidt reported a bug for the arm32 clock_gettimeofday64 vdso call last > > month: https://github.com/richfelker/musl-cross-make/issues/96 and > > https://github.com/raspberrypi/linux/issues/3579 > > > > As Will Deacon pointed out, this was never reported on the mailing list, > > so I'll try to summarize what we know, so this can hopefully be resolved soon. > > > > - This happened reproducibly on Linux-5.6 on a 32-bit Raspberry Pi patched > > kernel running on a 64-bit Raspberry Pi 4b (bcm2711) when calling > > clock_gettime64(CLOCK_REALTIME) > > Does it happen with other clocks as well? > > > > > - The kernel tree is at https://github.com/raspberrypi/linux/, but I could > > see no relevant changes compared to a mainline kernel. > > Is this bug reproducible with mainline kernel or mainline kernel can't be > booted on bcm2711? > > > > > - From the report, I see that the returned time value is larger than the > > expected time, by 3.4 to 14.5 million seconds in four samples, my > > guess is that a random number gets added in at some point. > > What kind code are you using to reproduce it? It is threaded or issue > clock_gettime from signal handlers? Original report thread is here: https://github.com/richfelker/musl-cross-make/issues/96 The reporter originally misunderstood the issue and wrongly attributed it to difference between gettimeofday and clock_gettime but it was just big jumps between successive vdso clock_gettime64 calls. No transformation was being done on the output of the vdso function; as long as it succeeds musl just returns directly with the value it stored in the timespec. No threads or anything fancy were involved. Current musl will no longer call it but you should be able to dlopen("linux-gate.so.1", RTLD_NOW|RTLD_LOCAL) then use dlsym to get its address and call it (not tested; I've never used it this way). > > - The current musl git tree has been patched to not call clock_gettime64 > > on ARM because of this problem, so it cannot be used for reproducing it. > > So should glibc follow musl and remove arm clock_gettime6y4 vDSO support > or this bug is localized to an specific kernel version running on an > specific hardware? For musl it was important to disable it asap pending a fix, because users are expected to generate static binaries, and these could make it into the wild without anyone realizing they're broken until much later when run on an affected kernel (especially since pre-5.6 kernels would hide the issue entirely due to lacking vdso). Ideally a fix will be something we can detect (e.g. new symbol version) so as not to risk calling the broken one, but whether that's necessary may depend on what's affected. I'm not sure if glibc should do the same; it's not often used in static linking, and replacing libc (shared lib, or re-static-linking which LGPL requires you to facilitate to distribute static binaries) could solve the issue on affected systems. Rich