Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6311540rwd; Mon, 19 Jun 2023 05:41:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7oEnkjcAKikqqnDJDZmRGMRr8OYU7w3oKRoA/Cvm6AEtBP3g81TuX39bn72RGoX6mynYys X-Received: by 2002:a05:6a20:3ca2:b0:122:5c71:6c81 with SMTP id b34-20020a056a203ca200b001225c716c81mr153713pzj.43.1687178467874; Mon, 19 Jun 2023 05:41:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687178467; cv=pass; d=google.com; s=arc-20160816; b=Qa7mi3rPP4UYsPsVFFuv/JkmiUs/5nN4xnHoWx6dIy9T6QAm44ZOOI6WM8ZmRrZ/rH WynH/7a259dGW3XQd29iEU41hYlbYCPgptjJ+ryy3gp3ubM8fFvUG3YW6osdM1tIatsG Q1DbCZeLxsauloE8IiJpUrBKFQ9x//98uELEfMjWiLyrf9co0gmWUXzaTA0IXD231E/d OdDb9i2rODNKbZNYZr/9EN+ZacqB6cKExR5YDwkGHdpewk9+zPjYpeE2XMfE2Ksv7Fmx kKpMHIX/ITvQRmjWeBcd4gZonC7lg6+ajTb6IIAROkRQa1uScQZueFMs70cn+azAXU00 Lisg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id; bh=5RZVwlv9MFI+QC9G4Fo0BGa9nOSduQ7EZjTZwrFmJWk=; b=r/Js5JjPZReL4h9tdDR02Jxj7etJfU8ZHeGpEVmpBM71c+fNJOTpdTKTUVVbXS+xZ2 pvq+qWNnBVFol6rACdgK7IcIFMyuC468nfMvGbSyrSzG8Jdo5G/U8plusMyKhP2AOcuz CFU09jYoXsq0ynV4lBxysNaAB2WnEfCDN2zulIv74gPAoDmwKS1ez9yWl/JTLunGEN4a ZcOlqru0cMvELkS9kTG2eROuctiZAF42BM3dYsMUv6Wtt1PtaRcgLuo1yic7GYdFJ+X7 aCsjzxsQhGJceyMbrs9C4X134ogqeIlver3atbFy1wzRezm/780Q8oqkXAYQHq0TnEe0 werg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=talpey.com dkim=pass dkdomain=talpey.com dmarc=pass fromdomain=talpey.com); 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o18-20020a637e52000000b005533e84b283si7385759pgn.367.2023.06.19.05.40.55; Mon, 19 Jun 2023 05:41:07 -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; arc=pass (i=1 spf=pass spfdomain=talpey.com dkim=pass dkdomain=talpey.com dmarc=pass fromdomain=talpey.com); 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230166AbjFSM1G (ORCPT + 99 others); Mon, 19 Jun 2023 08:27:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229695AbjFSM1B (ORCPT ); Mon, 19 Jun 2023 08:27:01 -0400 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2048.outbound.protection.outlook.com [40.107.212.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58638E73; Mon, 19 Jun 2023 05:26:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HW0LRvGwO2+yQ/nTQoc/4IQzz+50EEkQkL3RMpRe9nzuWAppAgxa7rN1tgRtuJyDo7Zhp/UBkhdSqTYZ1WLKFDHZTEJPGsslXA9wD6/xO7klRpyJ9HJRaj+ybv0kTWD0xWeCA4l4Y4cwoyfirW2dkaTmu/Wy8F07fh33amU4VjTBFO2OGPGP5jOKDDSecK3Jj/2ENozkqn2j4Sans6Tv7YYPLeeJ8v46X7wQJ81FtjNAe+kanTp9zD2a7jca81kiEx/rrM3CFmVjCW1eY6EoNY3gXA4qhkMJsrpwhdZjvpSM1QB9zqAK49j3NAI5WGBsOkpHREDJjxH3B3WkH5dSeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5RZVwlv9MFI+QC9G4Fo0BGa9nOSduQ7EZjTZwrFmJWk=; b=l/tU8cwSsOD8iqtLK/yt378b6/yEGwFp0g48TGKNf12BEud6NGEJm36OjyQt0Bmcqfrdg2P/ndHEnjj0aoANAL2rdNxuS8PJ00k/CHunXyDFCl7aaXZBqloqg4gEPqVEXmdFbuRG1sucAoskES+lG+G7zs8GG81a0/GS+UL2brrT0re2PQeXRYcmf3P1kTh6/ihH9l+DrarVDgY+lQ6fQyly5ZhNc3D1HycNvjolyi+Gvx3bortptY7aUc4jQLesHLhilTlRBGONQLRoh5upDh1oRQz7T1rpn22PSL2l6qQP9wQvwjJGMC8NHp+r6RNHR96o15QGxYcwQClSDsaYWg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=talpey.com; dmarc=pass action=none header.from=talpey.com; dkim=pass header.d=talpey.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=talpey.com; Received: from SN6PR01MB4445.prod.exchangelabs.com (2603:10b6:805:e2::33) by MW6PR01MB8319.prod.exchangelabs.com (2603:10b6:303:241::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36; Mon, 19 Jun 2023 12:26:31 +0000 Received: from SN6PR01MB4445.prod.exchangelabs.com ([fe80::17e9:7e30:6603:23bc]) by SN6PR01MB4445.prod.exchangelabs.com ([fe80::17e9:7e30:6603:23bc%5]) with mapi id 15.20.6500.031; Mon, 19 Jun 2023 12:26:29 +0000 Message-ID: <930c76ab-89a9-3b03-7436-50bfb5696d0c@talpey.com> Date: Mon, 19 Jun 2023 08:26:29 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH] [v2] smb: avoid field overflow warning Content-Language: en-US To: Arnd Bergmann , Namjae Jeon , Steve French Cc: Arnd Bergmann , Sergey Senozhatsky , Nathan Chancellor , Nick Desaulniers , Tom Rix , Christian Brauner , Ronnie Sahlberg , Hyunchul Lee , linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev References: <20230619082019.656605-1-arnd@kernel.org> From: Tom Talpey In-Reply-To: <20230619082019.656605-1-arnd@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: BLAPR05CA0020.namprd05.prod.outlook.com (2603:10b6:208:36e::23) To SN6PR01MB4445.prod.exchangelabs.com (2603:10b6:805:e2::33) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR01MB4445:EE_|MW6PR01MB8319:EE_ X-MS-Office365-Filtering-Correlation-Id: 2593ba8e-04f2-441b-339d-08db70c06887 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aWLCMSJiCJ1qbWkGwvkf2OZhUBVjTS5EPTzcRAGW1BSab4lBt08Yga/pKpdMozvdpzYgSNQloi1eEIrE45lsIUn8Ge/8B69CmyfJ+IFDkfBMZ3QiJEGDBinMruufHku1fqOdcjlj/on/wOPztISIblazEy++XYxV38F6jCKpPDR/4xdG2l2R0dUqSMLvR0jVcWADWWsAEMkA9VNahQCzM8SG5jkzaxvflc6wldutwd0E2ZDwK7M410zEgBs2E4j4PjTj2lWov3eOOldrdY2LoC9NKu9j1VKzdzppt7ppxSrx5oBVtJoFSZ619968FR+b+ztsuw0cnc3SKTTdDa4qIDMriEV2llx0oijCXogkAjY6QatsiblmAo9n/cAB0/LFjUPqF8R5Z+dGNRySJ8qlS92Ji1FMCfH/AnYgTTBRjWMqOJC1j1AZVDaTi7x3SOQ0+apUTMRBJOlkSW+viuZ5BIuyRcwA3U6azrgYjeneZl6JxbZ+jDznR7ZShPTw8ZUb+Ip/nD56vyli06MKshT6zjUCUduNGLVQQL25mGrdjD0KdedW5s8qbIFCyksJQbZuVh04sOFXnSnelgAwNQ2YbctEY/vhpCNIuU1zyBtDgcmQ8EcDq258c7PQzdOfyT6nEUjvLV+XZtT6luLiSt7MsA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR01MB4445.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(39830400003)(366004)(136003)(346002)(451199021)(186003)(66946007)(8936002)(8676002)(66556008)(5660300002)(66476007)(110136005)(54906003)(52116002)(6486002)(316002)(38350700002)(38100700002)(478600001)(41300700001)(36756003)(26005)(53546011)(6506007)(6512007)(4326008)(7416002)(2906002)(31696002)(86362001)(83380400001)(31686004)(2616005)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?cnNLVGRZSDE1V3dNR3I0QjhzVGhrZmJmaHpqdEFFd0RVWDMrb3JuOExvdkxn?= =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hKTzRnVzZBZlZ3eTZtZjRtTzJ4TGpP?= =?utf-8?B?cW9XWVpCbnpoM3RYVjJmQy9SY1E5SmtLd3J4WFpGRTg0R1krL01yY0pVQ25C?= =?utf-8?B?NjcrcWwrM29DOWI3SDI4NVdnQkVBSEpLT29pK1hrY3BMSlYrUDJDQ1NnUHY0?= =?utf-8?B?b3MvYmp5ZURjbXp1bTJ2VDRtQkZPNFZDYmZQOGttRG5YTGhzTGpsK0JaVUk4?= =?utf-8?B?UjQvQmI3UTQ5ODFNaVV6bzFhbDhEOXBZdTRwUnJTM0tJQTVHRFpnMS9UYkJE?= =?utf-8?Q?18HUvzi+igPxnn/9ni5G262Z8?= X-OriginatorOrg: talpey.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2593ba8e-04f2-441b-339d-08db70c06887 X-MS-Exchange-CrossTenant-AuthSource: SN6PR01MB4445.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2023 12:26:29.4184 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 2b2dcae7-2555-4add-bc80-48756da031d5 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GBs6ald7a4S6Oa7RSCdXeElilmJG/khBgBgeTuUHyVvzVnX3LMZmGZ5GSmMDPWLn X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR01MB8319 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 On 6/19/2023 4:19 AM, Arnd Bergmann wrote: > From: Arnd Bergmann > > 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 > ---- > v2: fix typo in array length, and make sure it still addresses the warning > --- > 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..39c6c8d7d0623 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, 4); > else > out[baselen + 4] = '\0'; > smbConvertToUTF16((__le16 *)shortname, out, PATH_MAX, It'd be really confusing to have the other two out[baselen + foo] = bar in the lines above and below. Can this be fixed more clearly with a new pointer, like char *q = &out[baselen + 4]; memcpy(q, extension, 4); ?? Tom.