From nobody Tue Nov 26 04:51:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709681997; cv=none; d=zohomail.com; s=zohoarc; b=JDy4ikyxiOLAgblAumt96+5TNCWG972keWUuuu54n4Ce98aILV98cI4fuK2aUFlST2i+l/4HPWWKKH3wjIAtvOrzJfyoRj1SO1dWedYo9/jTOdA5eq6i7EDNOyCcPTFtXWUWZQ6d6KDXnUZCoagjtEj2rF5fEsyF+kO70sFfWSY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709681997; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=cNrt0Wl61cfd1qXgT4oVr/IuvLTx/2WAS0L17LlfJ9g=; b=LiiS9SUUj2zWLJdEkfzL6wSZ9sWUTdgp3DDSnW2p3OGGDTsK86CttgoHuDvAYRMZ9LHYUpgFLIHzJoV+LsUmnAHk1tJwcxGKgHtK1iszqSh+nIunizV8CxqBeRkP6Olb1KMV7bkzPy3rch0YpTVh0UKEIdmA8d8Qv7VC5I8EprU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709681997577219.26959190622722; Tue, 5 Mar 2024 15:39:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rheNr-0006lk-TM; Tue, 05 Mar 2024 18:39:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rheNo-0006dZ-SG for qemu-devel@nongnu.org; Tue, 05 Mar 2024 18:39:41 -0500 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rheNn-0001W7-0y for qemu-devel@nongnu.org; Tue, 05 Mar 2024 18:39:40 -0500 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-29ae4c7da02so4105213a91.2 for ; Tue, 05 Mar 2024 15:39:36 -0800 (PST) Received: from stoup.. (098-147-055-211.res.spectrum.com. [98.147.55.211]) by smtp.gmail.com with ESMTPSA id s12-20020a17090ad48c00b0029aac9c523fsm10047291pju.47.2024.03.05.15.39.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 15:39:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709681975; x=1710286775; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=cNrt0Wl61cfd1qXgT4oVr/IuvLTx/2WAS0L17LlfJ9g=; b=LroM5vnFfZ1DiD6HMe0ijeveZZ6g9FJ5z6813QztpJm90HmkmKpMbzuS/zuaU7mUxY DMjxfLDLTP3fcvFLy6KoesPNuc7vPUm/4e2sQOP/eFyHcellJqAtOXPoGfPzUKzwib23 ycsowtsFxcJJebtVi+FzdZ7vwWoA8ZR0w9JkvAwOb7zv+dWLSs1Wm5T2DRnJvKdDr9h1 TR32rH9ukGQ+ahHagiXq2RG5cLqG8gAJdF4sjgtXPP/dxNcrUd6bEpG0WWZywRYGOYAN TVTa532mLICxabhFn2tCH5W1FawvKOgvsb5TI5vOlVfIPTmMHyQutcV9djT6z3D6VO8W 4NdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709681975; x=1710286775; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cNrt0Wl61cfd1qXgT4oVr/IuvLTx/2WAS0L17LlfJ9g=; b=iUd02nVnsaWIOTYB2KtSMvm8SYCrp1w7T2PANHwtaeahqkB7Mv2f0Ts7QQcCXS0ooi PvQrIAVR3qajUw5hasD2jbaupM66uqHOwf8sbvq21qqIWUsmf67gCzhv4z7qEWB2Syf9 zo1y/MoR/wiZq2iD0VQEUylgZ5YtESzvbMk0WrmlDOaUTvG9GdUQH+ywghL5IGLLskJk hVI0Wk4R+BAbgztWGjh0p20+sgqb/94wSzggiAHHXDPP3yG6vgZpeW7TvAD3xrlt3a7j TXN8SwGdBaGq8BDxHUor6IDQjMvfaJk5Gn+AfSnsKPL5quRPks8O+wbfws42689iV7Wb QyyA== X-Gm-Message-State: AOJu0YzTjf5oF/wrldTFNinLH5xp7quRySgVy9TAK+ZivQ1uogIthHVk rgfMD1p2TTwKdjl5desZM/gtu4OxhAPJuPRClJMHb6Jssp3w8aQTgLUtVMafNlq+7GpWdQ1tUDV 7 X-Google-Smtp-Source: AGHT+IGKBgZLbDHQf2z1qhqxo44HpmWlW9OkGpZ+Sm2wEcL6uXdJsasMDn5V/xrdjrhcCV5PVhw37Q== X-Received: by 2002:a17:90b:78a:b0:299:3efe:8209 with SMTP id l10-20020a17090b078a00b002993efe8209mr10122967pjz.4.1709681975546; Tue, 05 Mar 2024 15:39:35 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 1/2] linux-user/elfload: Don't close an unopened file descriptor Date: Tue, 5 Mar 2024 13:39:30 -1000 Message-Id: <20240305233931.283629-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240305233931.283629-1-richard.henderson@linaro.org> References: <20240305233931.283629-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709681998803100001 Content-Type: text/plain; charset="utf-8" Fixes Coverity CID: 1534964 Fixes: 106f8da664 ("linux-user/elfload: Open core file after vma_init") Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/elfload.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 0c299a7c15..8565b9520a 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -4522,7 +4522,9 @@ static int elf_core_dump(int signr, const CPUArchStat= e *env) ret =3D -errno; mmap_unlock(); cpu_list_unlock(); - close(fd); + if (fd >=3D 0) { + close(fd); + } return ret; } #endif /* USE_ELF_CORE_DUMP */ --=20 2.34.1 From nobody Tue Nov 26 04:51:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709681997; cv=none; d=zohomail.com; s=zohoarc; b=Kvklp9Iv38C92RaLSca4QEoDbeSg6DV/wKkZS0plCX3JEXcX4SMSBIapJf+3RTUhHUxVaSa3PSuSHenm+76ZVuVoU9UfxhkJmMlAy/kXiyiX9GoeeKPVqbrCdYR+CofEmJ179y9SFaLjctYyCfnhiOg9tuyTR0qSUGVdytUK17M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709681997; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=GOolTmzYeE12+ps8/v2gwrBliAlhC/9M+kqd6Bq+ehk=; b=iwSuvD7PALhzQZ+XmB1wZw9yiXKLmlikMppMopH2MERe0bRTDHi70h3KKNZF8XTA1wUGv2eGbVgrUeBmai0RMViw2UFArjo5T+Hw3gtbz2Be+e3Jsbq6e0hd4NAtBVrc0uM+yEQKlIgaUyippCskmemTsu3/edoeWFPuzFINIqE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709681997592638.0555273959898; Tue, 5 Mar 2024 15:39:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rheNp-0006da-Ie; Tue, 05 Mar 2024 18:39:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rheNn-0006cq-Kw for qemu-devel@nongnu.org; Tue, 05 Mar 2024 18:39:39 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rheNm-0001WA-44 for qemu-devel@nongnu.org; Tue, 05 Mar 2024 18:39:39 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1dc0e5b223eso53860035ad.1 for ; Tue, 05 Mar 2024 15:39:37 -0800 (PST) Received: from stoup.. (098-147-055-211.res.spectrum.com. [98.147.55.211]) by smtp.gmail.com with ESMTPSA id s12-20020a17090ad48c00b0029aac9c523fsm10047291pju.47.2024.03.05.15.39.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 15:39:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709681976; x=1710286776; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=GOolTmzYeE12+ps8/v2gwrBliAlhC/9M+kqd6Bq+ehk=; b=OFwlLqqj5fnU4z/rv3fuC48dQAnXuMY+fM457ZHeSCyn2+0D7YI2WdQ/fxdneMuUcP O8BvnPA7cy5cQ7lQaUHVnr4YmF60VmBTncILE9V5RRBYlccdC1zTrTZA4/sYDevdjatT SMRYeUU90fx9J+jlDLvp2XEF1+qs5noSnnBaiAodSKfU7AEkdvXdcPmGcl5Tr7Xa9plZ UAtUEsIJptFrGJz7WoEEVHCRdyNJLEFdDJUYBD10abGo/b/IM6lUU8qR4S9c+HS1qP/Q 9gTtcbJaAqhQuK6dJ+7NzbGbGXf8drakd6/RO9ZFvDC3dL5DYH54XZ4mEQVC5SZonetf 3hrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709681977; x=1710286777; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GOolTmzYeE12+ps8/v2gwrBliAlhC/9M+kqd6Bq+ehk=; b=LKuxU47tajWa7KooGMOWEdpbAsYWYKPgbLKE0hUJggCWR9bizNiM9ik4RuycXAFPMu qHuLdUpbi9zxNQwvsI+iZGkMp9Rgop4jaECvssd70gbJIMhsUXgDEOOshLAmyR4yPFxT h7SS+uozJGPHqvzR+aORFNpzA/Sx+sAhhLBT4pXiMi1w9S+e1lUBGabzNnKNpTXtPN+A U1KReXuQJptSOfYP+g3BwdwyoAUr4A0lrUF5IbNvG4xJRgyJsXvoBfc3Bhl0K9/ghyDc jl+ButRBqteIqPOnjPVJ2jazBuGO0ofW1p8NWIx+Ruz/c4kF2wqGvn6gHUeAa5u9njXj PO2g== X-Gm-Message-State: AOJu0Yy2PvON+U0grNxEgMgOW9sTcuBYjpyVhewcxwpV2q+TV3NhZxPQ JiDndHNi1ww9sNkYyC8MR0AFdsKHbQB7H4EOXnK4U8ArBPYqSBw53UecRJ5jMrFxTxvvK+qRctu M X-Google-Smtp-Source: AGHT+IFHsQRY4a0tZJkZsSoaS5BfXGM8ih1sPBX0hcKfsFqj1IlsuBjacH242vfiVFf2qKv84ihfuQ== X-Received: by 2002:a17:903:1209:b0:1dc:4199:a31d with SMTP id l9-20020a170903120900b001dc4199a31dmr3817103plh.53.1709681976682; Tue, 05 Mar 2024 15:39:36 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 2/2] linux-user/elfload: Fully initialize struct target_elf_prpsinfo Date: Tue, 5 Mar 2024 13:39:31 -1000 Message-Id: <20240305233931.283629-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240305233931.283629-1-richard.henderson@linaro.org> References: <20240305233931.283629-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709681998816100002 Content-Type: text/plain; charset="utf-8" Fixes Coverity CID: 1534962 Fixes: 243c4706625 ("linux-user/elfload: Write corefile elf header in one b= lock") Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/elfload.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 8565b9520a..a9a6f55d6e 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -4204,7 +4204,14 @@ static void fill_prpsinfo_note(void *data, const Tas= kState *ts) * may well have higher alignment requirements, fill locally and * memcpy to the destination afterward. */ - struct target_elf_prpsinfo psinfo; + struct target_elf_prpsinfo psinfo =3D { + .pr_pid =3D getpid(), + .pr_ppid =3D getppid(), + .pr_pgrp =3D getpgrp(), + .pr_sid =3D getsid(0), + .pr_uid =3D getuid(), + .pr_gid =3D getgid(), + }; char *base_filename; size_t len; =20 @@ -4217,13 +4224,6 @@ static void fill_prpsinfo_note(void *data, const Tas= kState *ts) } } =20 - psinfo.pr_pid =3D getpid(); - psinfo.pr_ppid =3D getppid(); - psinfo.pr_pgrp =3D getpgrp(); - psinfo.pr_sid =3D getsid(0); - psinfo.pr_uid =3D getuid(); - psinfo.pr_gid =3D getgid(); - base_filename =3D g_path_get_basename(ts->bprm->filename); /* * Using strncpy here is fine: at max-length, --=20 2.34.1