Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp2931587pxy; Mon, 3 May 2021 11:09:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxceJXx/eSCZL7wupGTX7N2JRBdKE1uxlYOz52WW+3SeWsMES3uNvS9Q1/ZXaam3rF868VX X-Received: by 2002:a62:1b94:0:b029:28d:496d:10d0 with SMTP id b142-20020a621b940000b029028d496d10d0mr16232873pfb.28.1620065349020; Mon, 03 May 2021 11:09:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620065349; cv=none; d=google.com; s=arc-20160816; b=LxOceAJT2MR0opSitxYc8c7HIXCcO72qqUK33/41HGnfATGjEsRx83Q4wjkel0+HVO VUOXHEDnOBbJddPm8/Zvak/4IV78wD3U5CTTJivxZLnKXGNDKeiS9+xfYFzXyFEkbAoN eWykg4STjETaV86lrn2UkwrJe8Jhofgu8kYWaS+EZXpH8GhJ1aXJDyqlcQQRDotw1WFT O16W2koPZFDwfpuS65DqBkf3/PisNQ3dAv8bz68pZe0jIMqcZWLrII5giTHRJUggkQvt OHjOHZ+7pirqzF1420AonZu/IpZr93W0K0y0XD2vV0HDWsjlOJ+g4YIR0keaEYBrJAvU OUYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=CvIdh7PoFsgHHMy8MB6WlNW0ViD/jbS56DUb0aHqAdU=; b=wi8XpbbGqRWs4VFQEW+KZLQzP5O94cGfQiPfuSZbZvcwe4WzXS25haKBfpbwnWtm2G J8cbqiIW8mzlG5mLKxzI/ZOt6cDP6n8bACK4HSu3hrv8pgvc+ESd/ity630NP60e0uLM F4cFP6KoAewdVWR9qKjE1cpv3C7ITx3R6XLuhW/QMDfFdmbbvPnOwPa0eQlF4pIMxHpk pVXWuXEKYw90tepLOU6UYrLQbkPSb07Wl8mdteWOZp/YGnbaUfZGivV12TF/zynUHznj X/o/ZxKTpRysIfOwqk9jwKLlaz29CV10oOMGGxjtoIU4jM8CogpHMq9FWprqre9NCFpE BfJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="WzosU/8R"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i21si394381pgl.235.2021.05.03.11.08.54; Mon, 03 May 2021 11:09:09 -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=@infradead.org header.s=casper.20170209 header.b="WzosU/8R"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229616AbhECOrz (ORCPT + 99 others); Mon, 3 May 2021 10:47:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229546AbhECOry (ORCPT ); Mon, 3 May 2021 10:47:54 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75F04C06174A for ; Mon, 3 May 2021 07:47:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=CvIdh7PoFsgHHMy8MB6WlNW0ViD/jbS56DUb0aHqAdU=; b=WzosU/8RxawiSVl+UxrFbsmPxJ 2+BTBjzbLI4k/FmeaycFkYTayiJvpTZDaFKNmduGO12Z73xy2olESINQwHv4ewuTEAT2wQ4LWg769 Xp1FkanoC0LYu3FRPugR4AU2Ne42pb2fKDLoItVFDNvBlbhI500/Y3Bi2E/YhPU0erkHRt18BWh64 Nu54nq+mKtTMxbhWmOwyiV4Oa0e6ISVHKRBnVJYCSBT9pE9C49adTQLIZJDAqNuWUnF+Dgpn4BU7+ DMaj4CpePIvnplkOCNgiuq+5leCRazDgwVpxGA2rTefXK3KW6N6geukB0liHucVYM/r6hSEIYJBLi NJkht+5g==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1ldZoz-00FC9Y-V4; Mon, 03 May 2021 14:45:48 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 4981030022C; Mon, 3 May 2021 16:45:16 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 3311E2D69371E; Mon, 3 May 2021 16:45:16 +0200 (CEST) Date: Mon, 3 May 2021 16:45:16 +0200 From: Peter Zijlstra To: Dietmar Eggemann Cc: Vincent Guittot , Quentin Perret , Ingo Molnar , Juri Lelli , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Qais Yousef , Android Kernel Team , linux-kernel , Patrick Bellasi Subject: Re: [PATCH v3] sched: Fix out-of-bound access in uclamp Message-ID: References: <20210430151412.160913-1-qperret@google.com> <562004ff-9f60-bf37-df4c-547415ae2cd5@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <562004ff-9f60-bf37-df4c-547415ae2cd5@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 03, 2021 at 12:55:34PM +0200, Dietmar Eggemann wrote: > On 30/04/2021 17:27, Vincent Guittot wrote: > > On Fri, 30 Apr 2021 at 17:14, Quentin Perret wrote: > >> > >> Util-clamp places tasks in different buckets based on their clamp values > >> for performance reasons. However, the size of buckets is currently > >> computed using a rounding division, which can lead to an off-by-one > >> error in some configurations. > >> > >> For instance, with 20 buckets, the bucket size will be 1024/20=51. A > >> task with a clamp of 1024 will be mapped to bucket id 1024/51=20. Sadly, > >> correct indexes are in range [0,19], hence leading to an out of bound > >> memory access. > >> > >> Clamp the bucket id to fix the issue. > >> > >> Fixes: 69842cba9ace ("sched/uclamp: Add CPU's clamp buckets refcounting") > >> Suggested-by: Qais Yousef > >> Signed-off-by: Quentin Perret > > > > Reviewed-by: Vincent Guittot > Reviewed-by: Dietmar Eggemann Thanks!