From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 BA9703F8EBE; Mon, 17 Aug 2026 15:28:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786980502; cv=none; b=q3p7EIYHMxI7b8sZOscTcaBpOSajQx/RVng/bk7aLeyWEdca8CM6xIsWD7AWLt3fvCRIoMcU6h5lvpXgsxmkoy1riv3NmkV/rNw41BiK+8KpLcF1iDyesp7pRlDvitQmFuyZl6R8VOng6VYyS8yXU/6V7Vc4mBIK3T/H5EsL9Xo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786980502; c=relaxed/simple; bh=E6hALF1fv+qzd4sJGG0blqvbMkeItLzIo179450i57c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SbHmWQRqKXjLK3vnlAgcMac9xBNo5CfADF02s1QBy/SMlJd9Inwuvu8fgj+kG/BegbqAY9ml6tzQ/lBAF5DHDjgX4wkkEuyVRMRQSLjd6PpjLBCCKg/brEYSnBp9kGCIk2Ttg8hwHWU3YSKFMQgnfY3sNX/xkJBAdFcqdKws4V0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=GtTgIFKe; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="GtTgIFKe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21C111F000E9; Mon, 17 Aug 2026 15:28:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786980501; bh=vMw24xb56vubzMoXXd/ypu5ccSWkFBWh2MU85+xyHiU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GtTgIFKebZ9V9vZqFE8IJfqm1gK6h8okW9DU+KtLKsK2Jbsinb+fnfpPVokTnizOW LibB5yS0fvKcVqp7Abpkqr2BgNUF8qFV+tUbjxbqfqPJsemBU4TV7Wb72ls3+yRNeq aw87oUADsZPa0S94YbAVQbNToc0/8L+Dao7JeglM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ahmad Byagowi , Vadim Fedorenko , Jakub Kicinski Subject: [PATCH 6.1 595/609] ptp: ocp: Fix board ID over-read Date: Mon, 17 Aug 2026 15:34:51 +0200 Message-ID: <20260817132603.558797515@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260817132543.039278408@linuxfoundation.org> References: <20260817132543.039278408@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ahmad Byagowi commit 6b69f2ef10cdb018c0b127a7cab88e590bbddba4 upstream. The EEPROM board ID is a fixed 13-byte field and is not guaranteed to contain a NUL terminator. Passing it directly to devlink_info_version_fixed_put() treats it as a C string and may read beyond the field. Format at most OCP_BOARD_ID_LEN bytes into the existing local buffer before reporting the ID. Use a precision limit because the snprintf() output size alone does not bound the source string scan. Fixes: 0cfcdd1ebcfe ("ptp: ocp: add nvmem interface for accessing eeprom") Cc: stable@vger.kernel.org Signed-off-by: Ahmad Byagowi Reviewed-by: Vadim Fedorenko Link: https://patch.msgid.link/20260804210751.48248-1-ahmadexp@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/ptp/ptp_ocp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/ptp/ptp_ocp.c +++ b/drivers/ptp/ptp_ocp.c @@ -1483,9 +1483,11 @@ ptp_ocp_devlink_info_get(struct devlink if (err) return err; + snprintf(buf, sizeof(buf), "%.*s", OCP_BOARD_ID_LEN, + (const char *)bp->board_id); err = devlink_info_version_fixed_put(req, DEVLINK_INFO_VERSION_GENERIC_BOARD_ID, - bp->board_id); + buf); if (err) return err;