From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pdx-out-005.esa.us-west-2.outbound.mail-perimeter.amazon.com (pdx-out-005.esa.us-west-2.outbound.mail-perimeter.amazon.com [52.13.214.179]) (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 9B40E33CE86 for ; Tue, 28 Apr 2026 16:58:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=52.13.214.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777395527; cv=none; b=eWx8xFxsBt75gFIKZhfOzckdNbTOA22Gk0/Psh9ntqJzNN9hW/+sLTPAddLyMYPvFj7b2yPjufGueMEyDx4o0uwscVqA0YX6ZaxU/idocy5HF4asNNjlLWuQGGLiDhhLhWKXVgkxAsWHLdQ0DYIdHuxoBQz3JySKnMg/oR20AVk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777395527; c=relaxed/simple; bh=TNE3wFxySN+NnT7u8aGCpT/TMQW6VUAIal+tyAB0im0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QEbWLvWbeZzk41IRhK66doS+5jfZ5mubZSH4GR9yhMPROF2JJemZVCCgsRj40Tkq9hVMjbI0XdoiGdBjXNh3s3phALBl5O+s6FpBbNmINjmU+pGWT6jp7fzSetfpeJmIwQdQbUxA6xX8dx45dC+qGzEFGNfRkL0LNEM5YlajPxY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com; spf=pass smtp.mailfrom=amazon.com; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b=M7Yns1t7; arc=none smtp.client-ip=52.13.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b="M7Yns1t7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazoncorp2; t=1777395526; x=1808931526; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aBezZd7agyWR38Sjrg0pK67g+bbxDS/5NCgYDQZAEAo=; b=M7Yns1t7WqiJW0ugiGQBD4SkM7rQQrz58NZved2VV7BnurIG0HWXowvz 2OLiL9vd3hy6ZsYhnZ+UPd5R8dKi86ZG+MmsK0DkWMeWNydh1YN0WLil7 jnhlDDQChN7JmceXncdC8ZhEiIjoUagJEt7zdpmLtHdWQXHSbCz9ytLY5 t26R2ZQUu9OQ9e0TbRhV/KsUTSVz8MwmvZtOE96GNV/E9B2gjgcQigaxI lLbkJIJoH+h/ffvkCatBmG7LUf2cWNf+y2NORqBCM+iKhIlVX1hus7w+I APs25hehwhQaAkU3/s2UvsGZZVAKuRwP4LJpnA5a4tyOg3nIF4KtrEa5S Q==; X-CSE-ConnectionGUID: zBTsRyBwQEi75ihrRaY3oA== X-CSE-MsgGUID: SHgS0xejTWOPxxDE0RGOfA== X-IronPort-AV: E=Sophos;i="6.23,204,1770595200"; d="scan'208";a="18382072" Received: from ip-10-5-0-115.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.0.115]) by internal-pdx-out-005.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2026 16:58:46 +0000 Received: from EX19MTAUWB001.ant.amazon.com [205.251.233.51:13871] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.20.153:2525] with esmtp (Farcaster) id 87736d2e-eb13-4527-8e5a-20417de70872; Tue, 28 Apr 2026 16:58:45 +0000 (UTC) X-Farcaster-Flow-ID: 87736d2e-eb13-4527-8e5a-20417de70872 Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWB001.ant.amazon.com (10.250.64.248) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Tue, 28 Apr 2026 16:58:43 +0000 Received: from dev-dsk-akiyano-1c-2138b29d.eu-west-1.amazon.com (172.19.83.6) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Tue, 28 Apr 2026 16:58:39 +0000 From: Arthur Kiyanovski To: David Miller , Jakub Kicinski , CC: Arthur Kiyanovski , Richard Cochran , Eric Dumazet , Paolo Abeni , David Woodhouse , Thomas Gleixner , Miroslav Lichvar , Andrew Lunn , Wen Gu , Xuan Zhuo , "Woodhouse, David" , "Sarna, Yonatan" , "Machulsky, Zorik" , "Matushevsky, Alexander" , Saeed Bshara , "Wilson, Matt" , "Liguori, Anthony" , "Bshara, Nafea" , "Schmeilin, Evgeny" , "Belgazal, Netanel" , "Saidi, Ali" , "Herrenschmidt, Benjamin" , "Dagan, Noam" , "Arinzon, David" , "Ostrovsky, Evgeny" , "Tabachnik, Ofir" Subject: [PATCH net-next 5/8] net: ena: PHC: Check return code before setting timestamp output Date: Tue, 28 Apr 2026 16:54:23 +0000 Message-ID: <20260428165659.2811-6-akiyano@amazon.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260428165659.2811-1-akiyano@amazon.com> References: <20260428165659.2811-1-akiyano@amazon.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: EX19D038UWB002.ant.amazon.com (10.13.139.185) To EX19D001UWA001.ant.amazon.com (10.13.138.214) ena_phc_gettimex64() is setting the output parameter regardless of whether ena_com_phc_get_timestamp() succeeded or failed. When ena_com_phc_get_timestamp() returns an error, the timestamp parameter may contain uninitialized stack memory (e.g., when PHC is disabled or in blocked state) or invalid hardware values. Passing these to userspace via the PTP ioctl is both a security issue (information leak) and a correctness bug. Fix by checking the return code after releasing the lock and only setting the output timestamp on success. Fixes: e0ea34158ee8 ("net: ena: Add PHC support in the ENA driver") Signed-off-by: Arthur Kiyanovski --- drivers/net/ethernet/amazon/ena/ena_phc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/amazon/ena/ena_phc.c b/drivers/net/ethernet/amazon/ena/ena_phc.c index 7867e89..c2a3ff1 100644 --- a/drivers/net/ethernet/amazon/ena/ena_phc.c +++ b/drivers/net/ethernet/amazon/ena/ena_phc.c @@ -46,9 +46,12 @@ static int ena_phc_gettimex64(struct ptp_clock_info *clock_info, spin_unlock_irqrestore(&phc_info->lock, flags); + if (rc) + return rc; + *ts = ns_to_timespec64(timestamp_nsec); - return rc; + return 0; } static int ena_phc_settime64(struct ptp_clock_info *clock_info, -- 2.47.3