Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp201564pxb; Mon, 16 Aug 2021 03:34:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgdlDtP3MNhaMCTotor/pdPsTauMJd0jS9k8v63PZvEOkwSlhuVNfosYFrrzg6T5SYBphH X-Received: by 2002:a17:906:144e:: with SMTP id q14mr15462146ejc.19.1629110093831; Mon, 16 Aug 2021 03:34:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629110093; cv=none; d=google.com; s=arc-20160816; b=JvAzK0osryMVmU5OGqJ51hQTTs6vM2C5KpllCHv2IsxDR51uY38pR+meVcS/uzux/m u3yiLIFY03qup/sWYT+4Of1rAv9XPp4VNL1S+8Wk8S0w/kC5S5vQF0jBfuXOX95pOLko uZSx+WyjnWV+tZ32gsCQzssbYo16JsfBsrSlqBRUMdL+7ge9TNhMHY9ZQfgSGJfJ11Ib 3FosaG93UkszXf7AckJyLZAefJCQazr9XGrdbABmAyVIYtRPf9+0iQgOVe0V9+HPpsG2 7vvdahGixPTCm4JPbDUGslX2yPXKkC1QYxXn9/Ea8x5vQvBDe1H71WCLIhcD+o4Nn+me IzOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=ccX+otJKzYiw7fTpASq5EiKmXI5wu1oM2Rkshyanugg=; b=OZ/k7aWv5C1rseqrOTgu2ncGDsiI4fmpXnYrq3NDhZ6z+s2Dtepbfi1R2UPuQIREQf 7GlOLlOrDZpZ1bJlrBX30U4FIZ+4njH7qKbYrbXSUiSn/rlb2muWnrOT1azobJ32AMfW YVPiarfxHq4VX6jPtb1PIYoN9oLlf1WwLBjXHA4iZ6oJRr4HwnE9Hrlwcess6F/KlzRl sygIoU+W8/krD0VD3YDkx8cZ8QTesBgUGRXiek62aEO4vBcNL1le7lrl46fchlvD4i7Q OfEeHeLbsgDUS1JlwhX/v/tBh+iATVZAYGhwNV2QZzMn3dswSO1aGXhFxKoeNVEOG820 qmOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nyTjql4k; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d22si11951855ejj.387.2021.08.16.03.34.30; Mon, 16 Aug 2021 03:34:53 -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=@gmail.com header.s=20161025 header.b=nyTjql4k; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235784AbhHPKc0 (ORCPT + 99 others); Mon, 16 Aug 2021 06:32:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235837AbhHPKcB (ORCPT ); Mon, 16 Aug 2021 06:32:01 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25F6DC0617AE for ; Mon, 16 Aug 2021 03:31:29 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id j1so25735773pjv.3 for ; Mon, 16 Aug 2021 03:31:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=ccX+otJKzYiw7fTpASq5EiKmXI5wu1oM2Rkshyanugg=; b=nyTjql4kPU5b2tlliqQClzMia17+fqOan4LwezfDCn5/sGGbjPNeN6UdQ602MiLmVS yRdL5HwSNqxX3TLwsbGgi1lkq5yoZapTrurxpvYwULnFJ+gBBw23X3lri9m096BgDT// IKposJALqA9eUslVUf0jlBwS/RXtBzOUApWV+mV6x54TX3w2wIDBL8y/bixUv3TDGLkh ighUtLEpkT1PzcFgJuxUHLVrwA0kmYRY/yFPoIiNLH35qyj6sNMT+0/CWqALrtkrCkUF PoqiSd/WVIQT+61eYpyy7yVLmNbqV346PvlJ1Y3xjC52QVqGblfnU+7olmsm/vtjEadr qy6g== 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=ccX+otJKzYiw7fTpASq5EiKmXI5wu1oM2Rkshyanugg=; b=R7ru4PnB8hgt2vOfTfM8D9qM4V/ZbkrqJWEh33+5M/qk45DXgmMTYTN830X0+FCZd4 E91v27Q0KZ/cU58Z6oVDZhCx++sWnRgVqsomG/aU++vMBd+moPoyk3mNzF/TKRVejBe2 +j/uKR8ueo5NptZBVd4iON0Joe8QaQ3F9zheu3qytMKtdhUADITnYPU+qpVDIUG3BYVy yBxEue6iTY+zbDmxvO7EKqfiYzqIOdQEM7Kv3oPKoVlcFJJS9r1qKhdxVQ3qJyK0C/oh 36G3yiKulTsDi9yyswwQEhcaqx5/Y+5PkJhSzdSaEI/UFVAMO/jaYhlVSbIs5z6mRWnP OQdw== X-Gm-Message-State: AOAM532Rc1L7M0R2bQNVaR4QubOOuVnTWz5Gcl9p//5uQdwc/T1fA6Km C0kbypXPoimZYFYNxeSdJZc= X-Received: by 2002:a63:111f:: with SMTP id g31mr15459522pgl.80.1629109888650; Mon, 16 Aug 2021 03:31:28 -0700 (PDT) Received: from [192.168.1.237] ([118.200.190.93]) by smtp.gmail.com with ESMTPSA id f137sm10813481pfa.160.2021.08.16.03.31.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 16 Aug 2021 03:31:28 -0700 (PDT) Subject: Re: [PATCH v2] drm: avoid races with modesetting rights To: Daniel Vetter Cc: kernel test robot , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Dave Airlie , kbuild-all@lists.01.org, dri-devel , Linux Kernel Mailing List , intel-gfx , Shuah Khan References: <20210815153740.195330-1-desmondcheongzx@gmail.com> <202108160208.ONHHWxXy-lkp@intel.com> From: Desmond Cheong Zhi Xi Message-ID: <3a5ffd83-3d91-73dc-0cae-e822ba381b2b@gmail.com> Date: Mon, 16 Aug 2021 18:31:23 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16/8/21 5:04 pm, Daniel Vetter wrote: > On Mon, Aug 16, 2021 at 10:53 AM Desmond Cheong Zhi Xi > wrote: >> On 16/8/21 2:47 am, kernel test robot wrote: >>> Hi Desmond, >>> >>> Thank you for the patch! Yet something to improve: >>> >>> [auto build test ERROR on next-20210813] >>> [also build test ERROR on v5.14-rc5] >>> [cannot apply to linus/master v5.14-rc5 v5.14-rc4 v5.14-rc3] >>> [If your patch is applied to the wrong git tree, kindly drop us a note. >>> And when submitting patch, we suggest to use '--base' as documented in >>> https://git-scm.com/docs/git-format-patch] >>> >>> url: https://github.com/0day-ci/linux/commits/Desmond-Cheong-Zhi-Xi/drm-avoid-races-with-modesetting-rights/20210815-234145 >>> base: 4b358aabb93a2c654cd1dcab1a25a589f6e2b153 >>> config: i386-randconfig-a004-20210815 (attached as .config) >>> compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 >>> reproduce (this is a W=1 build): >>> # https://github.com/0day-ci/linux/commit/cf6d8354b7d7953cd866fad004cbb189adfa074f >>> git remote add linux-review https://github.com/0day-ci/linux >>> git fetch --no-tags linux-review Desmond-Cheong-Zhi-Xi/drm-avoid-races-with-modesetting-rights/20210815-234145 >>> git checkout cf6d8354b7d7953cd866fad004cbb189adfa074f >>> # save the attached .config to linux build tree >>> make W=1 ARCH=i386 >>> >>> If you fix the issue, kindly add following tag as appropriate >>> Reported-by: kernel test robot >>> >>> All errors (new ones prefixed by >>, old ones prefixed by <<): >>> >>>>> ERROR: modpost: "task_work_add" [drivers/gpu/drm/drm.ko] undefined! >>> >> >> I'm a bit uncertain about this. Looking into the .config used, this >> error seems to happen because task_work_add isn't an exported symbol, >> but DRM is being compiled as a loadable kernel module (CONFIG_DRM=m). >> >> One way to deal with this is to export the symbol, but there was a >> proposed patch to do this a few months back that wasn't picked up [1], >> so I'm not sure what to make of this. >> >> I'll export the symbol as part of a v3 series, and check in with the >> task-work maintainers. >> >> Link: >> https://lore.kernel.org/lkml/20210127150029.13766-3-joshi.k@samsung.com/ [1] > > Yeah that sounds best. I have two more thoughts on the patch: > - drm_master_flush isn't used by any modules outside of drm.ko, so we > can unexport it and drop the kerneldoc (the comment is still good). > These kind of internal functions have their declaration in > drm-internal.h - there's already a few there from drm_auth.c > Sounds good, I'll do that and move the declaration from drm_auth.h to drm_internal.h. > - We know have 3 locks for master state, that feels a bit like > overkill. The spinlock I think we need to keep due to lock inversions, > but the master_mutex and master_rwsem look like we should be able to > merge them? I.e. anywhere we currently grab the master_mutex we could > instead grab the rwsem in either write mode (when we change stuff) or > read mode (when we just check, like in master_internal_acquire). > > Thoughts? > -Daniel > Using rwsem in the places where we currently hold the mutex seems pretty doable. There are some tricky bits once we add rwsem read locks to the ioctl handler. Some ioctl functions like drm_authmagic need a write lock. In this particular case, it might make sense to break master_mutex down into finer-grained locks, since the function doesn't change master permissions. It just needs to prevent concurrent writes to the drm_master.magic_map idr. For other ioctls, I'll take a closer look on a case-by-case basis. >> >>> --- >>> 0-DAY CI Kernel Test Service, Intel Corporation >>> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org >>> >> > >