Received: by 2002:a4a:301c:0:0:0:0:0 with SMTP id q28-v6csp1266724oof; Tue, 25 Sep 2018 10:20:44 -0700 (PDT) X-Google-Smtp-Source: ACcGV61RVwyeue0QZ816i+waPAjoh/n/7Gd/wQmLGdA2D64X51HC0Bq2yp9ma3YPG3VN06Wm9AKM X-Received: by 2002:a63:f51:: with SMTP id 17-v6mr2000111pgp.100.1537896044658; Tue, 25 Sep 2018 10:20:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537896044; cv=none; d=google.com; s=arc-20160816; b=knf0v2vyvQcxcQTQ8xFU2jmYOg4Lqs/yokufAe/+EMPGQk3oNaovKz0ZialvWmAUfb 2z6ctm7sRpx35o2rZ8wVYkv5In6/EU/QjkOTyLnxCbU3qNdFFNjMU+fCR4ciMNwrdP5Y tGo97ylYVq4jnFMMJWbWCPMpYiLgXnU7E7S0w8VHlHhCqB5+WR8sKiLOzNU56uWVfLdd 8SkHVCCV91PPqrIQjUCGBSGxEj5E6Mxr411xokhTLrcJGDG37ruMTMM5sevw8ly8Ubdw AOrHy+W8SOnnWmhPj/EYvNWQxTHrp80w31oGtECMne61nQuIm+2cyM/MA/Jqlljqr2Cx ffUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:references:in-reply-to:message-id :date:cc:to:from; bh=6R6aepVbAZCa3MKzADorkxrnHIzorhk5ahIuB2mga0I=; b=tX916tE/NhlzPjsYfxO0/h0rJLXSQKFM8329Z+/Qw1evlkqnz6jHvAQTkPvTpZL6zk Gi4Ihtv9jqbItLqQmZ0L/kjRzprhiy8EoKm+AeTJoI1nEe85F7i3pyE27Mc5CNdD2OhS NBhtc6omcDCYIQeZbFLhIJCGMOJUT26TaCIa3hXEbbBx3CZekhrkZyVXE/WWhV46NE3Y Kv/M95Vspxlkw0GiOg5zbsOdY8JGGNQ/dudAjUP/a7oVu15d0a4WgQzuinMtIj+r+1z3 Bqlw00XGb3LFPbxJCIUEEIYJZs5ap+Gk5Qdp9yAwRxKCdkws5EuiIVVPf8ZFE3i7mQsk 8Ncg== 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 h9-v6si3201669plk.461.2018.09.25.10.20.28; Tue, 25 Sep 2018 10:20:44 -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; 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 S1727995AbeIYX2Y (ORCPT + 99 others); Tue, 25 Sep 2018 19:28:24 -0400 Received: from out02.mta.xmission.com ([166.70.13.232]:60785 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726400AbeIYX2X (ORCPT ); Tue, 25 Sep 2018 19:28:23 -0400 Received: from in01.mta.xmission.com ([166.70.13.51]) by out02.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1g4r07-0000Xd-3w; Tue, 25 Sep 2018 11:19:55 -0600 Received: from [105.184.227.67] (helo=x220.Home) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA256:128) (Exim 4.87) (envelope-from ) id 1g4r06-0001uD-0y; Tue, 25 Sep 2018 11:19:54 -0600 From: "Eric W. Biederman" To: linux-kernel@vger.kernel.org Cc: linux-api@vger.kernel.org, linux-arch@vger.kernel.org, Oleg Nesterov , Linus Torvalds , "Eric W. Biederman" Date: Tue, 25 Sep 2018 19:19:02 +0200 Message-Id: <20180925171906.19683-2-ebiederm@xmission.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <87h8idv6nw.fsf@xmission.com> References: <87h8idv6nw.fsf@xmission.com> X-XM-SPF: eid=1g4r06-0001uD-0y;;;mid=<20180925171906.19683-2-ebiederm@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=105.184.227.67;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1+Vj4CgC0WrCxvJmB02LgyOu8MWo/KdEDs= X-SA-Exim-Connect-IP: 105.184.227.67 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa05.xmission.com X-Spam-Level: *** X-Spam-Status: No, score=3.5 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,TR_Symld_Words,T_TooManySym_01,T_TooManySym_02, T_TooManySym_03,XMNoVowels,XMSubLong autolearn=disabled version=3.4.1 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.7 XMSubLong Long Subject * 1.5 TR_Symld_Words too many words that have symbols inside * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa05 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject * 0.0 T_TooManySym_02 5+ unique symbols in subject * 0.0 T_TooManySym_03 6+ unique symbols in subject X-Spam-DCC: XMission; sa05 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ***;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 254 ms - load_scoreonly_sql: 0.07 (0.0%), signal_user_changed: 4.0 (1.6%), b_tie_ro: 2.8 (1.1%), parse: 1.33 (0.5%), extract_message_metadata: 17 (6.5%), get_uri_detail_list: 2.1 (0.8%), tests_pri_-1000: 9 (3.4%), tests_pri_-950: 2.2 (0.9%), tests_pri_-900: 1.64 (0.6%), tests_pri_-400: 24 (9.5%), check_bayes: 23 (8.9%), b_tokenize: 8 (3.1%), b_tok_get_all: 8 (3.0%), b_comp_prob: 2.3 (0.9%), b_tok_touch_all: 2.6 (1.0%), b_finish: 0.72 (0.3%), tests_pri_0: 183 (72.1%), check_dkim_signature: 0.61 (0.2%), check_dkim_adsp: 3.1 (1.2%), tests_pri_500: 8 (3.2%), rewrite_mail: 0.00 (0.0%) Subject: [REVIEW][PATCH 2/6] signal: Fail sigqueueinfo if si_signo != sig X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The kernel needs to validate that the contents of struct siginfo make sense as siginfo is copied into the kernel, so that the proper union members can be put in the appropriate locations. The field si_signo is a fundamental part of that validation. As such changing the contents of si_signo after the validation make no sense and can result in nonsense values in the kernel. As such simply fail if someone is silly enough to set si_signo out of sync with the signal number passed to sigqueueinfo. I don't expect a problem as glibc's sigqueue implementation sets "si_signo = sig" and CRIU just returns to the kernel what the kernel gave to it. If there is some application that calls sigqueueinfo directly that has a problem with this added sanity check we can revisit this when we see what kind of crazy that application is doing. Signed-off-by: "Eric W. Biederman" --- kernel/signal.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/signal.c b/kernel/signal.c index 7b49c31d3fdb..e445b0a63faa 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -3306,7 +3306,8 @@ static int do_rt_sigqueueinfo(pid_t pid, int sig, siginfo_t *info) (task_pid_vnr(current) != pid)) return -EPERM; - info->si_signo = sig; + if (info->si_signo != sig) + return -EINVAL; /* POSIX.1b doesn't mention process groups. */ return kill_proc_info(sig, info, pid); @@ -3354,7 +3355,8 @@ static int do_rt_tgsigqueueinfo(pid_t tgid, pid_t pid, int sig, siginfo_t *info) (task_pid_vnr(current) != pid)) return -EPERM; - info->si_signo = sig; + if (info->si_signo != sig) + return -EINVAL; return do_send_specific(tgid, pid, sig, info); } -- 2.17.1