Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4060754ybg; Mon, 21 Oct 2019 03:10:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqyHrP7E/nYgPA4Y0jq2N9LrRb2LU1i9jQ1FlWYo1twEgl0FBNSawbaJr8GQJ8vzhSBC6g0E X-Received: by 2002:a17:906:524b:: with SMTP id y11mr20522026ejm.82.1571652634681; Mon, 21 Oct 2019 03:10:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571652634; cv=none; d=google.com; s=arc-20160816; b=YmpxsO586ujIbwtWfPNJlzXfCceH4/KvBFxkWLwSkNp6l7kO7j1eKRwO8QTAeVSkKu pmZ1XOSvwFz9z+AyN3fcsbZ+A8KIHptxMXv9oCmGLjl4D5shxqUzxQmzZc29UTXaSTaV 0GB5JcopcN+SXhdfkD9xmKejN+NusIRXat3VYzk7UDYR1dbV6DAGJrtXv/CoUmWRY99z 5pf6Ecq+IqNmU66uoTJIYZAihjnWwQU/e7h7dT7CdDhk0V0TWYN7LyZW2oAnvhJS8/6S CGG/M++RmRcr43M9B85Wivf1+aeG79PaJF6ghXrrhWrJqiHCBjwfzHpanFro57OmyYrj KiRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=Rne4WAfSmroga5TWU46vae5WFuWqa8FjBDwIuElfbco=; b=qqOQA/Pvg3Xbg36RpQDsvIUskyqFqIZZjKrGHIsnzCdiBoVCdw0PBZBp94IhTbwJnN EvVmbWDYW2Ni7toCq3AsPsCXqlgpBfZqh6AG89moYqUrxOfPy0Xvi1kK0nqvYYsfx/mQ ca4glOp+PAXVoTjAaMVUK3f1wMFnZcSJ2RAQwG9gD5TCH9fRHQJgSWennsiNAHdLrrCL 9ZvQH++5HmzpJnifIeAKGdP2NELxHJnapB9fkJfNT19CGvb5CKkyriVYxK9Hu212B9nq se6HxE27IR3wW0rN/h81Bfr1ZTFRB4aPifdZLWVTfmrxjLKk9d9RFXehGVQFDyju5cKi 2m4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x6si2539708eju.349.2019.10.21.03.10.11; Mon, 21 Oct 2019 03:10:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727832AbfJUKHb (ORCPT + 99 others); Mon, 21 Oct 2019 06:07:31 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:34189 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726767AbfJUKHb (ORCPT ); Mon, 21 Oct 2019 06:07:31 -0400 Received: from [5.158.153.52] (helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iMUaq-0006Yb-JY; Mon, 21 Oct 2019 12:07:16 +0200 Date: Mon, 21 Oct 2019 12:07:15 +0200 (CEST) From: Thomas Gleixner To: Andreas Schwab cc: Christophe Leroy , Nathan Lynch , "linuxppc-dev@ozlabs.org" , Vincenzo Frascino , LKML , Andy Lutomirski Subject: [PATCH] lib/vdso: Make clock_getres() POSIX compliant again In-Reply-To: <87eez7glre.fsf@igel.home> Message-ID: References: <0fc22a08-31d9-e4d1-557e-bf5b482a9a20__6444.28012180782$1571503753$gmane$org@c-s.fr> <87v9skcznp.fsf@igel.home> <87tv83zqt1.fsf@hase.home> <875zkjipra.fsf@igel.home> <87r237h01a.fsf@igel.home> <87eez7glre.fsf@igel.home> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A recent commit removed the NULL pointer check from the clock_getres() implementation causing a test case to fault. POSIX requires an explicit NULL pointer check for clock_getres() aside of the validity check of the clock_id argument for obscure reasons. Add it back for both 32bit and 64bit. Note, this is only a partial revert of the offending commit which does not bring back the broken fallback invocation in the the 32bit compat implementations of clock_getres() and clock_gettime(). Fixes: a9446a906f52 ("lib/vdso/32: Remove inconsistent NULL pointer checks") Reported-by: Andreas Schwab Signed-off-by: Thomas Gleixner Cc: stable@vger.kernel.org --- lib/vdso/gettimeofday.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/lib/vdso/gettimeofday.c +++ b/lib/vdso/gettimeofday.c @@ -214,9 +214,10 @@ int __cvdso_clock_getres_common(clockid_ return -1; } - res->tv_sec = 0; - res->tv_nsec = ns; - + if (likely(res)) { + res->tv_sec = 0; + res->tv_nsec = ns; + } return 0; } @@ -245,7 +246,7 @@ static __maybe_unused int ret = clock_getres_fallback(clock, &ts); #endif - if (likely(!ret)) { + if (likely(!ret && res)) { res->tv_sec = ts.tv_sec; res->tv_nsec = ts.tv_nsec; }