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 17DD7C4345F for ; Thu, 25 Apr 2024 17:15:37 +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=K5BtzM+qipGzqDjPGYGrEuTgeRZMS3JU0ql45qC1YNQ=; b=b06W2tFEiR7+Zl it+vpGlhxPNHg/eP67ai9FGL7dvdK3DYOCaclIod0np8Ydc33/XJSE+ltq3QEnBNFXffZqWD9+i7Y BPK8/tRGToC1xsKyT9Mi6dRIxh4quIGp0JlYXeP69jUEUuUK0NZZE+DfGVKtj16zhHOJVLPLgF3mq dGaXQ57stMUmeUAehCN+AEEC6l/UrJ5IwnLKIT5jGyJ+fx4cpCFjRK9G1eqwW6eo7PIeXxt9YZcCP P9NVObMXX9OHFzz4UxZABcKQmT6KDpL4lawjxVd2ed+GQKMGxUuOlFiP8OQntNcpFLmb3jRrCVfpE gk+GnUfV/cmk0ZKkOEAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s02gy-00000009YL1-1tDd; Thu, 25 Apr 2024 17:15:28 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s02gv-00000009YJ4-0ClR for linux-arm-kernel@lists.infradead.org; Thu, 25 Apr 2024 17:15:26 +0000 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6f103b541aeso1150629b3a.3 for ; Thu, 25 Apr 2024 10:15:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714065323; x=1714670123; 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=u1JLCe9OgKQpwj7dtaGJUIZ9L7mQbrj8lQtYz3ctHGE=; b=dNRgYVzE4K1VMOYBxbUMDlod6oafRXzE/NdMPNcVChfBfP6/ehJV7cmtxxLmW6XDJh LXYC85leuAqP6wQPTheVHh5O5TxMuLnX8f+Rct6cXxVb9xEm7XwpQExKX7zaVcNlmC0B vANZADIMtNh/oryDeE6YoMiuAcEeryCLPxqkw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714065323; x=1714670123; 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=u1JLCe9OgKQpwj7dtaGJUIZ9L7mQbrj8lQtYz3ctHGE=; b=N2yXgLp6wZ7vx8uMttblVnNZjxJ1uJb7g6I3gR6PyJbjCEnGorhoLjiEUnSwBfFGFq I1HPCjFLkZmJ3EimeGte1/4kGswrDTzs5dUgUWuztb3jEo44q/Y5kguDzjfW+GgovKiF b7unWcx2GIgo2l6neeghhGOMx7j+fsrJeibyexxbuRZuFrYMpRLksCnJA1xdg9Ywr0La f3Vw4IEDW7Pwzla+1Q36KMgGHEtt7DqEI91CT1rqbHC/BoMbY8ZkpJXOgCf+8x6UEFol ehOv/Nz9A+sDX6j2G0mN+MXnrTsoV5ITvwOLkYW0mrVndN0UrOBi3dQwYuH+BQuP+Qzn iN6w== X-Forwarded-Encrypted: i=1; AJvYcCXYKPK5D/idear43IJmaiGeCUy6aWkR953wQjyjZ5A0xS8oHotSLZgiC5kwLV1wKwQi6UONHjH0CfXvPp+FkftQOLmbWJPTZd7KbYVeQyCMPXwztaU= X-Gm-Message-State: AOJu0YyOFTNbkv5iuPOEqQizG0rpj64djpGRe30n/n8qcDRnJ9Dkx4jT /JSq+ezLs9uPBaLalWdB1x0HBSAw11qbaQ++g9pjBagY/S34W1QdE2euTZBIFw== X-Google-Smtp-Source: AGHT+IHdAL2pUCcpe/Rwp2MmAw3VaSPub4F1WVpc3ytbvH+LpXMd2WcDJZqLoubA0TgHiGRSKS322g== X-Received: by 2002:a05:6a20:5b12:b0:1a7:aecd:9902 with SMTP id kl18-20020a056a205b1200b001a7aecd9902mr294646pzb.49.1714065323492; Thu, 25 Apr 2024 10:15:23 -0700 (PDT) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id a7-20020a654187000000b0060013d7c463sm6433305pgq.72.2024.04.25.10.15.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 10:15:22 -0700 (PDT) Date: Thu, 25 Apr 2024 10:15:22 -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 1/2] clk: bcm: dvp: Assign ->num before accessing ->hws Message-ID: <202404251015.23D4949BCF@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-1-e2db3b82d5ef@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240425-cbl-bcm-assign-counted-by-val-before-access-v1-1-e2db3b82d5ef@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240425_101525_314821_E0E0818B X-CRM114-Status: GOOD ( 14.77 ) 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:51AM -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 > clk_dvp_probe() due to ->num being assigned after ->hws has been > accessed: > > UBSAN: array-index-out-of-bounds in drivers/clk/bcm/clk-bcm2711-dvp.c:59:2 > index 0 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 Thanks for finding this! 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