Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754655AbdFEQec (ORCPT ); Mon, 5 Jun 2017 12:34:32 -0400 Received: from www.llwyncelyn.cymru ([82.70.14.225]:53086 "EHLO fuzix.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754083AbdFEQe3 (ORCPT ); Mon, 5 Jun 2017 12:34:29 -0400 Date: Mon, 5 Jun 2017 17:34:16 +0100 From: Alan Cox To: Adam Borowski Cc: Greg Kroah-Hartman , Jiri Slaby , linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/5] vt: use copy_to_user instead of __put_user in GIO_UNIMAP ioctl Message-ID: <20170605173416.73da4975@lxorguk.ukuu.org.uk> In-Reply-To: <20170603073509.4718-3-kilobyte@angband.pl> References: <20170603073255.zgpfmdp2pqusz4qw@angband.pl> <20170603073509.4718-1-kilobyte@angband.pl> <20170603073509.4718-3-kilobyte@angband.pl> Organization: Intel Corporation X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 649 Lines: 21 > @@ -775,13 +775,11 @@ int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct, struct uni > } > } > console_unlock(); > - for (i = min(ect, ct), plist = unilist; i; i--, list++, plist++) { > - __put_user(plist->unicode, &list->unicode); > - __put_user(plist->fontpos, &list->fontpos); > - } > - __put_user(ect, uct); > + if (copy_to_user(list, unilist, min(ect, ct) * sizeof(struct unipair))) > + ret = -EFAULT; > + put_user(ect, uct); > kfree(unilist); > - return ((ect <= ct) ? 0 : -ENOMEM); > + return ret ? ret : (ect <= ct) ? 0 : -ENOMEM; > } The rest looks good but that line needs taking out and shooting. Alan