From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965949AbdIYT4H (ORCPT ); Mon, 25 Sep 2017 15:56:07 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:46181 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932107AbdIYT4G (ORCPT ); Mon, 25 Sep 2017 15:56:06 -0400 Date: Mon, 25 Sep 2017 21:56:00 +0200 (CEST) From: Thomas Gleixner To: Ingo Molnar cc: linux-kernel@vger.kernel.org, Andrew Morton , Eric Biggers , Andy Lutomirski , Borislav Petkov , Dave Hansen , Fenghua Yu , "H . Peter Anvin" , Linus Torvalds , Oleg Nesterov , Peter Zijlstra , Rik van Riel , Yu-cheng Yu Subject: Re: [PATCH 08/33] x86/fpu: Clarify parameter names in the copy_xstate_to_*() methods In-Reply-To: <20170923130016.21448-9-mingo@kernel.org> Message-ID: References: <20170923130016.21448-1-mingo@kernel.org> <20170923130016.21448-9-mingo@kernel.org> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 23 Sep 2017, Ingo Molnar wrote: > static inline int > __copy_xstate_to_kernel(void *kbuf, > const void *data, > - unsigned int pos, unsigned int count, int end_pos) > + unsigned int offset, unsigned int size, int size_total) Why is size_total int? > { > - if (!count) > + if (!size) > return 0; > > - if (end_pos < 0 || pos < end_pos) { > - unsigned int copy = end_pos < 0 ? count : min(count, end_pos - pos); > + if (size_total < 0 || offset < size_total) { And why would it be < 0? The call sites of this inline are all inside of: int copy_xstate_to_kernel(void *kbuf, struct xregs_state *xsave, unsigned int offset_start, int size_total) and hand in size_total completely unmodified. copy_xstate_to_kernel() itself has a single callsite: int xstateregs_get(struct task_struct *target, const struct user_regset *regset, unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf) and that hands in count unmodified. The same issue is with the to_user() variant which is even more obvious. All callers are inside of copy_xstate_to_user() where size_total is an unsigned int argument which is handed in unmodified. This signed/unsigned mismatch is confusing at best. Thanks, tglx