Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp681381pxv; Thu, 22 Jul 2021 09:37:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7lWxhkG2CkYVkBqpCx6B+1BfairnE1lDElvVx+IefuPdbVToREAXwWmMaO1P4ZbiGNhBD X-Received: by 2002:a6b:7901:: with SMTP id i1mr447948iop.41.1626971854290; Thu, 22 Jul 2021 09:37:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626971854; cv=none; d=google.com; s=arc-20160816; b=g13Lag889reQeSiKm+uh4TctooM7S0Ydv2auyJ9QS/BMzXBvS3+PpK6FzZzwjLtWsF UHHW0wfL6r4P/P5SQUPTNcSJsNzC+zrSPekIqyZlNCfOu5hNbKWt5Aj9CQpnEmGskMGO 8sKGpT7RMZ5AF5psL0neDrOT0pEP2L/F+sVnZ/vL+/tTNer8x0+mMXaYiltb2+DUVTHE 3IGPE3R8Y5fFHaJKXADxfpllLlOQcaDg/gs8zj5KUu4Ne4H7GRVlWj/XylgkNWiCW0ai gXnQoi4G4bhA6tQMVKrTJRhXQO60QO8jwoKL2GTBNbwcvMSVJvcK6Osy1HPz5uTYZw9J aGrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NG+WfEZ3Jy+ZUkS8Up3TCY5xYu7PmKEApQ0lasXIfN4=; b=PZ13wF5VFYdt/1zX20TUB+7a77N67xQfqKvI2MuTq0LF3aqdnBfQaiRF9elnNnya7V 8IPGjMZ1mmlP3FYsV/Hl399G0Xq8TVymeuZRB1R5laKyR3Dk+JuhgGgtadf6joH7F3XY YIlZQWsOQPTxGS0l5wXNoGi7dLlh5HXRGD1Dv+jSQybjnQkWwB/LdpfjJsO0EBq7CJPs KZhyo7K8+nrjsD+3Db50zK6xEoJYsjI5voskFSyWBkMQ9F8EUIni6kUjCUd8YTZBR6gQ tbwcS/+TZIp+Ted+DRhQv8RokQWhrVzakDljJQyUuMe+30Te23J/zXWvlNaoYRhWeYND rl5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2cGvHplJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n6si31773196ilj.66.2021.07.22.09.37.22; Thu, 22 Jul 2021 09:37:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2cGvHplJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229945AbhGVPz6 (ORCPT + 99 others); Thu, 22 Jul 2021 11:55:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:58980 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231152AbhGVPyu (ORCPT ); Thu, 22 Jul 2021 11:54:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0300361362; Thu, 22 Jul 2021 16:35:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626971725; bh=ZmT+drcZBBH0K4+KL76eoM8ZjibvMPXxGj91oQO4ZK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2cGvHplJZNiXbKNIoLi3YCpWBia5M2tO8+msS9B9iLas2d45BD5GMxMc8T75O21hz 6kU7vEqxYuxToI+4tKTAoulyGI8WtZ+7I4+M9je526obkte/fKbZxvwnz0kjbqDegm KlX2CSsCzrwPuaP9RnBtN5b2Nh4GS7J7oEHV//x4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Odin Ugedal , "Peter Zijlstra (Intel)" , Ben Segall , Sasha Levin Subject: [PATCH 5.4 42/71] sched/fair: Fix CFS bandwidth hrtimer expiry type Date: Thu, 22 Jul 2021 18:31:17 +0200 Message-Id: <20210722155619.270341479@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210722155617.865866034@linuxfoundation.org> References: <20210722155617.865866034@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Odin Ugedal [ Upstream commit 72d0ad7cb5bad265adb2014dbe46c4ccb11afaba ] The time remaining until expiry of the refresh_timer can be negative. Casting the type to an unsigned 64-bit value will cause integer underflow, making the runtime_refresh_within return false instead of true. These situations are rare, but they do happen. This does not cause user-facing issues or errors; other than possibly unthrottling cfs_rq's using runtime from the previous period(s), making the CFS bandwidth enforcement less strict in those (special) situations. Signed-off-by: Odin Ugedal Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Ben Segall Link: https://lore.kernel.org/r/20210629121452.18429-1-odin@uged.al Signed-off-by: Sasha Levin --- kernel/sched/fair.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index d2ba080ea742..74cb20f32f72 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4786,7 +4786,7 @@ static const u64 cfs_bandwidth_slack_period = 5 * NSEC_PER_MSEC; static int runtime_refresh_within(struct cfs_bandwidth *cfs_b, u64 min_expire) { struct hrtimer *refresh_timer = &cfs_b->period_timer; - u64 remaining; + s64 remaining; /* if the call-back is running a quota refresh is already occurring */ if (hrtimer_callback_running(refresh_timer)) @@ -4794,7 +4794,7 @@ static int runtime_refresh_within(struct cfs_bandwidth *cfs_b, u64 min_expire) /* is a quota refresh about to occur? */ remaining = ktime_to_ns(hrtimer_expires_remaining(refresh_timer)); - if (remaining < min_expire) + if (remaining < (s64)min_expire) return 1; return 0; -- 2.30.2