Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp362348ybj; Thu, 19 Sep 2019 15:46:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqyEy5DgkgrvT5bp8Pow00zJ4vB4As2QgRJ8mdzkf4t3bWra0e9wDpvQDbjUPWg43jrKhYmf X-Received: by 2002:a50:884c:: with SMTP id c12mr18633389edc.134.1568933165624; Thu, 19 Sep 2019 15:46:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568933165; cv=none; d=google.com; s=arc-20160816; b=KVq50eZ6SctgjDR8hkc9zRe5AoRQmbKaFqtRGUz/+o3dvR6pMhxG4+RCIGf71QzrAd BnEsVM0cLo+uRN9CK3JlJAAXnntoNvCvZyVpckU920IySQZDncfh0Fqf3Mto77yWviGk nyTNhCNefcBJMSMjvHv0FI0hFnhNHEueYdXV9LrQWIuAAY+JpVdYlIQuzPSwUAvUq+lM xu3nIRS3JLnUBTYwWkHAALGeym/invnADG0SuLi3YPKLY/Ice+4+5bp+Z1fUgWaZANKi 0/ZbVKZH/P/CN9Sgi86IlJJafO2ZDnTTh1onZhTh9SNLESYGqWM2cOh8vvo/XGoV3p45 J/pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vNQpzZeNR6IyFHiUE79MtLZ2nyglAHsktp/KJVGcUeM=; b=pcBUd/0tB9O1UDeNpFiAMSHx+7VNE0KeUgdj22RSr4xsrGn8Y0vWv7GNifKJozYc7D YCxV+tJPe+HQqcdIttqsCNykQ8vC8ckZDuEj/VcmKyVNMJj0dXxSX3G1bn85D7qUDmvA DoG6Fn3ZOyMxPjdbeooBYr+nLkgbqCpXtt8dOWMReK0a0Im5XwXCeiZTY8FDj8A18TIG sAby5voqpr6NCW/ynIhQlTpL0COCUCCATXEKwzLw3LvSMpUl8sY6ExjTPzntoG20HuXV o2rpZ7XTH0jaERs70YjxSNJnJ7lfO45jnEZDfDgLTNUvyyI6fkFYxsk23QYwjmi0TlWu AASw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gMBwpIMJ; 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 r23si91031edq.243.2019.09.19.15.45.42; Thu, 19 Sep 2019 15:46:05 -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=@kernel.org header.s=default header.b=gMBwpIMJ; 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 S2406029AbfISWNC (ORCPT + 99 others); Thu, 19 Sep 2019 18:13:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:52032 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406008AbfISWM7 (ORCPT ); Thu, 19 Sep 2019 18:12:59 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AB6B4218AF; Thu, 19 Sep 2019 22:12:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568931179; bh=mrHPstL9iqpCEs00xslJimRfbU5IgiEpQekd6zBwPBc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gMBwpIMJrOdEEA3FoqRAye8ezwuKlxdcgKBffwR43Tr3HPr451FJhC81bOp2NVxux jOtetM8WXWZlbe0nFHulD2KWORgS+7OLzS2dot6S13nD5RrepOFoVMLCJtIIOV5lFy B8BGHGAGvWlgYlNsUhZ41OnN563ADmGAfCUt16lY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilya Leoshkevich , Daniel Borkmann , Sasha Levin Subject: [PATCH 4.19 30/79] selftests/bpf: fix "bind{4, 6} deny specific IP & port" on s390 Date: Fri, 20 Sep 2019 00:03:15 +0200 Message-Id: <20190919214810.467024983@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919214807.612593061@linuxfoundation.org> References: <20190919214807.612593061@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ilya Leoshkevich [ Upstream commit 27df5c7068bf23cab282dc64b1c9894429b3b8a0 ] "bind4 allow specific IP & port" and "bind6 deny specific IP & port" fail on s390 because of endianness issue: the 4 IP address bytes are loaded as a word and compared with a constant, but the value of this constant should be different on big- and little- endian machines, which is not the case right now. Use __bpf_constant_ntohl to generate proper value based on machine endianness. Fixes: 1d436885b23b ("selftests/bpf: Selftest for sys_bind post-hooks.") Signed-off-by: Ilya Leoshkevich Signed-off-by: Daniel Borkmann Signed-off-by: Sasha Levin --- tools/testing/selftests/bpf/test_sock.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/test_sock.c b/tools/testing/selftests/bpf/test_sock.c index b8ebe2f580741..e9567122070a3 100644 --- a/tools/testing/selftests/bpf/test_sock.c +++ b/tools/testing/selftests/bpf/test_sock.c @@ -13,6 +13,7 @@ #include #include "cgroup_helpers.h" +#include "bpf_endian.h" #include "bpf_rlimit.h" #include "bpf_util.h" @@ -231,7 +232,8 @@ static struct sock_test tests[] = { /* if (ip == expected && port == expected) */ BPF_LDX_MEM(BPF_W, BPF_REG_7, BPF_REG_6, offsetof(struct bpf_sock, src_ip6[3])), - BPF_JMP_IMM(BPF_JNE, BPF_REG_7, 0x01000000, 4), + BPF_JMP_IMM(BPF_JNE, BPF_REG_7, + __bpf_constant_ntohl(0x00000001), 4), BPF_LDX_MEM(BPF_W, BPF_REG_7, BPF_REG_6, offsetof(struct bpf_sock, src_port)), BPF_JMP_IMM(BPF_JNE, BPF_REG_7, 0x2001, 2), @@ -260,7 +262,8 @@ static struct sock_test tests[] = { /* if (ip == expected && port == expected) */ BPF_LDX_MEM(BPF_W, BPF_REG_7, BPF_REG_6, offsetof(struct bpf_sock, src_ip4)), - BPF_JMP_IMM(BPF_JNE, BPF_REG_7, 0x0100007F, 4), + BPF_JMP_IMM(BPF_JNE, BPF_REG_7, + __bpf_constant_ntohl(0x7F000001), 4), BPF_LDX_MEM(BPF_W, BPF_REG_7, BPF_REG_6, offsetof(struct bpf_sock, src_port)), BPF_JMP_IMM(BPF_JNE, BPF_REG_7, 0x1002, 2), -- 2.20.1