spinlocks and copy_to_user()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I have a question about spinlocks and copy_to_user():
copy_to_user() can sleep
so it should not be called when a spin_lock is held.

However, I have data (a structure, not atomic variable) which can be
changed in interrupt context
in my module;  so this data is protected by spinlocks.

I use ioctl to pass this data to user space; this ioctl() calls
copy_to_user(); when I call spin_lock_bh()
before cp[y_to_user() in this ioctl , I get:

"kernel: BUG: sleeping function called from invalid
context at include/linux/kernel.h:155".

How should I call copy_to_user() so that it won't pass wrong data to
user space ? If I remove the
spin_lock_bh() before the call to copy_to_user()  , I have a chance to
copy wrong data (to copy data while it is changing in my module ).

Regards,
Mark

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux