From patchwork Tue Feb 3 18:57:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 44276 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f199.google.com (mail-we0-f199.google.com [74.125.82.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7FBFF2034D for ; Tue, 3 Feb 2015 18:57:53 +0000 (UTC) Received: by mail-we0-f199.google.com with SMTP id u56sf22170567wes.2 for ; Tue, 03 Feb 2015 10:57:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=Cph21tUcIxaBB3kPj7skVQFN3Wn7V3wUWY1oSm2cN44=; b=bvJI191wtWVv6BDr1MPhiVzDjVA3p4aluGoipPWN/l1wwdujzxR0J5qiSEbtpaNkZi LVOjSFGROMiqBehIinko4c5EwQ7uM4hko1AszfZph8c9r/Cob5ZSTgfDKo7cvc0gXlEK Zk+T3MWUid/s4YsAiEMlaqvQaacUgILnWUz1CUcPC8HLrqJ1lCGBVxzco2S/VKz5sFq3 HXF6t/+5kiGPWb5mc1rAA/gowW61TD20aZ2PZXQvwT0/hI8FYxyRy03z2pUhiGlhwDZl MtK6DAS4dYyPPGU+PzwArmYm7IErx7ci2N13Ryn3DFG6Cyg/DvCkQlpN8ezrRO+qpUQy Z+7w== X-Gm-Message-State: ALoCoQmWU9fVoEAmWswSq5Etf5WM89lw5+sUWtp6VEKOF2ikz2rt4c1Nmp3b5/37CTm/0/wATwlt X-Received: by 10.194.239.41 with SMTP id vp9mr321752wjc.5.1422989872770; Tue, 03 Feb 2015 10:57:52 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.137 with SMTP id t9ls738460lag.44.gmail; Tue, 03 Feb 2015 10:57:52 -0800 (PST) X-Received: by 10.152.226.134 with SMTP id rs6mr17905428lac.98.1422989872578; Tue, 03 Feb 2015 10:57:52 -0800 (PST) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id an7si20053109lbd.64.2015.02.03.10.57.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Feb 2015 10:57:52 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by mail-lb0-f169.google.com with SMTP id f15so40364146lbj.0 for ; Tue, 03 Feb 2015 10:57:52 -0800 (PST) X-Received: by 10.152.2.41 with SMTP id 9mr5859597lar.59.1422989872410; Tue, 03 Feb 2015 10:57:52 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.35.133 with SMTP id h5csp21145lbj; Tue, 3 Feb 2015 10:57:51 -0800 (PST) X-Received: by 10.66.162.234 with SMTP id yd10mr28733999pab.26.1422989870775; Tue, 03 Feb 2015 10:57:50 -0800 (PST) Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com. [209.85.220.52]) by mx.google.com with ESMTPS id xt17si3518277pac.212.2015.02.03.10.57.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Feb 2015 10:57:50 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.52 as permitted sender) client-ip=209.85.220.52; Received: by mail-pa0-f52.google.com with SMTP id kx10so99548304pab.11 for ; Tue, 03 Feb 2015 10:57:49 -0800 (PST) X-Received: by 10.67.6.103 with SMTP id ct7mr40529990pad.49.1422989869783; Tue, 03 Feb 2015 10:57:49 -0800 (PST) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id rb3sm2898400pab.29.2015.02.03.10.57.48 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Feb 2015 10:57:48 -0800 (PST) From: John Stultz To: lkml Cc: John Stultz , Thomas Gleixner , Ingo Molnar , Sasha Levin , stable@vger.kernel.org Subject: [PATCH] ntp: Fixup adjtimex freq validation on 32bit systems Date: Tue, 3 Feb 2015 10:57:38 -0800 Message-Id: <1422989859-16456-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , For tip/timers/urgent. Additional validation of adjtimex freq values to avoid potential multiplication overflows were added in commit 5e5aeb4367b (time: adjtimex: Validate the ADJ_FREQUENCY values) Unfortunately the patch used LONG_MAX/MIN instead of LLONG_MAX/MIN, which was fine on 64bit systems, but being much smaller on 32bit systems caused false positives resulting in most direct frequency adjustments to fail w/ EINVAL. ntpd only does direct frequency adjustments at startup, so the issue was not as easily observed there, but other time sync applications like ptpd and chrony were more effected by the bug. See bugs: https://bugzilla.kernel.org/show_bug.cgi?id=92481 https://bugzilla.redhat.com/show_bug.cgi?id=1188074 Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Sasha Levin Cc: stable@vger.kernel.org Reported-by: Josh Boyer Reported-by: George Joseph Tested-by: George Joseph Signed-off-by: John Stultz --- One note: 0day kbuild bot complains about >> kernel/time/ntp.c:637: warning: comparison is always false due to limited range of data type >> kernel/time/ntp.c:639: warning: comparison is always false due to limited range of data type We could fix this via adding an extra (BITS_PER_LONG == 64) case before we check these to avoid it, but that seemed a bit too ugly to me. Thoughts? kernel/time/ntp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index 28bf91c..242774d 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c @@ -634,9 +634,9 @@ int ntp_validate_timex(struct timex *txc) return -EPERM; if (txc->modes & ADJ_FREQUENCY) { - if (LONG_MIN / PPM_SCALE > txc->freq) + if (LLONG_MIN / PPM_SCALE > txc->freq) return -EINVAL; - if (LONG_MAX / PPM_SCALE < txc->freq) + if (LLONG_MAX / PPM_SCALE < txc->freq) return -EINVAL; }