From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CCA44464E9 for ; Wed, 2 Apr 2025 11:35:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C3193402A9; Wed, 2 Apr 2025 11:35:33 +0200 (CEST) Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) by mails.dpdk.org (Postfix) with ESMTP id D3DB240261 for ; Wed, 2 Apr 2025 11:35:31 +0200 (CEST) Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-54acc0cd458so822910e87.0 for ; Wed, 02 Apr 2025 02:35:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=interfacemasters.com; s=google; t=1743586531; x=1744191331; darn=dpdk.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=tNlf2qgNUQSDezqY2JYgZ43QeCY62uoDIUXliVo6yok=; b=XriOWtsF0jDHlqGcrV5SAE9CX0GKQNmBRupQnsX81gSlsU6VbuD4EE6i+/LM7xDbWQ jtk6tmdwFUYA1BGl2fkuTYETIfm4ovJOQ5zOH4EwN4dwN7JOo3M6pJlhhSGFpfSqmGnK vZNgG8D8U8lrCe+8mT9fIIlZ1csrlu7h0/Ep8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743586531; x=1744191331; 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=tNlf2qgNUQSDezqY2JYgZ43QeCY62uoDIUXliVo6yok=; b=pjON+1IoJepdnTyUjnu6YpCgX1JI96c575MkA+Vdp8UxFHLq5Sl29o6ebl7FyTV7+r BhHxNm6M4kTJOV+rrksbcvxnPEBcVE5XgqtWVNUnzXzDFc4Rif8DwPDn0r4nBONlINvB sH7Soh5mUaUm9wA8MD8fqqASeR7KyZsBJGI2ebKWD9XN8GorEaDHu+smJ26sbHVeGHRF Zmo7oCplSbno9raMbFZAa0hOO9OiB3DtkEhFptNXtMUE6si9Pjvv/ilbYinI3N3KaR1d 3Ruyl+Q2yRtQUaFKxYaZQgNQyPgo1dtvZECgoFdEWM43WVNe2vTVhBfgqA3/my6DNUjn vGFQ== X-Forwarded-Encrypted: i=1; AJvYcCVqtiyJTYn9dl9F3OAj8XfqkRk6huTBsHMyVuflQlLJW3B35MUwsrja8BT83bVi6PQMNsj+Dd8=@dpdk.org X-Gm-Message-State: AOJu0YwtKGQm13Y0KOoCtekexSMyQfFoKdnKHzDHKQ6rg1BzlRn+7a0n PsKWxI0G4YVt8D63oy+19FQtSbCLKvFiJzX1eH5Rsei0ol+CM2mYJCaJRWngEd4= X-Gm-Gg: ASbGnctNwkluwK8ou5+v99A+sY3Ays8byCuAHqvdHxfy0TxW1WhpuutvIk40XX/1g7j ryZJyErMVbDAQvxTdnojZPv5hY9JhM8krr90iPOptbjwI9e47Mc8Tmfi6HWRjAKEOsAOvt+xtWb Y1NNbckBefH7U7deXcITPly4uAXN+9huVzQpJm5PD65WIwMRRmnYWM3Ui4PzyM8JukKYs9TNgZ2 o3i+qZ0IJL5Yb34JxMsRZgQvhA6MnZ8p60tThjNdoy6qij8hcf1cJhvaB27cHcbmndcnE4PS3aT ebeVcvlP/Dc554WrJAwiWA5LCzHWyRUw2wZNXs5hDyBOQhxHxYCRIYo3NQ== X-Google-Smtp-Source: AGHT+IEkVAOVS8a8pvMiArWMm4OR7Bk8FEWODsCSmKTKtw6qB30DWpX5e56P2cHiD69ZBV8vTPIyhQ== X-Received: by 2002:a05:6512:3f1e:b0:549:912a:d051 with SMTP id 2adb3069b0e04-54c19c1adfamr535495e87.0.1743586531098; Wed, 02 Apr 2025 02:35:31 -0700 (PDT) Received: from fedora.. ([185.143.144.104]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54b0959324bsm1578465e87.163.2025.04.02.02.35.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Apr 2025 02:35:30 -0700 (PDT) From: Oleksandr Nahnybida To: Jerin Jacob , Sunil Kumar Kori , Tyler Retzlaff , David Marchand Cc: dev@dpdk.org, stable@dpdk.org, Oleksandr Nahnybida Subject: [PATCH] trace: fix out of bounds write in __rte_trace_mem_get Date: Wed, 2 Apr 2025 12:33:09 +0300 Message-ID: <20250402093309.10394-1-oleksandrn@interfacemasters.com> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Offset should be aligned first before checking if there is free space for another write. Bugzilla ID: 1665 Fixes: ebaee6409702 ("trace: simplify trace point headers") Signed-off-by: Oleksandr Nahnybida --- lib/eal/include/rte_trace_point.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/eal/include/rte_trace_point.h b/lib/eal/include/rte_trace_point.h index 8a317d31d2..343e0271b3 100644 --- a/lib/eal/include/rte_trace_point.h +++ b/lib/eal/include/rte_trace_point.h @@ -328,7 +328,7 @@ __rte_trace_mem_get(uint64_t in) return NULL; } /* Check the wrap around case */ - uint32_t offset = trace->offset; + uint32_t offset = RTE_ALIGN_CEIL(trace->offset, __RTE_TRACE_EVENT_HEADER_SZ); if (unlikely((offset + sz) >= trace->len)) { /* Disable the trace event if it in DISCARD mode */ if (unlikely(in & __RTE_TRACE_FIELD_ENABLE_DISCARD)) @@ -336,8 +336,6 @@ __rte_trace_mem_get(uint64_t in) offset = 0; } - /* Align to event header size */ - offset = RTE_ALIGN_CEIL(offset, __RTE_TRACE_EVENT_HEADER_SZ); void *mem = RTE_PTR_ADD(&trace->mem[0], offset); offset += sz; trace->offset = offset; -- 2.49.0