Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp427371ybh; Wed, 15 Jul 2020 05:53:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdn7R4KqtjFnNyltyceGIdU8FW3Cehg9/vSD9i2HzXtp2o9dbxQisgYoWVWO2fds7HOTMF X-Received: by 2002:a17:906:4bc1:: with SMTP id x1mr8861385ejv.377.1594817631050; Wed, 15 Jul 2020 05:53:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594817631; cv=none; d=google.com; s=arc-20160816; b=Y5zFGRJZVQQeBWOjb6G5Jk8kaY1LDQFBfHTjY3rqM79864IPvIZYBp2lvyBoff/EpP bDWGPhfH5BRycpZSb3OFY9c4SOXEvHYxuW7IQqVDLMPRXx3NHowKVxuGJi9NQLGwMyLE Zeg6IRuPibrOyJ4YEWPtamEjBSdJ7h7lxEt8kD3pzJo7FzRHcV9BBOMI5yE/JakJXPzW SRizZ8711OKdcV1+tRb+bEf0Lmk9qIzuU3p4EMOSMIy2qwbAXlAJzbVIFULHsXDjhSY1 5TlI+QofnYO15efc2gLCt0yeK6l9VgkUIyzwemRfKsdmhISZE75J6rG7dAENYtrEL5k6 GBxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:to:date:from:dkim-signature; bh=ShVGtDM5xerpslVq+QO4NAQXlRlUc1FZogmGfNpoutY=; b=EOE648TInMrV41o9M/KLlywCTypTl/A7p1UWJ+UkdjD/SdcvsG31h/nB09Yo6+TT5f 3VFj886s0bc1yF+sgZpNmZVnNjjBkIgr0Ux+rD2a1eky8YlGz3QSp8SAsv1Cg1G9DawK 3uAnXR9ZFGZa7jzc+YeLNwwkE1zovqz9iJ9CB/IzYE8BSAidkFwwRFZ4vI45L9zHjWJJ Rb4aie7dmIHYSSpLRhcTEzOPOGcB3Zy7U/p2owxzskfoWlO4ATIh2j0s00DK/iTvHlKw p5uaGhBS4shTQl15wyAha9NKFVX3Ke4K9xiKNb5rY6w4W9MS2l6Abj0Wb+MmoPTffRYl AqQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pesu-pes-edu.20150623.gappssmtp.com header.s=20150623 header.b=zfEz8H5E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=pes.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dk28si1150394edb.425.2020.07.15.05.53.27; Wed, 15 Jul 2020 05:53:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@pesu-pes-edu.20150623.gappssmtp.com header.s=20150623 header.b=zfEz8H5E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=pes.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730980AbgGOMu1 (ORCPT + 99 others); Wed, 15 Jul 2020 08:50:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728766AbgGOMu1 (ORCPT ); Wed, 15 Jul 2020 08:50:27 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 012A2C061755 for ; Wed, 15 Jul 2020 05:50:27 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id m9so2065800pfh.0 for ; Wed, 15 Jul 2020 05:50:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pesu-pes-edu.20150623.gappssmtp.com; s=20150623; h=from:date:to:subject:message-id:mime-version:content-disposition :user-agent; bh=ShVGtDM5xerpslVq+QO4NAQXlRlUc1FZogmGfNpoutY=; b=zfEz8H5E0uTrtiedmvrlTGbHtdxGX3RrMjMgJxif+xhNGImqKZRwVnxOB7SiJiHGZb EgfDXwV6eV0eYsRRBkuQtDnVaC/gA32Wm8PgvRC0S/grBe3RSNr07Qwb/U5MFJQCd+xu ZzRH0TwSYyHM7F+ByWaX4y+/lwLlfZropXcAtw4OEd6s5YhRov92z0a99VRfYJAAhfNf bZtJoVQi9SqMDg0zgDRRi4WZCRBAeTXicGV743fdg5EHoHEDZibVOgCS65ZUQ9HcWhdA loHkMsrB0ViJIeLN9ArV7hzmoxVeMMuJFVT9NdQFZG26b8lb2eJfYno6GYBY0w3mG5Fw aObg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:subject:message-id:mime-version :content-disposition:user-agent; bh=ShVGtDM5xerpslVq+QO4NAQXlRlUc1FZogmGfNpoutY=; b=R4PvkTf5Xror0VUwfQR/Ep+asa/1D0mGreNQ+AfyVZ/3iydCd3kJcRJ75HMf8/JCl5 ipynfFsSSyIo8M8mHdg2tWtziTa9+rriJzjsftX/eF6Nq7s+5Pv1nUfWwf7Sig6deaUk DgVwvUDkHEKxZDovXHjgFC4ReexwxPpFNpIiDI1NXvM6K8e45VbpetqKKljPG1477oVO zCpb49BbV/0uX1DYytsVPx3S9BFFnmYauPdDYXh41/3FQ60euiDtXa/Ut7sUxOI7XnYt F6nPO0hqfEQVZ/IP2+bdV6eToVZ/06s9cVcBodA1cRHCLtXMGevjiraDGadbg1k+j2Fi NYsA== X-Gm-Message-State: AOAM531hwnE3MkLF4I2vtfTV5DoQUM0U4qwpxndQD+1PWbvSqfpMlrNv oa15zWWbm9DZWf1SEzdBgmBWRkv4yCM= X-Received: by 2002:a63:1f11:: with SMTP id f17mr7755201pgf.217.1594817426552; Wed, 15 Jul 2020 05:50:26 -0700 (PDT) Received: from localhost ([2406:7400:73:f0a7:1936:cfd2:c2df:5e48]) by smtp.gmail.com with ESMTPSA id ml8sm2037189pjb.47.2020.07.15.05.50.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2020 05:50:25 -0700 (PDT) From: B K Karthik X-Google-Original-From: B K Karthik Date: Wed, 15 Jul 2020 08:50:18 -0400 To: Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] fs: block_dev.c: fix WARNING in submit_bio_check Message-ID: <20200715125018.mjj6sj5uibd5s67b@pesu-pes-edu> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="lpn6rsynz3x3gxmk" Content-Disposition: inline User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --lpn6rsynz3x3gxmk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable duplicating the logic in blkdev_get_by_path to blkdev_get_by_dev to avoid a user-triggerable WARN trying to write to a read-only block device. blkdev_get_by_path() looks at ((mode & FMODE_WRITE) && bdev_read_only(bdev)) to check for write permissio= ns. A user-triggerable WARN can be avoided by doing the same with bdev_get_by_d= ev. Reported-by: syzbot+4c50ac32e5b10e4133e1@syzkaller.appspotmail.com Signed-off-by: B K Karthik --- fs/block_dev.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/block_dev.c b/fs/block_dev.c index 64c4fe8181f2..472e3b046406 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -1796,6 +1796,11 @@ struct block_device *blkdev_get_by_dev(dev_t dev, fm= ode_t mode, void *holder) if (err) return ERR_PTR(err); =20 + if ((mode & FMODE_WRITE) && bdev_read_only(bdev)) { + blkdev_put(bdev, mode); + return ERR_PTR(-EACCES); + } + return bdev; } EXPORT_SYMBOL(blkdev_get_by_dev); --=20 2.20.1 --lpn6rsynz3x3gxmk Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAEBCgAdFiEEpIrzAt4LvWLJmKjp471Q5AHeZ2oFAl8O+4kACgkQ471Q5AHe Z2rFSwv/eUXmS0JEAwk4ovaLtuu9ly240wFQQBHwIyOidIuxiw0fnOKPfRpBFCHc NDdVlZ3/IDfRbcT/5Td3wO+X4OmWPoE/mr2EClOxeYWFCcJV7oWzO+FBkkYb7P93 JmzuDtIYMsSVnIrAyjlwwCdlii0nW2eism0rIP2Ja30FsAvZR5l1pqw8ypjFpKrQ tGot98tkBA5iAm5A2F/8iBpwX+kp/y5kEzXpfH8qgrslt3booQ4FLFcg+TCOeIaj G1vPkY0fuVCsQZPXSta6RU89NI71AQKN5FhyujqpNa1hIiA5IYT4+c9ryRwzuJIr fzLFygwWbFXLXtvgZ87BlhkSIayJMQNFUBrjA36BB0iN83fRyKr69K0i8BbG5QKU FP/zryOsnO2AdbtBpB8OCPXq5era+hbeZnXncBzl9h9ApatmRWajO4D0mOXQRd7a njx23nf5npJtjXeHmznhi+luoAeeLkK+te0hvGl2fmFhT/v7Zt8xa7D4bMnC18eh ZkaRfIHq =Pl6p -----END PGP SIGNATURE----- --lpn6rsynz3x3gxmk--