Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5407204rdb; Sat, 16 Sep 2023 16:14:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE2w5JmITVD5xuhLXlhn8/Xb0Cox8pQkpaL1U4aEOxoA0vqOQPSTawSKwXWmj2ISJvW3bxa X-Received: by 2002:a17:90b:a4a:b0:268:d05c:2d7e with SMTP id gw10-20020a17090b0a4a00b00268d05c2d7emr4886482pjb.14.1694906048651; Sat, 16 Sep 2023 16:14:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694906048; cv=none; d=google.com; s=arc-20160816; b=V0OmuNj9H2aUiGVUvSaeUm8s6aUasCpLyQBvJTqliTu/MDBoBgV818oiLS7wCh+tEn TqxBeWSilxpFdaRuWN1F6QeC2y9MRYFj6EB9YUzJ5JmjXuo1qXd6GxDyCDnAxUUotbeN QUR0vXgYVPAhbPqoZABVvIreNz8jTeJNG/y7vePUuUYuRjLKI5aaJzVxhKUz3rQFmHG+ +GQtunKWZ8NHHBJCfmOUNJT5/XQQpatoD/R5hLMMu9wn07BZO5WRAbVi1KwmRqh3xBof DyC7hmCJ9N+h1kDxFa1qfszhkO94KsQEa12SVziAAgY/EE1UOwz774ahJYIbYxDjRA83 tkmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:organization:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date; bh=lDHQ8LFkL7PJaSsVURB0Vaa+GzcUOuKYftAnwlz7uqs=; fh=uuyFq2zRAJyCTmsWepdRWCjkSt41jKh/AyvAZ5Zb85E=; b=E0vFIbIVwiTIBk+7wiKgjWzYFvrQ0exNKWh9PDDiJn4jsoaa0xZnuDo6Z0RzZRAzLW QJa3dnhZ64iPHPSpbZE4SJ7ik1W7GGBHzFZF2vVERvUfpDXewroCU/tNFeCgKxCd3f2j NPPkRTtjZwNeylXHNPP9BtpsekUAyK16ys6iNWDeMeOLOBpjI/7GUjJ24hl1yoy/2Wc2 Xjwtt5QHvs0l4N6oHzl6p/kHYM6S5l8CzlHsOVNXmtQgcN0eZTIg+g43awKKX11evNni /SZu7x0uaGF1P8UVUEDqiF/JXOWb1vfbUBd/Oxx/3tMNKzTZGZ2c8bQDVaf9+WgMtPnf lNtw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id f24-20020a637558000000b00563dd9b6da6si5438334pgn.718.2023.09.16.16.14.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 16:14:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 8224380990CD; Sat, 16 Sep 2023 16:10:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232626AbjIPXJD (ORCPT + 99 others); Sat, 16 Sep 2023 19:09:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229713AbjIPXIb (ORCPT ); Sat, 16 Sep 2023 19:08:31 -0400 Received: from sonata.ens-lyon.org (sonata.ens-lyon.org [140.77.166.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DC42CD5; Sat, 16 Sep 2023 16:08:25 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id D89D32013C; Sun, 17 Sep 2023 01:08:09 +0200 (CEST) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id o1eLfS2tQsgw; Sun, 17 Sep 2023 01:08:09 +0200 (CEST) Received: from begin (lfbn-bor-1-1163-184.w92-158.abo.wanadoo.fr [92.158.138.184]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 7FDB520137; Sun, 17 Sep 2023 01:08:08 +0200 (CEST) Received: from samy by begin with local (Exim 4.96) (envelope-from ) id 1qheOW-007HHT-04; Sun, 17 Sep 2023 01:08:08 +0200 Date: Sun, 17 Sep 2023 01:08:07 +0200 From: Samuel Thibault To: Justin Stitt Cc: Kees Cook , William Hubbs , Chris Brannon , Kirk Reiser , speakup@linux-speakup.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] accessibility: speakup: refactor deprecated strncpy Message-ID: <20230916230807.motaqyb5gqzqjvub@begin> Mail-Followup-To: Samuel Thibault , Justin Stitt , Kees Cook , William Hubbs , Chris Brannon , Kirk Reiser , speakup@linux-speakup.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org References: <20230824-strncpy-drivers-accessibility-speakup-kobjects-c-v1-1-3a1ef1221e90@google.com> <202308251439.36BC33ADB2@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sat, 16 Sep 2023 16:10:46 -0700 (PDT) Hello, Justin Stitt, le ven. 25 août 2023 15:41:03 -0700, a ecrit: > Thanks for the review Kees and Samuel. Hoping to get this picked-up soon :) > > FWIW, I've quickly copy/pasted Kees' suggested refactor of > synth_direct_store and rebased against v6.5-rc7 if anyone has the > means by which to test it. > > TEST PATCH BELOW > --- > From e7216bca30673a162660c51f8bad3b463d283041 Mon Sep 17 00:00:00 2001 > From: Justin Stitt > Date: Fri, 25 Aug 2023 22:32:03 +0000 > Subject: [PATCH NEEDS TEST] synth_direct_store refactor to use synth_write > > I've just copy/pasted Kees' suggestion here [1] and rebased it against > 6.5-rc7. > > This patch needs testing as it refactors behavior in synth_direct_store. > > [1]: https://lore.kernel.org/all/202308251439.36BC33ADB2@keescook/ > > Signed-off-by: Justin Stitt Tested-by: Samuel Thibault but please submit it properly :) It was completely mangled in the mail. > --- > drivers/accessibility/speakup/kobjects.c | 25 +++++++++++------------- > 1 file changed, 11 insertions(+), 14 deletions(-) > > diff --git a/drivers/accessibility/speakup/kobjects.c > b/drivers/accessibility/speakup/kobjects.c > index a7522d409802..0dfdb6608e02 100644 > --- a/drivers/accessibility/speakup/kobjects.c > +++ b/drivers/accessibility/speakup/kobjects.c > @@ -413,27 +413,24 @@ static ssize_t synth_direct_store(struct kobject *kobj, > struct kobj_attribute *attr, > const char *buf, size_t count) > { > - u_char tmp[256]; > - int len; > - int bytes; > - const char *ptr = buf; > + char *unescaped; > unsigned long flags; > > if (!synth) > return -EPERM; > > - len = strlen(buf); > + unescaped = kstrdup(buf, GFP_KERNEL); > + if (!unescaped) > + return -ENOMEM; > + > + string_unescape_any_inplace(unescaped); > + > spin_lock_irqsave(&speakup_info.spinlock, flags); > - while (len > 0) { > - bytes = min_t(size_t, len, 250); > - strncpy(tmp, ptr, bytes); > - tmp[bytes] = '\0'; > - string_unescape_any_inplace(tmp); > - synth_printf("%s", tmp); > - ptr += bytes; > - len -= bytes; > - } > + synth_write(unescaped, strlen(unescaped)); > spin_unlock_irqrestore(&speakup_info.spinlock, flags); > + > + kfree(unescaped); > + > return count; > } > > -- > 2.42.0.rc1.204.g551eb34607-goog > -- Samuel --- Pour une évaluation indépendante, transparente et rigoureuse ! Je soutiens la Commission d'Évaluation de l'Inria.