Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp914152rdb; Sat, 7 Oct 2023 04:34:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFXO/m/XVi1gh7Y7KE7NK67o3mIxmfDCTmuHP8xDQTTUCKk92Z/y2RxQNIlohhpXaTuTCXb X-Received: by 2002:a17:902:d352:b0:1c6:de6:5eb4 with SMTP id l18-20020a170902d35200b001c60de65eb4mr8651800plk.13.1696678488543; Sat, 07 Oct 2023 04:34:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696678488; cv=none; d=google.com; s=arc-20160816; b=OvRhVKswFQBaMotRYC9QvYhhDHJb7BX+sBG9lheOAxhiDJ0TqK87xL9B4LkqLK4gcd T4g6WOEFttl0dn2BeA+ZlaGFZAxhmtSp5Q/up92R41BrrRZmMXBqiEXK3pSwLlewT3jy CkdffA3CBl7a1gxnrMSU6lkOGEoFO/g/mBtVKVfPnEbqOc/xsWOMMA2t12CVDZrZzZ1u Nb6pV+D0jU5BT9Khca/BLRACEsXBWRFc6kNewklPUQojx2I4gOCzkDsD2hRzPcB55vie +o7W0D68a2XkYNYzRAqUCfiyCLC2m/AkvdLIwdDbbfQ7iXM15d/Wch++UT6cG7tbT0qA qfeg== 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=G+by8RcLA+dS9xjWR5WO1qwVXkDdY4wQRTadK1A2YtQ=; fh=fytwr9ESODMVyAkXF0er5FFqDPp8gbQuw0ga+WKaA9k=; b=DNYDUmYe4cTMFIBHLI73fYlNutxYj+uxaV5HglCyE1uOPdu1KJwuqSjJoy5AF820/U A18+Cqb63pESz1imRaTOAAW2zfuap7kbKmZy8u4TDVJlhLdl+Ceos8SdS5rmATYPR2cy TPVlvqD/88I+MMt4N28QqVPDY8vFxOvgY9Xs68UPvtx/jORGaibow8KPaoK3/r2qrzZj le3LTMWQp8ULuHZW5bR6wj09ZaLBxx9+fkxvf6evgQr8OWI7kw34k2JCGZPNZTrvxXMl PIZc9HhUKpu6YKmvyQPEwiOfwtw49VL/lj040lDAtedAKe5k8fQW18dgkNmQhQEm/nsi rEiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="dEVzae/V"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id m11-20020a170902c44b00b001b6788a54f4si5390067plm.191.2023.10.07.04.34.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Oct 2023 04:34:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="dEVzae/V"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 1692D8047847; Sat, 7 Oct 2023 04:34:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343868AbjJGLeb (ORCPT + 99 others); Sat, 7 Oct 2023 07:34:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233662AbjJGLea (ORCPT ); Sat, 7 Oct 2023 07:34:30 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 352A8BF for ; Sat, 7 Oct 2023 04:34:29 -0700 (PDT) Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 397BTPRU006713; Sat, 7 Oct 2023 11:34:11 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=G+by8RcLA+dS9xjWR5WO1qwVXkDdY4wQRTadK1A2YtQ=; b=dEVzae/VUoiiQrgG5ROXwrEcSaqUzZK+gyUqI1heJFN5fVF2D/MQZn/ptaajkJBGBVFA 27WhilrZitRAojdJ1y40VtNfruekbeCjGQ885UQyGjEMKrhQAXbiM6bc1g++YVF0rXZV ze0Jkp7nWMRHFRNRhXrEVUvIO9CTpNRkRgQO60ge+UPpKHt7FEp0bxfYJ7cEFWepgJzM +yJKtj69XsTcSbuWA+6foRdnQKlxqSvvrgJB092Nip/T3+R+hmtHtAjIuosHuMTWQ2Di Blcw6j0mm4SK4xJjwdTDcKxaFpofq7NyuW4gzfRSf9c47eSONz2D2MVISRfV7zM0oJQR cQ== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3tk03q0kkj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 07 Oct 2023 11:34:11 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 397BYAaV006816 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 7 Oct 2023 11:34:10 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:34:07 -0700 Message-ID: <12642deb-0db3-9210-b468-1872cd3d5409@quicinc.com> Date: Sat, 7 Oct 2023 19:34:05 +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> From: Kassey Li In-Reply-To: <2023100725-oversized-shore-c873@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: oKVpFQwegheiCvwgBYvYCh1lz8k7Ezyb X-Proofpoint-GUID: oKVpFQwegheiCvwgBYvYCh1lz8k7Ezyb 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 clxscore=1015 spamscore=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 mlxlogscore=661 adultscore=0 suspectscore=0 phishscore=0 mlxscore=0 impostorscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310070103 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 fry.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 (fry.vger.email [0.0.0.0]); Sat, 07 Oct 2023 04:34:44 -0700 (PDT) X-Spam-Level: ** 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. Fixes: 19c987241ca1 ("binder: separate out binder_alloc functions") Fixes: f2517eb76f1f ("android: binder: Add global lru shrinker to binder") Signed-off-by: Kassey Li > > thanks, > > greg k-h