Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3316206pxf; Mon, 15 Mar 2021 07:01:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwA3+eIB1QSXlnTfPwYbqPQR6s9gbtRjoUvEyVZTAFUrGfUBaKGIlDTKEBzRlFqtDbHsG2a X-Received: by 2002:aa7:d4d2:: with SMTP id t18mr30172405edr.342.1615816909191; Mon, 15 Mar 2021 07:01:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615816909; cv=none; d=google.com; s=arc-20160816; b=T8zD3i2aq42YReQm6Sanl6SuIwU6Z50+37ELdFv8jOHi1072v1gAtGLpbcJ67nK4/n q6nS3ODZVNZOQjnmK1r5whJAQWIifAf9A5HUsNiwtytFgr2o3ZjrRIli4vksefGEiZko XfopcYDcYUsIt3TVwMeCLZA0Qc9IgUU3cgjzwrZur+l7RwpzDjlENg2LrIjh59plRT5r icjR8ItEoW79w+y5VM8NW86J7aS2Tl89SK8YQuPXID9951H3p10rUBXIoFn2Df6R2Gzz q3slSxjIiw7ls+evok/5jtkGss8fkh3ZJCs+DiDlCgDP0pIIeqoCbF+pRtUHBimwcP5v AIBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NLUjS2+ygPdTc8W7KvGd7z1mTNlgVVtzgNq1At1rN2k=; b=PyhzJZ0MnlV4IR3IdOgb3yVbvYMturmO82co1/A6YEEPnkBtwtKj95BMuD+jqzDbTD IdBev/ETD+QvkRoGCuY1LQ6YfpveOt9StoyyxL2U6HmhTN5RuKpMyrBv7wEiSqDv0zkJ IgBsEAbQxd8GNLs0b9UskBMxzyx2M+V/4mf5NINBo150rx961iwbSvyirwsv9BrN5bwz TVMS3dN5uIdKmVVBkjJpa+dTEHPF/AW9cc543o3lBUgZy5EbbchuwjHmyDzY0XOx8keY 0BAkCQ+FNqs9XJib+51qgrAyiBjkpYDe0pIIjzOMWnQEiYPGaVOWWMo1uCF5qqEH2SqP +K7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ki6ImO91; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g5si11013302edy.61.2021.03.15.07.01.25; Mon, 15 Mar 2021 07:01:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ki6ImO91; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232362AbhCON63 (ORCPT + 99 others); Mon, 15 Mar 2021 09:58:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:58268 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231545AbhCONyg (ORCPT ); Mon, 15 Mar 2021 09:54:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6C89E64EED; Mon, 15 Mar 2021 13:54:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816475; bh=DM80zCVAqR7ECdY7KHXj1Y3CaTwgKu9kBTUJIY+O3Z4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ki6ImO91hMWaEpWKAfa/EINJtifeuzeclUGdykAbS47Nic30iLCA0ki7LHQAMFC6n XYIBfN9iR5NifL2hViXyOzCDnYhcNjBE0OR/C4hYpW8gNRdCMKbenWa1Wj23iiVivn PxJYY3hlprOwFsVHJ2n3pqdlwtDMvBpagbF02Eg0= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Viro , Guenter Roeck Subject: [PATCH 4.4 66/75] alpha: get rid of tail-zeroing in __copy_user() Date: Mon, 15 Mar 2021 14:52:20 +0100 Message-Id: <20210315135210.417715043@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135208.252034256@linuxfoundation.org> References: <20210315135208.252034256@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Al Viro commit 085354f907969fb3ee33f236368f6e1dd4c74d62 upstream. ... and adjust copy_from_user() accordingly Signed-off-by: Al Viro Cc: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- arch/alpha/include/asm/uaccess.h | 9 +++++---- arch/alpha/lib/copy_user.S | 16 +--------------- arch/alpha/lib/ev6-copy_user.S | 23 +---------------------- 3 files changed, 7 insertions(+), 41 deletions(-) --- a/arch/alpha/include/asm/uaccess.h +++ b/arch/alpha/include/asm/uaccess.h @@ -396,11 +396,12 @@ copy_to_user(void __user *to, const void extern inline long copy_from_user(void *to, const void __user *from, long n) { + long res = n; if (likely(__access_ok((unsigned long)from, n, get_fs()))) - n = __copy_tofrom_user_nocheck(to, (__force void *)from, n); - else - memset(to, 0, n); - return n; + res = __copy_from_user_inatomic(to, from, n); + if (unlikely(res)) + memset(to + (n - res), 0, res); + return res; } extern void __do_clear_user(void); --- a/arch/alpha/lib/copy_user.S +++ b/arch/alpha/lib/copy_user.S @@ -126,22 +126,8 @@ $65: bis $31,$31,$0 $41: $35: -$exitout: - ret $31,($28),1 - $exitin: - /* A stupid byte-by-byte zeroing of the rest of the output - buffer. This cures security holes by never leaving - random kernel data around to be copied elsewhere. */ - - mov $0,$1 -$101: - EXO ( ldq_u $2,0($6) ) - subq $1,1,$1 - mskbl $2,$6,$2 - EXO ( stq_u $2,0($6) ) - addq $6,1,$6 - bgt $1,$101 +$exitout: ret $31,($28),1 .end __copy_user --- a/arch/alpha/lib/ev6-copy_user.S +++ b/arch/alpha/lib/ev6-copy_user.S @@ -228,33 +228,12 @@ $dirtyentry: bgt $0,$onebyteloop # U .. .. .. : U L U L $zerolength: +$exitin: $exitout: # Destination for exception recovery(?) nop # .. .. .. E nop # .. .. E .. nop # .. E .. .. ret $31,($28),1 # L0 .. .. .. : L U L U -$exitin: - - /* A stupid byte-by-byte zeroing of the rest of the output - buffer. This cures security holes by never leaving - random kernel data around to be copied elsewhere. */ - - nop - nop - nop - mov $0,$1 - -$101: - EXO ( stb $31,0($6) ) # L - subq $1,1,$1 # E - addq $6,1,$6 # E - bgt $1,$101 # U - - nop - nop - nop - ret $31,($28),1 # L0 - .end __copy_user EXPORT_SYMBOL(__copy_user)