Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp945639ybm; Fri, 29 May 2020 16:29:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz63S/8OVJwwdW+AnwoC4QpJoWnbd5j1ZY44SZTsgQjG1r/dW2sNQiEJfwLnfQIhzplzXO/ X-Received: by 2002:a17:906:6c82:: with SMTP id s2mr9635093ejr.215.1590794979626; Fri, 29 May 2020 16:29:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590794979; cv=none; d=google.com; s=arc-20160816; b=vXvBZZGHJTsHA/umzioPoHEqKBWXAmW2PfomuLYetEjmIw2g2FS7UROo2yHrA+oOK6 Byw2mvkde44WS8prP/E2arMH5zWySfiDoGazm8VrR6taRUtNBf7mm3vAixBpn9qAbZRK 0zj0ZOLLu/msoOgmXXpqeiYg4+BN2N0SKLxiUHCXRbstqEM5YXn/+TneK6Dt0Khh+env bc3cyun09QfXMqhYuLa8KSJPZFvDb+LN9wEZ5oHbuFqV+NSX4GiRfQZvghMWja7wQpZQ 8tg6AiSGWE814hJqGwzvs5oI0PVgfgeXrZxdqPbK6jIP/6p/Jk5ZPV5cMUdPiZmHdQHa gCXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=mN/yrCSMi1r7L02LK1RKILuxDxvMzoGR5DyR6V3gXK4=; b=X3q6wad22NFtnOHCt4kto1LvIkCLZuat/DDiKYvQhWLnALr9Isfgpk2byGCE0nyz/i 7HkZ+AHpMlkaAAF3NvB0R/0sBN2LhPiSXqmshGRLwm6ZdpizxPv/f/ZyviHUcJMtjN9r 0k4MUhcT89aatrPUGZnfvC4G5KmkbT95hQWTZiB+k0TO4NaJ4vlXQ6r+sh5JDAQE8jbZ FUm5TezUrl8AFw8YB9xokwqvHBiDkW/mytQv8RzglUnTTAu9vZsak5ek4DFwwMP9AdCI quzWuAuPaKVVyYXi4g5bFTctEcx9jpCQxpomzVVgF60DfTpumoIB4zwuZOK4anDTbkOC AJ9w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y14si4716736ejp.357.2020.05.29.16.29.16; Fri, 29 May 2020 16:29:39 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728610AbgE2X1c (ORCPT + 99 others); Fri, 29 May 2020 19:27:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728425AbgE2X1Z (ORCPT ); Fri, 29 May 2020 19:27:25 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 586F8C08C5CB; Fri, 29 May 2020 16:27:25 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.93 #3 (Red Hat Linux)) id 1jeoPL-000Bhm-PJ; Fri, 29 May 2020 23:27:23 +0000 From: Al Viro To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 4/9] binfmt_flat: don't use __put_user() Date: Sat, 30 May 2020 00:27:19 +0100 Message-Id: <20200529232723.44942-4-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200529232723.44942-1-viro@ZenIV.linux.org.uk> References: <20200528234025.GT23230@ZenIV.linux.org.uk> <20200529232723.44942-1-viro@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro ... and check the return value Signed-off-by: Al Viro --- fs/binfmt_flat.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index 831a2b25ba79..7b663ed5247b 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c @@ -138,35 +138,40 @@ static int create_flat_tables(struct linux_binprm *bprm, unsigned long arg_start current->mm->start_stack = (unsigned long)sp & -FLAT_STACK_ALIGN; sp = (unsigned long __user *)current->mm->start_stack; - __put_user(bprm->argc, sp++); + if (put_user(bprm->argc, sp++)) + return -EFAULT; if (IS_ENABLED(CONFIG_BINFMT_FLAT_ARGVP_ENVP_ON_STACK)) { unsigned long argv, envp; argv = (unsigned long)(sp + 2); envp = (unsigned long)(sp + 2 + bprm->argc + 1); - __put_user(argv, sp++); - __put_user(envp, sp++); + if (put_user(argv, sp++) || put_user(envp, sp++)) + return -EFAULT; } current->mm->arg_start = (unsigned long)p; for (i = bprm->argc; i > 0; i--) { - __put_user((unsigned long)p, sp++); + if (put_user((unsigned long)p, sp++)) + return -EFAULT; len = strnlen_user(p, MAX_ARG_STRLEN); if (!len || len > MAX_ARG_STRLEN) return -EINVAL; p += len; } - __put_user(0, sp++); + if (put_user(0, sp++)) + return -EFAULT; current->mm->arg_end = (unsigned long)p; current->mm->env_start = (unsigned long) p; for (i = bprm->envc; i > 0; i--) { - __put_user((unsigned long)p, sp++); + if (put_user((unsigned long)p, sp++)) + return -EFAULT; len = strnlen_user(p, MAX_ARG_STRLEN); if (!len || len > MAX_ARG_STRLEN) return -EINVAL; p += len; } - __put_user(0, sp++); + if (put_user(0, sp++)) + return -EFAULT; current->mm->env_end = (unsigned long)p; return 0; @@ -998,7 +1003,8 @@ static int load_flat_binary(struct linux_binprm *bprm) unsigned long __user *sp; current->mm->start_stack -= sizeof(unsigned long); sp = (unsigned long __user *)current->mm->start_stack; - __put_user(start_addr, sp); + if (put_user(start_addr, sp)) + return -EFAULT; start_addr = libinfo.lib_list[i].entry; } } -- 2.11.0