Linux-Modules Archive on lore.kernel.org
 help / Atom feed
* [PATCH] libkmod-elf: resolve CRC if module is built with MODULE_REL_CRCS
@ 2017-07-19 14:56 Yauheni Kaliuta
  2017-07-19 17:51 ` Lucas De Marchi
  0 siblings, 1 reply; 6+ messages in thread
From: Yauheni Kaliuta @ 2017-07-19 14:56 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: linux-modules, Ard Biesheuvel, linux-kernel

Normally exported symbol's crc is stored as absolute (SHN_ABS)
value of special named symbol __crc_<symbol name>.

When the kernel and modules are built with the config option
CONFIG_MODULE_REL_CRCS, all the CRCs are put in a special section
and the __crc_<symbol name> symbols values are offsets in the
section. See patch description of the commit:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=56067812d5b0e737ac2063e94a50f76b810d6ca3

Add kmod support of this configuration.

Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
---
 libkmod/libkmod-elf.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/libkmod/libkmod-elf.c b/libkmod/libkmod-elf.c
index 90da89aebbaf..ef4a8a3142a1 100644
--- a/libkmod/libkmod-elf.c
+++ b/libkmod/libkmod-elf.c
@@ -747,6 +747,31 @@ static inline uint8_t kmod_symbol_bind_from_elf(uint8_t elf_value)
 	}
 }
 
+static uint64_t kmod_elf_resolve_crc(const struct kmod_elf *elf, uint64_t crc, uint16_t shndx)
+{
+	int err;
+	uint64_t off, size;
+	uint32_t nameoff;
+
+	if (shndx == SHN_ABS || shndx == SHN_UNDEF)
+		return crc;
+
+	err = elf_get_section_info(elf, shndx, &off, &size, &nameoff);
+	if (err < 0) {
+		ELFDBG("Cound not find section index %"PRIu16" for crc", shndx);
+		return (uint64_t)-1;
+	}
+
+	if (crc > (size - sizeof(uint32_t))) {
+		ELFDBG("CRC offset %"PRIu64" is too big, section %"PRIu16" size is %"PRIu64"\n",
+		       crc, shndx, size);
+		return (uint64_t)-1;
+	}
+
+	crc = elf_get_uint(elf, off + crc, sizeof(uint32_t));
+	return crc;
+}
+
 /* array will be allocated with strings in a single malloc, just free *array */
 int kmod_elf_get_symbols(const struct kmod_elf *elf, struct kmod_modversion **array)
 {
@@ -830,6 +855,7 @@ int kmod_elf_get_symbols(const struct kmod_elf *elf, struct kmod_modversion **ar
 		uint32_t name_off;
 		uint64_t crc;
 		uint8_t info, bind;
+		uint16_t shndx;
 
 #define READV(field)							\
 		elf_get_uint(elf, sym_off + offsetof(typeof(*s), field),\
@@ -839,11 +865,13 @@ int kmod_elf_get_symbols(const struct kmod_elf *elf, struct kmod_modversion **ar
 			name_off = READV(st_name);
 			crc = READV(st_value);
 			info = READV(st_info);
+			shndx = READV(st_shndx);
 		} else {
 			Elf64_Sym *s;
 			name_off = READV(st_name);
 			crc = READV(st_value);
 			info = READV(st_info);
+			shndx = READV(st_shndx);
 		}
 #undef READV
 		name = elf_get_mem(elf, str_off + name_off);
@@ -856,7 +884,7 @@ int kmod_elf_get_symbols(const struct kmod_elf *elf, struct kmod_modversion **ar
 		else
 			bind = ELF64_ST_BIND(info);
 
-		a[count].crc = crc;
+		a[count].crc = kmod_elf_resolve_crc(elf, crc, shndx);
 		a[count].bind = kmod_symbol_bind_from_elf(bind);
 		a[count].symbol = itr;
 		slen = strlen(name);
-- 
2.14.0.rc0

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] libkmod-elf: resolve CRC if module is built with MODULE_REL_CRCS
  2017-07-19 14:56 [PATCH] libkmod-elf: resolve CRC if module is built with MODULE_REL_CRCS Yauheni Kaliuta
@ 2017-07-19 17:51 ` Lucas De Marchi
  2017-07-19 19:04   ` Yauheni Kaliuta
  0 siblings, 1 reply; 6+ messages in thread
From: Lucas De Marchi @ 2017-07-19 17:51 UTC (permalink / raw)
  To: Yauheni Kaliuta; +Cc: linux-modules, Ard Biesheuvel, lkml

On Wed, Jul 19, 2017 at 7:56 AM, Yauheni Kaliuta
<yauheni.kaliuta@redhat.com> wrote:
> Normally exported symbol's crc is stored as absolute (SHN_ABS)
> value of special named symbol __crc_<symbol name>.
>
> When the kernel and modules are built with the config option
> CONFIG_MODULE_REL_CRCS, all the CRCs are put in a special section
> and the __crc_<symbol name> symbols values are offsets in the
> section. See patch description of the commit:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=56067812d5b0e737ac2063e94a50f76b810d6ca3
>
> Add kmod support of this configuration.
>
> Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
> ---
>  libkmod/libkmod-elf.c | 30 +++++++++++++++++++++++++++++-
>  1 file changed, 29 insertions(+), 1 deletion(-)
>
> diff --git a/libkmod/libkmod-elf.c b/libkmod/libkmod-elf.c
> index 90da89aebbaf..ef4a8a3142a1 100644
> --- a/libkmod/libkmod-elf.c
> +++ b/libkmod/libkmod-elf.c
> @@ -747,6 +747,31 @@ static inline uint8_t kmod_symbol_bind_from_elf(uint8_t elf_value)
>         }
>  }
>
> +static uint64_t kmod_elf_resolve_crc(const struct kmod_elf *elf, uint64_t crc, uint16_t shndx)
> +{
> +       int err;
> +       uint64_t off, size;
> +       uint32_t nameoff;
> +
> +       if (shndx == SHN_ABS || shndx == SHN_UNDEF)
> +               return crc;
> +
> +       err = elf_get_section_info(elf, shndx, &off, &size, &nameoff);
> +       if (err < 0) {
> +               ELFDBG("Cound not find section index %"PRIu16" for crc", shndx);
> +               return (uint64_t)-1;
> +       }
> +
> +       if (crc > (size - sizeof(uint32_t))) {
> +               ELFDBG("CRC offset %"PRIu64" is too big, section %"PRIu16" size is %"PRIu64"\n",
> +                      crc, shndx, size);
> +               return (uint64_t)-1;
> +       }
> +
> +       crc = elf_get_uint(elf, off + crc, sizeof(uint32_t));
> +       return crc;
> +}
> +
>  /* array will be allocated with strings in a single malloc, just free *array */
>  int kmod_elf_get_symbols(const struct kmod_elf *elf, struct kmod_modversion **array)
>  {
> @@ -830,6 +855,7 @@ int kmod_elf_get_symbols(const struct kmod_elf *elf, struct kmod_modversion **ar
>                 uint32_t name_off;
>                 uint64_t crc;
>                 uint8_t info, bind;
> +               uint16_t shndx;
>
>  #define READV(field)                                                   \
>                 elf_get_uint(elf, sym_off + offsetof(typeof(*s), field),\
> @@ -839,11 +865,13 @@ int kmod_elf_get_symbols(const struct kmod_elf *elf, struct kmod_modversion **ar
>                         name_off = READV(st_name);
>                         crc = READV(st_value);
>                         info = READV(st_info);
> +                       shndx = READV(st_shndx);
>                 } else {
>                         Elf64_Sym *s;
>                         name_off = READV(st_name);
>                         crc = READV(st_value);
>                         info = READV(st_info);
> +                       shndx = READV(st_shndx);
>                 }
>  #undef READV
>                 name = elf_get_mem(elf, str_off + name_off);
> @@ -856,7 +884,7 @@ int kmod_elf_get_symbols(const struct kmod_elf *elf, struct kmod_modversion **ar
>                 else
>                         bind = ELF64_ST_BIND(info);
>
> -               a[count].crc = crc;
> +               a[count].crc = kmod_elf_resolve_crc(elf, crc, shndx);
>                 a[count].bind = kmod_symbol_bind_from_elf(bind);
>                 a[count].symbol = itr;
>                 slen = strlen(name);
> --

LGTM. I'll give this a try and apply.  Do you think it's possible to
build an out-of-tree module with this option so we can add one to the
testsuite?


Lucas De Marchi

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] libkmod-elf: resolve CRC if module is built with MODULE_REL_CRCS
  2017-07-19 17:51 ` Lucas De Marchi
@ 2017-07-19 19:04   ` Yauheni Kaliuta
  2017-07-19 19:10     ` Ard Biesheuvel
  2017-08-08 21:40     ` [RFC] resolve CRC test. Was: " Yauheni Kaliuta
  0 siblings, 2 replies; 6+ messages in thread
From: Yauheni Kaliuta @ 2017-07-19 19:04 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: linux-modules, Ard Biesheuvel, lkml

Hi, Lucas!

>>>>> On Wed, 19 Jul 2017 10:51:44 -0700, Lucas De Marchi  wrote:
 > On Wed, Jul 19, 2017 at 7:56 AM, Yauheni Kaliuta
 > <yauheni.kaliuta@redhat.com> wrote:
 >> Normally exported symbol's crc is stored as absolute (SHN_ABS)
 >> value of special named symbol __crc_<symbol name>.
 >> 
 >> When the kernel and modules are built with the config option
 >> CONFIG_MODULE_REL_CRCS, all the CRCs are put in a special section
 >> and the __crc_<symbol name> symbols values are offsets in the
 >> section. See patch description of the commit:
 >> 
 >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=56067812d5b0e737ac2063e94a50f76b810d6ca3
 >> 
 >> Add kmod support of this configuration.

[...]

 > LGTM. I'll give this a try and apply.

Thanks! I would also like to get some feedback from the kernel feature
author, Ard Biesheuvel, that this does not miss other usecases.

 > Do you think it's possible to build an out-of-tree module with this
 > option so we can add one to the testsuite?

I'll check what I can do.

The problem is seen if you run depmod with -e -E, which I guess is not used
too often.

-- 
WBR,
Yauheni Kaliuta

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] libkmod-elf: resolve CRC if module is built with MODULE_REL_CRCS
  2017-07-19 19:04   ` Yauheni Kaliuta
@ 2017-07-19 19:10     ` Ard Biesheuvel
  2017-07-19 19:33       ` Yauheni Kaliuta
  2017-08-08 21:40     ` [RFC] resolve CRC test. Was: " Yauheni Kaliuta
  1 sibling, 1 reply; 6+ messages in thread
From: Ard Biesheuvel @ 2017-07-19 19:10 UTC (permalink / raw)
  To: Yauheni Kaliuta; +Cc: Lucas De Marchi, linux-modules, lkml

On 19 July 2017 at 20:04, Yauheni Kaliuta <yauheni.kaliuta@redhat.com> wrote:
> Hi, Lucas!
>
>>>>>> On Wed, 19 Jul 2017 10:51:44 -0700, Lucas De Marchi  wrote:
>  > On Wed, Jul 19, 2017 at 7:56 AM, Yauheni Kaliuta
>  > <yauheni.kaliuta@redhat.com> wrote:
>  >> Normally exported symbol's crc is stored as absolute (SHN_ABS)
>  >> value of special named symbol __crc_<symbol name>.
>  >>
>  >> When the kernel and modules are built with the config option
>  >> CONFIG_MODULE_REL_CRCS, all the CRCs are put in a special section
>  >> and the __crc_<symbol name> symbols values are offsets in the
>  >> section. See patch description of the commit:
>  >>
>  >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=56067812d5b0e737ac2063e94a50f76b810d6ca3
>  >>
>  >> Add kmod support of this configuration.
>
> [...]
>
>  > LGTM. I'll give this a try and apply.
>
> Thanks! I would also like to get some feedback from the kernel feature
> author, Ard Biesheuvel, that this does not miss other usecases.
>

Hi all,

The patch looks correct to me. My only comment is that
kmod_elf_resolve_crc() should probably return a uint32_t instead,
given the size of a CRC32.

In any case,

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Thanks,
Ard.


>  > Do you think it's possible to build an out-of-tree module with this
>  > option so we can add one to the testsuite?
>
> I'll check what I can do.
>
> The problem is seen if you run depmod with -e -E, which I guess is not used
> too often.
>
> --
> WBR,
> Yauheni Kaliuta

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] libkmod-elf: resolve CRC if module is built with MODULE_REL_CRCS
  2017-07-19 19:10     ` Ard Biesheuvel
@ 2017-07-19 19:33       ` Yauheni Kaliuta
  0 siblings, 0 replies; 6+ messages in thread
From: Yauheni Kaliuta @ 2017-07-19 19:33 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: Lucas De Marchi, linux-modules, lkml

Hi, Ard!

>>>>> On Wed, 19 Jul 2017 20:10:17 +0100, Ard Biesheuvel  wrote:

 > On 19 July 2017 at 20:04, Yauheni Kaliuta <yauheni.kaliuta@redhat.com> wrote:
 >> Hi, Lucas!
 >> 
 >>>>>>> On Wed, 19 Jul 2017 10:51:44 -0700, Lucas De Marchi  wrote:
 >> > On Wed, Jul 19, 2017 at 7:56 AM, Yauheni Kaliuta
 >> > <yauheni.kaliuta@redhat.com> wrote:
 >> >> Normally exported symbol's crc is stored as absolute (SHN_ABS)
 >> >> value of special named symbol __crc_<symbol name>.
 >> >>
 >> >> When the kernel and modules are built with the config option
 >> >> CONFIG_MODULE_REL_CRCS, all the CRCs are put in a special section
 >> >> and the __crc_<symbol name> symbols values are offsets in the
 >> >> section. See patch description of the commit:
 >> >>
 >> >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=56067812d5b0e737ac2063e94a50f76b810d6ca3
 >> >>
 >> >> Add kmod support of this configuration.
 >> 
 >> [...]
 >> 
 >> > LGTM. I'll give this a try and apply.
 >> 
 >> Thanks! I would also like to get some feedback from the kernel feature
 >> author, Ard Biesheuvel, that this does not miss other usecases.
 >> 

 > The patch looks correct to me. My only comment is that
 > kmod_elf_resolve_crc() should probably return a uint32_t instead,
 > given the size of a CRC32.

Well, it's a specific of the internal libkmod implementation. Both
struct kmod_modversion::crc and return value of elf_get_uint()
are uint64_t, but in the patch elf_get_uint() reads correct
sizeof(uint32_t) value from the ELF.

 > In any case,

 > Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Thanks a lot!

-- 
WBR,
Yauheni Kaliuta

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [RFC] resolve CRC test. Was: Re: [PATCH] libkmod-elf: resolve CRC if module is built with MODULE_REL_CRCS
  2017-07-19 19:04   ` Yauheni Kaliuta
  2017-07-19 19:10     ` Ard Biesheuvel
@ 2017-08-08 21:40     ` " Yauheni Kaliuta
  1 sibling, 0 replies; 6+ messages in thread
From: Yauheni Kaliuta @ 2017-08-08 21:40 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: linux-modules

Hi, Lucas!

>>>>> On Wed, 19 Jul 2017 22:04:19 +0300, Yauheni Kaliuta  wrote:
>>>>> On Wed, 19 Jul 2017 10:51:44 -0700, Lucas De Marchi  wrote:

[...]

 >> Do you think it's possible to build an out-of-tree module with this
 >> option so we can add one to the testsuite?

 > I'll check what I can do.

Some ideas below. I reused the existing "foo" modules with their
dependencies. Possible problem is that it requires the host kernel to be
built with MODVERSIONS enabled (not the case for Fedora).

---
 testsuite/module-playground/Makefile               | 10 +++++++-
 testsuite/populate-modules.sh                      |  4 +++
 .../test-depmod/relocated-crc/boot/symvers         |  0
 .../lib/modules/4.4.4/correct-modules.dep          |  4 +++
 .../lib/modules/4.4.4/modules.builtin              |  0
 .../relocated-crc/lib/modules/4.4.4/modules.order  |  0
 .../test-depmod/relocated-crc/output.err           | 10 ++++++++
 testsuite/test-depmod.c                            | 30 ++++++++++++++++++++++
 8 files changed, 57 insertions(+), 1 deletion(-)
 create mode 100644 testsuite/rootfs-pristine/test-depmod/relocated-crc/boot/symvers
 create mode 100644 testsuite/rootfs-pristine/test-depmod/relocated-crc/lib/modules/4.4.4/correct-modules.dep
 create mode 100644 testsuite/rootfs-pristine/test-depmod/relocated-crc/lib/modules/4.4.4/modules.builtin
 create mode 100644 testsuite/rootfs-pristine/test-depmod/relocated-crc/lib/modules/4.4.4/modules.order
 create mode 100644 testsuite/rootfs-pristine/test-depmod/relocated-crc/output.err

diff --git a/testsuite/module-playground/Makefile b/testsuite/module-playground/Makefile
index e6045b0..f12f301 100644
--- a/testsuite/module-playground/Makefile
+++ b/testsuite/module-playground/Makefile
@@ -11,6 +11,10 @@ obj-m += mod-foo-b.o
 obj-m += mod-foo-c.o
 obj-m += mod-foo.o
 
+# predictable relocated/non-relocated symbols crc
+mod-foo-a-rel-y := mod-foo-a.o
+mod-foo-b-nonrel-y := mod-foo-b.o
+
 # mod-loop: create loops in dependencies:
 # 1) mod-loop-a  ->  mod-loop-b -> mod-loop-c -> mod-loop-a
 #     |-> mod-loop-f    |-> mod-loop-f
@@ -63,8 +67,12 @@ mod-simple-%.ko: mod-simple-%.c Makefile.arch
 	$(MAKE) KDIR=$(KDIR_$(arch)) ARCH=$(arch) CROSS_COMPILE=$(CROSS_COMPILE_$(arch)) -f Makefile.arch
 
 ifeq ($(FAKE_BUILD),0)
-modules:
+modules: rel-modules
 	$(MAKE) -C $(KDIR) M=$$PWD
+
+rel-modules:
+	$(MAKE) -C $(KDIR) M=$$PWD CONFIG_MODULE_REL_CRCS=y obj-m=mod-foo-a-rel.o
+	$(MAKE) -C $(KDIR) M=$$PWD CONFIG_MODULE_REL_CRCS=n obj-m=mod-foo-b-nonrel.o
 else
 modules:
 	@echo "  CP       cache/*.ko"
diff --git a/testsuite/populate-modules.sh b/testsuite/populate-modules.sh
index 3ac92ee..f6f71fa 100755
--- a/testsuite/populate-modules.sh
+++ b/testsuite/populate-modules.sh
@@ -28,6 +28,10 @@ map=(
     ["test-depmod/search-order-external-last/lib/modules/4.4.4/foo/"]="mod-simple.ko"
     ["test-depmod/search-order-external-last/lib/modules/4.4.4/foobar/"]="mod-simple.ko"
     ["test-depmod/search-order-external-last/lib/modules/external/"]="mod-simple.ko"
+    ["test-depmod/relocated-crc/lib/modules/4.4.4/kernel/mod-foo-a-rel.ko"]="mod-foo-a-rel.ko"
+    ["test-depmod/relocated-crc/lib/modules/4.4.4/kernel/mod-foo-b-nonrel.ko"]="mod-foo-b-nonrel.ko"
+    ["test-depmod/relocated-crc/lib/modules/4.4.4/kernel/mod-foo-c.ko"]="mod-foo-c.ko"
+    ["test-depmod/relocated-crc/lib/modules/4.4.4/kernel/mod-foo.ko"]="mod-foo.ko"
     ["test-dependencies/lib/modules/4.0.20-kmod/kernel/fs/foo/"]="mod-foo-b.ko"
     ["test-dependencies/lib/modules/4.0.20-kmod/kernel/"]="mod-foo-c.ko"
     ["test-dependencies/lib/modules/4.0.20-kmod/kernel/lib/"]="mod-foo-a.ko"
diff --git a/testsuite/rootfs-pristine/test-depmod/relocated-crc/boot/symvers b/testsuite/rootfs-pristine/test-depmod/relocated-crc/boot/symvers
new file mode 100644
index 0000000..e69de29
diff --git a/testsuite/rootfs-pristine/test-depmod/relocated-crc/lib/modules/4.4.4/correct-modules.dep b/testsuite/rootfs-pristine/test-depmod/relocated-crc/lib/modules/4.4.4/correct-modules.dep
new file mode 100644
index 0000000..303060c
--- /dev/null
+++ b/testsuite/rootfs-pristine/test-depmod/relocated-crc/lib/modules/4.4.4/correct-modules.dep
@@ -0,0 +1,4 @@
+kernel/mod-foo-c.ko:
+kernel/mod-foo-b-nonrel.ko:
+kernel/mod-foo.ko: kernel/mod-foo-b-nonrel.ko kernel/mod-foo-a-rel.ko kernel/mod-foo-c.ko
+kernel/mod-foo-a-rel.ko:
diff --git a/testsuite/rootfs-pristine/test-depmod/relocated-crc/lib/modules/4.4.4/modules.builtin b/testsuite/rootfs-pristine/test-depmod/relocated-crc/lib/modules/4.4.4/modules.builtin
new file mode 100644
index 0000000..e69de29
diff --git a/testsuite/rootfs-pristine/test-depmod/relocated-crc/lib/modules/4.4.4/modules.order b/testsuite/rootfs-pristine/test-depmod/relocated-crc/lib/modules/4.4.4/modules.order
new file mode 100644
index 0000000..e69de29
diff --git a/testsuite/rootfs-pristine/test-depmod/relocated-crc/output.err b/testsuite/rootfs-pristine/test-depmod/relocated-crc/output.err
new file mode 100644
index 0000000..d7e4fb0
--- /dev/null
+++ b/testsuite/rootfs-pristine/test-depmod/relocated-crc/output.err
@@ -0,0 +1,10 @@
+depmod: WARNING: /lib/modules/4.4.4/kernel/mod-foo-c.ko needs unknown symbol __fentry__
+depmod: WARNING: /lib/modules/4.4.4/kernel/mod-foo-c.ko needs unknown symbol printk
+depmod: WARNING: /lib/modules/4.4.4/kernel/mod-foo-c.ko needs unknown symbol module_layout
+depmod: WARNING: /lib/modules/4.4.4/kernel/mod-foo-b-nonrel.ko needs unknown symbol __fentry__
+depmod: WARNING: /lib/modules/4.4.4/kernel/mod-foo-b-nonrel.ko needs unknown symbol printk
+depmod: WARNING: /lib/modules/4.4.4/kernel/mod-foo-b-nonrel.ko needs unknown symbol module_layout
+depmod: WARNING: /lib/modules/4.4.4/kernel/mod-foo.ko needs unknown symbol module_layout
+depmod: WARNING: /lib/modules/4.4.4/kernel/mod-foo-a-rel.ko needs unknown symbol __fentry__
+depmod: WARNING: /lib/modules/4.4.4/kernel/mod-foo-a-rel.ko needs unknown symbol printk
+depmod: WARNING: /lib/modules/4.4.4/kernel/mod-foo-a-rel.ko needs unknown symbol module_layout
diff --git a/testsuite/test-depmod.c b/testsuite/test-depmod.c
index e249c61..a4c8ed7 100644
--- a/testsuite/test-depmod.c
+++ b/testsuite/test-depmod.c
@@ -183,4 +183,34 @@ DEFINE_TEST(depmod_search_order_external_last,
 		},
 	});
 
+#define RELOCATED_CRC_ROOTFS TESTSUITE_ROOTFS "test-depmod/relocated-crc"
+static noreturn int relocated_crc(const struct test *t)
+{
+	const char *progname = ABS_TOP_BUILDDIR "/tools/depmod";
+	const char *const args[] = {
+		progname,
+		"-aeE",
+		"/boot/symvers",
+		NULL,
+	};
+
+	test_spawn_prog(progname, args);
+	exit(EXIT_FAILURE);
+}
+DEFINE_TEST(relocated_crc,
+	.description = "check if depmod understand both relocated and non-relocated crcs",
+	.print_outputs = true,
+	.config = {
+		[TC_UNAME_R] = "4.4.4",
+		[TC_ROOTFS] = RELOCATED_CRC_ROOTFS,
+	},
+	.output = {
+	        .err = RELOCATED_CRC_ROOTFS "/output.err",
+		.files = (const struct keyval[]) {
+			{ RELOCATED_CRC_ROOTFS "/lib/modules/4.4.4/correct-modules.dep",
+			  RELOCATED_CRC_ROOTFS "/lib/modules/4.4.4/modules.dep" },
+			{ }
+		},
+	});
+
 TESTSUITE_MAIN();
-- 
2.13.3





-- 
WBR,
Yauheni Kaliuta

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-19 14:56 [PATCH] libkmod-elf: resolve CRC if module is built with MODULE_REL_CRCS Yauheni Kaliuta
2017-07-19 17:51 ` Lucas De Marchi
2017-07-19 19:04   ` Yauheni Kaliuta
2017-07-19 19:10     ` Ard Biesheuvel
2017-07-19 19:33       ` Yauheni Kaliuta
2017-08-08 21:40     ` [RFC] resolve CRC test. Was: " Yauheni Kaliuta

Linux-Modules Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-modules/0 linux-modules/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-modules linux-modules/ https://lore.kernel.org/linux-modules \
		linux-modules@vger.kernel.org linux-modules@archiver.kernel.org
	public-inbox-index linux-modules


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-modules


AGPL code for this site: git clone https://public-inbox.org/ public-inbox