Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3237506imu; Sat, 24 Nov 2018 00:47:52 -0800 (PST) X-Google-Smtp-Source: AJdET5eL7XBJ+/+IwYigZa5PUoY2s1ZfsEYNB7UeUp0GJHK0YxUhWKLAKMzvpLDOfks9IeIjve4T X-Received: by 2002:a62:e044:: with SMTP id f65mr19220163pfh.208.1543049272266; Sat, 24 Nov 2018 00:47:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543049272; cv=none; d=google.com; s=arc-20160816; b=kT9H36r0UrCcWrTGZc5cR2WfJY0M3tl3DoXeJ1Qx/OXYGGJcL2Ez2pYWHfbDzIoeHP UDhkFuEvoaaryQ/bUZXfwvXB7Ksj7c3hgSMWIpXEALYAKTI17oPJNG8gghcq392X2mOI Sn1ZIZC3lNCdBCNc5O88mlUTLBhafZsweTLLJ4K+tEC7e6fBdbuwraxY0EKVdK+SKl43 +HKNqRVT/SFW6Loyo+TlCB/CVI8j3RBfoN/eLWClQPkOgKyjY07XT4bkUrFvA77xUTWv oHPWgPW/ffqk+huFpFGOurrwM7HZ0W0Ejhmp2IxOVYZShVlQ28OScrpsBN3ibsC7V75c yq1A== 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; bh=U2gLBiE/urN2F/mtlhiCiBb8gt0LaLBVFOG5nq6HycQ=; b=TEsJSbSOEyTSSAZm+PbmCZKU1+fhMq8XhYU7hACljJkUhhE/eThcMqCBtxL2yy4ZWa yDliKKq0FZSx6BdLCfJ3PSnWG3c/y6xETfJybqut+qPpzfsyYWp9vNdFBkOdyKqpEesX sNvyJ0W6O3uP3WToIm+mIJ9++AC8gh86ug8hO4N/aJ2KLg2bGcZEswIhvWEhhK+IQxge AheAg4FTivkofTp+58a5/pli/kM0DBkkoJyyBmrDb7vSDkw1UF8awbABZ4S5k0KFs49L LI1SyQIHrsP+r/vnV3XMOX9Fbp8P7H1pLOQKIdvSHstQiv9lxqkGBBOgoX6UYfVvtx7C HeAw== 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=codethink.co.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c7si40306616plz.118.2018.11.24.00.47.38; Sat, 24 Nov 2018 00:47:52 -0800 (PST) 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=codethink.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437188AbeKXFUl (ORCPT + 99 others); Sat, 24 Nov 2018 00:20:41 -0500 Received: from imap1.codethink.co.uk ([176.9.8.82]:60779 "EHLO imap1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395385AbeKXFUk (ORCPT ); Sat, 24 Nov 2018 00:20:40 -0500 Received: from cpc118554-reig6-2-0-cust775.6-3.cable.virginm.net ([86.18.95.8] helo=xylophone.i.decadent.org.uk) by imap1.codethink.co.uk with esmtpsa (Exim 4.84_2 #1 (Debian)) id 1gQGIK-0001LL-HD; Fri, 23 Nov 2018 18:35:12 +0000 Date: Fri, 23 Nov 2018 18:35:10 +0000 From: Ben Hutchings To: Alexei Starovoitov , Daniel Borkmann Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] selftests/bpf: Add test case for defence against SSB exploitation Message-ID: <20181123183510.irdednmxibfal5mu@xylophone.i.decadent.org.uk> References: <20181123183356.5q4bu47zpj5wdufb@xylophone.i.decadent.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181123183356.5q4bu47zpj5wdufb@xylophone.i.decadent.org.uk> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Test that the defence added by commit af86ca4e3088 "bpf: Prevent memory disambiguation attack" is actually being applied. Signed-off-by: Ben Hutchings --- tools/testing/selftests/bpf/test_verifier.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c index e71b7f2e5f17..ca21a63541b0 100644 --- a/tools/testing/selftests/bpf/test_verifier.c +++ b/tools/testing/selftests/bpf/test_verifier.c @@ -13927,6 +13927,21 @@ static struct bpf_test tests[] = { .result = ACCEPT, }, { + "reference tracking: defend against SSB exploitation", + .insns = { + BPF_MOV32_IMM(BPF_REG_2, 1), + /* stack[-1] = (integer) 1 */ + BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_2, -8), + /* stack[-1] = (pointer) context */ + BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_1, -8), + BPF_MOV32_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }, + .infostr_unpriv = "patching in sanitization against SSB at 2", + .result_unpriv = ACCEPT, + .result = ACCEPT, + }, + { "calls: ctx read at start of subprog", .insns = { BPF_MOV64_REG(BPF_REG_6, BPF_REG_1), -- Ben Hutchings, Software Developer Codethink Ltd https://www.codethink.co.uk/ Dale House, 35 Dale Street Manchester, M1 2HF, United Kingdom