From patchwork Fri Aug 27 11:22:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: nicola.pancheri@netduma.com X-Patchwork-Id: 1521640 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) 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=bombadil.20210309 header.b=Bqr0GPsL; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=netduma-com.20150623.gappssmtp.com header.i=@netduma-com.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=lBwJtWE6; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 4Gwy774GRjz9sRf for ; Fri, 27 Aug 2021 21:25:07 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :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=g2bxYhghI9xw53oJ+dlj54doDitl4DVpKBFQ3mmldco=; b=Bqr0GPsLKeAZUP qRaWArMzT0LppsprZSvYq69BoBq7+y+IVTHeqoG3AI56NvPh/fPfuNbmgyp5ydQKbtlbaNMUrJrUi pHRL3W2H4tP6PltOBgRg8+07ujf1qU91lHLDfSvoLPdcjiFW7wnkdLVYBC/8IvdX2WwYdErsuD6u4 JKnHiW0ETYGWC4qkQMwwaYzx6rj7XDmpp7C2rGVPsa/ZyWEFADGPHHmIjmSRWeSZKiagAMOel7qq4 ETfy44iUlQtFxFT3thZlyHyTTz1cZWPSyc9TlPb2ig8rxGbdmuMt3DtLLH8cMhHbDgJ4tiXS7y0nC BL+r2gzp0I9u4QqDG8gA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mJZwS-00CK33-Nu; Fri, 27 Aug 2021 11:22:36 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mJZwQ-00CK2l-0m for openwrt-devel@lists.openwrt.org; Fri, 27 Aug 2021 11:22:35 +0000 Received: by mail-wm1-x329.google.com with SMTP id g135so3627727wme.5 for ; Fri, 27 Aug 2021 04:22:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netduma-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZUgU0pq/DMhCRQojZ/SHlRujX4Krut/pugPYoVghoHQ=; b=lBwJtWE6JHDULPtTwODSaydcAsLL1wTwlSji0N5KLk8VWZ0q1myAeuoW4Vj0Dzr6jW UppHaN7rhSvbLT8xraxXHRtarTs61o/2B2VNWWX3Bm4PFjIT7Ua7TkuXj7amXMayOghz RVOYOX4iyeRF1OIwxUP5qwM3AsmcAZDcz6CGRlRsGkXoO1Q3WGg7UhDdWg3xO88lLjI7 Q/BVl+6KojSMuRfEKf5AqD4XJXUBwn72ZDC4zFLspKmOYumMvL7+F/lJX8feIVeArMYO pWLcZorCoPeWWFdyvgUN7U90u/kYfJqMJvCT61yEtneaXnc5v1BG4GyP3AxrA/aefFgR d7wg== 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=ZUgU0pq/DMhCRQojZ/SHlRujX4Krut/pugPYoVghoHQ=; b=Ba43aZIcogBZFuSsNQrB68Oy9pH5QUA/XAWhNdvOT0W017Ii7B69W8EEkUgMrDM+K2 wnUUPDp8J51MXePRAbkegO1MvTf6i5TbIS4oYVAOw03imKtyFzOQfrEdrIk1bCTKxJjw ll2KnDQDG5F/pqBFsNx9V5+dbZZNkTgp7h8mwxd8rtxjaTFiz2hoobRnSVyRGronAWpX /4arvsp5THbWP2PWXYNF+haNmeTzP4hqIH+M+CsCuX47iGpahOf6yWxJyID6AO+dzio9 9SQfGBwxxKiwjF5h5zWmfMqZHUCESWVxN4T+R7bcvkTIn911swNNHs4KtOeNUUkis5lL ZcBQ== X-Gm-Message-State: AOAM530dFb+cFk3S4OtzOMb7OquDV0x/zPH5kkAHjfBl97Cz5kp0SLUL fqXUNwx9W8grcpPcTRGvqCibaAp4EJu4LU/y+08= X-Google-Smtp-Source: ABdhPJztTBV+7aEVCPD7J5XsJdIEOiYKsj0yeTDhctDf3qrVWx38edfZLDNuMfylLTmUvSWZkd9dEA== X-Received: by 2002:a05:600c:295:: with SMTP id 21mr8306231wmk.37.1630063352254; Fri, 27 Aug 2021 04:22:32 -0700 (PDT) Received: from lin-dev-004.modem ([77.95.36.54]) by smtp.gmail.com with ESMTPSA id d124sm5120159wmd.2.2021.08.27.04.22.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Aug 2021 04:22:31 -0700 (PDT) From: nicola.pancheri@netduma.com To: openwrt-devel@lists.openwrt.org Cc: Nicola Pancheri Subject: [PATCH] ubus/lua: fix stack leak Date: Fri, 27 Aug 2021 12:22:26 +0100 Message-Id: <20210827112226.34985-1-nicola.pancheri@netduma.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-20210827_042234_106670_93852A4A X-CRM114-Status: UNSURE ( 9.74 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.7 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Nicola Pancheri Fixes leak in the Lua stack; the call to lua_next in the loop pushes two values to the stack, therefore both values should be popped off the stack. Content analysis details: (0.7 points, 5.0 required) 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:329 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.7 SPF_NEUTRAL SPF: sender does not match SPF record (neutral) -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Nicola Pancheri Fixes leak in the Lua stack; the call to lua_next in the loop pushes two values to the stack, therefore both values should be popped off the stack. Signed-off-by: Nicola Pancheri --- lua/ubus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/ubus.c b/lua/ubus.c index e2bb081..64fe338 100644 --- a/lua/ubus.c +++ b/lua/ubus.c @@ -238,7 +238,7 @@ ubus_lua_format_blob_array(lua_State *L, struct blob_buf *b, bool table) { if (!ubus_lua_format_blob(L, b, table)) { - lua_pop(L, 1); + lua_pop(L, 2); return false; } }