Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp26045imm; Thu, 28 Jun 2018 14:10:05 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL2UdxAjzoMCIdLkvGcfgGaMP6BtwfkId5UhrRKrFeTG0kwjAJ9Kb99MFnLAwLpp6fG97zg X-Received: by 2002:a17:902:6bca:: with SMTP id m10-v6mr12122174plt.6.1530220205836; Thu, 28 Jun 2018 14:10:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530220205; cv=none; d=google.com; s=arc-20160816; b=ZztXbm7/+7HmJEoZEWf6zsnnAOiuB6TcrXRSQXjGIGqnEPLbC3lhKFCiryAufu5rBu 0t3ch1BN00b6hJLh1YVT5ULFbgPn3p/zo5tk4KRX0lkrl5E+faSKZgIkKEoH91VRUG/i MvPe/D/3GnDaZlEGPENuhRtTAjdCpp5eOOJ0FNdOhVZ6VeMq0uLEAhiYBFnRiC3xneoq 4vc2+z2SvsHYmhTJcC2uf5kS/Se0KwzW1QezByqIQ1uSQrAdbv7dHq6SHOxzMipATXqv c9YfP8FS0bm1W4bO192utUwnbdkLb8NgJELkGF1qZyG2javpW7uD3swlFFwYITefHYtb d3Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:dkim-signature:dkim-filter :arc-authentication-results; bh=7dnHIL3lY3zJkvdfIyJkkzbkHK4giwmfZCtI66wF5ic=; b=KsMKzn+pv5M4zFMte95tnU2KZiCpAbFE+T16tWaHo2ZqXv3Fnc81V/mYcapcmrzYk8 EL2oKWHAFlk2vFA7BeD6Z47PfVKmWw8oYScdnRBRYDuIqhfT2LJ7uWNam1Y0VoWRCOKX Xarguyv0srZ6ypdfENynI3aqVO43w+6vqP3q7bPAaTDbrgamzZfXJUIbhF4FCsH8LQLz jF4yoLLLQtPQeEHio6yVoXGq/3NPbK9G2VA6891S5Kl1OHh7oBDXuIlzkKDdl5/uaOx5 KcTYkUMrEyp5AG+YHXHpWEA700ugYBKcS+vtpssS/gogofi/M5urWyVSPt70zB2u3UO4 /kpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=Fdt0MkxU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k2-v6si7487882plt.374.2018.06.28.14.09.51; Thu, 28 Jun 2018 14:10:05 -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; dkim=pass header.i=@efficios.com header.s=default header.b=Fdt0MkxU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935676AbeF1U4s (ORCPT + 99 others); Thu, 28 Jun 2018 16:56:48 -0400 Received: from mail.efficios.com ([167.114.142.138]:50146 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934003AbeF1U4q (ORCPT ); Thu, 28 Jun 2018 16:56:46 -0400 Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id C10B922EA6A; Thu, 28 Jun 2018 16:56:45 -0400 (EDT) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id oFwiNID3aV5X; Thu, 28 Jun 2018 16:56:45 -0400 (EDT) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 77DC322EA67; Thu, 28 Jun 2018 16:56:45 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 77DC322EA67 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1530219405; bh=7dnHIL3lY3zJkvdfIyJkkzbkHK4giwmfZCtI66wF5ic=; h=Date:From:To:Message-ID:MIME-Version; b=Fdt0MkxUBDGJB9DDxTWbrhFuKWlbGthiqKWAffsQ7deVM2FGBt1pyUGHAu4mHhuNp 1lzuFKvGtNrLeXm4Uqum+7xbH+CwQTX7tkHHwZZnC95hoF9NQQnqnZHrXEc6o9AkFj P0T7/ercmuoNugbLDJkDksV1sg83Az5TunzEGFpxOtYcfWwfA9wVD+RTxbLRZufutQ sJhPB34+VWQVQMFeu31UgPQRZp42jIbg0drje/N/ATFdcrG9Kiv2Nb33z+6haGHeg5 SPzmWisMbymHfZxg48wrZ54b3jy9DNLsemWIkCr9GKjKMnkSsiEzo6zKEvqsGMuLYn VHeO8KHhc63SQ== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id sb2LLc0em6GE; Thu, 28 Jun 2018 16:56:45 -0400 (EDT) Received: from mail02.efficios.com (mail02.efficios.com [167.114.142.138]) by mail.efficios.com (Postfix) with ESMTP id 597FB22EA60; Thu, 28 Jun 2018 16:56:45 -0400 (EDT) Date: Thu, 28 Jun 2018 16:56:45 -0400 (EDT) From: Mathieu Desnoyers To: Andy Lutomirski Cc: Thomas Gleixner , linux-kernel , linux-api , Peter Zijlstra , "Paul E. McKenney" , Boqun Feng , Dave Watson , Paul Turner , Andrew Morton , Russell King , Ingo Molnar , "H. Peter Anvin" , Andi Kleen , Chris Lameter , Ben Maurer , rostedt , Josh Triplett , Linus Torvalds , Catalin Marinas , Will Deacon , Michael Kerrisk , Joel Fernandes Message-ID: <1074518629.9408.1530219405324.JavaMail.zimbra@efficios.com> In-Reply-To: References: <20180628162359.9054-1-mathieu.desnoyers@efficios.com> Subject: Re: [RFC PATCH for 4.18 1/2] rseq: validate rseq_cs fields are < TASK_SIZE MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.142.138] X-Mailer: Zimbra 8.8.8_GA_2096 (ZimbraWebClient - FF52 (Linux)/8.8.8_GA_1703) Thread-Topic: rseq: validate rseq_cs fields are < TASK_SIZE Thread-Index: kHvWI6Urg2LteztK1iHd2b4YHD36iw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Jun 28, 2018, at 4:22 PM, Andy Lutomirski luto@kernel.org wrote: > On Thu, Jun 28, 2018 at 9:23 AM, Mathieu Desnoyers > wrote: >> Validating the abort_ip field of rseq_cs ensures that the kernel don't >> return to an invalid address when returning to userspace after an abort. >> I don't fully trust each architecture code to cleanly deal with invalid >> return addresses. >> >> Validating the range [ start_ip, start_ip + post_commit_offset ] is an >> extra validation step ensuring that userspace provides valid values to >> describe the critical section. >> >> If validation fails, the process is killed with a segmentation fault. >> >> Change the rseq ABI so rseq_cs start_ip, post_commit_offset and abort_ip >> fields are seen as 64-bit fields by both 32-bit and 64-bit kernels rather >> that ignoring the 32 upper bits on 32-bit kernels. This ensures we have >> a consistent behavior for a 32-bit binary executed on 32-bit kernels and >> in compat mode on 64-bit kernels. > > This is okay with me for a fix outside the merge window. Can you do a > followup for the next merge window that fixes it better, though? In > particular, TASK_SIZE is generally garbage. I think a better fix > would be something like adding a new arch-overridable helper like: > > static inline unsigned long current_max_user_addr(void) { return TASK_SIZE; } > > and overriding it on x86 as something like: > > static inline unsigned long current_max_user_addr(void) { > #ifdef CONFIG_IA32_EMULATION > return user_64bit_mode(current_pt_regs()) ? TASK_SIZE_MAX : (1UL << 32) - 1; > #else > return TASK_SIZE_MAX; > } > > TASK_SIZE really needs to die. Sure, I'll put it in my backlog. Thanks! Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com