Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2328866imm; Fri, 7 Sep 2018 14:46:01 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYt1HAzs2KNgQQVpDNpdTYAR/8H0bbNlFK9jimJjJALp5rTSkQ4Fk4REK2B5bfC0K0P+8J2 X-Received: by 2002:a17:902:9a83:: with SMTP id w3-v6mr10262279plp.75.1536356761871; Fri, 07 Sep 2018 14:46:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536356761; cv=none; d=google.com; s=arc-20160816; b=GeHW4Zkp/gPExd893C7VI9QCqITnZRlqVtmJs7e1C8XacZBIjeNykgNAUhUWESeFox 38IjHlGf197LIb/PuKoR9ue1/YSYeM3CeY/XI5yyw+bmPVFSBiX4mVMpySnT+tyu8WCE ZGXLCk9xSRZl8MGdwo6+HahqenwvC1yZT1SH8rIMJW505GNTdSuHDUgccfaFNuxU34AW xTRYXGfqRHkb8vA+PkmhKA6q60UpbVMD7n6m9uXI50yo0R8q0Rh6ZUzaRnHMNCGuzPMj zz7yQJsa5PoVUKAfZGvExJOb5SBQROjPrd2nhP8U8wTd70uOhnW33+UdUEx5PJOCjvlN EyPw== 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; bh=DZ0ONNsR8XMCZknAR1z4tcn4JH6PEi/MwIE/kjkW/ic=; b=BmDddULlm4MILg9TrqQM+D4qntmLuhIM7gJ7IRNXUQNt4feaBPbISwZqFxkFWxVT/H f7kGLXcmeST4nDoWjqoKK5Z/RmPo9zwxCKHLBRTEcZl4iCaAD9Qi6WfH4M6ycH4Fr7eL xm71sKuZDU+AScECVAp8sOlxcoeg5+Z+gKomqmOwr9s6/YHx5bFrVgtn6QJPjkB0qga9 uvH6WqxRadu1+LsYUFEV1zZ+llzUU/Jp3fECIhfmaCVo/Fi2MKX9kFdqU5GGpDT88tJK NuV6Osht/zydLHjYZPMBfRyDPCKoqag3OoBsjY0u/mlYBapiBIovomNdfXOMTdXty+Fc zmaQ== 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 a93-v6si9294053pla.277.2018.09.07.14.45.46; Fri, 07 Sep 2018 14:46: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 S1730890AbeIHC00 (ORCPT + 99 others); Fri, 7 Sep 2018 22:26:26 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:56908 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729993AbeIHC0Z (ORCPT ); Fri, 7 Sep 2018 22:26:25 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 84F52C9A; Fri, 7 Sep 2018 21:43:29 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Viro Subject: [PATCH 3.18 18/29] osf_getdomainname(): use copy_to_user() Date: Fri, 7 Sep 2018 23:10:39 +0200 Message-Id: <20180907210910.816346587@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180907210909.523240901@linuxfoundation.org> References: <20180907210909.523240901@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 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Al Viro commit 9ba3eb5103cf56f0daaf07de4507df76e7813ed7 upstream. Signed-off-by: Al Viro Signed-off-by: Greg Kroah-Hartman --- arch/alpha/kernel/osf_sys.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) --- a/arch/alpha/kernel/osf_sys.c +++ b/arch/alpha/kernel/osf_sys.c @@ -560,25 +560,20 @@ SYSCALL_DEFINE0(getdtablesize) */ SYSCALL_DEFINE2(osf_getdomainname, char __user *, name, int, namelen) { - unsigned len; - int i; + int len, err = 0; + char *kname; - if (!access_ok(VERIFY_WRITE, name, namelen)) - return -EFAULT; - - len = namelen; - if (len > 32) - len = 32; + if (namelen > 32) + namelen = 32; down_read(&uts_sem); - for (i = 0; i < len; ++i) { - __put_user(utsname()->domainname[i], name + i); - if (utsname()->domainname[i] == '\0') - break; - } + kname = utsname()->domainname; + len = strnlen(kname, namelen); + if (copy_to_user(name, kname, min(len + 1, namelen))) + err = -EFAULT; up_read(&uts_sem); - return 0; + return err; } /*