Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp275409ybi; Wed, 29 May 2019 21:10:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqyegbCzi7wLhWzWBmYyU5GgcVl+baPE0wU9lxZhnT9nLNxfmMlz53aHkWiVRez6Wv7lzf5S X-Received: by 2002:a17:902:8e87:: with SMTP id bg7mr1846449plb.281.1559189452898; Wed, 29 May 2019 21:10:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559189452; cv=none; d=google.com; s=arc-20160816; b=FCb+vyhfZz2iByrIZO06nFbMTjyUGB/RbPnRRje3a63GFsJOeWjikiqPcyBcX39qqS WaNdqH0hU+XVyVcjA3jGwQGRfq69sUMhhgikayj6VvylMvAnbGUh8yNtPyVPU0WOIGpL ZI3nwiDVZVIpfV3Ijcm3HklzDTaQksP/zx5JKpMC9sQKr2kraB7RHuivlWWwo9/OcqtS qR4CjQfawYRsZzQh+KVxKK22rXJNasusFHkE5tr92nt5GzBPRNM9b14JRlAOxkAT3owu wc20Abd+cIum3PJL7Go/Sh6IaEDrDwOhJb6AMx0GtNocGqX0OSa09jeOCDqfk220Khjh Rxmw== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mYzHTGPu+kal2GpiXiYRiuJqjBWIoUIqmJO1v07k284=; b=Drvd/JsZF501WGVnA7ZrBavtiyigmcb8cP1dMyM7ZzTZnciHYfjKYZyAOlGXirKKjt kwY8cvnDocrdVlMWj4RGboRB7t+JVtssggLV/4LoYXf07qrwYhjZePPhxA+xRRZMEZ/f 1M6/mUKB6Mo62Pivu+ZZezjqwJWS9elcKiIc3/7JqVisWLYc0/c6kgqHyfeeSJ8Zn+v9 JFws1n1Es1M3ZxMy28YPrsFPjNi5nB6srHlpgBQDvMpL2hgBA0VOGZHsvzs39ZgBm+a6 WqIAwZpDkjbBsnP+gKRghgw2i/fZXwbj1CKUCWcjV0fbBeZG7q/lwt1CrN5Ex0rzfn9Q F1Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ybYMDG7p; 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 o31si1767385pje.45.2019.05.29.21.10.36; Wed, 29 May 2019 21:10:52 -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; dkim=pass header.i=@kernel.org header.s=default header.b=ybYMDG7p; 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 S1727081AbfE3EJT (ORCPT + 99 others); Thu, 30 May 2019 00:09:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:45502 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730963AbfE3DRN (ORCPT ); Wed, 29 May 2019 23:17:13 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8934824667; Thu, 30 May 2019 03:17:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186232; bh=Sggf7DE/dWqdGOyyTn7HrVZ2bSeYDvsNmoVhtkxp1Tw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ybYMDG7pNuUiujDHnVoCG0mHWhOIKNW5+JarrZStXJ2L9AcwX4/6oNP0Z9H1iR896 kGT0uYedBmkpAuAZHhIqkAyra0vjPw0szrax90W5SoPv0mPdp3U6i/t3NP0N5yXjW5 4N0HqrUHKlDrxwc74IOx+EgZwCQsxdLlQV0UGqRs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Konstantin Khlebnikov , Peter Zijlstra , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Sasha Levin Subject: [PATCH 4.19 138/276] sched/core: Handle overflow in cpu_shares_write_u64 Date: Wed, 29 May 2019 20:04:56 -0700 Message-Id: <20190530030534.341055704@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030523.133519668@linuxfoundation.org> References: <20190530030523.133519668@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 5b61d50ab4ef590f5e1d4df15cd2cea5f5715308 ] Bit shift in scale_load() could overflow shares. This patch saturates it to MAX_SHARES like following sched_group_set_shares(). Example: # echo 9223372036854776832 > cpu.shares # cat cpu.shares Before patch: 1024 After pattch: 262144 Signed-off-by: Konstantin Khlebnikov Acked-by: Peter Zijlstra Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/155125501891.293431.3345233332801109696.stgit@buzz Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin --- kernel/sched/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index bd5ae34c20c0b..6138754e5030f 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6491,6 +6491,8 @@ static void cpu_cgroup_attach(struct cgroup_taskset *tset) static int cpu_shares_write_u64(struct cgroup_subsys_state *css, struct cftype *cftype, u64 shareval) { + if (shareval > scale_load_down(ULONG_MAX)) + shareval = MAX_SHARES; return sched_group_set_shares(css_tg(css), scale_load(shareval)); } -- 2.20.1