Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3107889pxk; Mon, 7 Sep 2020 03:30:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzywA6/Rw6xXXTt+bsnJ7hh7B69f76CC8xD62Khl2vCsLJrUwYhl92Dmp8LftqQgIODSno3 X-Received: by 2002:a50:ba8c:: with SMTP id x12mr21853453ede.319.1599474617362; Mon, 07 Sep 2020 03:30:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599474617; cv=none; d=google.com; s=arc-20160816; b=0RYRKhITyKyXOo/D/NEabJJZ7Y5y/DQ2yR0dny8dQlzvBA7eOY3zwoXcHKBZdpXeTR oTPmlRhxihHsK62nUHrGO522uOUWcTi6NL8c23gnxXS8CoUM741heehIUaYLgv325n1Q wsmj50qRs4dvJ1Of0ml+HAunSx0djSdXXfCZaaATfxieje/kXnAnmONqk9aCV7kAGfiZ hUfIdReEtp6t3dxKkOo08jRrgTj1oY380SH/1IfLb6kGLKqEy+TsJkLlGAqfCzdoBp/m 6WqBNlINUo4MkKaLlKwjS6cewWX/llAijmYHvnhFN0fm17I3y7IcSNJOS/V+Khb/DAWN czTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=E+6kvSO+kGtFqzwSOsHYLQdHmE8ihK39UIVQKLTGAlE=; b=h8u3Ua9IZQVmOKOEHKW/Iz6t3lIjZKfDMxT9fI1E4oNoFvIeazMdBd2pst+tgMHf3Q dXzIaj/g0NQIa3cvFU2l3G36ALGpSo/X/R5OCJlXXHXvk/pmSwN7nHSbAMp+jnMafn4p QUTvWcaMAkihvILPEU5QsjOx86awzG0ZAvpjbUQbgAJ/hJ4xg+c2hJb5RSI4bvRWWf7F IvRNAFrwPd7HC0ZTlaZMBlCAY49RM1605ZyWB4dgtIsZO0HQCKdwopKe6lpTkUcepeTx VZbU4QKdAFKzOhskvEaG816+xBQ/AYB4r61A78P8VaYqQGI+7UKRIwiU39UvLOL6q19t rWlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=YKpxYuJt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n12si8855743edv.103.2020.09.07.03.29.54; Mon, 07 Sep 2020 03:30:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=YKpxYuJt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728886AbgIGK3T (ORCPT + 99 others); Mon, 7 Sep 2020 06:29:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728951AbgIGK2T (ORCPT ); Mon, 7 Sep 2020 06:28:19 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48B0CC061757 for ; Mon, 7 Sep 2020 03:28:17 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id lo4so17551726ejb.8 for ; Mon, 07 Sep 2020 03:28:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=E+6kvSO+kGtFqzwSOsHYLQdHmE8ihK39UIVQKLTGAlE=; b=YKpxYuJtNjDEcMyhlLGRj0HX0hQkUXEqPjKuUoBXv/e3UDUS4Hln7rKvyvdJTkScwl k1rXYkIZAbO2UsMaPTxTaUrbbBWUu4R8sdHC0L1BG0mGaX4xk380OjSevy0ECUxykK/F W0r2qxkPzqjPoDdZ8gzABSBUnDIUQFXvKxYS4mab97WFlQCFfhbvkd4IVjnPhoWyKel2 XD9I7vu5rWTXsRIKY4qpSRmj1lEfs+bqL5eIbLSlZkr5OCsU1EbDHMwj00krDCJyqj4O gmJBrn/Lyg7t/40d/iHFqrkkALM3z3AbVL2yVDPRt/STFncNY1w/mvM9VKLyly28uSNr Y8vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=E+6kvSO+kGtFqzwSOsHYLQdHmE8ihK39UIVQKLTGAlE=; b=UkO9KUqjtW2HKhJhXA/KuZwuBlObVgwZXgjCQOvf9o6141YhKdLosiF1olu40uc907 QCGmNPNjezJODKFAoB2470I1RAcwXYQWIOx7gz5UEtaEQ9vwCcxAW3eGSPqAB42swp8O cSCY6BH5owtRehmzMTE4PHhYZ1jKcfWabKdgaES/3M/HTYq+0ZkVt3VXcH34RarKyMWr mYAoUAfyjuvYb2GbExD6pFvrwb/fTt+iNUj4lSZEOLZf845NVa1T559BFQDiszi/XruE Qt2YJuKeG0K/zrgN1uwqqtBXv1RlRXwkQytRAVZcr2fotN0fh6rRw3qoBHxyChhKGyol G14g== X-Gm-Message-State: AOAM531oV1lGCIUusQAvrTFErhQ5Htt8KHGTkerk6JeA35iA6XiPnzsR DxuiyiwoKrM6wEzLCZuBbVJsZG+u/zlrz7s5K6snRYjMrF8= X-Received: by 2002:a17:906:941a:: with SMTP id q26mr20103973ejx.496.1599474496010; Mon, 07 Sep 2020 03:28:16 -0700 (PDT) MIME-Version: 1.0 References: <20200904154547.3836-1-brgl@bgdev.pl> <20200904154547.3836-4-brgl@bgdev.pl> <20200904163517.GW1891694@smile.fi.intel.com> In-Reply-To: From: Bartosz Golaszewski Date: Mon, 7 Sep 2020 12:28:05 +0200 Message-ID: Subject: Re: [PATCH 03/23] lib: uaccess: provide getline_from_user() To: Andy Shevchenko Cc: Andy Shevchenko , Bartosz Golaszewski , Linus Walleij , Jonathan Corbet , Mika Westerberg , Kent Gibson , linux-gpio , linux-doc , LKML , ACPI Devel Maling List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 7, 2020 at 12:19 PM Andy Shevchenko wrote: > > On Mon, Sep 7, 2020 at 1:05 PM Bartosz Golaszewski > wrote: > > On Fri, Sep 4, 2020 at 6:35 PM Andy Shevchenko > > wrote: > > > On Fri, Sep 04, 2020 at 05:45:27PM +0200, Bartosz Golaszewski wrote: > > > > From: Bartosz Golaszewski > > > > Doesn't mm/util.c provides us something like this? > > > strndup_user()? > > > > > > > Yes, there's both strndup_user() as well as strncpy_from_user(). The > > problem is that they rely on the strings being NULL-terminated. This > > is not guaranteed for debugfs file_operations write callbacks. We need > > some helper that takes the minimum of bytes provided by userspace and > > the buffer size and figure out how many bytes to actually copy IMO. > > Wouldn't this [1] approach work? > > [1]: https://elixir.bootlin.com/linux/v5.9-rc3/source/arch/x86/kernel/cpu/mtrr/if.c#L93 > Sure, but this is pretty much what I do in getline_from_user(). If anything we should port mtrr_write() to using getline_from_user() once it's available upstream, no? Bart