Message ID | 20240328202922.7025-1-maks.mishinFZ@gmail.com |
---|---|
State | Rejected |
Headers |
Return-Path: <elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 259043858CDB for <patchwork@sourceware.org>; Thu, 28 Mar 2024 20:29:40 +0000 (GMT) X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id C427D3858D1E for <elfutils-devel@sourceware.org>; Thu, 28 Mar 2024 20:29:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C427D3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C427D3858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::234 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711657771; cv=none; b=XgGs1BFOi3wZ/aSUDHtYTvPZOybPH9UoYC2po7Tm2RKD+ePqfzhqvn56XdvrLHKRIpjncS5KiGF/yNI/gTh1ypfVvLSWi9fxmz4RPFhm4W+XeYJi9CNt5CbcImKWMLljSuRKv807sArx+aBLOItgtOtrW/TFgFJtruMOdFmfdlg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711657771; c=relaxed/simple; bh=PEjrEV5DexPBkLEi7LATay9Jwf81YKubatCnhalBoKA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=ntTNldf0JTz41rElSFE4u4VZgOBg0X7JQmXii0+/r8IZQEe6pDXGDGSSFF9fQGAC/99xFwr3cnT7bdPAiy2Kvy3ZSyWe5fXb/VW4Mxy9bM4lSLXwvY4eLWUl3SY6DUYIdEy6R0a7bYE5BDv+yhBB+kbi5eCbwUkqJqRIOiweNsc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2d23114b19dso18937091fa.3 for <elfutils-devel@sourceware.org>; Thu, 28 Mar 2024 13:29:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711657768; x=1712262568; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=fznGxCFYq2pCKV1Hi0YrmUvZCCKP/StUu6MEa4nVuNI=; b=Y4tjDrd7CSuZ5Z9VjmaqV9YRlf6C9fnQbUlGWOZ11oXXbjG5OcLGlmZN77J0K3UWra nOcrbOB0g9cbCpzunmq7xfnU/L1flYmqHo1xG+fkeGtYh+FAOQbsZ8iKuaRqUNZkOE9S DNZKP/UZ5tYr8gSeosnhPKugPIHSMIgwDHiJ3rVjOhHJx2w9rxKdyBXOA3s1LVKHCnFy zCakQy+SLwJjFPzkxC3WaCMIuAUKkWHX1UDySvcSwZfaZgqCAcalc1qGgJ6rdzap2T6t A4kyIwnh0JVfDhjGr+4doN6SGpchSYNudJa8Vppd371zRCsjeVDnTo4EF4ncQ0jJ4pYe rhIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711657768; x=1712262568; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=fznGxCFYq2pCKV1Hi0YrmUvZCCKP/StUu6MEa4nVuNI=; b=wLZjvoesBnWu2tOhihOzfhPBjVmrTUhFW8idPA84xskotrlAnDZpH2OAtepA2XL3Dm DpkbZ4LHlbNzWV5vLRJx9SAQbtSBDDAd5pDnI2Po5RvRo+FIo3uoxnbZweX5QdtVNSdX Q6fgmBKcRcw2ByBjUI0VuxeJOEXQYT19txVPlvKzLNPcQ5FI+ggSg00yqRoPHeKV8JUv nFdqFo94oTxbq/4MwI+wpE8H2hpy0ILp44fy17qtk36+yHxyWWZiZso5+14GE/CY7Qql QNURVEvGM7pqesUavhE3Mtt2yO/ATMhC7OqEDOdN6y4N3ko0CkVtVk9/X63L9m14fkk9 /FDg== X-Gm-Message-State: AOJu0YxckZxW7J7nL1Syu5gFtfQL3iBAbjUkmyL36A5djrbDu2+KYWlB zkXr/+D14ePscBMc3B1X31UjRlLz+or3LJXawkj22Dw1cgr5pMGuUiw18JE+ X-Google-Smtp-Source: AGHT+IH9SaFE4YiXGCKql66wIyHHcjunGJQfndaT1+UGcBn3NQvF6wrP6pIM8RXNFV7vBDmArMFrCw== X-Received: by 2002:a19:a40b:0:b0:513:aa05:9fb0 with SMTP id q11-20020a19a40b000000b00513aa059fb0mr290258lfc.69.1711657767358; Thu, 28 Mar 2024 13:29:27 -0700 (PDT) Received: from mishin.sarov.local (95-37-71-41.dynamic.mts-nn.ru. [95.37.71.41]) by smtp.gmail.com with ESMTPSA id j9-20020a056512398900b00515a87e1288sm51806lfu.123.2024.03.28.13.29.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 13:29:26 -0700 (PDT) From: Maks Mishin <maks.mishinfz@gmail.com> X-Google-Original-From: Maks Mishin <maks.mishinFZ@gmail.com> To: elfutils-devel@sourceware.org Cc: Maks Mishin <maks.mishinFZ@gmail.com> Subject: [PATCH] segment: Fix dangling pointer Date: Thu, 28 Mar 2024 23:29:22 +0300 Message-Id: <20240328202922.7025-1-maks.mishinFZ@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Elfutils-devel mailing list <elfutils-devel.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/elfutils-devel>, <mailto:elfutils-devel-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/elfutils-devel/> List-Post: <mailto:elfutils-devel@sourceware.org> List-Help: <mailto:elfutils-devel-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/elfutils-devel>, <mailto:elfutils-devel-request@sourceware.org?subject=subscribe> Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org |
Series |
segment: Fix dangling pointer
|
|
Commit Message
Maks Mishin
March 28, 2024, 8:29 p.m. UTC
Pointer 'lookup_module' which is a field of the structure 'Dwfl'
freed at segment.c:88 is not overwritten, but it is usually overwritten
after free.
Found by RASU JSC.
Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
---
libdwfl/segment.c | 1 +
1 file changed, 1 insertion(+)
Comments
Hi Maks, On Thu, Mar 28, 2024 at 11:29:22PM +0300, Maks Mishin wrote: > Pointer 'lookup_module' which is a field of the structure 'Dwfl' > freed at segment.c:88 is not overwritten, but it is usually overwritten > after free. But the very next statement is a return true; so old isn't in scope anymore. Why would we assign NULL to it? > Found by RASU JSC. What or who is that? > Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com> > --- > libdwfl/segment.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/libdwfl/segment.c b/libdwfl/segment.c > index f6a3e84e..af76f2f8 100644 > --- a/libdwfl/segment.c > +++ b/libdwfl/segment.c > @@ -86,6 +86,7 @@ insert (Dwfl *dwfl, size_t i, GElf_Addr start, GElf_Addr end, int segndx) > if (unlikely (dwfl->lookup_module == NULL)) > { > free (old); > + old = NULL; > return true; > } > } > -- > 2.30.2 >
Hi Maks, Adding the elfutils-devel list back to the CC because that is where patches are discussed. On Tue, Apr 02, 2024 at 10:45:59PM +0300, Максим Мишин wrote: > RASU JSC is a part of Rosatom, a company where one of the areas of work is > software development based on the Linux kernel. > That's why I'm doing a static analysis of the Linux-core components. > > We use the Svace static analyzer: > https://www.ispras.ru/en/technologies/svace/ > > This patch is the processing of the analyzer's triggers with the > DANGLING_POINTER type for pointer `old`. OK, but that doesn't really make sense. old isn't a dangling pointer. It is a local pointer that is freed before returning from the function. What do you try to accomplish by assigning it the value NULL? What real issue are you trying to fix? Thanks, Mark > пт, 29 мар. 2024 г. в 00:04, Mark Wielaard <mark@klomp.org>: > > > Hi Maks, > > > > On Thu, Mar 28, 2024 at 11:29:22PM +0300, Maks Mishin wrote: > > > Pointer 'lookup_module' which is a field of the structure 'Dwfl' > > > freed at segment.c:88 is not overwritten, but it is usually overwritten > > > after free. > > > > But the very next statement is a return true; so old isn't in scope > > anymore. Why would we assign NULL to it? > > > > > Found by RASU JSC. > > > > What or who is that? > > > > > Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com> > > > --- > > > libdwfl/segment.c | 1 + > > > 1 file changed, 1 insertion(+) > > > > > > diff --git a/libdwfl/segment.c b/libdwfl/segment.c > > > index f6a3e84e..af76f2f8 100644 > > > --- a/libdwfl/segment.c > > > +++ b/libdwfl/segment.c > > > @@ -86,6 +86,7 @@ insert (Dwfl *dwfl, size_t i, GElf_Addr start, > > GElf_Addr end, int segndx) > > > if (unlikely (dwfl->lookup_module == NULL)) > > > { > > > free (old); > > > + old = NULL; > > > return true; > > > } > > > } > > > -- > > > 2.30.2 > > > > > > > > -- > С уважением, > Максим Мишин > +7 (915) 958-41-07 > maks.mishinFZ@gmail.com
diff --git a/libdwfl/segment.c b/libdwfl/segment.c index f6a3e84e..af76f2f8 100644 --- a/libdwfl/segment.c +++ b/libdwfl/segment.c @@ -86,6 +86,7 @@ insert (Dwfl *dwfl, size_t i, GElf_Addr start, GElf_Addr end, int segndx) if (unlikely (dwfl->lookup_module == NULL)) { free (old); + old = NULL; return true; } }