Received: by 10.223.185.116 with SMTP id b49csp6329090wrg; Wed, 28 Feb 2018 07:39:53 -0800 (PST) X-Google-Smtp-Source: AH8x224II28BGS9xCdeFGHRL9VxJQg6G927Vq0cIlpcqV3em4P1nszS0jftHtBh7c8FRDK5DV2cm X-Received: by 10.98.229.21 with SMTP id n21mr17952235pff.158.1519832392960; Wed, 28 Feb 2018 07:39:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519832392; cv=none; d=google.com; s=arc-20160816; b=YjZ/7sASnx6Ix8BoOE86LTBicu1Xo/3HW0l8UaZBVkwIgoii6OAJkEVxUBGH4aOPSs 0wz7BbapsgdFNNeTVue1V4TD0qCz8xmxSCcoMX3W0HPaurRKuSUNMKFwRgJXxFf4CBJz NNiqO0uXIKTZoN4ap0jgwchUN7l7GPtosRPGKr5Xz8gna2e7DzN6u3O7t883ZVhcYppu q4LlDnD5ezUHualZSaSc8poAGYkcr41VUSdRsAVS0tLHM7LQd6Xme2sT6aES7Z2bCbHN qOR1leqiJy+Yn+kWRrJKNRC8CAVlEeVcmT4jUzW8LBRVuR9M8/xhOCc7BsOOUCpAbj6j UjKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=AdSAMA4KH6FRP1x14C+p6va2zbq9lnMs5zcA+OOoAyI=; b=s/5f1XB350ET4mePrFjMOLKAorF7r7GToDnSTP124FTMZY8sjxvsGvCKpFoayshKo1 kuWkZq/mTJ2S+rrHcWYwe1Zeblg89JO53+x9ZVWuLfVyQMmle5Gd36qTqOOogVnby/f5 RAWv8CXnzXlDCkSS/w3ie//rp0mQHunszDeyshvVR0XmrzyBYmLmlc2RyFz/BBdV87vL z7rbvN0fZBIh8/nfSPTONSWHaDA1WBB6blutgbBDSG5mtrTr69BwpkQvBW8q5lybUgH4 AXBhKh7WkR8v/kCBlZh9yA246glKa7sIxcWRsrcQtPP6DoZ/DEOXIvsMabnlefHdpVmQ oATw== 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 x15-v6si1465532pll.113.2018.02.28.07.39.38; Wed, 28 Feb 2018 07:39:52 -0800 (PST) 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 S933319AbeB1Pgq (ORCPT + 99 others); Wed, 28 Feb 2018 10:36:46 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:33241 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752756AbeB1PWe (ORCPT ); Wed, 28 Feb 2018 10:22:34 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1er3Yf-0006XR-I7; Wed, 28 Feb 2018 15:22:17 +0000 Received: from ben by deadeye with local (Exim 4.90_1) (envelope-from ) id 1er3Ye-0008RS-Jw; Wed, 28 Feb 2018 15:22:16 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Martin Schwidefsky" , "Heiko Carstens" Date: Wed, 28 Feb 2018 15:20:18 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 055/254] s390: always save and restore all registers on context switch In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.55-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Heiko Carstens commit fbbd7f1a51965b50dd12924841da0d478f3da71b upstream. The switch_to() macro has an optimization to avoid saving and restoring register contents that aren't needed for kernel threads. There is however the possibility that a kernel thread execve's a user space program. In such a case the execve'd process can partially see the contents of the previous process, which shouldn't be allowed. To avoid this, simply always save and restore register contents on context switch. Fixes: fdb6d070effba ("switch_to: dont restore/save access & fpu regs for kernel threads") Signed-off-by: Heiko Carstens Signed-off-by: Martin Schwidefsky [bwh: Backported to 3.16: - The save/restore functions are different here - FP restore is non-lazy, so drop the comment about it being lazy] Signed-off-by: Ben Hutchings --- --- a/arch/s390/include/asm/switch_to.h +++ b/arch/s390/include/asm/switch_to.h @@ -117,21 +117,17 @@ static inline void restore_access_regs(u asm volatile("lam 0,15,%0" : : "Q" (*(acrstype *)acrs)); } -#define switch_to(prev,next,last) do { \ - if (prev->mm) { \ - save_fp_ctl(&prev->thread.fp_regs.fpc); \ - save_fp_regs(prev->thread.fp_regs.fprs); \ - save_access_regs(&prev->thread.acrs[0]); \ - save_ri_cb(prev->thread.ri_cb); \ - } \ +#define switch_to(prev, next, last) do { \ + save_fp_ctl(&prev->thread.fp_regs.fpc); \ + save_fp_regs(prev->thread.fp_regs.fprs); \ + save_access_regs(&prev->thread.acrs[0]); \ + save_ri_cb(prev->thread.ri_cb); \ update_cr_regs(next); \ - if (next->mm) { \ - restore_fp_ctl(&next->thread.fp_regs.fpc); \ - restore_fp_regs(next->thread.fp_regs.fprs); \ - restore_access_regs(&next->thread.acrs[0]); \ - restore_ri_cb(next->thread.ri_cb, prev->thread.ri_cb); \ - } \ - prev = __switch_to(prev,next); \ + restore_fp_ctl(&next->thread.fp_regs.fpc); \ + restore_fp_regs(next->thread.fp_regs.fprs); \ + restore_access_regs(&next->thread.acrs[0]); \ + restore_ri_cb(next->thread.ri_cb, prev->thread.ri_cb); \ + prev = __switch_to(prev, next); \ } while (0) #endif /* __ASM_SWITCH_TO_H */