Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3094365pxk; Mon, 7 Sep 2020 03:04:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5ZHyYtW66l1mR8v7jQFTV9ccEtrvrHhQNgantPssqO4OfvlrpO5vsjk3WTL4zrzqcqokZ X-Received: by 2002:a17:906:1719:: with SMTP id c25mr21061085eje.487.1599473049579; Mon, 07 Sep 2020 03:04:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599473049; cv=none; d=google.com; s=arc-20160816; b=obZSNUqSdgDPN/f6YJv91ZG4IuYSvAlTa3tL1/m6hIhxlfYHiNP3DMo/suPF476FI8 FnfBbjnb27GGAhpbsai8zWtIOHLXiTMkdWYIGyntdAdLEhJILiYFJ2aB450+oMRTXuYz C4cVkahUi0WkoHF+zq169kvNHwM7Wf5YSid3Ay+kmoUjjcQOC7ckdCkdrRy9/v0kGAyV lnTZG0pNr3MkKjesEq+MDDT4Ssc/O8mfPXtgWT6RaLvXne4b3Lux+SL47QgDGSF+4yUg bBd8IlRbvJqP7Lzt8J/HgzOUXdFgWDlgt8yDHyKjbjGwSbanYaZCFad1IqCsR3MbCfOm USsw== 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=eu0tVdC2SapQmxPGnrOiQAZ5HG6pSAsS9H4UlH7DET8=; b=ImakZKc4YfTd55fGBFBC/cl1puLs9iL71AHN+cuCVXKhAkGMJYbw4zR6GSXc+aQkUl 8YvrHfpxr2tiNZvmHC47HBEMfNDjhh9Gobb3/2RNOTHBQaD5qB70Q55P1CBHeTfbhpHH V/vLRbDd9pAZJVWq2xVmujC4tyW3m1Ke8w9tYf/+H+RWtGAP2NDB7Dp+Ihwp59qgEeWe ct7MpkEi07TH+TfwC6Agr1iwt4xisTp00aBBOP63h1ShmxdI5uhrY/MsU0UxFmxpsJcP ouveHVHlHDnBwPY0nhheTL43syGYWwco2/cFbZbgbbLpApo3AAP0+tRe1vGgWpQ0fTZy zh9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=ugGVMJW5; 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 g1si9359790ejz.637.2020.09.07.03.03.47; Mon, 07 Sep 2020 03:04:09 -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=ugGVMJW5; 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 S1728413AbgIGKDI (ORCPT + 99 others); Mon, 7 Sep 2020 06:03:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728395AbgIGKDF (ORCPT ); Mon, 7 Sep 2020 06:03:05 -0400 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DEF7C061573 for ; Mon, 7 Sep 2020 03:03:04 -0700 (PDT) Received: by mail-ed1-x542.google.com with SMTP id q21so12214939edv.1 for ; Mon, 07 Sep 2020 03:03:04 -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=eu0tVdC2SapQmxPGnrOiQAZ5HG6pSAsS9H4UlH7DET8=; b=ugGVMJW5RJbLvOkkPTzMtesjDjGP+0VKjWNbvyeyw2RAMXE6OInFtbSWjFRmI2mEZS Qsd8ZTpoPGy21huaFxq7lp3WRwdQ2JfnmeqB9iOMeg5qjFXrc5D3naTXSyS3YuGEFwBm oRbHf7veaLO0JOYUz/DRU9qgAEXENey2/qrOyy7qen1h8LeM1btTG83H6yE/8QPWql7s PzxcpQ97iEe6gy1nn1Kp/keE93njE+5j0WNLrCc2AomoVHBqeHFuwlm8+z6haucaxF0Z 72HZWjDalObdCuk9FIuI/j7BVINn0EVKCXAj8MCKTFXVU4ebqr3a2n1HRESpqbxbLXcv oUoA== 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=eu0tVdC2SapQmxPGnrOiQAZ5HG6pSAsS9H4UlH7DET8=; b=lYmR9dDiS7Zg/VgGG5jIhyW1FXaQ1BPOpadH0IjRLudjMoRVtSkk+vz3SbOCOsNFXS 94EdndLFqLZkpaJPQ15x2j+4uw8mpo+xriD4yD16zofbH13IHmYS+aZsEXaNQK0c0Ukp /cU6xaXEHo1EhUw2n5WjIjbxn3/+Qs4p9bx+L48vzBla1eSVWbjRDwnccCWopbsYDstj fv0wUxmCj8Gc+DpsQ1BgSD055DrRoM5tvDDvio4BHO52Bc8bCl5WQ1oz7F2wfEhFy3yf DU4ReAeJSs1iIDOpIs8g5wxK6kPNvCIajOf3dcf+GXrxG9JvuK6JeRp+pqGJlPdZMOlj DuHg== X-Gm-Message-State: AOAM532WW8ePaASRRmKDPJrVY08AoK4ahkc8o357BDYjb85Qt+ulPSQ7 OX0zmYYvbskC99Dzxr9p31l99KTWNHfK8zQ1jOFVow== X-Received: by 2002:a50:d809:: with SMTP id o9mr20387639edj.12.1599472983149; Mon, 07 Sep 2020 03:03:03 -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: <20200904163517.GW1891694@smile.fi.intel.com> From: Bartosz Golaszewski Date: Mon, 7 Sep 2020 12:02:52 +0200 Message-ID: Subject: Re: [PATCH 03/23] lib: uaccess: provide getline_from_user() To: Andy Shevchenko Cc: Bartosz Golaszewski , Linus Walleij , Jonathan Corbet , Mika Westerberg , Kent Gibson , linux-gpio , linux-doc , LKML , linux-acpi@vger.kernel.org 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 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 > > > > Provide a uaccess helper that allows callers to copy a single line from > > user memory. This is useful for debugfs write callbacks. > > 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. Bart