lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 20 Jul 2007 09:37:00 +0530
From:	"Satyam Sharma" <satyam.sharma@...il.com>
To:	"Reiner Sailer" <sailer@...ibm.com>
Cc:	"Jesper Juhl" <jesper.juhl@...il.com>, kjhall@...ux.vnet.ibm.com,
	"Linux Kernel Mailing List" <linux-kernel@...r.kernel.org>,
	"Seiji Munetoh" <munetoh@...ibm.com>,
	"Reiner Sailer" <sailer@...son.ibm.com>, stefanb@...ibm.com
Subject: Re: [PATCH] Memory leak in tpm_ascii_bios_measurements_open() fix.

On 7/20/07, Reiner Sailer <sailer@...ibm.com> wrote:
>
> Jesper Juhl <jesper.juhl@...il.com> wrote on 07/18/2007 07:11:54 PM:
>  >
>  > +++ b/drivers/char/tpm/tpm_bios.c
>  > @@ -427,7 +427,7 @@ static int
>  > tpm_ascii_bios_measurements_open(struct inode *inode,
>  >        return -ENOMEM;
>  >
>  >     if ((err = read_log(log)))
>  > -      return err;
>  > +      goto out_free;
>  >
>  >     /* now register seq file */
>  >     err = seq_open(file, &tpm_ascii_b_measurments_seqops);
>  > @@ -435,10 +435,15 @@ static int
>  > tpm_ascii_bios_measurements_open(struct inode *inode,
>  >        seq = file->private_data;
>  >        seq->private = log;
>  >     } else {
>  > -      kfree(log->bios_event_log);
>  > -      kfree(log);
>  > +      goto out_free;
>  >     }
>  > +
>  > +out:
>  >     return err;
>  > +out_free:
>  > +   kfree(log->bios_event_log);
>  > +   kfree(log);
>  > +   goto out;
>  >  }
>  >
>  >  const struct file_operations tpm_ascii_bios_measurements_ops = {
>  >
>  >
>
> Index: linux-2.6.22-rc7/drivers/char/tpm/tpm_bios.c
> ===================================================================
> --- linux-2.6.22-rc7.orig/drivers/char/tpm/tpm_bios.c
> +++ linux-2.6.22-rc7/drivers/char/tpm/tpm_bios.c
> @@ -426,9 +426,10 @@ static int tpm_ascii_bios_measurements_o
>      if (!log)
>          return -ENOMEM;
>
> -    if ((err = read_log(log)))
> +    if ((err = read_log(log))) {
> +        kfree(log);
>          return err;
> -
> +    }
>      /* now register seq file */
>      err = seq_open(file, &tpm_ascii_b_measurments_seqops);
>      if (!err) {
>
> Do you agree?


Jesper's patch makes  the code conforming to the kernel coding style
(kfree()'s in common error paths, single "return" call, etc). Not a big
issue, just a consistency thing, so feel free to take your pick between
the two alternatives.

BTW please also fix an exactly similar memory leak 30 lines later in the
same file -- in tpm_binary_bios_measurements_open() -- while you're at it.

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ