lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <28aa038c8879b4cafcbaff669f603b19.squirrel@wm.schorsch-tech.de>
Date:	Wed, 15 Jun 2016 16:35:28 +0200
From:	georg@...orsch-tech.de
To:	linux-kernel@...r.kernel.org
Subject: sysfs_create_group(): Where to call?

Hi,

currently i write an driver module which offers some entries in the sysfs.
I read a lot through the driver source tree and the internet. I found two
approches where the sysfs_create_group() is called:

a) most commonly: In the probe() function of the Driver. Like adviced here
http://stackoverflow.com/questions/37237835/how-to-attach-file-operations-to-sysfs-attribute-in-platform-driver

Random Thing i looked at:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/rtc/rtc-ds1307.c#n1580

b) In the driver struct.
http://kroah.com/log/blog/2013/06/26/how-to-create-a-sysfs-file-correctly/

I know, Greg KH is a very well known developer. So i tried to follow his
advice. In the bla_show()/bla_store() functions i tried to get my Driver
private data, but my printk()'s showed much different addresses than i
printed in the probe() function. My private data is (null). Which is ofc 
wrong.

When i use approch a) it works as expected, but as Greg KH suggests it is
wrong too. I see it a lot in the stable tree in different Drivers. Greg
writes, the userspace already got the notification that there is a new
device, but the LDD3 book states, that the probe function is there to
determine if the device is present. So why get the userspace notified
about it, even when the kernel doesnt know if it can handle it?


LDD3: https://static.lwn.net/images/pdf/LDD3/ch14.pdf
PDF page 24
[Quote=LDD3 chapter 14]
probe is a function called to query the existence of a specific device
(and whether this driver can work with it), remove is called when the
device is removed from the system,and shutdown is called at shutdown time
to quiesce the device.
[/Quote]

I know, Greg KH is a very well known developer. So i tried to follow his
advice. In the bla_show()/bla_store() functions i tried to get my Driver
private data, but my printk()'s showed much different addresses than i
printed in the probe() function. My private data is (null). Which is ofc
wrong.

When i use approch a) it works as expected, but as Greg KH suggests it is
wrong too. I see it a lot in the stable tree in different drivers. Greg
writes, the userspace already got the notification that there is a new
device, but the LDD3 book states, that the probe function is there to
determine if the device is present.

To sum my question up:
1.Why get the userspace notified about it, even when the kernel doesnt
know if it can handle it?
2.Where is the right place to call sysfs_create_group()? Is it a) or b) ?


I am more confused than before .....

Best Regards
Georg

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ