Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2886699pxb; Sun, 28 Feb 2021 17:20:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJxCmwyAP2DHZaXoJ3fTmYyuR1oQzy0jX8szz9z7jEGICMFQj2FCHm6q8Ob+UoKpOHOeVemT X-Received: by 2002:aa7:dd05:: with SMTP id i5mr3984951edv.300.1614561603635; Sun, 28 Feb 2021 17:20:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614561603; cv=none; d=google.com; s=arc-20160816; b=AmJcdbVk6upJBw3qbS4ZxoNBIILVDyFKEqXvww5bAv+LowLlwz07ijqiG3huDl305T oywagV2XXbrO+xtxC6q1GClaklIIgxhXmmmJmGKjeriZL4OpIZltKSbVHiRwv4BfZ2Gg JCzAzH2kY7pomCH4JpCEZJUVXuznlcM1+LFUszGKz4ytp6PBs0NWJZUu/ToL8xzmDS1J Ljdxi5n4KddoiEK4OJzT9xu6TG0wAk97Zvy3R3/Pcw32L6fQmK9T5ItrRbViHId1IIdb 6zQ4S5Q46vHdmRWsVoFNfySu8YFJNQoTFY/v++kFMib4s+q8crx73KTIB7b+wMK6jZH8 e5wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4ldXGh03zy5ClnMT7q7y7sw5ze6F2NXvT0BQp+tFnFA=; b=eX0IjJM7pmzumRa98WTeEpOA95C9ZYo5XJcBAXyIBzq/pUc1hI5pIIPnufjbnwWkqF d617W6Dwzo6D62w7qLrfz92IW+hKpk2xlY41Rr/VFIpel//QwXgXNH/An/159R8o+VQo sARCjGkhnrg1Z50FZM7qR9PLC/AuomiEAqRCJ6Vzo/duQfGnxJVhqAjeMAAyPsvbOdEU Py+DIEYgP3LQtPfpkqIqsGFdXzxCfQ3Pqa7GmMbwDihWt1+S3YhSX7C8/RprqugCwb8A pdsNTN4zod0J3gzXkHZvlJUHry80gudN/sx5rKwAsOgZOWGUDlZEA0fV+Yp4oS3KzRNI y2FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jJC96Eb4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k14si10950657ejp.62.2021.02.28.17.19.41; Sun, 28 Feb 2021 17:20:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jJC96Eb4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231284AbhB1XXf (ORCPT + 99 others); Sun, 28 Feb 2021 18:23:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231247AbhB1XXe (ORCPT ); Sun, 28 Feb 2021 18:23:34 -0500 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C8C6C06174A; Sun, 28 Feb 2021 15:22:53 -0800 (PST) Received: by mail-lf1-x12d.google.com with SMTP id 18so13959757lff.6; Sun, 28 Feb 2021 15:22:53 -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=4ldXGh03zy5ClnMT7q7y7sw5ze6F2NXvT0BQp+tFnFA=; b=jJC96Eb4lChoHEwPbM9kg5VlJ0LO5Te9A4quhDZ2O6VpuJjb7L0HXdE1OL1qynu13q UNbKzw0rQOvti2LPSNzPSpsOoaVhh/O0nvD0TreSJbmJOB3kLTwE5EPpIbhTemS9v0CH 7Q/Xs6E8fy7W4vH/LxSNzk5MadoBFoLPKokaBdK+M/HdJjIsFc483T0njwBBArgyN6x5 TP8dhdS4qeGYGtl23chw2r19X8gkoz8SwzIILrbxuaF862ioy7axrts1LEYkihHsxYB6 jvuch1B8YBVjEBVU7UP1tm7aE68+nV1vtoxUoa8mtF1bV3QsIXKKF4ccLuqY8skQu5Pa qVqw== 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=4ldXGh03zy5ClnMT7q7y7sw5ze6F2NXvT0BQp+tFnFA=; b=kWW/z33c8xYwnEflZyK9ndEbjOkMUICz7Y8vHKGb+CwVgT8OcJRDH0h72fTcWydS+v zqdJz1wHB/h37I73pVNRBR4GNrHacCNNkrm1zUnb7jCXgiFl7kVUKswuwVk0ZSTTQUuh g72lv1eHnHe+qDQURgu+6MwTnoGq52hL/jv3EUg9O46puLBGakSqXa1AY1xYH8vLnUYY LYAKgXEZyXzJb3Npfh59eeH/MtWIR3GdDhPHEtyHaf/gyX3jvbtjmwYXnXSrL7Zf89vW b8z5fA8lS+k0gv38YDyYlj4ktdfiXZuQQJVKGYOnHMlrb3bKbQRIhtp29H9+MqrtEeeF MfKg== X-Gm-Message-State: AOAM530WQ4IPYQXqyh4pEwuftbGzpNNOInY4m0Yxffv/b44DBa8OzvEK ucF2vLEhyjFNeH38HZc8ufw= X-Received: by 2002:ac2:4e71:: with SMTP id y17mr7687310lfs.153.1614554571918; Sun, 28 Feb 2021 15:22:51 -0800 (PST) Received: from localhost.localdomain ([94.103.235.167]) by smtp.gmail.com with ESMTPSA id h62sm1246886lfd.234.2021.02.28.15.22.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Feb 2021 15:22:51 -0800 (PST) From: Pavel Skripkin To: alobakin@pm.me Cc: linmiaohe@huawei.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+80dccaee7c6630fa9dcf@syzkaller.appspotmail.com, Pavel Skripkin Subject: [PATCH v4] net/qrtr: fix __netdev_alloc_skb call Date: Mon, 1 Mar 2021 02:22:40 +0300 Message-Id: <20210228232240.972205-1-paskripkin@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210228201000.13606-1-alobakin@pm.me> References: <20210228201000.13606-1-alobakin@pm.me> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org syzbot found WARNING in __alloc_pages_nodemask()[1] when order >= MAX_ORDER. It was caused by a huge length value passed from userspace to qrtr_tun_write_iter(), which tries to allocate skb. Since the value comes from the untrusted source there is no need to raise a warning in __alloc_pages_nodemask(). [1] WARNING in __alloc_pages_nodemask+0x5f8/0x730 mm/page_alloc.c:5014 Call Trace: __alloc_pages include/linux/gfp.h:511 [inline] __alloc_pages_node include/linux/gfp.h:524 [inline] alloc_pages_node include/linux/gfp.h:538 [inline] kmalloc_large_node+0x60/0x110 mm/slub.c:3999 __kmalloc_node_track_caller+0x319/0x3f0 mm/slub.c:4496 __kmalloc_reserve net/core/skbuff.c:150 [inline] __alloc_skb+0x4e4/0x5a0 net/core/skbuff.c:210 __netdev_alloc_skb+0x70/0x400 net/core/skbuff.c:446 netdev_alloc_skb include/linux/skbuff.h:2832 [inline] qrtr_endpoint_post+0x84/0x11b0 net/qrtr/qrtr.c:442 qrtr_tun_write_iter+0x11f/0x1a0 net/qrtr/tun.c:98 call_write_iter include/linux/fs.h:1901 [inline] new_sync_write+0x426/0x650 fs/read_write.c:518 vfs_write+0x791/0xa30 fs/read_write.c:605 ksys_write+0x12d/0x250 fs/read_write.c:658 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Reported-by: syzbot+80dccaee7c6630fa9dcf@syzkaller.appspotmail.com Signed-off-by: Pavel Skripkin --- net/qrtr/qrtr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index b34358282f37..82d2eb8c21d1 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -439,7 +439,7 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len) if (len == 0 || len & 3) return -EINVAL; - skb = netdev_alloc_skb(NULL, len); + skb = __netdev_alloc_skb(NULL, len, GFP_ATOMIC | __GFP_NOWARN); if (!skb) return -ENOMEM; -- 2.25.1