Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2937409pxb; Tue, 19 Jan 2021 09:29:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJzawrmWeiohNv3nkU8JqeF0IN14Kuwxl4UHPioCCHUIO8vYHglgDe392qHduXViRbUtbejL X-Received: by 2002:a05:6402:20e:: with SMTP id t14mr4324898edv.178.1611077353454; Tue, 19 Jan 2021 09:29:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611077353; cv=none; d=google.com; s=arc-20160816; b=ose60A49HckvR80BD6ImfhrPMIO6Wv3zSuYLEkeOrdDZ4S8DFJUu23re9JWClhsccQ h5rioWAZoIDpoLu06cPDw9Ywxk/uhSUzeQDXHEdOS7XmfS4nf6mpCZAy7db1BgZzKsvo dbg/zgE5Rmx7uaBT+XFqOnNh0MTlsz9xC86voK4CSNQeqdoq4I0Od+Q87n5FTJ4Yc1Zd BGqTg1Dib8ss58vosPciHkkDAmA8ngPGPRo9dH5uVBmyanWeAr0dyZHKEuBVe5xSaXnO zK5C+rf0N+VqN2HRU2+lkDpY2d98Ua6tkGbmXeL0zIliG3n5dHlnfNtyheYGgW8KSR0p OVFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=mAzpHVdlnMaDyvxGTKzMDyi59keeJ2kOytyejQDWyqg=; b=WcYNoOhC5Q9ElMhTU7YPq4SfkIo6xQqd6CfXItS5WF13qvKLef1U1XDJFyd3EYLZhM KdoK7u53GUcDe+HJRgE7FZTQBygNZ6VzgErFLRnMwNPomT3mOZPjvX5PThiQjC+JQoJL 0xaupPVwv7SuC7Pf39PZBMrO6liraKYZyKlsXuMmB+YR2nCmyGZvJgtU76Fg8axaW8ZH Cv5sGoPx68dPNRflT3WEg3GP2PmLUTWm76TpIWMaR6kkKseEVc2x8AUgHbpBSwBi9Z8c vh2BfwTTw777mi5A5J6x6jy/0OkDLGp5ujALoURA2sYAAjr2Ijn2sMMYYq2j9US8SBbJ Na6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hyIy8isn; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g21si4108914edu.180.2021.01.19.09.28.49; Tue, 19 Jan 2021 09:29:13 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=hyIy8isn; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390864AbhASR2P (ORCPT + 99 others); Tue, 19 Jan 2021 12:28:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53655 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391390AbhASR1r (ORCPT ); Tue, 19 Jan 2021 12:27:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611077172; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=mAzpHVdlnMaDyvxGTKzMDyi59keeJ2kOytyejQDWyqg=; b=hyIy8isn2lizrPSy7PuszBneMy+rbbws+E75bcrkRIYc2rDQE0cjKlR2ZUDLR4bg0NYjvz zbKBVRGFv62/yu+S+21Q7AMaOm8cuP7FO8EMZ5ETNBreIepr1tqUzN/3NT9Wlxp2rsa7JT rlSM9hdjlaAs4x1KKGwyuuBDQ7EakDc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-299-AXabtRcgOPCQB4xr3nWivg-1; Tue, 19 Jan 2021 12:26:10 -0500 X-MC-Unique: AXabtRcgOPCQB4xr3nWivg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B3CF01936B8A; Tue, 19 Jan 2021 17:26:07 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with SMTP id 0C6A260C9C; Tue, 19 Jan 2021 17:26:04 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Tue, 19 Jan 2021 18:26:07 +0100 (CET) Date: Tue, 19 Jan 2021 18:26:03 +0100 From: Oleg Nesterov To: Ravi Bangoria Cc: mpe@ellerman.id.au, rostedt@goodmis.org, paulus@samba.org, jniethe5@gmail.com, naveen.n.rao@linux.ibm.com, sandipan@linux.ibm.com, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] powerpc/uprobes: Don't allow probe on suffix of prefixed instruction Message-ID: <20210119172603.GA16696@redhat.com> References: <20210119091234.76317-1-ravi.bangoria@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210119091234.76317-1-ravi.bangoria@linux.ibm.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/19, Ravi Bangoria wrote: > > Probe on 2nd word of a prefixed instruction is invalid scenario and > should be restricted. I don't understand this ppc-specific problem, but... > +#ifdef CONFIG_PPC64 > +int arch_uprobe_verify_opcode(struct page *page, unsigned long vaddr, > + uprobe_opcode_t opcode) > +{ > + uprobe_opcode_t prefix; > + void *kaddr; > + struct ppc_inst inst; > + > + /* Don't check if vaddr is pointing to the beginning of page */ > + if (!(vaddr & ~PAGE_MASK)) > + return 0; So the fix is incomplete? Or insn at the start of page can't be prefixed? > +int __weak arch_uprobe_verify_opcode(struct page *page, unsigned long vaddr, > + uprobe_opcode_t opcode) > +{ > + return 0; > +} > + > static int verify_opcode(struct page *page, unsigned long vaddr, uprobe_opcode_t *new_opcode) > { > uprobe_opcode_t old_opcode; > @@ -275,6 +281,8 @@ static int verify_opcode(struct page *page, unsigned long vaddr, uprobe_opcode_t > if (is_swbp_insn(new_opcode)) { > if (is_swbp) /* register: already installed? */ > return 0; > + if (arch_uprobe_verify_opcode(page, vaddr, old_opcode)) > + return -EINVAL; Well, this doesn't look good... To me it would be better to change the prepare_uprobe() path to copy the potential prefix into uprobe->arch and check ppc_inst_prefixed() in arch_uprobe_analyze_insn(). What do you think? Oleg.