Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp10682222rwd; Thu, 22 Jun 2023 03:26:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Enezey+7o6AVspld4uUcFsndnv1o5sjMc8dl+Tx6D1V6KEsMJyRMusLf6uCWxx70e5cJU X-Received: by 2002:a67:b109:0:b0:43f:5d2f:b878 with SMTP id w9-20020a67b109000000b0043f5d2fb878mr7748935vsl.17.1687429586621; Thu, 22 Jun 2023 03:26:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687429586; cv=none; d=google.com; s=arc-20160816; b=bfs5eoS5jOmeduEYoCJMvrv8SJnr94e63OcC6T9zTlbh72qv47MvrBWlZmU9DQhilU k6t0iF/B2Tg7DsMk15d+MoDdoS0vFLqKVonOs87SOeSx2Gc0oP6wya2/kTlBwL8B5Bka X294tnXiJeVun9SWZBzGSdYpuYfiQB1UQoCo0fi5iN3xLeqyqt0jlOuG1voHPg4Z+hi+ onlsBrLuLzjt6OgybuS/0tCN6HB4iJZmDJlYqJydTkxqpeOSV5MpTkpzjTvR6JuzAhYi txhlIXk31d53r5fasrK/VnG+SZS7W1d3GgsaYkdjlKkaTrE67BXBAAgzuFPdcMWQXpVh 2JPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=8QK1d/sGr17Od5CRHfXe0fev5x2C+MMFhIn5a0qlZM8=; b=Zt3lnflCabapnMUIWoaxtPkoy3HQjzK0IsqkrHjPSwF8vrmrJcBI1xsj4SQi9LfB7G rIaVpJ7zebN4HN6b1EpUhRqNrDbL6PyYIup3TE+LGLsLQOvMqJGTWbc7dZGh1opJ/MQj qCd10geCCJ2nwQJkqoqGBVuQr1+GmQC98KYZ5bLWbMDcbk/LTCGzZSrvEM4b4JEFW+Hk Fi0nTVXqpr0fm8VZ9WW8s8HuUjzCHqf7HvnrubPQAdU91bGG4Pw4j1kFhuvZWUK8yjun En5SmVdWk8lO4PZR+s+cTPtY5QNJ1nSp6osuypomTTlccx5en8MA6dtnjnXuA9+LEddS +oNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Jxh4dVRb; 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 k11-20020a636f0b000000b00553365f5bf0si2531756pgc.321.2023.06.22.03.26.13; Thu, 22 Jun 2023 03:26:26 -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=Jxh4dVRb; 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 S229978AbjFVKRL (ORCPT + 99 others); Thu, 22 Jun 2023 06:17:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229866AbjFVKRI (ORCPT ); Thu, 22 Jun 2023 06:17:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4956D107 for ; Thu, 22 Jun 2023 03:17: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)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D7B09617C3 for ; Thu, 22 Jun 2023 10:17:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06E8AC433C8; Thu, 22 Jun 2023 10:17:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687429026; bh=LKeF6N/V+xgw47jyD6tRnEV8eEabABkGvs7O5k9QKhM=; h=From:To:Cc:Subject:Date:From; b=Jxh4dVRbcJ+uww/w+YUjVODVegZPu/WRfX+VdZ0r1aRjnKLgoSlh3WIEG4sKDO/7+ 4UYYdnjR8rbY4GwlXYSc97d2Wa7+FlAGKCLqGoggoHsdCY+JrXIMkH4/pi53S16Vdh kzqWtrDvdoGAB3WVViZTz1rWUvgpG+LI1rv7RgYK5PiT8oCmN/Lr/00Ku63Uo8/VLY SxOl15+TTXMh73Z7YD1a3hs/xFw/L117EpNiP0xTXpDMr+gyCulSEYTn6Ld6Sv5XKF b7NpnTYZu4fF6/HLgl66MPtZkEXJHFFitbNndNgT5+CZlZDueYR2p+h8+ThvDJuPm6 yHIIpc5nFVa2A== From: Arnd Bergmann To: Mike Marshall Cc: Arnd Bergmann , Martin Brandenburg , devel@lists.orangefs.org, linux-kernel@vger.kernel.org Subject: [PATCH] orangefs: fix out-of-bounds fsid access Date: Thu, 22 Jun 2023 12:16:52 +0200 Message-Id: <20230622101701.3399585-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 From: Arnd Bergmann orangefs_statfs() copies two consecutive fields of the superblock into the statfs structure, which triggers a warning from the string fortification helpers: In file included from fs/orangefs/super.c:8: include/linux/fortify-string.h:592:4: error: call to '__read_overflow2_field' declared with 'warning' attribute: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Werror,-Wattribute-warning] __read_overflow2_field(q_size_field, size); Change the memcpy() to an individual assignment of the two fields, which helps both the compiler and human readers understand better what it does. Signed-off-by: Arnd Bergmann --- fs/orangefs/super.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/orangefs/super.c b/fs/orangefs/super.c index 5254256a224d7..509a74aca2dcb 100644 --- a/fs/orangefs/super.c +++ b/fs/orangefs/super.c @@ -201,7 +201,10 @@ static int orangefs_statfs(struct dentry *dentry, struct kstatfs *buf) (long)new_op->downcall.resp.statfs.files_avail); buf->f_type = sb->s_magic; - memcpy(&buf->f_fsid, &ORANGEFS_SB(sb)->fs_id, sizeof(buf->f_fsid)); + buf->f_fsid = (__kernel_fsid_t) {{ + ORANGEFS_SB(sb)->fs_id, + ORANGEFS_SB(sb)->id, + }}; buf->f_bsize = new_op->downcall.resp.statfs.block_size; buf->f_namelen = ORANGEFS_NAME_MAX; -- 2.39.2