From patchwork Fri Sep 22 17:53:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 13396274 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B2564447F for ; Fri, 22 Sep 2023 17:54:07 +0000 (UTC) Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC1FF26BF for ; Fri, 22 Sep 2023 10:53:43 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1bf55a81eeaso21130395ad.0 for ; Fri, 22 Sep 2023 10:53:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695405223; x=1696010023; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=F/L92X22dJhyhtQ8lDKApFNV7vkLUEgyD7DW61AIGrg=; b=R9xyZN9cQTzCHh1zGdoKQao8yI/eVpTF6uJsDtWMYY9GWDxthUzvTpDgsXfpkWgh/V /YdrSM1hp+eLqX2UPVgWaL9dStDGnatO9ahE+XSJD1OT50KM+lT5TJGelJE5MTBTX30t wdulrdqgzfVkdLnMjJs0YdPshpQ7OKZseb+YY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695405223; x=1696010023; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=F/L92X22dJhyhtQ8lDKApFNV7vkLUEgyD7DW61AIGrg=; b=M0c8HF6a4xsMAG/YbUjftGGdQoTKLGH2zZUa1TWm4PW3MnD4RxcbXTXkmbshIcn7fs SVd5H55f8dDbIvXKXe9v0s3lHkdPmptkSzeb1uZGwwtBY5/MLn1R5ARYN7iV4EbWkGFS 9S39WU14GR2lVZTtHmkZQOf+wlkQr9+IgrFtW6hHXsdeaenGMoX7eNTvDgEqGZVeGhL+ xkR6yOAq3yqnbFcZAcaoPCcQOlvMVcNvB/uhO32xc17rOrEtNL3VlxD5u7rv8Gi+NGM2 /gxKFc70KUefABnVx8k/z4LfddalywoOgpzd56FZPrPF6kjPIXi/y6CtbqKTk54wkBKh M5pA== X-Gm-Message-State: AOJu0Yy+i6gsrbPcLYjuJd1ckna4GCAt3Nlj2W0XyQNuIVDGIdTIg9it YvJrBWfPjvGA1sbHUqIkNTpbjA== X-Google-Smtp-Source: AGHT+IHGWszC9sNGNLlYcYJz1tQiG2EBYKJI1eKGKzyA7OlbgEJ46OgR6p2V4Nmm7b7vzpvejaUosA== X-Received: by 2002:a17:903:110d:b0:1bb:d280:5e0b with SMTP id n13-20020a170903110d00b001bbd2805e0bmr246508plh.18.1695405223181; Fri, 22 Sep 2023 10:53:43 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id ji18-20020a170903325200b001bdbe6c86a9sm3779903plb.225.2023.09.22.10.53.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:53:42 -0700 (PDT) From: Kees Cook To: Andy Gross Cc: Kees Cook , Bjorn Andersson , Konrad Dybcio , Amit Kucheria , Thara Gopinath , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: [PATCH] drivers: thermal: tsens: Annotate struct tsens_priv with __counted_by Date: Fri, 22 Sep 2023 10:53:41 -0700 Message-Id: <20230922175341.work.919-kees@kernel.org> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1437; i=keescook@chromium.org; h=from:subject:message-id; bh=yU2HdTIvaMKiOikp0zqOQXXfFgKhOPJCGAbuECY4jOI=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDdSlvezRdvtVZduY7QM2bmTOaemd9ierWA9Ag 6m2g04zvqaJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3UpQAKCRCJcvTf3G3A Jj+VD/9XA5O7ImEBS5lp7pFupDLhl0qpeveeJl1/ws9XB4+qfWGwP+u+B/yGl1V1if8pWYaZHlS gsqmwyDwotCQkne3cBhWOEhu34q/vFTAAFYkmFsBxgqdEmAvCgw6E93LPtr32936+3M036VPvAF 69Kn+xQ++3aBnlnaUnGWexWUQtZ1BS1/3Qk1BZX9wiZcM2AppV+v03THCd2OnaV7GiuE8rZLidJ IKwzISZpU7HmiLVADRtiQRxDQYY7udzm1EYCbIKeB16siRiRX/wJ8B0rmqgucSPZNQOor4PZM4l vgNXz3L3qYnqgZa8ZT96/zA8GcZu7v8wB3rYxEfOqmYw43FXc0J0geWreIJRzsL9HEFlKGt1dSQ rOFKd0sHwKcpv9uSOSDoYV7pbxj7ZQ24AKv7OeLykWg9uOpGPezAYIKNyHMbgHpRqmgHihP1Tmj 4otwf/3z+CJgIl0XIVW0W1B6YF4lUaRB5hyf71QQggSR4OB0ReLaLvDMAtIslb+edPFvWeTzTHs YSmoWaWdM3Mh1xXVaa4/UzuDRz1J8T3rY1YXU0VoYQZAsZIknGkKW3jUm/ZVnO4Gk0P7rHrxkSA udeto6Sq0lS20NGkgL1YMg62eSI2ZRseFlf3zhvVz6ax5crha3+IWjhindVoZ+Xh3fMVbQllLbX FqtV4/g FbpWcylQ== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family functions). As found with Coccinelle[1], add __counted_by for struct tsens_priv. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Andy Gross Cc: Bjorn Andersson Cc: Konrad Dybcio Cc: Amit Kucheria Cc: Thara Gopinath Cc: "Rafael J. Wysocki" Cc: Daniel Lezcano Cc: Zhang Rui Cc: linux-arm-msm@vger.kernel.org Cc: linux-pm@vger.kernel.org Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva --- drivers/thermal/qcom/tsens.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h index 2805de1c6827..cb637fa289ca 100644 --- a/drivers/thermal/qcom/tsens.h +++ b/drivers/thermal/qcom/tsens.h @@ -585,7 +585,7 @@ struct tsens_priv { struct dentry *debug_root; struct dentry *debug; - struct tsens_sensor sensor[]; + struct tsens_sensor sensor[] __counted_by(num_sensors); }; /**