From patchwork Fri Dec 22 14:54:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 182681 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp1114249dyi; Fri, 22 Dec 2023 06:56:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IFpvDBLp3A1GJR/33Z5nl/gJfPVO4m1iEm5EzQvsolsO/6RqBBWvR0DK0UU8v61LQlu5zdX X-Received: by 2002:a05:6a20:6113:b0:195:2d4f:bbfb with SMTP id m19-20020a056a20611300b001952d4fbbfbmr1163270pzb.19.1703256987073; Fri, 22 Dec 2023 06:56:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703256987; cv=none; d=google.com; s=arc-20160816; b=byxcJ9G4wF19gXQbSX/4LBAVo8e9N8GkLXHIHwxckamSlWGnOUG1OP0b/pefvO6RQT tvKZR31qpgtQJCdDlzzTmfyAoKEBy54zHRGe0nVSv6EaFWDPdqqn4K47qY2z3xwJuMiM GNlU/dmLbclBCRfulePdXq/EpJGj5D8ZQzY2B3HOKHpnhot1X4jcBaSZKyBCLgHhqOwx bt3DOk5DBiCP9otBPeMmzQ4HQz29kmNVMt9/fGvb9mYmumlBMNpJbacey3ulZNVzht8I ISVbiT7aG+1LvazefL1lHN3bn8Eys1uQJD2WfA0bc9bApcqk5C6GHRL8fAM7RKrQnIap 9VAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:message-id:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:date :from:dkim-signature; bh=0IAVBMvy+o0p64/Zqm3ssdMErhXYDLhA9mJOds14fAs=; fh=LKUX993GSTtawIcs7LMiYSJ/7nN/M/rqymLBiK7PRW8=; b=I4/aHBDK4dTZHgAY32tbsbzUeRRuY9PwR9/VuB7OlFIwBQco5SeWIdN9ODjJ68LqCT KsFrNwisnimadFC/rBPnGkpZ90w36sxh16+1SdVSYU8VH+8FY6ARgqkalf6GKZg6JL+s n8wVGUQwkVd+SMHwxqttkbjoxd1mEPfswWxMv7xvED0Qtl0QKXuoMwuX82K8IyNpD3ta 0KM0tG2AVL/kGIjE/+zj39QFAf4b7Rhj1OBAlw1JMo+BYDTOI4CQDNfgEJmx5oqWkSAH aR70GVCntl/dhBVQVNe5nYI422b74EmZVVn5CWVyTbULIc6pynLV78VmgTHXIot3+FEI bLhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BmE7+o7x; spf=pass (google.com: domain of linux-kernel+bounces-9795-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9795-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id x31-20020a056a00189f00b006ce9cb273c6si3450598pfh.136.2023.12.22.06.56.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 06:56:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9795-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BmE7+o7x; spf=pass (google.com: domain of linux-kernel+bounces-9795-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9795-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A2087B242DD for ; Fri, 22 Dec 2023 14:54:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F1EC123762; Fri, 22 Dec 2023 14:54:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BmE7+o7x" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 55F4423740; Fri, 22 Dec 2023 14:54:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDC2BC433C7; Fri, 22 Dec 2023 14:54:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703256882; bh=Tf6r9+dOJakriookGkExO9gdNVREb4CJwWTm93Lq6B8=; h=From:Date:Subject:To:Cc:From; b=BmE7+o7xibvyL1cPsn3sUQEc2K7uvqtKiHB8ZEUmzHqC1V0M3gJGUhBUv9/gUtDAa OhikQutGcBJikPIH1PWNSh3W0fe8nusKNfELhZPkRhR0SdCH9ctEuUp+BoaJaZ90/b cUcea556r653aV87getayQiU2dP26arQlVz3xukFLSdbyCnm6gY1oHKlSl7kr3zJv5 EtPpqvTJAYYukwNFSortNLXTXOwbStMINfpR+GFzMpLPtei7rVqiimH0W9RxgHL61h yTSp/aOiBCEi1nBaU67U5VSg5cVEE3KjOzzwcvPq9xXWuOQaV2v0bV5U6QqOcZOGCt yWl9+6/K/FTeA== From: Mark Brown Date: Fri, 22 Dec 2023 14:54:37 +0000 Subject: [PATCH v2] lsm: Add a __counted_by() annotation to lsm_ctx.ctx Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231222-lsm-fix-counted-by-v2-1-f1237a095bdc@kernel.org> X-B4-Tracking: v=1; b=H4sIACyjhWUC/32NTQ7CIBCFr9LM2jEyRrGuvIfpAmFoiRUaqMSm4 e5iD2De6nt5Pyskjo4TXJsVImeXXPAVaNeAHpTvGZ2pDHSgoyASOKYXWvdBHd5+ZoOPBW1rzYU k01kpqMUpck1so/eu8uDSHOKyfWTxc//OZYFVpDXJUyu1sbcnR8/jPsQeulLKF+dZ4DO1AAAA To: Paul Moore , James Morris , "Serge E. Hallyn" , Kees Cook , "Gustavo A. R. Silva" Cc: linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Aishwarya TCV , Mark Brown X-Mailer: b4 0.13-dev-5c066 X-Developer-Signature: v=1; a=openpgp-sha256; l=1237; i=broonie@kernel.org; h=from:subject:message-id; bh=Tf6r9+dOJakriookGkExO9gdNVREb4CJwWTm93Lq6B8=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBlhaMv/ELUVrM0GuXyutYsNbqAiTiWGM2DJYFEcwQ8 cfgmv++JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZYWjLwAKCRAk1otyXVSH0LQZB/ sEPxe44AsrwfISPQhOJQqpoDU08dBpuIpRT3OXE0oJFqhXeSccZBba0BM3U10GzFS2UK9FLlGjoIbh FKz6IXXIKUgZu+z8XyyDQk9Z73+Feex94HtfaQL4qpgAIwELqP6ff0jScbiK6E6swF9JDo28aqjLjh v2S/sBBc+OEu8iLFA9V5eT+Qi6I1XfJhYxH8+/ZrdJ6d3CDSjSJ4FvNc9E0L0UQB7neJf8TcjqvnOr Cmv/ebG5qqNhnkW46R5Mafbeb+pWTWJg4uRrXH9DlRag5nIAtGanyCy+cocIk9DMx0/MhhFOWJr/3h c/VbPTFugX9+OqPEOcoHnwf8rRbqn/ X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785994398347346665 X-GMAIL-MSGID: 1785994398347346665 The ctx in struct lsm_ctx is an array of size ctx_len, tell the compiler about this using __counted_by() where supported to improve the ability to detect overflow issues. Reported-by: Aishwarya TCV Signed-off-by: Mark Brown --- Changes in v2: - Add explicit stddef.h inclusion in case __counted_by() definition isn't otherwise pulled in. - Link to v1: https://lore.kernel.org/r/20231221-lsm-fix-counted-by-v1-1-12cc27597cdf@kernel.org --- include/uapi/linux/lsm.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- base-commit: ec4e9d630a64df500641892f4e259e8149594a99 change-id: 20231221-lsm-fix-counted-by-f9fd827e26aa Best regards, diff --git a/include/uapi/linux/lsm.h b/include/uapi/linux/lsm.h index f0386880a78e..f8aef9ade549 100644 --- a/include/uapi/linux/lsm.h +++ b/include/uapi/linux/lsm.h @@ -9,6 +9,7 @@ #ifndef _UAPI_LINUX_LSM_H #define _UAPI_LINUX_LSM_H +#include #include #include @@ -36,7 +37,7 @@ struct lsm_ctx { __u64 flags; __u64 len; __u64 ctx_len; - __u8 ctx[]; + __u8 ctx[] __counted_by(ctx_len); }; /*