Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1665551ybh; Tue, 14 Jul 2020 04:11:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOdo5ss4pej9GrD0T6Fs5KsJnDSIiloVQJBG6+Dni/nTyQ2eT/b6F+cBIT/joCYN+2R4Ui X-Received: by 2002:a17:906:492:: with SMTP id f18mr3944305eja.279.1594725115227; Tue, 14 Jul 2020 04:11:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594725115; cv=none; d=google.com; s=arc-20160816; b=iaD/JdNS4kvj3YfhVyzLJItHpLuqQiq02xiabujrpnFpeb4r/x3yvc79h7YWcVrh/0 GmjqMx7mkX+BRUk9jB8qkvSASr1SWwdSCg7cDfNRSLWF9lGOAqJnVbw32Q52+H3sd5/x i9HbJxjNBeWiTRsG1YBQR2MuTE0esrRjZM6PKvjobXkAcEpJJ5pqlEJJeTvG6Je8NdAb KvlkN+y6yGOhHbGeSEmHVnxlYqcSkPSjOjiFxSeNqN03HbR3ORa3zZZt9zeYfsab2Ole mZCfEte4U/zqRjq/O+1Tu55Ebo8LowmzHMLar77PPim1oyCZtZi+Bjxy4UJGvHLV0rjp aUuA== 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 :dkim-signature; bh=aA679qIodiBpC5vbULiwbVKx3fOumlOYyYuEKhecoTI=; b=e4L5eBPeEf42YD4uecKnSnPtR8f20+gtkE6nh+UlbiDNAUuShfpHEwRpvd8YekNqPe dx1sYxvK472OCANojYkUnTHPR6NatypHZtDeMx+IeahgxIVEDA505yue3Ju9F193sn/c OBeLt4NOdtouTTNze9emcAapes4vYyStXFPZWUF7NFWvDK0Ds2yQ3kYf3/0kvWEgVpCn R02ZCAna4cJEdBBJhBly+doaQhk/8VEEeDSotkb4Mpd6ApCPtWVt45QfqPsVrW0cdsPd iABiU5rUH+Ubpsjl6y/cz9FZS3Qa+Zd6UsuoMDsicy/i8gU9sa2DZUpdwtlcxtb9fik4 keVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=I23oUhor; 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 mc14si10663826ejb.282.2020.07.14.04.11.30; Tue, 14 Jul 2020 04:11:55 -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=fail header.i=@infradead.org header.s=casper.20170209 header.b=I23oUhor; 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 S1727829AbgGNLKf (ORCPT + 99 others); Tue, 14 Jul 2020 07:10:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726252AbgGNLKe (ORCPT ); Tue, 14 Jul 2020 07:10:34 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63AFEC061755; Tue, 14 Jul 2020 04:10:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=aA679qIodiBpC5vbULiwbVKx3fOumlOYyYuEKhecoTI=; b=I23oUhorQvkUc3pKxqW65dWZKi 2fvnRyOEcYQiwRX71KaxF5fb1WDG9GhMZ0whjJ4vniWBpxRO+H4GEqTsMWqFwK88N8jITuk5W5dzq 964ngvwoNriO55HokZ0KVUAATgpYwv7/l2gjlugolwHLuVj7WlJlE//60NlcNcyzqauvWByDcKjSJ 7Fv51WGpAXn+LU5rCKIO7zOLWNs/SrNcTp5pWrbsbYxma8sEaB72+1iDJlLGTd2VnQ97nIKoe1xMK eTx5w1U1nwg7BYSroNLCMEwFnKIR79GysRyZxtpMg5ya2xRvud3GD+pkGvH1WKaGvX+CzkoWoN/aS XwKN5xUQ==; Received: from 089144201169.atnat0010.highway.a1.net ([89.144.201.169] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvIpP-0006Ta-Mr; Tue, 14 Jul 2020 11:10:28 +0000 From: Christoph Hellwig To: Nick Hu , Greentime Hu , Vincent Chen , Paul Walmsley , Palmer Dabbelt , Andrew Morton , Linus Torvalds Cc: linux-riscv@lists.infradead.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/6] exec: use force_uaccess_begin during exec and exit Date: Tue, 14 Jul 2020 12:55:05 +0200 Message-Id: <20200714105505.935079-7-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200714105505.935079-1-hch@lst.de> References: <20200714105505.935079-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Both exec and exit want to ensure that the uaccess routines actually do access user pointers. Use the newly added force_uaccess_begin helper instead of an open coded set_fs for that to prepare for kernel builds where set_fs() does not exist. Signed-off-by: Christoph Hellwig --- fs/exec.c | 7 ++++++- kernel/exit.c | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index e6e8a9a7032784..769af470b69124 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1380,7 +1380,12 @@ int begin_new_exec(struct linux_binprm * bprm) if (retval) goto out_unlock; - set_fs(USER_DS); + /* + * Ensure that the uaccess routines can actually operate on userspace + * pointers: + */ + force_uaccess_begin(); + me->flags &= ~(PF_RANDOMIZE | PF_FORKNOEXEC | PF_KTHREAD | PF_NOFREEZE | PF_NO_SETAFFINITY); flush_thread(); diff --git a/kernel/exit.c b/kernel/exit.c index 727150f2810338..17d486a20f0dc6 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -731,7 +731,7 @@ void __noreturn do_exit(long code) * mm_release()->clear_child_tid() from writing to a user-controlled * kernel address. */ - set_fs(USER_DS); + force_uaccess_begin(); if (unlikely(in_atomic())) { pr_info("note: %s[%d] exited with preempt_count %d\n", -- 2.26.2