Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp990224lqp; Fri, 22 Mar 2024 02:06:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUulJ3ZtHZk++7StlNXZM0uHS8seI2DWG5fmEYSu+Iw3XeLCpFKMYLi0A7fLc7zgwAxOXSFQK/qtCMKO8RTPKs9wNo7yCbqlwNS974xxw== X-Google-Smtp-Source: AGHT+IFXSNxl0+HgHMOpvkpgy/Z25TWK9AXd6hajiwYZWFOOJebwlPMmJXl5tEbJxm/PIa/Mfj+h X-Received: by 2002:a05:6a00:14c1:b0:6e7:e6b:2ead with SMTP id w1-20020a056a0014c100b006e70e6b2eadmr2287186pfu.28.1711098360256; Fri, 22 Mar 2024 02:06:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711098360; cv=pass; d=google.com; s=arc-20160816; b=QCZ9vlyLrmmZ+NqNJ2gwhOAObeW3WcBm65MXfsmz3l73KvUoawnofCNFDULGqlsAkF 1gIR24VNv1hLKGKN1MUHErzJWM+cAFfRnGNcioPlSMJnO2zmQ3qSlaWvpry63q2rmIPK 7IpKbO7JGEpnawA5O2Q3lQPlYcfF8jDWfBWC99nfN/QQjJgqv8VqRsGxAA36z2OSvZN2 FbO348Br2Ydo5diQcDi2tu6Aqtd/XkMtz6hsf5yYecHrV5qpIcaHXr2ZqWiTsrXWSB5g ZUrfQ7mPJUsM9C4fc7a1yJAMNmv1N9iCxmKmyyl44W3IJnmUMUU3kUYyQsJX3H7zPodj hLyg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:content-language:accept-language :message-id:date:thread-index:thread-topic:subject:cc:to:from; bh=JpJY8nN7ePdbJUAfzWfHTiZULV4nOMaCYCz1s07YbH4=; fh=7W4/TUDvx8w8EAXJ/r02cRH3+ae+3C1FphXlNjPDRQ4=; b=QsBr99z4rqQ8P9WwtQdKwqrVnfZE+YgTRnT+91yahzMZdOKHvt2EoKHa5rF0AviDX2 GEIB1T7BOs1AQEjgr4Fv58KIz2kXwqv8qEuYLNceOLLp/XFlDTxe9UvJBK0vYxkVxDRZ ZchNiMisKBMBEjVDbtcqtQncnUnV12wO5Fo799bZkz9FmNJrT8Vhcbmm0zS5uQX9556n R2d0EPjIqThin7bIBtxyw38rjCA2X/VRkWgfLybO9f0jb1Lq1T8U090YkLc/oL6C5QQ9 iVGfCP/LK6n1CKtFFsezz/3SenqCQEtqASHQF7lg11tb5cROOQxhFUUmlegvSARkpLRC YZtw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=omp.ru); spf=pass (google.com: domain of linux-kernel+bounces-111182-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111182-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id m62-20020a625841000000b006e721d9d6a2si1501713pfb.130.2024.03.22.02.05.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 02:06:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111182-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=omp.ru); spf=pass (google.com: domain of linux-kernel+bounces-111182-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111182-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1BA53285431 for ; Fri, 22 Mar 2024 09:05:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C48E1B27A; Fri, 22 Mar 2024 09:05:39 +0000 (UTC) Received: from mx01.omp.ru (mx01.omp.ru [90.154.21.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF7DF171AC for ; Fri, 22 Mar 2024 09:05:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.154.21.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711098338; cv=none; b=e7x9q5/FWu/dY2loKnaJSlO+3V4boDlU1vM77tfWaVOgYFJbESk0GYDw5avV1fMGqyXW7ka0iIcRtKN2KgbVR4BPih4rjGctnPctylMOORN9NAdRtEQgaDrjPYP05oFMJzcwhDQ5uZahfoNy0NjkMWsu455VdASbnZlMejRWRGU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711098338; c=relaxed/simple; bh=0SfqVZk9hcRK6f4B5G6z0EpueUIq5c4y6dDJtYndN1Q=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=O54b5QKH3pVkY648geusCWQR/ysDcD+fg0pkyISYOoUsqw5Ih2C8BlOBJ1zJ7H3R1X5ljMF9SJ3W16iPdWMctVbb3ewK/uGz2tHLvZfMIL/mlTO70m3Z9wl6fKj/VKoH6+9Ww9rx+h1aIMZuYpMxMjhGE687K5ntn9oJ5xI55q0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=omp.ru; spf=pass smtp.mailfrom=omp.ru; arc=none smtp.client-ip=90.154.21.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=omp.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=omp.ru Received: from msexch01.omp.ru (10.188.4.12) by msexch01.omp.ru (10.188.4.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1258.12; Fri, 22 Mar 2024 12:05:32 +0300 Received: from msexch01.omp.ru ([fe80::485b:1c4a:fb7f:c753]) by msexch01.omp.ru ([fe80::485b:1c4a:fb7f:c753%5]) with mapi id 15.02.1258.012; Fri, 22 Mar 2024 12:05:32 +0300 From: Roman Smirnov To: "jaegeuk@kernel.org" , "chao@kernel.org" CC: "linux-f2fs-devel@lists.sourceforge.net" , "linux-kernel@vger.kernel.org" , Sergey Shtylyov , "Karina Yankevich" , "lvc-project@linuxtesting.org" Subject: [bug report] fs: f2fs: integer overflow in f2fs_truncate_inode_blocks() Thread-Topic: [bug report] fs: f2fs: integer overflow in f2fs_truncate_inode_blocks() Thread-Index: AQHafDfLQelSTjCNm0mAqA97oN6w2Q== Date: Fri, 22 Mar 2024 09:05:32 +0000 Message-ID: <085b27fd2b364a3c8c3a9ca77363e246@omp.ru> Accept-Language: ru-RU, en-US Content-Language: ru-RU X-MS-Has-Attach: X-MS-TNEF-Correlator: x-kse-serverinfo: msexch01.omp.ru, 9 x-kse-antivirus-interceptor-info: scan successful x-kse-antivirus-info: Clean, bases: 3/22/2024 6:00:00 AM x-kse-attachment-filter-triggered-rules: Clean x-kse-attachment-filter-triggered-filters: Clean x-kse-bulkmessagesfiltering-scan-result: InTheLimit Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Hello.=20 There is a possible bug in f2fs_truncate_inode_blocks(): if (err < 0 && err !=3D -ENOENT) goto fail; ... offset[1] =3D 0; offset[0]++; nofs +=3D err; If err =3D -ENOENT then nofs will sum with an error code, which is strange behaviour. Also if nofs < ENOENT this will cause an overflow. err will be equal to -ENOENT with the following call stack: truncate_nodes() f2fs_get_node_page() __get_node_page() read_node_page() It looks like ENOENT processing is missing here. What can you say about it? How can it be fixed? Found by Linux Verification Center (linuxtesting.org) with the Svace static analysis tool.=