On Wed, Jan 28, 2015 at 7:58 PM, Tuukka Tikkanen idlestat@tic0.net wrote:
Previously any directory entry in /sys/devices/system/cpu/ with the substring "cpu" within the name would be considered to be a subdirectory for a cpu. The substring should begin the name, not just appear within the name.
OK. Will apply.
But what directories do you see other than cpuX, cpuidle and cpufreq under /sys/devices/system/cpu/ ?
cpuidle and cpufreq are already filtered in the previous line. I'm curious what else are you guarding against?
Signed-off-by: Tuukka Tikkanen idlestat@tic0.net
topology.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/topology.c b/topology.c index ff0b6fb..c7528af 100644 --- a/topology.c +++ b/topology.c @@ -333,7 +333,7 @@ static struct cpu_topology *topo_folder_scan(char *path, folder_filter_t filter) if (filter && filter(direntp->d_name)) continue;
if (!strstr(direntp->d_name, "cpu"))
if (strncmp(direntp->d_name, "cpu", 3)) continue; ret = asprintf(&newpath, "%s/%s/%s", basedir,
-- 1.7.9.5
On Tue, 10 Mar 2015, Amit Kucheria wrote:
On Wed, Jan 28, 2015 at 7:58 PM, Tuukka Tikkanen idlestat@tic0.net wrote:
Previously any directory entry in /sys/devices/system/cpu/ with the substring "cpu" within the name would be considered to be a subdirectory for a cpu. The substring should begin the name, not just appear within the name.
OK. Will apply.
But what directories do you see other than cpuX, cpuidle and cpufreq under /sys/devices/system/cpu/ ?
All the patch does is changes the match from "^.*cpu.*$" to "^cpu.*$" (aka "cpu" to "^cpu") in terms of regular expressions. As all the (current) cpu entries have the "cpu" substring in the beginning of the name, it is the proper thing to do.
This is not really fixing any current realized problem as far as I know of. It was simply something I happened to come across while fixing the issue of hotplugged cpus. While it is still not bulletproof against arbitrary changes in future kernels, it is slightly more secure. The unpatched version would break if kernel introduced something like /sys/devices/system/cpu/online_cpus or /sys/devices/system/cpu/cpus_online while the patched version would break only on the latter.
Tuukka
cpuidle and cpufreq are already filtered in the previous line. I'm curious what else are you guarding against?
Signed-off-by: Tuukka Tikkanen idlestat@tic0.net
topology.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/topology.c b/topology.c index ff0b6fb..c7528af 100644 --- a/topology.c +++ b/topology.c @@ -333,7 +333,7 @@ static struct cpu_topology *topo_folder_scan(char *path, folder_filter_t filter) if (filter && filter(direntp->d_name)) continue;
if (!strstr(direntp->d_name, "cpu"))
if (strncmp(direntp->d_name, "cpu", 3)) continue; ret = asprintf(&newpath, "%s/%s/%s", basedir,
-- 1.7.9.5
On Tue, Mar 10, 2015 at 3:55 AM, Tuukka Tikkanen idlestat@tic0.net wrote:
On Tue, 10 Mar 2015, Amit Kucheria wrote:
On Wed, Jan 28, 2015 at 7:58 PM, Tuukka Tikkanen idlestat@tic0.net wrote:
Previously any directory entry in /sys/devices/system/cpu/ with the substring "cpu" within the name would be considered to be a subdirectory for a cpu. The substring should begin the name, not just appear within the name.
OK. Will apply.
But what directories do you see other than cpuX, cpuidle and cpufreq under /sys/devices/system/cpu/ ?
All the patch does is changes the match from "^.*cpu.*$" to "^cpu.*$" (aka "cpu" to "^cpu") in terms of regular expressions. As all the (current) cpu entries have the "cpu" substring in the beginning of the name, it is the proper thing to do.
This is not really fixing any current realized problem as far as I know of. It was simply something I happened to come across while fixing the issue of hotplugged cpus. While it is still not bulletproof against arbitrary changes in future kernels, it is slightly more secure. The unpatched version would break if kernel introduced something like /sys/devices/system/cpu/online_cpus or /sys/devices/system/cpu/cpus_online while the patched version would break only on the latter.
Fair enough. Applied it to a local tree. Trying to fix a bug in the comparison mode introduced by 7f365110 before I push out all the changes.