History

vdso/gettimeofday: Verify COMPAT_32BIT_TIME interactions

If CONFIG_COMPAT_32BIT_TIME is disabled then the vDSO should not provide any 32-bit time related functionality. Add some build-time validations to make sure the architecture-specific glue satisfies this requirement.

Thomas Weißschuh committed 4 months ago

Commit 369cecd1 parent 27002971 file · +10 −0Browse files

Showing the changes to lib (1 of 1 file). Show all

Unified · Split

lib/vdso/gettimeofday.c+10−0
@@ -25,6 +25,8 @@ · 24 unmodified lines
2525 */
2626 #include <asm/vdso/gettimeofday.h>
2727
28+#include <linux/build_bug.h>
29+
2830 /* Bring in default accessors */
2931 #include <vdso/vsyscall.h>
3032
@@ -325,6 +327,8 @@ __cvdso_clock_gettime32_data(const struct vdso_time_data *vd, clockid_t clock, · 294 unmodified lines
325327 struct __kernel_timespec ts;
326328 bool ok;
327329
330+ BUILD_BUG_ON(!IS_ENABLED(CONFIG_COMPAT_32BIT_TIME));
331+
328332 ok = __cvdso_clock_gettime_common(vd, clock, &ts);
329333
330334 if (unlikely(!ok))
@@ -354,6 +358,8 @@ __cvdso_gettimeofday_data(const struct vdso_time_data *vd, · 23 unmodified lines
354358 BUILD_BUG();
355359 #endif
356360
361+ BUILD_BUG_ON(sizeof(tv->tv_sec) != 8 && !IS_ENABLED(CONFIG_COMPAT_32BIT_TIME));
362+
357363 if (likely(tv != NULL)) {
358364 struct __kernel_timespec ts;
359365
@@ -392,6 +398,8 @@ __cvdso_time_data(const struct vdso_time_data *vd, __kernel_old_time_t *time) · 32 unmodified lines
392398 BUILD_BUG();
393399 #endif
394400
401+ BUILD_BUG_ON(sizeof(*time) != 8 && !IS_ENABLED(CONFIG_COMPAT_32BIT_TIME));
402+
395403 if (vdso_is_timens_clock(vc)) {
396404 vd = vdso_timens_data(vd);
397405 vc = vd->clock_data;
@@ -481,6 +489,8 @@ __cvdso_clock_getres_time32_data(const struct vdso_time_data *vd, clockid_t cloc · 83 unmodified lines
481489 struct __kernel_timespec ts;
482490 bool ok;
483491
492+ BUILD_BUG_ON(!IS_ENABLED(CONFIG_COMPAT_32BIT_TIME));
493+
484494 ok = __cvdso_clock_getres_common(vd, clock, &ts);
485495
486496 if (unlikely(!ok))

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t