Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3662046pxv; Mon, 26 Jul 2021 08:57:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMpqSVj/djPl1YRnRm7csTnzYpKSnNQsizfoPpqATtDKILnIF1nRDs866PHuUE+vrDNZJ2 X-Received: by 2002:a92:d3cb:: with SMTP id c11mr13922301ilh.178.1627315037430; Mon, 26 Jul 2021 08:57:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627315037; cv=none; d=google.com; s=arc-20160816; b=cFWRsg/J+n9lnS+V3qkP89l7aL7oyWFvqetXAM3JW7ftvNSpuoKustm7FULb7d9RKm GJf2od60TC3ClQ/5SC/tfgajibgqzhaGoqc0luXt4YprRXRvw2IZLHy6HVRqc0vnmeZ2 fz+IL+IYJShmlL4zOGFeSazhXswx7PYXwNAkTZAtZMsRVzqVqZhj++56hgW1dpQvNPMZ g7pu4QzYJc+v0oEldrz8/PZzTia2u3FFYNSFyT0QjzI5jaoQ/U5We4eCWaMiEasJLxRt AbgKu2B3fbV8fecFJ9HiZWb/a2a+Q1mjYpoyWBkGDrb8EVpjXvH1+gZSnnN2O3kLp26O LIeQ== 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=4Lh2WQ3cW57hGSfdmV0W8bQ+gRn1rnrXMTx+a/VJHts=; b=v/FR7xrYPWS7zx78CjNUplDlJfB0UICBlbCGzqPHemS9XwY5ucKyoYa4ZGsn/ZU3Hp GNeWpNrb/yMQqyQogiwCyG1W86FopEwF8WrEqB9D0rcb8ZHBQlby17tRQmbvqHlVH3tC OzpHTSxE5r01J1BZmIv0v4nNYV1Tbbqo7CtUl1sG9+WNmeEz4sEHMurNgYiwwm+Xd6Jc VYWfdPxH5iEpO5tJqt/ZZBkR3e19bgjxtAH6/2aMicRNx9730daQAxmQufM3fc4Q9KSl HGtD/tm52DRIMEaw6zQcHeuNY3dFn8oxahAX5a6JbXlxh4uc9woHwm0BTeqwgl+iVnkl 5x0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nwQRiqDM; 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 t16si253115ilm.159.2021.07.26.08.57.03; Mon, 26 Jul 2021 08:57:17 -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=nwQRiqDM; 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 S235374AbhGZPK4 (ORCPT + 99 others); Mon, 26 Jul 2021 11:10:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:47542 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236163AbhGZPGa (ORCPT ); Mon, 26 Jul 2021 11:06:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 576F060F59; Mon, 26 Jul 2021 15:46:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627314418; bh=6Y9W5CE7mr7KW6UlyBi2buo11m/O+O5p28a1c+IyMfk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nwQRiqDMlaVhSblKbhCqqunFtgfVAje8QjT2wMrhKV7fuPYSltGDi7aDJ7TWEUry2 hzjYmD7qBnkWJ1pt6ujXskj+B7vUubuQwWTzeoRhpr2Mwsqe9xtZMPi0MlR0vpU3zl 01i8QyCJ25mkve2QduNSxkek3FKndHg7NW1e0EYo= 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 4.14 22/82] sched/fair: Fix CFS bandwidth hrtimer expiry type Date: Mon, 26 Jul 2021 17:38:22 +0200 Message-Id: <20210726153828.884613765@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153828.144714469@linuxfoundation.org> References: <20210726153828.144714469@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 37ac76dce908..3ff60230710c 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4464,7 +4464,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)) @@ -4472,7 +4472,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