Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3018524rdb; Wed, 15 Nov 2023 19:07:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IH1Jp03L31HQw/f9FRWq6ULlt+mD7vAzHcY2h++kCQql4jBk3BU4R/jdDXPjPBGkdyr4lDO X-Received: by 2002:a17:902:9894:b0:1cc:e66:3732 with SMTP id s20-20020a170902989400b001cc0e663732mr7676730plp.19.1700104054728; Wed, 15 Nov 2023 19:07:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700104054; cv=none; d=google.com; s=arc-20160816; b=RQ51+/irzZ43zKqkt953M6PDHpDz5uh4zsM6l8rvFymRSsCyqldIi1HoXvsnkm+0K+ P5UB8hJGnKmfgKRh0keCQdc2gFNCDE3Be/sLgDMMzIu+wIqxq+ijO0RXFxsqK5hL0+qs P+s4NIgUl2PnjSJubufrw/NCkdU8JbFuQsERtZGrzsF0jW5ybp9fkOo27nPFmyAWg7CE YjyjKQYGzQSMbyhIvMxQS3SdsIgzeMayZdaZjnYCO3ob8wY5j7UNvWofxKU24VGxix7B xxgIFwrwp2I8STqfXo7kmDcIJ89bteV0NrSvoEj3d70xuRpOwUex6sIgN5KaDiUJkB3z QGMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=m0gSEf7JiRv42BybUzT0POwhSlpfuDNjghSiOqfLdfM=; fh=AGRvPI2GY4ebPzpB+lB4+mNTDBQLR+vaSi7p9vM6bQQ=; b=EVxzOjm8n/igEcbDFuEw4VndLdDxFF7xx5t8XZdWq/yVZs6iKt5lTjgt8Xz3LHsA1r EOHpey9ZTl2tqrGnEIqOv2JANB2G+6VnCfijABNBPRMlot3dA0E6eEYw69PtYVjrbF2R tX/7nSN2naLjJsOvUqIaumxRAqp+yw94XvHMZR2GyCwhh5GcI9keawv+hUeHdj1odzDG vsPyHiKK6gJte/NLPf3EoeiAy8EUKp9tdnMSbR3IZRRhd2keWaZnsHB9+Bd2RC0WtKBv y3bfrKr0/HunYW4uj9cmO2SiDL68LWBQQyX4IkgqXr5QOjMbRi7tcs5MYyx823K2pqF9 gLbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KsxV6tlc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id i4-20020a170902c94400b001c9ff461649si11585301pla.581.2023.11.15.19.07.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 19:07:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KsxV6tlc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 1C1B5802B173; Wed, 15 Nov 2023 19:07:32 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344462AbjKPDHF (ORCPT + 99 others); Wed, 15 Nov 2023 22:07:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229692AbjKPDHE (ORCPT ); Wed, 15 Nov 2023 22:07:04 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB75FBD for ; Wed, 15 Nov 2023 19:07:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700104019; h=from:from:reply-to:subject:subject: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=m0gSEf7JiRv42BybUzT0POwhSlpfuDNjghSiOqfLdfM=; b=KsxV6tlcKM+07/hn/yKn450ue1V3KKcGU7nsXIWhIi4KodlxT8aea5TNx3kTPawZYJunqA g2qaMW83Ng7ZGrWAke3Mb9EVn5IWAzoVf3WtMJoFh6qL3blKUS7FD0OiqxjlA0b0j7FAFN 9jziQMfSbqQQ/cBHcTDL1AhlO+CwT8g= Received: from mail-oo1-f69.google.com (mail-oo1-f69.google.com [209.85.161.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-546-ugDTUKtaO0WSKMd6eXEpEg-1; Wed, 15 Nov 2023 22:06:58 -0500 X-MC-Unique: ugDTUKtaO0WSKMd6eXEpEg-1 Received: by mail-oo1-f69.google.com with SMTP id 006d021491bc7-58a8142a7a7so324789eaf.3 for ; Wed, 15 Nov 2023 19:06:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700104018; x=1700708818; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=m0gSEf7JiRv42BybUzT0POwhSlpfuDNjghSiOqfLdfM=; b=hpdw8V/m/LqENsD3ndb83wj8la5U+nni5ojxg82UILFkHw4T00ZGGYHkUW082tvDJc Km+X3sYlbI0rscvDvT70cmLYM/2wr3SvyJ/yQoe9xeADdar342rHy/FEBwGemfmgynMA 64K+IMgfK6oNJtuc57MtKndUlPROVAUE2YPqspr58WP2dcsReY+NO/UolFXPFLUAFYRu wfhZi9gmlp/W+jFWyG+CFkn1hM3N8rANgK6NQM1ZL0DdbRiSJY1+bGyadV+Kw5bgz+80 vGwZ1MONyyNuk6NnnFAD7e2QahtYYJgEwqTUmXjrSoYhS05kK2S+JiCJczssJTTXwUqx Wmvg== X-Gm-Message-State: AOJu0Yw/jOQoR75aMAOmBeC/1g060ZazwGEe/l/SNBlPOcQAuEMkpdwo yth6iWbMaMCMquUaHhH/oY4yQS4M+F0zCeCkOmzzoDNHTUoEL92AQYwEcB5iomCgQnRX5OPMkkS GLQ00iNGZYDi/7Jl7y7cUBtk4 X-Received: by 2002:a05:6870:6b0a:b0:1eb:192b:e75a with SMTP id mt10-20020a0568706b0a00b001eb192be75amr18651331oab.22.1700104017775; Wed, 15 Nov 2023 19:06:57 -0800 (PST) X-Received: by 2002:a05:6870:6b0a:b0:1eb:192b:e75a with SMTP id mt10-20020a0568706b0a00b001eb192be75amr18651319oab.22.1700104017506; Wed, 15 Nov 2023 19:06:57 -0800 (PST) Received: from [10.72.112.63] ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id d15-20020a17090a110f00b0028018af8dc2sm625368pja.23.2023.11.15.19.06.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Nov 2023 19:06:57 -0800 (PST) Message-ID: <6824ece2-33ee-63f4-2c7a-7033556325cb@redhat.com> Date: Thu, 16 Nov 2023 11:06:52 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] ceph: quota: Fix invalid pointer access in To: Wenchao Hao , Ilya Dryomov Cc: Jeff Layton , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, louhongxiang@huawei.com References: <20231114153108.1932884-1-haowenchao2@huawei.com> <5a1766c6-d923-a4e5-c5be-15b953372ef5@redhat.com> <5eb54f3e-3438-ba47-3d43-baf6b27aad0e@huawei.com> Content-Language: en-US From: Xiubo Li In-Reply-To: <5eb54f3e-3438-ba47-3d43-baf6b27aad0e@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,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 groat.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 (groat.vger.email [0.0.0.0]); Wed, 15 Nov 2023 19:07:32 -0800 (PST) On 11/16/23 10:54, Wenchao Hao wrote: > On 2023/11/15 21:34, Xiubo Li wrote: >> >> On 11/15/23 21:25, Ilya Dryomov wrote: >>> On Wed, Nov 15, 2023 at 2:17 PM Xiubo Li wrote: >>>> >>>> On 11/15/23 20:32, Ilya Dryomov wrote: >>>>> On Wed, Nov 15, 2023 at 1:35 AM Xiubo Li wrote: >>>>>> On 11/14/23 23:31, Wenchao Hao wrote: >>>>>>> This issue is reported by smatch, get_quota_realm() might return >>>>>>> ERR_PTR, so we should using IS_ERR_OR_NULL here to check the return >>>>>>> value. >>>>>>> >>>>>>> Signed-off-by: Wenchao Hao >>>>>>> --- >>>>>>>     fs/ceph/quota.c | 2 +- >>>>>>>     1 file changed, 1 insertion(+), 1 deletion(-) >>>>>>> >>>>>>> diff --git a/fs/ceph/quota.c b/fs/ceph/quota.c >>>>>>> index 9d36c3532de1..c4b2929c6a83 100644 >>>>>>> --- a/fs/ceph/quota.c >>>>>>> +++ b/fs/ceph/quota.c >>>>>>> @@ -495,7 +495,7 @@ bool ceph_quota_update_statfs(struct >>>>>>> ceph_fs_client *fsc, struct kstatfs *buf) >>>>>>>         realm = get_quota_realm(mdsc, d_inode(fsc->sb->s_root), >>>>>>>                                 QUOTA_GET_MAX_BYTES, true); >>>>>>>         up_read(&mdsc->snap_rwsem); >>>>>>> -     if (!realm) >>>>>>> +     if (IS_ERR_OR_NULL(realm)) >>>>>>>                 return false; >>>>>>> >>>>>>> spin_lock(&realm->inodes_with_caps_lock); >>>>>> Good catch. >>>>>> >>>>>> Reviewed-by: Xiubo Li >>>>>> >>>>>> We should CC the stable mail list. >>>>> Hi Xiubo, >>>>> >>>>> What exactly is being fixed here?  get_quota_realm() is called with >>>>> retry=true, which means that no errors can be returned -- EAGAIN, the >>>>> only error that get_quota_realm() can otherwise generate, would be >>>>> handled internally by retrying. >>>> Yeah, that's true. >>>> >>>>> Am I missing something that makes this qualify for stable? >>>> Actually it's just for the smatch check for now. >>>> >>>> IMO we shouldn't depend on the 'retry', just potentially for new >>>> changes >>>> in future could return a ERR_PTR and cause potential bugs. >>> At present, ceph_quota_is_same_realm() also depends on it -- note how >>> old_realm isn't checked for errors at all and new_realm is only checked >>> for EAGAIN there. >>> >>>> If that's not worth to make it for stable, let's remove it. >>> Yes, let's remove it.  Please update the commit message as well, so >>> that it's clear that this is squashing a static checker warning and >>> doesn't actually fix any immediate bug. >> >> WenChao, >> >> Could update the commit comment and send the V2 ? >> > > OK, I would update the commit comment as following: > > This issue is reported by smatch, get_quota_realm() might return > ERR_PTR. It's not a immediate bug because get_quota_realm() is called > with 'retry=true', no errors can be returned. > > While we still should check the return value of get_quota_realm() with > IS_ERR_OR_NULL to avoid potential bugs if get_quota_realm() is changed > to return other ERR_PTR in future. > > What's more, should I change the ceph_quota_is_same_realm() too? > Yeah, please. Let's fix them all. Thanks - Xiubo > Thanks > >> Thanks >> >> - Xiubo >> >> >>> Thanks, >>> >>>                  Ilya >>> >> >