Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3371141ybi; Fri, 5 Jul 2019 06:19:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqz3mAhTE0+6wOQSya3HI3BoeXTn8niN/5Gl02D8mI8D/mpOa45k572+a1ADpOB6SXmaXtTq X-Received: by 2002:a65:6256:: with SMTP id q22mr3465029pgv.408.1562332750533; Fri, 05 Jul 2019 06:19:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562332750; cv=none; d=google.com; s=arc-20160816; b=I46oDwlKZyvSPGgQtRmYs6K2HTbiW56P7dDA1fDvLiUOnJsUKmoBGXANoiK4PInlty htIvuAF1u/QOP7qWaI3mF/wobWSNqN26P8T+bWVJd1baUXEQ5U3/iEUYDBn3YAmoRXxu 2TjRXzOrMXLdG89RA0iAxrJ1ACpd47jCeBZXB2NUFuxEBoXmuRLHpqnhmWAgoz1xqG/1 SUyDCLcu/LGqM3q8hKFjaMq4xWy9BpGzGWBaUs7yXq/ckHCkQdQ0+TWhfEM7HZdlu8mo c70xmqT8xoZcVY+Msa5t6qUGSb0N6Ir7hnzEpmjawzbF6mZAaH1+Tz5gYK7DH1imrC+2 Yr2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=YSfYBdjq9eXwTiCay9jCI9dTcH2k+TAMpMGOQVBE8Rc=; b=KfLgNtRkKv3Eyts+lE5aAvrlCbkYie6riH5LUAE4Hh7CySIDsGT2pqI47IonyK0okB ByDYJnBxrKojUNn6SzC77ezhfyzj24BRW0CJscrAo6kBucrPn9kHGLlIwDkwrJz6HTx4 UAfJ1CZovvCTdPIpFCZM/tltBg/yAZhTGk/18IqZ6CuxZL+H9FNznjb7WkvR9IuE4JTL giMlpeLYU7XjwW/shVJjl3O0QU7YLFieovSc/NBKAks7fNQbaleYKWwCqQ1/416Mvz8D ajo1QG/YUSxgqRMiPLl65sRuza58oEoaoaiZCIuGBonJr4/ARutyFM9MOGlbxeDHSVAd Y/ow== 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 f96si8891838plb.339.2019.07.05.06.18.55; Fri, 05 Jul 2019 06:19:10 -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 S1728481AbfGEMdO (ORCPT + 99 others); Fri, 5 Jul 2019 08:33:14 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8712 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725601AbfGEMdO (ORCPT ); Fri, 5 Jul 2019 08:33:14 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 02C3EBD676E72E9322B4; Fri, 5 Jul 2019 20:33:12 +0800 (CST) Received: from [127.0.0.1] (10.184.213.217) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.439.0; Fri, 5 Jul 2019 20:33:05 +0800 Subject: Re: [PATCH] time: compat settimeofday: Validate the values of tv from user To: Thomas Gleixner CC: , , , , References: <1562318088-37669-1-git-send-email-zhengbin13@huawei.com> From: "zhengbin (A)" Message-ID: <39dd218b-4fc1-83bd-df2a-3cd69cc90c72@huawei.com> Date: Fri, 5 Jul 2019 20:32:55 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [10.184.213.217] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/7/5 20:14, Thomas Gleixner wrote: > Zhengbin, > > On Fri, 5 Jul 2019, zhengbin wrote: > >> Similar to commit 6ada1fc0e1c4 >> ("time: settimeofday: Validate the values of tv from user"), >> an unvalidated user input is multiplied by a constant, which can result >> in an undefined behaviour for large values. While this is validated >> later, we should avoid triggering undefined behaviour. > I surely agree with the patch, but the argument that this is validated > later and we just should avoid UB in general is just wrong. > > For a wide range of negative tv_usec values the multiplication overflow > turns them in positive numbers. So the 'validated later' is not catching > the invalid input. > > So 'should avoid ....' is just the wrong argument here. > > Validation _is_ required before the multiplication so UB won't turn an > invalid value into a valid one. > > Thanks, > > tglx Strongly agree with this, I send a v2 patch, modify the comment? > > . >