Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3285790ybt; Mon, 29 Jun 2020 21:43:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjUigq1WoIjjodtm8saPVlmkn6FZDLHpoBbbBunFJtJpGjUbnMmQMCyitlSZmH9mj3EzFr X-Received: by 2002:aa7:d9c7:: with SMTP id v7mr16730347eds.36.1593492217520; Mon, 29 Jun 2020 21:43:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593492217; cv=none; d=google.com; s=arc-20160816; b=SxCiViahFUYcDR0fZDiUGzKsNwgvayapyG3CWRLDkReQBnwv4j8TeLSkPca8N19Eib X4uwCRzWDyRGeCGF1IUSzJa5eCaOD+bwJQpzkJm75wJ9JUu3VXCqWRZWsJIgZPnCOkWL SJvISNkCWXQOKJpMT7YCxXr8sQQF2kmhp2tZ/6vk0acJOSr10Ls1f3NSWWp1e2cR/qDo J1sPvEl4Jkln4H3HcaWDwB46zfzumSg/edW9VdSW120HDsl1IgWT4pkcaYszEWGEIieQ /Or0/mkZsAbYAyCAimRUAKl/ioVhdnoTXC1JppNsAIUZFI5dgZstT/v0P0BYAAPZkKmP JasQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=VL9ifDWhBa7r4fxQIr8xqOr2mY4ePEXhIxHUKCd3w3w=; b=cEdl8BP/LGw/6PEmSdabopJglpFuDfMcQ4Ayn4YrpnWiFYuaWR25LN7+Eh9Y/YWk8z elTBx7SVxGYHGMiwhyCsIxQTP7T6auwSRiFavTzXNPHoGq0Al6YqVUHkmzXuY6sWM/cR 8QMMHR4x/dz8JuvLHEllWsiXwMf7kF00TaZBpq0FXUtEgZXJuCDxp060Vmd14Lp8W/Sw XXHC+TNpkm46+PMuuTz1MZtnw/miBloPedgyASbAwam3XqxuYoa1DEfZzRc0HEuyYw/N 2gpKn3Bjo6OWmNwvWi5kqNLjJ+FqL+WlWLZSeOf8ay1WrkTPfEAGWneJyLbjDjbXHYFf DIUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d4si832788ejb.349.2020.06.29.21.43.14; Mon, 29 Jun 2020 21:43:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729288AbgF3Elc (ORCPT + 99 others); Tue, 30 Jun 2020 00:41:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726607AbgF3ElK (ORCPT ); Tue, 30 Jun 2020 00:41:10 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5823C03E97B for ; Mon, 29 Jun 2020 21:41:09 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jq84y-002aB7-K2; Tue, 30 Jun 2020 04:41:08 +0000 From: Al Viro To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, "Eric W . Biederman" , David Howells , Nicolas Pitre Subject: [PATCH 4/7] [elf-fdpic] coredump: don't bother with cyclic list for per-thread objects Date: Tue, 30 Jun 2020 05:41:05 +0100 Message-Id: <20200630044108.615673-4-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200630044108.615673-1-viro@ZenIV.linux.org.uk> References: <20200630043641.GD2786714@ZenIV.linux.org.uk> <20200630044108.615673-1-viro@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro plain single-linked list is just fine here... Signed-off-by: Al Viro --- fs/binfmt_elf_fdpic.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index a6ee92137529..bcbf756fba39 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c @@ -1453,7 +1453,7 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p, /* Here is the structure in which status of each thread is captured. */ struct elf_thread_status { - struct list_head list; + struct elf_thread_status *next; struct elf_prstatus_fdpic prstatus; /* NT_PRSTATUS */ elf_fpregset_t fpu; /* NT_PRFPREG */ struct task_struct *thread; @@ -1578,8 +1578,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) struct memelfnote *notes = NULL; struct elf_prstatus_fdpic *prstatus = NULL; /* NT_PRSTATUS */ struct elf_prpsinfo *psinfo = NULL; /* NT_PRPSINFO */ - LIST_HEAD(thread_list); - struct list_head *t; + struct elf_thread_status *thread_list = NULL; elf_fpregset_t *fpu = NULL; int thread_status_size = 0; elf_addr_t *auxv; @@ -1627,15 +1626,12 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) goto end_coredump; tmp->thread = ct->task; - list_add(&tmp->list, &thread_list); + tmp->next = thread_list; + thread_list = tmp; } - list_for_each(t, &thread_list) { - struct elf_thread_status *tmp; - int sz; - - tmp = list_entry(t, struct elf_thread_status, list); - sz = elf_dump_thread_status(cprm->siginfo->si_signo, tmp); + for (tmp = thread_list; tmp; tmp = tmp->next) { + int sz = elf_dump_thread_status(cprm->siginfo->si_signo, tmp); thread_status_size += sz; } @@ -1760,10 +1756,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) goto end_coredump; /* write out the thread status notes section */ - list_for_each(t, &thread_list) { - struct elf_thread_status *tmp = - list_entry(t, struct elf_thread_status, list); - + for (tmp = thread_list; tmp; tmp = tmp->next) { for (i = 0; i < tmp->num_notes; i++) if (!writenote(&tmp->notes[i], cprm)) goto end_coredump; @@ -1791,10 +1784,10 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) } end_coredump: - while (!list_empty(&thread_list)) { - struct list_head *tmp = thread_list.next; - list_del(tmp); - kfree(list_entry(tmp, struct elf_thread_status, list)); + while (thread_list) { + tmp = thread_list; + thread_list = thread_list->next; + kfree(tmp); } kfree(phdr4note); kfree(elf); -- 2.11.0