From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19C50C61DF4 for ; Fri, 24 Nov 2023 17:51:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231403AbjKXRvG (ORCPT ); Fri, 24 Nov 2023 12:51:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229741AbjKXRvD (ORCPT ); Fri, 24 Nov 2023 12:51:03 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D52B4170B; Fri, 24 Nov 2023 09:51:09 -0800 (PST) Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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 E49C721C1C; Fri, 24 Nov 2023 17:51:07 +0000 (UTC) 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 671BE139E8; Fri, 24 Nov 2023 17:51:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id 0NVdFoviYGXtVwAAn2gu4w (envelope-from ); Fri, 24 Nov 2023 17:51:07 +0000 Date: Fri, 24 Nov 2023 18:43:56 +0100 From: David Sterba To: Jann Horn Cc: Chris Mason , Josef Bacik , David Sterba , Alex Lyakas , Alexander Block , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: [PATCH] btrfs: send: Ensure send_fd is writable Message-ID: <20231124174356.GH18929@suse.cz> Reply-To: dsterba@suse.cz References: <20231124164831.2191549-1-jannh@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231124164831.2191549-1-jannh@google.com> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) X-Spamd-Bar: ++++++++++++++++ Authentication-Results: smtp-out1.suse.de; dkim=none; dmarc=none; spf=softfail (smtp-out1.suse.de: 2a07:de40:b281:104:10:150:64:98 is neither permitted nor denied by domain of dsterba@suse.cz) smtp.mailfrom=dsterba@suse.cz X-Rspamd-Server: rspamd2 X-Spamd-Result: default: False [16.14 / 50.00]; HAS_REPLYTO(0.30)[dsterba@suse.cz]; RCVD_VIA_SMTP_AUTH(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:98:from]; TO_DN_SOME(0.00)[]; REPLYTO_ADDR_EQ_FROM(0.00)[]; R_SPF_SOFTFAIL(4.60)[~all]; RCVD_COUNT_THREE(0.00)[3]; MX_GOOD(-0.01)[]; RCPT_COUNT_SEVEN(0.00)[9]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(2.20)[]; MIME_TRACE(0.00)[0:+]; MID_RHS_MATCH_FROM(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(1.20)[suse.cz]; NEURAL_SPAM_SHORT(2.95)[0.983]; NEURAL_SPAM_LONG(3.50)[1.000]; FUZZY_BLOCKED(0.00)[rspamd.com]; FREEMAIL_CC(0.00)[fb.com,toxicpanda.com,suse.com,gmail.com,googlemail.com,vger.kernel.org,googlegroups.com]; RCVD_TLS_ALL(0.00)[]; SUSPICIOUS_RECIPS(1.50)[] X-Rspamd-Queue-Id: E49C721C1C Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 24, 2023 at 05:48:31PM +0100, Jann Horn wrote: > kernel_write() requires the caller to ensure that the file is writable. > Let's do that directly after looking up the ->send_fd. > > (We don't need a separate bailout path because the "out" path already > does fput() if ->send_filp is non-NULL.) > > This has no security impact for two reasons: > > - the ioctl requires CAP_SYS_ADMIN > - __kernel_write() bails out on read-only files - but only since 5.8, > see commit a01ac27be472 ("fs: check FMODE_WRITE in __kernel_write") > > Reported-and-tested-by: syzbot+12e098239d20385264d3@syzkaller.appspotmail.com > Closes: https://syzkaller.appspot.com/bug?extid=12e098239d20385264d3 > Fixes: 31db9f7c23fb ("Btrfs: introduce BTRFS_IOC_SEND for btrfs send/receive") > Cc: stable@vger.kernel.org > Signed-off-by: Jann Horn Added to misc-next, thanks.