From patchwork Sat May 1 16:32:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Claudi X-Patchwork-Id: 12234851 X-Patchwork-Delegate: dsahern@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86F4AC433B4 for ; Sat, 1 May 2021 16:38:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5E23E61481 for ; Sat, 1 May 2021 16:38:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231648AbhEAQiv (ORCPT ); Sat, 1 May 2021 12:38:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:22965 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230195AbhEAQit (ORCPT ); Sat, 1 May 2021 12:38:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619887078; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ya3wLOI6BKQPUQ26BNG5ZARIF5TltVg6MaqK6JTg6jo=; b=I/0aPnkrtqFb1sYo1HNER8Zsm4dsFMeujEbYRaNq9BNI6/Dcpk2/cXyRAry5f9O7UE8EGb xgN/L+5wOmGNoNeFA4VGWfvu5Mo7ERVz7WSYo2TarpbeSm4nodjJD8N2pGdVHjSEDgznUB 2tYw5O7iyoWr3f+5gTV5KCPDjMZJva4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-29-pf5UWe--Oxe5acb9af8qgQ-1; Sat, 01 May 2021 12:37:55 -0400 X-MC-Unique: pf5UWe--Oxe5acb9af8qgQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 27BE51898297; Sat, 1 May 2021 16:37:54 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-28.ams2.redhat.com [10.36.112.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 560FC50C0B; Sat, 1 May 2021 16:37:53 +0000 (UTC) From: Andrea Claudi To: netdev@vger.kernel.org Cc: stephen@networkplumber.org, dsahern@gmail.com Subject: [PATCH iproute2 1/2] tipc: bail out if algname is abnormally long Date: Sat, 1 May 2021 18:32:29 +0200 Message-Id: <0615f30dc0e11d25d61b48a65dfcb9e9f1136188.1619886329.git.aclaudi@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com tipc segfaults when called with an abnormally long algname: $ tipc node set key 0x1234 algname supercalifragilistichespiralidososupercalifragilistichespiralidoso *** buffer overflow detected ***: terminated Fix this returning an error if provided algname is longer than TIPC_AEAD_ALG_NAME. Fixes: 24bee3bf9752 ("tipc: add new commands to set TIPC AEAD key") Signed-off-by: Andrea Claudi --- tipc/node.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tipc/node.c b/tipc/node.c index ae75bfff..bf592a07 100644 --- a/tipc/node.c +++ b/tipc/node.c @@ -236,10 +236,15 @@ get_ops: /* Get algorithm name, default: "gcm(aes)" */ opt_algname = get_opt(opts, "algname"); - if (!opt_algname) + if (!opt_algname) { strcpy(input.key.alg_name, "gcm(aes)"); - else + } else { + if (strlen(opt_algname->val) > TIPC_AEAD_ALG_NAME) { + fprintf(stderr, "error, invalid algname\n"); + return -EINVAL; + } strcpy(input.key.alg_name, opt_algname->val); + } /* Get node identity */ opt_nodeid = get_opt(opts, "nodeid"); From patchwork Sat May 1 16:32:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Claudi X-Patchwork-Id: 12234849 X-Patchwork-Delegate: dsahern@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6962FC433B4 for ; Sat, 1 May 2021 16:37:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D94761481 for ; Sat, 1 May 2021 16:37:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231593AbhEAQis (ORCPT ); Sat, 1 May 2021 12:38:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22644 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230195AbhEAQis (ORCPT ); Sat, 1 May 2021 12:38:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619887077; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tAaAngf+gDad2nQ9tOb2/jsMhQgqXV0Q/WN1X+tGXvs=; b=SXEj7CXz0CiMSnx76zZAq+/5Px7nPrsbYA6NKI3xncdIscq0tBpixYt8pHvuAAU93FxJgw EtFHREVARGx8BAKFAuWoyqeB9xOKkvQGqkifkKnidkK5HgGWBdYZLZ5GOmya5MAgds5q6X 9lGINlbqNdZpPRjzy52vlqhdzBWx1CM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-500--syRrDQXOKaFpv2pZx8Pqg-1; Sat, 01 May 2021 12:37:56 -0400 X-MC-Unique: -syRrDQXOKaFpv2pZx8Pqg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 429CF189829D; Sat, 1 May 2021 16:37:55 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-28.ams2.redhat.com [10.36.112.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 71B6350C0B; Sat, 1 May 2021 16:37:54 +0000 (UTC) From: Andrea Claudi To: netdev@vger.kernel.org Cc: stephen@networkplumber.org, dsahern@gmail.com Subject: [PATCH iproute2 2/2] tipc: bail out if key is abnormally long Date: Sat, 1 May 2021 18:32:30 +0200 Message-Id: <9df1a85dd34faf5377ee67598c76d39db32c699e.1619886329.git.aclaudi@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com tipc segfaults when called with an abnormally long key: $ tipc node set key 0123456789abcdef0123456789abcdef0123456789abcdef *** buffer overflow detected ***: terminated Fix this returning an error if key length is longer than TIPC_AEAD_KEYLEN_MAX. Fixes: 24bee3bf9752 ("tipc: add new commands to set TIPC AEAD key") Signed-off-by: Andrea Claudi --- tipc/misc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tipc/misc.c b/tipc/misc.c index 1daf3072..909975d8 100644 --- a/tipc/misc.c +++ b/tipc/misc.c @@ -113,6 +113,9 @@ int str2key(char *str, struct tipc_aead_key *key) } } + if (len > TIPC_AEAD_KEYLEN_MAX) + return -1; + /* Obtain key: */ if (!ishex) { key->keylen = len;