From patchwork Thu Feb 3 17:26:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 12734415 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46DD4C433EF for ; Thu, 3 Feb 2022 17:27:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352822AbiBCR1L (ORCPT ); Thu, 3 Feb 2022 12:27:11 -0500 Received: from smtp-out1.suse.de ([195.135.220.28]:47462 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352827AbiBCR1K (ORCPT ); Thu, 3 Feb 2022 12:27:10 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id F375321128; Thu, 3 Feb 2022 17:27:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1643909230; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nfLPlzGqYP/LAeHIPI2v6jFiHA3b/xUR1RCgog9Qkyo=; b=RtpKdadE1D68X7TKpezMebACfuhbiWxhZQWvKejTF4Pwwc0kbWZBAgEj0hfE2dgPx1pGVj qOvXROH+Dz/NonCIcZUYNdmTVR9fFi/WkKrIKZknk4U+JPCHIoO/cr2i1OQHLKByX3N/gI 300IwXvUgBp6f8OwmCWbYHWHGBXxzOk= Received: from ds.suse.cz (ds.suse.cz [10.100.12.205]) by relay2.suse.de (Postfix) with ESMTP id EDB83A3B81; Thu, 3 Feb 2022 17:27:09 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id ECEFDDA781; Thu, 3 Feb 2022 18:26:24 +0100 (CET) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba Subject: [PATCH 1/5] btrfs: remove redundant check in up check_setget_bounds Date: Thu, 3 Feb 2022 18:26:24 +0100 Message-Id: <0cccec1104fd7058b4b19c6960dd4c10da646058.1643904960.git.dsterba@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org There are two separate checks in the bounds checker, the first one being a special case of the second. As this function is performance critical due to checking access to any eb member, reducing the size can slightly improve performance. On a release build on x86_64 the helper is completely inlined so the function call overhead is also gone. Signed-off-by: David Sterba --- fs/btrfs/struct-funcs.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/fs/btrfs/struct-funcs.c b/fs/btrfs/struct-funcs.c index f429256f56db..12455b2b41de 100644 --- a/fs/btrfs/struct-funcs.c +++ b/fs/btrfs/struct-funcs.c @@ -12,15 +12,10 @@ static bool check_setget_bounds(const struct extent_buffer *eb, { const unsigned long member_offset = (unsigned long)ptr + off; - if (member_offset > eb->len) { + if (unlikely(member_offset + size > eb->len)) { btrfs_warn(eb->fs_info, - "bad eb member start: ptr 0x%lx start %llu member offset %lu size %d", - (unsigned long)ptr, eb->start, member_offset, size); - return false; - } - if (member_offset + size > eb->len) { - btrfs_warn(eb->fs_info, - "bad eb member end: ptr 0x%lx start %llu member offset %lu size %d", + "bad eb member %s: ptr 0x%lx start %llu member offset %lu size %d", + (member_offset > eb->len ? "start" : "end"), (unsigned long)ptr, eb->start, member_offset, size); return false; } From patchwork Thu Feb 3 17:26:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 12734416 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6BBEC433F5 for ; Thu, 3 Feb 2022 17:27:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352836AbiBCR1N (ORCPT ); Thu, 3 Feb 2022 12:27:13 -0500 Received: from smtp-out1.suse.de ([195.135.220.28]:47494 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352827AbiBCR1M (ORCPT ); Thu, 3 Feb 2022 12:27:12 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 1EB0A21128; Thu, 3 Feb 2022 17:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1643909232; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Zl3dv1TdXq/P6G0My53EEBJ+1sI2Ri+GwbUucpcecB0=; b=pZqbIYrb/vxGfpzij5qVRk0p9wOh9ltRKyby9hMntj5OA+0Va1qOFXNgngLzjvnMEPZJu6 jnXt4qb33Tg2KU+yvDjJCJUtWI0JHDSTXgJK9Mp43E7gApdAr2Ob595EXUPryDe29FRcnT w4kmwi0C4Cke5QZMvrGVk2iWeL8Ctag= Received: from ds.suse.cz (ds.suse.cz [10.100.12.205]) by relay2.suse.de (Postfix) with ESMTP id 192A1A3B85; Thu, 3 Feb 2022 17:27:12 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 18A09DA781; Thu, 3 Feb 2022 18:26:27 +0100 (CET) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba Subject: [PATCH 2/5] btrfs: factor out reporting when check_setget_bounds fails Date: Thu, 3 Feb 2022 18:26:27 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The eb bounds checks are supposed to almost never fail so the reporting part can be moved away to a separate function and will be used to store information about the failed checks. Add the inline keyword as a hint, but according to the generated assembly it is already inlined. The message level is set from warning to error as this should be noticeable in the logs. Signed-off-by: David Sterba --- fs/btrfs/struct-funcs.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/struct-funcs.c b/fs/btrfs/struct-funcs.c index 12455b2b41de..c97c69e29d64 100644 --- a/fs/btrfs/struct-funcs.c +++ b/fs/btrfs/struct-funcs.c @@ -7,16 +7,24 @@ #include "ctree.h" -static bool check_setget_bounds(const struct extent_buffer *eb, - const void *ptr, unsigned off, int size) +static void report_setget_bounds(const struct extent_buffer *eb, + const void *ptr, unsigned off, int size) { const unsigned long member_offset = (unsigned long)ptr + off; - if (unlikely(member_offset + size > eb->len)) { - btrfs_warn(eb->fs_info, + btrfs_err_rl(eb->fs_info, "bad eb member %s: ptr 0x%lx start %llu member offset %lu size %d", - (member_offset > eb->len ? "start" : "end"), - (unsigned long)ptr, eb->start, member_offset, size); + (member_offset > eb->len ? "start" : "end"), + (unsigned long)ptr, eb->start, member_offset, size); +} + +static inline bool check_setget_bounds(const struct extent_buffer *eb, + const void *ptr, unsigned off, int size) +{ + const unsigned long member_offset = (unsigned long)ptr + off; + + if (unlikely(member_offset + size > eb->len)) { + report_setget_bounds(eb, ptr, off, size); return false; } From patchwork Thu Feb 3 17:26:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 12734417 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8C2CC433F5 for ; Thu, 3 Feb 2022 17:27:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352839AbiBCR1R (ORCPT ); Thu, 3 Feb 2022 12:27:17 -0500 Received: from smtp-out1.suse.de ([195.135.220.28]:47502 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352827AbiBCR1P (ORCPT ); Thu, 3 Feb 2022 12:27:15 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 416CF21128; Thu, 3 Feb 2022 17:27:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1643909234; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EvU8lL3FYBqaVC1loovwFyZkzTBq1hN+Y6IyBME0tUQ=; b=r2MQ5b3G9OD20S+B40M8pzVOGw4j0W5X4WNqh1B2heiO5nkkIlGEOKoC8ob6V6CSgG76+L +s86Fn90PdQWfqRLqfwckck5PnHXxSHu0lauiRHddRuBDwK9IvLN3ijsoUvGgUSkVBxAiG Gl8JuX5r7irGTPSfYLOcTjJR1KcfGJc= Received: from ds.suse.cz (ds.suse.cz [10.100.12.205]) by relay2.suse.de (Postfix) with ESMTP id 3BCE6A3B88; Thu, 3 Feb 2022 17:27:14 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 3AD89DA781; Thu, 3 Feb 2022 18:26:29 +0100 (CET) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba Subject: [PATCH 3/5] btrfs: store details about first setget bounds check failure Date: Thu, 3 Feb 2022 18:26:29 +0100 Message-Id: <79c2eac1b0c7f0a1769bbe9b9ee4ca8b23ef0132.1643904960.git.dsterba@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The way the setget helpers are used makes it hard to return an error code at the call site, as this would require to clutter a lot of code with potential failures that are expected to be rare. Instead, do a delayed reporting, tracked by a filesystem-wide bit that synchronizes potential races in the reporting function that records only the first event. To give a bit more insight into the scale, count the total number of events. Signed-off-by: David Sterba --- fs/btrfs/ctree.h | 16 ++++++++++++++-- fs/btrfs/struct-funcs.c | 12 ++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 9f7a950b8a69..5d12a80d09f5 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -127,6 +127,13 @@ static inline unsigned long btrfs_chunk_item_size(int num_stripes) enum { /* Global indicator of serious filesystem errors */ BTRFS_FS_STATE_ERROR, + /* Track if a transaction abort has been reported on this filesystem */ + BTRFS_FS_STATE_TRANS_ABORTED, + /* + * There was a failed bounds check in check_setget_bounds, set this on + * first event. + */ + BTRFS_FS_SETGET_COMPLAINS, /* * Filesystem is being remounted, allow to skip some operations, like * defrag @@ -134,8 +141,6 @@ enum { BTRFS_FS_STATE_REMOUNTING, /* Filesystem in RO mode */ BTRFS_FS_STATE_RO, - /* Track if a transaction abort has been reported on this filesystem */ - BTRFS_FS_STATE_TRANS_ABORTED, /* * Bio operations should be blocked on this filesystem because a source * or target device is being destroyed as part of a device replace @@ -1060,6 +1065,13 @@ struct btrfs_fs_info { spinlock_t zone_active_bgs_lock; struct list_head zone_active_bgs; + /* Store details about the first bounds check failure in report_setget_bounds */ + u64 setget_eb_start; + const void *setget_ptr; + unsigned setget_off; + int setget_size; + atomic_t setget_failures; + #ifdef CONFIG_BTRFS_FS_REF_VERIFY spinlock_t ref_verify_lock; struct rb_root block_tree; diff --git a/fs/btrfs/struct-funcs.c b/fs/btrfs/struct-funcs.c index c97c69e29d64..28b9e62cdc86 100644 --- a/fs/btrfs/struct-funcs.c +++ b/fs/btrfs/struct-funcs.c @@ -11,11 +11,23 @@ static void report_setget_bounds(const struct extent_buffer *eb, const void *ptr, unsigned off, int size) { const unsigned long member_offset = (unsigned long)ptr + off; + struct btrfs_fs_info *fs_info; btrfs_err_rl(eb->fs_info, "bad eb member %s: ptr 0x%lx start %llu member offset %lu size %d", (member_offset > eb->len ? "start" : "end"), (unsigned long)ptr, eb->start, member_offset, size); + + /* Count events and record more details about the first one */ + fs_info = eb->fs_info; + atomic_inc(&fs_info->setget_failures); + if (test_and_set_bit(BTRFS_FS_SETGET_COMPLAINS, &eb->fs_info->flags)) + return; + + fs_info->setget_eb_start = eb->start; + fs_info->setget_ptr = ptr; + fs_info->setget_off = member_offset; + fs_info->setget_size = size; } static inline bool check_setget_bounds(const struct extent_buffer *eb, From patchwork Thu Feb 3 17:26:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 12734418 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCC43C433EF for ; Thu, 3 Feb 2022 17:27:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352827AbiBCR1S (ORCPT ); Thu, 3 Feb 2022 12:27:18 -0500 Received: from smtp-out2.suse.de ([195.135.220.29]:58582 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241975AbiBCR1R (ORCPT ); Thu, 3 Feb 2022 12:27:17 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 61E5B1F399; Thu, 3 Feb 2022 17:27:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1643909236; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cI28xQq/jaCGMIrda1+ADuuDDUaTqvUccpsJTMPhJOM=; b=tYCJ9GuLqHbchudAncLZT3kw+aVeuE/xQWdkDzHyaRwzw7UbLnenzNU5Nb8PgG2Qh9bcBG ojh6CN46Yu8mUDA3EFbC5628qRwRbukENAFQgF4yYQnvQxarjZu717sQqDJ2owVJ0CYB2Q OIAa9ciB+Jr7C2/dv0278J/ZvyIMDoc= Received: from ds.suse.cz (ds.suse.cz [10.100.12.205]) by relay2.suse.de (Postfix) with ESMTP id 5D19AA3B81; Thu, 3 Feb 2022 17:27:16 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 5D375DA781; Thu, 3 Feb 2022 18:26:31 +0100 (CET) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba Subject: [PATCH 4/5] btrfs: fail transaction when a setget bounds check failure is detected Date: Thu, 3 Feb 2022 18:26:31 +0100 Message-Id: <617931b8ee53e8fcde1560eb86758024ca753f42.1643904960.git.dsterba@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org As the setget check only sets the bit, we need to use it in the transaction: - when attempting to start a new one, fail with EROFS as if would be aborted in another way already - in should_end_transaction - when transaction is about to end, insert an explicit abort Signed-off-by: David Sterba --- fs/btrfs/transaction.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 6db634ebae17..f48194df6c33 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -591,6 +591,9 @@ start_transaction(struct btrfs_root *root, unsigned int num_items, if (BTRFS_FS_ERROR(fs_info)) return ERR_PTR(-EROFS); + if (test_bit(BTRFS_FS_SETGET_COMPLAINS, &fs_info->flags)) + return ERR_PTR(-EROFS); + if (current->journal_info) { WARN_ON(type & TRANS_EXTWRITERS); h = current->journal_info; @@ -924,6 +927,9 @@ static bool should_end_transaction(struct btrfs_trans_handle *trans) { struct btrfs_fs_info *fs_info = trans->fs_info; + if (test_bit(BTRFS_FS_SETGET_COMPLAINS, &fs_info->flags)) + return true; + if (btrfs_check_space_for_delayed_refs(fs_info)) return true; @@ -969,6 +975,11 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans, struct btrfs_transaction *cur_trans = trans->transaction; int err = 0; + /* If a serious error was detected abort the transaction early */ + if (!TRANS_ABORTED(trans) && + test_bit(BTRFS_FS_SETGET_COMPLAINS, &info->flags)) + btrfs_abort_transaction(trans, -EIO); + if (refcount_read(&trans->use_count) > 1) { refcount_dec(&trans->use_count); trans->block_rsv = trans->orig_rsv; From patchwork Thu Feb 3 17:26:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 12734419 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4843EC433F5 for ; Thu, 3 Feb 2022 17:27:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240782AbiBCR1U (ORCPT ); Thu, 3 Feb 2022 12:27:20 -0500 Received: from smtp-out1.suse.de ([195.135.220.28]:47510 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241975AbiBCR1T (ORCPT ); Thu, 3 Feb 2022 12:27:19 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 87D4F21128; Thu, 3 Feb 2022 17:27:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1643909238; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BGqzze+e/tD+EJlxJr6vsI2GXArSu8b553HG/gVW3sQ=; b=bkWjrRApl5A6ZhEo8yLkNqBsO7a59qUOobKzy0ZwKPxZMf2gnOfxm2RxMTfumtIKdY5zfI p/zwc4tVL0jIDq5dm3T8/L036t66nIyzVOTz0aC5f5a4is8THJfb/HgkP1F4Ghtjvui77X QTJ/rxPXG2NCpVqt3xrtOE2wJ/hIIEs= Received: from ds.suse.cz (ds.suse.cz [10.100.12.205]) by relay2.suse.de (Postfix) with ESMTP id 83A6CA3B89; Thu, 3 Feb 2022 17:27:18 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 83AE3DA781; Thu, 3 Feb 2022 18:26:33 +0100 (CET) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba Subject: [PATCH 5/5] btrfs: move check_setget_bounds out of ASSERT Date: Thu, 3 Feb 2022 18:26:33 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The bounds check should be done on all builds unconditionally. Now that the whole checking and reporting machinery is done and optimized, the impact should be minimal. Assertion would normally fail, the helpers will not try to access the memory and return, we can't do much else. Signed-off-by: David Sterba --- fs/btrfs/struct-funcs.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/struct-funcs.c b/fs/btrfs/struct-funcs.c index 28b9e62cdc86..1761111e8098 100644 --- a/fs/btrfs/struct-funcs.c +++ b/fs/btrfs/struct-funcs.c @@ -81,7 +81,8 @@ u##bits btrfs_get_token_##bits(struct btrfs_map_token *token, \ \ ASSERT(token); \ ASSERT(token->kaddr); \ - ASSERT(check_setget_bounds(token->eb, ptr, off, size)); \ + if (check_setget_bounds(token->eb, ptr, off, size)) \ + return 0; \ if (token->offset <= member_offset && \ member_offset + size <= token->offset + PAGE_SIZE) { \ return get_unaligned_le##bits(token->kaddr + oip); \ @@ -108,7 +109,8 @@ u##bits btrfs_get_##bits(const struct extent_buffer *eb, \ const int part = PAGE_SIZE - oip; \ u8 lebytes[sizeof(u##bits)]; \ \ - ASSERT(check_setget_bounds(eb, ptr, off, size)); \ + if (check_setget_bounds(eb, ptr, off, size)) \ + return 0; \ if (INLINE_EXTENT_BUFFER_PAGES == 1 || oip + size <= PAGE_SIZE) \ return get_unaligned_le##bits(kaddr + oip); \ \ @@ -131,7 +133,8 @@ void btrfs_set_token_##bits(struct btrfs_map_token *token, \ \ ASSERT(token); \ ASSERT(token->kaddr); \ - ASSERT(check_setget_bounds(token->eb, ptr, off, size)); \ + if (check_setget_bounds(token->eb, ptr, off, size)) \ + return; \ if (token->offset <= member_offset && \ member_offset + size <= token->offset + PAGE_SIZE) { \ put_unaligned_le##bits(val, token->kaddr + oip); \ @@ -160,7 +163,8 @@ void btrfs_set_##bits(const struct extent_buffer *eb, void *ptr, \ const int part = PAGE_SIZE - oip; \ u8 lebytes[sizeof(u##bits)]; \ \ - ASSERT(check_setget_bounds(eb, ptr, off, size)); \ + if (check_setget_bounds(eb, ptr, off, size)) \ + return; \ if (INLINE_EXTENT_BUFFER_PAGES == 1 || oip + size <= PAGE_SIZE) { \ put_unaligned_le##bits(val, kaddr + oip); \ return; \