Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753818AbbG3SWZ (ORCPT ); Thu, 30 Jul 2015 14:22:25 -0400 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:48498 "EHLO relay2-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753424AbbG3SWX (ORCPT ); Thu, 30 Jul 2015 14:22:23 -0400 X-Originating-IP: 50.43.43.179 Date: Thu, 30 Jul 2015 11:22:05 -0700 From: Josh Triplett To: Ingo Molnar Cc: David Drysdale , linux-api@vger.kernel.org, Michael Kerrisk , Andrew Morton , Arnd Bergmann , Shuah Khan , Jonathan Corbet , Eric B Munson , Randy Dunlap , Andrea Arcangeli , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Oleg Nesterov , Linus Torvalds , Greg Kroah-Hartman , Andy Lutomirski , Al Viro , Rusty Russell , Peter Zijlstra , Vivek Goyal , Alexei Starovoitov , David Herrmann , "Theodore Ts'o" , Kees Cook , Miklos Szeredi , Milosz Tanski , Fam Zheng , Mathieu Desnoyers , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Zijlstra Subject: Re: [PATCHv2 1/1] Documentation: describe how to add a system call Message-ID: <20150730182205.GB16452@x> References: <1438242731-27756-1-git-send-email-drysdale@google.com> <1438242731-27756-2-git-send-email-drysdale@google.com> <20150730083831.GA22182@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150730083831.GA22182@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1556 Lines: 30 On Thu, Jul 30, 2015 at 10:38:31AM +0200, Ingo Molnar wrote: > When the system call is extended in the future on the kernel side, with 'u64 > param_4', then the structure expands from an old size of 24 to a new size of 32 > bytes. The following scenarios might occur: > > - the common case: new user-space calls the new kernel code, ->size is 32 on both > sides. > > - old binaries might call the kernel with params->size == 24, in which case the > kernel sets the new fields to 0. The new feature should be written > accordingly, so that a value of 0 means the old behavior. > > - new binaries might run on old kernels, with params->size == 32. In this case > the old kernel will check that all the new fields it does not know about are > set to 0 - if they are nonzero (if the new feature is used) it returns with > -ENOSYS or -EINVAL. Nit: it seems easier, rather than having the kernel check this, to have userspace only use the minimum version of the structure that contains the features they use, and then have older kernels reject sizes bigger than they understand. If you don't need param_4, don't use the version of the structure that has param_4. That also means the kernel doesn't need to copy and read those values. Either approach works, though. - Josh Triplett -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/