This is an automated email from the ASF dual-hosted git repository.

GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 17ce421da37f708f1d33d86dfa20b5b57810cace
Author: v-liuchenxu3 <[email protected]>
AuthorDate: Thu Apr 16 22:38:01 2026 +0800

    drivers/rptun: keep a copy of the carveout name
    
    The carveout heap was registered with a name pointing into the resource
    table in shared memory. If the peer resets or rewrites the table, the
    name changes under the heap, and procfs meminfo (e.g. `free`) reads it
    with strnlen(), which can run off the end of the table and fault.
    
    Copy the name into struct rptun_carveout_s and register the copy.
    
    Signed-off-by: v-liuchenxu3 <[email protected]>
---
 drivers/rptun/rptun.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/rptun/rptun.c b/drivers/rptun/rptun.c
index 114b504fa03..3db73daf5d9 100644
--- a/drivers/rptun/rptun.c
+++ b/drivers/rptun/rptun.c
@@ -77,6 +77,7 @@ struct rptun_carveout_s
   FAR struct mm_heap_s       *heap;
   FAR void                   *base;
   size_t                      size;
+  char                        name[RPROC_MAX_NAME_LEN];
 };
 
 struct rptun_priv_s
@@ -510,8 +511,10 @@ static int rptun_init_carveout(FAR struct rptun_priv_s 
*priv,
   carveout = kmm_zalloc(sizeof(*carveout));
   if (carveout != NULL)
     {
+      strlcpy(carveout->name, shmname, sizeof(carveout->name));
+
       memset(&config, 0, sizeof(config));
-      config.name      = shmname;
+      config.name      = carveout->name;
       config.start     = shmbase;
       config.size      = shmlen;
       config.nokasan   = true;

Reply via email to