From patchwork Wed Jan 7 18:12:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 42850 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6B5892055F for ; Wed, 7 Jan 2015 18:12:52 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id u14sf940403lbd.11 for ; Wed, 07 Jan 2015 10:12:51 -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=H1M5jGmvHt+6BVBxJepORpz+6tb9JROiBmgZFi3XAmI=; b=j0mV4FO3eJv6VG7KjTVuqDgfFMBbArDteMHR/nJPe1H4tVpfZw0vr6s5qVy4k8vagN sTmOtJaVwa6JPL2ET2KODi+qiLwWn4AuyObB0PtCRrbuPBt3ZUJP2d4SKTgfRqWCotyL DYKrFReHQTmz6Y9X4fPhyFxP8pPaYGbBwbCFBqswU/uptlNsGLvM8A4ro9B10AQRmLqe gRFv/RObDLaPHU/3ZxPkwuGclciEd73Th1nV1jThwiEGtXCZODBcQUlNjy61ZulpFfeg dnPRSN6nZ/rph0BZDpnmdY4KXmvsJ+1wgGsOxLPlDopRZGhUkwTXiGfO0JmOIilWzXdN AxMg== X-Gm-Message-State: ALoCoQmaTg3vBgqxnngmVBtQnYd1Fa6PIJOHKqUBDG0VawVzHTdITzQJgYjXs/fOIjBLwebEcQ68 X-Received: by 10.112.171.74 with SMTP id as10mr532751lbc.8.1420654371003; Wed, 07 Jan 2015 10:12:51 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.202.198 with SMTP id kk6ls189551lac.103.gmail; Wed, 07 Jan 2015 10:12:50 -0800 (PST) X-Received: by 10.112.140.196 with SMTP id ri4mr6860737lbb.55.1420654370861; Wed, 07 Jan 2015 10:12:50 -0800 (PST) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id lk10si4292290lac.5.2015.01.07.10.12.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 07 Jan 2015 10:12:50 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by mail-la0-f53.google.com with SMTP id gm9so5085213lab.12 for ; Wed, 07 Jan 2015 10:12:50 -0800 (PST) X-Received: by 10.152.6.132 with SMTP id b4mr7003829laa.59.1420654370144; Wed, 07 Jan 2015 10:12:50 -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 c8csp20175lbb; Wed, 7 Jan 2015 10:12:48 -0800 (PST) X-Received: by 10.68.132.169 with SMTP id ov9mr7826859pbb.74.1420654361854; Wed, 07 Jan 2015 10:12:41 -0800 (PST) Received: from mail-pa0-f51.google.com (mail-pa0-f51.google.com. [209.85.220.51]) by mx.google.com with ESMTPS id qt4si4411475pbb.75.2015.01.07.10.12.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 07 Jan 2015 10:12:41 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.51 as permitted sender) client-ip=209.85.220.51; Received: by mail-pa0-f51.google.com with SMTP id ey11so6323111pad.10 for ; Wed, 07 Jan 2015 10:12:41 -0800 (PST) X-Received: by 10.66.224.72 with SMTP id ra8mr7531865pac.43.1420654360517; Wed, 07 Jan 2015 10:12:40 -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 pd9sm2429545pdb.35.2015.01.07.10.12.39 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Jan 2015 10:12:39 -0800 (PST) From: John Stultz To: lkml Cc: Sasha Levin , Thomas Gleixner , Ingo Molnar , stable , Andy Lutomirski , John Stultz Subject: [PATCH 2/2] time: adjtimex: Validate the ADJ_FREQUENCY values Date: Wed, 7 Jan 2015 10:12:20 -0800 Message-Id: <1420654340-3009-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1420654340-3009-1-git-send-email-john.stultz@linaro.org> References: <1420654340-3009-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.53 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 Cc: Andy Lutomirski 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; }