[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH for-4.19] tools/libxs: Fix fcntl() invocation in set_cloexec()



On 08.07.24 17:15, Andrew Cooper wrote:
set_cloexec() had a bit too much copy&pate from setnonblock(), and
insufficient testing on ancient versions of Linux...

As written (emulating ancient linux by undef'ing O_CLOEXEC), strace shows:

   open("/dev/xen/xenbus", O_RDWR)         = 3
   fcntl(3, F_GETFL)                       = 0x8002 (flags O_RDWR|O_LARGEFILE)
   fcntl(3, 0x8003 /* F_??? */, 0x7ffe4a771d90) = -1 EINVAL (Invalid argument)
   close(3)                                = 0

which is obviously nonsense.

Switch F_GETFL -> F_GETFD, and fix the second invocation to use F_SETFD.  With
this, strace is rather happer:

   open("/dev/xen/xenbus", O_RDWR)         = 3
   fcntl(3, F_GETFD)                       = 0
   fcntl(3, F_SETFD, FD_CLOEXEC)           = 0

Fixes: bf7c1464706a ("tools/libxs: Fix CLOEXEC handling in get_dev()")
Reported-by: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

Reviewed-by: Juergen Gross <jgross@xxxxxxxx>


Juergen




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.