From patchwork Tue Dec 19 00:26:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 180687 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1623918dyi; Mon, 18 Dec 2023 16:27:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IHRc0DKQOIuDtoc7VW9QhDzJCBzLTwDW7IFBFQ1Ys+FXX/JDgDx4Y7CcWBWBbUX1hduO5wL X-Received: by 2002:a05:6a20:12ce:b0:190:8779:e06a with SMTP id v14-20020a056a2012ce00b001908779e06amr229516pzg.43.1702945622787; Mon, 18 Dec 2023 16:27:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702945622; cv=none; d=google.com; s=arc-20160816; b=cnupIrGtz8VDI0AG8cbs0kFYRn9j7rIGLg289XA9TbE3FEuCKE1NSBsGKh7fJlXc4m pHQcLKJAQG9JT9L5y+eeNZ/HTvFCrNzd/9xiGCrHPUQdzV5DC9jcUXzTXlshSK9EbjBv tS76gMTu56BGKY5QVpkOPTyXAGxNreHt9UCB8MuXlAS/DeQBtpltBnHyVecZWwEkPhtD xiVlxFSfGu2Iw+HSOKP7D/h4apkzln+twfOTAONcQ/N2bBDxJQ/mLImLjtVK9DRrjHWc RuIwzSc29RNtGzsTBGANyMS/ZwQPnReC7FALNQm2KloKlC13l0ooHRHnQI/imCMxLU8W mhdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date :dkim-signature; bh=vIgMcWPGg0vcJgJ+ozsYCB22nR9n1S7rQ6UnmpFWPQ0=; fh=a9DUR2BkWEeP0cACbiaI2xwcDvDVC/gt15O7/cIFKdk=; b=YWadBVJr+EtgtFZ2oM5dJowTXba10xaV3RzUS1FYLgDdPexqo2boP8Ti4ljmK6Zft+ rB+Ad7oP/btulb5bgWiTPR0gOTwnGb/bJ8Exa2wGDmD721nTMLfdFCphGFBrAeU02q2h iqUHWRcr/1nq4d7gH/oF9cCfzxo98BzLqlWaCKyocJqc+mzWrlqGWfztHlpy2Ut+MUv4 WwzGgIERzruSpqi7NcAH7RI/AKeqb48jg4zr7xqHwTgbheulSRLZvMPkHqNO3opDYlTi fogxwSaPmC+aZC8bqJBWVCRvaUmLJM7OTDo4Y14d4Xzed3nVJ7+TWNAnioHSAIuROtmm pNyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JWmjYB24; spf=pass (google.com: domain of linux-kernel+bounces-4521-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4521-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t7-20020a6564c7000000b005be1f24c951si17931810pgv.838.2023.12.18.16.27.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 16:27:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4521-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JWmjYB24; spf=pass (google.com: domain of linux-kernel+bounces-4521-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4521-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 6D88128632B for ; Tue, 19 Dec 2023 00:27:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 28B03468A; Tue, 19 Dec 2023 00:26:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JWmjYB24" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 66F6163A; Tue, 19 Dec 2023 00:26:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C7ACC433C8; Tue, 19 Dec 2023 00:26:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702945588; bh=7NEFQ8R3rBkXCqeCCvEjVFHOC3Fz0I3oIIJHg+yuvj0=; h=Date:From:To:Cc:Subject:From; b=JWmjYB24TEa+UDi07pE7PXCdzt9C2b35c1LndtSIoxerQbe9EeA/6P0hsImCXPR4T hSeh8mYPIY8L+7Qt4kfT0H31V+67XUKLQ/qOirLVzbiJvVpdldHcra6DGtTT23W2Wb PGEiJkyq+Aem+hREwVvTX6tJUOnKngN6VOnkUDwjm+SHOBjBc6IEKmUqhzAb0QOKlA /USL+uFtoejY64WHXsbKEF/HYpJHW/yqvOprJdR26+oB+iimV7p6tteOEeQ4DSyNit l6OonzamS4j1hvoZElPOfM8FOl8e6uoyKrJrKJZWQct1+CUX6RSUxgds54SLAIWrlJ gsEAlStkNpXUA== Date: Mon, 18 Dec 2023 18:26:26 -0600 From: "Gustavo A. R. Silva" To: Kent Overstreet , Brian Foster Cc: linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH][next] bcachefs: Use array_size() in call to copy_from_user() Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785667909507042350 X-GMAIL-MSGID: 1785667909507042350 Use array_size() helper, instead of the open-coded version in call to copy_from_user(). Signed-off-by: Gustavo A. R. Silva --- fs/bcachefs/chardev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/bcachefs/chardev.c b/fs/bcachefs/chardev.c index 304ea619a888..22a52bc8406b 100644 --- a/fs/bcachefs/chardev.c +++ b/fs/bcachefs/chardev.c @@ -360,7 +360,8 @@ static long bch2_ioctl_fsck_offline(struct bch_ioctl_fsck_offline __user *user_a init_waitqueue_head(&thr->output.wait); darray_init(&thr->output2); - if (copy_from_user(devs, &user_arg->devs[0], sizeof(user_arg->devs[0]) * arg.nr_devs)) { + if (copy_from_user(devs, &user_arg->devs[0], + array_size(sizeof(user_arg->devs[0]), arg.nr_devs))) { ret = -EINVAL; goto err; }