Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5895148imb; Fri, 8 Mar 2019 04:59:30 -0800 (PST) X-Google-Smtp-Source: APXvYqwY8iVaNXSvUFvFAsfksIbAoKg1xEIygTd0t/Mj88Vo0fdPaWCXbMJrgDZirFg4BLJalQWK X-Received: by 2002:a63:8942:: with SMTP id v63mr16068873pgd.406.1552049970607; Fri, 08 Mar 2019 04:59:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552049970; cv=none; d=google.com; s=arc-20160816; b=1CTM3a0AcAa3JAoS935u4rhQxLdCa0zFWPx1hzYMa6FMtsEDIQysMnt2NQsSFHwbJu m48NqSZpxORZNDYQR9KKVlbUZOZwB6Rfvp2mnMOmKbCnWKU+ZR6d4/WoyJ5GZKhqnScZ Yb3OoF5YnVBe43i5xfLhIWhCScr9icbUrwT2f1Y6ZGn9AkntKP2tvHXq+W6xyxqVyQu+ UVMExnj/ALApHmqMhOQDgOmomOQU2rrfo0dwWdluaQ5NQmls1zAMj2lI4XmqWVtesk/s vGvOpnT5/EV0lzv6aAVAaOjYOR8vxH3+nG6XDbUC85cAp9jJCdx2mKyxpgXeJtCFQSzG 5psQ== 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=ZT1xlLoG19KdfNT8uCH03cWsDOqewpKKNeiVp7fM4bk=; b=tON28wXdiVrv4QmP8c7DNVfn7og4JVeafomJkWzRNZi8+yHQ6YNzeRNKzakclZ4JUe dv1FHCKRg4d+kgqfieqsuUuvYz3Kxa5hHdT/PHaE1swfk8S8K5VhmK/6IIX6ayDVctqR E3Jd/MLzOAqPGUJ++SewRO0moONNNgeREMw5kZKmwdRZZwDhMt1EIPOm3JjrQfkHpHXd fvAe9eyWMS6v4gWPz63JzIBX/uNpjKTqhrdGL71f9gbXPIdgYWrZ7mdx2F2SxmMl1vbN BHAPOOwVonStjsCrXAskLIhGfbUde9V6Q8F/FF2DW+IQ+UbO0V/aJ5FMZytwc6DLEBoq NyUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ew0KtdoK; 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 l70si6593003pgd.470.2019.03.08.04.59.15; Fri, 08 Mar 2019 04:59:30 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Ew0KtdoK; 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 S1727894AbfCHM5h (ORCPT + 99 others); Fri, 8 Mar 2019 07:57:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:33966 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727874AbfCHM5e (ORCPT ); Fri, 8 Mar 2019 07:57:34 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 980F620811; Fri, 8 Mar 2019 12:57:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552049854; bh=OZhB1E2tBJW/EYUcsxk6rnwU39375CC5Og18bBQmBYs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ew0KtdoKfjhD9T+hVYp+dGf71vU1vpRvjw2yhg61MgViDjC6e7y6qWJxlZ5GBTLne Kxlo2BgOF9gS91dTy/fSFEwLeXPkcGysMrVNT0m5Pa4W0MEtAYed1EBPUtt0OmsPIK 9SNGdYxmMkgOiRroG0JTQ9tysLTGmTrh98Qd2Bo8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marek Majkowski , Arthur Fabre , Daniel Borkmann , Song Liu , Alexei Starovoitov Subject: [PATCH 4.20 76/76] bpf: fix sanitation rewrite in case of non-pointers Date: Fri, 8 Mar 2019 13:50:28 +0100 Message-Id: <20190308124917.480135207@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190308124914.789210760@linuxfoundation.org> References: <20190308124914.789210760@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Daniel Borkmann commit 3612af783cf52c74a031a2f11b82247b2599d3cd upstream. Marek reported that he saw an issue with the below snippet in that timing measurements where off when loaded as unpriv while results were reasonable when loaded as privileged: [...] uint64_t a = bpf_ktime_get_ns(); uint64_t b = bpf_ktime_get_ns(); uint64_t delta = b - a; if ((int64_t)delta > 0) { [...] Turns out there is a bug where a corner case is missing in the fix d3bd7413e0ca ("bpf: fix sanitation of alu op with pointer / scalar type from different paths"), namely fixup_bpf_calls() only checks whether aux has a non-zero alu_state, but it also needs to test for the case of BPF_ALU_NON_POINTER since in both occasions we need to skip the masking rewrite (as there is nothing to mask). Fixes: d3bd7413e0ca ("bpf: fix sanitation of alu op with pointer / scalar type from different paths") Reported-by: Marek Majkowski Reported-by: Arthur Fabre Signed-off-by: Daniel Borkmann Link: https://lore.kernel.org/netdev/CAJPywTJqP34cK20iLM5YmUMz9KXQOdu1-+BZrGMAGgLuBWz7fg@mail.gmail.com/T/ Acked-by: Song Liu Signed-off-by: Alexei Starovoitov Signed-off-by: Greg Kroah-Hartman --- kernel/bpf/verifier.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -6428,7 +6428,8 @@ static int fixup_bpf_calls(struct bpf_ve u32 off_reg; aux = &env->insn_aux_data[i + delta]; - if (!aux->alu_state) + if (!aux->alu_state || + aux->alu_state == BPF_ALU_NON_POINTER) continue; isneg = aux->alu_state & BPF_ALU_NEG_VALUE;