Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1021785yba; Thu, 4 Apr 2019 02:37:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqwO9DtjL9cBpvbOWYn2npTnCZHNzdxJ1rLFk/CTYY2T3xwg0HE+hcQ8RaqXM5WF9WGUhtpt X-Received: by 2002:a17:902:bd41:: with SMTP id b1mr5343520plx.221.1554370632034; Thu, 04 Apr 2019 02:37:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554370632; cv=none; d=google.com; s=arc-20160816; b=HNU93SW2jHnIY9S99ns8rG7gcnPbe8cgzfu05k+YS8HXAddkiKhZJXHSCEetFMl9SR vzIi2pN1JJl6Cx7XDmVy0IWAh0y9/DKBxd7WKycSB2Yffivqd3IXo4N5uyZiWa8AgwJX 1cX1LSACjpXsEzwtKke1qPnIobBg9LVV/J0MDjFEUzdpW3SCO5r+sv8kd2zufx1inahR cHa0Kmd34yj1wucxUC9TKf8NynCy6Ap93h586VloX7MrlVh6snju1XNfYoi+bz8cbe6+ VqrVr3x8k3gtLOo7cImqDe7tni+6hk6fL1ZNYxbFFMJSjEPyibP1Y+STrl1PcEOgDSGT tVjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IsnmGeWb/vFwhYsk/QdoyoBl+My6bkrgul9hLlddKDw=; b=WuD3o0GQ3GUe/JPACbBcRQiBe4KYfZhUK78gKV8gjZOI7MxlfIp8q0A/boDHke9n4+ 62cNdmmVyDmbYRXtxKUAVDkn2qOJqtpbEpgd8iKASD0zTJnvyNcSz4Qas88DWGDYL5Oh INCA01oJEXispP51wmvKqWMLeBtEhIHuOffTXsPFuZQk8HR3MREEIgro1hy13r75NsEk wcKfb2Bm3LdENPkwoEeOXokaES7CqBAruPJqQMy1giidYrbvJYMD9MGC4XtShrX0bEgg /k4HKOMZnkhMHHmy9jhP5L+10YZeuzmtI1gWw6u6Et6d9EoX12PicYUB7/UzbWuR17UC x/Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="hW/nSsGF"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i6si15423879pfa.87.2019.04.04.02.36.56; Thu, 04 Apr 2019 02:37:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="hW/nSsGF"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732467AbfDDJHP (ORCPT + 99 others); Thu, 4 Apr 2019 05:07:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:45976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732463AbfDDJHM (ORCPT ); Thu, 4 Apr 2019 05:07:12 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EA77C21741; Thu, 4 Apr 2019 09:07:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368831; bh=1QYASjBT7cfph3J+Z+pJhxTE5vKmtqRzPIPlj81N4YQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hW/nSsGFhmafcDKVuygTeG2olj4wr/0nKAtFmxZGbKaAG6S5T8ylMk434vTH4L/B+ K3t7vtHOWsKRcPHcgb56qWqUnZ1vTXJ1riO//OGsIAxvz/uAKZU9k3GPb4NWqSnDTt m50pcxWKCXT4heBfrLMNdj8fx5MyASXbdfuAl44I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sheng Yong , Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH 4.19 160/187] f2fs: UBSAN: set boolean value iostat_enable correctly Date: Thu, 4 Apr 2019 10:48:17 +0200 Message-Id: <20190404084610.646579097@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit ac92985864e187a1735502f6a02f54eaa655b2aa ] When setting /sys/fs/f2fs//iostat_enable with non-bool value, UBSAN reports the following warning. [ 7562.295484] ================================================================================ [ 7562.296531] UBSAN: Undefined behaviour in fs/f2fs/f2fs.h:2776:10 [ 7562.297651] load of value 64 is not a valid value for type '_Bool' [ 7562.298642] CPU: 1 PID: 7487 Comm: dd Not tainted 4.20.0-rc4+ #79 [ 7562.298653] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 [ 7562.298662] Call Trace: [ 7562.298760] dump_stack+0x46/0x5b [ 7562.298811] ubsan_epilogue+0x9/0x40 [ 7562.298830] __ubsan_handle_load_invalid_value+0x72/0x90 [ 7562.298863] f2fs_file_write_iter+0x29f/0x3f0 [ 7562.298905] __vfs_write+0x115/0x160 [ 7562.298922] vfs_write+0xa7/0x190 [ 7562.298934] ksys_write+0x50/0xc0 [ 7562.298973] do_syscall_64+0x4a/0xe0 [ 7562.298992] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 7562.299001] RIP: 0033:0x7fa45ec19c00 [ 7562.299004] Code: 73 01 c3 48 8b 0d 88 92 2c 00 f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 44 00 00 83 3d dd eb 2c 00 00 75 10 b8 01 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 31 c3 48 83 ec 08 e8 ce 8f 01 00 48 89 04 24 [ 7562.299044] RSP: 002b:00007ffca52b49e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 [ 7562.299052] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fa45ec19c00 [ 7562.299059] RDX: 0000000000000400 RSI: 000000000093f000 RDI: 0000000000000001 [ 7562.299065] RBP: 000000000093f000 R08: 0000000000000004 R09: 0000000000000000 [ 7562.299071] R10: 00007ffca52b47b0 R11: 0000000000000246 R12: 0000000000000400 [ 7562.299077] R13: 000000000093f000 R14: 000000000093f400 R15: 0000000000000000 [ 7562.299091] ================================================================================ So, if iostat_enable is enabled, set its value as true. Signed-off-by: Sheng Yong Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/sysfs.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index 81c0e5337443..98887187af4c 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -273,10 +273,16 @@ out: return count; } - *ui = t; - if (!strcmp(a->attr.name, "iostat_enable") && *ui == 0) - f2fs_reset_iostat(sbi); + if (!strcmp(a->attr.name, "iostat_enable")) { + sbi->iostat_enable = !!t; + if (!sbi->iostat_enable) + f2fs_reset_iostat(sbi); + return count; + } + + *ui = (unsigned int)t; + return count; } -- 2.19.1