From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755725AbcHXPTl (ORCPT ); Wed, 24 Aug 2016 11:19:41 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:20091 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753773AbcHXPTj (ORCPT ); Wed, 24 Aug 2016 11:19:39 -0400 X-IBM-Helo: d06dlp01.portsmouth.uk.ibm.com X-IBM-MailFrom: borntraeger@de.ibm.com X-IBM-RcptTo: kernel-janitors@vger.kernel.org;kvm@vger.kernel.org;linux-kernel@vger.kernel.org;linux-s390@vger.kernel.org Subject: Re: [PATCH 2/4] KVM-S390: Use memdup_user() rather than duplicating its implementation To: SF Markus Elfring , kvm@vger.kernel.org, linux-s390@vger.kernel.org, Cornelia Huck , David Hildenbrand , Heiko Carstens , Martin Schwidefsky , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= References: <82b84c9c-38a4-4d17-910f-312668dbae01@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: Christian Borntraeger Date: Wed, 24 Aug 2016 11:19:28 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16082415-0020-0000-0000-00000237352D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16082415-0021-0000-0000-00003DBF7733 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-08-24_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1608240141 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/17/2016 02:08 PM, SF Markus Elfring wrote: > From: Markus Elfring > Date: Wed, 17 Aug 2016 18:41:43 +0200 > > * Reuse existing functionality from memdup_user() instead of keeping > duplicate source code. > > This issue was detected by using the Coccinelle software. > > * Return directly if this copy operation failed. > > Signed-off-by: Markus Elfring I was going to apply this patch, but it probably makes sense to respin the first patch first as suggested to avoid me fixing up the conflicts and then you fixing up the new conflict. So can you respin patch 1,2 as suggested and add the acks/rb for patch 2? > --- > arch/s390/kvm/guestdbg.c | 13 +++---------- > 1 file changed, 3 insertions(+), 10 deletions(-) > > diff --git a/arch/s390/kvm/guestdbg.c b/arch/s390/kvm/guestdbg.c > index b68db4b..8f886ee 100644 > --- a/arch/s390/kvm/guestdbg.c > +++ b/arch/s390/kvm/guestdbg.c > @@ -217,16 +217,9 @@ int kvm_s390_import_bp_data(struct kvm_vcpu *vcpu, > return -EINVAL; > > size = dbg->arch.nr_hw_bp * sizeof(*bp_data); > - bp_data = kmalloc(size, GFP_KERNEL); > - if (!bp_data) { > - ret = -ENOMEM; > - goto error; > - } > - > - if (copy_from_user(bp_data, dbg->arch.hw_bp, size)) { > - ret = -EFAULT; > - goto error; > - } > + bp_data = memdup_user(dbg->arch.hw_bp, size); > + if (IS_ERR(bp_data)) > + return PTR_ERR(bp_data); > > for (i = 0; i < dbg->arch.nr_hw_bp; i++) { > switch (bp_data[i].type) { > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christian Borntraeger Date: Wed, 24 Aug 2016 15:19:28 +0000 Subject: Re: [PATCH 2/4] KVM-S390: Use memdup_user() rather than duplicating its implementation Message-Id: List-Id: References: <82b84c9c-38a4-4d17-910f-312668dbae01@users.sourceforge.net> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: SF Markus Elfring , kvm@vger.kernel.org, linux-s390@vger.kernel.org, Cornelia Huck , David Hildenbrand , Heiko Carstens , Martin Schwidefsky , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall On 08/17/2016 02:08 PM, SF Markus Elfring wrote: > From: Markus Elfring > Date: Wed, 17 Aug 2016 18:41:43 +0200 > > * Reuse existing functionality from memdup_user() instead of keeping > duplicate source code. > > This issue was detected by using the Coccinelle software. > > * Return directly if this copy operation failed. > > Signed-off-by: Markus Elfring I was going to apply this patch, but it probably makes sense to respin the first patch first as suggested to avoid me fixing up the conflicts and then you fixing up the new conflict. So can you respin patch 1,2 as suggested and add the acks/rb for patch 2? > --- > arch/s390/kvm/guestdbg.c | 13 +++---------- > 1 file changed, 3 insertions(+), 10 deletions(-) > > diff --git a/arch/s390/kvm/guestdbg.c b/arch/s390/kvm/guestdbg.c > index b68db4b..8f886ee 100644 > --- a/arch/s390/kvm/guestdbg.c > +++ b/arch/s390/kvm/guestdbg.c > @@ -217,16 +217,9 @@ int kvm_s390_import_bp_data(struct kvm_vcpu *vcpu, > return -EINVAL; > > size = dbg->arch.nr_hw_bp * sizeof(*bp_data); > - bp_data = kmalloc(size, GFP_KERNEL); > - if (!bp_data) { > - ret = -ENOMEM; > - goto error; > - } > - > - if (copy_from_user(bp_data, dbg->arch.hw_bp, size)) { > - ret = -EFAULT; > - goto error; > - } > + bp_data = memdup_user(dbg->arch.hw_bp, size); > + if (IS_ERR(bp_data)) > + return PTR_ERR(bp_data); > > for (i = 0; i < dbg->arch.nr_hw_bp; i++) { > switch (bp_data[i].type) { >