Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp803071imm; Mon, 21 May 2018 14:47:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqMu8qVEKs/lx9ucJe4ZaEB4H5UYP9fEMe3lXu+PIItOkKCYlqo7OdsvFmsg/vL8NANpdNc X-Received: by 2002:a63:7157:: with SMTP id b23-v6mr10698366pgn.436.1526939226856; Mon, 21 May 2018 14:47:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526939226; cv=none; d=google.com; s=arc-20160816; b=coKaaKYKbYxzy96xxhmNXkwVK+/AS/80wsu7KRYTTTWNnWiLh3+B1Dvthkms4v7GeS p3Mjhz6rH3OTkJ37vxZkjo87W4Ocu0RqS1n1RGZNP/XXZIUS+lpVrkWlDS2IYXa/WJ9n 5qQ9m5FIUkxVU59eCbfCXu4k1ZyUpT/bOZIzgoCQQGR8ej5AqNhW7/0qSCfFaZtNYoPC 5DJLXmbP2DQLAyrQ5pdM+j0ggmxlx3f/pfSF2dtGxd1F83CyH42mELZttF6FISs5Ahyx e61DhryCAhI50Z1pHZltbaF1E94st++8uIsw3NU2BE1wzbvmPYffyO3395y/l5U5z8x0 ew6g== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=9mAbRRtv/Tux6kjv6Sh+oQIMhJEt6YNYoYh+G8CarGI=; b=zOd1LFAHL0Q4bw6LY9KUMV8S8xKzEfldj+s3iKjoJ2pR1tcZ3YlmgDNFXOsnL7Pg2D rimM/h2IVsRnHFd+SXSacKcXVgU4AMff/N9cq5IVFIpdsaxUtT1sJfs3NNaknhBCQh0U L/zlJV+8A/PQABo3OZX/LdHlhOHLu9R9bl9WrGg4WPI1iGRgVvN7E/bed6yPlxqay152 jt24gSMwt6EIb7Qk9/Id71/4Mfc9XA8OtyDH9iow5wtc0kpjn/KmWS3KfYQHG+Smlyxe wppSjjPJHYw6XlS277Q3JSfY7pHDMHVYWAt4kuxuhLhZYAASymF/dTPEW/kCV8UkboOa USWw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 61-v6si14700921plz.290.2018.05.21.14.46.52; Mon, 21 May 2018 14:47:06 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932454AbeEUVqk (ORCPT + 99 others); Mon, 21 May 2018 17:46:40 -0400 Received: from www62.your-server.de ([213.133.104.62]:39008 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932164AbeEUVqh (ORCPT ); Mon, 21 May 2018 17:46:37 -0400 Received: from [62.202.221.10] (helo=linux.home) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-SHA:256) (Exim 4.85_2) (envelope-from ) id 1fKsdT-0004Ro-VQ; Mon, 21 May 2018 23:46:32 +0200 Subject: Re: [PATCH] bpf: prevent memory disambiguation attack To: Alexei Starovoitov , "David S . Miller" Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com References: <20180521211743.1492305-1-ast@kernel.org> From: Daniel Borkmann Message-ID: <65f20b2e-d9d5-ca7d-6027-54a900893d6d@iogearbox.net> Date: Mon, 21 May 2018 23:46:31 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20180521211743.1492305-1-ast@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.99.3/24591/Mon May 21 22:33:36 2018) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/21/2018 11:17 PM, Alexei Starovoitov wrote: > Detect code patterns where malicious 'speculative store bypass' can be used > and sanitize such patterns. > > 39: (bf) r3 = r10 > 40: (07) r3 += -216 > 41: (79) r8 = *(u64 *)(r7 +0) // slow read > 42: (7a) *(u64 *)(r10 -72) = 0 // verifier inserts this instruction > 43: (7b) *(u64 *)(r8 +0) = r3 // this store becomes slow due to r8 > 44: (79) r1 = *(u64 *)(r6 +0) // cpu speculatively executes this load > 45: (71) r2 = *(u8 *)(r1 +0) // speculatively arbitrary 'load byte' > // is now sanitized > > Above code after x86 JIT becomes: > e5: mov %rbp,%rdx > e8: add $0xffffffffffffff28,%rdx > ef: mov 0x0(%r13),%r14 > f3: movq $0x0,-0x48(%rbp) > fb: mov %rdx,0x0(%r14) > ff: mov 0x0(%rbx),%rdi > 103: movzbq 0x0(%rdi),%rsi > > Signed-off-by: Alexei Starovoitov (No further action needed since already in Linus tree [1]. This went via the batch of x86 fixes on the speculative store buffer bypass from today [2].) [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=af86ca4e3088fe5eacf2f7e58c01fa68ca067672 [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3b78ce4a34b761c7fe13520de822984019ff1a8f