Received: by 10.223.176.5 with SMTP id f5csp970565wra; Fri, 2 Feb 2018 09:03:09 -0800 (PST) X-Google-Smtp-Source: AH8x225fDtbYcQwHiCY/++wbxLR5iUtx/hgSSvMOaUcumSgCzkxXUUsR4RiSLF+mI6syHql/j91b X-Received: by 2002:a17:902:788b:: with SMTP id q11-v6mr15431710pll.378.1517590989591; Fri, 02 Feb 2018 09:03:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517590989; cv=none; d=google.com; s=arc-20160816; b=j24+5mJb306216cMbP4g8rP1wTUZcRpDzGAhiwvbCHwdVLS+DYi7g7kEfFukU0LpVL 3PUkRsGztfu/JtfyFAYuFHc6C+qNZLV6di1b/ntQaW4207+nviAXqYue+KH8ks3zJ2Ha dLDsPAaHz+osu+K8zSvzWdT8EVLQQmy3B+ox4ZFSiM0dcI6PrR7HeHyjxX8/CFhK+ELS zTO2hxO/btWLMvvWNOy+q8+ueBUaP4CxMsBZYGibCPrAsX+b/0G2au1b5LJC4zp5V9j0 w1nprhz8cL4H9ylY2a3Ql5mMGl65FXsty7zyTekvgBmZdcHqXWktlvxV1GzBVt2VLqLJ IMYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Q2FByB1aZYpufaiPMkAOslNlp9oYvA5ABW5k8Gzi3aE=; b=To9KNGqDPLggXq5VERkkTHh4eD4F/1tcvtEGN3rrNDDd0upYzpxrLPy7bTpJgbyIsg LxPKjIZan/Y97K+Xm+CUjh5yHbCnGrkmLWk9Qj2xiGMvn37kZBlkvKTMgBPS0JMYUokN qw0ViCFr4h116dcpp/BhgGEFD/gCtQBuGY1kB00TISenJ0btcKHBRTR4m2kYy4DHa5nJ SkYyMRXNQ5pMgg+r2fo1CX1dCGOb2um1UD1oWLS1MeOhJJKEXWo8M7t1WOuyZs0y37dA CrejyNZlBGMbfBNHccXOt4p+Ku9oMIHmzEmncKUvnmqO6OjO3Ayo8PANSAEFNzeTUUL7 mXSg== ARC-Authentication-Results: i=1; mx.google.com; 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 p9-v6si277077pls.317.2018.02.02.09.02.54; Fri, 02 Feb 2018 09:03:09 -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; 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 S1752736AbeBBRBv (ORCPT + 99 others); Fri, 2 Feb 2018 12:01:51 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:34786 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752618AbeBBRAe (ORCPT ); Fri, 2 Feb 2018 12:00:34 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 7C51CDE1; Fri, 2 Feb 2018 17:00:33 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "ast@kernel.org, daniel@iogearbox.net, stable@vger.kernel.org, Eric Dumazet" , syzbot , Alexei Starovoitov , Eric Dumazet Subject: [PATCH 4.4 08/67] bpf: fix divides by zero Date: Fri, 2 Feb 2018 17:57:37 +0100 Message-Id: <20180202140816.159023846@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140815.091718203@linuxfoundation.org> References: <20180202140815.091718203@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ upstream commit c366287ebd698ef5e3de300d90cd62ee9ee7373e ] Divides by zero are not nice, lets avoid them if possible. Also do_div() seems not needed when dealing with 32bit operands, but this seems a minor detail. Fixes: bd4cf0ed331a ("net: filter: rework/optimize internal BPF interpreter's instruction set") Signed-off-by: Eric Dumazet Reported-by: syzbot Signed-off-by: Alexei Starovoitov Signed-off-by: Greg Kroah-Hartman --- kernel/bpf/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -444,7 +444,7 @@ select_insn: DST = tmp; CONT; ALU_MOD_X: - if (unlikely(SRC == 0)) + if (unlikely((u32)SRC == 0)) return 0; tmp = (u32) DST; DST = do_div(tmp, (u32) SRC); @@ -463,7 +463,7 @@ select_insn: DST = div64_u64(DST, SRC); CONT; ALU_DIV_X: - if (unlikely(SRC == 0)) + if (unlikely((u32)SRC == 0)) return 0; tmp = (u32) DST; do_div(tmp, (u32) SRC);