From nobody Sun Feb 8 11:25:53 2026 Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.178]) (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 92DED37E31F for ; Wed, 14 Jan 2026 08:45:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768380344; cv=none; b=O+JsvhhD0V8pkpBPmQruChMaF573VwAlcSrJJYhSXZqr/o1upIMXeEzc0a4q0kFNF+El8+4QyNkfoimP7yPFo5qxE7zLEuzvB89DNsJG6ajm11Qdeq/Vpqzk4eDO/qh7suUHxlshwyUr26n8IQiMHtV47HzuQNs6EYBa0pogyb0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768380344; c=relaxed/simple; bh=ehXgC3JCvlf7wN89iHmJKWGfkq49NBB6QvoXZM60iEQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=DsIvTzPoY10WtKlx4YhCiQ4GadI+/rCp8jemXe3tqgrwnsQUxDLeM7GxhdtQ43tI5wyFkNKR14OzFeu2HUbdRl1RzoNEyYFNgrY1ig0rVNRSBclCiuGgQRGL41N7vvVY8wDwLRM7zBKORvmvwQqu1fhsmFmHYo3LUjywLvjqXVo= 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=djwpjF/3; arc=none smtp.client-ip=209.85.128.178 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="djwpjF/3" Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-790948758c1so84260577b3.1 for ; Wed, 14 Jan 2026 00:45:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768380338; x=1768985138; 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; bh=lckbZ7Xlds9xlfZoOEoTCQnZ7dZ179/bxP7jKwPynW4=; b=djwpjF/3J6jtyBGe3W348rskPxTpj7OeoXm2unfPyc5/cA4sP7YONkN3GySkCSbhBa h5EDxVQ61YGHtfIO33iVgv4Kz03KXW+FWZdnalNzrlOZq+LQiJsDrIT23QmFABsVl020 PzeqAyZ6kq7xPix4wXgM/C0QtbJG2MlMoS3yxnZjsBe+LxVywAMrQnlggmVcP3JLE1p1 yhyTSaaD+pa7oFvVktOx6fZ07JUcLGgw2+kc+Hve84uFpJpZ2LtEyMMPPFeCSpwTG3oW xXsFp1s7cNzQcYcaFI1EZ5gP7i6x05NVZc8UBKquA9zZobG6Z3QUzdFAi1n7Q5YZPe/F MyOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768380338; x=1768985138; 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; bh=lckbZ7Xlds9xlfZoOEoTCQnZ7dZ179/bxP7jKwPynW4=; b=wnEdxHPYw6kjZdWSlE/jaHVUmnP7Eg1ERcfQkNcLmM/3gtwgwmcqPjCe7oPimvwGqN 5jZSjWNOGtcq4r70dOjOOq/ZT0C+nmpE+8oIwe2kHAj+sl4vvnWw3jqtNh4eKlrqUuEc 45dRd/ms8pbDFQoin25Y6Tmn94oNQ9rxVe37qEyNsMej7sc3DZpe1cmns9V9ZVavs4P1 aEEAtvbbUw613UDEx/mezN3rPX6eJwyQ9Qf4pHSdJNFTl0rnfA/OKFbeu0ftLgRyqqrs 9z0a87RSzqYU+KcGdklpnW1PUL7DXeUxomjSlrljmUcHy9twXD23xMwUcA7iXdW/j0Yk YDNQ== X-Forwarded-Encrypted: i=1; AJvYcCVwZGiivq8EmonpW1/gpLu2/uhXIcC/+JUpXz9FAU8KsLeQdTrhiVNjVXKEG9GZea7LithpwX/YoX/GKkU=@vger.kernel.org X-Gm-Message-State: AOJu0Yza2HXsL/DSfeLLyNzpTOpIjoh3TIy234GaiDizz1A9S4XJhOEd hu1nlRuJFWwsFzfEHu41N7Td1rJpnYria2qO5khCs+JxkUAE3UJ3e7zmup8zveEJ9UdIJw== X-Gm-Gg: AY/fxX6eJCPNbl71/9NwRE0BFG89rrdqeZyJLaPMGVxANXELbrwrzfGf++FX0hXzZEa Qax354SpEehg3rY2N1Gp3FkrQgEobU9Qrb3LQ6PLwKhHnHGt3+xa+dYXjUBGys9gnRjRPbKhXpG NVxxKFxshchuuOaDVr4D2EP234l0PmAX4YoSpoqzc360C1kCI1lVMOB8YU7y0wzHv3HrgONa9hI 0DNrWXU1/hVNuuNEHwn2sQvCZFavDKYlVsB77IswsPFQGe7KeD7BsB9XeR5G006Lp1CYlnYZgID L/BR6i6eUkeDAAjw3oiPvXUjrDF1kqTQJzKOThxUZ4V212o3J5GLnh5lB1dexh8+LpnePdRDTNp xwxXxPXZ94CTNsndNyjt4bcUHmI4NsO2zxUL/R6oTrZwvyCO02/VAYreVarm5rdNeHLO3Ojmyv7 JAl51j1y5fzMXQ1YVfGBzYu6SLnHHoQlhW2e1Z2VtVFSggdZpt8FAdbo2HRMsZbzoTCegyD9nPc LPBfkkxDUMBi2qzNazKxEA+r8NgJ5KlHe/hUNHU X-Received: by 2002:a05:690c:9688:b0:788:131:d053 with SMTP id 00721157ae682-793a1d5234amr13807187b3.43.1768380338155; Wed, 14 Jan 2026 00:45:38 -0800 (PST) Received: from u2404-VMware-Virtual-Platform.localdomain (108-214-96-168.lightspeed.sntcca.sbcglobal.net. [108.214.96.168]) by smtp.gmail.com with ESMTPSA id 00721157ae682-790aa6713e5sm87544757b3.29.2026.01.14.00.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jan 2026 00:45:37 -0800 (PST) From: Sun Jian To: Andy Lutomirski Cc: Thomas Gleixner , Vincenzo Frascino , linux-kernel@vger.kernel.org, Sun Jian Subject: [PATCH] lib/vdso: guard clockid before building u32 bitmask Date: Wed, 14 Jan 2026 16:45:29 +0800 Message-ID: <20260114084529.1676356-1-sun.jian.kdev@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: quoted-printable Content-Type: text/plain; charset="utf-8" __cvdso_clock_gettime_common() and __cvdso_clock_getres_common() build a u32 bitmask from clockid_t using "1U << clock". This requires the shift amount to be < 32, otherwise leading to undefined behaviour. Add a guard to reject out-of-range clockids before building the bitmask. This avoids undefined shifts and silences sparse "shift too big" warnings. No functional change intended. Signed-off-by: Sun Jian --- lib/vdso/gettimeofday.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c index 95df0153f05a..eee30f2bc6c6 100644 --- a/lib/vdso/gettimeofday.c +++ b/lib/vdso/gettimeofday.c @@ -298,6 +298,9 @@ __cvdso_clock_gettime_common(const struct vdso_time_dat= a *vd, clockid_t clock, * Convert the clockid to a bitmask and use it to check which * clocks are handled in the VDSO directly. */ + if ((u32)clock >=3D 32) + return false; + msk =3D 1U << clock; if (likely(msk & VDSO_HRES)) vc =3D &vc[CS_HRES_COARSE]; @@ -440,6 +443,9 @@ bool __cvdso_clock_getres_common(const struct vdso_time= _data *vd, clockid_t cloc * Convert the clockid to a bitmask and use it to check which * clocks are handled in the VDSO directly. */ + if ((u32)clock >=3D 32) + return false; + msk =3D 1U << clock; if (msk & (VDSO_HRES | VDSO_RAW)) { /* --=20 2.43.0