WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH] Export Multicore information

To: "Kamble, Nitin A" <nitin.a.kamble@xxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] Export Multicore information
From: Emmanuel Ackaouy <ack@xxxxxxxxxxxxx>
Date: Wed, 13 Dec 2006 12:01:07 +0000
Cc: "Yu, Wilfred" <wilfred.yu@xxxxxxxxx>, Ian Pratt <m+Ian.Pratt@xxxxxxxxxxxx>, Xen devel list <xen-devel@xxxxxxxxxxxxxxxxxxx>, "Nakajima, Jun" <jun.nakajima@xxxxxxxxx>, "Mallick, Asit K" <asit.k.mallick@xxxxxxxxx>, "Yang, Fred" <fred.yang@xxxxxxxxx>, Keir Fraser <keir@xxxxxxxxxxxxx>
Delivery-date: Wed, 13 Dec 2006 04:01:05 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <5461330FA59EDB46BE9AB8AAF2C431AD028B487F@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Mail-followup-to: "Kamble, Nitin A" <nitin.a.kamble@xxxxxxxxx>, Keir Fraser <keir@xxxxxxxxxxxxx>, Ian Pratt <m+Ian.Pratt@xxxxxxxxxxxx>, "Mallick, Asit K" <asit.k.mallick@xxxxxxxxx>, "Yu, Wilfred" <wilfred.yu@xxxxxxxxx>, Xen devel list <xen-devel@xxxxxxxxxxxxxxxxxxx>, "Yang, Fred" <fred.yang@xxxxxxxxx>, "Nakajima, Jun" <jun.nakajima@xxxxxxxxx>
References: <5461330FA59EDB46BE9AB8AAF2C431AD028B487F@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.4.1i
On Tue, Dec 12, 2006 at 03:39:22PM -0800, Kamble, Nitin A wrote:
> I think I should have added some documentation comments in the code
> there mentioning the usage of count. It would make more sense if you
> look at the code which is calling this interface in the xc.c. There are
> 2 conventions for calling this sysctl function.
> 
> 1. With count = 0, and the array_list = NULL
> 
> 2. Here user space allocates the space for array_list of count size, and
> passes it to the sysctl.

(2) is the case I'm talking about.

>From your patch in sysctl.c:

+        count = min((int)pi->count, num_possible_cpus());

    ^^^^^^^^^^ You grab "count" correctly.

+
+        if ( guest_handle_is_null(pi->cpuinfo_list) ) {
+            printk("sysctl XEN_SYSCTL_cpuinfo: guest handle is null \n");
+            ret = -EFAULT;
+            break;
+        }
+
+        j = 0;
+        for_each_cpu(i) {
+            extern int cpu_2_node[];
+
+            cl.cpu_id = i;
+            cl.core_id = cpu_core_id[i];
+            cl.package_id = phys_proc_id[i];
+            cl.node_id = cpu_2_node[i];
+            cl.thread_siblings_map = cpus_addr(cpu_sibling_map[i])[0];
+            cl.core_siblings_map = cpus_addr(cpu_core_map[i])[0];
+
+            if ( copy_to_guest_offset(pi->cpuinfo_list, j, &cl, 1) ) {
+                printk("sysctl XEN_SYSCTL_cpuinfo: copy to guest (cpuinfo_list)
 failed \n");
+                ret -EFAULT;
+                break;
+            }
+            j++;

        ^^^^^^^^^^^ We never check that 'j' goes >= 'count'.

+        }


As a matter of fact, it looks to me like 'count' is a dead
variable as soon as it's set?

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel