From patchwork Fri Jan 2 19:51:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 42705 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f197.google.com (mail-we0-f197.google.com [74.125.82.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2728626CD1 for ; Fri, 2 Jan 2015 19:51:23 +0000 (UTC) Received: by mail-we0-f197.google.com with SMTP id w61sf2406936wes.0 for ; Fri, 02 Jan 2015 11:51:22 -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:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=/YXzXtZ5i5x6iYQwm/uvympmUz2Wohhgooy+soyUtaY=; b=a6s64FNTyAk8x/2dNrHQnV+gSYRGhog7aIy7Y6gnUky7ZRvUcIkXNe2VHtfsh9Pasx aHoWbEvsijKOCgFoLvpW8gXFYOAum52X0KGhq1OZE9l5hX+79l77RieL34lLGKuCZRXI LfULUnvwZhXOCOTELUA8sNR73dU3bGfUmFvCw0+wdhxrIwSciHU89rNV4xqmmuM8AkI7 8CGuUhbnqklgBHP90W0TJr/+s0NiQNGJq/CRY8yBlTuxII9Hy1rDsyIAjzg1XN2W3HFY yJ8GhPTxiKO7ibQhIa3i3all1s/+8hSoeaDqGzFQaa3J5CxsR0UH0DgUBRDwKwYuOyRS V9rQ== X-Gm-Message-State: ALoCoQlMgN3qXCEhltsnKKJpIROg6yQor0w+SlLY7VbcQE/7oX6I90dDuEDwAaDYqQswuCr244IG X-Received: by 10.152.8.67 with SMTP id p3mr346983laa.4.1420228282408; Fri, 02 Jan 2015 11:51:22 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.71 with SMTP id k7ls1850654laf.9.gmail; Fri, 02 Jan 2015 11:51:22 -0800 (PST) X-Received: by 10.152.204.70 with SMTP id kw6mr78835516lac.53.1420228282274; Fri, 02 Jan 2015 11:51:22 -0800 (PST) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id v3si32345830lae.26.2015.01.02.11.51.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 02 Jan 2015 11:51:22 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by mail-la0-f44.google.com with SMTP id gd6so16083811lab.3 for ; Fri, 02 Jan 2015 11:51:22 -0800 (PST) X-Received: by 10.112.131.1 with SMTP id oi1mr76436338lbb.2.1420228282078; Fri, 02 Jan 2015 11:51:22 -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.9.200 with SMTP id c8csp277544lbb; Fri, 2 Jan 2015 11:51:21 -0800 (PST) X-Received: by 10.70.54.37 with SMTP id g5mr126411849pdp.71.1420228278789; Fri, 02 Jan 2015 11:51:18 -0800 (PST) Received: from mail-pd0-f175.google.com (mail-pd0-f175.google.com. [209.85.192.175]) by mx.google.com with ESMTPS id pn5si71058845pbb.72.2015.01.02.11.51.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 02 Jan 2015 11:51:18 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.192.175 as permitted sender) client-ip=209.85.192.175; Received: by mail-pd0-f175.google.com with SMTP id g10so24160173pdj.20 for ; Fri, 02 Jan 2015 11:51:17 -0800 (PST) X-Received: by 10.70.22.208 with SMTP id g16mr122970445pdf.141.1420228276411; Fri, 02 Jan 2015 11:51:16 -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 jt8sm33913718pbc.6.2015.01.02.11.51.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 02 Jan 2015 11:51:15 -0800 (PST) From: John Stultz To: lkml Cc: Sasha Levin , Thomas Gleixner , Ingo Molnar , stable , John Stultz Subject: [PATCH 2/2] time: adjtimex: Validate the ADJ_FREQUENCY values Date: Fri, 2 Jan 2015 11:51:08 -0800 Message-Id: <1420228268-2161-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1420228268-2161-1-git-send-email-john.stultz@linaro.org> References: <1420228268-2161-1-git-send-email-john.stultz@linaro.org> 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.215.44 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: , From: Sasha Levin Verify that the frequency value from userspace is valid and makes sense. Unverified values can cause overflows later on. Cc: Thomas Gleixner Cc: Ingo Molnar Cc: stable Signed-off-by: Sasha Levin [jstultz: Fix up bug for negative values and drop redunent cap check] Signed-off-by: John Stultz --- kernel/time/ntp.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index 87a346f..28bf91c 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c @@ -633,6 +633,13 @@ int ntp_validate_timex(struct timex *txc) if ((txc->modes & ADJ_SETOFFSET) && (!capable(CAP_SYS_TIME))) return -EPERM; + if (txc->modes & ADJ_FREQUENCY) { + if (LONG_MIN / PPM_SCALE > txc->freq) + return -EINVAL; + if (LONG_MAX / PPM_SCALE < txc->freq) + return -EINVAL; + } + return 0; }