From patchwork Sun May 9 12:18:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Potter X-Patchwork-Id: 12246409 X-Patchwork-Delegate: kuba@kernel.org 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.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 5C43CC433B4 for ; Sun, 9 May 2021 12:19:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 27B02613E8 for ; Sun, 9 May 2021 12:19:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229615AbhEIMUF (ORCPT ); Sun, 9 May 2021 08:20:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229590AbhEIMUE (ORCPT ); Sun, 9 May 2021 08:20:04 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BE22C061574 for ; Sun, 9 May 2021 05:19:01 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id l18-20020a1ced120000b029014c1adff1edso9590733wmh.4 for ; Sun, 09 May 2021 05:19:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philpotter-co-uk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=YqSSl0qicw8S1ed4pNsXBhSgZaQS6HCAXzNACgXQNog=; b=TOV4S5s0G6u9v9R1FK1rsk1u891PtTqDM59/a0ROMpk+jtnLetiGRleDAxrAKPaqCS HtMzWlcyiMjkWQAcrv+TTxsjPQUY9pe9OplQqo3r2iTQqz3tXsaAWmWBdYLvb8FcuaJR dh4IZ9xTqQbsdEQPgEzlgjlt763h+MYGCWanDIIRF4QKBGgEI/Ky5xifsNYmFYxzxuoM T0PDkjLnYeak3U7DPXZH36DEtxaxPx1KGpJqPfBrXKA3q9ifCROLgiIrzmwfljLFOP5V msDzs0ObROqD9Dj/oCb0FQ9nTPrDFpBFZBzNbHgl8r6YVNX4iPnkAUNUmKngwjXLY8oa N0sA== 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=YqSSl0qicw8S1ed4pNsXBhSgZaQS6HCAXzNACgXQNog=; b=rxSb61XzsTcF9Skj94J/TWXB5kYhYhDzEKlKpdlJNMJSsy1rlWPYTMWNYOBE2s7Yft LoAr4aLR/d0soXJOUfW5S0ewPdaIU7DNMby8zDDRKw2nm5Rx/l2gGTYSmhv8OZJnftMt si4/eG4ieA4wv7p8uhK4f4emoXk+iilzpQZEVtv6b8c8DaL2PPwhroCu7nI1wSfGy6IM 5Dc4d/9VoQ21+La9GICBR8dNjKRXl0sZFg++YtzueU8lJFOl+WQN4HTR95aMGORikkzt /iB56F9FkJx1oYlHZn9mL3wsZFkzm0tGIVKaAK38hFJdiAQ6O55s5sGk/Dwidj6+XWda DoOQ== X-Gm-Message-State: AOAM532tnkECFdtAGEeslmvOcxelUcG+72ZY+XqVuPisGXxQP1bmc4hs 0khCmAormjiJqZspaNBXdEkx7g== X-Google-Smtp-Source: ABdhPJzqyERM42xv3k0v3/mJEy4FwHnNStDcZqDn8swknsVhbFkb4DErcx5RuxDGmuA82atG+raK/w== X-Received: by 2002:a1c:7fd0:: with SMTP id a199mr20861840wmd.161.1620562740099; Sun, 09 May 2021 05:19:00 -0700 (PDT) Received: from localhost.localdomain (2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.a.1.e.e.d.f.d.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:dfde:e1a0::2]) by smtp.gmail.com with ESMTPSA id p10sm19158223wre.84.2021.05.09.05.18.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 May 2021 05:18:59 -0700 (PDT) From: Phillip Potter To: davem@davemloft.net Cc: kuba@kernel.org, yhs@fb.com, ast@kernel.org, johannes.berg@intel.com, rdunlap@infradead.org, 0x7f454c46@gmail.com, yangyingliang@huawei.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] netlink: netlink_sendmsg: memset unused tail bytes in skb Date: Sun, 9 May 2021 13:18:58 +0100 Message-Id: <20210509121858.1232583-1-phil@philpotter.co.uk> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org When allocating the skb within netlink_sendmsg, with certain supplied len arguments, extra bytes are allocated at the end of the data buffer, due to SKB_DATA_ALIGN giving a larger size within __alloc_skb for alignment reasons. This means that after using skb_put with the same len value and then copying data into the skb, the skb tail area is non-zero in size and contains uninitialised bytes. Wiping this area (if it exists) fixes a KMSAN-found uninit-value bug reported by syzbot at: https://syzkaller.appspot.com/bug?id=3e63bcec536b7136b54c72e06adeb87dc6519f69 Reported-by: syzbot+a73d24a22eeeebe5f244@syzkaller.appspotmail.com Signed-off-by: Phillip Potter --- net/netlink/af_netlink.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 3a62f97acf39..e54321b63f98 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -1914,6 +1914,9 @@ static int netlink_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) goto out; } + if (skb->end - skb->tail) + memset(skb_tail_pointer(skb), 0, skb->end - skb->tail); + err = security_netlink_send(sk, skb); if (err) { kfree_skb(skb);