From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 925FDCDE001 for ; Thu, 26 Sep 2024 13:32:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0AAEA6B008C; Thu, 26 Sep 2024 09:32:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 00A576B0093; Thu, 26 Sep 2024 09:32:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DED446B0095; Thu, 26 Sep 2024 09:32:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id BE1ED6B008C for ; Thu, 26 Sep 2024 09:32:09 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 72DAC140827 for ; Thu, 26 Sep 2024 13:32:09 +0000 (UTC) X-FDA: 82606977978.03.A6C311F Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) by imf17.hostedemail.com (Postfix) with ESMTP id 4EF6040005 for ; Thu, 26 Sep 2024 13:32:07 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=bREM96Z1; spf=pass (imf17.hostedemail.com: domain of pmladek@suse.com designates 209.85.218.53 as permitted sender) smtp.mailfrom=pmladek@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727357407; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=V6B4L9PguQXpZvu7wod8xXLrp4XbiyR0NJvOfDo+9EQ=; b=kgCYSuj9cHadttUEo+NxlYj/4fR9AHS+OfFOZa/UDwIey16LmCnw2G81/nAWGYjK5fPPzj UVvG/TeBbOAgnkNDqzcAVLVDOr23NoU76NvfIa9hkyFlx+lac8UZulZ6Mxvfr1kVclnD90 akTDt4Q2dnWJoHQLjU0dcj3FdvlueY4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727357407; a=rsa-sha256; cv=none; b=Q2SGnZGqubyliE3YLc3Vq9WlYWxNPtUOlyIiTEA7vVrqokGAKnOjd8PHqcLdiHSt5tYibf TslzroxeivxANXOyCmdZHjUlXl7dKv2v//xQNa+wg5MMmHCO/uvBvQZQoxqeY5h+srgWjU gQc0gfrEghEot5tIWSVn5KKH6Mhub7I= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=bREM96Z1; spf=pass (imf17.hostedemail.com: domain of pmladek@suse.com designates 209.85.218.53 as permitted sender) smtp.mailfrom=pmladek@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a8d51a7d6f5so130585866b.2 for ; Thu, 26 Sep 2024 06:32:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1727357526; x=1727962326; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=V6B4L9PguQXpZvu7wod8xXLrp4XbiyR0NJvOfDo+9EQ=; b=bREM96Z1jSqQ36xOJO/bU9jagzPJfbnS0Ej7jSkYk0tgwRb9mfcNh5y97Te19r0xCV wHZGFAI2P5A/jZs9GbQGIIbirV4OpG8hji/Hw5yX39YEfRXcOIYnQFNToiZFPgyynUUh Ui5s+Cg2gqSZ+iUorgczotNg38sgHjsR/MYa8juT5R+ivdUCd4oX+g0G9rqKIcInMTy+ AjOSIX1ncpOqIJcKctamAOLfT2mCMalfFV8Gw04sh19NUPxVMD702gyhO75VWhprRpmz h44EL6jWoPqrKBDf9eusXrwifcbmaDBucPsagreMLo15XXD15Ta66VpJtoyOWISMo6bA 2tkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727357526; x=1727962326; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=V6B4L9PguQXpZvu7wod8xXLrp4XbiyR0NJvOfDo+9EQ=; b=XMN5b0s2ZmwYIfjJFaaF+MZgtXiPAbULEH/Rr4K0uNhwe+TO314Kpu511GVN0BoBER G+2QwkZXGzpWj4Xh07yfR5ZL8xbPjfnhfWfd3xb1M9JCePwlJv6XIopW3jMgmdT04MFd qjJOhKOWv2D29LbaMwkz5h2P6bvNwqI7BZY7eYHpKoWWGjEf/DGaMeSQ+iZMFjGdYmMy vMiEaVhPUzJ2oLEyPjdysRL1nmiarSS7qWobNfKFj4+RWfD7a5qXa5IZwnzdYWOTT4l9 11W01D+L/3/PTSyJlXoYZAZq5CxutNucgfBHPKVBmqz6pIQcK3od5X5oSRlCNPCzabaJ fSfg== X-Forwarded-Encrypted: i=1; AJvYcCUrjGkwdK/VcRkpIYcHJc0jhfiR9SS0Hu1AUcryNqR65UYcUQ3ynsqLANfxF8ZoSyC94mvYGjFzhw==@kvack.org X-Gm-Message-State: AOJu0YyWBcBioYc8ab5YHzF1vZ3y88MIW6fGv+F3BYM/gDyyMOGJYAwt 7franiAa6c4vMwc9DC+rXNgzyXsm8ie0/S+9uSYFQJLgSprKfyRTXs2FJ3Axan0= X-Google-Smtp-Source: AGHT+IG4oNQmzrTlb2jF8ndi4FRoYPKIyxkpvaaZ1r8v34GV2vOajwHLhGhi5V/QZz74Pv2R/KsRLQ== X-Received: by 2002:a17:907:7fa0:b0:a91:158c:8057 with SMTP id a640c23a62f3a-a93a0682353mr725893266b.54.1727357525616; Thu, 26 Sep 2024 06:32:05 -0700 (PDT) Received: from pathway.suse.cz ([176.114.240.50]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9392f346e0sm358252266b.11.2024.09.26.06.32.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 06:32:05 -0700 (PDT) Date: Thu, 26 Sep 2024 15:32:03 +0200 From: Petr Mladek To: Sergey Senozhatsky Cc: John Ogness , Catalin Marinas , Steven Rostedt , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: Re: [next-20240925] possible circular locking: uart vs kmemleak Message-ID: References: <20240926040715.GC11458@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240926040715.GC11458@google.com> X-Rspamd-Queue-Id: 4EF6040005 X-Stat-Signature: nn8fpqnnppba3pxd9ty5db481i35j8uk X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1727357527-892162 X-HE-Meta: U2FsdGVkX1+O7meWkzsx7jn8EKxq1eBgasOQMHeaCBAQh+4apCxzNpzquTg7AaHda1f/fomHVFzJ7kYHtT9tl6UbHRxylQEatVEonhzO3T/Q+CW67EIcVrEjmbIRpmVSeVb47GCz3c7gzLbuNsJe8PceejA5coCz8roPY9z56D9Oo9E+AkivF8Rgh4+nPiKdKVDo80i+Ztu2JcYWKig0iAFAffPqHcvo5DQPeKawvneis4k7olV9z8z1Ob1kPJJ5WvPk+kBEZFjtvRwkXGZ/+OwtGS2PLIst/wl4Uvm6Mcm5m/toq1jYtrrEMV3DSRrMo9D17O35xg+uCx1ZfG22tFkv0MwDdTagqVSAU4cipEcaD2+VR5ndEohIxrJpYVXc2dEcGe4jhWaXT6p0GvrEMENZaG8FICFfs08p2iucxHp6tRvzKggdE/h/tgm5Sv028mjrNnzUydseClMYIk3tlOoGKqxYQKHAE5vkvwehiQHjlim0rsNHYrnxv+kstWZtILQkasUVcO7RytoY6ih+GQuqf9tKTMs7FA4LGcYA8I8Xo8jarKRtsrYnWuVsB9/y4KLiJQRJMFRS3MCQvcMkNbCp3Mh53rofGtFcOOF2KGhC4WH1cyUF8bayrvkNlUmMlW/njxh0BiI3/jgHm3AYT+Lc0f+LsSpx5pZaTaISsECJDfJURaoKVF9L0JqFEWZ+72vxhKh4BYb4Qi/1urkMbjN8/L36Vm8pNRcZln+ln5llnGf/x5y7T4ne89KAq2tdnEnoSWKe7egfvou152MOjB3ZKl3DhxYnmKR5VyHQF6EIHmszGcrGQgfppkh+3/8eOxRLIFMeHY1n1oVYeZq7xqFSGb1gdrtHxOzrr18vzXZ+0GrKDdYIhTu4+JIt9+uakB7dab5CMkBL3beYZGaFRMmVOatLvQqzlTcrN12TPLzvs4Tv3mg2dXRKl16JMFbwuWNGartCO/OzGvanSwM PwuI+WQw rJwx1FopxOLsKkO6DN0efXoo+IgAS3buTm61sL9SHfxh7Mzh9EIcnLSp6Eb3v1koAwaNeY1zjqG/HB17+7mkIumdzuS2H7/PqI7vIusdlIeruYeu6w3fzT2VL8aazKh70cRsT+URdm/0hzb/9zG3K4tMdRp/TQ88FvZVkFMjvS3R9smEmWf8z3/t8araJaOzXn9QWqd2Iypfet2vC4e4LsxxkC22GgehVIksm9dZqwvPXTu6J+T9LwVXX7x5icMQrSR5iNjr6Ay/Elsu2jZrzU0FIR905OcrTjhu+ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu 2024-09-26 13:07:15, Sergey Senozhatsky wrote: > Greetings, > > Ran into the following issue today. It's sort of interesting, not sure > what even to do about it. The > > uart -> tty -> mm /* kmalloc -> kmemleak */ > > chain looks problematic, it certainly overlaps with > > mm -> printk -> uart /* which can kmalloc and re-enter mm -> kmemleak? */ I believe that it will get solved by the uart console driver conversion to nbcon. I should remove the path: printk -> uart or more precisely, it should remove the path: console_owner --> &port_lock_key The patchset with the uart 8250 console driver conversion is still pending a review, see the last version at https://lore.kernel.org/r/20240913140538.221708-1-john.ogness@linutronix.de Best Regards, Petr > chain. > > [ 40.056844] ====================================================== > [ 40.056845] WARNING: possible circular locking dependency detected > [ 40.056847] 6.11.0-next-20240925+ #729 Tainted: G W N > [ 40.056849] ------------------------------------------------------ > [ 40.056850] modprobe/431 is trying to acquire lock: > [ 40.056851] ffffffff83cef3e0 (console_owner){-...}-{0:0}, at: console_flush_all+0xd9/0x9d0 > [ 40.056859] > [ 40.056859] but task is already holding lock: > [ 40.056859] ffffffff83ed97d8 (kmemleak_lock){-.-.}-{2:2}, at: kmemleak_free+0x2e/0x70 > [ 40.056866] > [ 40.056866] which lock already depends on the new lock. > [ 40.056866] > [ 40.056867] > [ 40.056867] the existing dependency chain (in reverse order) is: > [ 40.056868] > [ 40.056868] -> #2 (kmemleak_lock){-.-.}-{2:2}: > [ 40.056872] _raw_spin_lock_irqsave+0x76/0xb0 > [ 40.056876] __create_object+0x3a/0x110 > [ 40.056878] __kmalloc_noprof+0x1ff/0x390 > [ 40.056882] __tty_buffer_request_room+0x18b/0x4e0 > [ 40.056887] __tty_insert_flip_string_flags+0x8b/0x3c0 > [ 40.056889] uart_insert_char+0x211/0x7f0 > [ 40.056893] serial8250_handle_irq+0x34a/0xb10 > [ 40.056897] serial8250_default_handle_irq+0xaa/0x170 > [ 40.056900] serial8250_interrupt+0xa7/0x130 > [ 40.056902] __handle_irq_event_percpu+0x1e1/0x680 > [ 40.056904] handle_irq_event+0x87/0x1c0 > [ 40.056906] handle_edge_irq+0x201/0x9b0 > [ 40.056910] __common_interrupt+0xb4/0x120 > [ 40.056914] common_interrupt+0x78/0x90 > [ 40.056917] asm_common_interrupt+0x22/0x40 > [ 40.056921] default_idle+0xb/0x10 > [ 40.056924] default_idle_call+0x6e/0xa0 > [ 40.056927] do_idle+0x172/0x3c0 > [ 40.056930] cpu_startup_entry+0x45/0x60 > [ 40.056932] start_secondary+0x12b/0x130 > [ 40.056935] common_startup_64+0x12c/0x137 > [ 40.056938] > [ 40.056938] -> #1 (&port_lock_key){-.-.}-{2:2}: > [ 40.056942] _raw_spin_lock_irqsave+0x76/0xb0 > [ 40.056945] serial8250_console_write+0xf5/0x1b10 > [ 40.056947] console_flush_all+0x4fd/0x9d0 > [ 40.056949] console_unlock+0x99/0x230 > [ 40.056952] vprintk_emit+0x3b6/0x650 > [ 40.056955] _printk+0x59/0x7b > [ 40.056958] register_console+0x7fb/0xb40 > [ 40.056960] univ8250_console_init+0x3b/0x6b > [ 40.056965] console_init+0x11a/0x3bb > [ 40.056970] start_kernel+0x22a/0x39b > [ 40.056975] x86_64_start_reservations+0x26/0x2b > [ 40.056979] copy_bootdata+0x0/0xb0 > [ 40.056981] common_startup_64+0x12c/0x137 > [ 40.056983] > [ 40.056983] -> #0 (console_owner){-...}-{0:0}: > [ 40.056986] __lock_acquire+0x3790/0x7830 > [ 40.056992] lock_acquire+0x140/0x3b0 > [ 40.056994] console_flush_all+0x482/0x9d0 > [ 40.056996] console_unlock+0x99/0x230 > [ 40.056999] vprintk_emit+0x3b6/0x650 > [ 40.057001] _printk+0x59/0x7b > [ 40.057003] __find_and_remove_object+0x106/0x120 > [ 40.057005] kmemleak_free+0x3d/0x70 > [ 40.057007] free_large_kmalloc+0x4d/0xb0 > [ 40.057009] init_module+0x12/0xffb [zram] > [ 40.057016] do_one_initcall+0x130/0x450 > [ 40.057018] do_init_module+0x36a/0x890 > [ 40.057021] __se_sys_finit_module+0x513/0x7e0 > [ 40.057022] do_syscall_64+0x71/0x110 > [ 40.057024] entry_SYSCALL_64_after_hwframe+0x4b/0x53 > [ 40.057027] > [ 40.057027] other info that might help us debug this: > [ 40.057027] > [ 40.057028] Chain exists of: > [ 40.057028] console_owner --> &port_lock_key --> kmemleak_lock > [ 40.057028] > [ 40.057032] Possible unsafe locking scenario: > [ 40.057032] > [ 40.057033] CPU0 CPU1 > [ 40.057033] ---- ---- > [ 40.057034] lock(kmemleak_lock); > [ 40.057035] lock(&port_lock_key); > [ 40.057037] lock(kmemleak_lock); > [ 40.057039] lock(console_owner); > [ 40.057040] > [ 40.057040] *** DEADLOCK *** > [ 40.057040] > [ 40.057041] 3 locks held by modprobe/431: > [ 40.057043] #0: ffffffff83ed97d8 (kmemleak_lock){-.-.}-{2:2}, at: kmemleak_free+0x2e/0x70 > [ 40.057048] #1: ffffffff83cef440 (console_lock){+.+.}-{0:0}, at: _printk+0x59/0x7b > [ 40.057053] #2: ffffffff83cef050 (console_srcu){....}-{0:0}, at: console_flush_all+0xd9/0x9d0 > [ 40.057057] > [ 40.057057] stack backtrace: > [ 40.057059] CPU: 11 UID: 0 PID: 431 Comm: modprobe Tainted: G W N 6.11.0-next-20240925+ #729 > [ 40.057063] Tainted: [W]=WARN, [N]=TEST > [ 40.057065] Call Trace: > [ 40.057066] > [ 40.057067] dump_stack_lvl+0xa3/0xeb > [ 40.057071] print_circular_bug+0x136/0x1b0 > [ 40.057074] check_noncircular+0x26a/0x370 > [ 40.057078] __lock_acquire+0x3790/0x7830 > [ 40.057085] lock_acquire+0x140/0x3b0 > [ 40.057087] ? console_flush_all+0xd9/0x9d0 > [ 40.057090] ? console_flush_all+0xd9/0x9d0 > [ 40.057092] console_flush_all+0x482/0x9d0 > [ 40.057094] ? console_flush_all+0xd9/0x9d0 > [ 40.057096] ? console_flush_all+0xd9/0x9d0 > [ 40.057100] console_unlock+0x99/0x230 > [ 40.057103] vprintk_emit+0x3b6/0x650 > [ 40.057107] _printk+0x59/0x7b > [ 40.057110] __find_and_remove_object+0x106/0x120 > [ 40.057113] kmemleak_free+0x3d/0x70 > [ 40.057115] free_large_kmalloc+0x4d/0xb0 > [ 40.057118] init_module+0x12/0xffb [zram] > [ 40.057125] do_one_initcall+0x130/0x450 > [ 40.057127] ? __cfi_init_module+0x5/0x5 [zram] > [ 40.057133] ? stack_depot_save_flags+0x25/0x700 > [ 40.057136] ? stack_trace_save+0xb3/0x150 > [ 40.057140] ? kasan_save_track+0x3c/0x60 > [ 40.057143] ? kasan_save_track+0x2b/0x60 > [ 40.057145] ? __kasan_kmalloc+0x6e/0x80 > [ 40.057147] ? do_init_module+0x16e/0x890 > [ 40.057149] ? __se_sys_finit_module+0x513/0x7e0 > [ 40.057151] ? do_syscall_64+0x71/0x110 > [ 40.057156] ? entry_SYSCALL_64_after_hwframe+0x4b/0x53 > [ 40.057160] ? stack_depot_save_flags+0x25/0x700 > [ 40.057162] ? stack_trace_save+0xb3/0x150 > [ 40.057165] ? __create_object+0x62/0x110 > [ 40.057168] ? do_raw_spin_unlock+0x5a/0x950 > [ 40.057170] ? __create_object+0x62/0x110 > [ 40.057173] ? _raw_spin_unlock_irqrestore+0x31/0x40 > [ 40.057176] ? __create_object+0x62/0x110 > [ 40.057179] ? kasan_unpoison+0x49/0x70 > [ 40.057182] ? __asan_register_globals+0x54/0x70 > [ 40.057184] do_init_module+0x36a/0x890 > [ 40.057189] __se_sys_finit_module+0x513/0x7e0 > [ 40.057195] do_syscall_64+0x71/0x110 > [ 40.057197] entry_SYSCALL_64_after_hwframe+0x4b/0x53