2017-11-02 11:10:09

by Baolin Wang

[permalink] [raw]
Subject: [RFC PATCH v2 0/7] Fix year 2038 issue for sound subsystem

Since many structures will use timespec type variables to record time stamp
in uapi/asound.h, which are not year 2038 safe on 32bit system. This patchset
tries to introduce new structures removing timespec type to compatible native
mode and compat mode.

Moreover this patchset also converts the internal structrures to use timespec64
type and related APIs.

Changes since v1:
- Flat all structues to make them more clear.
- Re-modify the convertion for struct snd_timer_tread.
- Use same coding style when converting struct snd_rawmidi_status.
- Use struct snd_timer_user_status64 in compat mode directly when converting
struct snd_timer_status.
- Add #ifdef __KERNEL__ when converting struct snd_ctl_elem_value.
- Re-modify the convertion for struct snd_pcm_sync_ptr.
- Fix some building errors.

Appreciated for any comments, especially for patch6 which I am not sure if it
is correct.

Baolin Wang (7):
sound: Replace timespec with timespec64
sound: core: Avoid using timespec for struct snd_pcm_status
sound: core: Avoid using timespec for struct snd_rawmidi_status
sound: core: Avoid using timespec for struct snd_timer_status
uapi: sound: Avoid using timespec for struct snd_ctl_elem_value
sound: core: Avoid using timespec for struct snd_pcm_sync_ptr
sound: core: Avoid using timespec for struct snd_timer_tread

include/sound/pcm.h | 126 +++++++++-
include/sound/timer.h | 4 +-
include/uapi/sound/asound.h | 19 +-
sound/core/pcm.c | 20 +-
sound/core/pcm_compat.c | 469 ++++++++++++++++++++++++++++---------
sound/core/pcm_lib.c | 33 ++-
sound/core/pcm_native.c | 220 +++++++++++++----
sound/core/rawmidi.c | 81 ++++++-
sound/core/rawmidi_compat.c | 121 +++++++---
sound/core/timer.c | 253 ++++++++++++++++----
sound/core/timer_compat.c | 67 ++----
sound/pci/hda/hda_controller.c | 10 +-
sound/soc/intel/skylake/skl-pcm.c | 4 +-
13 files changed, 1090 insertions(+), 337 deletions(-)

--
1.7.9.5


From 1582912246615520633@xxx Thu Nov 02 00:32:34 +0000 2017
X-GM-THRID: 1582893258796902866
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread


2017-11-02 11:10:41

by Baolin Wang

[permalink] [raw]
Subject: [RFC PATCH v2 5/7] uapi: sound: Avoid using timespec for struct snd_ctl_elem_value

The struct snd_ctl_elem_value will use 'timespec' type variables to record
timestamp, which is not year 2038 safe on 32bits system.

Since there are no drivers will implemented the tstamp member of the
struct snd_ctl_elem_value, and also the stucture size will not be changed
if we change timespec to s64 for tstamp member of struct snd_ctl_elem_value.

Thus we can simply change timespec to s64 for tstamp member to avoid
using the type which is not year 2038 safe on 32bits system.

Signed-off-by: Baolin Wang <[email protected]>
---
include/uapi/sound/asound.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
index 1949923..fabb283 100644
--- a/include/uapi/sound/asound.h
+++ b/include/uapi/sound/asound.h
@@ -943,8 +943,12 @@ struct snd_ctl_elem_value {
} bytes;
struct snd_aes_iec958 iec958;
} value; /* RO */
- struct timespec tstamp;
- unsigned char reserved[128-sizeof(struct timespec)];
+#ifndef __KERNEL__
+ struct { s64 tv_sec; s64 tv_nsec; } tstamp;
+ unsigned char reserved[128-sizeof(struct { s64 tv_sec; s64 tv_nsec; })];
+#else
+ unsigned char reserved[128];
+#endif
};

struct snd_ctl_tlv {
--
1.7.9.5


From 1588474799012484851@xxx Tue Jan 02 10:06:58 +0000 2018
X-GM-THRID: 1586577963246198076
X-Gmail-Labels: Inbox,Category Forums,Downloaded_2018-01