Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1196363

Re: [PATCHv2 1/1] Documentation: describe how to add a system call

From Josh Triplett <josh@joshtriplett.org>
Newsgroups linux.kernel
Subject Re: [PATCHv2 1/1] Documentation: describe how to add a system call
Date 2015-07-30 20:30 +0200
Message-ID <pS0KB-6m6-1@gated-at.bofh.it> (permalink)
References <pRQUW-t0-23@gated-at.bofh.it> <pRQUW-t0-21@gated-at.bofh.it> <pRRxD-1rf-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCHv2 1/1] Documentation: describe how to add a system call David Drysdale <drysdale@google.com> - 2015-07-30 10:00 +0200
  Re: [PATCHv2 1/1] Documentation: describe how to add a system call Ingo Molnar <mingo@kernel.org> - 2015-07-30 10:40 +0200
    Re: [PATCHv2 1/1] Documentation: describe how to add a system call David Drysdale <drysdale@google.com> - 2015-07-30 13:20 +0200
      Re: [PATCHv2 1/1] Documentation: describe how to add a system call Kees Cook <keescook@chromium.org> - 2015-07-30 20:30 +0200
        Re: [PATCHv2 1/1] Documentation: describe how to add a system call Josh Triplett <josh@joshtriplett.org> - 2015-07-30 21:10 +0200
          Re: [PATCHv2 1/1] Documentation: describe how to add a system call Kees Cook <keescook@chromium.org> - 2015-07-30 22:10 +0200
    Re: [PATCHv2 1/1] Documentation: describe how to add a system call Josh Triplett <josh@joshtriplett.org> - 2015-07-30 20:30 +0200
  Re: [PATCHv2 1/1] Documentation: describe how to add a system call Josh Triplett <josh@joshtriplett.org> - 2015-07-30 21:00 +0200

csiph-web