Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2228167ybd; Thu, 27 Jun 2019 08:51:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJfJ98Du/8ai18jE3QqEly70V39ztPOQnC8DNOqhGYjdAt7q8xA8UUtX+GQKAMoGdHBANU X-Received: by 2002:a17:902:f089:: with SMTP id go9mr5457583plb.81.1561650698718; Thu, 27 Jun 2019 08:51:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561650698; cv=none; d=google.com; s=arc-20160816; b=XbtGCS7hOWQ3o9OWZ3c9sfHWOBpfIYaK0g9eBwP61srzm4GAgvgjVrxXJIkkRR58h7 ncCt/F0y4vUs986CnWqxMaH3xGmKJFMQKcOfXFc0YK9WEQF7NNcSjfGyrF/KlY7UK/GA R/YmS4xy1ZIfALGgRKbjmV0+L4njI5h7vFKXgBqbw4u6TNS1kXbeF4z+wVSXGHW6Kyiq 1b10bo6ragTx/vBylMAY0y2WB4GvmAIY3erjHbqoX1Fl9aMc0C3c/kEcvgB2M9XVHRgf jvmT3rRy8YTKtr560rKzoEV6qJmWJiH3b0s2zKngWKirU671xfrRIs4PmptQNWRk9WCr YAvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=tMDVUbLTOCls0VIHnjsoh7DWeqSSrubUVJ0usmY9Ymg=; b=Hv8qWyQlC0m9KK0qXfly6ku5crUWfRyLT29+ciyiX5l1dVqHv7vopZF5sceK/Z02AZ 38JXjCnVOH1ViwzDYLuG/EoZ9RcgcAgG86aVrm6oHVWZFGugBKIU26gA/NJgifikIcuH J5Ys2Z5KHNJyTrqT/6LJXI7kmF+qDUMvAW2v8jOUNQOa0eiyzjfJ6e/zfKuRsS/+DVtY vwON/2lIwWWuKeBNrpEfBwLPTc6N7uRSyS/LoDrj6jsBr0CAu9wSX1PaN2UnNYk5ZiG2 MUjSdtoUIK6Vpl1OvFEl+wDOZ5c2Da5COO5DUxJe6IalrCuVHZ8ZOevOW8UOkiWQdb2W oyiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fomichev-me.20150623.gappssmtp.com header.s=20150623 header.b=WMEfiSZ3; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l13si5476879pjq.69.2019.06.27.08.51.22; Thu, 27 Jun 2019 08:51:38 -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=@fomichev-me.20150623.gappssmtp.com header.s=20150623 header.b=WMEfiSZ3; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726566AbfF0Puc (ORCPT + 99 others); Thu, 27 Jun 2019 11:50:32 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:36067 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726405AbfF0Puc (ORCPT ); Thu, 27 Jun 2019 11:50:32 -0400 Received: by mail-pl1-f195.google.com with SMTP id k8so1528762plt.3 for ; Thu, 27 Jun 2019 08:50:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fomichev-me.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=tMDVUbLTOCls0VIHnjsoh7DWeqSSrubUVJ0usmY9Ymg=; b=WMEfiSZ3TlXa+mXfYTEgWVlwNbrgesrqc3XR79vxkvHrCzhuWJgIuAIempAYwIwEza +JbFajU0wgwOxn61DReXpfWvf/9nm8EdoB+v2KwaYdQBWCk5VZCJGSRPJX3qYpVlXp+Y Mp8e7iPlgGpVEzsvWFScb8jg5Trk/+H7sHpMVd1zbEjPTWn4wEYuK6bV3J6PW5W392o2 WDqBlav0fct1ZocreCrRkhtbWnjmt1uXYnO30s0S7bKhPoxoKJ7PgDElmIwb9xxMMow9 vU8GdgiwMsawoOHQ1SBCVFiiNQNfc/1bqnNY5UkQ62MSgdwVLVS5jDzkzC3AfUkCZBom lanA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=tMDVUbLTOCls0VIHnjsoh7DWeqSSrubUVJ0usmY9Ymg=; b=LMXJeEeLZcy07gd1YCWKDj9+CzgfQwB0DXz6EOX5ILCyliLxKr3hd2quVBrpaOQ7sb DpbWJoO8ULYdJ0SkO2fWELoyAIrsmzYM1n8mKruiEp2L7kYYjXzw5vGCSU0d8yVqQxGS kvZNd7J8aTdo8DL7gKTKU30uf/QRiq33SjIfrw+kJDOJbxH1VTivftaJrXH29JioXKo5 yXuSPLPhxeZmyatAjyQDE/fZH3zvSRQCxSmX568/rMHmwE8ayKX070ykIgTOC+liSXwU 1iCN2XGnd8hLZQqPvGRiqX0bEMqJFsZULPyCeKn9daj10tH2ynRXHhKkrw+7wgtdUdFw HyRg== X-Gm-Message-State: APjAAAVFUjfZO7x4CUTaE0ekVQtNnxPpxfVNYqzsk4uhozvuXC7zl4kX klqgDS2J9vRP6BR1lLqs2wlqWw== X-Received: by 2002:a17:902:848c:: with SMTP id c12mr5348356plo.17.1561650631033; Thu, 27 Jun 2019 08:50:31 -0700 (PDT) Received: from localhost ([2601:646:8f00:18d9:d0fa:7a4b:764f:de48]) by smtp.gmail.com with ESMTPSA id p6sm2693091pgs.77.2019.06.27.08.50.30 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 27 Jun 2019 08:50:30 -0700 (PDT) Date: Thu, 27 Jun 2019 08:50:29 -0700 From: Stanislav Fomichev To: kernel test robot Cc: Stanislav Fomichev , Daniel Borkmann , Martin Lau , LKML , Stephen Rothwell , bpf@vger.kernel.org, lkp@01.org Subject: Re: [bpf/tools] cd17d77705: kernel_selftests.bpf.test_sock_addr.sh.fail Message-ID: <20190627155029.GC4866@mini-arch> References: <20190627090446.GG7221@shao2-debian> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190627090446.GG7221@shao2-debian> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/27, kernel test robot wrote: > FYI, we noticed the following commit (built with gcc-7): > > commit: cd17d77705780e2270937fb3cbd2b985adab3edc ("bpf/tools: sync bpf.h") > https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git master > > in testcase: kernel_selftests > with following parameters: > > group: kselftests-00 > > test-description: The kernel contains a set of "self tests" under the tools/testing/selftests/ directory. These are intended to be small unit tests to exercise individual code paths in the kernel. > test-url: https://www.kernel.org/doc/Documentation/kselftest.txt > > > on test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 8G > > caused below changes (please refer to attached dmesg/kmsg for entire log/backtrace): > > # ; int connect_v6_prog(struct bpf_sock_addr *ctx) > # 0: (bf) r6 = r1 > # 1: (18) r1 = 0x100000000000000 > # ; tuple.ipv6.daddr[0] = bpf_htonl(DST_REWRITE_IP6_0); > # 3: (7b) *(u64 *)(r10 -16) = r1 > # 4: (b7) r1 = 169476096 > # ; memset(&tuple.ipv6.sport, 0, sizeof(tuple.ipv6.sport)); > # 5: (63) *(u32 *)(r10 -8) = r1 > # 6: (b7) r7 = 0 > # ; tuple.ipv6.daddr[0] = bpf_htonl(DST_REWRITE_IP6_0); > # 7: (7b) *(u64 *)(r10 -24) = r7 > # 8: (7b) *(u64 *)(r10 -32) = r7 > # 9: (7b) *(u64 *)(r10 -40) = r7 > # ; if (ctx->type != SOCK_STREAM && ctx->type != SOCK_DGRAM) > # 10: (61) r1 = *(u32 *)(r6 +32) > # ; if (ctx->type != SOCK_STREAM && ctx->type != SOCK_DGRAM) > # 11: (bf) r2 = r1 > # 12: (07) r2 += -1 > # 13: (67) r2 <<= 32 > # 14: (77) r2 >>= 32 > # 15: (25) if r2 > 0x1 goto pc+33 > # R1=inv(id=0,umax_value=4294967295,var_off=(0x0; 0xffffffff)) R2=inv(id=0,umax_value=1,var_off=(0x0; 0x1)) R6=ctx(id=0,off=0,imm=0) R7=inv0 R10=fp0,call_-1 fp-8=????mmmm fp-16=mmmmmmmm fp-24=00000000 fp-32=00000000 fp-40=00000000 > # ; else if (ctx->type == SOCK_STREAM) > # 16: (55) if r1 != 0x1 goto pc+8 > # R1=inv1 R2=inv(id=0,umax_value=1,var_off=(0x0; 0x1)) R6=ctx(id=0,off=0,imm=0) R7=inv0 R10=fp0,call_-1 fp-8=????mmmm fp-16=mmmmmmmm fp-24=00000000 fp-32=00000000 fp-40=00000000 > # 17: (bf) r2 = r10 > # ; sk = bpf_sk_lookup_tcp(ctx, &tuple, sizeof(tuple.ipv6), > # 18: (07) r2 += -40 > # 19: (bf) r1 = r6 > # 20: (b7) r3 = 36 > # 21: (b7) r4 = -1 > # 22: (b7) r5 = 0 > # 23: (85) call bpf_sk_lookup_tcp#84 > # 24: (05) goto pc+7 > # ; if (!sk) > # 32: (15) if r0 == 0x0 goto pc+16 > # R0=sock(id=0,ref_obj_id=2,off=0,imm=0) R6=ctx(id=0,off=0,imm=0) R7=inv0 R10=fp0,call_-1 fp-8=????mmmm fp-16=mmmmmmmm fp-24=mmmmmmmm fp-32=mmmmmmmm fp-40=mmmmmmmm refs=2 > # ; if (sk->src_ip6[0] != tuple.ipv6.daddr[0] || > # 33: (61) r1 = *(u32 *)(r0 +28) > # ; if (sk->src_ip6[0] != tuple.ipv6.daddr[0] || > # 34: (61) r2 = *(u32 *)(r10 -24) > # ; if (sk->src_ip6[0] != tuple.ipv6.daddr[0] || > # 35: (5d) if r1 != r2 goto pc+11 > # R0=sock(id=0,ref_obj_id=2,off=0,imm=0) R1=inv(id=0,umax_value=4294967295,var_off=(0x0; 0xffffffff)) R2=inv(id=0,umax_value=4294967295,var_off=(0x0; 0xffffffff)) R6=ctx(id=0,off=0,imm=0) R7=inv0 R10=fp0,call_-1 fp-8=????mmmm fp-16=mmmmmmmm fp-24=mmmmmmmm fp-32=mmmmmmmm fp-40=mmmmmmmm refs=2 > # ; sk->src_ip6[1] != tuple.ipv6.daddr[1] || > # 36: (61) r1 = *(u32 *)(r0 +32) > # ; sk->src_ip6[1] != tuple.ipv6.daddr[1] || > # 37: (61) r2 = *(u32 *)(r10 -20) > # ; sk->src_ip6[1] != tuple.ipv6.daddr[1] || > # 38: (5d) if r1 != r2 goto pc+8 > # R0=sock(id=0,ref_obj_id=2,off=0,imm=0) R1=inv(id=0,umax_value=4294967295,var_off=(0x0; 0xffffffff)) R2=inv(id=0,umax_value=4294967295,var_off=(0x0; 0xffffffff)) R6=ctx(id=0,off=0,imm=0) R7=inv0 R10=fp0,call_-1 fp-8=????mmmm fp-16=mmmmmmmm fp-24=mmmmmmmm fp-32=mmmmmmmm fp-40=mmmmmmmm refs=2 > # ; sk->src_ip6[2] != tuple.ipv6.daddr[2] || > # 39: (61) r1 = *(u32 *)(r0 +36) > # ; sk->src_ip6[2] != tuple.ipv6.daddr[2] || > # 40: (61) r2 = *(u32 *)(r10 -16) > # ; sk->src_ip6[2] != tuple.ipv6.daddr[2] || > # 41: (5d) if r1 != r2 goto pc+5 > # R0=sock(id=0,ref_obj_id=2,off=0,imm=0) R1=inv(id=0,umax_value=4294967295,var_off=(0x0; 0xffffffff)) R2=inv(id=0,umax_value=4294967295,var_off=(0x0; 0xffffffff)) R6=ctx(id=0,off=0,imm=0) R7=inv0 R10=fp0,call_-1 fp-8=????mmmm fp-16=mmmmmmmm fp-24=mmmmmmmm fp-32=mmmmmmmm fp-40=mmmmmmmm refs=2 > # ; sk->src_ip6[3] != tuple.ipv6.daddr[3] || > # 42: (61) r1 = *(u32 *)(r0 +40) > # ; sk->src_ip6[3] != tuple.ipv6.daddr[3] || > # 43: (61) r2 = *(u32 *)(r10 -12) > # ; sk->src_ip6[3] != tuple.ipv6.daddr[3] || > # 44: (5d) if r1 != r2 goto pc+2 > # R0=sock(id=0,ref_obj_id=2,off=0,imm=0) R1=inv(id=0,umax_value=4294967295,var_off=(0x0; 0xffffffff)) R2=inv(id=0,umax_value=4294967295,var_off=(0x0; 0xffffffff)) R6=ctx(id=0,off=0,imm=0) R7=inv0 R10=fp0,call_-1 fp-8=????mmmm fp-16=mmmmmmmm fp-24=mmmmmmmm fp-32=mmmmmmmm fp-40=mmmmmmmm refs=2 > # ; sk->src_port != DST_REWRITE_PORT6) { > # 45: (61) r1 = *(u32 *)(r0 +44) > # ; if (sk->src_ip6[0] != tuple.ipv6.daddr[0] || > # 46: (15) if r1 == 0x1a0a goto pc+4 > # R0=sock(id=0,ref_obj_id=2,off=0,imm=0) R1=inv(id=0,umax_value=4294967295,var_off=(0x0; 0xffffffff)) R2=inv(id=0,umax_value=4294967295,var_off=(0x0; 0xffffffff)) R6=ctx(id=0,off=0,imm=0) R7=inv0 R10=fp0,call_-1 fp-8=????mmmm fp-16=mmmmmmmm fp-24=mmmmmmmm fp-32=mmmmmmmm fp-40=mmmmmmmm refs=2 > # ; bpf_sk_release(sk); > # 47: (bf) r1 = r0 > # 48: (85) call bpf_sk_release#86 > # ; } > # 49: (bf) r0 = r7 > # 50: (95) exit > # > # from 46 to 51: R0=sock(id=0,ref_obj_id=2,off=0,imm=0) R1=inv6666 R2=inv(id=0,umax_value=4294967295,var_off=(0x0; 0xffffffff)) R6=ctx(id=0,off=0,imm=0) R7=inv0 R10=fp0,call_-1 fp-8=????mmmm fp-16=mmmmmmmm fp-24=mmmmmmmm fp-32=mmmmmmmm fp-40=mmmmmmmm refs=2 > # ; bpf_sk_release(sk); > # 51: (bf) r1 = r0 > # 52: (85) call bpf_sk_release#86 > # 53: (b7) r1 = 2586 > # ; ctx->user_port = bpf_htons(DST_REWRITE_PORT6); > # 54: (63) *(u32 *)(r6 +24) = r1 > # 55: (18) r1 = 0x100000000000000 > # ; ctx->user_ip6[2] = bpf_htonl(DST_REWRITE_IP6_2); > # 57: (7b) *(u64 *)(r6 +16) = r1 > # invalid bpf_context access off=16 size=8 This looks like clang doing single u64 write for user_ip6[2] and user_ip6[3] instead of two u32. I don't think we allow that. I've seen this a couple of times myself while playing with some progs, but not sure what's the right way to 'fix' it. > # processed 49 insns (limit 1000000) max_states_per_insn 0 total_states 13 peak_states 13 mark_read 11 > # > # libbpf: -- END LOG -- > # libbpf: failed to load program 'cgroup/connect6' > # libbpf: failed to load object './connect6_prog.o' > # (test_sock_addr.c:752: errno: Bad file descriptor) >>> Loading program (./connect6_prog.o) error.