From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DB18C43458 for ; Fri, 24 Jul 2020 07:41:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 167582074F for ; Fri, 24 Jul 2020 07:41:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726711AbgGXHlp (ORCPT ); Fri, 24 Jul 2020 03:41:45 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:21754 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726567AbgGXHlm (ORCPT ); Fri, 24 Jul 2020 03:41:42 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06O7Vi2W061405; Fri, 24 Jul 2020 03:41:10 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 32faj7a73n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 24 Jul 2020 03:41:10 -0400 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 06O7WkxM063974; Fri, 24 Jul 2020 03:41:10 -0400 Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com with ESMTP id 32faj7a733-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 24 Jul 2020 03:41:09 -0400 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 06O7e8oe001856; Fri, 24 Jul 2020 07:41:08 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma02fra.de.ibm.com with ESMTP id 32brq7x2es-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 24 Jul 2020 07:41:08 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 06O7f5Hh12059078 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Jul 2020 07:41:06 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BCE16A404D; Fri, 24 Jul 2020 07:41:05 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 76EDEA4040; Fri, 24 Jul 2020 07:41:04 +0000 (GMT) Received: from linux.vnet.ibm.com (unknown [9.126.150.29]) by d06av23.portsmouth.uk.ibm.com (Postfix) with SMTP; Fri, 24 Jul 2020 07:41:04 +0000 (GMT) Date: Fri, 24 Jul 2020 13:11:03 +0530 From: Srikar Dronamraju To: Oleg Nesterov Cc: Ingo Molnar , Steven Rostedt , Aaron Merey , Peter Zijlstra , linux-kernel@vger.kernel.org Subject: Re: [PATCH] uprobes: change handle_swbp() to send SIGTRAP with si_code=SI_KERNEL Message-ID: <20200724074103.GA14710@linux.vnet.ibm.com> Reply-To: Srikar Dronamraju References: <20200723154420.GA32043@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20200723154420.GA32043@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-24_01:2020-07-24,2020-07-23 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 spamscore=0 malwarescore=0 impostorscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 adultscore=0 mlxscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007240052 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Oleg Nesterov [2020-07-23 17:44:20]: > If a tracee is uprobed and it hits int3 inserted by debugger, handle_swbp() > does send_sig(SIGTRAP, current, 0) which means si_code == SI_USER. This used > to work when this code was written, but then GDB started to validate si_code > and now it simply can't use breakpoints if the tracee has an active uprobe: > > > The tracee hits the internal breakpoint inserted by GDB to monitor shared > library events but GDB misinterprets this SIGTRAP and reports a signal. > > Change handle_swbp() to use force_sig(SIGTRAP), this matches do_int3_user() > and fixes the problem. > > This is the minimal fix for -stable, arch/x86/kernel/uprobes.c is equally > wrong; it should use send_sigtrap(TRAP_TRACE) instead of send_sig(SIGTRAP), > but this doesn't confuse GDB and needs another x86-specific patch. > > Reported-by: Aaron Merey > Cc: stable@vger.kernel.org > Signed-off-by: Oleg Nesterov Looks good to me. Reviewed-by: Srikar Dronamraju > --- > kernel/events/uprobes.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c > index bb0862873dba..5f8b0c52fd2e 100644 > --- a/kernel/events/uprobes.c > +++ b/kernel/events/uprobes.c > @@ -2199,7 +2199,7 @@ static void handle_swbp(struct pt_regs *regs) > if (!uprobe) { > if (is_swbp > 0) { > /* No matching uprobe; signal SIGTRAP. */ > - send_sig(SIGTRAP, current, 0); > + force_sig(SIGTRAP); > } else { > /* > * Either we raced with uprobe_unregister() or we can't > -- > 2.25.1.362.g51ebf55 > > -- Thanks and Regards Srikar Dronamraju