linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.de.marchi@gmail.com>
To: Mian Yousaf Kaukab <yousaf.kaukab@suse.com>
Cc: linux-modules <linux-modules@vger.kernel.org>,
	Lucas De Marchi <lucas.demarchi@intel.com>,
	bjorn.andersson@linaro.org, afaerber@suse.de
Subject: Re: [PATCH v1 2/2] depmod: ignore related modules in depmod_report_cycles
Date: Tue, 8 Nov 2016 22:40:20 -0200	[thread overview]
Message-ID: <CAKi4VAKh0R-RN1j=Eum3wKtQ434D_7uBj1EGwzGCBrEB0qFkTg@mail.gmail.com> (raw)
In-Reply-To: <1478623550-18716-2-git-send-email-yousaf.kaukab@suse.com>

On Tue, Nov 8, 2016 at 2:45 PM, Mian Yousaf Kaukab
<yousaf.kaukab@suse.com> wrote:
> Only print actual cyclic dependencies. Print count of all the modules
> in cyclic dependency at the end of the function so that dependent
> modules which are not in cyclic chain can be ignored.
>
> Printing dependent modules which are not in cyclic chain causes buffer
> overflow as m->modnamesz is not included in buffer size calculations
> (loop =3D=3D m is never true). This buffer overflow causes kmod to crash.
>
> Update depmod test to reflect the change as well.
>
> Reported-by: Andreas F=C3=A4rber <afaerber@suse.de>
> Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@suse.com>
> ---
> Change-log:
>  v1: Keep the old output stings. Only change their order
>      Add test case to reproduce the problem
>
>  .../rootfs-pristine/test-depmod/detect-loop/correct.txt     |  2 +-
>  tools/depmod.c                                              | 13 +++++++=
+++++-
>  2 files changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/testsuite/rootfs-pristine/test-depmod/detect-loop/correct.tx=
t b/testsuite/rootfs-pristine/test-depmod/detect-loop/correct.txt
> index 4eb26df..01ecb89 100644
> --- a/testsuite/rootfs-pristine/test-depmod/detect-loop/correct.txt
> +++ b/testsuite/rootfs-pristine/test-depmod/detect-loop/correct.txt
> @@ -1,3 +1,3 @@
> -depmod: ERROR: Found 5 modules in dependency cycles!
>  depmod: ERROR: Cycle detected: mod_loop_d -> mod_loop_e -> mod_loop_d
>  depmod: ERROR: Cycle detected: mod_loop_b -> mod_loop_c -> mod_loop_a ->=
 mod_loop_b
> +depmod: ERROR: Found 5 modules in dependency cycles!
> diff --git a/tools/depmod.c b/tools/depmod.c
> index ad01f66..f2b370f 100644
> --- a/tools/depmod.c
> +++ b/tools/depmod.c
> @@ -1456,7 +1456,7 @@ static void depmod_report_cycles(struct depmod *dep=
mod, uint16_t n_mods,
>  {
>         const char sep[] =3D " -> ";
>         int ir =3D 0;
> -       ERR("Found %u modules in dependency cycles!\n", n_roots);
> +       int num_cyclic =3D 0;
>
>         while (n_roots > 0) {
>                 int is, ie;
> @@ -1491,6 +1491,7 @@ static void depmod_report_cycles(struct depmod *dep=
mod, uint16_t n_mods,
>                         if (m->visited) {
>                                 int i, n =3D 0, sz =3D 0;
>                                 char *buf;
> +                               bool is_cyclic =3D false;
>
>                                 for (i =3D ie - 1; i >=3D 0; i--) {
>                                         struct mod *loop =3D depmod->modu=
les.array[edges[i]];
> @@ -1498,9 +1499,17 @@ static void depmod_report_cycles(struct depmod *de=
pmod, uint16_t n_mods,
>                                         n++;
>                                         if (loop =3D=3D m) {
>                                                 sz +=3D loop->modnamesz -=
 1;
> +                                               is_cyclic =3D true;
>                                                 break;
>                                         }
>                                 }
> +                               /* Current module not found in dependency=
 list.
> +                                * Must be a related module. Ignore it.
> +                                */
> +                               if (!is_cyclic)
> +                                       continue;
> +
> +                               num_cyclic +=3D n;
>
>                                 buf =3D malloc(sz + n * strlen(sep) + 1);
>                                 sz =3D 0;
> @@ -1538,6 +1547,8 @@ static void depmod_report_cycles(struct depmod *dep=
mod, uint16_t n_mods,
>                         }
>                 }
>         }
> +
> +       ERR("Found %d modules in dependency cycles!\n", num_cyclic);
>  }

thanks, much better now.

Applied.

Lucas De Marchi

  reply	other threads:[~2016-11-09  0:40 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-08 16:45 [PATCH v1 1/2] testsuite: depmod: add module dependency outside cyclic chain Mian Yousaf Kaukab
2016-11-08 16:45 ` [PATCH v1 2/2] depmod: ignore related modules in depmod_report_cycles Mian Yousaf Kaukab
2016-11-09  0:40   ` Lucas De Marchi [this message]
2016-11-09  2:59     ` Yauheni Kaliuta
2016-11-09  9:17       ` Mian Yousaf Kaukab
2016-11-09 11:23         ` Yauheni Kaliuta
2016-11-11 11:43         ` [PATCH RFC 0/3] Proposal for cycles handling Yauheni Kaliuta
2016-11-11 11:43           ` [PATCH RFC 2/3] libkmod: list: export list handling functions Yauheni Kaliuta
2017-02-13  8:05             ` Lucas De Marchi
2017-02-20 14:22               ` Yauheni Kaliuta
2017-02-22  5:26                 ` Lucas De Marchi
2017-02-22  9:41                   ` [PATCH v3 0/2] Proposal for cycles handling Yauheni Kaliuta
2017-02-22  9:41                     ` [PATCH v3 1/2] testsuite: depmod: check netsted loops reporting Yauheni Kaliuta
2017-02-22  9:41                     ` [PATCH v3 2/2] depmod: handle nested loops Yauheni Kaliuta
2017-02-23 22:30                       ` Lucas De Marchi
2016-11-11 11:43           ` [PATCH RFC 3/3] " Yauheni Kaliuta
2017-02-13  8:30             ` Lucas De Marchi
2017-02-20 14:16               ` Yauheni Kaliuta
2017-02-13  8:16           ` [PATCH RFC 0/3] Proposal for cycles handling Lucas De Marchi
2017-02-13  9:56             ` Yauheni Kaliuta
2017-02-13  8:32           ` Lucas De Marchi
2017-02-20 14:18             ` [PATCH RFC v2 0/2] " Yauheni Kaliuta
2017-02-20 14:18               ` [PATCH RFC v2 1/2] testsuite: depmod: check netsted loops reporting Yauheni Kaliuta
2017-02-20 14:19               ` [PATCH RFC v2 2/2] depmod: handle nested loops Yauheni Kaliuta
2016-11-09  0:29 ` [PATCH v1 1/2] testsuite: depmod: add module dependency outside cyclic chain Lucas De Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKi4VAKh0R-RN1j=Eum3wKtQ434D_7uBj1EGwzGCBrEB0qFkTg@mail.gmail.com' \
    --to=lucas.de.marchi@gmail.com \
    --cc=afaerber@suse.de \
    --cc=bjorn.andersson@linaro.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=lucas.demarchi@intel.com \
    --cc=yousaf.kaukab@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).