linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* LKM programming - problem with chars from user space (?)
@ 2004-08-08 21:06 authn
  2004-08-09  6:35 ` Thiago Rondon
  0 siblings, 1 reply; 3+ messages in thread
From: authn @ 2004-08-08 21:06 UTC (permalink / raw)
  To: linux-c-programming

Hello,
I am coding a linux kernel module and have problem with some string from user 
space (from execve system call). There is no problem with useing this string 
as a one, for example printk(KERN_ALERT "%s", string) works fine. 
Problem appears when i want to printk or compare single char, in first case it 
is printked with some extra '<1>' and in second case, when i compare it with 
other one, it doesnt fit to real char (it is "connected" with '<1>' in some 
way ?). I tried to copy it to kmalloced buffer:

if ((k_space=(char *)kmalloc(len, GFP_KERNEL))==NULL)
                        return -1;
memcpy_fromfs((void *)k_space, (void *)argv[argc], len); 

but then playing with k_space[i] was the same. Can anybody help me with this ?

Regards, 
apacz

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: LKM programming - problem with chars from user space (?)
  2004-08-08 21:06 LKM programming - problem with chars from user space (?) authn
@ 2004-08-09  6:35 ` Thiago Rondon
  2004-08-15 21:03   ` Jan Opacki
  0 siblings, 1 reply; 3+ messages in thread
From: Thiago Rondon @ 2004-08-09  6:35 UTC (permalink / raw)
  To: opacki; +Cc: linux-c-programming

Yeah, because you put KERN_ALERT as the first argument in the 
printk() function..

See this file, ~linux/include/linux/kernel.h

-Thiago Rondon

On Sun, 8 Aug 2004 23:06:15 +0200, authn <opacki@acn.waw.pl> wrote:
> Hello,
> I am coding a linux kernel module and have problem with some string from user
> space (from execve system call). There is no problem with useing this string
> as a one, for example printk(KERN_ALERT "%s", string) works fine.
> Problem appears when i want to printk or compare single char, in first case it
> is printked with some extra '<1>' and in second case, when i compare it with
> other one, it doesnt fit to real char (it is "connected" with '<1>' in some
> way ?). I tried to copy it to kmalloced buffer:
> 
> if ((k_space=(char *)kmalloc(len, GFP_KERNEL))==NULL)
>                         return -1;
> memcpy_fromfs((void *)k_space, (void *)argv[argc], len);
> 
> but then playing with k_space[i] was the same. Can anybody help me with this ?
> 
> Regards,
> apacz
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: LKM programming - problem with chars from user space (?)
  2004-08-09  6:35 ` Thiago Rondon
@ 2004-08-15 21:03   ` Jan Opacki
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Opacki @ 2004-08-15 21:03 UTC (permalink / raw)
  To: linux-c-programming

On Mon, 2004-08-09 at 08:35, Thiago Rondon wrote:
Ok, but im not talking only about printing it into log file, but also
with compareing chars.For example, when i have string like:
"somestring"
and i want to print it by one string (with %s") then i've got in log
file:
somestring
when i want to print it char by char (with %c):
<1>s<1>o<1>m<1>e (...and it goes)
But how i say it's not only problem with printing couse when i want to
compare for ex. third char from this string with static allocated char
then it's false also if chars are same! (this <1> is "connected" in some
way with char?)
So how to play with this char ? i want to compare'em.
Regards.
> Yeah, because you put KERN_ALERT as the first argument in the 
> printk() function..
> 
> See this file, ~linux/include/linux/kernel.h
> 
> -Thiago Rondon
> 
> On Sun, 8 Aug 2004 23:06:15 +0200, authn <opacki@acn.waw.pl> wrote:
> > Hello,
> > I am coding a linux kernel module and have problem with some string from user
> > space (from execve system call). There is no problem with useing this string
> > as a one, for example printk(KERN_ALERT "%s", string) works fine.
> > Problem appears when i want to printk or compare single char, in first case it
> > is printked with some extra '<1>' and in second case, when i compare it with
> > other one, it doesnt fit to real char (it is "connected" with '<1>' in some
> > way ?). I tried to copy it to kmalloced buffer:
> > 
> > if ((k_space=(char *)kmalloc(len, GFP_KERNEL))==NULL)
> >                         return -1;
> > memcpy_fromfs((void *)k_space, (void *)argv[argc], len);
> > 
> > but then playing with k_space[i] was the same. Can anybody help me with this ?
> > 
> > Regards,
> > apacz
> > -
> > To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-08-15 21:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-08 21:06 LKM programming - problem with chars from user space (?) authn
2004-08-09  6:35 ` Thiago Rondon
2004-08-15 21:03   ` Jan Opacki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).