Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1050503pxj; Tue, 18 May 2021 20:31:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWQrJB0+puN1ATMy8Pt4oCQd5oLWBT4zXK7mLUYHpQhvP953o8fV549BBN0iKnrr4wstM3 X-Received: by 2002:a05:6e02:1a4d:: with SMTP id u13mr8190031ilv.64.1621395098723; Tue, 18 May 2021 20:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621395098; cv=none; d=google.com; s=arc-20160816; b=cDJKljmt+80g8I9R/boyUQ01VdeEU299A7bIwzLjQo2XcuDj/usbepODD5kclH93rl J1KfyluGmdT7Doh+m0Xfy1igvvXZ7sKQwdSSIkHRBhWZFgeyEYcE+Fec9SvBjRg9LuEE UpBop47oHMkGc44ClhxjPxM3XejWrf1TnHyjtS6sczEs8qFkkGqhcZtZLzMQKEv0EuCS 5uFgGDkp8KamH/o5FglTy1+L9LXeamqtM2oD1A35swLxmjbI/TANheLYoCqG+rW0O/AE q8+nolqbK8RkOGNiB0WE9bJLHF3dybjAmcNF8QAYVHMZBq7kIyEfBrWzzzMG8R86gMoz g2Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from; bh=MSxjiTj0Bs1+ekPwIQ2uI/1hn+FENwIiBY9li4B6/zk=; b=H6nPx/ehRFrZbrCbP9Ft6HnyUyIgWmfmul5nnAy3JBZQ512Hgt6kQ5ajeVG1ZHn47V f+GvUFNePMRiWWUsXtmn+eQQgldLhfuN144NAER3ElOjiKO1nN+yaH1R1FzcMRGf6Z6T WBVzvk+n9/24349n5Br1BvD5OYIJR/0XTOy2uBAuWsWKY+BLPSSKT4GqsBdAMHjgbPgo FmhXP82jVw7d123DiCuxGLrRWeE8fbWnL1h7ELmCxL9hvhurrrV6yuUDc1AX/h2uYsZf xPCERqx/U6xxpE/p/HNIaLGMSJQAr/Yzn92AaPdfPqyNLLZvyvdsCryBm4z5Kg9Y/qVk l5gg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g15si3893374iln.71.2021.05.18.20.31.01; Tue, 18 May 2021 20:31:38 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237413AbhEQUEo (ORCPT + 99 others); Mon, 17 May 2021 16:04:44 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:56180 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237381AbhEQUEn (ORCPT ); Mon, 17 May 2021 16:04:43 -0400 Received: from in01.mta.xmission.com ([166.70.13.51]) by out01.mta.xmission.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lijSY-009hJl-4f; Mon, 17 May 2021 14:03:26 -0600 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=fess.int.ebiederm.org) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1lijNw-0001rb-Fk; Mon, 17 May 2021 13:58:43 -0600 From: "Eric W. Beiderman" To: Marco Elver Cc: Arnd Bergmann , Florian Weimer , "David S. Miller" , Peter Zijlstra , Ingo Molnar , Thomas Gleixner , Peter Collingbourne , Dmitry Vyukov , Alexander Potapenko , sparclinux , linux-arch , Linux Kernel Mailing List , Linux API , kasan-dev , "Eric W. Biederman" Date: Mon, 17 May 2021 14:57:46 -0500 Message-Id: <20210517195748.8880-3-ebiederm@xmission.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210517195748.8880-1-ebiederm@xmission.com> References: <20210517195748.8880-1-ebiederm@xmission.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-XM-SPF: eid=1lijNw-0001rb-Fk;;;mid=<20210517195748.8880-3-ebiederm@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX18fYPk1LCSdXRWjF81+VdMO4wVqvRKe23A= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa06.xmission.com X-Spam-Level: X-Spam-Status: No, score=0.9 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,FVGT_m_MULTI_ODD,T_TM2_M_HEADER_IN_MSG, T_TooManySym_01,XMSubLong autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 0.7 XMSubLong Long Subject * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa06 1397; Body=1 Fuz1=1 Fuz2=1] * 0.4 FVGT_m_MULTI_ODD Contains multiple odd letter combinations * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Marco Elver X-Spam-Relay-Country: X-Spam-Timing: total 2202 ms - load_scoreonly_sql: 0.03 (0.0%), signal_user_changed: 10 (0.5%), b_tie_ro: 9 (0.4%), parse: 0.93 (0.0%), extract_message_metadata: 15 (0.7%), get_uri_detail_list: 2.4 (0.1%), tests_pri_-1000: 21 (0.9%), tests_pri_-950: 1.18 (0.1%), tests_pri_-900: 1.01 (0.0%), tests_pri_-90: 75 (3.4%), check_bayes: 74 (3.4%), b_tokenize: 10 (0.4%), b_tok_get_all: 7 (0.3%), b_comp_prob: 3.0 (0.1%), b_tok_touch_all: 52 (2.3%), b_finish: 0.81 (0.0%), tests_pri_0: 351 (16.0%), check_dkim_signature: 0.77 (0.0%), check_dkim_adsp: 2.3 (0.1%), poll_dns_idle: 1711 (77.7%), tests_pri_10: 2.2 (0.1%), tests_pri_500: 1722 (78.2%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH v4 3/5] signal: Factor force_sig_perf out of perf_sigtrap 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) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Eric W. Biederman" Separate filling in siginfo for TRAP_PERF from deciding that siginal needs to be sent. There are enough little details that need to be correct when properly filling in siginfo_t that it is easy to make mistakes if filling in the siginfo_t is in the same function with other logic. So factor out force_sig_perf to reduce the cognative load of on reviewers, maintainers and implementors. v1: https://lkml.kernel.org/r/m17dkjqqxz.fsf_-_@fess.ebiederm.org v2: https://lkml.kernel.org/r/20210505141101.11519-10-ebiederm@xmission.com Reviewed-by: Marco Elver Acked-by: Peter Zijlstra (Intel) Signed-off-by: "Eric W. Biederman" --- include/linux/sched/signal.h | 1 + kernel/events/core.c | 11 ++--------- kernel/signal.c | 13 +++++++++++++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h index 3f6a0fcaa10c..7f4278fa21fe 100644 --- a/include/linux/sched/signal.h +++ b/include/linux/sched/signal.h @@ -326,6 +326,7 @@ int send_sig_mceerr(int code, void __user *, short, struct task_struct *); int force_sig_bnderr(void __user *addr, void __user *lower, void __user *upper); int force_sig_pkuerr(void __user *addr, u32 pkey); +int force_sig_perf(void __user *addr, u32 type, u64 sig_data); int force_sig_ptrace_errno_trap(int errno, void __user *addr); diff --git a/kernel/events/core.c b/kernel/events/core.c index 928b166d888e..48ea8863183b 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -6394,8 +6394,6 @@ void perf_event_wakeup(struct perf_event *event) static void perf_sigtrap(struct perf_event *event) { - struct kernel_siginfo info; - /* * We'd expect this to only occur if the irq_work is delayed and either * ctx->task or current has changed in the meantime. This can be the @@ -6410,13 +6408,8 @@ static void perf_sigtrap(struct perf_event *event) if (current->flags & PF_EXITING) return; - clear_siginfo(&info); - info.si_signo = SIGTRAP; - info.si_code = TRAP_PERF; - info.si_errno = event->attr.type; - info.si_perf = event->attr.sig_data; - info.si_addr = (void __user *)event->pending_addr; - force_sig_info(&info); + force_sig_perf((void __user *)event->pending_addr, + event->attr.type, event->attr.sig_data); } static void perf_pending_event_disable(struct perf_event *event) diff --git a/kernel/signal.c b/kernel/signal.c index 597594ee72de..3a18d13c39b2 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -1763,6 +1763,19 @@ int force_sig_pkuerr(void __user *addr, u32 pkey) } #endif +int force_sig_perf(void __user *addr, u32 type, u64 sig_data) +{ + struct kernel_siginfo info; + + clear_siginfo(&info); + info.si_signo = SIGTRAP; + info.si_errno = type; + info.si_code = TRAP_PERF; + info.si_addr = addr; + info.si_perf = sig_data; + return force_sig_info(&info); +} + /* For the crazy architectures that include trap information in * the errno field, instead of an actual errno value. */ -- 2.30.1