From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B126FC35242 for ; Fri, 14 Feb 2020 21:54:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 81F4E24654 for ; Fri, 14 Feb 2020 21:54:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581717281; bh=lpm37VSiCvyvzrUMxYL85tfQ1o8pXGNkVe47bNaYcF0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=q++PtpOwhZYjgl6NMbzZurNV7R8qUwNYILufe6uKbihbo2JjCwpdETxkbl2n1pMjs L1Z3wZW+tgqIrnKv2GvPMHaUqlTXBKC0Ibb9awCajJCr5o9NblqPojGa849VVmg29E 65a5pU5wo2XIHoD+EWgzeHPK9ZLt0QwbZyz7M1z8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388076AbgBNVyk (ORCPT ); Fri, 14 Feb 2020 16:54:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:59698 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387933AbgBNVyh (ORCPT ); Fri, 14 Feb 2020 16:54:37 -0500 Received: from localhost (unknown [65.119.211.164]) (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 CF6562187F; Fri, 14 Feb 2020 21:54:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581717277; bh=lpm37VSiCvyvzrUMxYL85tfQ1o8pXGNkVe47bNaYcF0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ULfvwwWOt3qiaqFnSb2CeRBlcOASfI4qn7jTbfgo9Ba9Vs7B6ctpaUt2e07Uv1s1l E5GGL3/zKXag1vzuXQ9zTTwEzpl8aDWccyiWCJzNlPBAO9nWCChsa0nPL3kpbOedVb UdUpLz+SeFhAx6BigOC+kSTY9sAF7XoGIjh4PYfc= Date: Fri, 14 Feb 2020 16:49:35 -0500 From: Greg Kroah-Hartman To: Sasha Levin Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Simon Schwartz Subject: Re: [PATCH AUTOSEL 5.5 346/542] driver core: platform: Prevent resouce overflow from causing infinite loops Message-ID: <20200214214935.GG4193448@kroah.com> References: <20200214154854.6746-1-sashal@kernel.org> <20200214154854.6746-346-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200214154854.6746-346-sashal@kernel.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Fri, Feb 14, 2020 at 10:45:38AM -0500, Sasha Levin wrote: > From: Simon Schwartz > > [ Upstream commit 39cc539f90d035a293240c9443af50be55ee81b8 ] > > num_resources in the platform_device struct is declared as a u32. The > for loops that iterate over num_resources use an int as the counter, > which can cause infinite loops on architectures with smaller ints. > Change the loop counters to u32. > > Signed-off-by: Simon Schwartz > Link: https://lore.kernel.org/r/2201ce63a2a171ffd2ed14e867875316efcf71db.camel@theschwartz.xyz > Signed-off-by: Greg Kroah-Hartman > Signed-off-by: Sasha Levin > --- > drivers/base/platform.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/drivers/base/platform.c b/drivers/base/platform.c > index cf6b6b722e5c9..864b53b3d5980 100644 > --- a/drivers/base/platform.c > +++ b/drivers/base/platform.c > @@ -27,6 +27,7 @@ > #include > #include > #include > +#include > > #include "base.h" > #include "power/power.h" > @@ -48,7 +49,7 @@ EXPORT_SYMBOL_GPL(platform_bus); > struct resource *platform_get_resource(struct platform_device *dev, > unsigned int type, unsigned int num) > { > - int i; > + u32 i; > > for (i = 0; i < dev->num_resources; i++) { > struct resource *r = &dev->resource[i]; > @@ -255,7 +256,7 @@ struct resource *platform_get_resource_byname(struct platform_device *dev, > unsigned int type, > const char *name) > { > - int i; > + u32 i; > > for (i = 0; i < dev->num_resources; i++) { > struct resource *r = &dev->resource[i]; > @@ -501,7 +502,8 @@ EXPORT_SYMBOL_GPL(platform_device_add_properties); > */ > int platform_device_add(struct platform_device *pdev) > { > - int i, ret; > + u32 i; > + int ret; > > if (!pdev) > return -EINVAL; > @@ -590,7 +592,7 @@ EXPORT_SYMBOL_GPL(platform_device_add); > */ > void platform_device_del(struct platform_device *pdev) > { > - int i; > + u32 i; > > if (!IS_ERR_OR_NULL(pdev)) { > device_del(&pdev->dev); > -- > 2.20.1 > This doesn't solve a real issue, so please drop from everywhere. thanks, greg k-h