Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1700415yba; Thu, 25 Apr 2019 04:23:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZXr15ZDqTKxQb/cADNOXndQ0ZHXkT8wM96GQUqPNdFD34esY+scxsO4Nrz33IwWBwAXEM X-Received: by 2002:a63:6907:: with SMTP id e7mr35606770pgc.209.1556191415269; Thu, 25 Apr 2019 04:23:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556191415; cv=none; d=google.com; s=arc-20160816; b=AWoVFDBMEVUTcQSTYdlyYQ9k9XhAGvRKwFgioKu+VYaehkUvGpH4Gwww5QWxkb2Ynb jrQbseFRF2XTA5W5ddWut3O4rPxDyk7R+LriEEmeTUdy+ApPcHBOz5nHC5foD4upSe7L RryvfF7fGtWjGmTw/dn7MnbH+ynz+9OOAOHPxL5d8f2xuaptNQhzUSKn8MsD2LXi1HJq FSeRH0itH8H9PVSmUkzYiPufxpnvfIRD5fpYgw3gZT/we2wLox6+XWfzKXjWs6SDnPPX tCxLxGba2R5WSyff+NggzFmeZ2zyreYYYjIWwiMKEy1/+pMiyVaqPcxojdUw5JIE2Apd t2Bw== 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=hAk8J21RYGVGGk+nHzMHcIxcmlujm3Yc5uJuOJHpT/4=; b=TJ4K8+pZ7/P8ikx0f1qyaxVl2uQs2gFdAS3mq6MaT1xlrQZw2R3GA9xHrUhKCuX6Ed Uks/zUbGxyuOzN9eoN6Nws7VV4vs0obVLr7v7XfHrtURm5l4HClq4VqH1WyzI7BZjwGG TLrdfEezy7mrLgmWgffK8EI6nGjt9g1GxtiJIMmMgKkPJH2kOojmSdA97Ai58qA1P8Bh mJkOhe74FPO9cN/6YZA36HR/PcEOboNzxP7fSdMp9xDMGyv++Gc0IdpgQDlMivNCAcyG jDAEBRlQ+Y2TqBmriVIBLwK7TI+qSSjRw092WTRIQJHF+PobTA7uwuk05c2p8s3D1FyA HErg== 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 gn6si21790983plb.167.2019.04.25.04.23.20; Thu, 25 Apr 2019 04:23:35 -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 S1731084AbfDXUW7 (ORCPT + 99 others); Wed, 24 Apr 2019 16:22:59 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:55705 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730569AbfDXUW6 (ORCPT ); Wed, 24 Apr 2019 16:22:58 -0400 Received: from p5de0b374.dip0.t-ipconnect.de ([93.224.179.116] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1hJOPs-00067V-SD; Wed, 24 Apr 2019 22:22:53 +0200 Date: Wed, 24 Apr 2019 22:22:52 +0200 (CEST) From: Thomas Gleixner To: Weikang shi cc: John Stultz , sboyd@kernel.org, LKML , swkhack@qq.com, Miroslav Lichvar Subject: Re: [PATCH] time: fix a assignment error in ntp module In-Reply-To: <20190422093421.47896-1-swkhack@gmail.com> Message-ID: References: <20190422093421.47896-1-swkhack@gmail.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 22 Apr 2019, Weikang shi wrote: > From: swkhack > > It is meanless to check a 64bit(txc->constant) value is postive > when the value has to be assigned to a 32 bit variable(*time_tai). > So I make a temp type conversion before the compare. Errm no. This is missing a proper range check in the first place. > Signed-off-by: swkhack > --- > kernel/time/ntp.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c > index 92a90014a..6b454eafc 100644 > --- a/kernel/time/ntp.c > +++ b/kernel/time/ntp.c > @@ -690,7 +690,7 @@ static inline void process_adjtimex_modes(const struct __kernel_timex *txc, > time_constant = max(time_constant, 0l); > } > > - if (txc->modes & ADJ_TAI && txc->constant > 0) > + if (txc->modes & ADJ_TAI && (int)txc->constant > 0) > *time_tai = txc->constant; > > if (txc->modes & ADJ_OFFSET) > -- > 2.17.1 > >