From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sandipan Das Subject: Re: [RFC PATCH] bpf: Add helpers to read useful task_struct members Date: Mon, 6 Nov 2017 10:46:46 +0530 Message-ID: References: <20171103065833.8076-1-sandipan@linux.vnet.ibm.com> <94a4761f-1b51-8b70-fb7f-3cea91c69717@fb.com> <1509815348.8zu63uatdo.naveen@linux.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: daniel@iogearbox.net, Martin KaFai Lau , linux-kernel@vger.kernel.org, Kees Cook , Brendan Gregg To: "Naveen N. Rao" , Alexei Starovoitov , netdev@vger.kernel.org Return-path: Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:59328 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750715AbdKFFQy (ORCPT ); Mon, 6 Nov 2017 00:16:54 -0500 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vA65EJYK105263 for ; Mon, 6 Nov 2017 00:16:53 -0500 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2e26wabenb-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 06 Nov 2017 00:16:53 -0500 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 6 Nov 2017 05:16:51 -0000 In-Reply-To: <1509815348.8zu63uatdo.naveen@linux.ibm.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: Hi Alexei, Naveen, On 11/04/2017 11:01 PM, Naveen N. Rao wrote: > > I think the offsets described in dwarf were incorrect with CONFIG_GCC_PLUGIN_RANDSTRUCT, but I'll let Sandipan confirm that. > I think that the offsets described in dwarf are probably incorrect when CONFIG_GCC_PLUGIN_RANDSTRUCT is enabled. To verify this, I used perf to attach a probe to try_to_wake_up() which is the also the function to which waker() is attached in the previously mentioned kernel sample. So, if the run the following: # perf probe "try_to_wake_up" "p->pid" # perf record -a -e probe:try_to_wake_up # perf script The value of p->pid is reported as 0. Similarly, if I try to read p->comm, it is reported to be an empty string. The same problem is seen with systemtap as well. Also, if I do a printk with offsetof(struct task_struct, pid) and offsetof(struct task_struct, comm) inside the kernel code and then compare the values with the offsets reported by pahole, they are completely different. - Sandipan