From patchwork Wed Nov 28 12:39:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Schramm X-Patchwork-Id: 1004524 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) 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; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="UihLxm6+"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jZ50v8En"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 434gG05szhz9s2P for ; Wed, 28 Nov 2018 23:39:36 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ebMqwCaY2ApQ9vf88bYNwVd3oNRncD02BbyhDJ4O/Wk=; b=UihLxm6+TUPGrU 8YvwjYfrL6iU+rxPBwOXrm2vdRXfgz2KWAmdBCEqt5Q1pNhb3BVSRf4Wb3BBOlYJNE5NDomlTyuON Xw10EHlONoWENTWa68QHQMgqKdk8B7ZrETSRx/rtarvm6WDFnu0g/BDMPDE7bZF1bQH3Lsn821CKH 5I7YB7pJm2BCWO+hqFSjLvGFozUkcMw+HRnnvPd4SjfboHmshBDVELSn2FgeAIDHmg9NgDLmbWChd HuFuWBMSSDmjC/K3sKEC0W1ZlCqlWepviz2up0Pyg8DGP4NqrZdWP8T64B4nNBHQZdkFuraulmJbi S7bPI2xjTOn1BQx5haBQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gRz7q-0005Kn-3S; Wed, 28 Nov 2018 12:39:30 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gRz7b-00058m-SN for openwrt-devel@lists.openwrt.org; Wed, 28 Nov 2018 12:39:18 +0000 Received: by mail-wr1-x441.google.com with SMTP id t3so26138152wrr.3 for ; Wed, 28 Nov 2018 04:39:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JePgHmJ8JL3Q8eMK/EU4Ea9q4lBbJOJO4VLDsJIZH4U=; b=jZ50v8EnJH4NyNxCa6EOWZguqrnsQVM/zI6A/noNO8ZOAQ1NnMYEAzOy9oglfVyo4o mXXTNlQOA/+xT1/dihOnS1hCk5S8+a3PLB3fVLzNZVXg7OdKMntYbhLZ2q5C8f0GfeIt TY8l9cNR7jvsjIuxdaNfKLWlZOv+8Fzan5hVuyhUnh5BsRL/S3zVqHH3YJazTwy7Ya5D kPrPx7h1MIumhwpkode0P0k8get/4unttFzE8slfTZQv5hIj1p8cWXPbNKa9r34QjNrZ BpsIqt7uvwywFKrU9wqajxUNAVkIwJIyasGW071lMkBpk28n1E0p9+IanxGMLEaDbFh9 XMIA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=JePgHmJ8JL3Q8eMK/EU4Ea9q4lBbJOJO4VLDsJIZH4U=; b=oiSXHj3smNPDGvskbHkT5yiMnELDhp2VY9WfGzvc7B5ty+kpCs3nPUYjVvpNH5rtie ZgfZCuyOJtAFPGoafZ/klhw5pJmt2vziBNXpG+j6/NGGs5/nIJOYSjr8sBdzJbEIKQpj DZhMc0DSyCiOx150gUmjFbwslkhTM4dRFDxf+9cLBufHCS2GO+SFxhMse/NS8W24WWh5 06vvZbAszai8jANDE7yy+AzzKuZ3OUtkLNJOnAHPHv68VrMS1sNnc5Eo8l4afqEa1Bjp e1+0ZvhHrGqsk0e+1aoGwYR0Gsz0oJI4ya1eIN7Nd4O6GogRc+07KJfWRZ/smc+R/FMm e6Ow== X-Gm-Message-State: AA+aEWZ2248p9/as2lkyZ51g+lNCCUMllK2QPOqwHdCxQbHWHz4z2T6K OG9u7fOJhY5Ase5hkMLEnREvo0pU X-Google-Smtp-Source: AFSGD/WBYnd8JnPhiAu9A6T5RlhNAcz5/Bye+GLXtr6FjKFHBrnc/QGVutlan2Of013kAgXOjWHi6Q== X-Received: by 2002:adf:a393:: with SMTP id l19mr31595801wrb.110.1543408743513; Wed, 28 Nov 2018 04:39:03 -0800 (PST) Received: from sunsetshimmer.lan ([2a02:8106:19:4900:3ab5:b1b6:c8c2:b39f]) by smtp.gmail.com with ESMTPSA id b7sm5612177wrs.47.2018.11.28.04.39.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Nov 2018 04:39:02 -0800 (PST) From: Tobias Schramm To: openwrt-devel@lists.openwrt.org Date: Wed, 28 Nov 2018 13:39:29 +0100 Message-Id: <20181128123931.28840-2-tobleminer@gmail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181128123931.28840-1-tobleminer@gmail.com> References: <20181128123931.28840-1-tobleminer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181128_043915_988987_17C644A9 X-CRM114-Status: UNSURE ( 9.27 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:441 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (tobleminer[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Subject: [OpenWrt-Devel] [PATCH v4 1/3] Ensure blob_attr length check does not perform out of bounds reads X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tobias Schramm , nbd@nbd.name Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Before there might have been as little as one single byte left which would result in 3 bytes of blob_attr->id_len being out of bounds Signed-off-by: Tobias Schramm --- blob.h | 4 ++-- blobmsg.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/blob.h b/blob.h index a092f5d..2304f8c 100644 --- a/blob.h +++ b/blob.h @@ -242,7 +242,7 @@ blob_put_u64(struct blob_buf *buf, int id, uint64_t val) #define __blob_for_each_attr(pos, attr, rem) \ for (pos = (struct blob_attr *) attr; \ - rem > 0 && (blob_pad_len(pos) <= rem) && \ + rem >= sizeof(struct blob_attr) && (blob_pad_len(pos) <= rem) && \ (blob_pad_len(pos) >= sizeof(struct blob_attr)); \ rem -= blob_pad_len(pos), pos = blob_next(pos)) @@ -250,7 +250,7 @@ blob_put_u64(struct blob_buf *buf, int id, uint64_t val) #define blob_for_each_attr(pos, attr, rem) \ for (rem = attr ? blob_len(attr) : 0, \ pos = (struct blob_attr *) (attr ? blob_data(attr) : NULL); \ - rem > 0 && (blob_pad_len(pos) <= rem) && \ + rem >= sizeof(struct blob_attr) && (blob_pad_len(pos) <= rem) && \ (blob_pad_len(pos) >= sizeof(struct blob_attr)); \ rem -= blob_pad_len(pos), pos = blob_next(pos)) diff --git a/blobmsg.h b/blobmsg.h index b06ef59..c75f1d9 100644 --- a/blobmsg.h +++ b/blobmsg.h @@ -266,7 +266,7 @@ int blobmsg_printf(struct blob_buf *buf, const char *name, const char *format, . #define blobmsg_for_each_attr(pos, attr, rem) \ for (rem = attr ? blobmsg_data_len(attr) : 0, \ pos = (struct blob_attr *) (attr ? blobmsg_data(attr) : NULL); \ - rem > 0 && (blob_pad_len(pos) <= rem) && \ + rem >= sizeof(struct blob_attr) && (blob_pad_len(pos) <= rem) && \ (blob_pad_len(pos) >= sizeof(struct blob_attr)); \ rem -= blob_pad_len(pos), pos = blob_next(pos))