From nobody Sun Oct 5 10:51:19 2025 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (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 5540128BABE for ; Tue, 5 Aug 2025 16:20:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754410836; cv=none; b=AFFhZWbmybRzT1t6os+hKGZyteyPdkBkBrSEDT2yTME7rmVPW4cREYwe8x8/KCjy/3uvo9Ze+7eb8ccilP8BJ8w+FSGxnMJfBiJkN2o0SZflWLZDxNZjqPUm/ny7DMvrP5EOtFc/ri8Pr/8KVpu4T/MmzQVQu63Jrs1k3z5KXEg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754410836; c=relaxed/simple; bh=b2dhbaF/pk/NFPcdxLdEyKbE+xfcHsMrSQj7Hev2whc=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=Oej5SN8f0Cjc6YKGycTLsnqASpZGaz2wXlwglV5cCSy7B4K/jGdC6FBpbX2CYDFzgAgoPzrxXTx7MhXajKwyu9lje38PJFRZFyKL2oTPR1uN9iP9bYorAOFtWrR3/SYoAWs24edWDx4WfPM+WKilifH6nsMXpyF55yJIwqVBckg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--wakel.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=vbmBQBNK; arc=none smtp.client-ip=209.85.210.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--wakel.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="vbmBQBNK" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-76bb73b63d2so5530566b3a.1 for ; Tue, 05 Aug 2025 09:20:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1754410834; x=1755015634; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=36rRNVwGvNB+pofkD3n2pIQi/fX7BoFaKjjYFA4l3XQ=; b=vbmBQBNKQa47zDk1bZ6loVKtKP8EhqhyXlG02bwspsKVtl4DWd2TaTV0v5p+kfyNr6 X8zSrVAX+xBUSqHY7LekHAHR9fIp0cgQPwFEQt3vv+Z1VGkyuuPiZZzpBCpzePfrmxFO oJvwRNnoZ/wBp1qUupHdfQbo47HySLr1nahZ7icHUEs9UQB1PLc9na+v9arKHoIhffP9 dvYmrUwvCOI5zskFJWDy8880OC1na41PIoO+8daf4pu2odnC8Cch2cwoZ9Dl21DCeQz+ 6ohpSxZPd43vECCnPmuUGEEOxEzgyySUGhi3JVOO7+UoMHxihgLmIKZRFqNf092ccDqn FqdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754410834; x=1755015634; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=36rRNVwGvNB+pofkD3n2pIQi/fX7BoFaKjjYFA4l3XQ=; b=dKxDw+ekpdFHj93kC9JeqzRQduM7pR+Qm7fFSk8DoYvl4mh9XdegH7xBqWH/5uQnGe FPZuBnG3vPFDMY5U/vudHXLsVyaB8rwOu923nh4WRpDEaTs/QwOtAh1O41Syvrks2azA 8Y8Am8gJtu3a/c93stzBrZgtpuftBXoCig7EZLSS6bybmObponga+8EnJ6Lld+1CuRVV EZElYKdoK//jj36AlbGSSRqTDmIYIPU61QJ/mfck8WAgxkgzQFPCBCKHCqhEfOPA9esJ J3MylO4a/iWUK7oH8yMAPT9xLXoTsQoIBcPaCwPd/xnhmNg/uMRIWeQrSj9TitprClB9 RTgg== X-Gm-Message-State: AOJu0Yxu+K7iIyziZPp41S6J7uRT1/oAaYcJmOLcVPBHpH9MSQNQy13R FmEY2Vumr1LTAdSp2IWydo12jEM9d9UGbzbDgRvW1WoqVb97TYEgbCq9Zl+4tedVrheoutDX++u TXg== X-Google-Smtp-Source: AGHT+IHL96s4Hqrn3CB2fAXGuE+D+Q4GO/8xpdFTrf1lxIfh0W20hvtTrVgOvBT9VRIfEQG+3ts14Kkq9w== X-Received: from pgcv23.prod.google.com ([2002:a05:6a02:5317:b0:b42:26ab:304e]) (user=wakel job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:958f:b0:23d:c4c6:f406 with SMTP id adf61e73a8af0-23df9188b3cmr20456836637.43.1754410834355; Tue, 05 Aug 2025 09:20:34 -0700 (PDT) Date: Wed, 6 Aug 2025 00:20:30 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.50.1.565.gc32cd1483b-goog Message-ID: <20250805162031.952223-1-wakel@google.com> Subject: [PATCH] vdso: Define NSEC_PER_SEC as 64-bit to prevent overflow From: Wake Liu To: Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino Cc: linux-kernel@vger.kernel.org, wakel@google.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The constant NSEC_PER_SEC (1,000,000,000) is defined as a long literal. On 32-bit systems like arm32, where long is 32 bits, this value can overflow when used in 64-bit calculations. This can lead to incorrect time calculations within the VDSO. To fix this, define NSEC_PER_SEC as a long long literal (1000000000LL), ensuring it is treated as a 64-bit value on all architectures and preventing potential overflows. Signed-off-by: Wake Liu --- include/vdso/time64.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/vdso/time64.h b/include/vdso/time64.h index b40cfa2aa33c..07641b27d139 100644 --- a/include/vdso/time64.h +++ b/include/vdso/time64.h @@ -8,7 +8,7 @@ #define NSEC_PER_USEC 1000L #define NSEC_PER_MSEC 1000000L #define USEC_PER_SEC 1000000L -#define NSEC_PER_SEC 1000000000L +#define NSEC_PER_SEC 1000000000LL #define PSEC_PER_SEC 1000000000000LL #define FSEC_PER_SEC 1000000000000000LL =20 --=20 2.50.1.565.gc32cd1483b-goog