Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758903AbcDHVEX (ORCPT ); Fri, 8 Apr 2016 17:04:23 -0400 Received: from mail-vk0-f51.google.com ([209.85.213.51]:36157 "EHLO mail-vk0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750819AbcDHVEW (ORCPT ); Fri, 8 Apr 2016 17:04:22 -0400 MIME-Version: 1.0 From: Andrew Kelley Date: Fri, 8 Apr 2016 14:04:00 -0700 Message-ID: Subject: alternatives to null-terminated byte arrays in syscalls in the future? To: linux-kernel@vger.kernel.org Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 858 Lines: 20 The open syscall looks like this: SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, umode_t, mode) filename is a null terminated byte array. Null termination is one way to handle lengths of byte arrays, but arguably a better way is to keep track of the length in a separate field. Many programming languages use pointer + length instead of null termination for various reasons. When it's time to make a syscall such as open, software which does not have a null character at the end of byte arrays are forced to allocate memory, do a memcpy, insert a null byte, perform the open syscall, then deallocate the memory. What are the chances that in the future, Linux will have alternate syscalls which accept byte array parameters where one can pass the length of the byte array explicitly instead of using a null byte? Regards, Andrew Kelley