From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE850C433E6 for ; Mon, 22 Feb 2021 16:37:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A434264E83 for ; Mon, 22 Feb 2021 16:37:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231433AbhBVQhk (ORCPT ); Mon, 22 Feb 2021 11:37:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231124AbhBVQhg (ORCPT ); Mon, 22 Feb 2021 11:37:36 -0500 Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 022CEC06178B for ; Mon, 22 Feb 2021 08:36:55 -0800 (PST) Received: by mail-ot1-x333.google.com with SMTP id r19so5264623otk.2 for ; Mon, 22 Feb 2021 08:36:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=CQtzj2ET+OspvcT7VasFUJh31XI2DgueE7K7chQefu0=; b=JgIAcXbmqnUtAzeQggrQMFDw+iRD7712f5b6XLlsNpGFq/2OH71ZR8eVPcYSvV8O9Z Q4ZFhr/HY3qIL2VVw5am2ZXMqQjcHv6oQm57icBzxpF2r/H6pUN28Ic0UVcMNAWR0oM3 Nk4pk+06r39DoxUQo5VbU8V6VX0ewSDT/6fu0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=CQtzj2ET+OspvcT7VasFUJh31XI2DgueE7K7chQefu0=; b=r3sA3M30sRIgb71GbuggJCbxRUt11AtSK4GLwgLbDW4VgReNJ65YyHpU+ljd90yKXc xkvKVhVT6tCUhVC0LVSS8f+k97aoRlT2u/1A6u5y53o+6iqnR8KRyriOTNaqKemlYID2 5nBJQuLeGqaQgoMC7RPQ7wYAaIWcXY9UNyWaeHNJGkjawa5hlCdqtgjP9eUV5XPL4Ui3 HaNwmsdZ2HCnRi0BnNVjaYxq7jz/dOsqtnZskjZi7c+CTytjTJN2jVkgTiZEdwhVppDQ jTDXt8EN7zt3+dbps0vPx57bDq1zKQ4g8SdIp4S0FPHrfU3Sj6p1wQtnd0WPZO8PG9KW ysmA== X-Gm-Message-State: AOAM532kjJVfb8i92yIlRNhPAPSSeTO1xwG7HwIkR3tXNzaRG151dK31 TSAlz3IcijW7V6EW45V4Sj6sUQ== X-Google-Smtp-Source: ABdhPJyA692d/UkhfnySsVsus41uILuIidqyduT1DxwFO8wUlVI27VDOIjP5WOhWxUUsjwOOYq7M6Q== X-Received: by 2002:a05:6830:314d:: with SMTP id c13mr16134049ots.124.1614011814286; Mon, 22 Feb 2021 08:36:54 -0800 (PST) Received: from [192.168.1.112] (c-24-9-64-241.hsd1.co.comcast.net. [24.9.64.241]) by smtp.gmail.com with ESMTPSA id 7sm3712035oth.38.2021.02.22.08.36.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Feb 2021 08:36:53 -0800 (PST) Subject: Re: [PATCH 00/20] Manual replacement of all strlcpy in favor of strscpy To: Romain Perier , Kees Cook , kernel-hardening@lists.openwall.com, Tejun Heo , Zefan Li , Johannes Weiner , Herbert Xu , "David S. Miller" , Jiri Pirko , Sumit Semwal , =?UTF-8?Q?Christian_K=c3=b6nig?= , Greg Kroah-Hartman , Mimi Zohar , Dmitry Kasatkin , "J. Bruce Fields" , Chuck Lever , Geert Uytterhoeven , Jessica Yu , Guenter Roeck , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Steffen Maier , Benjamin Block , "Martin K. Petersen" , Jaroslav Kysela , Takashi Iwai , Steven Rostedt , Ingo Molnar , Jiri Slaby , Felipe Balbi , Valentina Manea , Shuah Khan , Wim Van Sebroeck Cc: cgroups@vger.kernel.org, linux-crypto@vger.kernel.org, netdev@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, "Rafael J. Wysocki" , linux-integrity@vger.kernel.org, linux-nfs@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-hwmon@vger.kernel.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, alsa-devel@alsa-project.org, linux-usb@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Shuah Khan References: <20210222151231.22572-1-romain.perier@gmail.com> From: Shuah Khan Message-ID: <936bcf5e-2006-7643-7804-9efa318b3e2b@linuxfoundation.org> Date: Mon, 22 Feb 2021 09:36:51 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <20210222151231.22572-1-romain.perier@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-s390@vger.kernel.org On 2/22/21 8:12 AM, Romain Perier wrote: > strlcpy() copy a C-String into a sized buffer, the result is always a > valid NULL-terminated that fits in the buffer, howerver it has severals > issues. It reads the source buffer first, which is dangerous if it is non > NULL-terminated or if the corresponding buffer is unbounded. Its safe > replacement is strscpy(), as suggested in the deprecated interface [1]. > > We plan to make this contribution in two steps: > - Firsly all cases of strlcpy's return value are manually replaced by the > corresponding calls of strscpy() with the new handling of the return > value (as the return code is different in case of error). > - Then all other cases are automatically replaced by using coccinelle. > Cool. A quick check shows me 1031 strscpy() calls with no return checks. All or some of these probably need to be reviewed and add return checks. Is this something that is in the plan to address as part of this work? thanks, -- Shuah