Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp76718ybl; Mon, 2 Dec 2019 07:48:39 -0800 (PST) X-Google-Smtp-Source: APXvYqx/gXfjj5MSsus7sJbJm7aehZlhO7/vQrG5/U/NCGRsGv3+T2TCVmF6xQGtE9/Z0ta+mYIc X-Received: by 2002:a05:6402:17a7:: with SMTP id j7mr25133408edy.8.1575301719004; Mon, 02 Dec 2019 07:48:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575301718; cv=none; d=google.com; s=arc-20160816; b=kciX5DKymvTIQDwZY8DVhyShBnUyWuhveZmmTYHd7EBmHIj5fn0/bLPaeSrV8BSuhw N1lcSWIkrvycAbfGu6M4W2oNMqreqgTtuH4rwDKh8Wc7Yvrga1lJ6QhKleH/3OZuMygt jxPKipNYbIkyMrWt/FniGx5sbIc85PtZ+j5oKHAFmdRlQr/g7GRhZudO10PTsGPNQQCT vBlkfbxam0x16KBQQSEC0PjWVpltqu6dcI3RMi34LxFS/0qJDb7b1stX2rGbhQlSGCYx yTaZ9QcKkCPAQAx1mMVnHKfDby81w78iL47n8L2S4pnWX9vNc63OHm/iPlxI3ZJHRfLa 1DhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=Qo0WCLG/RhcpIAjfVeitSqiWKm1KS1IacYIGFKaHtek=; b=hhDWgWNTSTw/JR6diyLU7HyMrer+96pWtp8J3g4j4K2T9G4eevSZ7I6NX1QunGgvvU sVSRDE68MEgQ+TwenVi6a5jYJxydjq3ru1i0WN5J+xOCGSssi3qEsCP34StabfkfKjOR H0wTqhLVtuvD91gVKgKSWLxefm4DGr2WnOGQ8dZ2ZiYtQlkGon4uzBtRMaVvKRM5T/nT 62zvwmXUmm0mPyaj4oMO8zoT0G6pdPAys7AE4ey3/UggO8nHzjC6jRY1rUKQnA9PvGa8 bV3oT+f27SdkUh0vJjI4wA09NyjdVh/vWTyXlAQGNeoLDhKKyIKMz5DbI2Lt+bxNW0Gd 6LuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=ZuACP+D8; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f4si21960379edn.213.2019.12.02.07.48.14; Mon, 02 Dec 2019 07:48:38 -0800 (PST) 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=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=ZuACP+D8; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727502AbfLBPkt (ORCPT + 99 others); Mon, 2 Dec 2019 10:40:49 -0500 Received: from mail-il1-f196.google.com ([209.85.166.196]:42553 "EHLO mail-il1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727436AbfLBPkt (ORCPT ); Mon, 2 Dec 2019 10:40:49 -0500 Received: by mail-il1-f196.google.com with SMTP id f6so22846ilh.9 for ; Mon, 02 Dec 2019 07:40:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Qo0WCLG/RhcpIAjfVeitSqiWKm1KS1IacYIGFKaHtek=; b=ZuACP+D8ju5cgg0LyHFliG0Q8/9feKVCNcdWd0oXkCcuaedkespPghKpv9mfFyxZRS ZXsnO+3bNzcMA8yRzWG0/lHtJrvvccRtdL5yifvMFNxe27/5jSB6OB5d25YHAAVMey42 wOuwr96LroiltNAZ8mRDNJhho6c3wsufng70hEbeufxMAaZaTa6syagxaGf6gLmg5Nwg /1bLlnOBuSZNkxT5ABR7YDP5ZWq6Ks9KhzQxLz9OL1Xt73Nf3crm0nLNLSmlopYVT38b DV+0YisNvyX9bF9qtS6kmeNq27bByKWy9N6mhMtKsoe0KqlyAVIiZB8FhsYnuL/RU8Y2 ohVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Qo0WCLG/RhcpIAjfVeitSqiWKm1KS1IacYIGFKaHtek=; b=BWNzkWqnmY9QI2eg1g0QxbvgpPEhzXBfrXgraFopKPIkHsZayom68lOgYzPYCfNT14 9KMbDR7BEeGW/Ueq4mpGtQca4SYjAfif5oQPM5o6daDgNMhf0xHEN9rmeG/Ga7v2fLUc APk8JNti0KXhvIlksGXp0YSPL791AVRc5SI9ujJFSZCg43ruAjC5/vD4nskQMaImWk1C OV+urXxIi6Xh5eujb2nLkDJx3w1BwG2hi8Q+/n+kM4uvXVfa0G3JTkU64oE/DZjCo9SI B70OFqeUJU75Jm5kNZ6/oImRuyHfZCU3FZG+XUn8AZslsXxkL2/p6W1JLFKIB78LHM0Y 0xaw== X-Gm-Message-State: APjAAAX/3Wz36gquyo1GxnDw3vLKssAAQg1CG/sm/pnsy4j70Q1ObORA zgroB036ekVLuGn8kkoYYAnt+g== X-Received: by 2002:a92:3dd0:: with SMTP id k77mr20312842ilf.3.1575301248415; Mon, 02 Dec 2019 07:40:48 -0800 (PST) Received: from [192.168.1.159] ([65.144.74.34]) by smtp.gmail.com with ESMTPSA id s2sm8128247ioe.64.2019.12.02.07.40.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Dec 2019 07:40:47 -0800 (PST) Subject: Re: general protection fault in override_creds To: Dmitry Vyukov , syzbot , Al Viro , io-uring@vger.kernel.org, linux-fsdevel Cc: Anna.Schumaker@netapp.com, Casey Schaufler , David Howells , Jann Horn , Kees Cook , Kate Stewart , LKML , NeilBrown , syzkaller-bugs , Thomas Gleixner References: <000000000000da160a0598b2c704@google.com> From: Jens Axboe Message-ID: <39ea5e00-3278-a84f-25ae-c7a93a4b8ab5@kernel.dk> Date: Mon, 2 Dec 2019 08:40:45 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/1/19 10:40 PM, Dmitry Vyukov wrote: > On Mon, Dec 2, 2019 at 7:35 AM syzbot > wrote: >> >> Hello, >> >> syzbot found the following crash on: >> >> HEAD commit: b94ae8ad Merge tag 'seccomp-v5.5-rc1' of git://git.kernel... >> git tree: upstream >> console output: https://syzkaller.appspot.com/x/log.txt?x=10f9ffcee00000 >> kernel config: https://syzkaller.appspot.com/x/.config?x=ff560c3de405258c >> dashboard link: https://syzkaller.appspot.com/bug?extid=5320383e16029ba057ff >> compiler: gcc (GCC) 9.0.0 20181231 (experimental) >> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12dd682ae00000 >> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16290abce00000 >> >> IMPORTANT: if you fix the bug, please add the following tag to the commit: >> Reported-by: syzbot+5320383e16029ba057ff@syzkaller.appspotmail.com > > I think this relates to fs/io_uring.c rather than kernel/cred.c. > +io_uring maintainers Yeah that's my fault, guessing the below will fix it. I'll test and queue it up. diff --git a/fs/io_uring.c b/fs/io_uring.c index ec53aa7cdc94..afafe0463d2d 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -4361,7 +4361,8 @@ static void io_ring_ctx_free(struct io_ring_ctx *ctx) io_unaccount_mem(ctx->user, ring_pages(ctx->sq_entries, ctx->cq_entries)); free_uid(ctx->user); - put_cred(ctx->creds); + if (ctx->creds) + put_cred(ctx->creds); kfree(ctx->completions); kmem_cache_free(req_cachep, ctx->fallback_req); kfree(ctx); @@ -4759,7 +4760,12 @@ static int io_uring_create(unsigned entries, struct io_uring_params *p) ctx->compat = in_compat_syscall(); ctx->account_mem = account_mem; ctx->user = user; + ctx->creds = prepare_creds(); + if (!ctx->creds) { + ret = -ENOMEM; + goto err; + } ret = io_allocate_scq_urings(ctx, p); if (ret) -- Jens Axboe