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] [day] [month] [year] [list]
Message-Id: <20070731113608.f2c5d8b6.akpm@linux-foundation.org>
Date:	Tue, 31 Jul 2007 11:36:08 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	"Mike Frysinger" <vapier.adi@...il.com>
Cc:	"Robin Getz" <rgetz@...ckfin.uclinux.org>,
	linux-kernel@...r.kernel.org, "Greg Ungerer" <gerg@...pgear.com>,
	"Russell King" <rmk@....linux.org.uk>,
	"Paul Mundt" <lethal@...ux-sh.org>,
	"Tim Bird" <tim.bird@...sony.com>, bryan.wu@...log.com
Subject: Re: early_printk accessing __log_buf

On Tue, 31 Jul 2007 03:47:59 -0400
"Mike Frysinger" <vapier.adi@...il.com> wrote:

> attached
> -mike
> 
> 
> [linux-log_buf_read.patch  application/octet-stream (2.4KB)]

Please sort out the email thing if you plan on sending more kernel patches?

Incremental:


From: Andrew Morton <akpm@...ux-foundation.org>

- compile fix

- Race fix: oops_in_progress can change at any time

- coding-style fixlets.

Cc: Greg Ungerer <gerg@...pgear.com>
Cc: Mike Frysinger <vapier.adi@...il.com>
Cc: Mike Frysinger <vapier@...too.org>
Cc: Paul Mundt <lethal@...ux-sh.org>
Cc: Robin Getz <rgetz@...ckfin.uclinux.org>
Cc: Russell King <rmk@....linux.org.uk>
Cc: Tim Bird <tim.bird@...sony.com>
Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
---

 include/linux/kernel.h |    2 +-
 kernel/printk.c        |   12 ++++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff -puN include/linux/kernel.h~early_printk-accessing-__log_buf-fix include/linux/kernel.h
--- a/include/linux/kernel.h~early_printk-accessing-__log_buf-fix
+++ a/include/linux/kernel.h
@@ -168,7 +168,7 @@ static inline int printk(const char *s, 
 	__attribute__ ((format (printf, 1, 2)));
 static inline int __cold printk(const char *s, ...) { return 0; }
 static inline int log_buf_get_len(void) { return 0; }
-static inline int log_buf_read(int idx); { return 0; }
+static inline int log_buf_read(int idx) { return 0; }
 static inline int log_buf_copy(char *dest, int idx, int len) { return 0; }
 #endif
 
diff -puN kernel/printk.c~early_printk-accessing-__log_buf-fix kernel/printk.c
--- a/kernel/printk.c~early_printk-accessing-__log_buf-fix
+++ a/kernel/printk.c
@@ -233,14 +233,17 @@ int log_buf_get_len(void)
 int log_buf_copy(char *dest, int idx, int len)
 {
 	int ret, max;
+	bool took_lock = false;
 
-	if (!oops_in_progress)
+	if (!oops_in_progress) {
 		spin_lock_irq(&logbuf_lock);
+		took_lock = true;
+	}
 
 	max = log_buf_get_len();
-	if (idx < 0 || idx >= max)
+	if (idx < 0 || idx >= max) {
 		ret = -1;
-	else {
+	} else {
 		if (len > max)
 			len = max;
 		ret = len;
@@ -250,7 +253,7 @@ int log_buf_copy(char *dest, int idx, in
 		}
 	}
 
-	if (!oops_in_progress)
+	if (took_lock)
 		spin_unlock_irq(&logbuf_lock);
 
 	return ret;
@@ -262,6 +265,7 @@ int log_buf_copy(char *dest, int idx, in
 int log_buf_read(int idx)
 {
 	char ret;
+
 	if (log_buf_copy(&ret, idx, 1) == 1)
 		return ret;
 	else
_

-
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