From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
To: Albert Esteve <aesteve@redhat.com>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>
Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
Sarannya S <quic_sarannya@oss.qualcomm.com>,
Pranav Mahesh Phansalkar <quic_pphansal@oss.qualcomm.com>,
Sudeepgoud Patil <quic_sudeepgo@oss.qualcomm.com>
Subject: Re: [PATCH v3 1/4] soc: qcom: smem: add IN_PARTITION_RANGE helper
Date: Wed, 21 Oct 2026 14:23:47 +0200 [thread overview]
Message-ID: <2c748a4d-b416-4f33-a6c7-195ccda6a5ee@oss.qualcomm.com> (raw)
In-Reply-To: <20260924-port-smem-v3-1-fbc2ea81a654@redhat.com>
On 9/24/26 3:10 PM, Albert Esteve wrote:
> From: Sarannya S <quic_sarannya@oss.qualcomm.com>
>
> Add IN_PARTITION_RANGE() to test that a pointer lies in [start, end]
> and that pointer + size does not wrap.
>
> Signed-off-by: Sarannya S <quic_sarannya@oss.qualcomm.com>
> Signed-off-by: Pranav Mahesh Phansalkar <quic_pphansal@oss.qualcomm.com>
> Signed-off-by: Sudeepgoud Patil <quic_sudeepgo@oss.qualcomm.com>
> Signed-off-by: Albert Esteve <aesteve@redhat.com>
> ---
> drivers/soc/qcom/smem.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
> index b5e7bd8c1512..6783a3c533f0 100644
> --- a/drivers/soc/qcom/smem.c
> +++ b/drivers/soc/qcom/smem.c
> @@ -2,6 +2,7 @@
> /*
> * Copyright (c) 2015, Sony Mobile Communications AB.
> * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
> + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
> */
>
> #include <linux/debugfs.h>
> @@ -88,6 +89,17 @@
> /* Processor/host identifier for the global partition */
> #define SMEM_GLOBAL_HOST 0xfffe
>
> +/* Entry range check
> + * ptr >= start : Checks if ptr is greater than the start of access region
> + * ptr + size >= ptr: Check for integer overflow (On 32bit system where ptr
> + * and size are 32bits, ptr + size can wrap around to be a small integer)
> + * ptr + size <= end: Checks if ptr+size is less than the end of access region
> + */
> +#define IN_PARTITION_RANGE(ptr, size, start, end) \
> + (((void *)(ptr) >= (void *)(start)) && \
> + (((void *)(ptr) + (size)) >= (void *)(ptr)) && \
> + (((void *)(ptr) + (size)) <= (void *)(end)))
LLM is unhappy about the 32-bit base and suggests this instead:
#define IN_PARTITION_RANGE(ptr, size, start, end) \
((void *)(ptr) >= (void *)(start) && \
(void *)(ptr) <= (void *)(end) && \
(size) <= (uintptr_t)(end) - (uintptr_t)(ptr))
Konrad
next prev parent reply other threads:[~2026-10-21 12:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 13:10 [PATCH v3 0/4] Add automotive SMEM hardening for Qualcomm platforms Albert Esteve
2026-09-24 13:10 ` [PATCH v3 1/4] soc: qcom: smem: add IN_PARTITION_RANGE helper Albert Esteve
2026-10-21 12:23 ` Konrad Dybcio [this message]
2026-09-24 13:10 ` [PATCH v3 2/4] soc: qcom: smem: validate private entry list walks Albert Esteve
2026-10-21 12:39 ` Konrad Dybcio
2026-09-24 13:10 ` [PATCH v3 3/4] soc: qcom: smem: validate private item payloads Albert Esteve
2026-09-24 13:10 ` [PATCH v3 4/4] soc: qcom: smem: ignore multi remote host partitions Albert Esteve
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2c748a4d-b416-4f33-a6c7-195ccda6a5ee@oss.qualcomm.com \
--to=konrad.dybcio@oss.qualcomm.com \
--cc=aesteve@redhat.com \
--cc=andersson@kernel.org \
--cc=konradybcio@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=quic_pphansal@oss.qualcomm.com \
--cc=quic_sarannya@oss.qualcomm.com \
--cc=quic_sudeepgo@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®