Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1431556lqp; Mon, 15 Apr 2024 06:33:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUse8Sgk6d3YA7wMHSR/ek4lTn7LQeHO2SyaYAonOX34FtkdTeXdZ8ZifrrqYIc2NMehsR2J+aLgns7jVmO8zVnt9Wfsmj4ljppj3h/hA== X-Google-Smtp-Source: AGHT+IFtF+I/7WyLNiA3ZNtzC4OZejluiqTzk3RiOp6Ead6af+GXV7S6ehM77yw9Kl9w2BjD34F8 X-Received: by 2002:a17:902:dac2:b0:1e4:fea2:29b7 with SMTP id q2-20020a170902dac200b001e4fea229b7mr9532204plx.59.1713187981927; Mon, 15 Apr 2024 06:33:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713187981; cv=pass; d=google.com; s=arc-20160816; b=B4O2Hke9ZSz3bUSBEirvxmdwcROYrNTWjYxVMTL5ydKG4ELhkxQC8H2NqmZFxsd5Jm GdUbBBDLbdAVP+Z/+ITGoyYpokYw8RUtjmgObm9gSaWD1O195J77YMt3SLD1XOJOKOdV oPqIAzgAXAWga7gocwBDPyqkwf2voLyFvkiuEGlqNhoK69F/rD8d65Vl3uGY4I0ra/2K DV/kgdvT907kjZ0bOQsNkHSIbgCVTuWOvqNfn4z50C4nwogIt5mAbJCM8/H/G5YM+h25 7mdrPN9eU7SmrY4nECWO2pmKcT5cB34hEZQFcQabFraCELRM1MgG06hyiXSQ3J9jUhCC j4JA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:organization:in-reply-to:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:mail-followup-to:message-id:subject:cc:to:from:date; bh=njrjxkMxwuHIRU0+anvAjGxnspvNMS39EMKE5hYEc1k=; fh=+q9w+M2ZlpBzk7WCwjaAIee1vlFtmR0fmDLdveYJIqk=; b=UZlVEKILs0s8Y7bWrnx9uZ/ZnAyheh5gSuNcKpBXN3FtxNDde67q3SJQCllMp36FFv 9quZrFvVSYcfsQtHqfzIUNmHXWdVm3yGy2vZauOSYGhD/joAUMsarKwNHhj4iTOmApAa q5vQwLknpwO8nRLEcDLw5O469PzPsTi6+Z830wtU/GGqX6d8J7Ymqi3uyM3iq5xWKrdi io/LZSoYqhPKjnyePRx7f1F95LpXeKtuI+qffJfVv56rnT9Yv7iABWKkdW0Quv0ExjID sR+NYrVpH4YZl6q0yyTV4kPyuhuLnPxFigGPNrQherZfqcw6Kfg0yNpAEqf14OQ1l6FE yffQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=bounce.ens-lyon.org); spf=pass (google.com: domain of linux-kernel+bounces-145238-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145238-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id f9-20020a17090274c900b001e276acdafdsi7808056plt.330.2024.04.15.06.33.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 06:33:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-145238-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=bounce.ens-lyon.org); spf=pass (google.com: domain of linux-kernel+bounces-145238-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145238-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 334D2283DC4 for ; Mon, 15 Apr 2024 13:28:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5060984A58; Mon, 15 Apr 2024 13:21:10 +0000 (UTC) Received: from sonata.ens-lyon.org (sonata.ens-lyon.org [140.77.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C7D283CB4; Mon, 15 Apr 2024 13:21:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=140.77.166.138 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713187269; cv=none; b=rgoEidmJmNThm6PELDOhombkW9UlmXBSvksl/N1ySEkoz0qP0Wt8G6FtzyQJCMwh+7VEMw9V34YLP81tlTpCdEfk4RgLe+BqLbWrKqK2PeLDRVn9luSACgmRZpzpIYBxEnh6bEDH6jCecZ24TgKHfVbZzPnwSI3bicxw9gTz+bA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713187269; c=relaxed/simple; bh=YX7hllbyiJmA8n7JHQzkLlbiw1r46OIwRrV5JFT8Yk4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Hm675OQA8jXg52dwYij1UKzurkwKl7KX0jaEI6+pSQSzP3S3lAikIMxpzg2KiaxHK03jKuqWklB8GTxyIVC9YHu9mg01MNSOKAdRm5sOs7km1lja5UXXx6RLwTa0Wjon1KCX9Jn+GObD5rs7tB294M7Ksph+Q9YrbaPm+OpGA2k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org; arc=none smtp.client-ip=140.77.166.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 14966A0356; Mon, 15 Apr 2024 15:12:27 +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 0ePUsKKeAeGk; Mon, 15 Apr 2024 15:12:27 +0200 (CEST) Received: from begin (unknown [61.199.131.154]) (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 4D97EA0326; Mon, 15 Apr 2024 15:12:25 +0200 (CEST) Received: from samy by begin with local (Exim 4.97) (envelope-from ) id 1rwM89-00000007bTI-0YTQ; Mon, 15 Apr 2024 15:12:17 +0200 Date: Mon, 15 Apr 2024 15:12:17 +0200 From: Samuel Thibault To: Dan Carpenter Cc: William Hubbs , Chris Brannon , Kirk Reiser , Greg Kroah-Hartman , Randy Dunlap , speakup@linux-speakup.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] speakup: Fix sizeof() vs ARRAY_SIZE() bug Message-ID: <20240415131217.t3zfjucclauc3rkz@begin> Mail-Followup-To: Samuel Thibault , Dan Carpenter , William Hubbs , Chris Brannon , Kirk Reiser , Greg Kroah-Hartman , Randy Dunlap , speakup@linux-speakup.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) Dan Carpenter, le lun. 15 avril 2024 14:02:23 +0300, a ecrit: > The "buf" pointer is an array of u16 values. This code should be > using ARRAY_SIZE() (which is 256) instead of sizeof() (which is 512), > otherwise it can the still got out of bounds. > > Fixes: c8d2f34ea96e ("speakup: Avoid crash on very long word") > Cc: stable@vger.kernel.org > Signed-off-by: Dan Carpenter Reviewed-by: Samuel Thibault --- > drivers/accessibility/speakup/main.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/accessibility/speakup/main.c b/drivers/accessibility/speakup/main.c > index 736c2eb8c0f3..f677ad2177c2 100644 > --- a/drivers/accessibility/speakup/main.c > +++ b/drivers/accessibility/speakup/main.c > @@ -574,7 +574,7 @@ static u_long get_word(struct vc_data *vc) > } > attr_ch = get_char(vc, (u_short *)tmp_pos, &spk_attr); > buf[cnt++] = attr_ch; > - while (tmpx < vc->vc_cols - 1 && cnt < sizeof(buf) - 1) { > + while (tmpx < vc->vc_cols - 1 && cnt < ARRAY_SIZE(buf) - 1) { > tmp_pos += 2; > tmpx++; > ch = get_char(vc, (u_short *)tmp_pos, &temp); > -- > 2.43.0 >