Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6760036ybi; Mon, 8 Jul 2019 08:12:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqxxjFBxApFeJssI82N/u0SUJwghlRl5v0QFy0rrfZsm8Ki2m0PnZ82JJl5dmgfKNvh50fOx X-Received: by 2002:a63:f953:: with SMTP id q19mr13881684pgk.367.1562598770170; Mon, 08 Jul 2019 08:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562598770; cv=none; d=google.com; s=arc-20160816; b=bDYyo9BNsvUqLtRWm2qnEBKdl4z/1MZ8eXDc9nqemaX8YvKJ4pvHJh3nv7lCzynUTq V/W9E7lXF4u+Jnpx1s/WyRDV/RrBn+wC9RbAg1e0hNpiNMEfjMwM+4Dg83ND2/LQ8/2r Mn/3ip5xgZ6Haq9F0OxGPlF6ESRsqj+GXHJoAsR5w19Ir1h07v50np0TwAHlEGBaGS/Z XLHCcb0kOONAnPJehXUzx6cG1MfvqF7fedi3sGDuDRfTfthwVckheP/DQcoNMN5voB6f Agx6A+GVyOV996Hb+Tt6pJ/UqgrobOtUJKfhqgiCdI1Gzwr0lhfeVkSdSuzw7KxZ9BWy h8TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=evGWBxOkRFEQ2jZF2RYbjfFYlAUI3oolxL1Q01UYUww=; b=FIaqSd4EbQCnJrxpPrv429deOCVbjD5yqoFuqxgshP6/gEWScNfuJ1KbPOr8xMCKst owYa5bJZc7+koQhomvo/IMR+a5qF9Z/lp+9wR75u0Qr78sFNuLW38bwRy6NY8QMpKKAG c+zzrJPW5dD1+ldbdb9S0v60VaGuOzPqB2U+o86lPEqtI6repXn66ikjVUXgZCDAkx3V 2n59ADFqNV1S7raK8Lwt0g9d0JKUPYm2y+M5Qjrau/F2SV/eJn2RFHDKy2rA7zTnZrhQ yQK0tkf7vPIih33zJ3m3USnpyI6GRX6bHDceR79I2D4JXC+4EWQlwcXKvkgXuq6IZghd C4Wg== 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 z24si8851428pga.335.2019.07.08.08.12.34; Mon, 08 Jul 2019 08:12:50 -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 S1729001AbfGHKml (ORCPT + 99 others); Mon, 8 Jul 2019 06:42:41 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2177 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725836AbfGHKml (ORCPT ); Mon, 8 Jul 2019 06:42:41 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 213007686DB78DAE8ABD; Mon, 8 Jul 2019 18:42:39 +0800 (CST) Received: from [127.0.0.1] (10.184.189.120) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.439.0; Mon, 8 Jul 2019 18:42:26 +0800 Subject: Re: [PATCH] time: Validate the usec before covert to nsec in do_adjtimex To: Thomas Gleixner CC: , , References: <1562572504-142115-1-git-send-email-zhangxiaoxu5@huawei.com> From: "zhangxiaoxu (A)" Message-ID: <2c4e8e8d-6e90-0d09-cf28-45330eb598ce@huawei.com> Date: Mon, 8 Jul 2019 18:42:13 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.184.189.120] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ?? 2019/7/8 17:24, Thomas Gleixner ะด??: > On Mon, 8 Jul 2019, ZhangXiaoxu wrote: > >> When covert the usec to nsec, it will multiple 1000, it maybe >> overflow and lead an undefined behavior. >> >> For example, users may input an negative tv_usec values when >> call adjtimex syscall, then multiple 1000 maybe overflow it >> to a positive and legal number. >> >> So, we should validate the usec before coverted it to nsec. > > That's correct, but the actuall inject function wants to keep the sanity > check, timekeeping_inject_offset is called only by timekeeping_warp_clock and do_adjtimex. The do_adjtimex already validate it, and timekeeping_warp_clock is set tv_nsec=0. We keep the sanity check is for some other maybe use this function? I had send a v2 to keep the sanity check in timekeeping_inject_offset. Thanks. > > Thanks, > > tglx > > . >