lkml.org 
[lkml]   [2001]   [Oct]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] binfmt_misc.c, kernel-2.4.12
Hi Linus,

As Al pissed me off again with complaining about binfmt_misc, please
apply the attached patch which corrects the 'not C code' line and
fixes the problem Albert noticed. This doesnt fix various assumptions
about the /proc code that were either valid at the time of writing
binfmt_misc or badly/not documented.

Feel free to use binfmt_misc version from -ac, I'm sure Al will take
responsibility of maintaining that crappy version then.

Thanx, Richard.

On Fri, 19 Oct 2001, Alexander Viro wrote:
> On Fri, 19 Oct 2001, Albert Bartoszko wrote:
> > Hello
> >
> > I find bug in binfmt_misc.c from kernel 2.4.12 source. The read() syscal
>
> only one?
>
> > return bad value, causes some application SIGSEGV.
>
> Hardly a surprise. Not everything that passes compiler is valid C.
> Stuff in fs/binfmt_misc.c from Linus' tree isn't. Pick one from -ac
> + corresponding change in fs/proc/root.c (again, see -ac). Variant
> in Linus' tree is complete crap.
>
> <goes back to sleep>

--
Richard Guenther <richard.guenther@uni-tuebingen.de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/
The GLAME Project: http://www.glame.de/
--- /home/kobras/tatadm/kernel/linux-2.4.3-UP/fs/binfmt_misc.c Fri Feb 9 20:29:44 2001
+++ binfmt_misc.c Fri Oct 19 15:26:32 2001
@@ -13,6 +13,8 @@
* 1997-06-26 hpa: pass the real filename rather than argv[0]
* 1997-06-30 minor cleanup
* 1997-08-09 removed extension stripping, locking cleanup
+ * 2001-10-15 Albert Bartoszko: cleanup,
+ * correct return value of proc_read_status()
*/

#include <linux/config.h>
@@ -300,9 +302,7 @@

e->proc_name = copyarg(&dp, &sp, &cnt, del, 0, &err);

- /* we can use bit 3 of type for ext/magic
- flag due to the nice encoding of E and M */
- if ((*sp & ~('E' | 'M')) || (sp[1] != del))
+ if ((*sp != 'E' && *sp != 'M') || (sp[1] != del))
err = -EINVAL;
else
e->flags = (*sp++ & (ENTRY_MAGIC | ENTRY_ENABLED));
@@ -354,28 +354,19 @@
char *dp;
int elen, i, err;

-#ifndef VERBOSE_STATUS
- if (data) {
+ if (!data)
+ sprintf(page, "%s\n", "enabled");
+ else {
if (!(e = get_entry((int) data))) {
err = -ENOENT;
goto _err;
- }
- i = e->flags & ENTRY_ENABLED;
- put_entry(e);
- } else {
- i = enabled;
- }
- sprintf(page, "%s\n", (i ? "enabled" : "disabled"));
+ }
+#ifndef VERBOSE_STATUS
+ sprintf(page, "%s\n",
+ (e->flags & ENTRY_ENABLED) ? "enabled" : "disabled");
#else
- if (!data)
- sprintf(page, "%s\n", (enabled ? "enabled" : "disabled"));
- else {
- if (!(e = get_entry((long) data))) {
- err = -ENOENT;
- goto _err;
- }
- sprintf(page, "%s\ninterpreter %s\n",
- (e->flags & ENTRY_ENABLED ? "enabled" : "disabled"),
+ sprintf(page, "%s\ninterpreter %s\n",
+ (e->flags & ENTRY_ENABLED) ? "enabled" : "disabled",
e->interpreter);
dp = page + strlen(page);
if (!(e->flags & ENTRY_MAGIC)) {
@@ -399,13 +390,14 @@
*dp++ = '\n';
*dp = '\0';
}
- put_entry(e);
- }
#endif
-
+ put_entry(e);
+ }
elen = strlen(page) - off;
if (elen < 0)
elen = 0;
+ if (elen > count)
+ elen = count;
*eof = (elen <= count) ? 1 : 0;
*start = page + off;
err = elen;
\
 
 \ /
  Last update: 2005-03-22 13:08    [W:0.093 / U:1.344 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site