Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4329105pxj; Tue, 8 Jun 2021 11:38:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEWEjMTjiMXhs8i8MFjfQccZQGD112eLs5N+Rb96KuThWM1qoyRyrDXjgK9Rq1wKl1Hwfm X-Received: by 2002:aa7:ce86:: with SMTP id y6mr3292302edv.309.1623177516546; Tue, 08 Jun 2021 11:38:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623177516; cv=none; d=google.com; s=arc-20160816; b=i+I3jrCXVod+22xWWT+rGTCN1KpqNBon3YBV2zamTLNrXLZMpnko9xgRdWa5Z3U1pP SFl8nMJIlaNjA7c0BPZHSpFnbYwBFgsg+q1W7xZ5qEfNXRoqzIyjpoK4DNg6i/aZx6dy hoJ0zVX3OIvrPuW8U/S4Fx2tyZVuA+iaYxzPrqlgqj2OZiVaTJeiwtLS4P00SRnIoP/c fuSXTy0t14NpyOs7UhmI+9VBNdkZdBxaW2C8qmS9kmLiHGrXq3vLxExWIQ1ChpEqgKdY SflZ8FCpsMSulfG5scQvpbp0vDDaQ2WbNLxTLlevZQwwraXq6eHvKmn8baBFBj17lcBZ imAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DCp60BW+RgVRZrMMWnL/yWGyyG1LQl2tuqRgsKmkKPg=; b=K1Bydv+7ff00Zo5Vt/gR+96sWkxVPbKlhUFVLxAJDt4f+T5mYX99EpB1eV3acz752T tpf5SLhYyGdQASSBq1YIACAaioK7hJ8YfCyHNTJ5qpUMagxJC+rDWcVD+pyB7PPklP2q ThC3nZTlampz0cRVNKTP6bsUWBe13PD+MUibcjYgBb+Geq0+sZTldBu4sjGXV5wGx/Q3 vo1g0eKwvafISum93et0zLGXMVurzL0UHYvZhCy5tS/aZOk9C5OJkYN2ewULcJOylTAk 6V6RpeuVpahEI95Lw7hioMqBkwPxnzu3y9otveHrXdPlx5VEtBy3OjGm/Yrdr6oGaP1V PEvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bxEob4yH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j10si378803edw.560.2021.06.08.11.38.12; Tue, 08 Jun 2021 11:38:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bxEob4yH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233996AbhFHSgo (ORCPT + 99 others); Tue, 8 Jun 2021 14:36:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:57310 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234388AbhFHSem (ORCPT ); Tue, 8 Jun 2021 14:34:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DA17C613B9; Tue, 8 Jun 2021 18:31:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623177114; bh=YWx7Wpz/nixlUUeiM88xb7Aa0wPZrmfma7RLTzvvMLI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bxEob4yHrTq6Xh47BrOw1xgQoLdlesewW0tYy64MBThemc3fwfJFw6gIsxgztVuSw 9rE1JhH6/Qde7B+aL0CNzfAN3PHUfE/6M1g0WGUDM0LMH9u7SZbMFCwztdh3ksYL5M eriaeLEuH7mIvn4VNyUh1H+ev0xuel5AxgUUEHCc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Jann Horn , Daniel Borkmann , Alexei Starovoitov , Frank van der Linden Subject: [PATCH 4.14 37/47] bpf/verifier: disallow pointer subtraction Date: Tue, 8 Jun 2021 20:27:20 +0200 Message-Id: <20210608175931.695295703@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608175930.477274100@linuxfoundation.org> References: <20210608175930.477274100@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexei Starovoitov commit dd066823db2ac4e22f721ec85190817b58059a54 upstream. Subtraction of pointers was accidentally allowed for unpriv programs by commit 82abbf8d2fc4. Revert that part of commit. Fixes: 82abbf8d2fc4 ("bpf: do not allow root to mangle valid pointers") Reported-by: Jann Horn Acked-by: Daniel Borkmann Signed-off-by: Alexei Starovoitov Signed-off-by: Daniel Borkmann [fllinden@amazon.com: backport to 4.14] Signed-off-by: Frank van der Linden Signed-off-by: Greg Kroah-Hartman --- kernel/bpf/verifier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -2754,7 +2754,7 @@ static int adjust_reg_min_max_vals(struc * an arbitrary scalar. Disallow all math except * pointer subtraction */ - if (opcode == BPF_SUB){ + if (opcode == BPF_SUB && env->allow_ptr_leaks) { mark_reg_unknown(regs, insn->dst_reg); return 0; }