Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1613805rdb; Wed, 31 Jan 2024 04:14:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IGU9EqkLHXpvaruamkrR4XHtYgJSOlUQOjszTOq9HW+/9A9OyJs2c64V9iIVpMo6o/Hiijp X-Received: by 2002:a05:622a:1a94:b0:42b:ee4c:4798 with SMTP id s20-20020a05622a1a9400b0042bee4c4798mr473811qtc.11.1706703291691; Wed, 31 Jan 2024 04:14:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706703291; cv=pass; d=google.com; s=arc-20160816; b=Al2ciOHnY053IcQkqqC8ETOu5b0j6cAASl0OZgdoDbWV/0aT4RE6VHXxBoWHH3YQyv jdERHNWkcRf/g9oUOkCvXwZRbmcFl3wajaUBzr4ieq86zkP5aHQZKRfUgTJLwdpMq78s XgBQJoTT/cX94Fj6zaHSFQa4THW6MWZvqYiyxj45m+xqAeKdRBao4xZBymUiRkCp5i9n RyLGyftNxiSzwzAmf0cc/QrHWDGx0bG2vc4XnGGw1FPRbsgU2hfBRiK4BE1SOWt57AsZ XIVdLtlYY+CrAEiqz8l0x17syVm4JZovbtIvF1rTyz6RLYTobbydDsv3qFF3/H2YsiM/ 0EJQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:to:from; bh=ca1LZ9NVnWU9DOwnduM6bPX+CJZzbjgKLF5HdzROB78=; fh=fqJ0JbifiGI98IuCI83+URyKH0D59Wqbx4S2wCMuIa4=; b=nK7WFFLOLRjUYD3kyM0UPJe/yskP2pytqaeIzlYBB3Tn7gknkuJ9M7oHXL2luBloA5 b/GYq7dEY4qT/Wugys8DtGiZhd7UW531jqE2pQNfFuKdACnTylDZe1WVMGvrVvy1xLLA nnVVBYdg6OURCeqhrrV+b1PwO9cuqiRtTSlaDeIVVJXYsv+4l4cKL3cO+eZGNJ8Zx+Xo uHtoQHzC8qYcriDrXOFCGkKLPqhCha73PUmHXArhChZkLOY1Z+dB4x1PZkBDtr9z9HuN n5Do/xcpByGs9Gjx5GRiVAAr9VkbKuyDK0LhHbLkjcSVQB3h06WprpQ1GEW55BMPpIvt guvg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=unisoc.com); spf=pass (google.com: domain of linux-kernel+bounces-46407-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46407-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCXFkhC+5syHz3GGps+W2VUyCQFPIYbq20IRupebSmftzx5Mm5EIGGpxW1LswNgY7fJC2czsHupxEXZBNhb4fwT7Tal0tAsDP2HSBa86RQ== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id e1-20020a05622a110100b0042ab57b7b46si3866690qty.600.2024.01.31.04.14.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 04:14:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46407-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=unisoc.com); spf=pass (google.com: domain of linux-kernel+bounces-46407-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46407-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 60DDE1C2746B for ; Wed, 31 Jan 2024 12:14:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 756DE78669; Wed, 31 Jan 2024 12:14:47 +0000 (UTC) Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [222.66.158.135]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE4F978676 for ; Wed, 31 Jan 2024 12:14:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=222.66.158.135 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706703282; cv=none; b=aCUb3oPvy4Yku5po3Znpb93ilDhq6s9pj3bwGMrg2G5/V4XlboJCq5UlGUkYBYonaOtFRGY+MRaeTq/zmgpg3sBL0lnmFdLtSFSMZwD8nOHh5kTon3BY//3La0HyPg07/0ot8uizTBvDAskmiF6OjxcTg386Tw3Kl9zugzduTqE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706703282; c=relaxed/simple; bh=Q0wV+TnItOkEHfIiIhxUFssbDbFUQK4VKdx1sKcggrI=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=cq1KQty6iK0cmY9e6arFPTlpGafWMR2uUkgVjz+XUkZgB05EEM4WQa+Nt/yzKaJZ55gRMvJNCnU9LKY7rEFXZ7kb0sJp9gFJ/QGwnrHz66hWlUdUGeQP4BrSrbTXcK9WprLPHrh2VivrPoMema46blEWDUOwUaamxRlB8wK6ias= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unisoc.com; spf=pass smtp.mailfrom=unisoc.com; arc=none smtp.client-ip=222.66.158.135 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unisoc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=unisoc.com Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 40VCE6du013504; Wed, 31 Jan 2024 20:14:06 +0800 (+08) (envelope-from zhaoyang.huang@unisoc.com) Received: from SHDLP.spreadtrum.com (bjmbx01.spreadtrum.com [10.0.64.7]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4TQ13T1Q8Jz2SjW7v; Wed, 31 Jan 2024 20:06:29 +0800 (CST) Received: from bj03382pcu01.spreadtrum.com (10.0.73.40) by BJMBX01.spreadtrum.com (10.0.64.7) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Wed, 31 Jan 2024 20:14:04 +0800 From: "zhaoyang.huang" To: Damien Le Moal , Niklas Cassel , "Martin K . Petersen" , Hannes Reinecke , , Zhaoyang Huang , Subject: [PATCH 1/1] block: print warning when invalid domain set to ioprio Date: Wed, 31 Jan 2024 20:14:01 +0800 Message-ID: <20240131121401.3898735-1-zhaoyang.huang@unisoc.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SHCAS01.spreadtrum.com (10.0.1.201) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL:SHSQR01.spreadtrum.com 40VCE6du013504 From: Zhaoyang Huang Since few caller check IOPRIO_PRIO_VALUE's return value and bio_set_prio is a open macro to set bio->ioprio directly.It is confused for the developer who run across kernel panic[1] but can find nothing in previous kernel log. Add a pr_err here to dump the information. [1] Here is the kernel panic I run across which caused by a out of bounds check introduced by CONFIG_FOTIFY_SOURCE. [exception_serialno]: [exception_kernel_version]: [exception_reboot_reason]: kernel_crash [exception_panic_reason]: UBSAN: array index out of bounds: Fatal exception [exception_time]: 1970-01-01_08-00-23 [exception_file_info]: not-bugon [exception_task_id]: 409 [exception_task_family]: [f2fs_ckpt-254:4, 409][kthreadd, 2] [exception_pc_symbol]: [] dd_request_merge+0x100/0x110 [exception_stack_info]: [] get_exception_stack_info+0x124/0x2d8 [sysdump]gc [] prepare_exception_info+0x158/0x1d4 [sysdump]gc [] sysdump_panic_event+0x5d8/0x748 [sysdump]gc [] notifier_call_chain+0x98/0x17cgc [] atomic_notifier_call_chain+0x44/0x68gc [] panic+0x194/0x37cgc [] die+0x300/0x310gc [] ubsan_handler+0x34/0x4cgc [] brk_handler+0x9c/0x11cgc [] do_debug_exception+0xb0/0x140gc [] el1_dbg+0x58/0x74gc [] el1h_64_sync_handler+0x3c/0x90gc [] el1h_64_sync+0x68/0x6cgc [] dd_request_merge+0x100/0x110gc //out of bound here caused by the value of class transferred from ioprio [] elv_merge+0x248/0x270gc [] blk_mq_sched_try_merge+0x4c/0x20cgc [] dd_bio_merge+0x64/0xb4gc [] blk_mq_sched_bio_merge+0x68/0x144gc [] blk_mq_submit_bio+0x2e8/0x6c0gc [] __submit_bio+0xbc/0x1b0gc [] submit_bio_noacct_nocheck+0xe4/0x2f0gc [] submit_bio_noacct+0x298/0x3d8gc [] submit_bio+0xd4/0xf0gc [] f2fs_submit_write_bio+0xcc/0x49cgc [] __submit_merged_bio+0x48/0x13cgc [] __submit_merged_write_cond+0x18c/0x1f8gc [] f2fs_submit_merged_write+0x2c/0x38 [] f2fs_sync_node_pages+0x6e0/0x740gc [] f2fs_write_checkpoint+0x4c0/0x97cgc [] __checkpoint_and_complete_reqs+0x88/0x248gc [] issue_checkpoint_thread+0x94/0xf4gc [] kthread+0x110/0x1b8gc Signed-off-by: Zhaoyang Huang --- include/uapi/linux/ioprio.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/ioprio.h b/include/uapi/linux/ioprio.h index bee2bdb0eedb..73c420a0df72 100644 --- a/include/uapi/linux/ioprio.h +++ b/include/uapi/linux/ioprio.h @@ -112,8 +112,11 @@ static __always_inline __u16 ioprio_value(int prioclass, int priolevel, { if (IOPRIO_BAD_VALUE(prioclass, IOPRIO_NR_CLASSES) || IOPRIO_BAD_VALUE(priolevel, IOPRIO_NR_LEVELS) || - IOPRIO_BAD_VALUE(priohint, IOPRIO_NR_HINTS)) + IOPRIO_BAD_VALUE(priohint, IOPRIO_NR_HINTS)) { + pr_err("%s: get a invalid domain in class %d, level %d, hint %d\n", + __func__, prioclass, priolevel, priohint); return IOPRIO_CLASS_INVALID << IOPRIO_CLASS_SHIFT; + } return (prioclass << IOPRIO_CLASS_SHIFT) | (priohint << IOPRIO_HINT_SHIFT) | priolevel; -- 2.25.1