Message ID | ZJNrsjDEfe0iwQ92@work |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4661030vqr; Wed, 21 Jun 2023 14:36:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5m7Wzv6ShvabEuEeziT6XmM8yLEM1o0s7Vk/FeeiygrC3Mcg/wwzTyO1clO1MVVUBaIVjN X-Received: by 2002:a17:902:8c8a:b0:1b5:2728:4721 with SMTP id t10-20020a1709028c8a00b001b527284721mr9492286plo.58.1687383388168; Wed, 21 Jun 2023 14:36:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687383388; cv=none; d=google.com; s=arc-20160816; b=ED0cQFr1U6QTKt714JE32zcJU9hkZBfPRrve1lefW73y82I8pUlYbTaL6W/9HFk/WZ e7UkFrx8tbqCntFSwmfdOH1GarVGv+ruDP9Hojz/3xbGYrgxy2piN4k1TbmbQjirhpnC Ut58DFBQ4dXyVw9QW3SKDIdmi1b5wKBzxbTVt2U6cPAi9mLgTtLEVCIty4RCRu9utypp LTgQTuKnlWcwM78j4r4KvegwdzWnErUglRgJn5CkAo59oABwMkIlXvMAldh9pLPQHL3m 3JASxkQ7prYnBrP/a07WpsuK96sRYjcVdSKDQru5W65Pw7oStvym2FvyvoEkColeDW2d XzvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=dS1Pr+xLzdS3cBauwFYEzEn6nBMzmvbscCUDkALixJs=; b=OiEOT7ZyY22z/PhBe6T51L+UBY4VWJtLW0x9cYnvWa/K0lF1BlbLrNgfPk0Ju4WOSJ 0v1+rYGz3+GVsavKzGPy2AfppIvMs1bJUx7sOoWuBXYJkuUil7xENDrmSxfMv4h4Oj7j W/Oim4T8jpNfo7PjvH2SJt0X2DavLcpk7QD3bU94KOxLky7YNtDg9X4Ul18n1E8IH/k9 aymAcjoBcxj1QD04QT5+92dNpF+gSWnLMZlHN+dS/mRUSQPI/wlPEV5qYWtjzKJ5uLUq U9ELMOArY5q/O0FwplG9crIxKedm0nORqgtVEBYnnTFXvFUz8uv6nQv6r4VkwvvH0YGd CKjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kllHomcK; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v17-20020a170902ca9100b001a6e98a5f21si4582306pld.586.2023.06.21.14.36.14; Wed, 21 Jun 2023 14:36:28 -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=@kernel.org header.s=k20201202 header.b=kllHomcK; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229832AbjFUV2c (ORCPT <rfc822;maxin.john@gmail.com> + 99 others); Wed, 21 Jun 2023 17:28:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229971AbjFUV2a (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 21 Jun 2023 17:28:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 459321988; Wed, 21 Jun 2023 14:28:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C6D8F616DE; Wed, 21 Jun 2023 21:28:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72184C433C8; Wed, 21 Jun 2023 21:28:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687382907; bh=jMM5maLB1n7n18QpQ4GX1Q/OPQs1vFd4DPSmOfWIvKE=; h=Date:From:To:Cc:Subject:From; b=kllHomcKxmcBzBuz+hh7DjecvxYH5RCglPxKh1H80fArO2MG6W+WedoZkb7KIDcxB uJrF5+Q2dr0lmY0IcgGuuYfh0gDUfW6x9SqsbEdVbAPOc08jjFFpgVhPjychHWkWVG UHVlVHpCM+gzOqlhfnK24Az2TVP44ODC8tCovN8DO1XEgO8gHjZ01OmMBAcAxK1GLV puQQJ3I8RuF1zYbYBZHheXl47/2g30VZXVEeFxoopuGrryWobcL8Lr7gTvEuboE9gp PdBOde8gtOB73Lg6MgdEMdM6U0WJT8U4owN5uTKbSEaltrAl3QOHJiDkCtPX634s3y Q/RfrrW/uE30w== Date: Wed, 21 Jun 2023 15:29:22 -0600 From: "Gustavo A. R. Silva" <gustavoars@kernel.org> To: Namjae Jeon <linkinjeon@kernel.org>, Steve French <sfrench@samba.org>, Sergey Senozhatsky <senozhatsky@chromium.org>, Tom Talpey <tom@talpey.com> Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" <gustavoars@kernel.org>, linux-hardening@vger.kernel.org Subject: [PATCH][next] ksmbd: Use struct_size() helper in ksmbd_negotiate_smb_dialect() Message-ID: <ZJNrsjDEfe0iwQ92@work> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769349723353287442?= X-GMAIL-MSGID: =?utf-8?q?1769349723353287442?= |
Series |
[next] ksmbd: Use struct_size() helper in ksmbd_negotiate_smb_dialect()
|
|
Commit Message
Gustavo A. R. Silva
June 21, 2023, 9:29 p.m. UTC
Prefer struct_size() over open-coded versions.
Link: https://github.com/KSPP/linux/issues/160
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
fs/smb/server/smb_common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Wed, Jun 21, 2023 at 03:29:22PM -0600, Gustavo A. R. Silva wrote: > Prefer struct_size() over open-coded versions. > > Link: https://github.com/KSPP/linux/issues/160 > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Reviewed-by: Kees Cook <keescook@chromium.org>
2023-06-22 6:29 GMT+09:00, Gustavo A. R. Silva <gustavoars@kernel.org>: > Prefer struct_size() over open-coded versions. > > Link: https://github.com/KSPP/linux/issues/160 > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Thanks!
On (23/06/21 15:29), Gustavo A. R. Silva wrote: > Prefer struct_size() over open-coded versions. > > Link: https://github.com/KSPP/linux/issues/160 > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
2023-06-22 6:29 GMT+09:00, Gustavo A. R. Silva <gustavoars@kernel.org>: > Prefer struct_size() over open-coded versions. > > Link: https://github.com/KSPP/linux/issues/160 > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Applied it with reviewed/acked-by tags to #ksmbd-for-next-next. Thanks.
diff --git a/fs/smb/server/smb_common.c b/fs/smb/server/smb_common.c index a7e81067bc99..b51f431ade01 100644 --- a/fs/smb/server/smb_common.c +++ b/fs/smb/server/smb_common.c @@ -266,7 +266,7 @@ static int ksmbd_negotiate_smb_dialect(void *buf) if (smb2_neg_size > smb_buf_length) goto err_out; - if (smb2_neg_size + le16_to_cpu(req->DialectCount) * sizeof(__le16) > + if (struct_size(req, Dialects, le16_to_cpu(req->DialectCount)) > smb_buf_length) goto err_out;