Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp1034049lqs; Wed, 6 Mar 2024 04:36:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWewxbG1TmAx6ogR8wSlkwSTgz+1xg76PEl4taVUj1B8qIsk1egRMCrbd9UM9a8UXEZEMLvzGrSu+V1fPKVXR0c1JDQxTuQc5VwaBwsTQ== X-Google-Smtp-Source: AGHT+IH5kX+Gd5QaOQ6O3KxDnmW+I4SKhRbfC73d12E0QjNz3vlmeculdXXHjAa9UqzEfoX5tSA0 X-Received: by 2002:a17:902:c946:b0:1db:dd24:9945 with SMTP id i6-20020a170902c94600b001dbdd249945mr5691433pla.14.1709728616994; Wed, 06 Mar 2024 04:36:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709728616; cv=pass; d=google.com; s=arc-20160816; b=MfWG6iYJZFQeqZgU+98fPIF2hkpP05ZMP3zKZl+9rEGn2a6s9x7uY8YbSN041cE6r4 ExLjfyheZr43u0HPij8mio4CduUGvPlAB0nZsJwTvNKl8DbCht1POftJ5wcUIqhtX9zb hJ9urBuOutU3kPw3fcZAL06YutoX7qZUgaS+ynZWxmkg3Nu3YnbROzgHTvm9swWmla82 Cgh+6LuXzmxzsuAMPS88yvBXyvdoJVA3H9Z9CbAsXNTsDYREh/PkYmBA3iHQoc0ZuYUn OBtjEP5An2lYZUYVMKQdE9iAZ58xn/FunOnjm8oR6LiobSxGfjEmXKUatkMwa9/uhEDa KXWw== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature :dkim-signature:dkim-signature; bh=rBlJtVja81KFeI8Jp6o410PFrC90a2K0vJckbpWhMBc=; fh=iADkmGTq44D9y5mTDfdN5wCkcrcSr/cvhGyxGVyzPAU=; b=dFE2nl9QYWgV718QG3XH7tD26Pf8iYcMvcNr7Nnue5OYknqmsrXOke3UUQJmUGAQQ3 m/jA41olqHyRplH4+RFlgqxDTw86fBDY2Hnq6qEE0DEaXlWtxTW6UL9wWbg+4r8c4eL+ YGIq5JezORolAHsO+hWowmFxu0V9uk/NFggZ872bmVsRbGU3F462+GAGOIxIC2tZDEN2 T6gyM9H77i71W+Oqn3w1jgT+GwWzeX0VyFjBXYCXA7HlHecpMf554XE9tBqp1HJsEagY 0Y+kVNBSxG46N0Q819yUleCluiQDNzUaQKn2hm399Bp8WlqefgbdF4IrjXbmoPRM8sD+ hMxA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=GeEEvH7o; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=GeEEvH7o; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-93897-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93897-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id q13-20020a170902a3cd00b001da195b41dfsi11664896plb.390.2024.03.06.04.36.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 04:36:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-93897-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=GeEEvH7o; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=GeEEvH7o; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-93897-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93897-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id DCC23B219B7 for ; Wed, 6 Mar 2024 12:32:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B7EF1DFC1; Wed, 6 Mar 2024 12:31:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="GeEEvH7o"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="byNP0X5z"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="GeEEvH7o"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="byNP0X5z" Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 29D9884FAD for ; Wed, 6 Mar 2024 12:31:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709728271; cv=none; b=ANWqMj5y46nWJ/kS4qE0fE7fv2oAcY6VrmZg+sfQgmiBmlYidxODcqvwRsvpnLuwUq9ZjIjWQCnCQG3sp5YQ5q6vz+LOi5APLHX69CIpNSGSOrT0DOWueoeM5wtF9nece+lJCk8VjUd7WIfLwBMShInGPHlVdkZYoNQbGNSYxP4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709728271; c=relaxed/simple; bh=kOcsz5u7FPBLTJgum4Kbn4ncNOHyMsdG29cQnUuXgf8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LQ8Esiz+1ZGHCq7fl7VKJRQHvv+ZiJpGgokbj1fbHf7H+55ndjBz8Ri9Z/bTHmNiUt60+fAjzlYELaC1u4nXLz60KWpFqrxcg2FNPkSZnX8k1rmrTwGtiB7sTwkxK85Q363IFyxyZ/gsgTJ0bTMDE4X0+KEW4u+sJT0vbhznkaA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=GeEEvH7o; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=byNP0X5z; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=GeEEvH7o; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=byNP0X5z; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [10.150.64.98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 34DD7759A5; Wed, 6 Mar 2024 12:31:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1709728268; 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=rBlJtVja81KFeI8Jp6o410PFrC90a2K0vJckbpWhMBc=; b=GeEEvH7oKsaX6wN4AhpJKQ+b+OL817lZzSZEp8PpiEfVk2AyHlRcWIZ6nzYzy94FmbjdWB 22LQWNk+j7Rp3cZQSiqoaG7Ox2oEe6/GUdiATcLPr715wlWLkbHwkf4a8/2lmPw39hBhEN wMpw4TCBkafldEp3gXZMM6MAJvW074Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1709728268; 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=rBlJtVja81KFeI8Jp6o410PFrC90a2K0vJckbpWhMBc=; b=byNP0X5z1ajkB68ZoOPJL5oehbqo35x5Oo4zLvow9uSs5KH9AuBSFzcsSu6i+WcQSPlpl/ Q7doAaJd3ptnLzDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1709728268; 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=rBlJtVja81KFeI8Jp6o410PFrC90a2K0vJckbpWhMBc=; b=GeEEvH7oKsaX6wN4AhpJKQ+b+OL817lZzSZEp8PpiEfVk2AyHlRcWIZ6nzYzy94FmbjdWB 22LQWNk+j7Rp3cZQSiqoaG7Ox2oEe6/GUdiATcLPr715wlWLkbHwkf4a8/2lmPw39hBhEN wMpw4TCBkafldEp3gXZMM6MAJvW074Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1709728268; 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=rBlJtVja81KFeI8Jp6o410PFrC90a2K0vJckbpWhMBc=; b=byNP0X5z1ajkB68ZoOPJL5oehbqo35x5Oo4zLvow9uSs5KH9AuBSFzcsSu6i+WcQSPlpl/ Q7doAaJd3ptnLzDQ== Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 9A03F1377D; Wed, 6 Mar 2024 12:31:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id CJLKIgti6GUaTwAAn2gu4w (envelope-from ); Wed, 06 Mar 2024 12:31:07 +0000 From: Oscar Salvador To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Michal Hocko , Vlastimil Babka , Marco Elver , Andrey Konovalov , Alexander Potapenko , Oscar Salvador , kernel test robot Subject: [PATCH 1/2] mm,page_owner: Check for null stack_record before bumping its refcount Date: Wed, 6 Mar 2024 13:32:16 +0100 Message-ID: <20240306123217.29774-2-osalvador@suse.de> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240306123217.29774-1-osalvador@suse.de> References: <20240306123217.29774-1-osalvador@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [2.80 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_SEVEN(0.00)[10]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[intel.com:email,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[vger.kernel.org,kvack.org,suse.com,suse.cz,google.com,gmail.com,suse.de,intel.com]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-2.10)[95.61%] X-Spam-Level: ** X-Spam-Score: 2.80 X-Spam-Flag: NO Although the retrieval of the stack_records for {dummy,failure}_handle happen when page_owner gets initialized, there seems to be some situations where stackdepot space has been already depleted by then, so we get 0-handles which make stack_records being NULL for those cases. Be careful to 1) only bump stack_records refcount and 2) only access stack_record fields if we actually have a non-null stack_record between hands. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202403051032.e2f865a-lkp@intel.com Fixes: 4bedfb314bdd ("mm,page_owner: implement the tracking of the stacks count") Signed-off-by: Oscar Salvador --- mm/page_owner.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mm/page_owner.c b/mm/page_owner.c index 033e349f6479..7163a1c44ccf 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -107,8 +107,10 @@ static __init void init_page_owner(void) /* Initialize dummy and failure stacks and link them to stack_list */ dummy_stack.stack_record = __stack_depot_get_stack_record(dummy_handle); failure_stack.stack_record = __stack_depot_get_stack_record(failure_handle); - refcount_set(&dummy_stack.stack_record->count, 1); - refcount_set(&failure_stack.stack_record->count, 1); + if (dummy_stack.stack_record) + refcount_set(&dummy_stack.stack_record->count, 1); + if (failure_stack.stack_record) + refcount_set(&failure_stack.stack_record->count, 1); dummy_stack.next = &failure_stack; stack_list = &dummy_stack; } @@ -856,6 +858,9 @@ static int stack_print(struct seq_file *m, void *v) unsigned long nr_entries; struct stack_record *stack_record = stack->stack_record; + if (!stack->stack_record) + return 0; + nr_entries = stack_record->size; entries = stack_record->entries; stack_count = refcount_read(&stack_record->count) - 1; -- 2.44.0