Received: by 10.213.65.68 with SMTP id h4csp913246imn; Tue, 27 Mar 2018 11:05:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx49iipRILby5qPVFV5YLuo4kHna3PCCXK/UViCbPIO1EpTze3i0OukjqedarXIIa6WBMtX6N X-Received: by 10.99.160.25 with SMTP id r25mr201301pge.95.1522173901189; Tue, 27 Mar 2018 11:05:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522173901; cv=none; d=google.com; s=arc-20160816; b=jXG01c6eiHPDMota4siW1Sf11JPzGqVarn2St8WitCA0MM8SfGC8m3pu4bbT4KCFNH mh+YqTqpf5ShEtn218fV0v3V3KJFJ6PJUvieCET4NkTJeUr0vDCQJTPue2ffaZedDlyD 3vPOmmUtRE9QEkabeDfi9l245fV0rTkl5WiDQWbtVkZkx1ivMFIU/8n9iIic/KP+k+pb n4ahXRaU5aM4Zyk94NWbXrHMCzMsApd2gkIAi8FLzxJveS91RWu8KHJGSmjqr2gvSg5r rTD6Y0qs45E+qjFYKlg1GcTMZprF2leO6Tau9THx18OAQetlbxUybCFLS/zGzF2AXE9o SBPw== 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=92zqMNzu+3L+l1X9lqgjOAPtcEPGtOE3lRHC+a/3x0E=; b=C1DK/Jc/L9v8gGwKySSuQXjXPhR44AjOKTR1Vqfac9KKkpbI53oXkjywJILw2F1+At v0S7d+GRjCepGbbpxZ0LV3iRQzK7JbLACubNW+UDY6jIO7fmQBAuQ3RaxyNBKxo68CZT zFvGJi8Moyt0NmOiXodoLNyYIDuucE5taGZ8vx2uimGk1seKJiMiheylzTpQ1Kul7Jmz M44+nU4KeDpiKdnb7lmHYukfYZeRdGWx4OAzon1HMTp+Fq2NNx4fzGaKEgnRWUB4LIzj junU/L4sUrFQ6RdgiR+M8RYseVmBl3UV3rSoN46A0n5EJBEEwdNxahJ/XKPN9wKBdiF3 iawg== 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 y1-v6si1780855pli.586.2018.03.27.11.04.46; Tue, 27 Mar 2018 11:05:01 -0700 (PDT) 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 S1752860AbeC0Q3v (ORCPT + 99 others); Tue, 27 Mar 2018 12:29:51 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:41444 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752712AbeC0Q3j (ORCPT ); Tue, 27 Mar 2018 12:29:39 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 97F6D1116; Tue, 27 Mar 2018 16:29:38 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter Subject: [PATCH 4.4 30/43] staging: ncpfs: memory corruption in ncp_read_kernel() Date: Tue, 27 Mar 2018 18:27:34 +0200 Message-Id: <20180327162718.108104061@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180327162716.407986916@linuxfoundation.org> References: <20180327162716.407986916@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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: Dan Carpenter commit 4c41aa24baa4ed338241d05494f2c595c885af8f upstream. If the server is malicious then *bytes_read could be larger than the size of the "target" buffer. It would lead to memory corruption when we do the memcpy(). Reported-by: Dr Silvio Cesare of InfoSect Signed-off-by: Dan Carpenter Cc: stable Signed-off-by: Greg Kroah-Hartman --- fs/ncpfs/ncplib_kernel.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/fs/ncpfs/ncplib_kernel.c +++ b/fs/ncpfs/ncplib_kernel.c @@ -980,6 +980,10 @@ ncp_read_kernel(struct ncp_server *serve goto out; } *bytes_read = ncp_reply_be16(server, 0); + if (*bytes_read > to_read) { + result = -EINVAL; + goto out; + } source = ncp_reply_data(server, 2 + (offset & 1)); memcpy(target, source, *bytes_read);