Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3386743ybd; Tue, 25 Jun 2019 01:31:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqwlGeA5U5O27HoihSe96fspCfr58BkwRzrqUQngAsL1LPaS8eFlAzEcck6FEC/bMKQ3hQVC X-Received: by 2002:a17:90a:290b:: with SMTP id g11mr30487242pjd.122.1561451464560; Tue, 25 Jun 2019 01:31:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561451464; cv=none; d=google.com; s=arc-20160816; b=EXE6VY2t1T/pHo2i9DWpr8JtSmKgmi4Zuu00ZGmDt+44dTEBoWepN7Zxn+bNRkI58c PH2d3Jy7RuEdRmnfZxxZISe/9LlPKHPHjEoaxXHkuw+5c8gW1DfHaeC7cLMvzivaczfN p5i/d3oRG+GvjZWrEx0SlETnh32cCacbqsxPfJv85yQzrq+GfdYgC2pwaekt9CvdTLlX kfoWYtk6A0ubvpPPX87z3nyLBMnnkwTIofjx0/DFC6MBxQlbCOIBNZTrM6Sw/vp0I9bR tX4NGKaEb6UMxgKxzuQxCnEjaUTG2bTGX09RMicExz/LBFRn6xvYtnvDZHkeZN5+4UWg Debg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=sYnK457/kj4rRqWWeTXYNwEKMUmKlOYg/wzNhGH4qFM=; b=XGGdlE/oVZsfOBMjmm4uBRAHgoX055jZ8o1WPEE+yvZqi7/Cv5GrzSWFHk9pNo+Oru 5vOTsAmCmSmWA1lsbrRfhEZVmD8orbYl5UGfamJ2GkfD1gnQCwriyDXuVIXSNPvz2oJI 5SEcAAU9yH3U9lY0LU32SJj1MDLqKmixvn3r5m29kM/rWh1/k30kp8oMHLHW+yrcRUNX ykjOG0O9oXz0KU6r41Yf2R9QFVgeYvj+4mrN21uje+cM8mOckwng20s6qzD/HA2YiUdA dp6SXQdhU33mnJ/cbTEkvuKdk8NDeG+CLVZBmqZs6oFr050+hT3vLm1SWrjnKEBAZI+k L2HQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q1si11672751pgp.301.2019.06.25.01.30.48; Tue, 25 Jun 2019 01:31:04 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730466AbfFYI3n (ORCPT + 99 others); Tue, 25 Jun 2019 04:29:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44940 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726702AbfFYI3m (ORCPT ); Tue, 25 Jun 2019 04:29:42 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 636DD3082B6B; Tue, 25 Jun 2019 08:29:42 +0000 (UTC) Received: from astarta.redhat.com (ovpn-116-223.ams2.redhat.com [10.36.116.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5EEDF608C2; Tue, 25 Jun 2019 08:29:41 +0000 (UTC) From: Yauheni Kaliuta To: Daniel Borkmann Cc: linux-kernel@vger.kernel.org, Jiri Olsa , Jiri Benc Subject: bpf: test_verifier: sanitation: alu with different scalars Date: Tue, 25 Jun 2019 11:29:40 +0300 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 25 Jun 2019 08:29:42 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi! I'm wondering, how the sanitaion tests (#903 5.2-rc6 for example) are supposed to work on BE arches: { "sanitation: alu with different scalars 1", .insns = { BPF_MOV64_IMM(BPF_REG_0, 1), BPF_LD_MAP_FD(BPF_REG_ARG1, 0), BPF_MOV64_REG(BPF_REG_ARG2, BPF_REG_FP), BPF_ALU64_IMM(BPF_ADD, BPF_REG_ARG2, -16), BPF_ST_MEM(BPF_DW, BPF_REG_FP, -16, 0), BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem), BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1), BPF_EXIT_INSN(), BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0), reads one byte 0 on BE and 28 on LE (from ->index) since struct test_val { unsigned int index; int foo[MAX_ENTRIES]; }; struct test_val value = { .index = (6 + 1) * sizeof(int), .foo[6] = 0xabcdef12, }; BPF_JMP_IMM(BPF_JEQ, BPF_REG_1, 0, 3), So different branches are taken depending of the endianness. BPF_MOV64_IMM(BPF_REG_2, 0), BPF_MOV64_IMM(BPF_REG_3, 0x100000), BPF_JMP_A(2), BPF_MOV64_IMM(BPF_REG_2, 42), BPF_MOV64_IMM(BPF_REG_3, 0x100001), BPF_ALU64_REG(BPF_ADD, BPF_REG_2, BPF_REG_3), BPF_MOV64_REG(BPF_REG_0, BPF_REG_2), BPF_EXIT_INSN(), }, .fixup_map_array_48b = { 1 }, .result = ACCEPT, .retval = 0x100000, }, -- WBR, Yauheni Kaliuta