Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp70843rwd; Tue, 30 May 2023 16:26:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4nhtWp9Vpnm77eX3QkfSqz2Spf4Jj9Y1+Zo6pdfTsVwDhZ83oWITrJIIQRDc/zEMLYg02f X-Received: by 2002:a17:902:a581:b0:1a6:4127:857 with SMTP id az1-20020a170902a58100b001a641270857mr3397845plb.5.1685489161087; Tue, 30 May 2023 16:26:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685489161; cv=none; d=google.com; s=arc-20160816; b=0LjfEhLP+HHL0ryiCTlvaRVtkS22+NIAlWgoWiH3C3y6G/CN+nqw4OkVM6bE7yJNDv FUNyP77mvJ+m5XYvcIffIykIbRn9bv+6ql0fW/NX25Dwf9FyP9tD3rQO9X+w1FgL5Rrb gelpKWdY8U/DccRBTi2ZlIhiS/Nxd1v4RKvMR9Y2LtSCeuljRx9nKdWWhKwHIv5mlE2i koAyi2MZmb+8wucW6kq+URb0jhgHL3qzej23yv/fTjqmsn7/hp5Q3un0G5N3Mz1yL0kP vkpqbJ6LYAgOpFIqECbdtLYo0UYbot6EwtAOJMg/rXLn9/31l7Vg8C/5XJfpLkhjEyEB YDow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/Ch+QGZuDvVPqFvut3Fm3+Q/Pf0opluuawwoMyLnyLA=; b=dm9ANR2Ow3b58ML8Zb/S3ZIFkqj3TrL9/4cEav5jIt5f6S49PVtnQM+aQqmvGzCaxO ERmpadxm3cDmx/T0aQkv4RyxbZoFTbEogM+AT7wBq+4n72PZufjZ9GTFAB2PpFJR3QUh jaC+MN1YI1MeGb/FtfYY4IhHTF0LTY1w2rT6qywv5wSTf2RGsogbfP+nQ4T7FBTolP1a 1JEVNLdCMiv/sZPCYFATndew187o9LPKehl99wR4nvpOG2oyvuov2sRDWXsJ91kEmzHE P1OGP1KlHSBABmTCKGmtjT1LDUZBdpxdx+b5tHujH0YkpIMjEn1cdk+PxsG1Ve7jcBPd d9jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CTfNkSMX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y13-20020a1709027c8d00b001b02bd00c73si6489372pll.253.2023.05.30.16.25.46; Tue, 30 May 2023 16:26:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CTfNkSMX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233830AbjE3XS6 (ORCPT + 99 others); Tue, 30 May 2023 19:18:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233844AbjE3XS4 (ORCPT ); Tue, 30 May 2023 19:18:56 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31F6418C for ; Tue, 30 May 2023 16:18:27 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1b01d912a76so30902775ad.2 for ; Tue, 30 May 2023 16:18:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685488704; x=1688080704; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=/Ch+QGZuDvVPqFvut3Fm3+Q/Pf0opluuawwoMyLnyLA=; b=CTfNkSMXbEuK4v0Su6woV8ktAXJIQa0eTx8ShMV1zqZYDaGUCjkWgXoC+I5KwLCiK4 z4XtcGo2+1Dr6TPHsdz70M/hGLkKC/EEBRHBrsnzVukFWrelsdajx1aHIosqntKkhD8f dBXmMMZP2oDxGKA0lIrgm8sZVo9Y7M5yRS9o8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685488704; x=1688080704; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/Ch+QGZuDvVPqFvut3Fm3+Q/Pf0opluuawwoMyLnyLA=; b=BR3H6zdOunLptjLm9uYivQrnFrHQXnWDCIfYd4vOSTqcwr+UUo4rgsBlvmq/6OCAqx 5q69mCNRj4xYiWVSunPcdXkTsXAyTrNfI0Rtn0fdqrof0mSTtziguSPnzK0TGxzWesqt JyidQQEgFX7386XntpSTN4VDW5Lf0EDHnfFAwu/VsgGXV4c6b1krNlMSzN19q8XVOcZt Guy2nX1izzEIqou8K6IhOnbyHSD2YguWY2kpvwDHRjHRxg4Y8uqIum3NSeYtiisOAt+1 iM6TaVS6MGnbwrrvjHXvmKfGOpRirvLfZbJLISg+1B7dA04lUDyp86DDp6vw1tiZaagb oFSA== X-Gm-Message-State: AC+VfDy6+bbrpuz1jL2daRqZikD44adFBR0IbP6/lCwDQE6bVj70KEl5 zeXezyAYHAzuQnZUV6NbWw0JYA== X-Received: by 2002:a17:902:ce81:b0:1aa:86a4:37ed with SMTP id f1-20020a170902ce8100b001aa86a437edmr4226230plg.55.1685488704705; Tue, 30 May 2023 16:18:24 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id 17-20020a170902e9d100b00199203a4fa3sm10866444plk.203.2023.05.30.16.18.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 16:18:24 -0700 (PDT) Date: Tue, 30 May 2023 16:18:23 -0700 From: Kees Cook To: Ard Biesheuvel Cc: Maximilian Luz , Bjorn Andersson , Andy Gross , Konrad Dybcio , Ilias Apalodimas , Srinivas Kandagatla , Sudeep Holla , Johan Hovold , Steev Klimaszewski , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 1/4] lib/ucs2_string: Add UCS-2 strlcpy function Message-ID: <202305301617.4858B5672@keescook> References: <20230528230351.168210-1-luzmaximilian@gmail.com> <20230528230351.168210-2-luzmaximilian@gmail.com> <202305300820.9B2154B@keescook> <3255010d-82d5-e8e8-2e11-7de25d538d72@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 30, 2023 at 06:17:35PM +0200, Ard Biesheuvel wrote: > On Tue, 30 May 2023 at 18:15, Maximilian Luz wrote: > > > > On 5/30/23 17:25, Kees Cook wrote: > > > On Mon, May 29, 2023 at 01:03:48AM +0200, Maximilian Luz wrote: > > >> Add a ucs2_strlcpy() function for UCS-2 strings. The behavior is > > >> equivalent to the standard strlcpy() function, just for 16-bit character > > >> UCS-2 strings. > > > > > > Eek, no. strlcpy() is dangerous in multiple ways[1]. Please implement > > > strscpy() (i.e. use strnlen(), negative error on truncation, etc). > > > > Right, make sense, thanks. Somehow I missed that the kernel has a better > > function than the C stdlib for that... > > > > > Additionally, it'd be nice of the ucs2 helpers here also implemented the > > > rest of the CONFIG_FORTIFY_SOURCE mitigations (i.e. checking for source > > > and destination buffer size overflows at compile-time and run-time with > > > __builtin_object_size() and __builtin_dynamoc_object_size() respectively). > > > > I can certainly try that, but I think this might be better suited for a > > follow-up series, given that we then should also add those to the other > > helpers. > > > > Agreed. Let's log the followup work as a kspp work item, no need to > make that part of this series. Yeah, that's fine. Can you please open a KSSP issue for it so we don't forget? :) -- Kees Cook