Skip to content
Snippets Groups Projects
Forked from Alex Deucher / linux
Source project has a limited visibility.
  • Kees Cook's avatar
    6dbefad4
    string.h: Introduce memset_startat() for wiping trailing members and padding · 6dbefad4
    Kees Cook authored
    
    A common idiom in kernel code is to wipe the contents of a structure
    starting from a given member. These open-coded cases are usually difficult
    to read and very sensitive to struct layout changes. Like memset_after(),
    introduce a new helper, memset_startat() that takes the target struct
    instance, the byte to write, and the member name where zeroing should
    start.
    
    Note that this doesn't zero padding preceding the target member. For
    those cases, memset_after() should be used on the preceding member.
    
    Cc: Steffen Klassert <steffen.klassert@secunet.com>
    Cc: Herbert Xu <herbert@gondor.apana.org.au>
    Cc: "David S. Miller" <davem@davemloft.net>
    Cc: Jakub Kicinski <kuba@kernel.org>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Francis Laniel <laniel_francis@privacyrequired.com>
    Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
    Cc: Daniel Axtens <dja@axtens.net>
    Cc: netdev@vger.kernel.org
    Signed-off-by: default avatarKees Cook <keescook@chromium.org>
    6dbefad4
    History
    string.h: Introduce memset_startat() for wiping trailing members and padding
    Kees Cook authored
    
    A common idiom in kernel code is to wipe the contents of a structure
    starting from a given member. These open-coded cases are usually difficult
    to read and very sensitive to struct layout changes. Like memset_after(),
    introduce a new helper, memset_startat() that takes the target struct
    instance, the byte to write, and the member name where zeroing should
    start.
    
    Note that this doesn't zero padding preceding the target member. For
    those cases, memset_after() should be used on the preceding member.
    
    Cc: Steffen Klassert <steffen.klassert@secunet.com>
    Cc: Herbert Xu <herbert@gondor.apana.org.au>
    Cc: "David S. Miller" <davem@davemloft.net>
    Cc: Jakub Kicinski <kuba@kernel.org>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Francis Laniel <laniel_francis@privacyrequired.com>
    Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
    Cc: Daniel Axtens <dja@axtens.net>
    Cc: netdev@vger.kernel.org
    Signed-off-by: default avatarKees Cook <keescook@chromium.org>