Received: by 10.223.164.197 with SMTP id h5csp415987wrb; Sat, 4 Nov 2017 14:11:57 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TqNE93hAOEjakUVzYNemRNuZwW4tASneV3vS3bAANAoAv0tdwpPZegzbNMZFGRuigXo3or X-Received: by 10.99.67.195 with SMTP id q186mr10675126pga.186.1509829917748; Sat, 04 Nov 2017 14:11:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509829917; cv=none; d=google.com; s=arc-20160816; b=Ov/L/qTgMHjarH08UJRvb25Y9NTRSy1sa99U6WPUZFREru7SDNP1eSm1rN9eq//0sA 1+DfBiEHRE3amp+uNe4yoQS9RMRRDBAG5Z0u9wQjUuT6szmi4rJ7PMW40tXFwow5jzMQ Px2aNlX+Rd2Hg9edFV1In6pu2rY2HkiazyJTIPPD8KbGwHrjWUdCEHRLSj8xgLn/Uc+z JTX0IIyq4Td4OamCGBhFM7eNlv8HR3du4nHyrEBqt36EmLudW22FHyG46AL+b8FLtQmw kcUccpO7jSlJ+UBMuqpstokxzhk8hWbQMud9jeNqLdGe28+88/HsdCaghYuXOkTKzwoV pOiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:dkim-signature:dkim-signature:arc-authentication-results; bh=QPZe2kYd+KwRvsnJvv93rbXi00Fi/uUctc3/NdAIfH0=; b=hxKxI2li/hOBPDmqcJz7yRVQR6a+4MMuaX27lwct4OJ2BzJsN46kdY16lDab9/fBYL cgiNOn/yu4WrMs+8X1BBWlwMCZW8L/R4YozZOoEbeRa0m4dhJQy17+/Ox9AtUDMH7OSN hgVpMQ+xr3fHpz65N8Sp33XH9ctaGH9YA+WwBJ4+697wzSYsszXoVXHZdz5B5EvE2Xt9 ARuEbFDiLNPjY+5VP2eggtzMVnM9As4S4kX+ijs35xwiaPxJbFIOMmttFWF79Amqbb4I dZbOWEXIQSyvvc3gC3X06aMjwL91OVt+SDzm//V/wT9DkKfY2PZlChq+cPVIkz1IyR6p O9Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=CXyyZZrM; dkim=fail header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=JSXjBCQ1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w12si8001321plp.721.2017.11.04.14.11.44; Sat, 04 Nov 2017 14:11:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=CXyyZZrM; dkim=fail header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=JSXjBCQ1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752451AbdKDVLE (ORCPT + 94 others); Sat, 4 Nov 2017 17:11:04 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:51252 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751534AbdKDVLC (ORCPT ); Sat, 4 Nov 2017 17:11:02 -0400 Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.16.0.21/8.16.0.21) with SMTP id vA4L90DQ013530; Sat, 4 Nov 2017 14:10:39 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=subject : to : references : cc : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=facebook; bh=QPZe2kYd+KwRvsnJvv93rbXi00Fi/uUctc3/NdAIfH0=; b=CXyyZZrMvy64rO9JqHKTtIIoXXjXpewfjnmeqtiCrABuJdNPkLKCtcaprXpYJ8RSmkUU d8RQV4mMy9iNmGwLT/H+w5bGLbcOgFLQ91aBiRUbFY/j7S+GD+dCad09j0KDiXpMuv1y Xg0PqpIWue0yCgwkC9FtMuMUGoVZuNxqMJU= Received: from mail.thefacebook.com ([199.201.64.23]) by m0089730.ppops.net with ESMTP id 2e191tscu1-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Sat, 04 Nov 2017 14:10:39 -0700 Received: from NAM01-SN1-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.14) with Microsoft SMTP Server (TLS) id 14.3.361.1; Sat, 4 Nov 2017 14:10:37 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=QPZe2kYd+KwRvsnJvv93rbXi00Fi/uUctc3/NdAIfH0=; b=JSXjBCQ1powuNBWaPMHPX+7H/IJHrTAsNwoFjPw2bUm00ajMeyfelaa4EdBgdp8z51wssA8p5/qf9JSLzdSoev/dOQuWm0B7gJE+loa+se3RaKWeyFTMzMqkvZgnCHTr37yyKyKVhARSww93tSYDCrYWvuBvbX9RAkG554Z2i3M= Received: from [IPv6:2620:10d:c0e1:1110::1004] (2620:10d:c094:180::1:11c0) by BL2PR15MB0961.namprd15.prod.outlook.com (2603:10b6:201:15::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.197.13; Sat, 4 Nov 2017 21:10:28 +0000 Subject: Re: [RFC PATCH] bpf: Add helpers to read useful task_struct members To: "Naveen N. Rao" , , Sandipan Das References: <20171103065833.8076-1-sandipan@linux.vnet.ibm.com> <94a4761f-1b51-8b70-fb7f-3cea91c69717@fb.com> <1509815348.8zu63uatdo.naveen@linux.ibm.com> CC: , Martin KaFai Lau , , Kees Cook , Brendan Gregg From: Alexei Starovoitov Message-ID: <4acdc081-341d-ee91-a591-b1d331a8c8d5@fb.com> Date: Sun, 5 Nov 2017 06:10:13 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1509815348.8zu63uatdo.naveen@linux.ibm.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [2620:10d:c094:180::1:11c0] X-ClientProxiedBy: HK2PR02CA0180.apcprd02.prod.outlook.com (2603:1096:201:21::16) To BL2PR15MB0961.namprd15.prod.outlook.com (2603:10b6:201:15::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fcdafb7c-4cfb-4b42-133f-08d523c87c1d X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603249);SRVR:BL2PR15MB0961; X-Microsoft-Exchange-Diagnostics: 1;BL2PR15MB0961;3:0HAD8eSKsvrt/PVBLxDzJz+4A23VY9Rw5dTjjSKoh3RsKlzP4zjtdX42S1PaWXYYR13gPi7urFHwQMxo0i1tGSXhqZvhew06Rz9t3NlxAvL019kxu8jbPafQRkxpM4TLMUXKxsDYf4/zAuWFvTGEYhnkHdv2WlbzBhlCJeTXsg+Bw1ter3OM8v7EosplzHCkNDysygKJrJT4i0NEjDAgR8CIctpr1oN2QqQXs4m8zEgQKLygG/dojVXDNvZJGYPY;25:+uSj3c01fp/1TPStHdNE+6IVkarRiT1XMWGkyke4KFG98MlLnNnvjVBCsjq+pcI4g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3t33HVRCAek9emXXYJXgbBT/8s4f0OVgPFILYFYpR;4:bDTzbcWs+ZiwWO8sP6co1C31SuAGtebY7WC8+uFk4gKJ9Px7PHqRhvYhGnj/+Mdo4GY04sLxtiaG4CH9J6tPmm+Gpmm+JXM/8/GiyCIl0Ql/S1vQ/m6RrM0frvppSvD7fToGdGw+i/kSAVOqjc3uOdMfU1I4agBbXcCPzE/ZG6ffWWRb+r09+SZxD7SNlCv0ODqKAKM91g84/ZgSgRuN8X45QCsbPEdVLLQQXAl2X54BNWeq1CJB4OlrqIvKbh3rCGTW0zZrKN5W1eXEPqYvmXJPVQfTG3ifX81C+gGVUpS01FCnLopCYFSeKF15wI3rOt2qaxa9kGhpMNJzn35k8Kmsna8L4SkVAHKT/Hxj2zmnxvsvPvL80oBnltQ1q70dOwsn3un2ZR+Nh6ql4y/WW1LCwZjuzmxQTZLYlM6brKQ= X-Exchange-Antispam-Report-Test: UriScan:(190756311086443)(192374486261705)(104084551191319)(17755550239193); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(11241501159)(6040450)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(3231021)(10201501046)(3002001)(6041248)(20161123564025)(20161123560025)(20161123555025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BL2PR15MB0961;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BL2PR15MB0961; X-Forefront-PRVS: 048111149A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(376002)(346002)(24454002)(189002)(11905935001)(199003)(7736002)(6306002)(39060400002)(53546010)(189998001)(33646002)(106356001)(31686004)(105586002)(76176999)(53936002)(305945005)(97736004)(54356999)(50986999)(6486002)(36756003)(110136005)(229853002)(101416001)(316002)(6116002)(4326008)(2906002)(1706002)(6246003)(25786009)(54906003)(58126008)(966005)(68736007)(230700001)(64126003)(8936002)(23676003)(8676002)(81166006)(81156014)(478600001)(67846002)(31696002)(50466002)(5660300001)(65826007)(65956001)(86362001)(65806001)(47776003)(6666003)(2950100002)(83506002)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:BL2PR15MB0961;H:[IPv6:2620:10d:c0e1:1110::1004];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTDJQUjE1TUIwOTYxOzIzOk1NR3ZGMEtGNzNhQk1kWG5ITk5nSHVIRHhj?= =?utf-8?B?bmpNVmkzU3p5dG4vYTVSZ3poRTVuWHk0dmJWMnJmTC8xdGZIN2N1ZWVhWm82?= =?utf-8?B?UFo4WUQxMU9mVW1BZlZrTWMzQkN3VjZRcXVKcTlJOG5MaDE5dmwzOUFwVXdH?= =?utf-8?B?TlhUbFptY3ZSN0h4dHArTXI4S2ZSR0ZFRVNlSEJoZG5ZZE4xNGRRWE0wSWNu?= =?utf-8?B?aDJIYWxEUXhMc1N5Yk1vcEFqblpVR1VlaEZzOFIxTThETTRZNk0rZE9RdnpN?= =?utf-8?B?NEgyUDB4SHN4R3labVRqSmxvNkNndmpKVFhvT2k2aTRNS1JGYkdaWUdLVGh5?= =?utf-8?B?emJpd3RoZXhEMGxZVTlGMkswdzBzVWdiM1VPenMxZUtoUVJ0U1ArK3FXMzBQ?= =?utf-8?B?aFpwR0dta25KZFM4SzFFOFJyaUxUbDRCWkd1Mjlnck8zMy9jRmJ6STdIaXZx?= =?utf-8?B?N1JTZ2lCWUEvbmd0emlnZytlajVPMkhGdDlMVUZFRzRaWXdxaVFMOVBjT0Z0?= =?utf-8?B?RXVEVWVleEVZZUJw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Zim8e1kUnZaRBHlZWSbXfcKg=;24:ZZn2CZ343D2MREsJZNzgeAN97KVzB2bLHx4+LtirUrCDbLwpS8ntCOxI+rYWgCZYpPJqLWnQCeq21h09s8OJc26NOV9KsMeMlOKLU8KjGfo=;7:SQuMhs6EX/Z4eUqeCvnsBCgTWcNl6UKA0vxj1xTqk1p3xVyJ/Sk3yoTTwJMmmnzwnVvDBoEr3ctJl1DRvYFEkeTKzYk6e7xDQRTLmkLbR6eo/O2KGkRni/poIPqzG+URIHpn69bjMmFxvzWxjNuJemmT8BRzOQ73deogKtsfbaoVbmuWypcUorTvlNz3qJSoUD0znSA3YOkgL76VMOCvgrIQ8a6zQTnYfmFeqo7IYtW3EsV3l6Ko47jICSE8hDA0 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BL2PR15MB0961;20:/jQMmctN5kYVLs8Z/KwH6Arepnu48U5kFoFqbmKPUWszU365dHJeC7xlF9xfweXjgQ13Yh4f3Jr4NJTixqyt6wTsoGUv3p4vPkigxVQ9s2lWz8qjIvvYHQHGHo+LB332JwX2MaGPPQDP4otJMzeqKNebmxmbsMJkoaSzTd0HDBY= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2017 21:10:28.9566 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fcdafb7c-4cfb-4b42-133f-08d523c87c1d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR15MB0961 X-OriginatorOrg: fb.com X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-11-04_08:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/5/17 2:31 AM, Naveen N. Rao wrote: > Hi Alexei, > > Alexei Starovoitov wrote: >> On 11/3/17 3:58 PM, Sandipan Das wrote: >>> For added security, the layout of some structures can be >>> randomized by enabling CONFIG_GCC_PLUGIN_RANDSTRUCT. One >>> such structure is task_struct. To build BPF programs, we >>> use Clang which does not support this feature. So, if we >>> attempt to read a field of a structure with a randomized >>> layout within a BPF program, we do not get the expected >>> value because of incorrect offsets. To observe this, it >>> is not mandatory to have CONFIG_GCC_PLUGIN_RANDSTRUCT >>> enabled because the structure annotations/members added >>> for this purpose are enough to cause this. So, all kernel >>> builds are affected. >>> >>> For example, considering samples/bpf/offwaketime_kern.c, >>> if we try to print the values of pid and comm inside the >>> task_struct passed to waker() by adding the following >>> lines of code at the appropriate place >>> >>> char fmt[] = "waker(): p->pid = %u, p->comm = %s\n"; >>> bpf_trace_printk(fmt, sizeof(fmt), _(p->pid), _(p->comm)); >>> >>> it is seen that upon rebuilding and running this sample >>> followed by inspecting /sys/kernel/debug/tracing/trace, >>> the output looks like the following >>> >>> _-----=> irqs-off >>> / _----=> need-resched >>> | / _---=> hardirq/softirq >>> || / _--=> preempt-depth >>> ||| / delay >>> TASK-PID CPU# |||| TIMESTAMP FUNCTION >>> | | | |||| | | >>> -0 [007] d.s. 1883.443594: 0x00000001: waker(): >>> p->pid = 0, p->comm = >>> -0 [018] d.s. 1883.453588: 0x00000001: waker(): >>> p->pid = 0, p->comm = >>> -0 [007] d.s. 1883.463584: 0x00000001: waker(): >>> p->pid = 0, p->comm = >>> -0 [009] d.s. 1883.483586: 0x00000001: waker(): >>> p->pid = 0, p->comm = >>> -0 [005] d.s. 1883.493583: 0x00000001: waker(): >>> p->pid = 0, p->comm = >>> -0 [009] d.s. 1883.503583: 0x00000001: waker(): >>> p->pid = 0, p->comm = >>> -0 [018] d.s. 1883.513578: 0x00000001: waker(): >>> p->pid = 0, p->comm = >>> systemd-journal-3140 [003] d... 1883.627660: 0x00000001: waker(): >>> p->pid = 0, p->comm = >>> systemd-journal-3140 [003] d... 1883.627704: 0x00000001: waker(): >>> p->pid = 0, p->comm = >>> systemd-journal-3140 [003] d... 1883.627723: 0x00000001: waker(): >>> p->pid = 0, p->comm = >>> >>> To avoid this, we add new BPF helpers that read the >>> correct values for some of the important task_struct >>> members such as pid, tgid, comm and flags which are >>> extensively used in BPF-based analysis tools such as >>> bcc. Since these helpers are built with GCC, they use >>> the correct offsets when referencing a member. >>> >>> Signed-off-by: Sandipan Das >> ... >>> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h >>> index f90860d1f897..324508d27bd2 100644 >>> --- a/include/uapi/linux/bpf.h >>> +++ b/include/uapi/linux/bpf.h >>> @@ -338,6 +338,16 @@ union bpf_attr { >>> * @skb: pointer to skb >>> * Return: classid if != 0 >>> * >>> + * u64 bpf_get_task_pid_tgid(struct task_struct *task) >>> + * Return: task->tgid << 32 | task->pid >>> + * >>> + * int bpf_get_task_comm(struct task_struct *task) >>> + * Stores task->comm into buf >>> + * Return: 0 on success or negative error >>> + * >>> + * u32 bpf_get_task_flags(struct task_struct *task) >>> + * Return: task->flags >>> + * >> >> I don't think it's a solution. >> Tracing scripts read other fields too. >> Making it work for these 3 fields is a drop in a bucket. > > Indeed. However... > >> If randomization is used I think we have to accept >> that existing bpf scripts won't be usable. > > ... the actual issue is that randomization isn't necessary for this to > show up. The annotations added to mark off the structure members results > in some structure members being moved into an anonymous structure, which > would then get padded differently. So, *all* kernels since v4.13 are > affected, afaict. hmm. why would all 4.13+ be affected? It's just an anonymous struct inside task_struct. Are you saying that due to clang not adding this 'struct { };' treatment to task_struct? 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. > As such, we wanted to propose this as a short term solution, but I do > agree that this doesn't solve the real issue. > >> Long term solution is to support 'BPF Type Format' or BTF >> (which is old C-Type Format) for kernel data structures, >> so bcc scripts wouldn't need to use kernel headers and clang. >> The proper offsets will be described in BTF. >> We were planning to use it initially to describe map key/value, >> but it applies for this case as well. >> There will be a tool that will take dwarf from vmlinux and >> compress it into BTF. Kernel will also be able to verify >> that BTF is a valid BTF. > > This is the first that I've heard about BTF. Can you share more details > about it, or point me to some place where it has been discussed? > > We considered having tools derive the structure offsets from debuginfo, > but debuginfo may not always be present on production systems. So, it > isn't clear if having that dependency is fine. I'm not sure how BTF will > be different. It was discussed at this year plumbers: https://lwn.net/Articles/734453/ btw the name BTF is work in progress. We started with CTF, but it conflicts with all other meanings of this abbreviation. Likely we will call it something different at the end. Initial goal was to describe key/map values of bpf maps to make debugging easier, but now we want to use this compressed type format for tracing as well, since installing kernel headers everywhere doesn't scale well while CTF can be embedded in vmlinux We were also thinking to improve verifier with CTF knowledge too. Like if CTF describes that map value is two u32, but bpf program is doing 8-byte access then something is wrong and either warn or reject such program. From 1583157594813042620@xxx Sat Nov 04 17:32:16 +0000 2017 X-GM-THRID: 1583027203607239623 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread