Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp917514rdb; Sat, 7 Oct 2023 04:44:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHchb9cmespMavA5EwUP9LY4BUYKAP02AiLw21Amu5Q0FbPzkUU/JgbkGdkEyYJVCgzCcAS X-Received: by 2002:a05:6a20:8e12:b0:161:28dd:c09d with SMTP id y18-20020a056a208e1200b0016128ddc09dmr13256302pzj.15.1696679064598; Sat, 07 Oct 2023 04:44:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696679064; cv=none; d=google.com; s=arc-20160816; b=KhR+vBNAhhObNcXF2kygmlzfpyCGR8cjaZJwxDVL0FU9c7F8joYkYmkc+0UaohTpWP 2PsWGhGvsZkpbn9PyG4l6bg9q6xOpSdQADjG0+G1NEkGhJVA+KD5bG900ipvO1wFK3Am r7cB3ijeNWhIt4fGiqKEgG/e6H35VZCnqp63TjiA6Ux/Aix+7LOsQBR+gcjsj5mYbKqa Khaa5vhQfys4wxuxNk+MBzLPcJgoz5K6gyAEbqW46Xd8uJ5Hqj3r4NI0VXCyhJriV6yX 9Q5KQRRO2bvyCMzO9SLkBJb8SZh5bUAaIXgUul9DEy3jAt4u6vQT4GhZDcwXHQDDh46A jJ3g== 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 :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=Q6BWe4Lq7MY1NQBuGsJNqri+3KXC6PSmR18VQrasxTM=; fh=fytwr9ESODMVyAkXF0er5FFqDPp8gbQuw0ga+WKaA9k=; b=Au9K44Tjluw2ZVdfpmQr9AqjIflmhk+dOwjxE/YPZcHBgXNrYJOtK+ZER1guvpMNYu ziZzpM9h0bkaKsmk9m9SMZhMvGUqJWVuBROn6uivobqinJ4zv4r/cYh/IF+O8gOAetY0 csg5oHxNaZWI4zHCMUtr4Xisf57W4qqyRSCbshFOiYjtW4DJ5wgxcobnryk6Nlgaw0yR TwutEcqBcl5PEHoDawHQcBV3bc5UASj1sMINigL+1oK2KQg0haNZTlwX8OD5QfmuLKHe 3eAfmNXPkSuWcj9rxe61Y2PxeFBdAk16Jx3yigsLZfxvwwS9R8egJAc7kdr8EY8aMXW5 9CFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=dByDsoFa; 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=quicinc.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id cj27-20020a056a00299b00b00690cb77d5e5si3354592pfb.394.2023.10.07.04.44.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Oct 2023 04:44:24 -0700 (PDT) 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=@quicinc.com header.s=qcppdkim1 header.b=dByDsoFa; 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=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id DB483803B50E; Sat, 7 Oct 2023 04:44:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343875AbjJGLoF (ORCPT + 99 others); Sat, 7 Oct 2023 07:44:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343837AbjJGLoE (ORCPT ); Sat, 7 Oct 2023 07:44:04 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74108B9 for ; Sat, 7 Oct 2023 04:44:03 -0700 (PDT) Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 397Bhu12009405; Sat, 7 Oct 2023 11:43:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=qcppdkim1; bh=Q6BWe4Lq7MY1NQBuGsJNqri+3KXC6PSmR18VQrasxTM=; b=dByDsoFar/u7gP7jRUC4e9O3XQi2PWQFkqS95xCvwOA8/PNs5su4J2T9D8cTVD0TF8mP WeMyL+lN9U8Hvjj7rGlMQVXvXHiGnYIgQYblkDW08XqCBUDyMBHuRewW7ATpHLSaOAmN ZXtPSwRhDdWbbnvnA0SwXArryUE2u5a74vJaFyeAbOjCJDZGr0oOWJsUSk0F5TAyrjNO lqqEMQsEd3AwWcQLKfEp0b/2yCwisZ7oDI0cxemwGGxAt6YGwefu+n2JZzXbqYGObb3J 2pKhZ5fYWcV+hOylLb2LOm2BkblE0XdPK9qHFJve0Hmi1ESm2yJQCO0CCVx99W4VtRrs hw== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3tjxbhrsse-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 07 Oct 2023 11:43:56 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 397BhtWH027023 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 7 Oct 2023 11:43:55 GMT Received: from [10.232.65.248] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.36; Sat, 7 Oct 2023 04:43:52 -0700 Message-ID: Date: Sat, 7 Oct 2023 19:43:50 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.0.3 Subject: Re: [PATCH] binder: add mutex_lock for mmap and NULL when free Content-Language: en-US To: Greg KH CC: , , , , , , , , References: <20231007034046.2352124-1-quic_yingangl@quicinc.com> <2023100715-blade-valiant-714d@gregkh> <26988068-8c9f-8591-db6e-44c8105af638@quicinc.com> <2023100725-oversized-shore-c873@gregkh> <12642deb-0db3-9210-b468-1872cd3d5409@quicinc.com> <2023100735-dullness-cameo-2666@gregkh> From: Kassey Li In-Reply-To: <2023100735-dullness-cameo-2666@gregkh> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: R-0ksveWcJlr13aq86rhpEudyezGF9M9 X-Proofpoint-GUID: R-0ksveWcJlr13aq86rhpEudyezGF9M9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-07_09,2023-10-06_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=711 priorityscore=1501 mlxscore=0 spamscore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 suspectscore=0 clxscore=1015 phishscore=0 impostorscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310070104 X-Spam-Status: No, score=2.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no 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]); Sat, 07 Oct 2023 04:44:22 -0700 (PDT) X-Spam-Level: ** On 2023/10/7 19:37, Greg KH wrote: > On Sat, Oct 07, 2023 at 07:34:05PM +0800, Kassey Li wrote: >> >> >> On 2023/10/7 19:18, Greg KH wrote: >>> On Sat, Oct 07, 2023 at 07:07:40PM +0800, Kassey Li wrote: >>>> >>>> >>>> On 2023/10/7 14:44, Greg KH wrote: >>>>> On Sat, Oct 07, 2023 at 11:40:46AM +0800, Kassey Li wrote: >>>>>> Enforce alloc->mutex in binder_alloc_mmap_handler when add >>>>>> the entry to list. >>>>>> >>>>>> Assign the freed pages/page_ptr to NULL to catch possible >>>>>> use after free with NULL pointer access. >>>>>> >>>>>> Signed-off-by: Kassey Li >>>>>> --- >>>>>> drivers/android/binder_alloc.c | 5 ++++- >>>>>> 1 file changed, 4 insertions(+), 1 deletion(-) >>>>> >>>>> What commit id does this fix? >>>> >>>> there is no specific commit id this change going to fix. >>>> >>>> it is a follow up for commit >>>> 19c987241ca1216a51118b2bd0185b8bc5081783 binder: separate out binder_alloc >>>> functions (mutex lock added for list access in alloc/free) >>>> f2517eb76f1f2f7f89761f9db2b202e89931738c android: binder: Add global lru >>>> shrinker to binder (set page->page_ptr = NULL;) >>>> >>>> the background to raise this change that we are easy hit below crash in >>>> monkey test: >>>> >>>> where a wrong end is passing to >>>> binder_update_page_range, thus calculate a weird index >>>> for >>>> page = &alloc->pages[index] >>> >>> Obviously it is a fix for some commit, please list that here. >> >> ok, please kindly review this patch description according your suggest, i >> can re-send v2 patch again. >> >> commit 16aaeb8556ff4eb75823c56773ee82b06bac44a0 (HEAD -> master) >> Author: Kassey Li >> Date: Thu Sep 28 10:42:52 2023 +0800 >> >> binder: add mutex_lock for mmap and NULL when free >> >> -Enforce alloc->mutex in binder_alloc_mmap_handler when add >> the entry to list. >> >> -Assign the freed pages/page_ptr to NULL to catch possible >> use after free with NULL pointer access. > > Odd indentation :( thanks for the quick suggest and review, based on this version, will do below and send patch v2. ./scripts/checkpatch.pl 0001-binder-add-mutex_lock-for-mmap-and-NULL-when-free.patch total: 0 errors, 0 warnings, 26 lines checked 0001-binder-add-mutex_lock-for-mmap-and-NULL-when-free.patch has no obvious style problems and is ready for submission. > >> Fixes: 19c987241ca1 ("binder: separate out binder_alloc functions") >> Fixes: f2517eb76f1f ("android: binder: Add global lru shrinker to >> binder") >> Signed-off-by: Kassey Li > > Looks better than before, thanks. > > greg k-h