Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp378717imm; Thu, 10 May 2018 22:57:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZozqoWH8JG5Yklxqq3qiMBLSPlbzR4FcjLDq8a4r4PNL1CQSbg4LjfoZQBg4GLmC5i05DHe X-Received: by 2002:a63:b907:: with SMTP id z7-v6mr840830pge.9.1526018263552; Thu, 10 May 2018 22:57:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526018263; cv=none; d=google.com; s=arc-20160816; b=At/FtI+7raXUdsCYLYbJD8MdRdjuONW/lnDaXGpVUijJIp10wUUv0esFiYF26vKpEn kCn1pxACi+6PbMRtWqQ9ZRewVLNiFadDHqKihRdOhBpt3vDL1N/wPjn+L7IYZhQLu25T eQ7xOyoheqIkROhh9qk7c0BPpVjersZdIZVexT2VIZ4rbHdOXR9cX+/s81MfFEKhyVnr SDWHv/tOJ//RISi1u9lUoby+jMB0ZeLsAX8/wRalkZ+ZfBH8INX4hZ0EEEOKmPsCXjW+ D1xafhvyf43tyrldJcpnPKzF1yrYSCUfHfiG4wKi9W2VQmGp8AmFkE0wsmDBlZCq/b+i M9cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:user-agent:in-reply-to:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date:dkim-signature:arc-authentication-results; bh=+aAUyLsLQPGzE2RdzDcUn48mpcpsfLQqrsCtPuAyIAw=; b=XEfFmVqnaL8GG9JAEO+5KVuXxE3BIIrUtk8lmpltdYIdBrj8hNVuf/kPD4z68gcsq2 1zkNurchmUquw1omEaPV+bWEMpRW0of28UknvOi/MoeoSwUDTOLSsXDn1xSg8qbqota2 Fhq1iTzB3n/U5g2MrYP9ld49+gvyu7P25Ck5hX//1dEJB/kFloZYRcTxrhJ+VTNxOCVa q+iMct1Jw0kveo5CvpimlfKPsiZbod/4RTbRUGLoip1/xhwbypDrQSivd30I50B5Ed9R StbEJXAPPEsm56HdVCuiRnVfeA4N3yBdc+xXJLclUSj0V/2osDHK6ai77hIi/ozHXlsI PDPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=da3shqto; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b84-v6si2752497pfb.189.2018.05.10.22.57.28; Thu, 10 May 2018 22:57:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=da3shqto; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752028AbeEKF5R (ORCPT + 99 others); Fri, 11 May 2018 01:57:17 -0400 Received: from mail-ve1eur01on0097.outbound.protection.outlook.com ([104.47.1.97]:9612 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750751AbeEKF5O (ORCPT ); Fri, 11 May 2018 01:57:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=+aAUyLsLQPGzE2RdzDcUn48mpcpsfLQqrsCtPuAyIAw=; b=da3shqtoAge7IGJPWZedxbNtj/9BH6lAO9uArL6PHMvoHwII9FBcrtTEtpJCOImmAX/5QUBuP0A+SOAyojSlcYV/p4oo1/rZOP1dxnK2GP1hwowAY0SvrTod4PFGQlreyOCt4JrA5a2Umwf1qqCc3D5dMAjfa/o3OIny+JmttIM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=rkagan@virtuozzo.com; Received: from rkaganip.lan (2a02:2168:e1c:be00::cb2) by VI1PR0801MB1981.eurprd08.prod.outlook.com (2603:10a6:800:8a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.755.16; Fri, 11 May 2018 05:57:08 +0000 Date: Fri, 11 May 2018 08:57:04 +0300 From: Roman Kagan To: Dmitry Vyukov Cc: Paolo Bonzini , Matthew Wilcox , syzbot , "H. Peter Anvin" , KVM list , LKML , Ingo Molnar , Radim =?utf-8?B?S3LEjW3DocWZ?= , syzkaller-bugs , Thomas Gleixner , the arch/x86 maintainers , Cathy Avery , stable Subject: Re: [PATCH] idr: fix invalid ptr dereference on item delete Message-ID: <20180511055704.GB12563@rkaganip.lan> Mail-Followup-To: Roman Kagan , Dmitry Vyukov , Paolo Bonzini , Matthew Wilcox , syzbot , "H. Peter Anvin" , KVM list , LKML , Ingo Molnar , Radim =?utf-8?B?S3LEjW3DocWZ?= , syzkaller-bugs , Thomas Gleixner , the arch/x86 maintainers , Cathy Avery , stable References: <20180510191634.18796-1-rkagan@virtuozzo.com> <52bd5b0b-a4bb-5426-3c92-edd7085faea3@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.3 (2018-01-21) X-Originating-IP: [2a02:2168:e1c:be00::cb2] X-ClientProxiedBy: AM6PR0402CA0013.eurprd04.prod.outlook.com (2603:10a6:209::26) To VI1PR0801MB1981.eurprd08.prod.outlook.com (2603:10a6:800:8a::14) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:VI1PR0801MB1981; X-Microsoft-Exchange-Diagnostics: 1;VI1PR0801MB1981;3:jgjE/bNgTjqNlXbRNa7vaJs8AvSX+jLosHl44Zj4lHJTW/6JongLSSvBH2mbor9+2GU+bHBPa1CvzQ1DZMs5eFf27kjIRqFvrKDGFUps6y3ODyya7Qng1bv7qjoFxiygUGMUMCfwW8/cwRkmOZWjI5/4hmxoa9OE6SkllBYiEJZUAyFFc0LyAkXnqCc84OR+P/IWMXFLzbdmkYRSDX1Kl9DlSnImYR/ovcp1D2zC39RH0iZlZhpzVVJCYJgdr7sQ;25:smjkO+lHs73rw+lHNcTazc5CJ2pq6e3idn2XOTzfuybLEAoxNLEpxomgaAcScm96m1ZL3Wp0UNOn+Bws2+aIdwwTpTcqwx9gtpYCUu6EW74TbeMdinsu/I8LbFOnjaoWhoftlJIvY9TUBxjRBJN9XtvWuSHWdgS+gw4lB38sj7Z8MUmmhswBXp/2zZN6AVuqnUft3vtGTE0DTFdSHEX1b8JKcFdc8sASFGlWBOVj2CyKnRCCqZhn2hnx7gdoto9/iD105M5EyzVq56v9lkgCubuk6D3l50/8QVRM9pdyA64L5BsJEo92ewJWyvhx4X9yOngyLDsOqo8uxs+7ZtUzGQ==;31:taf+j/04OYn1GFQnH2T9s5A9hf2FU/a8ruRAzcKReCvYcLJ9xDLT3Y1/ScOhwBz/qGfRoqjDx5LKTUBEyTEiPyhcbJI6yU41Oq6BoNn6k7gGoBGnXK87dlrUD2eYaOPTmeO5jeP1PH3b+b1gKB+yV8qM7r17Js6FqNYgA9+DmDCCeqjQiCrIOw1qKgxiMXAjyW9aS32VFlr7zQTE4B4aVAbBpVRtpGOan2wn4jymLnM= X-MS-TrafficTypeDiagnostic: VI1PR0801MB1981: X-Microsoft-Exchange-Diagnostics: 1;VI1PR0801MB1981;20:LqCC8mawDfeIiYDh7XDtJI7G8UxW8vQxXoyMcypT5Vbg+K2z5VqVUamZqUu68p2BgnfXBdxtZ8agLY5OCAJBnGaezpa68AQoqhNwl4TQ9ccggiT7T+cLZA9NZIeUWTyAkU8E2jucdpXaZPM9LyXvv97m1J2K9vqPfhQrHlDUwK3emoLEeZYY3YWtnfLXQUCO237r+yH9P9MHK9AuFM/ccwWftmv3Rj5/mYGZ73IzExyNoIzrdkA9pZhUkuYSyVvdtj9mtkqNEZfsD6mt4Z6MtOtdKmdDgytb6J/CrYzb9TEIYxAhVOeSb2KEMMjcPEb6GaZU91qaka+21+/76GuJTFkNvGaCa5rt7C/yDoO/MaL2T6ams7nqQXP6tMNWncmB8b1OvHyaV/VHMjzfVCzwuwt5Ceq9VOZsvNEeYkweM/TiG70V2FN8vAJ5BnuQUhZPqxYt/RgGGt3EaUOsug6YLmMG1Ln6bxze5OdaTZmRlpB5m+E9YMWJGs4oKLalk2hZ;4:VSlK7XeM3OMq5oLEyYq8emrL2etbMug8L31Ws0+MIqMKVCqRgUReaaDU0VD5pMrsMxIDuth42hKkT54G0G2f4/swov8Qv5Mby782QFUC/8Al4uenTH98aq5iJqYg6G7JHMcUE6O/XhxfiK/VTvNsK4lzp/6dR8TppKHxS+2PT6u6w9i7phNOCEfHwL7TmAtrpna9z42YSNeBerOnBBjK6hB4o3FVOAPg/slMlK9m2lvs+xRfiU0u9UNAC0SYC+0AYKElWDzFFWsq+41/hTMWy8yUUES0SQOOJfflnLbKHKt7OCM4rI7J0gTXKITLoRZE X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(3231254)(944501410)(52105095)(93006095)(93001095)(3002001)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123564045)(20161123558120)(6072148)(201708071742011);SRVR:VI1PR0801MB1981;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0801MB1981; X-Forefront-PRVS: 06691A4183 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(366004)(39380400002)(396003)(346002)(39850400004)(376002)(189003)(199004)(21086003)(16526019)(59450400001)(6666003)(46003)(52396003)(446003)(6916009)(7416002)(54906003)(4326008)(53936002)(2906002)(6116002)(386003)(6506007)(16586007)(53546011)(68736007)(25786009)(5660300001)(575784001)(86362001)(229853002)(186003)(8936002)(7696005)(52116002)(76176011)(97736004)(36756003)(476003)(316002)(50466002)(55016002)(486006)(8676002)(7736002)(69596002)(81166006)(8666007)(1076002)(106356001)(105586002)(81156014)(9686003)(6246003)(23726003)(47776003)(33656002)(478600001)(11346002)(305945005)(58126008)(18370500001);DIR:OUT;SFP:1102;SCL:1;SRVR:VI1PR0801MB1981;H:rkaganip.lan;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;VI1PR0801MB1981;23:vqgInOwc/Drq5xKnR9ZszY2b5K/hdWbwz4PYbAs?= =?us-ascii?Q?7iTKOrCF8C2N9ktlq7RzRElk7q9FJ7BJB9YtDmVAlA+riU3N8D/D6GwTUZ7m?= =?us-ascii?Q?mbw/Ovush1wtsVJ3iF6Oeo0RnHOfayyIRQ0SCZh0Zp9G0Wor2u740ywQTIYq?= =?us-ascii?Q?RT4kXXAMFHymftk8DeOrv/MSi6XtrLtiUuqw4d4t68o1oDOZyehXK1m3ZGAt?= =?us-ascii?Q?McxbTkM6nJ7bOLWyKQwOhQisE3JJzrIo58UWDThCmCUB1AWeng2Qj9D0ORzJ?= =?us-ascii?Q?N3iqV9bjgFzrhGn1j2bzTJmbF1145rxB0s9lKkRQ6l7Yzkhf7aIDl/Yfjd+G?= =?us-ascii?Q?sUsND4HALv1nNaxePtmjnRaELtyKlF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HGk=;24:2R1PDXWgR+afaX5dHYi55F6npZaf6Dk81ztPyo2+Nuy6ZJ9Nfv6srzXr5NQP6nQYjYeSeJBjsHsoRWRcImqxPB8ekFZpjqRIke2DfkePtxc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;VI1PR0801MB1981;7:SXUoKRD4+MUB1hbc4G+nOSgL+4Ys9KtkZ/D8CnvX3cKpIFSa4ib34KfNVm7//xXQMuKn8VB3ukF1v6h4D/tyAxNnH1Fk8ucAkCXQCbTPffObqUxNP/bCs0Iqt+ekYOo/v+qDGKNOmI4XiT0u8R7Do40AuVA3yC/pXmXWZqwHFr+J+wsoBgkBhrqhkKECkygL+VD9vqiBwDiiO7SVfuXleQZW1x9rbVxeiau7zTv2m6V1Cq9I5fgSOCSdc+r5x8+b;20:bQmFQ0Rbw7Gkr+SUY9fgmfa3Qhf7pt2oToXACVbE1DusSgTay7fqgsoQGaE0qq3M184ujfiPP32SE5t8A2N1mgrPPg6dJUirasZ+/1QtVkOFyd/vHHkZR6ypu0pJEJxHwywrgivPT+ztdbrQ0yVspD7tSfCbg4XqSdj4UCKNpFE= X-MS-Office365-Filtering-Correlation-Id: 855abf23-c0d6-4e89-fab2-08d5b70408e4 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2018 05:57:08.6158 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 855abf23-c0d6-4e89-fab2-08d5b70408e4 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1981 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 11, 2018 at 07:40:26AM +0200, Dmitry Vyukov wrote: > On Fri, May 11, 2018 at 1:54 AM, Paolo Bonzini wrote: > > On 10/05/2018 21:16, Roman Kagan wrote: > >> If an IDR contains a single entry at index==0, the underlying radix tree > >> has a single item in its root node, in which case > >> __radix_tree_lookup(index!=0) doesn't set its *@nodep argument (in > >> addition to returning NULL). > >> > >> However, the tree itself is not empty, i.e. the tree root doesn't have > >> IDR_FREE tag. > >> > >> As a result, on an attempt to remove an index!=0 entry from such an IDR, > >> radix_tree_delete_item doesn't return early and calls > >> __radix_tree_delete with invalid parameters which are then dereferenced. > >> > >> Reported-by: syzbot+35666cba7f0a337e2e79@syzkaller.appspotmail.com > >> Signed-off-by: Roman Kagan > >> --- > >> lib/radix-tree.c | 5 +++-- > >> 1 file changed, 3 insertions(+), 2 deletions(-) > >> > >> diff --git a/lib/radix-tree.c b/lib/radix-tree.c > >> index da9e10c827df..10ff1bfae952 100644 > >> --- a/lib/radix-tree.c > >> +++ b/lib/radix-tree.c > >> @@ -2040,8 +2040,9 @@ void *radix_tree_delete_item(struct radix_tree_root *root, > >> void *entry; > >> > >> entry = __radix_tree_lookup(root, index, &node, &slot); > >> - if (!entry && (!is_idr(root) || node_tag_get(root, node, IDR_FREE, > >> - get_slot_offset(node, slot)))) > >> + if (!entry && (!is_idr(root) || !node || > >> + node_tag_get(root, node, IDR_FREE, > >> + get_slot_offset(node, slot)))) > >> return NULL; > >> > >> if (item && entry != item) > >> > > > > I cannot really vouch for the patch, but if it is correct it's > > definitely stuff for stable. The KVM testcase is only for 4.17-rc but > > this is a really nasty bug in a core data structure. > > > > Cc: stable@vger.kernel.org > > > > Should radix-tree be compilable in userspace, so that we can add unit > > tests for it?... > > Good point. > > For my education, what/where are the tests that run as user-space code? Actually there are userspace tests for it under tools/tests/radix-tree, but I didn't manage to get them to build. Looks like the recent introduction of a spin_lock in the radix_tree structure (for XArray work?) broke them. Roman.