Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp100106ybm; Thu, 28 May 2020 17:13:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBU4JMkKsbnNAXkc5iCzJxZZ824g+pSBpTTwm3iRGhYzZCPb2V84qjdXt01v6xK7R8oV25 X-Received: by 2002:a17:906:da05:: with SMTP id fi5mr5551250ejb.95.1590711182289; Thu, 28 May 2020 17:13:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590711182; cv=none; d=google.com; s=arc-20160816; b=jDoGZAE867GigQqVoB+oypcvL18Vx6eOcmXnPyOhw5DnCH247lRT3PcgdJwd36tIGg 5E4QK0KwS76IQVcQPtcWH3kCTBOcfRac7WjgkQkzjZmoylbtKQFHmhsEMkVYE57+JxFH a8jKUYcpErKcWGcw8txlGkem3+P3NoYweOqa5h6kZrd3/8yhuQXKukZuIwoqWMr8mTP6 REpDf2hsKDi/5QDdPsHcud2V8Q4apqSAu/E+4IqDWdEh45OTfmTqKTTNZEJJJix9G2jQ Z9Aa/Mn4SPPUzrlcNfVRpKWEm3WTSDKf0vCjsAt1ryEr/oypmEQ1xZxH3BigaluYToRM gTfg== 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=w3D6aGE6QxwLAtCQvb3gFMM3Qh2KmFj8wHqQmvjAdO4=; b=d0njRsYIU4jnbE7AVGn+c0Fe8serMFGwlFdWfTy8qVaAjIL3YzXheNOtT4Cdyng9U3 bFhIKCc4iW9dvXuwKZdtKC1wpgpkiYSgZxXwz4jG0NklFOGuJDP7k86aZa1JlBwdChP4 SQ6LPFDEFP+x7mbGfH9IBGA/ZIdWVt+8dgNgN4XypjFMhfX4G2ukIe8t49mBS4iLlciT mDQYyJ4/gDOKqKSQTuyNQYqi0oM0hG28teULQiWps9GTEo9n7H4UqB+d5PjYdiaQYFFh dzAKO8JGcIaKGdmdhWHYyw4kZuibGS63TVcmiWXjC1/KgOaC1FSavvZKsvFB+PUlqsh1 pxNA== 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 l6si4756167ejx.387.2020.05.28.17.12.39; Thu, 28 May 2020 17:13:02 -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 S2438006AbgE2AKs (ORCPT + 99 others); Thu, 28 May 2020 20:10:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438050AbgE2AK0 (ORCPT ); Thu, 28 May 2020 20:10:26 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59B07C08C5C8; Thu, 28 May 2020 17:10:25 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.93 #3 (Red Hat Linux)) id 1jeSbP-00HEZS-80; Fri, 29 May 2020 00:10:23 +0000 From: Al Viro To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 1/3] compat sysinfo(2): don't bother with field-by-field copyout Date: Fri, 29 May 2020 01:10:21 +0100 Message-Id: <20200529001023.4107547-1-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200529000957.GW23230@ZenIV.linux.org.uk> References: <20200529000957.GW23230@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 Signed-off-by: Al Viro --- kernel/sys.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/kernel/sys.c b/kernel/sys.c index d325f3ab624a..b4a0324a0699 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -2634,6 +2634,7 @@ struct compat_sysinfo { COMPAT_SYSCALL_DEFINE1(sysinfo, struct compat_sysinfo __user *, info) { struct sysinfo s; + struct compat_sysinfo s_32; do_sysinfo(&s); @@ -2658,23 +2659,23 @@ COMPAT_SYSCALL_DEFINE1(sysinfo, struct compat_sysinfo __user *, info) s.freehigh >>= bitcount; } - if (!access_ok(info, sizeof(struct compat_sysinfo)) || - __put_user(s.uptime, &info->uptime) || - __put_user(s.loads[0], &info->loads[0]) || - __put_user(s.loads[1], &info->loads[1]) || - __put_user(s.loads[2], &info->loads[2]) || - __put_user(s.totalram, &info->totalram) || - __put_user(s.freeram, &info->freeram) || - __put_user(s.sharedram, &info->sharedram) || - __put_user(s.bufferram, &info->bufferram) || - __put_user(s.totalswap, &info->totalswap) || - __put_user(s.freeswap, &info->freeswap) || - __put_user(s.procs, &info->procs) || - __put_user(s.totalhigh, &info->totalhigh) || - __put_user(s.freehigh, &info->freehigh) || - __put_user(s.mem_unit, &info->mem_unit)) + memset(&s_32, 0, sizeof(s_32)); + s_32.uptime = s.uptime; + s_32.loads[0] = s.loads[0]; + s_32.loads[1] = s.loads[1]; + s_32.loads[2] = s.loads[2]; + s_32.totalram = s.totalram; + s_32.freeram = s.freeram; + s_32.sharedram = s.sharedram; + s_32.bufferram = s.bufferram; + s_32.totalswap = s.totalswap; + s_32.freeswap = s.freeswap; + s_32.procs = s.procs; + s_32.totalhigh = s.totalhigh; + s_32.freehigh = s.freehigh; + s_32.mem_unit = s.mem_unit; + if (copy_to_user(info, &s_32, sizeof(s_32))) return -EFAULT; - return 0; } #endif /* CONFIG_COMPAT */ -- 2.11.0