Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp1310098rdh; Fri, 24 Nov 2023 09:25:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IFsms6bxldZVmu669FfL75zXK56IGFNuMFTz61+0SxNTBQG3QvpmSYmUeES6dvg//5+Ch6y X-Received: by 2002:a17:903:110d:b0:1cc:548d:4252 with SMTP id n13-20020a170903110d00b001cc548d4252mr4787918plh.57.1700846705676; Fri, 24 Nov 2023 09:25:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700846705; cv=none; d=google.com; s=arc-20160816; b=qUfeRAJvYY/CXGT6/Bsfgm8I6XEevvri73ECXrtAnOrFwrCW/O30GTrra4xVK2w8b0 VoAwPLYqRAUdpdAJr58JQBYQRhXyw4P2CsseV7I22sKKawqYVxAQ9LU0w4e4TmULWfbo u5sxxDWTJMpKNzU5kEjwnohMYzavb8Lxq+BZ/pKD1QXDJQFUGC1EUt68fizQJidJpOrQ NiK5WYszwaKT1G0aL594WgnPG5ZRM4KBs93FdLQbkz0UOrgb2JGZYq/0OXFudoJcu2PA y8rFxhcDLPajiffA/UmYJFH+rvCQfwIEkeulYSYSsC6A6zuOaPuuAZmp9mSCz7GtYFXu XnbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature:dkim-signature; bh=HxPPN20iBqWe0yb/pnf+KxCWGpSg8jYorXXnEZgUTj8=; fh=nuaMlao3nlHRFDrdN93Phi6NxAf3p4LHabBOw+efVuA=; b=mIApIc9O0rd5EpRUaXXPoaYkEIbsXIF33BdtK6rj8TQlemD7AQXNS2UjRK+Khc+6Ue T7KDh3+T1wcwM6+qLDDD8QZf3uyyVmNgwvlXCn2SOOo7oHcKcibKC5S6lvgWOKiGdwpa LKlNmbbvoTIA7HaY5OJKAqUuhS8p+sZUROTQnVogt5G7mCBdI5p3OFQ6/m3Jmz0+5sRb RPKK6UAbBj4m3n1D5ylYm4b6vlwHAFIklSsl/gLC1O7BIw0uqAG070vbeTcqjMCKZppQ 68sJSY/mszvjoECN2loo6TVJyUTSZRXUxs1yzN4uZ14CXCXMxCSTYzEqmgn5IakIzQCd uHpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=JKq3gy1y; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=yPummDNZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id b19-20020a170902d89300b001ce5b9a512fsi3408024plz.606.2023.11.24.09.24.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 09:25:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=JKq3gy1y; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=yPummDNZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 601DD8043CAD; Fri, 24 Nov 2023 09:24:39 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231228AbjKXRYW (ORCPT + 99 others); Fri, 24 Nov 2023 12:24:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230484AbjKXRYV (ORCPT ); Fri, 24 Nov 2023 12:24:21 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C1541725; Fri, 24 Nov 2023 09:24:27 -0800 (PST) Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [10.150.64.98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 5289121EB4; Fri, 24 Nov 2023 17:24:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1700846663; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HxPPN20iBqWe0yb/pnf+KxCWGpSg8jYorXXnEZgUTj8=; b=JKq3gy1y0+zqGnocWkqKqCkVdKB7hBsxtY+cqoV5K1aO2lInhionEPN+zXTr25ojWBDBgI uVr5YrrfU9XYHNl9qeZvMyOeoTb8x1AEVhrzkJrFFlPx++Vx7uiGxElcuElrIr/Q+mNXhU XJT5xcG2Ab/FXETFTy75ure7ZOFWVdI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1700846663; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HxPPN20iBqWe0yb/pnf+KxCWGpSg8jYorXXnEZgUTj8=; b=yPummDNZtI/L5rAxH3A6Cu5n6osmRTYKvDpoI00CFzb2d4j1eIBLKFCZGdDcY0P2EJCqPn 5/A5+Uts7OfrkZAw== Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id E88F9132E2; Fri, 24 Nov 2023 17:24:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id BnfYNkbcYGWfUgAAn2gu4w (envelope-from ); Fri, 24 Nov 2023 17:24:22 +0000 Date: Fri, 24 Nov 2023 18:17:08 +0100 From: David Sterba To: Jann Horn Cc: syzbot , clm@fb.com, dsterba@suse.com, josef@toxicpanda.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] WARNING in __kernel_write_iter Message-ID: <20231124171707.GF18929@twin.jikos.cz> Reply-To: dsterba@suse.cz References: <000000000000cf908705eaa8c5a7@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Authentication-Results: smtp-out1.suse.de; none X-Spam-Score: 5.09 X-Spamd-Result: default: False [5.09 / 50.00]; ARC_NA(0.00)[]; HAS_REPLYTO(0.30)[dsterba@suse.cz]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; URI_HIDDEN_PATH(1.00)[https://syzkaller.appspot.com/x/.config?x=d19f5d16783f901]; TAGGED_RCPT(0.00)[12e098239d20385264d3]; REPLYTO_ADDR_EQ_FROM(0.00)[]; REPLY(-4.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_SPAM_SHORT(2.89)[0.965]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_SPAM_LONG(3.50)[1.000]; RCPT_COUNT_SEVEN(0.00)[8]; DBL_BLOCKED_OPENRESOLVER(0.00)[appspotmail.com:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; SUSPICIOUS_RECIPS(1.50)[] X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 24 Nov 2023 09:24:39 -0800 (PST) On Fri, Nov 24, 2023 at 05:21:20PM +0100, Jann Horn wrote: > On Mon, Oct 10, 2022 at 9:04 AM syzbot > wrote: > > HEAD commit: a6afa4199d3d Merge tag 'mailbox-v6.1' of git://git.linaro... > > git tree: upstream > > console output: https://syzkaller.appspot.com/x/log.txt?x=110f6f0a880000 > > kernel config: https://syzkaller.appspot.com/x/.config?x=d19f5d16783f901 > > dashboard link: https://syzkaller.appspot.com/bug?extid=12e098239d20385264d3 > > compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2 > > > > Unfortunately, I don't have any reproducer for this issue yet. > > > > Downloadable assets: > > disk image: https://storage.googleapis.com/syzbot-assets/12e24d042ff9/disk-a6afa419.raw.xz > > vmlinux: https://storage.googleapis.com/syzbot-assets/4862ae4e2edf/vmlinux-a6afa419.xz > > > > IMPORTANT: if you fix the issue, please add the following tag to the commit: > > Reported-by: syzbot+12e098239d20385264d3@syzkaller.appspotmail.com > > > > ------------[ cut here ]------------ > > WARNING: CPU: 1 PID: 20347 at fs/read_write.c:504 __kernel_write_iter+0x639/0x740 > [...] > > __kernel_write fs/read_write.c:537 [inline] > > kernel_write+0x1c5/0x340 fs/read_write.c:558 > > write_buf fs/btrfs/send.c:590 [inline] > > send_header fs/btrfs/send.c:708 [inline] > > send_subvol+0x1a7/0x4b60 fs/btrfs/send.c:7648 > > btrfs_ioctl_send+0x1e34/0x2340 fs/btrfs/send.c:8014 > > _btrfs_ioctl_send+0x2e8/0x420 fs/btrfs/ioctl.c:5233 > > btrfs_ioctl+0x5eb/0xc10 > > vfs_ioctl fs/ioctl.c:51 [inline] > > The issue here is that BTRFS_IOC_SEND looks up an fd with fget() and > then writes into it with kernel_write(). Luckily the ioctl requires > CAP_SYS_ADMIN, and also Linux >=5.8 bails out on __kernel_write() on a > read-only file, so this has no security impact. I'm not sure if we could make the send ioctl safe for a non-root user, the code there has been doing tricks that have security implications. > I'm about to send a fix, let's have syzkaller check it beforehand: > > #syz test https://github.com/thejh/linux.git 573fd2562e0f The fix looks correct to me, thanks.