Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10785784imu; Thu, 6 Dec 2018 06:48:19 -0800 (PST) X-Google-Smtp-Source: AFSGD/XpCTCuHSTYETacZvyuvEp5vPXdwmRYsxlsNS2wyrJ3oXF0JJXuxKU/qvHmhwGMDPSyMoOj X-Received: by 2002:a63:20e:: with SMTP id 14mr24264166pgc.161.1544107698951; Thu, 06 Dec 2018 06:48:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544107698; cv=none; d=google.com; s=arc-20160816; b=YV8P1GQ1s9Pf934aAepVDuBMvqQyPuK589lLAUkD9G1k8GL8NlusFD248L2Ra8QCxp to4YlJxSRgf+Y4beELC+p1s8h0Myrf+APoL48DtDF3OkdfZXEvyvt7DKYUm7WhUGBMZB PoWF/c5I2/DJ2TtmjDhmaTiwpNMLDODKppwIG/H3fvPql4StRJEmBGOrfYfF3w8R19SU 03VNWehuztGyrasCCN5OEwGPxpB3Q4Ltg/Z9UMjFux/MH5QebgmhcOplocU73vkr4soW /r59LTetcwvF90Bz1vmIDt5+O8sJ4IKdAjOYDctSS5q618lJD7Q9xvCM50H4CpIayG1P Qvvg== 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=j2AvEVrwhXQdKPVbfUNDXueLFsIxuzDQQQFPhIyk+mU=; b=enX57Z7ufiyRAWLHqqeC0pmd0Jyuyjc7beA7Yab1pH33XrbRgr1LlP/Nwnm754LIp1 7FsG+XusJH9jYpeH02bRX5jU6s85QKDvp41BO4BUgLMNc4jEcOAkUSMPru4Um7Sf/8bi IktgvKKfZlbKUVdvfq8MYRyj8zXp1zK9Ssnp9KaG8eiIZihsiqSIk/13JIgxZ60gd8aE hsyDkAF75Z6oQeYPW4cNS6K0OnbyRW+z9DmUJkswtkenNwjXl9jBjGTSlXEZaoUV8jqF 8h2w+2qjG1FT4tA2VeohT2SOv/FtUJDfJKnophowL1cOEEeqfDYLqM/ZMigPOXwMI3Ri 1NAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LVkJh6PO; 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 e13si395347pgh.251.2018.12.06.06.48.02; Thu, 06 Dec 2018 06:48:18 -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=LVkJh6PO; 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 S1731234AbeLFOqV (ORCPT + 99 others); Thu, 6 Dec 2018 09:46:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:51016 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731225AbeLFOqQ (ORCPT ); Thu, 6 Dec 2018 09:46:16 -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 9E4202146D; Thu, 6 Dec 2018 14:46:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544107576; bh=M3xdBRGww5er9HDj/rTcJZuyAagwtmdWp/U9raUGM9A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LVkJh6POCR03Y4pJUhFn+52GhVnNkXz6qrFAOHFU+mrEk3xjN1sxTju3iuOs8cN0x 7ANT6QsAm8+dqRIUj7YHicIUAAHhuDFbz4k1xt4JuxT62we62u23mnXvdkTsrDAcS9 5zDvpRB4s4n1yZv/dvf11e6hu/F5SXamuF9Pj3Ss= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Borkmann , Alexei Starovoitov , Ben Hutchings Subject: [PATCH 4.9 058/101] bpf/verifier: Add spi variable to check_stack_write() Date: Thu, 6 Dec 2018 15:38:57 +0100 Message-Id: <20181206143014.935676158@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206143011.174892052@linuxfoundation.org> References: <20181206143011.174892052@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.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ben Hutchings Extracted from commit dc503a8ad984 "bpf/verifier: track liveness for pruning". Cc: Daniel Borkmann Cc: Alexei Starovoitov Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- kernel/bpf/verifier.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -543,7 +543,7 @@ static bool is_spillable_regtype(enum bp static int check_stack_write(struct bpf_verifier_state *state, int off, int size, int value_regno) { - int i; + int i, spi = (MAX_BPF_STACK + off) / BPF_REG_SIZE; /* caller checked that off % size == 0 and -MAX_BPF_STACK <= off < 0, * so it's aligned access and [off, off + size) are within stack limits */ @@ -558,15 +558,13 @@ static int check_stack_write(struct bpf_ } /* save register state */ - state->spilled_regs[(MAX_BPF_STACK + off) / BPF_REG_SIZE] = - state->regs[value_regno]; + state->spilled_regs[spi] = state->regs[value_regno]; for (i = 0; i < BPF_REG_SIZE; i++) state->stack_slot_type[MAX_BPF_STACK + off + i] = STACK_SPILL; } else { /* regular write of data into stack */ - state->spilled_regs[(MAX_BPF_STACK + off) / BPF_REG_SIZE] = - (struct bpf_reg_state) {}; + state->spilled_regs[spi] = (struct bpf_reg_state) {}; for (i = 0; i < size; i++) state->stack_slot_type[MAX_BPF_STACK + off + i] = STACK_MISC;