Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1159591ybf; Thu, 27 Feb 2020 06:07:04 -0800 (PST) X-Google-Smtp-Source: APXvYqzhFKQsVzfipV6nwfRnWB0ayU82kzMfCpK958QE5X33nTxv+RZH18QxpVYxsGWwhvAha++X X-Received: by 2002:aca:d03:: with SMTP id 3mr3436190oin.69.1582812422386; Thu, 27 Feb 2020 06:07:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582812422; cv=none; d=google.com; s=arc-20160816; b=H/8YcrPmRz3VH/ql+AvRxBZPiznKU7cYwLwxgHSVJo7itaTlTdcVUPQrU80gfwEhoi cQbO6d1d0FoxBQIvw7vWyIzxDtERBJD2o6GVxOH0ur0UERjzmSSIxXWvh6qfJOrEx6qn kY+Hqphnz9ZTLpMFBiZEwSNI6O5GcyvxMkKQbkMggb1HOw5D4wMG+khJ+SBnBPFdST0l 5mTqyeVYr+Gs5Z2ot+25zmw5RW4UShNmYPD6cayQgqcggZML4jYKCecuRJtLkK/X7/QG rmnpBFOmrwnlBrESBG4U3ujMl3BJVzQf0mXHi2+vxZe8UDnOW3GiDJA5TOS+f9xrmBfq YrpA== 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=bTcUICbrHPE8rzk4pbXAglP4WcUbCuCANud50pnQMFo=; b=EgwgoTtCFW6l0/uLVjDwmxVlQedr9sBM8bpgCRbjTkroFIxb2M5aYQkuP4ipURfacQ cjRcWfyz8gkQmoHERJUkmO9XACZXKKQGN4PRvNSGWVlNCRYr8T4QP6APcc01OtAGJoHN wR1asQawdV0fVXzWlcyMKpJiQdd81U2/H/jEWjIL2k4xb8Qg1kWXoTCG6tSDaqzKLIlE BeL4jb1wIuBPJwZ8eDyVsGItCoPS6f0GufMVFiRkMruXTtFEr4h7X+JvmfLey/KrE7Te fGmcIVo9nLRpe205/tv8o/LrfUcUng3Y8ZBY4bFHRQIo+SG0FL5fzPnAxy7DzSSbYOGQ zATg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=K99QoxRy; 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 m19si1407929otr.18.2020.02.27.06.06.46; Thu, 27 Feb 2020 06:07:02 -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=K99QoxRy; 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 S1730186AbgB0OGQ (ORCPT + 99 others); Thu, 27 Feb 2020 09:06:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:43294 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387514AbgB0OGN (ORCPT ); Thu, 27 Feb 2020 09:06:13 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 7FBBB20578; Thu, 27 Feb 2020 14:06:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582812373; bh=XpnBttSLc8xUIzI/h+JjzrXocDxEK+hidNJfISLZMg4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K99QoxRyG8EzMDfJQGnrQTNYExx7/p/EK4vXSaOPcPUkW9dq+LG0DiWhs5ZsMwq7I aqw/fWf79h5v9QMmtHuhmEvWJDlW7ni3y+V6WKyrUpZS/i7ld/NIHUbOLaM9Ugv/eq hHxvODMblpf6vDFJxvay9lQT8ydyrEJJ8X4lJDYQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Krude , Daniel Borkmann , Jakub Kicinski Subject: [PATCH 4.19 89/97] bpf, offload: Replace bitwise AND by logical AND in bpf_prog_offload_info_fill Date: Thu, 27 Feb 2020 14:37:37 +0100 Message-Id: <20200227132229.139895694@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200227132214.553656188@linuxfoundation.org> References: <20200227132214.553656188@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Johannes Krude commit e20d3a055a457a10a4c748ce5b7c2ed3173a1324 upstream. This if guards whether user-space wants a copy of the offload-jited bytecode and whether this bytecode exists. By erroneously doing a bitwise AND instead of a logical AND on user- and kernel-space buffer-size can lead to no data being copied to user-space especially when user-space size is a power of two and bigger then the kernel-space buffer. Fixes: fcfb126defda ("bpf: add new jited info fields in bpf_dev_offload and bpf_prog_info") Signed-off-by: Johannes Krude Signed-off-by: Daniel Borkmann Acked-by: Jakub Kicinski Link: https://lore.kernel.org/bpf/20200212193227.GA3769@phlox.h.transitiv.net Signed-off-by: Greg Kroah-Hartman --- kernel/bpf/offload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/bpf/offload.c +++ b/kernel/bpf/offload.c @@ -289,7 +289,7 @@ int bpf_prog_offload_info_fill(struct bp ulen = info->jited_prog_len; info->jited_prog_len = aux->offload->jited_len; - if (info->jited_prog_len & ulen) { + if (info->jited_prog_len && ulen) { uinsns = u64_to_user_ptr(info->jited_prog_insns); ulen = min_t(u32, info->jited_prog_len, ulen); if (copy_to_user(uinsns, aux->offload->jited_image, ulen)) {