Skip to contentSkip to conversation

ALSA: core: fix 64-bit SNDRV_PCM_IOCTL_STATUS ABI breakage

PATCH In review Clemens Ladisch 2 participants 4 messages Oct 27, 2012 – Oct 29, 2012 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: core: fix 64-bit SNDRV_PCM_IOCTL_STATUS ABI breakage

Commit 4eeaaeaea (ALSA: core: add hooks for audio timestamps) added the new audio_tstamp field to struct snd_pcm_status. However, struct timespec requires 64-bit alignment, so the 64-bit compiler would insert 32 bits of padding before this field, which broke SNDRV_PCM_IOCTL_STATUS with error messages like this:

kernel: unknown ioctl = 0x80984120

To solve this, insert the padding explicitly so that it can be taken into account when calculating the ABI structure size.

---
 include/uapi/sound/asound.h |    3 ++-
 sound/core/pcm_compat.c     |    3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
include/uapi/sound/asound.h +2 -1
@@ -408,8 +408,9 @@ struct snd_pcm_status {
 	snd_pcm_uframes_t avail_max;	/* max frames available on hw since last status */
 	snd_pcm_uframes_t overrange;	/* count of ADC (capture) overrange detections from last status */
 	snd_pcm_state_t suspended_state; /* suspended stream state */
+	__u32 reserved_alignment;	/* must be filled with zero */
 	struct timespec audio_tstamp;	/* from sample counter or wall clock */
-	unsigned char reserved[60-sizeof(struct timespec)]; /* must be filled with zero */
+	unsigned char reserved[56-sizeof(struct timespec)]; /* must be filled with zero */
 };
 
 struct snd_pcm_mmap_status {
sound/core/pcm_compat.c +2 -1
@@ -190,8 +190,9 @@ struct snd_pcm_status32 {
 	u32 avail_max;
 	u32 overrange;
 	s32 suspended_state;
+	u32 reserved_alignment;
 	struct compat_timespec audio_tstamp;
-	unsigned char reserved[60-sizeof(struct compat_timespec)];
+	unsigned char reserved[56-sizeof(struct compat_timespec)];
 } __attribute__((packed));
#1 lore raw

At Sat, 27 Oct 2012 21:55:27 +0200,

Quoted 7 lines · Clemens Ladisch

Commit 4eeaaeaea (ALSA: core: add hooks for audio timestamps) added the new audio_tstamp field to struct snd_pcm_status. However, struct timespec requires 64-bit alignment, so the 64-bit compiler would insert 32 bits of padding before this field, which broke SNDRV_PCM_IOCTL_STATUS with error messages like this:

Quoted 6 lines

kernel: unknown ioctl = 0x80984120

To solve this, insert the padding explicitly so that it can be taken into account when calculating the ABI structure size.

Oops, that's bad. Thanks for catching this.
I applied it now to for-next branch.

Could you fix alsa-lib code as well?

Takashi

Quoted 31 lines
---
 include/uapi/sound/asound.h |    3 ++-
 sound/core/pcm_compat.c     |    3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
include/uapi/sound/asound.h +2 -1
@@ -408,8 +408,9 @@ struct snd_pcm_status {
 	snd_pcm_uframes_t avail_max;	/* max frames available on hw since last status */
 	snd_pcm_uframes_t overrange;	/* count of ADC (capture) overrange detections from last status */
 	snd_pcm_state_t suspended_state; /* suspended stream state */
+	__u32 reserved_alignment;	/* must be filled with zero */
 	struct timespec audio_tstamp;	/* from sample counter or wall clock */
-	unsigned char reserved[60-sizeof(struct timespec)]; /* must be filled with zero */
+	unsigned char reserved[56-sizeof(struct timespec)]; /* must be filled with zero */
 };
 
 struct snd_pcm_mmap_status {
sound/core/pcm_compat.c +2 -1
@@ -190,8 +190,9 @@ struct snd_pcm_status32 {
 	u32 avail_max;
 	u32 overrange;
 	s32 suspended_state;
+	u32 reserved_alignment;
 	struct compat_timespec audio_tstamp;
-	unsigned char reserved[60-sizeof(struct compat_timespec)];
+	unsigned char reserved[56-sizeof(struct compat_timespec)];
 } __attribute__((packed));
 
 
#2 lore raw
Quoted 12 lines · Takashi Iwai
Quoted 11 lines · Clemens Ladisch

Commit 4eeaaeaea (ALSA: core: add hooks for audio timestamps) added the new audio_tstamp field to struct snd_pcm_status. However, struct timespec requires 64-bit alignment, so the 64-bit compiler would insert 32 bits of padding before this field, which broke SNDRV_PCM_IOCTL_STATUS with error messages like this:

kernel: unknown ioctl = 0x80984120

To solve this, insert the padding explicitly so that it can be taken into account when calculating the ABI structure size.

Quoted 6 lines
Quoted 1 line

Oops, that's bad. Thanks for catching this.
I applied it now to for-next branch.

Could you fix alsa-lib code as well?

Oops; done.

Regards,
Clemens

#3 lore raw

At Sun, 28 Oct 2012 11:45:35 +0100,

Quoted 14 lines · Clemens Ladisch
Quoted 12 lines · Takashi Iwai
Quoted 11 lines · Clemens Ladisch

Commit 4eeaaeaea (ALSA: core: add hooks for audio timestamps) added the new audio_tstamp field to struct snd_pcm_status. However, struct timespec requires 64-bit alignment, so the 64-bit compiler would insert 32 bits of padding before this field, which broke SNDRV_PCM_IOCTL_STATUS with error messages like this:

kernel: unknown ioctl = 0x80984120

To solve this, insert the padding explicitly so that it can be taken into account when calculating the ABI structure size.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Oops, that's bad. Thanks for catching this.
I applied it now to for-next branch.

Could you fix alsa-lib code as well?

Oops; done.

Thanks!

Takashi