Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2471290pxb; Mon, 19 Apr 2021 06:34:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzig2NTgYuM5mf3pXDP2q+UUJK6ZAERefKw4xEgLNfB6R2Oj+nH7gLap/OaA25pnvWht14Q X-Received: by 2002:a17:906:1284:: with SMTP id k4mr21300462ejb.409.1618839242367; Mon, 19 Apr 2021 06:34:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618839242; cv=none; d=google.com; s=arc-20160816; b=cAnlxreamq/HsctrqiHVyc9HXctQRignApOEIhC0L/FKhWU7thUxFrBz3wiCsdJmox COCtoIkPpsCWWF0+p5Lrxd0x2I0MNbosNUH7dS2HbGJH8raE6/U3htt+xOkGVG7Yd4D5 ub1xelsaFJjr+Yr4x2sEibS/rmBpPn6IjxYddFtJwP0RY+5AM1YAAwr7d0cn4e5NGGl2 VR0eJBVX0AWpVSjiaHNe+XNVwdRGZ4KtLpKz41kYgjKPcu7eq9B26URNjEerp2kdm81N NulbywMTrlzJYoh0ADuc/Ns8qKW4RIY+uENUqhhP1L2YzELHnFCcG7zkFKMcSIY0Wxo6 XEXw== 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=sw3wm6G1FRResfPZTskclf8Vand3M8uPryJa0AzII8o=; b=joITj2AnK2YHIWyQqDVrD7Mn4aF7nw8Q3qWC/6lfIpq/aPqcqep5xjxfR8tods9iyJ QtcZAU4tH5RGa3ltCfdLcLOAnH3wiGwXAntyhXss86halvRL12UjIdbGw+Wp8ogvM7Nx 59ZTxfrIME/6JYyhuQFPsxqPwMW1Mdef08P40aYrdcOEywm1pl9sdcXMKFiJsknx3VR/ YKKdrHJDcaHAHV6+1BkxEqW5AxYRy52EiUT6zOX56Jy/CsWd4R3ui8ho5gTv00COeIy8 cBDE6NVMHQCw8/Kv513qiCXTSgUCpPBigQvWWBOKIizhgLrcjd60MYaTH1tI0m3TZdhU XjnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xoYaURQt; 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 i10si7427905edc.63.2021.04.19.06.33.39; Mon, 19 Apr 2021 06:34:02 -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=xoYaURQt; 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 S242625AbhDSN3b (ORCPT + 99 others); Mon, 19 Apr 2021 09:29:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:56310 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241525AbhDSNUv (ORCPT ); Mon, 19 Apr 2021 09:20:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C19C7613F6; Mon, 19 Apr 2021 13:17:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618838234; bh=mSWW58JyVorAzLFuHZfKOcHAom1nBHNhedAniIa80eY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xoYaURQtcmdZOFVAE1JiVOb8bbKSATq1S/RkeCiYqfXGcWwXXrLV2nvj/vfaE6Igz VVCD80RaEebnnM4qLvrOds1c2NEeHQiOUdEN0W2k+/X+NRN/pvy3xvGNJak5MOKPKJ REpQDn8tsjnJqLxL+H19evg/LnuhnC5MMb9mbYoY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Borkmann , John Fastabend , Alexei Starovoitov , Sasha Levin Subject: [PATCH 5.10 092/103] bpf: Use correct permission flag for mixed signed bounds arithmetic Date: Mon, 19 Apr 2021 15:06:43 +0200 Message-Id: <20210419130530.956055833@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210419130527.791982064@linuxfoundation.org> References: <20210419130527.791982064@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: Daniel Borkmann [ Upstream commit 9601148392520e2e134936e76788fc2a6371e7be ] We forbid adding unknown scalars with mixed signed bounds due to the spectre v1 masking mitigation. Hence this also needs bypass_spec_v1 flag instead of allow_ptr_leaks. Fixes: 2c78ee898d8f ("bpf: Implement CAP_BPF") Signed-off-by: Daniel Borkmann Reviewed-by: John Fastabend Acked-by: Alexei Starovoitov Signed-off-by: Sasha Levin --- kernel/bpf/verifier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 12cd2997f982..2eaefd9c4152 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -5522,7 +5522,7 @@ static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env, dst, reg_type_str[ptr_reg->type]); return -EACCES; case PTR_TO_MAP_VALUE: - if (!env->allow_ptr_leaks && !known && (smin_val < 0) != (smax_val < 0)) { + if (!env->env->bypass_spec_v1 && !known && (smin_val < 0) != (smax_val < 0)) { verbose(env, "R%d has unknown scalar with mixed signed bounds, pointer arithmetic with it prohibited for !root\n", off_reg == dst_reg ? dst : src); return -EACCES; -- 2.30.2