Subject: loglevel.c & syscall()

From: Eli Carter <[email-masked]>
Date: Mon, 19 Jul 1999 08:36:38 -0500

Redhat Linux
StrongARM processor
kernel 2.2.10
initscripts 3.90-3
The command `loglevel' generates an -EINVAL from do_syslog() regardless
of
the level passed.  
According to loglevel.c, it is calling `syscall( SYS_syslog, 8, NULL,
level )', but according to do_syslog, it is receiving
do_syslog(type=9437287 buf=ï¡ len=0 ) regardless of the value of
`level'.  Every other program that calls do_syslog appears to work
correctly.  I've tried changing the loglevel.c code to call syslog(),
but it has the same results.  I also tried calling _syscall3(), but that
wouldn't even compile, 
...
loglevel.c: In function `main':
loglevel.c:25: parse error before `int'
loglevel.c:25: `__res' undeclared (first use in this function)
...
This is being cross-compiled on an x86 for the StrongARM processor.

Any suggestions on where to look, hunches, etc.?

Thank you for your time,

Eli
unsubscribe: body of `unsubscribe linux-arm' to [email-masked]

---

From: Philip Blundell <[email-masked]>
Date: Mon, 19 Jul 1999 14:59:11 +0100

>do_syslog(type=3D9437287 buf=3D=EF=A1 len=3D0 ) regardless of the value=
> of

This is probably the same bug in syscall() that Kyle Mestery reported last 
week (or whenever it was).  It is a kernel problem and the fix is pretty 
trivial; you should be able to find it in the archives for this mailing list.

Alternatively, glibc provides a wrapper for sys_syslog, as a function called 
"klogctl".  You may be able to use this instead or until you can get a fixed 
kernel.

p.

---

From: <[email-masked]>
Date: Mon, 19 Jul 1999 09:32:30 -0500 (CDT)

Hi,

> trivial; you should be able to find it in the archives for this mailing list.
Here is the code I am running (the patch Phil mentioned above) that
alleviated my problems with syscall():

SYMBOL_NAME(sys_syscall):
	eor     r6, r0, #OS_NUMBER << 20
	cmp     r6, #NR_syscalls	@ check range
	add     sp, sp, #4		@ take of the save of our r4
	ldmib   sp, {r0 - r4}		@ get our args
	str     r4, [sp, #-4]!          @ Put our arg on the stack
	ldrle   pc, [r5, r6, lsl #2]
	mov     r0, #-ENOSYS
	mov     pc, lr

This has worked for me.  Replace the beginning of sys_syscall() in
arch/arm/kernel/entry-common.S with what I have above, and it should
work.

--
Kyle Mestery			| StorageTek's Storage Networking Group
[email-masked]		| http://www.freebsd.org/
[email-masked]		| http://www.netwinder.org/
	Protect your right to privacy: www.freecrypto.org

---

From: Russell King - ARM Linux Admin <[email-masked]>
Date: Mon, 19 Jul 1999 16:12:20 +0100 (BST)

> arch/arm/kernel/entry-common.S with what I have above, and it should

No!  Don't add sp, sp, #4 - you'll end up corrupting the kernel stacks/
other pages!  Do it the way I said, and you'll have a more fruitful life!
   _____
  |_____| ------------------------------------------------- ---+---+-
  |   |        Russell King       [email-masked]      --- ---
  | | | |  http://www.arm.linux.org.uk/~rmk/armlinux.html    /  /  |
  | +-+-+                                                     --- -+-
  /   |               THE developer of ARM Linux              |+| /|\
 /  | | |                                                     ---  |
    +-+-+ -------------------------------------------------  /\\\  |
unsubscribe: body of `unsubscribe linux-arm' to [email-masked]

---

From: Eli Carter <[email-masked]>
Date: Mon, 19 Jul 1999 13:39:08 -0500

> alleviated my problems with syscall():
[snip]
> arch/arm/kernel/entry-common.S with what I have above, and it should

Hmmm...  I tried this change, however I'm getting garbage like:

^@^@^@©©^EN^U^[S^]/etc/rc.d/rc: /var/run/runlevel.dir: Read-only file
system
^@^@^@©©^EN^U^[S^]^@^@^@©©^EN^U^[S^]^@^@^@©©^EN^U^[S^]Bringing up
interface lo
^@^@^@©©^EN^U^[S^]^@^@^@©©^EN^U^[S^]^@^@^@©©^EN^U^[S^]modprobe: can't
locate module net-pf-6
modprobe: can't locate module net-pf-4
modprobe: can't locate module net-pf-5
^@^@^@©©^EN^U^[S^]modprobe: can't locate module net-pf-6
...etc.

I also tried the change as Russell gave last week, 
> The code around sys_syscall should read:
>        add     ip, sp, #4
>        ldmleib ip, {r0 - r4}

Which did not have such side effects, but the command `loglevel 1'
displays 
`syslog: Invalid argument', same as before.  As best as I can tell, the
command `/sbin/loglevel 1' calls (eventually, thru swi) do_syslog(type=2
buf=<NULL> len=1).  This seems to be an improvement, but it still isn't
working. :/  buf and len seem to be set correctly (loglevel 3 seems to
call do_syslog(type=2, buf=<NULL>, len=3) ), but type should be 8.

Thoughts, suggestions, comments?

(Incedentally, this also appears to break xntpd's setting of the date on
bootup, though I can't guarrantee that is related.  I'll try some checks
on this...)

Eli

---

From: Eli Carter <[email-masked]>
Date: Mon, 19 Jul 1999 14:27:12 -0500

> bootup, though I can't guarrantee that is related.  I'll try some checks

Well, these do seem to be related, though exactly how, I have no idea. 
My guess is that there's a domino effect going on.  *shrug*

In arch/arm/kernel/entry-common.S, there are special wrappers for a
number of other syscalls; is it possible that syslog needs one?

I do appreciate your help.

Thanks,

Eli

---

From: Philip Blundell <[email-masked]>
Date: Mon, 19 Jul 1999 21:06:06 +0100

>number of other syscalls; is it possible that syslog needs one?

No; the syscalls that have wrappers need them because of weirdo calling 
conventions.  Syslog is just a plain ol' system call.

What does strace show for the call that fails, and did you try using klogctl 
instead?

p.