From mboxrd@z Thu Jan 1 00:00:00 1970 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=-6.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 407BEC04E53 for ; Wed, 15 May 2019 12:11:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 00DBD20657 for ; Wed, 15 May 2019 12:11:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557922286; bh=RSA8DEQMu9ldm0HrJw3B8vBZEQVu2XSrTqEFNmZeNLI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=QbIai4K7oOki/VtlMVqOhTdZWKdg+EWIkwPM6ZfLVCU/9M8FYUgm9SjleSH6ugv0n nMPHpYrwQTgYzMS27Ew0DNnA9QHhGzGzI/wHrDlzY/cMkPkSE5eJYIDgIzf9eJCwC6 WemcpcCiYHnSxO3bKOy71rwbm1xR6BhBfyvElizA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728379AbfEOLGl (ORCPT ); Wed, 15 May 2019 07:06:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:37458 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728054AbfEOLGh (ORCPT ); Wed, 15 May 2019 07:06:37 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4C0B121743; Wed, 15 May 2019 11:06:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557918396; bh=RSA8DEQMu9ldm0HrJw3B8vBZEQVu2XSrTqEFNmZeNLI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZnOoADCJWBe5LBHKY3VEuNaCBssD/HzhjO24Wa7JnKth5cLzleBWQy5Rw5Nypii4c 9Jn37D/fv3NrBy15dNhEvi5HGw0JAwl8S0tVlMDH3pdGQcOcnIIi0aPJu0F8XWNj8N Ut/xvpcdShaQW77iinpAjJv06QHXTatesyHV+WFI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+de00a87b8644a582ae79@syzkaller.appspotmail.com, Xin Long , "David S. Miller" Subject: [PATCH 4.4 072/266] tipc: check link name with right length in tipc_nl_compat_link_set Date: Wed, 15 May 2019 12:52:59 +0200 Message-Id: <20190515090724.871395071@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190515090722.696531131@linuxfoundation.org> References: <20190515090722.696531131@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xin Long commit 8c63bf9ab4be8b83bd8c34aacfd2f1d2c8901c8a upstream. A similar issue as fixed by Patch "tipc: check bearer name with right length in tipc_nl_compat_bearer_enable" was also found by syzbot in tipc_nl_compat_link_set(). The length to check with should be 'TLV_GET_DATA_LEN(msg->req) - offsetof(struct tipc_link_config, name)'. Reported-by: syzbot+de00a87b8644a582ae79@syzkaller.appspotmail.com Signed-off-by: Xin Long Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/tipc/netlink_compat.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/net/tipc/netlink_compat.c +++ b/net/tipc/netlink_compat.c @@ -738,7 +738,12 @@ static int tipc_nl_compat_link_set(struc lc = (struct tipc_link_config *)TLV_DATA(msg->req); - len = min_t(int, TLV_GET_DATA_LEN(msg->req), TIPC_MAX_LINK_NAME); + len = TLV_GET_DATA_LEN(msg->req); + len -= offsetof(struct tipc_link_config, name); + if (len <= 0) + return -EINVAL; + + len = min_t(int, len, TIPC_MAX_LINK_NAME); if (!string_is_valid(lc->name, len)) return -EINVAL;