From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933386AbdKGIho convert rfc822-to-8bit (ORCPT ); Tue, 7 Nov 2017 03:37:44 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:49366 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754391AbdKGIhm (ORCPT ); Tue, 7 Nov 2017 03:37:42 -0500 Date: Tue, 07 Nov 2017 14:07:34 +0530 From: "Naveen N. Rao" Subject: Re: [RFC PATCH] bpf: Add helpers to read useful task_struct members To: Alexei Starovoitov , netdev@vger.kernel.org, Sandipan Das Cc: Brendan Gregg , daniel@iogearbox.net, Martin KaFai Lau , Kees Cook , linux-kernel@vger.kernel.org References: <20171103065833.8076-1-sandipan@linux.vnet.ibm.com> <94a4761f-1b51-8b70-fb7f-3cea91c69717@fb.com> <1509815348.8zu63uatdo.naveen@linux.ibm.com> <4acdc081-341d-ee91-a591-b1d331a8c8d5@fb.com> <1509982000.092la4257a.naveen@linux.ibm.com> In-Reply-To: User-Agent: astroid/0.10.2 (https://github.com/astroidmail/astroid) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8BIT X-TM-AS-GCONF: 00 x-cbid: 17110708-0008-0000-0000-000004A866E3 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17110708-0009-0000-0000-00001E3AFD62 Message-Id: <1510042830.62prnydrlw.naveen@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-11-07_03:,, 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-1711070122 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Alexei Starovoitov wrote: > On 11/7/17 12:55 AM, Naveen N. Rao wrote: >>> I thought such struct shouldn't change layout. >>> If it is we need to fix include/linux/compiler-clang.h to do that >>> anon struct as well. >> >> We considered that, but it looked to be very dependent on the version of >> gcc used to build the kernel. But, this may be a simpler approach for >> the shorter term. >> > > why it would depend on version of gcc? >>From what I can see, randomized_struct_fields_start is defined only for gcc >= 4.6. For older versions, it does not get mapped to an anonymous structure. We may not care for older gcc versions, but.. The other issue was that __randomize_layout maps to __designated_init when randstruct plugin is not enabled, which is in turn an attribute on gcc >= v5.1, but not otherwise. > We just need this, no? > > diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h > index de179993e039..4e29ab6187cb 100644 > --- a/include/linux/compiler-clang.h > +++ b/include/linux/compiler-clang.h > @@ -15,3 +15,6 @@ > * with any version that can compile the kernel > */ > #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), > __COUNTER__) > + > +#define randomized_struct_fields_start struct { > +#define randomized_struct_fields_end }; > > since offsets are mandated by C standard. Yes, this is what we're testing with and is probably sufficient for our purposes. - Naveen