Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1165464ybf; Thu, 27 Feb 2020 06:12:07 -0800 (PST) X-Google-Smtp-Source: APXvYqz+Wus/VUxudd9GvPV9+h0b40kChmXETX8XvFEpp7yqMhUDhKkBHoEjFd80wB/+190Jr+nH X-Received: by 2002:a9d:7999:: with SMTP id h25mr3450923otm.347.1582812727202; Thu, 27 Feb 2020 06:12:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582812727; cv=none; d=google.com; s=arc-20160816; b=xmsv1iOD5uwfOv/wEs0joozUb0N8vjSz947Ea2f9peEG1X+SYqYcJroCv+2FyxC33U wTF5In7yVFPBkyb6ylcWNX9+G9mqaXTJaKLbKFKBqrMHCEnx/f28spIRiZwQX44VLDZZ wO+sHH+A37QeeyW+nv/blH1g4A1Q/tIvgjE8Ls18PT/w1zdI13x1K3wSnqkVmQq5A7WL /kEnGeWGSO7pk/iqc2CNQf4dUxNACk9sgbJqSiiWQsf2kDZ+9xh5zlub/uH2npNYHj4Q vGTnB0MZCG4W8fFfdXJWirYKpIJonO9a+JHF8BabFflLY1dHq7gjpQzdgFdcU0TlJ4uW IfyQ== 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=xN1g7NbMQq6ZQjPHAnCogDLlFU5k7XFVeoH4TSfaBa4=; b=BG5AABZdWB46BfcmZ9P1rfANkjXUPBzf8slBgYRE9H68xXgXNPcPwMtYwqCtm/ZO8a SMXn5sVA7I+2YQZIaUIU6foPrOKlGQZ3HvNzuZxwXRc/HefQ2nkpfBXRSzDudAJX7WP2 9AMAuFmJz9Fwq5rr8J5SZzCgT5vb0h75dbX2AFmfgcVitnh/O7JMaeudKgHGMAwvuRTC fxdjNOOE3bfo7wgqS489GSJUcJDAmlROBvcBDE1lpe7sCTiFDzhaXi0vEg/O+iabym0W 0uRApp9URwbQSuY7JocTUuvBE9ozOjoqJTYdGtAUNpJ08jOYBtKlkNNg6p9fbqdIxRQp xbcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HimRU7Lr; 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 n2si1607290otq.315.2020.02.27.06.11.51; Thu, 27 Feb 2020 06:12:07 -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=HimRU7Lr; 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 S2388741AbgB0OLm (ORCPT + 99 others); Thu, 27 Feb 2020 09:11:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:50214 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388731AbgB0OLl (ORCPT ); Thu, 27 Feb 2020 09:11:41 -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 0446C20801; Thu, 27 Feb 2020 14:11:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582812700; bh=z19uYR+QfCZ8E4oYV9c3VMN4H6XEwgmRfaD1iFIPAIg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HimRU7LrGDFC6SFpUC3yfv9HYW9mZCe+NyUVRqIQRuf/II2fTK9OqqYL0PwZpdDLy n8nYBqIb2+ELzSbUVIX4A3VauVK/8A40s9JTj7oef5LdrzMv9WTkVdlkVtTH+HaHYX XwvDnWntpylMcX/zomAyqyfqSWgSZquC7LXkVAdI= 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 5.4 119/135] bpf, offload: Replace bitwise AND by logical AND in bpf_prog_offload_info_fill Date: Thu, 27 Feb 2020 14:37:39 +0100 Message-Id: <20200227132247.007929056@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200227132228.710492098@linuxfoundation.org> References: <20200227132228.710492098@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 @@ -321,7 +321,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)) {