From patchwork Thu Oct 10 11:39:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 175746 Delivered-To: patches@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2186059ocf; Thu, 10 Oct 2019 04:40:07 -0700 (PDT) X-Received: by 2002:a19:f11e:: with SMTP id p30mr5367364lfh.152.1570707607212; Thu, 10 Oct 2019 04:40:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570707607; cv=none; d=google.com; s=arc-20160816; b=QDyPj2FxgrO6VxarAIie5lK90PEUzQ9jfcoqwMpUNoIV3RH84PLKFa1NSyCdcVqSi1 6y0esSIwe0FTY1hhFWaM5qkQj0sGyy7ydxCt3PkngZE4Y05RQJRcN6A4qXRm3aPkWWyn vl0VmRM6vLLaX4DyibeoBsuNlUG1XcmGgOepJXvJVvVB9MjHFh+cwtjQwXQyLK/CGSzw BNCxjnbCyEsmudsjO87CO2JfTTDFRkvwNgD/1W+txWNs8zkw9MYDmdugVX0JeHSkdtMv OQp5/yhgnFja/7Ci0TU63OEUfRjpAnQv2uB09qoa3z7CkQXFoPwPmefkWPPuChpbtfHX IPmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=s32JeDhVlasQJ6pytWlkQPUAMG4/wlRqEgRTpBOYoJM=; b=ChtKyZ8rfrnqIChfQOBVrE/YuygqeWtEzZn3z3HEMZWdD3KKS/6rofVyCSnLCdJGws 1TDan6TWEZD5Ua5fKIhEkskEPA8TCNnjtev/frIrKBsSMGY7FtqzlbGo9f8Nhzgu4azU USYzVQBGA4kjMywAiLCMr74aURZayXH/VW/SmPgmJlyWLq3O23qQVF5W7AaUWUky5jgV BMnof1M1GsKWGRcatvSUBJocAbSTh2pFdmJWyxys90ZyXwuLbDeBAdLl3MUwVVcaPb9X lEdaSj467ZMOljY64AQQHQ0+8qs33Z+nDqMcC49uIVlPP/w2/xjal40pbyxH9KImj1HN iDiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oY4GQ9ts; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id y15sor3293601ljh.48.2019.10.10.04.40.06 for (Google Transport Security); Thu, 10 Oct 2019 04:40:06 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oY4GQ9ts; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=s32JeDhVlasQJ6pytWlkQPUAMG4/wlRqEgRTpBOYoJM=; b=oY4GQ9tspotLOINThxk9Kbs/w01ctme9MEPIEv5nplvQc0Gfk2yTpx63vcTwtFKh4B B+T2P47iK3kLvh+AM79Ow8hzpSL3BwO3bqbzE3b2EGXWMtodySrd61pw72AcbbCRFUpW afPqjSPD0x36xrozZ3piihjF4z1ppF7c8+sdn5Eb7tbNOIM4xve2bbcEhfKjKH3SEPiz mq2/6LaFi7GwljgIrb1NuH0pROuM4yrNj2ZjU5Ymvi8IEwKvRk9+do8bNp27z4n8h5v2 epXCe1vP/SQbHMt0CKqt4ltRSdU/ZufhVj++KFLUQjmpFA0FFee9QlnZH1Yo6uEaRSRm /omw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=s32JeDhVlasQJ6pytWlkQPUAMG4/wlRqEgRTpBOYoJM=; b=qv9BTtiVwkzS+LLiBsg6bKufk39KTwLZUsstrv+kstJI6QY+uUGtYQmCYjZ7eVyYNy VaLcOVe12ALu+ihsv7sAqKMfHyKAuat6p1C0nhJ/tvvcd3SvqsuNFPznBkD0XgXl/AS/ mN2S6jXqhwxEXMWpwXUSQmRAd0WJ2kKrEhUhEX9xWQNYy2eW0N7s7CTjxGGQO+KLgbA7 v/LhczHpsbON2O2ArYot52doxaWkiH5+7pvRvxgWuwhK4JNJVb2i6Qe78hlRd4Wmyt// zybGf8rBI/az0dTLgzYiu+/EWe1Jk3lpPlENnJbAYk+1rxCMsStUtKV+Iwxp8HadMPe8 b7Sg== X-Gm-Message-State: APjAAAWDdJIa3nE/OfzXUTOd1ONPh3P44lLExxrLaSVd7pUEZI4t+/oz Bcp5bfIhTGAFr/S5k2xJ3l10+7iIqDJq0Q== X-Google-Smtp-Source: APXvYqyGsGrLPyBDtCxTyveMalXdmwovqTcGDOWg4fzfp/TkTS6GWys0i/Jm2jUOUYV/1uUVYs7SYg== X-Received: by 2002:a05:651c:105c:: with SMTP id x28mr6132302ljm.114.1570707605886; Thu, 10 Oct 2019 04:40:05 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id p3sm1168937ljn.78.2019.10.10.04.40.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2019 04:40:05 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Daniel Lezcano , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Lina Iyer , linux-pm@vger.kernel.org Cc: Rob Herring , Vincent Guittot , Stephen Boyd , Bjorn Andersson , Kevin Hilman , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 01/13] cpuidle: psci: Fix potential access to unmapped memory Date: Thu, 10 Oct 2019 13:39:25 +0200 Message-Id: <20191010113937.15962-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191010113937.15962-1-ulf.hansson@linaro.org> References: <20191010113937.15962-1-ulf.hansson@linaro.org> When the WFI state have been selected, the in-parameter idx to psci_enter_idle_state() is zero. In this case, we must not index the state array as "state[idx - 1]", as it means accessing data outside the array. Fix the bug by pre-checking if idx is zero. Fixes: 9ffeb6d08c3a ("PSCI: cpuidle: Refactor CPU suspend power_state parameter handling") Signed-off-by: Ulf Hansson --- drivers/cpuidle/cpuidle-psci.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index f3c1a2396f98..2e91c8d6c211 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -27,10 +27,10 @@ static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state); static int psci_enter_idle_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, int idx) { - u32 *state = __this_cpu_read(psci_power_state); + u32 *states = __this_cpu_read(psci_power_state); + u32 state = idx ? states[idx - 1] : 0; - return CPU_PM_CPU_IDLE_ENTER_PARAM(psci_cpu_suspend_enter, - idx, state[idx - 1]); + return CPU_PM_CPU_IDLE_ENTER_PARAM(psci_cpu_suspend_enter, idx, state); } static struct cpuidle_driver psci_idle_driver __initdata = {