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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no 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 B49B2C4361A for ; Fri, 4 Dec 2020 15:06:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7651022B2D for ; Fri, 4 Dec 2020 15:06:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730435AbgLDPGD (ORCPT ); Fri, 4 Dec 2020 10:06:03 -0500 Received: from mail.skyhub.de ([5.9.137.197]:34638 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726715AbgLDPGC (ORCPT ); Fri, 4 Dec 2020 10:06:02 -0500 Received: from zn.tnic (p200300ec2f12b100a8acd31b3e2f4e6b.dip0.t-ipconnect.de [IPv6:2003:ec:2f12:b100:a8ac:d31b:3e2f:4e6b]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 76F1F1EC0380; Fri, 4 Dec 2020 16:05:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1607094321; 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: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=8vwBFDJPYoB3/M/m0V1lRoy6WWaJ5t8cn3KMXOOqFvI=; b=rJvQvvvPF68xiUsi3O+q8ks5y7OQFPhlPIYGperspDWn19yt8r8pzzKjDcMPb6FseERN1n bo3HItdEhgffVRjFmfbCSP/fm8X+s7uH/tqljLxfaLagCF5542ga0+Ral6ryczM6KmyItj NbuS9yWa9PaEk63fJHb8tKeIc3u8Xxk= Date: Fri, 4 Dec 2020 16:05:22 +0100 From: Borislav Petkov To: Masami Hiramatsu Cc: x86@kernel.org, Thomas Gleixner , Ingo Molnar , Kees Cook , "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 v3 1/3] x86/uprobes: Fix not using prefixes.nbytes for loop over prefixes.bytes Message-ID: <20201204150522.GG31534@zn.tnic> References: <160707930875.3296595.12884856538916078988.stgit@devnote2> <160707931985.3296595.4852247459424743502.stgit@devnote2> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <160707931985.3296595.4852247459424743502.stgit@devnote2> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 04, 2020 at 07:55:20PM +0900, Masami Hiramatsu wrote: > +/** > + * for_each_insn_prefix() -- Iterate prefixes in the instruction > + * @insn: Pointer to struct insn. > + * @idx: Index storage. > + * @prefix: Prefix byte. > + * > + * Iterate prefix bytes of given @insn. Each prefix byte is stored in @prefix > + * and the index is stored in @idx (note that this @idx is just for a cursor, > + * do not change it.) > + * Since prefixes.nbytes can be bigger than NUM_INSN_FIELD_BYTES when some > + * prefixes are repeated, it can not be used for looping over the prefixes. > + */ > +#define for_each_insn_prefix(insn, idx, prefix) \ > + for (idx = 0; \ > + idx < MAX_LEGACY_PREFIX_GROUPS && \ The problem I see here is that you check for the index limit to be < MAX_LEGACY_PREFIX_GROUPS but the array itself is defined using NUM_INSN_FIELD_BYTES, and that is confusing. I guess this should be: #define MAX_LEGACY_PREFIX_GROUPS 4 #define NUM_INSN_FIELD_BYTES MAX_LEGACY_PREFIX_GROUPS and later, iff the legacy prefixes array size needs separating from the insn field array size, then the defines would need to change too. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette