Ticket #19 (closed defect: fixed)

Opened 4 years ago

Last modified 3 years ago

Doesn't work on 64 bit machines with 32 bit userspace

Reported by: Sjoerd Simons <sjoerd@…> Owned by: lennart
Milestone: Avahi 0.6.10 Component: avahi-core
Keywords: Cc: sebastien.estienne@…

Description

Hi,

sendmsg on 64 bit machines with 32 bit userspace always throws -EINVAL with current avahi.

This is because the code does the following:

size_t cmsg_data[( CMSG_SPACE(sizeof(struct in_pktinfo)) / sizeof(size_t)) + 1]; to allocate the cmsg data and then passed the size of that as msg.msg_controllen.

Which makes it always somewhat too large, CMSG_SPACE returns a value with padding for allignment if needed, which normally is a multiple of sizeof(size_t). So it's always sizeof(size_t) too large..

Now normally this isn't too big a problem. Unfortunately the 32to64 bit translation code in the linux kernel assumes that if after a cmsg there is still some data left it's another valid cmsg.. Which isn't in this case so it throws EINVAL.

Two possible solution, either pass the CMS_SPACE as msg.msg_controllen or don't allocate too much space on the heap. I'll attach a patch that uses the second solution.

Attachments

03_cmsg_too_large.patch (0.9 kB) - added by Sjoerd Simons <sjoerd@…> 4 years ago.
Proposed patch. Tested on 64 bit sparc (ultra 5) and 64 bit powerpc (G5)
03_cmsg_too_large.2.patch (1.1 kB) - added by Sjoerd Simons <sjoerd@…> 4 years ago.
Proposed patch. Uses the first of the two mentioned fixes. Keeps alignment stuff for ia64 right :).. Testen on sparc64

Change History

Changed 4 years ago by Sjoerd Simons <sjoerd@…>

Proposed patch. Tested on 64 bit sparc (ultra 5) and 64 bit powerpc (G5)

Changed 4 years ago by sebest

  • cc sebastien.estienne@… added

it seems that this patch would revert a patch that was added for "ia64 alignment", have a look at r1130 .

Changed 4 years ago by sebest

  • priority changed from critical to major
  • milestone set to Avahi 0.6.10

Changed 4 years ago by Sjoerd Simons <sjoerd@…>

Proposed patch. Uses the first of the two mentioned fixes. Keeps alignment stuff for ia64 right :).. Testen on sparc64

Changed 4 years ago by sebest

this ticket is related to ticket #9

Changed 4 years ago by sebest

Patch 03_cmsg_too_large.2.patch commited on r1178. Could someone confirm that ia64 is still working correctly?

Changed 4 years ago by sebest

  • status changed from new to closed
  • resolution set to fixed

noone objected so, let's close this bug.

You can reopen it if it's not working for you

Changed 4 years ago by lennart

  • status changed from closed to reopened
  • resolution fixed deleted

Apparently 03_cmsg_too_large.patch needs to be applied too, hence i am reopening this bug. (see #32)

Changed 4 years ago by lennart

  • status changed from reopened to closed
  • resolution set to fixed

(In [1207]) fix sendmsg() calls on FreeBSD and AMD64 kernels with 32bit userspace. (Closes #35 and #19)

Note: See TracTickets for help on using tickets.