Received: by 2002:a05:6520:3645:b029:c0:f950:43e0 with SMTP id l5csp337393lki; Mon, 22 Feb 2021 07:49:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJyV6yk/2NEKBGgyx2w785E3d6LvrGC4olBLVGUJs+YmBU43OdZzlcmEOYlijdjpCytt8qF0 X-Received: by 2002:a17:907:da9:: with SMTP id go41mr21656184ejc.326.1614008940277; Mon, 22 Feb 2021 07:49:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614008940; cv=none; d=google.com; s=arc-20160816; b=SDkGJp7iF0kHpluh2x0LqP38yAZ47Y8lkGdqdztgyOtUThphRjzWLoI0sUf9kiOVIh i/19h0GBLEsp/HnsIjM5k1wZcU5KQcNrtu/F+Wg010tbT5h1wCxRLG3YMnayP2BalLaa fCUN5Lkg16HSXIFlJx2pXVROiSTeS6Tjl8K/qVOMNbTzxYfoU2S32vDr1z3lK5I0IaXM ptRVHoP3pajYcorRC/HG4qFixDZayg3GUCkl43dnZYqd6ASHDSKSiwpWGzFEVuDCtifv s4aF1NZP1AMszLpUPKuYbYJ9mknESoXkbYpPKqDMTX43dLRVLfeshqCWz2nfWAoJR0Or BGUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:autocrypt:from :references:cc:to:subject:sender:dkim-signature; bh=vHkq8WDTCU+eTW+Y+ogXk/LjXUPfvpkd05kCTtdlmLw=; b=i6CdYGzeu1KHADTltA07kPBN4ECUZBGuqxRTr+9k4KHYm76HfndCFeKQjjeTWbxIf9 oIJqfPTfFFlRxcUKaUmZjS3+wVw63B+bK8aNHsHbT2Yyq/ogMiz/4KCnum2Gp21r5o9q oz+s2J5vXrVyDojR5wjWNJXFpaxA5KjbGsYdXf/CAfqNqLAXWL3XL017I39JKDQk01hM SS0nFf+EscWvKl5z0fKQAu7kS+T0Nowfi2472OCHdkpGNgkusohKH39PkmWrT5DWP6sr GYycZiZbhND4FWHSqlhfHMqiClRug1EH24oeSOK+zSaqdFTkTfo48g2zYwnQKL2gA1Tl nNEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KOO32uLa; 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 dp16si12851703ejc.520.2021.02.22.07.48.37; Mon, 22 Feb 2021 07:49:00 -0800 (PST) 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=KOO32uLa; 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 S230037AbhBVPrK (ORCPT + 99 others); Mon, 22 Feb 2021 10:47:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230084AbhBVPq7 (ORCPT ); Mon, 22 Feb 2021 10:46:59 -0500 Received: from mail-oo1-xc32.google.com (mail-oo1-xc32.google.com [IPv6:2607:f8b0:4864:20::c32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83DDFC061574; Mon, 22 Feb 2021 07:46:17 -0800 (PST) Received: by mail-oo1-xc32.google.com with SMTP id f26so3055983oog.5; Mon, 22 Feb 2021 07:46:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=vHkq8WDTCU+eTW+Y+ogXk/LjXUPfvpkd05kCTtdlmLw=; b=KOO32uLaiXzFh0O2LFZ9bBgNrS6MwjmBM0YFq+L6jlki8ag/VzPUdSNECSrbAKH0JB mz8wg9sJNZ4GzG9Yi62+1CkS8ZG0obC+xiQh5PzjZnlFHEmvnGf+q9Yqh8uY3gdQCivP iwkahzfXOiyj1vU3+1AWSHAdqlW3aamaOnodqMcnp0Rf982swQyJOGCfRbxVEpNyL2B4 kFpE6doy47DwJHpfvoxXoi76tPL9djiTImEXQBO7Y5uG/80POF5PcjsJSrHcHlJckDkC U02k1p59IRmdBesZx4P+R/l95TcuOlQObI1YGR/lt2OfsabrLZ+kPU0uIYDLKD9l3KCB 3QbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=vHkq8WDTCU+eTW+Y+ogXk/LjXUPfvpkd05kCTtdlmLw=; b=q6O6aQ5yOAarzlDM4FlaIrGnoHcIEmr+TTr2YpTqF/jbPg7MV2QjleiGCQHUl2RkOe shXIVO03SCJx3pvbOPwBiSNnMnruP8SKZWRXSUXtIUK/xwN2mRp2iKD/e41AtcX6euBj qh2ktD3NCjv01QaHmM7Qo65Ti+kG35G1kqa7Gdx5fGI/G8efJ7lfYMbjnpTPVZ7KpmoH s3ph/1qdy/r5J1U8awGN7pc0qHoH6ZKuoC/gnq/Sdde3ApF0XJFEfIAdvB7Zkx88/vYc DGueVoTZDxbrSCU76EViL9DQ1c6N6H1roqUVigTj0QXuPSzUVpwjWnEEwAXwkhSpLXWW ps9A== X-Gm-Message-State: AOAM532S8GNd9cFQonp4AFEApPvV1i9xMiYXtvdXIG7urdK7siXxLqkD cHYHwfI12u32TwZIrjxnSLUjLMMq3MY= X-Received: by 2002:a4a:ab08:: with SMTP id i8mr16739312oon.40.1614008776621; Mon, 22 Feb 2021 07:46:16 -0800 (PST) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id 88sm3701594oto.3.2021.02.22.07.46.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Feb 2021 07:46:16 -0800 (PST) Sender: Guenter Roeck Subject: Re: [PATCH 11/20] hwmon: Manual replacement of the deprecated strlcpy() with return values To: Romain Perier , Kees Cook , kernel-hardening@lists.openwall.com Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210222151231.22572-1-romain.perier@gmail.com> <20210222151231.22572-12-romain.perier@gmail.com> From: Guenter Roeck Autocrypt: addr=linux@roeck-us.net; keydata= xsFNBE6H1WcBEACu6jIcw5kZ5dGeJ7E7B2uweQR/4FGxH10/H1O1+ApmcQ9i87XdZQiB9cpN RYHA7RCEK2dh6dDccykQk3bC90xXMPg+O3R+C/SkwcnUak1UZaeK/SwQbq/t0tkMzYDRxfJ7 nyFiKxUehbNF3r9qlJgPqONwX5vJy4/GvDHdddSCxV41P/ejsZ8PykxyJs98UWhF54tGRWFl 7i1xvaDB9lN5WTLRKSO7wICuLiSz5WZHXMkyF4d+/O5ll7yz/o/JxK5vO/sduYDIlFTvBZDh gzaEtNf5tQjsjG4io8E0Yq0ViobLkS2RTNZT8ICq/Jmvl0SpbHRvYwa2DhNsK0YjHFQBB0FX IdhdUEzNefcNcYvqigJpdICoP2e4yJSyflHFO4dr0OrdnGLe1Zi/8Xo/2+M1dSSEt196rXaC kwu2KgIgmkRBb3cp2vIBBIIowU8W3qC1+w+RdMUrZxKGWJ3juwcgveJlzMpMZNyM1jobSXZ0 VHGMNJ3MwXlrEFPXaYJgibcg6brM6wGfX/LBvc/haWw4yO24lT5eitm4UBdIy9pKkKmHHh7s jfZJkB5fWKVdoCv/omy6UyH6ykLOPFugl+hVL2Prf8xrXuZe1CMS7ID9Lc8FaL1ROIN/W8Vk BIsJMaWOhks//7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YMg5DRnBk WkRwrSuCn7UG+qVWZeKEsFKFOkynOs3pVbcbq1pxbhk3TRWCGRU5JolI4ohy/7JV1TVbjiDI HP/aVnm6NC8of26P40Pg8EdAhajZnHHjA7FrJXsy3cyIGqvg9os4rNkUWmrCfLLsZDHD8FnU mDW4+i+XlNFUPUYMrIKi9joBhu18ssf5i5Q= Message-ID: <3b8dd556-8c09-9686-dec6-9d523a9762a8@roeck-us.net> Date: Mon, 22 Feb 2021 07:46:14 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210222151231.22572-12-romain.perier@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/22/21 7:12 AM, Romain Perier wrote: > The strlcpy() reads the entire source buffer first, it is dangerous if > the source buffer lenght is unbounded or possibility non NULL-terminated. length > It can lead to linear read overflows, crashes, etc... > Not here. This description is misleading. > As recommended in the deprecated interfaces [1], it should be replaced > by strscpy. > > This commit replaces all calls to strlcpy that handle the return values > by the corresponding strscpy calls with new handling of the return > values (as it is quite different between the two functions). > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy > > Signed-off-by: Romain Perier This patch just adds pain to injury, as the source 'buffers' are all fixed strings and their length will never exceed the maximum buffer length. I really don't see the point of using strscpy() in this situation. > --- > drivers/hwmon/pmbus/max20730.c | 66 +++++++++++++++++++++-------------------- This patch only modifies a single driver and should be tagged as such. > 1 file changed, 35 insertions(+), 31 deletions(-) > > diff --git a/drivers/hwmon/pmbus/max20730.c b/drivers/hwmon/pmbus/max20730.c > index 9dd3dd79bc18..a384b57b7327 100644 > --- a/drivers/hwmon/pmbus/max20730.c > +++ b/drivers/hwmon/pmbus/max20730.c > @@ -107,7 +107,8 @@ struct max20730_debugfs_data { > static ssize_t max20730_debugfs_read(struct file *file, char __user *buf, > size_t count, loff_t *ppos) > { > - int ret, len; > + int ret; > + ssize_t len; > int *idxp = file->private_data; > int idx = *idxp; > struct max20730_debugfs_data *psu = to_psu(idxp, idx); > @@ -148,13 +149,13 @@ static ssize_t max20730_debugfs_read(struct file *file, char __user *buf, > >> MAX20730_MFR_DEVSET1_TSTAT_BIT_POS; > > if (val == 0) > - len = strlcpy(tbuf, "2000\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "2000\n", DEBUG_FS_DATA_MAX); > else if (val == 1) > - len = strlcpy(tbuf, "125\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "125\n", DEBUG_FS_DATA_MAX); > else if (val == 2) > - len = strlcpy(tbuf, "62.5\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "62.5\n", DEBUG_FS_DATA_MAX); > else > - len = strlcpy(tbuf, "32\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "32\n", DEBUG_FS_DATA_MAX); > break; > case MAX20730_DEBUGFS_INTERNAL_GAIN: > val = (data->mfr_devset1 & MAX20730_MFR_DEVSET1_RGAIN_MASK) > @@ -163,35 +164,35 @@ static ssize_t max20730_debugfs_read(struct file *file, char __user *buf, > if (data->id == max20734) { > /* AN6209 */ > if (val == 0) > - len = strlcpy(tbuf, "0.8\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "0.8\n", DEBUG_FS_DATA_MAX); > else if (val == 1) > - len = strlcpy(tbuf, "3.2\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "3.2\n", DEBUG_FS_DATA_MAX); > else if (val == 2) > - len = strlcpy(tbuf, "1.6\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "1.6\n", DEBUG_FS_DATA_MAX); > else > - len = strlcpy(tbuf, "6.4\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "6.4\n", DEBUG_FS_DATA_MAX); > } else if (data->id == max20730 || data->id == max20710) { > /* AN6042 or AN6140 */ > if (val == 0) > - len = strlcpy(tbuf, "0.9\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "0.9\n", DEBUG_FS_DATA_MAX); > else if (val == 1) > - len = strlcpy(tbuf, "3.6\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "3.6\n", DEBUG_FS_DATA_MAX); > else if (val == 2) > - len = strlcpy(tbuf, "1.8\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "1.8\n", DEBUG_FS_DATA_MAX); > else > - len = strlcpy(tbuf, "7.2\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "7.2\n", DEBUG_FS_DATA_MAX); > } else if (data->id == max20743) { > /* AN6042 */ > if (val == 0) > - len = strlcpy(tbuf, "0.45\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "0.45\n", DEBUG_FS_DATA_MAX); > else if (val == 1) > - len = strlcpy(tbuf, "1.8\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "1.8\n", DEBUG_FS_DATA_MAX); > else if (val == 2) > - len = strlcpy(tbuf, "0.9\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "0.9\n", DEBUG_FS_DATA_MAX); > else > - len = strlcpy(tbuf, "3.6\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "3.6\n", DEBUG_FS_DATA_MAX); > } else { > - len = strlcpy(tbuf, "Not supported\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "Not supported\n", DEBUG_FS_DATA_MAX); > } > break; > case MAX20730_DEBUGFS_BOOT_VOLTAGE: > @@ -199,26 +200,26 @@ static ssize_t max20730_debugfs_read(struct file *file, char __user *buf, > >> MAX20730_MFR_DEVSET1_VBOOT_BIT_POS; > > if (val == 0) > - len = strlcpy(tbuf, "0.6484\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "0.6484\n", DEBUG_FS_DATA_MAX); > else if (val == 1) > - len = strlcpy(tbuf, "0.8984\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "0.8984\n", DEBUG_FS_DATA_MAX); > else if (val == 2) > - len = strlcpy(tbuf, "1.0\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "1.0\n", DEBUG_FS_DATA_MAX); > else > - len = strlcpy(tbuf, "Invalid\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "Invalid\n", DEBUG_FS_DATA_MAX); > break; > case MAX20730_DEBUGFS_OUT_V_RAMP_RATE: > val = (data->mfr_devset2 & MAX20730_MFR_DEVSET2_VRATE) > >> MAX20730_MFR_DEVSET2_VRATE_BIT_POS; > > if (val == 0) > - len = strlcpy(tbuf, "4\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "4\n", DEBUG_FS_DATA_MAX); > else if (val == 1) > - len = strlcpy(tbuf, "2\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "2\n", DEBUG_FS_DATA_MAX); > else if (val == 2) > - len = strlcpy(tbuf, "1\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "1\n", DEBUG_FS_DATA_MAX); > else > - len = strlcpy(tbuf, "Invalid\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "Invalid\n", DEBUG_FS_DATA_MAX); > break; > case MAX20730_DEBUGFS_OC_PROTECT_MODE: > ret = (data->mfr_devset2 & MAX20730_MFR_DEVSET2_OCPM_MASK) > @@ -230,13 +231,13 @@ static ssize_t max20730_debugfs_read(struct file *file, char __user *buf, > >> MAX20730_MFR_DEVSET2_SS_BIT_POS; > > if (val == 0) > - len = strlcpy(tbuf, "0.75\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "0.75\n", DEBUG_FS_DATA_MAX); > else if (val == 1) > - len = strlcpy(tbuf, "1.5\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "1.5\n", DEBUG_FS_DATA_MAX); > else if (val == 2) > - len = strlcpy(tbuf, "3\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "3\n", DEBUG_FS_DATA_MAX); > else > - len = strlcpy(tbuf, "6\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "6\n", DEBUG_FS_DATA_MAX); > break; > case MAX20730_DEBUGFS_IMAX: > ret = (data->mfr_devset2 & MAX20730_MFR_DEVSET2_IMAX_MASK) > @@ -287,9 +288,12 @@ static ssize_t max20730_debugfs_read(struct file *file, char __user *buf, > "%d.%d\n", ret / 10000, ret % 10000); > break; > default: > - len = strlcpy(tbuf, "Invalid\n", DEBUG_FS_DATA_MAX); > + len = strscpy(tbuf, "Invalid\n", DEBUG_FS_DATA_MAX); > } > > + if (len == -E2BIG) > + return -E2BIG; > + > return simple_read_from_buffer(buf, count, ppos, tbuf, len); > } > >