Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2753068rwd; Fri, 16 Jun 2023 07:49:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5TFyyz4WxUqNdtef6pWVQdhJINxU5KnKYFcmskhv8hdjJHjF/kHiOUwVc7snOK+7qycfMx X-Received: by 2002:a05:6a00:991:b0:662:4041:30ba with SMTP id u17-20020a056a00099100b00662404130bamr3340792pfg.0.1686926986067; Fri, 16 Jun 2023 07:49:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686926986; cv=none; d=google.com; s=arc-20160816; b=k7oSFLDP8/HM0s5lxp4gy/f/wRQpUB3oFXfX1rAi61sRcSaP9+hjkkJ7thvOXI5Txe XZUIa3v0lZH2xg7tvCidr29GJNpvgEuVBxvWnzHx8lsowtNRv/5IKQDVu8A0bTfJkgcF ah2xByCIYIFA7mr8CA11udu2vNblzrdFPQU5bBUF54wGrxjiVmgJ8mWD3M/v+llhze7m GlyYNNRaupPD4ULyxziloPZceDAY9plwDdh/eRCSSavu52Jqi/JOs6aE6E4QftzP2fNq jYtAJRfMnsAT4vCyT7GNyz5ztftctE9UCp7+U+/VYYPbX0IFGOF5lagYdsWtDXhpvN7L 3s+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:references :in-reply-to:mime-version:dkim-signature; bh=4ZFGzGQwLfEi8s9Kq59YntFLMocnBG7L/iU25TjiGHA=; b=lPCZNSmtjNdlrI42rtKjSvvbtOiSaZBm4cRp4NvZ6ipB6xVxAywJ+FPeoc628A58os 8rmBWgZ1U3DPwCpzOT+Olsn45REA9Tfiz773+cwQgk5+gguO+D3j4s4V56wLobz3ufbk QHRfatkQSO4wws3CCHiksuuAcnvOmRq108cO7AAn3roc9PKh7SFyohtZwRLHulzeY447 T5D5mh4D1K5KapB70ZhxuCq5tnQEU52xyoK3xOk1EZ8JCxZXFjul/yX1K0Z82ugLkxVP gCyGzHtsR6fnR98felTRX5tJsM66NGteD+0PKq9qpoI+aSRERdytmXLwf+UZZ59dUdRA hnJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EvENScLd; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l8-20020a63be08000000b0053f25f2d32csi14985131pgf.840.2023.06.16.07.49.33; Fri, 16 Jun 2023 07:49:46 -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=EvENScLd; 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 S1345649AbjFPOkS (ORCPT + 99 others); Fri, 16 Jun 2023 10:40:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229577AbjFPOkI (ORCPT ); Fri, 16 Jun 2023 10:40:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F7012700; Fri, 16 Jun 2023 07:40:07 -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) server-digest SHA256) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 13CA062CD6; Fri, 16 Jun 2023 14:40:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 173E8C43395; Fri, 16 Jun 2023 14:40:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686926406; bh=LmQ0A+9O9O846YKQ9SkKO3tmg56GUE4m1YrLD2TzUKQ=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=EvENScLdZ2899SCUlEib3TpooSqIrCtaEXZzsD1BE1WIVTLGsud+qlbOU2R/70Chw bVtUjCBmb7msknzEaW5MevV/CFQBx0qFRiOjHZ7CLLp6nRCMzbAkHeuh6tz3C2YY2x gIPd8Ozt7OMBe8OvEmFvRWqIo8oO+gSq03PszmfHZhd30q64iQBjFNq2/q+OytalAv 89Yj9aC0EDcLz2ksTAkRNCavGQCS4CT6Zn+JEC2/FeT7DRLqhsDxjePTfnOboQJCY4 FL153lVpC1R36Ndn/6pkh46PQAEh9VehBT00JaOqO+u50SDTRyCIZaq2RfKwpp7kQC 6T4vx1n6+9VDg== Received: by mail-oo1-f48.google.com with SMTP id 006d021491bc7-555508fd7f9so467618eaf.3; Fri, 16 Jun 2023 07:40:06 -0700 (PDT) X-Gm-Message-State: AC+VfDwXTp9v3gcRYNvmkt2AA3QpQbA+LYFsgjeaStH8Gsd+4miorLM4 QBB/n3xQD5PFiwbG50j05SKNCN2X1FwSPrGW0HA= X-Received: by 2002:a4a:d786:0:b0:558:bb12:da9f with SMTP id c6-20020a4ad786000000b00558bb12da9fmr1811379oou.2.1686926405144; Fri, 16 Jun 2023 07:40:05 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a8a:7cb:0:b0:4df:6fd3:a469 with HTTP; Fri, 16 Jun 2023 07:40:04 -0700 (PDT) In-Reply-To: <20230616090749.2646749-1-arnd@kernel.org> References: <20230616090749.2646749-1-arnd@kernel.org> From: Namjae Jeon Date: Fri, 16 Jun 2023 23:40:04 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] smb: avoid field overflow warning To: Arnd Bergmann Cc: Steve French , Arnd Bergmann , Sergey Senozhatsky , Tom Talpey , Nathan Chancellor , Nick Desaulniers , Tom Rix , Christian Brauner , Dave Chinner , Kees Cook , =?UTF-8?B?TWlja2HDq2wgU2FsYcO8bg==?= , Ronnie Sahlberg , Hyunchul Lee , linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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: X-Mailing-List: linux-kernel@vger.kernel.org 2023-06-16 18:07 GMT+09:00, Arnd Bergmann : > From: Arnd Bergmann Hi Arnd, > > clang warns about a possible field overflow in a memcpy: > > In file included from fs/smb/server/smb_common.c:7: > include/linux/fortify-string.h:583:4: error: call to > '__write_overflow_field' declared with 'warning' attribute: detected write > beyond size of field (1st parameter); maybe use struct_group()? > [-Werror,-Wattribute-warning] > __write_overflow_field(p_size_field, size); > > It appears to interpret the "&out[baselen + 4]" as referring to a single > byte of the character array, while the equivalen "out + baselen + 4" is > seen as an offset into the array. > > I don't see that kind of warning elsewhere, so just go with the simple > rework. > > Fixes: e2f34481b24db ("cifsd: add server-side procedures for SMB3") > Signed-off-by: Arnd Bergmann > --- > fs/smb/server/smb_common.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/smb/server/smb_common.c b/fs/smb/server/smb_common.c > index a7e81067bc991..e3273fa640b07 100644 > --- a/fs/smb/server/smb_common.c > +++ b/fs/smb/server/smb_common.c > @@ -536,7 +536,7 @@ int ksmbd_extract_shortname(struct ksmbd_conn *conn, > const char *longname, > out[baselen + 3] = PERIOD; > > if (dot_present) > - memcpy(&out[baselen + 4], extension, 4); > + memcpy(out + baselen + 4, extension, 1); Is there any reason to change copy bytes from 4 bytes to 1 byte? Thanks! > else > out[baselen + 4] = '\0'; > smbConvertToUTF16((__le16 *)shortname, out, PATH_MAX, > -- > 2.39.2 > >