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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 73026C4345F for ; Thu, 25 Apr 2024 17:16:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pVu6tI75dqZouIcXN7FcQ1cMIKcqcdOoOOuMdXmhc4I=; b=CTLWVZeFaHeDBC qIpEF8c9mNH5lfIaoufl3uzxBtGPkIBfOw3DbWJJIFlavue1PXICE5Hm2g/F7Ss1IJP9vCYIyvIWW +RYNsCRDoPyHeuBzmg6EhciO/I7D1M9goS2KmGecmK+291cKszq0SGNZj6dBTc536UhQ56w5dkBgf QHkRwrxICVG8on3smE6qEZ4EAWKpdwHUZNLlTmtZxSWDmfDYUyhebUOvxaWA0gpOEo0w8x0OTOroA cXxT/49YEdyqVzZll+Ocy0Qq2M6ooyjzwBIt73uhm0DITbHE+xPp/p61X9Hc43dlmDn6vXOtQN3Ax vMiDSEqL3Px8J/nYXCyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s02hZ-00000009Yb0-32YU; Thu, 25 Apr 2024 17:16:05 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s02hV-00000009YX6-1Hfk for linux-arm-kernel@lists.infradead.org; Thu, 25 Apr 2024 17:16:03 +0000 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1e3ca4fe4cfso9656575ad.2 for ; Thu, 25 Apr 2024 10:15:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714065359; x=1714670159; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=BVoFOxCV1JHDP2aoF03ZloAG5l88Zzw+9lsvPKG2m90=; b=HjlQHaYfMcBqs67K9J6Imfuzo+gZZgJwCFPjsZTXNBtQDco80exT7HUCWG2yh4jmfK woNc2hCVqZvdOHK/SexGkoNL0wt56v4THtWceVeZhi6uoBzaEylsVZdiJsVjkQUkPXtn C38gUZStVeLxCu/Ew7B+nC/pYj0X3KlzfC+Kg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714065359; x=1714670159; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=BVoFOxCV1JHDP2aoF03ZloAG5l88Zzw+9lsvPKG2m90=; b=nOCQaqJzH4eE7/9gnD+E44E2H25YFuifuVAA45djFI6GksFlC6iGIE1GLB18tSrtS7 auqSVD+r/hLgP9qeoSdvrOkRxWgsbC9oAtwxScLOpBPwHftWyxifTxnA2b54rYG7aG9+ c+kmtHHdVeNySRsqw+7TP8FRImMy0A2U79fU3tyH6QZiUVnvRZuWapg/vXp/Jm/FDhu1 Psks8DgeL4fEQjcE2npNHV3wfhPEI62gJGv233DJxw16Un2iAMjRHvnoEMwkpsNQwNRv wv11pgzYXqLYkUJqWov6Ng7mKpg+82/fZVeg30n+uxhBe2BmWegsdOTYJefNCr+J1NHj RZyA== X-Forwarded-Encrypted: i=1; AJvYcCUaozMpXfQ10xzbSk3RG5mU6MKLMxgAgHz1XZBlNQeJkmvTelasBDzWlHX2FzFydQyui6TV2wVe8dD9OJmQj9vmOQEvk9kxpi62BrxKYk8pXTUNf9E= X-Gm-Message-State: AOJu0YyBRxHkEf86LlEjavIW+tH58x0nMeM+QI7l9ZawhG0HwIsywMVm PGDg8mU3JLihgU3Z0uDcCA6NZJaUhdjDUmAtgeCRSCmTnLUPkI3NhDz+OffZKQ== X-Google-Smtp-Source: AGHT+IFTVJMb3BdwwAwsZ2j36LZ7tJkEJr9FFByumTo4ENFk4yglK2iF8e7h1wGaAyCSClq9Nhgm1A== X-Received: by 2002:a17:903:25cf:b0:1e9:668d:a446 with SMTP id jc15-20020a17090325cf00b001e9668da446mr172628plb.20.1714065359234; Thu, 25 Apr 2024 10:15:59 -0700 (PDT) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id s17-20020a170902ea1100b001e511acfd0esm13979187plg.140.2024.04.25.10.15.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 10:15:58 -0700 (PDT) Date: Thu, 25 Apr 2024 10:15:57 -0700 From: Kees Cook To: Nathan Chancellor Cc: Michael Turquette , Stephen Boyd , Florian Fainelli , "Gustavo A. R. Silva" , bcm-kernel-feedback-list@broadcom.com, linux-clk@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, patches@lists.linux.dev, llvm@lists.linux.dev, stable@vger.kernel.org Subject: Re: [PATCH 2/2] clk: bcm: rpi: Assign ->num before accessing ->hws Message-ID: <202404251015.46D8BE1F1@keescook> References: <20240425-cbl-bcm-assign-counted-by-val-before-access-v1-0-e2db3b82d5ef@kernel.org> <20240425-cbl-bcm-assign-counted-by-val-before-access-v1-2-e2db3b82d5ef@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240425-cbl-bcm-assign-counted-by-val-before-access-v1-2-e2db3b82d5ef@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240425_101601_445800_B0C4F3DE X-CRM114-Status: GOOD ( 14.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Apr 25, 2024 at 09:55:52AM -0700, Nathan Chancellor wrote: > Commit f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with > __counted_by") annotated the hws member of 'struct clk_hw_onecell_data' > with __counted_by, which informs the bounds sanitizer about the number > of elements in hws, so that it can warn when hws is accessed out of > bounds. As noted in that change, the __counted_by member must be > initialized with the number of elements before the first array access > happens, otherwise there will be a warning from each access prior to the > initialization because the number of elements is zero. This occurs in > raspberrypi_discover_clocks() due to ->num being assigned after ->hws > has been accessed: > > UBSAN: array-index-out-of-bounds in drivers/clk/bcm/clk-raspberrypi.c:374:4 > index 3 is out of range for type 'struct clk_hw *[] __counted_by(num)' (aka 'struct clk_hw *[]') > > Move the ->num initialization to before the first access of ->hws, which > clears up the warning. > > Cc: stable@vger.kernel.org > Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by") > Signed-off-by: Nathan Chancellor Looks good; thanks! Reviewed-by: Kees Cook -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel