From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752194AbdK0WBn (ORCPT ); Mon, 27 Nov 2017 17:01:43 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:51301 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751506AbdK0WBm (ORCPT ); Mon, 27 Nov 2017 17:01:42 -0500 Date: Mon, 27 Nov 2017 23:01:28 +0100 From: Peter Zijlstra To: Milind Chabbi Cc: Jiri Olsa , Jiri Olsa , Ingo Molnar , Arnaldo Carvalho de Melo , lkml , Namhyung Kim , David Ahern , Andi Kleen , Alexander Shishkin , Michael Ellerman , Hari Bathini , Jin Yao , Kan Liang , Sukadev Bhattiprolu , Oleg Nesterov , Will Deacon Subject: Re: [PATCH 4/6] hw_breakpoint: Factor out __modify_user_hw_breakpoint function Message-ID: <20171127220128.kzgywcu5ucudaeyl@hirez.programming.kicks-ass.net> References: <20171127162133.21163-1-jolsa@kernel.org> <20171127162133.21163-5-jolsa@kernel.org> <20171127164639.3ymnc6io3eae7n4c@hirez.programming.kicks-ass.net> <20171127170911.GA22026@krava> <20171127171203.tmdvcsnsownieijv@hirez.programming.kicks-ass.net> <20171127172532.GA23094@krava> <20171127173417.eokpkznt65yreoav@hirez.programming.kicks-ass.net> <20171127212003.aauonfkbl45pd7dj@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 27, 2017 at 01:50:30PM -0800, Milind Chabbi wrote: > The possible checks is infinite struct perf_event_attr is very much a finite data type. Something as simple as: struct perf_event_attr tmp1 = new_attr, tmp2 = event->attr; tmp1.bp_type = tmp2.bp_type; tmp1.bp_addr = tmp2.bp_addr; tmp1.bp_len = tmp2.bp_len; if (memcmp(&tmp1, &tmp2, sizeof(tmp1))) return -EINVAL; would actually do the checks __modify_user_hw_breakpoint() needs to do.