Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3104233pxk; Mon, 7 Sep 2020 03:22:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx66tJLEsiK+1aX1JRueOeaDAT/dSkboLYqzmYWT1Ajos/GIHibCXmMU4GsETFiuukn67+k X-Received: by 2002:a17:907:374:: with SMTP id rs20mr21158737ejb.135.1599474174287; Mon, 07 Sep 2020 03:22:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599474174; cv=none; d=google.com; s=arc-20160816; b=d8+TbXLrDoJPpn2UdXixKSjs2flMeo3AhYXwoE6ozXV8dsGBB1pi821RWOKi2ZvaBC zl/xP6uNx3sZIgvUg+5d7R31W6XdPQPesCM75GdplCH0tqkejGT2DgqYvTpTl8Bgkruf jyzkvmkhUmJqDXWRZCj0mem50U2o4P57xM6qKTCSGxcxWBXvwCi3nfcFB9BBaRflj+qW 2bPeGz5EHy/q3RBRExgd6DSsSS9fCBDkCUPeE+lxo099DrG5YK0ISjrl6kyupBJxJcVe Ypyb7RtteOtQtLhd8rQlGchDVif4/X/K4JiyI73e9gM6Cq6hy8RRSExEY9wsr9hotU6s NvyA== 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=1O4Zn9P7hXV8yBwWw3nrL/yAlWgmCWvaLQgGvTWSTiU=; b=drRg5HEoCBDDiOk2d8EraV6lnqFDlS7hc+ftK2MDUnKoErtQ/VM6hpuFWoqUNvmjU4 X9fzUzL+PGZOI3OZ285SYZFzZcah/D9t44MnL50r08q6BVWRimwqPMafpB3ujytyfLjz SA7aCRjpN8QXbv4Ra6TuFTO8EP9HtCjtDY5lFlGdA7bGR/RaKcUX/3/CM676Tn+kriYo Yz3pB6WDdJXpTTuN1LagVws9J7peznrQ5O2IbD5XcueilD+FT5E0i2OJxDJO66ufAaL6 5VKRCeX9aSBZIv6AW6pLsSlbkIYKOeCgDSScnAdCDYwik4AEdxLsyX+3lM75OdPR8Bmf 35gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RYaB7CQH; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s20si10534658eji.313.2020.09.07.03.22.32; Mon, 07 Sep 2020 03:22:54 -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=@gmail.com header.s=20161025 header.b=RYaB7CQH; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728873AbgIGKT1 (ORCPT + 99 others); Mon, 7 Sep 2020 06:19:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728785AbgIGKTI (ORCPT ); Mon, 7 Sep 2020 06:19:08 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77400C061573; Mon, 7 Sep 2020 03:19:08 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id 31so7809308pgy.13; Mon, 07 Sep 2020 03:19:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1O4Zn9P7hXV8yBwWw3nrL/yAlWgmCWvaLQgGvTWSTiU=; b=RYaB7CQHhLnCHtIJffl5L81Pte42BfwB7BEbyWq3Zxp50y0qtwg4iD+iFd708zJot+ KbvxwnJJYgQWkw4kE+jQPlTUGoNkPq/tTc2ayTXC7ok4Es6v/kYXNRlK2islDzK+TnrR MeiU/4TJjGqeoY8pYLWMnqGemtQ9xOQB61GdgWRO+hucjohRzVTI41obIyg5vvD0011m hSFMWgCgqyacafyxsNcn2GwGSiZT4Y/yE69GTAsDhmVMiWYx8qYnVB53aVfXvJ/VAXSw dzHZJCbyBug2pJa0yQnpmBxztN2qscKjAqr7i9rZ6SAMRa0o9EbJn4iktsr3nDgJKIWt i95Q== 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=1O4Zn9P7hXV8yBwWw3nrL/yAlWgmCWvaLQgGvTWSTiU=; b=WENYWQ+ewL3CsSDR5SpHF/czAkWKDLPzG9BmdT83gh1v7iG1rufC/EvJGOM6tcYvIz Pc9lS1BlImbB3eGEBtFiiMasp2HKsuJ7QxQoz0EtiAmdsBcMDbgOCPOkAQEfLqVDXpQ0 +B7Mp3XucB1WXkSI2pmAqypYr0inKsajmLxPHW6eFEeAV01t3FoUHO2F6u0jxQxTCPRW hUMFPgK7TjtBWSfxVsvGvlR1yQ8XAr1PdVTlJQwN3uYYV5pLX+XLB7RcLIqjohso6faW XKBbiIUEfW++jcwuFmUn4Qy9Q0+kK6IlbGrbZmO49fygsoNwem22GLgH4ivFaeYuE9Kh uWSw== X-Gm-Message-State: AOAM530Vb6nml23k73nzWX66xmcMpnOnE1VsXluRDoDkzNssO2dbsaf7 36628BSta7OfRkCbBwkpnnaTXd+QTRMWZQRB/ImF85Xw+eUbpU3Q X-Received: by 2002:a63:c543:: with SMTP id g3mr16545032pgd.203.1599473946680; Mon, 07 Sep 2020 03:19:06 -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: Andy Shevchenko Date: Mon, 7 Sep 2020 13:18:49 +0300 Message-ID: Subject: Re: [PATCH 03/23] lib: uaccess: provide getline_from_user() To: Bartosz Golaszewski 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 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 -- With Best Regards, Andy Shevchenko