Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp793152pxb; Mon, 25 Oct 2021 19:08:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFJkUcvv4f1N6/+Uik63mRq5Do/f3U+bjgwnQuofRHIBeoN8djthsHTgTsecr95RcB+lvF X-Received: by 2002:a50:c88c:: with SMTP id d12mr14938173edh.102.1635214109664; Mon, 25 Oct 2021 19:08:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635214109; cv=none; d=google.com; s=arc-20160816; b=ZLK/ZRPPPbFy2Q8vF4FuNZsgTJDRdXnUsaSl/+Fe1ThbEhfUoDOkf49ypkxwYyitrO uxE5Ss0cg2xtj8CJDsgNujvvEVF7oiVHS0CnESElp9EpUmbMRbAinBLWhbYaEirv2XZb 3T6F2ONbqntlOAXVCHT/eTIEgxxuiRD5s3kQikWVMA7FqPJEFtaQ74Jn0GiBz8ZQKzO2 Lr8BI1PXQARhx2OV46AhDRqiVSsRV5SWckpMF2f5FfN+IJtd9AXDg3VRtxzUfkJKLLEa VhweVeAVD7MSBghYay6lbsY4B9flGeOpXyivUZgY3prvPOwsshgbyE+OqhV51q/RCuQs n9ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=PVKs7Wp6gFcS/WlJiKh3uGtQEe65MFObkMm0puzF894=; b=v4wqiSLCmEtcgK8Jzhi4AOKqqCrNI56H8fNXYr8DnQsZlcemB5APYeE+iich3nj3uC ITJT8UjXO4w9iFBcEYD8sXirxkKcNlCfRhkCNhXxVW4vA89y4QKXrqytH2vvigFQSwrm HZi3PyIsMo0qJ9j6+aZOPWfP1AGHMTxPScL1XCFqFcIqH8FFKjm5qii5spngZjGTzyr8 labH5MZr3BhJ617zJB+wxXSPUykw7SO9TD27ObrttN7DJmrEKtbLKXyFIQvn2YWWpGsE uHJy+xnSlt5PzGqhgK2R23pQNOttCYPLYGGm10MjAeb4+hLPpR+6ZK2yIQ2TdVhOfkYV kxYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PEHDxeNK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s1si1330017ejn.125.2021.10.25.19.08.07; Mon, 25 Oct 2021 19:08:29 -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=pass header.i=@kernel.org header.s=k20201202 header.b=PEHDxeNK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234213AbhJYWn1 (ORCPT + 99 others); Mon, 25 Oct 2021 18:43:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:46860 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234204AbhJYWnZ (ORCPT ); Mon, 25 Oct 2021 18:43:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4205E6103C; Mon, 25 Oct 2021 22:41:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1635201662; bh=ex+zDaQP63Cn6bMQxc/uGRqILguHZWqLS9gEpm92DDU=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=PEHDxeNK/gqMFjw58J3tXy7BRkq+Yrg2AgrWIgVWwpTzkGhZl8HpMgJJ+nVMB3EBG 08VE8MbdRGn866NTwITZJjLQwSCtXwYX0dhgN51JNqKA4rWs+kBrVXLob2Jsnj5JiX J/DDPX+VaJqglRJNT4NO/LiwPG7I/iXmd2mmwS672OilByu8oj2+qgfzvbXGu+kIaA FRRGrWOcyfGaD7QNMJQ0Go0gBXrWhQEG3U8PwXuqDo7oziFU5Q/9IFOiAMaMAowymk rrMo1/6ognvTAZIE2zAKiaElx39mOPw+mmwbCzTMcIk13s1REJTLUpNx8ZQMKZwsmV XJIQNm3J8umig== Message-ID: <9416e8d7-5545-4fc4-8ab0-68fddd35520b@kernel.org> Date: Mon, 25 Oct 2021 15:41:01 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: [PATCH 13/20] signal: Implement force_fatal_sig Content-Language: en-US To: Linus Torvalds , "Eric W. Biederman" , Linux Kernel Mailing List , linux-arch@vger.kernel.org Cc: Oleg Nesterov , Al Viro , Kees Cook References: <87y26nmwkb.fsf@disp2133> <20211020174406.17889-13-ebiederm@xmission.com> From: Andy Lutomirski In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/20/21 13:05, Linus Torvalds wrote: > On Wed, Oct 20, 2021 at 7:45 AM Eric W. Biederman wrote: >> >> Add a simple helper force_fatal_sig that causes a signal to be >> delivered to a process as if the signal handler was set to SIG_DFL. >> >> Reimplement force_sigsegv based upon this new helper. > > Can you just make the old force_sigsegv() go away? The odd special > casing of SIGSEGV was odd to begin with, I think everybody really just > wanted this new "force_fatal_sig()" and allow any signal - not making > SIGSEGV special. > I'm rather nervous about all this, and I'm also nervous about the existing code. A quick skim is finding plenty of code paths that assume force_sigsegv (or a do_exit that this series touches) are genuinely unrecoverable. For example: - rseq: the *kernel* will be fine if a signal is handled, but the userspace process may be in a very strange state. - bprm_execve: The comment says it best: /* * If past the point of no return ensure the code never * returns to the userspace process. Use an existing fatal * signal if present otherwise terminate the process with * SIGSEGV. */ if (bprm->point_of_no_return && !fatal_signal_pending(current)) force_sigsegv(SIGSEGV); - vm86: already discussed Now force_sigsegv() at least tries to kill the task, but not very well. With the whole series applied and force_sigsegv() gone, these errors become handleable, and that needs real care. (I don't think bprm_execve() is exploitable. It looks like it's attackable in the window between setting point_of_no_return and unshare_sighand(), but I'm not seeing any useful way to attack it unless a core dump is already in progress or a *different* fatal signal is already pending, and in either of those cases we're fine.)