From patchwork Mon Oct 26 08:45:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wojciech Jowsa X-Patchwork-Id: 1387544 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=xG4Mj1Gq; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=fmizp04J; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::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 ozlabs.org (Postfix) with ESMTPS id 4CKT5L2Qf5z9sRK for ; Mon, 26 Oct 2020 19:48:37 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=0PvO3mlxBS8HWDWKq/apohBzx5k5l574uolYr5JKXrU=; b=xG4Mj1GqlIuyskVbZ/PvMsp/jQ RPGbNPm5HHUARUoHmK08xn5/U439KMUP+8vCu3wEgEQr5bT0N/fKK9os/b0O7XEm2e7bYcn5TEmPp ZhKsXleUbaySHbeC8j2D14Next+CAiiwilbbJNmu6rg9ccFS2mvFlbze3bJ2tgFeJdwcFsgyVckNA nCozYcPREf2qElsF7QSIJ7utqO702Er6og0vvPh309IpmGp2pSSWE5YtnQSCo+xmBRJgCg/wuSljN 5l2nklOAu5IH9doV3ghgxXqft9OoLHEqNPPNHMhUh9f0JztfabdAJvjmD52Pkb7dmhgt+UAEOhaYU oyEMvX7A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kWy9B-0004PB-VY; Mon, 26 Oct 2020 08:46:34 +0000 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kWy98-0004NU-35 for openwrt-devel@lists.openwrt.org; Mon, 26 Oct 2020 08:46:32 +0000 Received: by mail-lj1-x243.google.com with SMTP id d24so8863028ljg.10 for ; Mon, 26 Oct 2020 01:46:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DfEKBKCjk/6GGxI4MLfh3tFRZ2u0AA+9g+QbYuNwQUk=; b=fmizp04JPqN/etlN2Yud6qFjKdF4ZbWkmmLdEoC0XaN5vXjisKOtoShXSlmh0xX/r6 mszHp2a4iYOrR85xL00bUMluHCKhVSJzjgsiysi6RRrwjo75csmLLXKardCR0ubRidy5 9zOY+2tIHBkFV0u573OafhM8adjnHMzW8UqE9tzJ8DImKc7W36SHijgaTvszRcUfkzX3 r+fdpiGxU9JVscY58qIWeh9kyycQDXYKaR2n/fGRAD4rkkV2a67ESUcBIFRoGshZnR2I ct8vb1/BOPZuqX7nchcNx7Ka7FBk5hz42sfd9n+sHuXRbwCdMzJ+2DFV/wtBlw/xitvh BMvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DfEKBKCjk/6GGxI4MLfh3tFRZ2u0AA+9g+QbYuNwQUk=; b=nSPK+KzBhTwimtv1IaLKp1agHWKaaBvxw53RDjCCW4SKi/XMUQJa3d8NKrXSv+vIDE NyJQF5ig1ScLoY8mi/2QmBonKDq/5ZBuYRzGoAog2l3z1zTWDBsc99Wck6EXApGLEtZv OO9N+qiNgu9dayMZZmzM7GNtljwAYtbrANlaFljjA+lGbONLpMzc4P5aujqB/bB+BrFK 9O2NbOzeqyNwnsXmSXwIDPFXEc80vDy3xvsI4Ao8caXMv4jik9372QmDCmH/lucBCt0D 0VSSkabvn6jGEwHWXPonNXY7bCGeCfCAZTrQnJG/lQ+yLvgGVPEv8OJx9P2tmtrXO0El 5aDw== X-Gm-Message-State: AOAM530LgMEDbenj4/9KzR7yyL1yjn/nviMOG8cqCfLRPC+hqKZNqOg3 roqkvbLZYHB7pAcqBkS82XdnvkBWLLZRkw== X-Google-Smtp-Source: ABdhPJyhUBGNZWv4g0vKE7Q6wkeLgtW2XUyb9a0kYrKWNKgx50wukWQWVCNPuSCu0q95F0fk8jjzgg== X-Received: by 2002:a05:651c:105c:: with SMTP id x28mr5645093ljm.223.1603701986705; Mon, 26 Oct 2020 01:46:26 -0700 (PDT) Received: from wjow-XPS-15-9570.lan (host-188-122-2-56.finemedia.pl. [188.122.2.56]) by smtp.gmail.com with ESMTPSA id p26sm970685lfc.75.2020.10.26.01.46.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 01:46:26 -0700 (PDT) From: wojciech.jowsa@gmail.com To: openwrt-devel@lists.openwrt.org Subject: [PATCH] client: don`t clear cl->dispatch Date: Mon, 26 Oct 2020 09:45:27 +0100 Message-Id: <20201026084527.29521-1-wojciech.jowsa@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201026_044630_213462_CB6730A0 X-CRM114-Status: GOOD ( 11.80 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:243 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wojciech.jowsa[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wojciech Jowsa Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Wojciech Jowsa A segfault occurs in ubus_cmp_id when a client tries to subscribe to an ubus object after the object was removed and added again. When the ubus object is removed then a client subcribed to this object in notified about that. This causes following functon calls uh_ubus_subscription_notification_remove_cb-> uh_request_done->memset(&cl->dispatch,..) When the object is added again and the client subscribes to it then following funcation are called ubus_add_object_cb-> avl_insert->avl_find_rec-> ubus_cmp_id. Ubus_cmp_id tries to compare keys by dereferencing pointers but one of the pointers was previoulsy zeroed in uh_request_done. Signed-off-by: Wojciech Jowsa --- client.c | 1 - 1 file changed, 1 deletion(-) diff --git a/client.c b/client.c index 6233d01..45cd591 100644 --- a/client.c +++ b/client.c @@ -125,7 +125,6 @@ void uh_request_done(struct client *cl) uh_chunk_eof(cl); uh_dispatch_done(cl); blob_buf_init(&cl->hdr_response, 0); - memset(&cl->dispatch, 0, sizeof(cl->dispatch)); if (!conf.http_keepalive || cl->request.connection_close) return uh_connection_close(cl);