From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750992AbdKFFQ4 (ORCPT ); Mon, 6 Nov 2017 00:16:56 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:49558 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750728AbdKFFQy (ORCPT ); Mon, 6 Nov 2017 00:16:54 -0500 Subject: Re: [RFC PATCH] bpf: Add helpers to read useful task_struct members To: "Naveen N. Rao" , Alexei Starovoitov , netdev@vger.kernel.org Cc: daniel@iogearbox.net, Martin KaFai Lau , linux-kernel@vger.kernel.org, Kees Cook , Brendan Gregg References: <20171103065833.8076-1-sandipan@linux.vnet.ibm.com> <94a4761f-1b51-8b70-fb7f-3cea91c69717@fb.com> <1509815348.8zu63uatdo.naveen@linux.ibm.com> From: Sandipan Das Date: Mon, 6 Nov 2017 10:46:46 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <1509815348.8zu63uatdo.naveen@linux.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 17110605-0008-0000-0000-000004A7DE5E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17110605-0009-0000-0000-00001E3A6FEB Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-11-06_01:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1711060072 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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