From: Andrew Morton on
On Wed, 04 Aug 2010 15:38:43 +0300
Alexey Fomenko <ext-alexey.fomenko(a)nokia.com> wrote:

> sec2annotation returns malloc'ed buffer directly to printf as an
> argument. Patch lets free this buffer after printing.
>
>
> [0001-fixed-resource-leak-in-scripts-mod-modpost.c.patch text/x-patch (5.3KB)]
> >From 57bde7f335730f95eac75bcec5a27fb6686df25a Mon Sep 17 00:00:00 2001
> From: Alexey Fomenko <ext-alexey.fomenko(a)nokia.com>
> Date: Tue, 27 Jul 2010 17:59:04 +0300
> Subject: [PATCH] fixed resource leak in scripts/mod/modpost.c
>

Against 2.6.35:

patching file scripts/mod/modpost.c
Hunk #1 succeeded at 1195 (offset 37 lines).
Hunk #2 FAILED at 1221.
Hunk #3 FAILED at 1243.
Hunk #4 FAILED at 1268.
Hunk #5 FAILED at 1301.
Hunk #6 FAILED at 1318.
5 out of 6 hunks FAILED -- saving rejects to file scripts/mod/modpost.c.rej

please check up on that.

Please also cc Rusty on this change.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Andy Shevchenko on
On Thu, Aug 5, 2010 at 3:09 PM, Alexey Fomenko
<ext-alexey.fomenko(a)nokia.com> wrote:
> Patch modified for released 2.6.35 kernel.
> sec2annotation returns malloc'ed buffer directly to printf as an
> argument. Patch lets free this buffer after printing.

Needs to be amended.
I told Alexey in private to resend new version of the patch.

--
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Andy Shevchenko on
On Tue, Aug 10, 2010 at 1:52 PM, Alexey Fomenko
<ext-alexey.fomenko(a)nokia.com> wrote:
> From: Alexey Fomenko <ext-alexey.fomenko(a)nokia.com>
>
> sec2annotation() returns malloc'ed buffer directly to printf as an
> argument. Patch lets free this buffer after printing. Preventing ops
> while freeing the buffer by changing return const str to return
> strdup empty line.
>
> Signed-off-by: Alexey Fomenko <ext-alexey.fomenko(a)nokia.com>
> ---
>  scripts/mod/modpost.c |   58 ++++++++++++++++++++++++++++++++++++------------
>  1 files changed, 42 insertions(+), 16 deletions(-)
>
> diff -ur linux-2.6.35/scripts/mod/modpost.c linux-2.6.35_b/scripts/mod/modpost.c
> --- linux-2.6.35/scripts/mod/modpost.c  2010-08-10 12:11:03.854528620 +0300
> +++ linux-2.6.35_b/scripts/mod/modpost.c        2010-08-10 12:11:25.174529109 +0300
> @@ -1165,9 +1165,9 @@
>                        strcat(p, "data ");
>                else
>                        strcat(p, " ");
> -               return r; /* we leak her but we do not care */
> +               return r;
Here is the extra tail whitespace.

> @@ -1283,11 +1301,15 @@
>                "uses functionality in the exit path.\n"
>                "The fix is often to remove the %sannotation of\n"
>                "%s%s so it may be used outside an exit section.\n",
> -               from, sec2annotation(fromsec), fromsym, from_p,
> -               to, sec2annotation(tosec), tosym, to_p,
> +               from, prl_from, fromsym, from_p,
> +               to, prl_to, tosym, to_p,
>                sec2annotation(tosec), tosym, to_p);
^^^^^^^^^^^^^^^^^^^^^^ missed change


Acked-by: Andy Shevchenko <ext-andriy.shevchenko(a)nokia.com>
(after fixing above issues)

--
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Andy Shevchenko on
On Tue, Aug 10, 2010 at 3:03 PM, Alexey Fomenko
<ext-alexey.fomenko(a)nokia.com> wrote:
> From: Alexey Fomenko <ext-alexey.fomenko(a)nokia.com>
>
> sec2annotation() returns malloc'ed buffer directly to printf as an
> argument. Patch lets free this buffer after printing. Preventing ops
> while freeing the buffer by changing return const str to return
> strdup empty line.
>
> Signed-off-by: Alexey Fomenko <ext-alexey.fomenko(a)nokia.com>

> @@ -1283,11 +1301,15 @@
>                "uses functionality in the exit path.\n"
>                "The fix is often to remove the %sannotation of\n"
>                "%s%s so it may be used outside an exit section.\n",
> -               from, sec2annotation(fromsec), fromsym, from_p,
> -               to, sec2annotation(tosec), tosym, to_p,
> -               sec2annotation(tosec), tosym, to_p);
> +               from, prl_from, fromsym, from_p,
> +               to, prl_to, tosym, to_p,
> +               ptl_to, tosym, to_p);
Did you ever compile this code?
It looks typo here.

> +               free(prl_from);
> +               free(prl_to);
>                break;
>        case ANY_EXIT_TO_ANY_INIT:
> +               prl_from = sec2annotation(fromsec);
> +               prl_to = sec2annotation(tosec);
>                fprintf(stderr,
>                "The %s %s%s%s references\n"
>                "a %s %s%s%s.\n"

--
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Alexey Fomenko on
On Tue, 2010-08-10 at 14:21 +0200, ext Andy Shevchenko wrote:
> On Tue, Aug 10, 2010 at 3:03 PM, Alexey Fomenko
> <ext-alexey.fomenko(a)nokia.com> wrote:
> > From: Alexey Fomenko <ext-alexey.fomenko(a)nokia.com>
> >
> > sec2annotation() returns malloc'ed buffer directly to printf as an
> > argument. Patch lets free this buffer after printing. Preventing ops
> > while freeing the buffer by changing return const str to return
> > strdup empty line.
> >
> > Signed-off-by: Alexey Fomenko <ext-alexey.fomenko(a)nokia.com>
>
> > @@ -1283,11 +1301,15 @@
> > "uses functionality in the exit path.\n"
> > "The fix is often to remove the %sannotation of\n"
> > "%s%s so it may be used outside an exit section.\n",
> > - from, sec2annotation(fromsec), fromsym, from_p,
> > - to, sec2annotation(tosec), tosym, to_p,
> > - sec2annotation(tosec), tosym, to_p);
> > + from, prl_from, fromsym, from_p,
> > + to, prl_to, tosym, to_p,
> > + ptl_to, tosym, to_p);
> Did you ever compile this code?
> It looks typo here.
Ever - yes, last one - no, was in a hurry. Shouldn't have been.
I'll fix it.

>
> > + free(prl_from);
> > + free(prl_to);
> > break;
> > case ANY_EXIT_TO_ANY_INIT:
> > + prl_from = sec2annotation(fromsec);
> > + prl_to = sec2annotation(tosec);
> > fprintf(stderr,
> > "The %s %s%s%s references\n"
> > "a %s %s%s%s.\n"
>


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/