Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2621607pxj; Mon, 31 May 2021 06:46:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKZKPalTEHW4nwqtPn+eRrCj8HsHEyhgSNdRyqhxpBawQxkYQRb3eDe8BVeOifd03nRtWF X-Received: by 2002:a05:6402:95d:: with SMTP id h29mr25309714edz.233.1622468776142; Mon, 31 May 2021 06:46:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622468776; cv=none; d=google.com; s=arc-20160816; b=RtZ8Kpq9sKEFFd+PALaWKuRAEw8HXN0T+Ku2zug1bUFgRzmKhVeTgtDpw/dL8AvZoS g2Ur+aSrEOkW3sYf5T23BeKfb5sKBpfkXF3TcSEa8c9xJNR4rCYmUXd420ypBHKZggJj wpLbI8TZN/t5XmpNQi7/+Agu+Fn31ZzUJm2kz6LM1xJZfiXrk3R7xqklaNdzTBSU21FN GFIYulMHtYmKdnJPPgSQZQHv76J11rczUxj+rd28ZtFwOsz7FsIAOTaAURB63OjPJFUp dHnVB+7DsxQt1KgBf9Skn7jJ+CXkMnJEeAyZfOFl3nLh940Wu1gd5Fa5I64COdrLb/0W bjhw== 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=ZqkuTr/nASEKvjWWUsXAvoZnDJimiGqHTpheuvzk90s=; b=yjn6QAnlbueIbMXsEy///Ema5NsSlPZQL/rcYExL7r8mgqEeRPR2gQdjqMdcHFp4SE N9DgEH1thVhsn6wvISK9AljJMjQgy2xogP9xfRGguaFZzeo1p2tPs1WZ0sry4x5uhEHx 8LIAnYdhnsUI4++/DmZWUnb4zOlMcRYJxGg3syDPfYGT2T7CfhL7bQHaMMkHboJiEkuR Sp06emgXPsVBDikJBaVwtzkQ6zkG/Hp4IWw6LCB+wQQCt/9jcc+l00PQZm76Piv3fsej 51A0Rlf4IiA+CTH7a0taKVno65OWd9yxwBoPN9jx/FMB8gISgEKrQXYd1aMwU5jqwAt/ UH3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ilxTzVbL; 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 s20si13376597ejb.555.2021.05.31.06.45.53; Mon, 31 May 2021 06:46:16 -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=ilxTzVbL; 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 S232817AbhEaNpi (ORCPT + 99 others); Mon, 31 May 2021 09:45:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:39134 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232310AbhEaNbX (ORCPT ); Mon, 31 May 2021 09:31:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5B13361434; Mon, 31 May 2021 13:23:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622467413; bh=2BVZ6E4O9fQ3wfq7+PomQvFxLlwY9udVOZj5I4Y7hMs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ilxTzVbLFK+pPGMPLSw86l972rzM9m6pJHl25UjUbTzhLVq/Dw2fnMOX2VSg3tZh8 3PfqUgk8oprqgvuHvaD6E2extQjdvJ7FLF5NDGcc+EqkxZWELAJBNxSlOLAVO3oBGI Wb49eofaKLsH6LiIv+apRmfkgSY1QfWRPsD+9pQA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Daniel Borkmann , Piotr Krysiuk , Alexei Starovoitov , Ovidiu Panait Subject: [PATCH 4.19 056/116] bpf: Wrap aux data inside bpf_sanitize_info container Date: Mon, 31 May 2021 15:13:52 +0200 Message-Id: <20210531130642.072928971@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130640.131924542@linuxfoundation.org> References: <20210531130640.131924542@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 commit 3d0220f6861d713213b015b582e9f21e5b28d2e0 upstream Add a container structure struct bpf_sanitize_info which holds the current aux info, and update call-sites to sanitize_ptr_alu() to pass it in. This is needed for passing in additional state later on. Signed-off-by: Daniel Borkmann Reviewed-by: Piotr Krysiuk Acked-by: Alexei Starovoitov Signed-off-by: Ovidiu Panait Signed-off-by: Greg Kroah-Hartman --- kernel/bpf/verifier.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -2815,15 +2815,19 @@ static bool sanitize_needed(u8 opcode) return opcode == BPF_ADD || opcode == BPF_SUB; } +struct bpf_sanitize_info { + struct bpf_insn_aux_data aux; +}; + static int sanitize_ptr_alu(struct bpf_verifier_env *env, struct bpf_insn *insn, const struct bpf_reg_state *ptr_reg, const struct bpf_reg_state *off_reg, struct bpf_reg_state *dst_reg, - struct bpf_insn_aux_data *tmp_aux, + struct bpf_sanitize_info *info, const bool commit_window) { - struct bpf_insn_aux_data *aux = commit_window ? cur_aux(env) : tmp_aux; + struct bpf_insn_aux_data *aux = commit_window ? cur_aux(env) : &info->aux; struct bpf_verifier_state *vstate = env->cur_state; bool off_is_imm = tnum_is_const(off_reg->var_off); bool off_is_neg = off_reg->smin_value < 0; @@ -2852,8 +2856,8 @@ static int sanitize_ptr_alu(struct bpf_v /* In commit phase we narrow the masking window based on * the observed pointer move after the simulated operation. */ - alu_state = tmp_aux->alu_state; - alu_limit = abs(tmp_aux->alu_limit - alu_limit); + alu_state = info->aux.alu_state; + alu_limit = abs(info->aux.alu_limit - alu_limit); } else { alu_state = off_is_neg ? BPF_ALU_NEG_VALUE : 0; alu_state |= off_is_imm ? BPF_ALU_IMMEDIATE : 0; @@ -2983,7 +2987,7 @@ static int adjust_ptr_min_max_vals(struc smin_ptr = ptr_reg->smin_value, smax_ptr = ptr_reg->smax_value; u64 umin_val = off_reg->umin_value, umax_val = off_reg->umax_value, umin_ptr = ptr_reg->umin_value, umax_ptr = ptr_reg->umax_value; - struct bpf_insn_aux_data tmp_aux = {}; + struct bpf_sanitize_info info = {}; u8 opcode = BPF_OP(insn->code); u32 dst = insn->dst_reg; int ret; @@ -3035,7 +3039,7 @@ static int adjust_ptr_min_max_vals(struc if (sanitize_needed(opcode)) { ret = sanitize_ptr_alu(env, insn, ptr_reg, off_reg, dst_reg, - &tmp_aux, false); + &info, false); if (ret < 0) return sanitize_err(env, insn, ret, off_reg, dst_reg); } @@ -3176,7 +3180,7 @@ static int adjust_ptr_min_max_vals(struc return -EACCES; if (sanitize_needed(opcode)) { ret = sanitize_ptr_alu(env, insn, dst_reg, off_reg, dst_reg, - &tmp_aux, true); + &info, true); if (ret < 0) return sanitize_err(env, insn, ret, off_reg, dst_reg); }