Differing ioctl results between Ubuntu Desktop and Ubuntu Server hosts

Hi. I’m trying to establish why I’m seeing different results when the same application is run within a container on an Ubuntu Desktop host vs. an Ubuntu Server host. Both hosts are running Ubuntu 20.04.3 LTS (amd64) and Docker v20.10.7. I have used a number of container variants and all exhibit the same issue.

My application uses the following C code to try and retrieve filesystem properties of the passed in file descriptor. This is usually just set to “/”.

int rc = ioctl(fd, FS_IOC_GETFLAGS, &num);

I run the following to launch my container, passing in a host volume where my ‘ioctl’ application resides.

docker run -it -v /home/neil:/neil ubuntu:20.04 /bin/bash

I use the same launch command on both Ubuntu Desktop & Server.

When, as user root, my ioctl application is run, on Ubuntu Desktop the application runs as expected and the ioctl function returns 0 indicating that all is well.

Unfortunately, on Ubuntu Server, the ioctl function returns -1 and errno is set to 25 (Inappropriate ioctl for device). It doesn’t seem to matter what filesystem value is used for the passed in file descriptor, I always get the same error reported.

As a test I have also tried adding extra capabilities to the container’s root user using ‘–cap-add ALL’ but this didn’t make any difference. Also - this wasn’t required on Ubuntu Desktop.

Here are my environment details…

Ubuntu Desktop Environment:

  • Ubuntu Desktop 20.04.3 LTS
  • Kernel: Linux 5.13.0-30-generic
  • Docker Client: v20.10.7
  • Docker Server: v20.10.7

Ubuntu Server Environment:

  • Ubuntu Server 20.04.3 LTS
  • Kernel: Linux 5.4.0-100-generic
  • Docker Client: v20.10.7
  • Docker Server: v20.10.7

I’m trying to establish what factor of the Ubuntu Server host is causing my application to behave differently and return an error. If anyone has any ideas or things to try out it would be greatly appreciated.

Please let me know if you require any more information/logs. Thanks.

OK I have resolved this issue. Ubuntu Server 20.04.3 has linux kernel 5.4.0. It appears that the GETFLAGS ioctl operation wasn’t available on directories until linux kernel 5.10.0. I have manually installed this kernel version and now my application behaves in the same was as it does in Ubuntu Desktop.

https://git.kernel.org/linus/61536bed2149b082748f8a38c593d915ff3e5957