From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from zeniv.linux.org.uk ([195.92.253.2]:49178 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751202AbcB2CKt (ORCPT ); Sun, 28 Feb 2016 21:10:49 -0500 Date: Mon, 29 Feb 2016 02:10:47 +0000 From: Al Viro To: Amber Thrall Cc: linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 1/1] fs: strncmp() for user space buffers Message-ID: <20160229021047.GU17997@ZenIV.linux.org.uk> References: <1456699822-2924-1-git-send-email-amber@thrall.me> <20160228230303.GQ17997@ZenIV.linux.org.uk> <20160228233908.GA1982@ARCH> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160228233908.GA1982@ARCH> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Sun, Feb 28, 2016 at 03:39:08PM -0800, Amber Thrall wrote: > Apologies for the confusing name, struggled to find an appropriate name > while staying consistent with the naming schemes of > simple_read/write_to_buffer() functions, as it based off of them. I'd > love to hear alternative names. > > I saw possible uses for this proposed function being an easy way to > interact with debugfs, via their write file operation. For > example in the function xenvif_write_io_ring() the string "kick" is > checked for against a user space buffer. TBH, that caller leaves an impression of rather... poor API - "any write of no more than 32 bytes that starts with 'k' 'i' 'c' 'k' is OK (and everything beyond first 4 characters is ignored), anything else is rejected, in some cases with whining into syslog, in some - quietly". I don't know if encouraging stuff like that is a good idea... In any case, you've ended up open-coding kmemdup_user() + strncmp() + kfree(); the problem with combining those into a single helper is that calling conventions will be very error-prone - you have zero/positive/negative for passing strncmp() result *and* you need to report errors somehow.