From patchwork Wed Jul 11 14:37:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 10520019 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5A306603D7 for ; Wed, 11 Jul 2018 14:37:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 481D429258 for ; Wed, 11 Jul 2018 14:37:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3CB162926C; Wed, 11 Jul 2018 14:37:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3E4D29257 for ; Wed, 11 Jul 2018 14:37:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388667AbeGKOmY (ORCPT ); Wed, 11 Jul 2018 10:42:24 -0400 Received: from mail-eopbgr40129.outbound.protection.outlook.com ([40.107.4.129]:10720 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388075AbeGKOmY (ORCPT ); Wed, 11 Jul 2018 10:42:24 -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:X-MS-Exchange-SenderADCheck; bh=ntacq14+sONblmmmB0QaGg5iOfk97y/I++nC6xvs4cQ=; b=XWbkDvMlu8NgesdfrZHzucs0TDZJzGerUkJcbtWCqVLbQ2saE/vLJSx9x8tTeL4o5U4wJY+fQXu2ndrr2kkRnU3kIWJs76+/Wq+WneBBmGRFgrTGhSEcj4vNDc9IpHS0HrXh5TidytWr3GMpzqwZO/bz5BRzd6b93SKW448qed0= Received: from localhost.localdomain (185.231.240.5) by HE1PR0801MB2025.eurprd08.prod.outlook.com (2603:10a6:3:50::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.930.21; Wed, 11 Jul 2018 14:37:37 +0000 Subject: [PATCH] fs: Fix double prealloc_shrinker() in sget_fc() From: Kirill Tkhai To: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, dhowells@redhat.com, ktkhai@virtuozzo.com Date: Wed, 11 Jul 2018 17:37:34 +0300 Message-ID: <153131984019.24777.15284245961241666054.stgit@localhost.localdomain> User-Agent: StGit/0.18 MIME-Version: 1.0 X-Originating-IP: [185.231.240.5] X-ClientProxiedBy: LO2P265CA0166.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9::34) To HE1PR0801MB2025.eurprd08.prod.outlook.com (2603:10a6:3:50::14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f3222517-2f72-455f-74fd-08d5e73bd9e2 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:HE1PR0801MB2025; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB2025; 3:CyP7Jc/Z7NQak8goAI+AC9J+bY6TCLaJoXIoRN+BtTZKtHk7QOJ0j8kc+7xrZNOm92+pnT+ar67I/Du8QzKq45Rnp8ofZzR+1rCrd2bULMYO+r3mU1af2Dx504ZxhUmaHIZgGAicah9+P9Tn/EvUHTg/pt4oSoP/IX3PGpM7Fcl9N8Sge+0pIuQgdPG0TW5/yKosQ5yo/QVPiT5jIGdQ57cyPxcxFZzggMVqjjbnKrKKmrcd9tG6+QzsJJHDBT5y; 25:dftJVS4Fzk9Eq7FeeNur/7jROmLfNacIasgb2UQYkkrEkQgys91kfWrtZiuNYSGL/jHQnaJKwwuQZPSXD5uT5+aItYzs1Vo7dFn+YjSR4Uhsn3iCDVcl9JV5VME+JClTfod33mv3+68KBnIy6hyf1NOKI6/7e0sREhXHLy/G5fb9H39v5pTHJ0IO4oxLy/uN+CcT1o1o7T0ej7E78F53a1/oj/BpOfRdzUC8RIcHUUBARerk/2Ll8lkTvwGLmD3ZorSCXfBVUUDUoiM3P8cE/Erv3HVWwJv0+IeYX0JQEQgUaDZdw1fhx4VTQJ162aKdk61gaWBAOsJszxVkO7Cx1A==; 31:ILh0TPDMg7et/Pl3bneqZx5gMMb9P5CHSfJrnR5R65RgldHbFsd6VfWonDA8XX4ZkXosr6IFF+WVPBKSTJ94JG3Ma1FY+DFS+VVghRejm9XsmqdQ80YrycnUzpf7xjr3arWHSbXTq/Zh8PhGePyQFfjqgRCyiZ5sVm4q1QMiLE6JMKCZB3hsRJSCaEQ5DiRnGgh5yZVB2lhSqxp+J9fCVRrLDs3N4bDO8/N0iUobAjw= X-MS-TrafficTypeDiagnostic: HE1PR0801MB2025: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB2025; 20:u8PtjPgAJ2EjzPT/FehnJXiJF7lvIQA3PLbuLUiCZ5BSzhdLd7cw5v8wTFbIJbrG5UWm92tkpSl2BytMxJNVUd+OnxvwoHzbhuqSYZBeDdTVIR3w9eEQHLzJztrIqWikrrxDkIiKTF+m1tkep5UDy6nDRibm9lMI/w0+cHWXVC91GA6o+oCWG5GdCJzAjFBqStwjzKlEBBx/c36F4nZsiLqiTDwchexgHjxmRfGxc+vU753Q3zfmAJBFNSVhYPvDMzJhvT/9pXDZxDgRGm4DF5uEMQpDuRYbIlafVQ/T2yV2Z2robcYcY0IyU/iRgxLHRrZeB9qgJag5y6yNepDDOOqY9XquD5YORYjL5c8iCPitrwEIR4gUVtSZP0JwK++CJphLNqy6/or+AZy10AiBcey32FCGQIW+Fhl67MnfksgkJBkVuflqW28yOH31yzGKqumDlR0wegDtPCDwP5tvrjYWKoWdY495Q+rn/hkmtXCHYWO/5AXTJD0GirpPIH96; 4:d0JSqmOBS4UhpfVRgjt128btPXFKdUkahQXN9Faw4uVXVlpguQz1moCIUQdukhouYb/jgajnK+MVKkIhqiSRrZSWT8syByB186EgOc7uFdJKgNA+LoH0SzMmoSSjY/zAhfnsO20Btq1ATOlk91UNuYizoqwJc8nEJQCV4rGfyEIOuiMCxPqpYIbXGC/eipox2vQQkJRBlJPxp93BoVveTar/lWng8Df4KRslAzi2FH+1l1Q9ucaFm7QiiDs1NSw4rF8Ik5diKghaEngNkHqkqA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3231311)(944501410)(52105095)(3002001)(149027)(150027)(6041310)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:HE1PR0801MB2025; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0801MB2025; X-Forefront-PRVS: 0730093765 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6069001)(366004)(136003)(39850400004)(396003)(376002)(346002)(199004)(189003)(68736007)(105586002)(106356001)(230700001)(8936002)(81166006)(25786009)(81156014)(956004)(476003)(3846002)(2906002)(26005)(53936002)(486006)(8676002)(6116002)(186003)(14444005)(50466002)(47776003)(23676004)(386003)(97736004)(7696005)(16526019)(1857600001)(86362001)(6506007)(61506002)(305945005)(66066001)(2486003)(7736002)(33896004)(6306002)(55016002)(966005)(5660300001)(9686003)(52116002)(6666003)(316002)(58126008)(103116003)(478600001)(99710200001); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0801MB2025; H:localhost.localdomain; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtIRTFQUjA4MDFNQjIwMjU7MjM6ckxDR2ZwNjU4Vm5zOHdMaXNMOGpmcXN4?= =?utf-8?B?NlMwSHJkUFJJYktXbzM2K2JCVmROTXVZMElDekFoL2lCeDB3dkJlV2lBS1Jm?= =?utf-8?B?RzE4NjdWYXVGcXd5NEdqVFYzS3IwZEx5SHVwQnFtTitrNTJ0L1VHWFg2aFU3?= =?utf-8?B?VDFXQW8vRWdxWUoyM3puYWtId2YvTjk1bmpBcUVCeXpEMlBSU3BiVUcxM1Vs?= =?utf-8?B?WmtjYXBHZDZSaVQ3V1IrS2ZRdDdsdm1OUXZIRlBtWUM0OWdqUmNDSEcvcWlJ?= =?utf-8?B?YVZFQ0Vpb1NRK2NPMFJRZEhTRUlXeU5rWGRjUWNRM2R0bVVGdW1hU2IxZ3d5?= =?utf-8?B?djMxZnpxRUtjMWVtR1RJN25LcGdTbG5pNm1Nenk1aGNObExkOW02R2QyYVZn?= =?utf-8?B?WmF2VWVXUDRseWV1QjhSK3o2bDFSdDkySExNMmY0bHUxaHQ3dUJnMklqdmM2?= =?utf-8?B?RzhGVGdtQ1hlWERld1B3Y0NnTWxvYk1iWERZbjQvVjZxL25yNFdhRlJzVlND?= =?utf-8?B?Qy9Vb0llYjZvb1djYldTTnhQdkljbzFiOEd6bXEwaFBNeEorZkZXM3BRclFi?= =?utf-8?B?cnFSVmozNG5vYkxEVXB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VRhGUmoDn71Jp7FtM11/kz6RhZjNNUjSrNhB/vwJHX53XQS0y0NCDL/W1sUygGKUqJJLKDKwA==; 5:j4yhdEd6kZNVUWDacu5coOEkeHvzkz2jeKOjF2prTLsvj98imnspBYrL4rqHsF+T7Mwt2ogQszhWMLP5nyMkfndCEGGZJj51xmu0dF+zQtz7BJM7/mdbiy+v+78jeG7PETnn3faFgkvSeGQFfWaSD6Fe1wAaHQRwz0iUxp4K9tw=; 24:OJU5C1Hp8AB/bPN1KKa/DPKCW7WxsqTwJNJYWRtg2KFhLivsjhmI0AwDTvkCQ9GW6BSo7UVZJRzv6SPVGaFfyg4vXmQoEyR0LJ3wnPvg//4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB2025; 7:/RkA1ptBu5NQMr80lqg+NQ2GpibHMyVtFcwx1JbWcOCPQA13mRnM33xch9iDCZA5Hfyvtbnh3yo2FJ8CcyRzjJkVgCN/xJ3wl4vdLdAXxcXqHpHifClaZReFkUOnhAMDuRoAvU0P0S2bAWMTNtOz5TEIdSoUMEpy2r/518zpnOF6EgRZBablYop/T42vdG3cUMI8ubvVSPfuQNoB2C5+b3xqsK9jTn980KJI8C4jVxj1YTfWcx2oSigdv8kPTCKn; 20:K2KuCKjLFDObe7LDGeAoS92bnELWIvM/Rk7+hbSU1QTaOxtnittdwyPZAANxYEVi76Y+UMBwOu0N1PrQjM413AvVGymnKECBV3O9nvgxZ5tH6KK21DVpeCIYAKKN0HMJpCkj+Lm6bSGW7MxU3LsipcItWeBdWwWacOD2o9tYUZE= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2018 14:37:37.9490 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f3222517-2f72-455f-74fd-08d5e73bd9e2 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB2025 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, I'm observing "KASAN: use-after-free Read in shrink_slab" on recent linux-next in the code I've added: https://syzkaller.appspot.com/bug?id=91767fc6346a4b9e0309a8cd7e2f356c434450b9 It seems to be not related to my patchset, since there is a problem with double preallocation of shrinker. We should use register_shrinker_prepared() in sget_fc(), since shrinker is already allocated in alloc_super(). Signed-off-by: Kirill Tkhai --- fs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/super.c b/fs/super.c index 13647d4fd262..47a819f1a300 100644 --- a/fs/super.c +++ b/fs/super.c @@ -551,7 +551,7 @@ struct super_block *sget_fc(struct fs_context *fc, hlist_add_head(&s->s_instances, &s->s_type->fs_supers); spin_unlock(&sb_lock); get_filesystem(s->s_type); - register_shrinker(&s->s_shrink); + register_shrinker_prepared(&s->shrinker); return s; } EXPORT_SYMBOL(sget_fc);