Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4696270pxv; Tue, 27 Jul 2021 14:03:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw22w69L9ht24pc0pb1ETi4nUKTGIeDzFBSIj5Qrx0SXcb7HWzq1/3kr56JnBiW8tyMUeSK X-Received: by 2002:a05:6402:1c83:: with SMTP id cy3mr777417edb.231.1627419784712; Tue, 27 Jul 2021 14:03:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627419784; cv=none; d=google.com; s=arc-20160816; b=PxsdSFTFATvnGJiXuimbdh3QGl8tbFPr8KHD3rFgKl3np78Vlm4/a61KJ/Tb/XDpIN 6P7cIqRs+g1ofm4XsVv0Zh57YD8NYh9p9g6VuO6KYgHTePaqwgI4X919/85DSPAAuBlU B3iUP1TjcPi+vAX25cGfytpWl+wn7f4MBIPsDRrzVKf+Ih2154oLcvFKK5ETLTE3yU/C VOKaiBB5HZf/vQLjIDEqRVPN1tQGNHN7JA30BAy8kjbcZEukxQGxLICC1g04a16s72SN Ied+Yhw+DJQfHVgbtNBwsqRmFd3By0RfTUxaWI+L27ZCNNvlIaLY5HS5GWZjqlu8VONG pYuA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9ZANtB/5paOTL9rrQ/OEPNR1JGy+0L6nD4QX9CL0F7k=; b=XHIPeQ2dBMVcbHmGDCSkK7BkYExTXSZL3Uwd5gVM6lTUlbJ8Ko9U9nvXZ5hHqFvgVP YiFW2yCXDDrve1mzf/ihXspLO5ATR3mJvasKWKFzUlK4Bviy4PMePnfDxOEp/NKvcVT3 6t8mnfhEGykWg7lbf/kvJ0cXyVT7ttPTOcGahXBwoh4aidYMdh43jGZcjZ0S4LL+14xD zrEAqOmV/tOeX657vg3OWxL0+dIQmdE4Os52HcoGIF1rsrzA87maUQxENL/1PqAQgBBM m7/ipwm/gXTE3yTZhwq7lXt+cYVVCWgkfVmENjh852+KAgeKiTT3vG/r+VTp0PSR+aA8 yC7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mvsqmz2p; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v11si4036989edx.190.2021.07.27.14.02.41; Tue, 27 Jul 2021 14:03:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mvsqmz2p; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232027AbhG0VBm (ORCPT + 99 others); Tue, 27 Jul 2021 17:01:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234665AbhG0VAg (ORCPT ); Tue, 27 Jul 2021 17:00:36 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FCBBC0617BD for ; Tue, 27 Jul 2021 13:59:15 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id g23-20020a17090a5797b02901765d605e14so997366pji.5 for ; Tue, 27 Jul 2021 13:59:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9ZANtB/5paOTL9rrQ/OEPNR1JGy+0L6nD4QX9CL0F7k=; b=mvsqmz2pOJhJ9OaX3L4K7kVGDAStkUtWNLy5iZu/K7AftRRNcUovN+y+miaZbg89tO Uthw8swwf1XqEL18bb1TQESLDee214WGoNCauwBep7bAKX+Je3IIRQ3judpMqtgucXOA K1pL1usRDZBmpoaR3SWjPg28m7oIJmlVwMC7k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9ZANtB/5paOTL9rrQ/OEPNR1JGy+0L6nD4QX9CL0F7k=; b=tDQHZ6iv8Ns5n8JRMuoFNcCOFJFn54n45uzlAwCvufuZ9IvI6vGetXZpBWeYNwsk9W j+EbX2Othod4FzA+hD44E2HHbEfRMvHP98eFUG0XTwnbsBxiZRbXiOKPVHy1+MxThILn 2+trelyNz5OVB3+yD12zKY1Y1Q9YORwMZ0Q+dcHcmeCRtUrYpBTSBq5UUE4yNb55GL5Q PIbmzD3HSEYGt2OFxt7s8tCDG/0WS7ReIUOUMmTQzKJQL1UYmbkBrPM1LShqLbrCWdIY OQbtm+SziVZPARjCpU2T8BYxBXgTUqXLNj7PlYGQ9wwg5eLiXTzisZ3o+qapnBTjZydR LDpA== X-Gm-Message-State: AOAM532WDXpG1+SPIFCZ7meoeTLJypYpWj4GxRZjzq2BHdP9sN9XhdT+ BRUigzmYJ21UVZRcIclL8tO6bQ== X-Received: by 2002:a17:90a:d251:: with SMTP id o17mr1322871pjw.200.1627419555206; Tue, 27 Jul 2021 13:59:15 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id o134sm4623683pfg.62.2021.07.27.13.59.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jul 2021 13:59:14 -0700 (PDT) From: Kees Cook To: linux-hardening@vger.kernel.org Cc: Kees Cook , "Gustavo A. R. Silva" , Keith Packard , Greg Kroah-Hartman , Andrew Morton , linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-staging@lists.linux.dev, linux-block@vger.kernel.org, linux-kbuild@vger.kernel.org, clang-built-linux@googlegroups.com Subject: [PATCH 47/64] btrfs: Use memset_after() to clear end of struct Date: Tue, 27 Jul 2021 13:58:38 -0700 Message-Id: <20210727205855.411487-48-keescook@chromium.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210727205855.411487-1-keescook@chromium.org> References: <20210727205855.411487-1-keescook@chromium.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=992; h=from:subject; bh=x7ocbS42SjohNmNf+jZzB+Ex+GPw48UesaUcGwh3RlU=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBhAHOKwywaxTW0OzsQGL01qHorKOsTwNUavfO4aV7/ 4MvZRoyJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCYQBzigAKCRCJcvTf3G3AJjfPD/ 4mFAUDF6T1seKtO/RA+qdlnriVg5ZRjAEH4H/h8DVsqaNsbNjkXXBxy4IGulp+GUR4SdYtq0qxTEGi dzjW0oiJ4wsB27VOGaHIXnH3D72eToay+7FKJsbTmxYF7qq7gMrBtZQ1lKPJOINEfDXC/GPs4PjHFt erSiS4lXcv7ZSR327qucJFy3X6rUI1vW/mu4I34D4vBVDPz7h/U/kTrFIpqQYU5qc8uY/8yajU/JNs mQ1m36vmx9AipRbk9NySHUPM6/19rIlM3mPS80ucsisVgDP46b0pgtm7X6nxCi9z/OaNCqCtQ+53mA 0TEThqquZzBXubfk3PRoVuwATx/orxB1j62Wns1xX49CmkH6puRyfHwmBSmk7CiM4Sk1wpqm9jnpGt 4DEdfYKvvTV5Mz5v4rooDk17qFI5QfRMISRbIJsWf42ioVfoojhOqA1vWlKc/ndypF47wowasPUGyj OXB4t+t9iIqUUqNtvyQSbgC16g4aG2X6ikTW6WjRC9vOt7wyZSNVoZoXQPD/ZmSRZZpvbQKkN2G4yN Vjn4IFYhXwNdyA0oK5yI/r1Q+WXeC+pvl6zO/L8B/K6xmBwrE0dWZNELGC+dpZM2lHGRXavr/S7tV7 OmHAQOFKQhK7/G9WgHJLShkAumxIBKLFh22qDqffVoP8zhUM+GH0rhbl7Mpw== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org In preparation for FORTIFY_SOURCE performing compile-time and run-time field bounds checking for memset(), avoid intentionally writing across neighboring fields. Use memset_after() so memset() doesn't get confused about writing beyond the destination member that is intended to be the starting point of zeroing through the end of the struct. Signed-off-by: Kees Cook --- fs/btrfs/root-tree.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c index 702dc5441f03..ec9e78f65fca 100644 --- a/fs/btrfs/root-tree.c +++ b/fs/btrfs/root-tree.c @@ -39,10 +39,7 @@ static void btrfs_read_root_item(struct extent_buffer *eb, int slot, need_reset = 1; } if (need_reset) { - memset(&item->generation_v2, 0, - sizeof(*item) - offsetof(struct btrfs_root_item, - generation_v2)); - + memset_after(item, 0, level); generate_random_guid(item->uuid); } } -- 2.30.2