Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4329106pxj; Tue, 8 Jun 2021 11:38:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYcGpQuH4BOwDYYlQnHB2WUENS1oOWejbJ8+IwdceRYpjhKwpXpBEPCueZLNDWSytw30uC X-Received: by 2002:aa7:c844:: with SMTP id g4mr27471391edt.257.1623177516541; 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=zayhlWVgcaj7v7t/MfYsL6/N3oQ9kBwWXECHtRFks52VYDKVSrstCaJM2exnPcCDoc 3Z7rj+eaFYzwVAd8ahzyhfUJtbE0mgJ6anBT0HrLutwi+qTj+b+I118OYYiGUwK0KEUq a22tGmT3189OUci9qLPDJtuQsoh1gYY9JXnW5Dinyc9ffZHbsEcaRKeiOecy7AxKczqp 8Js2Xmb2+Rh9hndXbzimVonkpTw9MUm6cO/tLMukV++yRlWO04TY/hYQK5OChh0nB4b9 91VsOx+SflH1ObGtGvEPNU0X/HxbxOQz59n/RiFYi7754FLUKQDBG91xUCFBBt2MqIRl J1pQ== 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=u48kR5iLmk4XEWHJsrI5YY0EoYrotkF6ePHqVe6BoIU=; b=qtuJErs5AQ99tDwzz2D13jQs1uGBofKX3Rek+/wgJeWx/w6WYmPEIf1Fy1obpnQLiL GnZXQ9EmjRa9I8LIvkpnLnSPAUs+4fMAfpE2tAo+hWdAoC0mzzjCO0F+GGBKYjnW1MpR n4njh8q2W7OQzusjNerkhyU+4fpMLwnhjPyi1yFd/mD0b8KtF8vbsoQrxzkHgZJ5w/U9 9hcV/n8VnuTneRlvyeisaKiTRrAWprApT1z8yuLQ4VnmC9bwmXinit5yQp00AdWmEd1P FOGdFKZ9w685n1U8ABpc0vPTkrnmm3OM9nyeTQRr7NaAh9wRgP0IVAhNEBvp/XyrLDn3 lM2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=c6SzbQss; 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 n15si411374edy.288.2021.06.08.11.38.13; 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=c6SzbQss; 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 S234808AbhFHShK (ORCPT + 99 others); Tue, 8 Jun 2021 14:37:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:57970 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234816AbhFHSfJ (ORCPT ); Tue, 8 Jun 2021 14:35:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 84C91613FF; Tue, 8 Jun 2021 18:32:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623177126; bh=1FgAsruzabu/OxP8X7lY9HM05qgsQsUoG4g9wC6mS5w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c6SzbQssC5MuhlgV3S/g+Tgw2n7/itBQb7F7+TtNZZkMQIsEd0ZgLN++jrer7wIgm NzFHCzycKDBP/2KB7kpG5ah4ixAcGeywWsVfl524029hb1mVRXdr9uCW4qeo4d1nUF al37Hf78W8CHqjllRbSrpuT7uTcIslazswBpAybs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Daniel Borkmann , Piotr Krysiuk , Alexei Starovoitov Subject: [PATCH 4.14 41/47] bpf: Wrap aux data inside bpf_sanitize_info container Date: Tue, 8 Jun 2021 20:27:24 +0200 Message-Id: <20210608175931.826626946@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: 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: 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 @@ -2110,15 +2110,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; @@ -2147,8 +2151,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; @@ -2276,7 +2280,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; @@ -2327,7 +2331,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); } @@ -2468,7 +2472,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); }