All of lore.kernel.org
 help / color / mirror / Atom feed
* SYSLOG_ACTION_READ_ALL question
@ 2011-08-04 22:40 William Douglas
  0 siblings, 0 replies; 5+ messages in thread
From: William Douglas @ 2011-08-04 22:40 UTC (permalink / raw)
  To: kernelnewbies

Hello all,

I'm trying to figure out why the do_syslog code in kernel/printk.c is using put_user instead of copy_to_user.

There is even a comment about how because of sleep, the buffer is read from back to front to minimize the impact of printk overwriting the syslog section we are using.  That wouldn't be necessary if a temporary copy was made and then written out with copy_to_user.

Does that make sense or am I missing something?


Thanks,
William

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

* SYSLOG_ACTION_READ_ALL question
  2011-08-11 20:22 william douglas
  2011-08-11 20:50 ` Jeff Haran
@ 2011-08-12  1:40 ` Mulyadi Santosa
  1 sibling, 0 replies; 5+ messages in thread
From: Mulyadi Santosa @ 2011-08-12  1:40 UTC (permalink / raw)
  To: kernelnewbies

On Fri, Aug 12, 2011 at 03:22, william douglas
<william.r.douglas@gmail.com> wrote:
> Hello all,
>
> I'm trying to figure out why the do_syslog code in kernel/printk.c is
> using put_user instead of copy_to_user.
>
> There is even a comment about how because of sleep, the buffer is read
> from back to front to minimize the impact of printk overwriting the
> syslog section we are using. ?That wouldn't be necessary if a
> temporary copy was made and then written out with copy_to_user.
>
> Does that make sense or am I missing something?

looking at lxr.linux.no, right now I got impression that put_user is
somewhat a wrapper for copy_to_user. What I quickly check is that
put_user employ checking like might_sleep() and might_fault()...might
be handy in certain situation IMHO

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

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

* SYSLOG_ACTION_READ_ALL question
  2011-08-11 20:50 ` Jeff Haran
@ 2011-08-11 21:31   ` william douglas
  0 siblings, 0 replies; 5+ messages in thread
From: william douglas @ 2011-08-11 21:31 UTC (permalink / raw)
  To: kernelnewbies

On Thu, Aug 11, 2011 at 1:50 PM, Jeff Haran <jharan@bytemobile.com> wrote:
>> -----Original Message-----
>> From: kernelnewbies-bounces at kernelnewbies.org [mailto:kernelnewbies-
>> bounces at kernelnewbies.org] On Behalf Of william douglas
>> Sent: Thursday, August 11, 2011 1:23 PM
>> To: kernelnewbies at kernelnewbies.org
>> Subject: SYSLOG_ACTION_READ_ALL question
>>
>> Hello all,
>>
>> I'm trying to figure out why the do_syslog code in kernel/printk.c is
>> using put_user instead of copy_to_user.
>>
>
> I *THINK* this has something to do with copy_to_user not being
> well-behaved in other than process context and since printk() gets
> called in all contexts, it wouldn't be a safe operation.
> But don't take my word for it.
>
>

Well from what I understand, copy_to_user doesn't work in interrupt
context for example as there is no user space necessarily to copy to.
In this case we have a __user buffer to copy back to and
__copy_to_user looks sane for the work load so I'm still unsure.

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

* SYSLOG_ACTION_READ_ALL question
  2011-08-11 20:22 william douglas
@ 2011-08-11 20:50 ` Jeff Haran
  2011-08-11 21:31   ` william douglas
  2011-08-12  1:40 ` Mulyadi Santosa
  1 sibling, 1 reply; 5+ messages in thread
From: Jeff Haran @ 2011-08-11 20:50 UTC (permalink / raw)
  To: kernelnewbies

> -----Original Message-----
> From: kernelnewbies-bounces at kernelnewbies.org [mailto:kernelnewbies-
> bounces at kernelnewbies.org] On Behalf Of william douglas
> Sent: Thursday, August 11, 2011 1:23 PM
> To: kernelnewbies at kernelnewbies.org
> Subject: SYSLOG_ACTION_READ_ALL question
> 
> Hello all,
> 
> I'm trying to figure out why the do_syslog code in kernel/printk.c is
> using put_user instead of copy_to_user.
> 

I *THINK* this has something to do with copy_to_user not being
well-behaved in other than process context and since printk() gets
called in all contexts, it wouldn't be a safe operation.
But don't take my word for it.

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

* SYSLOG_ACTION_READ_ALL question
@ 2011-08-11 20:22 william douglas
  2011-08-11 20:50 ` Jeff Haran
  2011-08-12  1:40 ` Mulyadi Santosa
  0 siblings, 2 replies; 5+ messages in thread
From: william douglas @ 2011-08-11 20:22 UTC (permalink / raw)
  To: kernelnewbies

Hello all,

I'm trying to figure out why the do_syslog code in kernel/printk.c is
using put_user instead of copy_to_user.

There is even a comment about how because of sleep, the buffer is read
from back to front to minimize the impact of printk overwriting the
syslog section we are using.  That wouldn't be necessary if a
temporary copy was made and then written out with copy_to_user.

Does that make sense or am I missing something?


Thanks,
William

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

end of thread, other threads:[~2011-08-12  1:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-04 22:40 SYSLOG_ACTION_READ_ALL question William Douglas
2011-08-11 20:22 william douglas
2011-08-11 20:50 ` Jeff Haran
2011-08-11 21:31   ` william douglas
2011-08-12  1:40 ` Mulyadi Santosa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.