From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 011A53FDC05 for ; Tue, 21 Jul 2026 01:43:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784598184; cv=none; b=u5bnn4KOWGRnSInt+XMz1tczKPsmKlHak10DjaiJ5mq/G6leTeYobtUr8EB7+26GxfE3tIyCPjnlUPfSsmO2peIp/sHIm0hCg+/es1spcIMA3Xj0z0ILGjpsZT5qfiJgZ9Un5ru68qUNLGRqseuScUcYZcVsnZ7JcfmtwWMaQFA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784598184; c=relaxed/simple; bh=mQkScGSrLsYTkQbmAFUS26qOkwVlPQxOZaGXJa9pixQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Z585T52CPX6F8qywRApOifwYZCZenkGEpBgHDHRSyfedkc8FAnpDbzquFlHSqqalyjvlHmyUzXk2yJPgWdAPj/FQti2Ny5UZKEYkgDaVaRRLViXCjrY6zq0WYGe9Khib4VEmD5GAUR84SfKrjh6ms/3J944/xx1x2IcecFCzCng= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SvaFBOoX; arc=none smtp.client-ip=209.85.219.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SvaFBOoX" Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-8f1a8e914a9so84044606d6.1 for ; Mon, 20 Jul 2026 18:43:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784598181; x=1785202981; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=TIhPn926bcTJS822r3FkEsmh9asbzmZ7+yhUCWhALnw=; b=SvaFBOoXceskOKy7qbZJ5kZNOwjrXax6us7iss/zjTMBzR83f5vhliUIkffya5r5p0 blfiORT+44kMVjMf6JSN4gPyrebCuMjhUmxch1+y4UvupNRCfCfAGqZU7guUqhS73P+v TfdYccxyBwV77x4i9zKAlLnRmwxQnZmzwLA7d0ayL/HgzGaTjsUc4QCOoLT8F1JMRFvc OF5SGuwp2suCBOVTM/3SAma8rqywCrxSJKzZ+5agE6pRSkT4OrzCYC1bmK1n8MDwnP3f ATjzIzjhfKKv+OxtceNqU7mI3anVGgAE/m/9F43a5OL0rN0v8GPtZbzbc09OE1Y4/4/i 7SXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784598181; x=1785202981; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=TIhPn926bcTJS822r3FkEsmh9asbzmZ7+yhUCWhALnw=; b=RJw3rvXQh/i6R0Ly2mOx66jsgItwTw2yg9Otelu5WRZMWVxoxncYaasS4mxWKWCFGG Bg/+enkZj6XT/6fTYPG1wkouJj4jEhbaM3ApwyLBNxdChMNbXhSwt1F4CHge58rirViP +psJrIO7LaLGulONG3xK1mADbaJMVnBMnhmxJm5zIm8gGk7Y2x+h1vXaA+Ng1bLL6Tlg oEooD3XN+z9cGqlYc9TMD5sIXi7Lmo9ffBhQhQ1w4TRONa/V0HMe/fPlSgac5sdWpcQ8 z3M6RqxScA6SCCj0Gm1fpcuPZi6JwQ/raSgFRpZntc9z2NBRP56YkOc/vzzGDRhhA5wp Gsyg== X-Gm-Message-State: AOJu0YxE+HAGqzBMBQNg8HJUnd+H99moX3lpgAYopeXpbXZ5hbmEleYK ciaO3owbI31NlOzAd8nBIPluwqZNYiZuJLmIN42xAeW85jWp6+kip32r X-Gm-Gg: AR+sD13TCEwXfRQ1ZZXuO4hvDO9lI1d6VXqWsSIJ2NiPdvG3Q1ZzyZUl0sbUAMPg3JV AFXz5ug6zeoVB926/WZutIE5/+K2P9txGeVKwSVFibyqO+PPjlg/mKtxBWi7J/kjFPyyQM2sFGi aMNAisJBzM5Jn6ncCANPixy+P+9iPFOJOj8AeswJlUDziwiwhZIA/WtFsuiDxFz8r6/razqvyXl /7TOmuz4WJ1qbvB0Lllrg9daleVLvHnOh5PGyqnCelJjRZX3zM5EzI3kTWMWYNhq29NAqGC1cK1 kZtJiUgQ1QDfnYp5liFTFqpNz/SkmSu1sPePV8Lt4m+nmY/8hsI6s0USequGK4TVbhiDPzdyk1d 6wHWkIzYyLn1tFjEt+ZcWGHWfp2s3euS2yI3zD+yFg5McPbKkMEnc11ka6Nw6NaSy1nx8uYHLBL vszVixP9PisZIqy7opaBaaG/+50JBLXkfVhQ8kMyzJvuNF4DpsEZOwJnke5GCSwRk8Hifu3k1nJ lZQsXR9/mRXpkxlbTqOH8ke9Kg= X-Received: by 2002:ad4:5c43:0:b0:8f1:36c7:497c with SMTP id 6a1803df08f44-907784ddb2dmr181885246d6.33.1784598180883; Mon, 20 Jul 2026 18:43:00 -0700 (PDT) Received: from ip-172-31-15-253.ec2.internal (ec2-13-222-20-6.compute-1.amazonaws.com. [13.222.20.6]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-9077871f650sm104418266d6.45.2026.07.20.18.42.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 18:42:58 -0700 (PDT) From: Deep Shah To: netdev@vger.kernel.org, Richard Cochran , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , Andrew Lunn Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Shuah Khan , Vadim Fedorenko , Simon Horman , Deep Shah Subject: [PATCH v2 net 0/2] ptp: fix scaled_ppm_to_ppb() overflow bypassing the max_adj check Date: Tue, 21 Jul 2026 01:42:54 +0000 Message-ID: <20260721014256.1876-1-deepshah146@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ptp_clock_adjtime() validates an ADJ_FREQUENCY request by converting tx->freq to ppb and comparing it against ops->max_adj. On 64-bit systems that conversion can overflow s64 and wrap the result back into range, so a crafted tx->freq bypasses the check and reaches ->adjfine() unclamped. Patch 1 rejects the overflow in ptp_clock_adjtime(). Patch 2 adds a regression test that crafts struct timex.freq directly (testptp's int-ppb path cannot express the value) and confirms it is rejected with -ERANGE. Changes in v2: - patch 1: unchanged, added Reviewed-by from Vadim Fedorenko. - patch 2 (all from Simon Horman's review): - cast fd to unsigned before the shift in FD_TO_CLOCKID (UBSan) - only set the 64-bit test value on 64-bit builds (32-bit -Woverflow) - save and restore the clock frequency - skip instead of fail on -EBUSY (free-running clock) Link to v1: https://lore.kernel.org/netdev/20260712040922.6403-1-deepshah146@gmail.com/ Deep Shah (2): ptp: reject frequency adjustments that overflow scaled_ppm_to_ppb() selftests: ptp: add a regression test for the frequency adjustment overflow drivers/ptp/ptp_clock.c | 14 ++- tools/testing/selftests/ptp/Makefile | 2 +- .../testing/selftests/ptp/ptp_freq_overflow.c | 99 +++++++++++++++++++ 3 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/ptp/ptp_freq_overflow.c base-commit: 1c975de3343cdef506f2eecc833cc1f14b0401c4 -- 2.43.0