Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755880AbbLGLQO (ORCPT ); Mon, 7 Dec 2015 06:16:14 -0500 Received: from smtp-out4.electric.net ([192.162.216.194]:57172 "EHLO smtp-out4.electric.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755047AbbLGLQM (ORCPT ); Mon, 7 Dec 2015 06:16:12 -0500 From: David Laight To: "'Dmitry Vyukov'" , David Miller CC: Alexei Starovoitov , Alexei Starovoitov , netdev , LKML , syzkaller , Kostya Serebryany , Alexander Potapenko , Sasha Levin , Eric Dumazet , Andrey Ryabinin Subject: RE: bpf: undefined shift in __bpf_prog_run Thread-Topic: bpf: undefined shift in __bpf_prog_run Thread-Index: AQHRLoUtXAbIH0S2GEmGe/S1V/zuzJ67KlKAgAAFpYCAAAHOgIAABKSAgAAGLICABCScgA== Date: Mon, 7 Dec 2015 11:14:22 +0000 Message-ID: <063D6719AE5E284EB5DD2968C1650D6D1CBE6492@AcuExch.aculab.com> References: <20151204184333.GA42737@ast-mbp.thefacebook.com> <20151204191013.GB45508@ast-mbp.thefacebook.com> <20151204.142651.968075964630586979.davem@davemloft.net> In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.99.200] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-Outbound-IP: 213.249.233.130 X-Env-From: David.Laight@ACULAB.COM X-PolicySMART: 3396946, 3397078 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id tB7BGJqE003428 Content-Length: 1088 Lines: 26 From: Dmitry Vyukov > Sent: 04 December 2015 19:49 ... > 3.4.3 > undefined behavior > 1 behavior, upon use of a nonportable or erroneous program construct > or of erroneous data, for which this International Standard imposes no > requirements > 2 NOTE Possible undefined behavior ranges from ignoring the situation > completely with unpredictable results, to behaving during translation > or program execution in a documented manner characteristic of the > environment (with or without the issuance of a diagnostic message), to > terminating a translation or execution While 'undefined behaviour' is allowed to include 'firing an ICBM at the current location of the person who wrote the code' it is very unlikely to result in anything other than an unexpected value and the compiler making false assumptions about the value. eg the compiler can assume this is an infinite loop: int i; for (i = 0; i >= 0; i++) ... David ????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?