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=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham 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 D263BC64E7C for ; Wed, 2 Dec 2020 19:05:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 721892224C for ; Wed, 2 Dec 2020 19:05:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731049AbgLBTFY (ORCPT ); Wed, 2 Dec 2020 14:05:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728673AbgLBTFY (ORCPT ); Wed, 2 Dec 2020 14:05:24 -0500 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 256ADC0613CF for ; Wed, 2 Dec 2020 11:04:44 -0800 (PST) Received: by mail-pj1-x1044.google.com with SMTP id p21so929523pjv.0 for ; Wed, 02 Dec 2020 11:04:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=GwFCcSF3JbZEcp9Z3pjvQUej5xg0kXdcQPMPFZwHFX8=; b=lwIJo2u0tzYkuHiYMvmii8cyOx50NaH8QvTxFNVCeSjxSaWfHw5bNbtbkEmwIVS65i hBg1Q0Qa6kINYzGAC8cBLP5xbA5StsYX+Ex6Q5422xUQ+4M0FtRh2ZJi+lcTYh1E0vsy RyMyyeYJSdJYvUXlYNzbqwBcZkW/KSJaiSY24= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=GwFCcSF3JbZEcp9Z3pjvQUej5xg0kXdcQPMPFZwHFX8=; b=Lz5k9Z8vQC3uYtloI4pnwEHLazeLdt9YYqBJZKjOgNIGhHYgBMnzN6/ChccqenK/ka VXbw8+RnwCLAgr+4TrLL/pfe9jGRniWMLx9SysT+cswNHe8Kg5F5zLW92XERLbtPsgpw xzwyJyL8CDAwvQgG0lWakLoBpCO+2gNP+KQxeZqFJXjhjBOZaeu89AMI/V/OF8cmL/9X 5IsPxF9Y66fC1K7P6Bogkr0iOcSyLgpDMVkTKid6YCm7xaMNhVy9ZWPoJPbC4SXUmPjT K9LGAKIG8A61RnFUPZ+A5hnR823ol/3tDsSvvb9e8ssBB7p9fg06Pv84JaW5cyHfGx/T OURQ== X-Gm-Message-State: AOAM533RT2n+tv8XTt9fBbHWvlOgGBr78RBwi56/9s+IuxXM9VJ3rJ0q cGf1pQg9L/sosFGd3cK1IRx4tw== X-Google-Smtp-Source: ABdhPJzc+grIh3FrlarD3mXxGH7nSP9p14zHQKfUiLiFIiwk52p3LcrnA0c2+0F5W9/96DViXwklJA== X-Received: by 2002:a17:90a:2d6:: with SMTP id d22mr1255625pjd.38.1606935883731; Wed, 02 Dec 2020 11:04:43 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id g85sm530108pfb.4.2020.12.02.11.04.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 11:04:42 -0800 (PST) Date: Wed, 2 Dec 2020 11:04:41 -0800 From: Kees Cook To: Masami Hiramatsu Cc: x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Joerg Roedel , Tom Lendacky , "Gustavo A . R . Silva" , Jann Horn , Srikar Dronamraju , Ricardo Neri , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] x86/uprobes: Fix not using prefixes.nbytes for loop over prefixes.bytes Message-ID: <202012021103.5A8030BF7A@keescook> References: <160689905099.3084105.7880450206184269465.stgit@devnote2> <160689907597.3084105.18019089399087866918.stgit@devnote2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <160689907597.3084105.18019089399087866918.stgit@devnote2> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 02, 2020 at 05:51:16PM +0900, Masami Hiramatsu wrote: > Since the insn.prefixes.nbytes can be bigger than the size of > insn.prefixes.bytes[] when a same prefix is repeated, we have to > check whether the insn.prefixes.bytes[i] != 0 and i < 4 instead > of insn.prefixes.nbytes. > > Fixes: 2b1444983508 ("uprobes, mm, x86: Add the ability to install and remove uprobes breakpoints") > Cc: stable@vger.kernel.org > Reported-by: Kees Cook This should probably be: Reported-by: syzbot+9b64b619f10f19d19a7c@syzkaller.appspotmail.com Debugged-by: Kees Cook > Signed-off-by: Masami Hiramatsu > --- > arch/x86/kernel/uprobes.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c > index 3fdaa042823d..bb3ea3705b99 100644 > --- a/arch/x86/kernel/uprobes.c > +++ b/arch/x86/kernel/uprobes.c > @@ -257,7 +257,7 @@ static bool is_prefix_bad(struct insn *insn) > { > int i; > > - for (i = 0; i < insn->prefixes.nbytes; i++) { > + for (i = 0; insn->prefixes.bytes[i] && i < 4; i++) { > insn_attr_t attr; > > attr = inat_get_opcode_attribute(insn->prefixes.bytes[i]); > @@ -746,7 +746,7 @@ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn) > * Intel and AMD behavior differ in 64-bit mode: Intel ignores 66 prefix. > * No one uses these insns, reject any branch insns with such prefix. > */ > - for (i = 0; i < insn->prefixes.nbytes; i++) { > + for (i = 0; insn->prefixes.bytes[i] && i < 4; i++) { > if (insn->prefixes.bytes[i] == 0x66) > return -ENOTSUPP; > } > -- Kees Cook