From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pdx-out-002.esa.us-west-2.outbound.mail-perimeter.amazon.com (pdx-out-002.esa.us-west-2.outbound.mail-perimeter.amazon.com [44.246.1.125]) (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 119B740DFD3; Thu, 7 May 2026 00:35:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=44.246.1.125 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778114139; cv=none; b=XYupWp19h9yxLagGQOUvv58MkY4J0hMd0VmPDoYzKlSXeEjY5YABrmDYty4Q8AAybwZN5oIaNo5/Cvy8tBAr2aF07+5nXp/N/pSLB1QoBj3zV85N9Niy1LvwEDufV3drwfZcz6mBTIeoxmtY6ba7YSmaWSBHtDLS6x2Lllxg1jc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778114139; c=relaxed/simple; bh=sLt55pcK0rHXDHdos4Kb5swzryqs4t8yZbPad7qkXGw=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=P3vXDAVH0ty+b0z8CleAsYNwas7OmQ7hlwOgwn2KvL6j9qtVIKjfWiajO6thyP4+C9B1BE9BdnMZSxUcC0uztRILMMidLB4D61p/qaKwYKj5hz70QtuaPwtY8nyg3OnG0viTvrgnTP9PnJXH1TV3AOlFLme5Hz3V3u1nosnLvqU= 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=hn9bfeZ4; arc=none smtp.client-ip=44.246.1.125 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="hn9bfeZ4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazoncorp2; t=1778114138; x=1809650138; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=yAfa9z/M5BpV7v6kn7A1vrdmJ9zU9WEKwjIOsqBs1Bo=; b=hn9bfeZ41MHyKBcX4FxDZ4qEw0ax6A71CVtHa30yTmf9zSaeO4l2xHNr 2TeHe5058FCVilQAQaM2x8/MhZc60Fet+EWv2lfHL4cc6P16RN8e0IzJy fA4Vmq7XG3OPAEckl39v7+rE8iMbqXOrjW5BFl8Ds2+hkxbbQ2aLJ5b7K hei2R9RmEWX2Zz0gCo9TqB3g+9A+nsk+C3BsR+cE3JjrUA9lV3voJ9S0f A69S941dmLpoedfLnIEqStunpozKLHfG5zrtEz+/r+fqmJj53/4dJCYL+ AI7lRfPdchCJhQqEr47bVaIIXw7ce1iBD6UVv9NkHN8PcvELukQ2iWp+n A==; X-CSE-ConnectionGUID: ilWi1k35RrSYfoC5C2nIwQ== X-CSE-MsgGUID: nCzSc9L3ScatlWC/yjPeew== X-IronPort-AV: E=Sophos;i="6.23,220,1770595200"; d="scan'208";a="19046485" Received: from ip-10-5-12-219.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.12.219]) by internal-pdx-out-002.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2026 00:35:35 +0000 Received: from EX19MTAUWB001.ant.amazon.com [205.251.233.51:2622] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.8.77:2525] with esmtp (Farcaster) id f26e7759-5087-4e81-b9f4-5154edc77345; Thu, 7 May 2026 00:35:35 +0000 (UTC) X-Farcaster-Flow-ID: f26e7759-5087-4e81-b9f4-5154edc77345 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; Thu, 7 May 2026 00:35:34 +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; Thu, 7 May 2026 00:35:30 +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 , David Woodhouse , "Yonatan Sarna" , Zorik Machulsky , "Alexander Matushevsky" , Saeed Bshara , Matt Wilson , Anthony Liguori , Nafea Bshara , Evgeny Schmeilin , Netanel Belgazal , Ali Saidi , Benjamin Herrenschmidt , Noam Dagan , David Arinzon , Evgeny Ostrovsky , Ofir Tabachnik , Amit Bernstein , Subject: [PATCH net] net: ena: PHC: Check return code before setting timestamp output Date: Thu, 7 May 2026 00:35:15 +0000 Message-ID: <20260507003518.22554-1-akiyano@amazon.com> X-Mailer: git-send-email 2.47.3 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: EX19D031UWA002.ant.amazon.com (10.13.139.96) 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") Cc: stable@vger.kernel.org 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 7867e893fd15..c2a3ff1ef645 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