diff options
| -rw-r--r-- | meta/recipes-devtools/e2fsprogs/e2fsprogs/xattr_ordering.patch | 66 | ||||
| -rw-r--r-- | meta/recipes-devtools/e2fsprogs/e2fsprogs_git.bb | 1 | 
2 files changed, 67 insertions, 0 deletions
| diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/xattr_ordering.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/xattr_ordering.patch new file mode 100644 index 0000000000..a89b946450 --- /dev/null +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/xattr_ordering.patch | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | [Message sent to linux-ext4 on 2016/2/7] | ||
| 2 | |||
| 3 | I'm using the -d option of mke2fs to construct a filesystem, I'm seeing | ||
| 4 | that some xattrs are being corrupted. The filesystem builds with no | ||
| 5 | errors but when mounted by the kernel, I see errors like "security.ima: | ||
| 6 | No such attribute". The strace from such a failure is: | ||
| 7 | |||
| 8 | mmap(NULL, 26258, PROT_READ, MAP_SHARED, 3, 0) = 0x7fdb36a8c000 | ||
| 9 | close(3) = 0 | ||
| 10 | getrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=64*1024}) = 0 | ||
| 11 | lstat("mnt/foobar", {st_mode=S_IFREG|0755, st_size=1, ...}) = 0 | ||
| 12 | listxattr("mnt/foobar", NULL, 0) = 30 | ||
| 13 | listxattr("mnt/foobar", "security.SMACK64\0security.ima\0", 256) = 30 | ||
| 14 | getxattr("mnt/foobar", "security.SMACK64", 0x0, 0) = 1 | ||
| 15 | getxattr("mnt/foobar", "security.SMACK64", "_", 256) = 1 | ||
| 16 | fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 13), ...}) = 0 | ||
| 17 | mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fdb36a8b000 | ||
| 18 | write(1, "# file: mnt/foobar\n", 19# file: mnt/foobar) = 19 | ||
| 19 | write(1, "security.SMACK64=\"_\"\n", 21security.SMACK64="_") = 21 | ||
| 20 | getxattr("mnt/foobar", "security.ima", 0x0, 0) = -1 ENODATA (No data available) | ||
| 21 | write(2, "mnt/foobar: ", 12mnt/foobar: ) = 12 | ||
| 22 | write(2, "security.ima: No such attribute\n", 32security.ima: No such attribute) = 32= 32 | ||
| 23 | |||
| 24 | so the attribute is there but the kernel gives ENODATA when trying | ||
| 25 | to read it. | ||
| 26 | |||
| 27 | http://www.nongnu.org/ext2-doc/ext2.html#CONTRIB-EXTENDED-ATTRIBUTES co | ||
| 28 | ntains the small snippet that " The entry descriptors are sorted by | ||
| 29 | attribute name, so that two extended attribute blocks can be compared | ||
| 30 | efficiently. ". It doesn't specify what kind of sort. | ||
| 31 | |||
| 32 | Looking at ext2fs, there is some sorting code through the qsort call | ||
| 33 | using attr_compare() but it doesn't match what the kernel is doing in | ||
| 34 | ext4_xattr_find_entry(). | ||
| 35 | |||
| 36 | This patch fixes the problem. | ||
| 37 | |||
| 38 | Upstream-Status: Submitted | ||
| 39 | RP | ||
| 40 | 2016/2/7 | ||
| 41 | |||
| 42 | Index: git/lib/ext2fs/ext_attr.c | ||
| 43 | =================================================================== | ||
| 44 | --- git.orig/lib/ext2fs/ext_attr.c | ||
| 45 | +++ git/lib/ext2fs/ext_attr.c | ||
| 46 | @@ -258,6 +258,7 @@ static struct ea_name_index ea_names[] = | ||
| 47 | static int attr_compare(const void *a, const void *b) | ||
| 48 | { | ||
| 49 | const struct ext2_xattr *xa = a, *xb = b; | ||
| 50 | + size_t len; | ||
| 51 | |||
| 52 | if (xa->name == NULL) | ||
| 53 | return +1; | ||
| 54 | @@ -267,7 +268,11 @@ static int attr_compare(const void *a, c | ||
| 55 | return -1; | ||
| 56 | else if (!strcmp(xb->name, "system.data")) | ||
| 57 | return +1; | ||
| 58 | - return 0; | ||
| 59 | + len = strlen(xa->name) - strlen(xb->name); | ||
| 60 | + if (len) | ||
| 61 | + return len; | ||
| 62 | + | ||
| 63 | + return strcmp(xa->name, xb->name); | ||
| 64 | } | ||
| 65 | |||
| 66 | static const char *find_ea_prefix(int index) | ||
| diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs_git.bb b/meta/recipes-devtools/e2fsprogs/e2fsprogs_git.bb index 9ade1ff684..d4a19f9dde 100644 --- a/meta/recipes-devtools/e2fsprogs/e2fsprogs_git.bb +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs_git.bb | |||
| @@ -6,6 +6,7 @@ SRC_URI += "file://acinclude.m4 \ | |||
| 6 | file://run-ptest \ | 6 | file://run-ptest \ | 
| 7 | file://ptest.patch \ | 7 | file://ptest.patch \ | 
| 8 | file://mkdir.patch \ | 8 | file://mkdir.patch \ | 
| 9 | file://xattr_ordering.patch \ | ||
| 9 | " | 10 | " | 
| 10 | 11 | ||
| 11 | SRCREV = "0f26747167cc9d82df849b0aad387bf824f04544" | 12 | SRCREV = "0f26747167cc9d82df849b0aad387bf824f04544" | 
