Re: Invalid argument reading file caps for file

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

 



>> If you can, please create a small reproducer that opens an executable,
>> unlink the executable and execute it with execveat().
>> I estimate this should fail with file capabilities enabled over any file
>> system, not just overlayfs.

I'm able to reproduce very similar failure with the small reproducer,
dmesg is like:
Invalid argument reading file caps for /dev/fd/3

But the result is different in test executable in overlay and ext4,
later one can pass the test.

Also I tested yocto codebase in ext4 can not reproduce the error.
The error accessed executable in yocto is compiled in build process
and run by shell exec.
It seems the shell script could rm the file in certain conditions.

Below is the reproducer usage and source code, for your reference.
$ cd /mnt/merged
$ cp /bin/echo .
$ ~/test_execveat/a.out
execveat exec: Invalid argument

$ cd /tmp
$ cp /bin/echo .
$ ~/test_execveat/a.out
hello

----
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <linux/fcntl.h>
#include <sys/syscall.h>
#include <errno.h>

static void die_if_negative(int ret, const char* msg) {
if(ret<0) {
   fprintf(stderr, "%s: %s\n", msg, strerror(errno));
   exit(1);
}
}

const char* exec="echo";
char *newargv[] = { "echo", "hello", NULL};
char *newenviron[] = { NULL };

void main() {
int exefd, ret;

exefd = open(exec, O_PATH);
die_if_negative(exefd, "open exec");

ret = unlink(exec);
die_if_negative(ret, "unlink exec");

ret = syscall(322/*SYS_execveat*/, exefd, "", newargv, newenviron,
AT_EMPTY_PATH);
die_if_negative(ret, "execveat exec");
}

thanks,
Eddie
--
To unsubscribe from this list: send the line "unsubscribe linux-unionfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux