Received: by 10.213.65.68 with SMTP id h4csp897580imn; Tue, 27 Mar 2018 10:47:27 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+JzQukEkpRELRX4m+MaHXCqafjuSfwQ0irQE9eKypgW0l9naRC5Y//n1uUHN2iOdrZ5GSl X-Received: by 10.99.3.216 with SMTP id 207mr172932pgd.163.1522172847261; Tue, 27 Mar 2018 10:47:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522172847; cv=none; d=google.com; s=arc-20160816; b=XkVzMR4JjPEK8j7wqiDHXX+yUXyXBMLo2nOLHtumyXzxBpgayjuKYRXKOr9rbNcIO/ TDah7DUurBnazn25F34Z6JObDTYVy0V88FQZYLq38YMx69+cHudHC5co8ll7vFn8yhCO /zmtSK1tVx75oGQuX55P5oIDhUzwYfiKy9tCE+DNDMPRL7k2W+FNMXBOMiYDdx0fv7Oc 6d3GCeBUdSHLeBh04Nn88sC1z7qopvVHfDGGnLaLkulRqXQ7MfG2ELZ5UVd+kJ2UWr1L j3tYtm1ejJn6LjzGSpbbQ7t8ZVPS8ONLnBJK26GH1CHRCaPpvvu6A5EAOhe9G1/Ay6S1 BXbw== 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=0AK0UeJjyN0XcGdG9n1rN4ZutOvQKbLdnSkUUxdirv4=; b=MBzXdULcj0lo8mR8qEiQcUhFo0eOzTGvF6yhUtMKuL3Q01OotAumGg8SVWUK/3Z5Rs fbTLh/rGrr9OfzMwpt0C0WFokYjGIT70nAula5/fjZVYNmMLKldi+EBAHR3JaVvQrL+H HGh53o2g0d9qWi17QTqUc36oPY/x1JygnFcSP19sxHI+l2ulak1g6K+vvhCSSgmEnZ3J WiAqWWwlgV6SLYbsspb/iXYZ+IRPHs0Yzc3wmoBT0Fv9s2m61bSApGOCUxtav27EJMxV 2Z6LKSsmmtasTBGpCQdpyBGjOGGelnmJRBYqLkXyOR1b5pDuH6hNHpu4kyPD7Ksq1sMp PWlw== 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 85si1223198pfz.271.2018.03.27.10.47.13; Tue, 27 Mar 2018 10:47:27 -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 S1753896AbeC0QdP (ORCPT + 99 others); Tue, 27 Mar 2018 12:33:15 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:43784 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753883AbeC0QdN (ORCPT ); Tue, 27 Mar 2018 12:33:13 -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 F38BEFE1; Tue, 27 Mar 2018 16:33:12 +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.9 42/67] staging: ncpfs: memory corruption in ncp_read_kernel() Date: Tue, 27 Mar 2018 18:27:34 +0200 Message-Id: <20180327162729.358274883@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180327162726.702411083@linuxfoundation.org> References: <20180327162726.702411083@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.9-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);