Content-Type: multipart/mixed; boundary="===============3998748111118331478==" MIME-Version: 1.0 From: kernel test robot To: kbuild-all@lists.01.org Subject: Re: [PATCH 3/3] tracing/filter: make filter_pred_pchar() survive the access to user space Date: Sat, 08 Jan 2022 16:20:39 +0800 Message-ID: <202201081659.D34Bri2n-lkp@intel.com> In-Reply-To: <20220107044951.22080-4-kernelfans@gmail.com> List-Id: --===============3998748111118331478== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Hi Pingfan, Thank you for the patch! Yet something to improve: [auto build test ERROR on linux/master] [also build test ERROR on linus/master v5.16-rc8] [cannot apply to rostedt-trace/for-next next-20220107] [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/Pingfan-Liu/tracing-filter= -make-filter_pred_pchar-survive-the-access-to-user-space/20220107-125117 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git = 136057256686de39cc3a07c2e39ef6bc43003ff6 config: i386-randconfig-r014-20220107 (https://download.01.org/0day-ci/arch= ive/20220108/202201081659.D34Bri2n-lkp(a)intel.com/config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 32167b= fe64a4c5dd4eb3f7a58e24f4cba76f5ac2) reproduce (this is a W=3D1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/= make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/0day-ci/linux/commit/61177cfa9fa8f64bc8036d7b1= 8c540b7b78306b0 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Pingfan-Liu/tracing-filter-make-fi= lter_pred_pchar-survive-the-access-to-user-space/20220107-125117 git checkout 61177cfa9fa8f64bc8036d7b18c540b7b78306b0 # save the config file to linux build tree mkdir build_dir COMPILER_INSTALL_PATH=3D$HOME/0day COMPILER=3Dclang make.cross W=3D= 1 O=3Dbuild_dir ARCH=3Di386 SHELL=3D/bin/bash If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All errors (new ones prefixed by >>): >> kernel/trace/trace_events_filter.c:1346:24: error: use of undeclared ide= ntifier 'event_class_syscall_enter' if (data->class =3D=3D &event_class_syscall_ente= r) ^ 1 error generated. vim +/event_class_syscall_enter +1346 kernel/trace/trace_events_filter.c 1170 = 1171 /* Called when a predicate is encountered by predicate_parse() */ 1172 static int parse_pred(const char *str, struct trace_event_call *data, 1173 int pos, struct filter_parse_error *pe, 1174 struct filter_pred **pred_ptr) 1175 { 1176 struct trace_event_call *call =3D data; 1177 struct ftrace_event_field *field; 1178 struct filter_pred *pred =3D NULL; 1179 char num_buf[24]; /* Big enough to hold an address */ 1180 char *field_name; 1181 char q; 1182 u64 val; 1183 int len; 1184 int ret; 1185 int op; 1186 int s; 1187 int i =3D 0; 1188 = 1189 /* First find the field to associate to */ 1190 while (isspace(str[i])) 1191 i++; 1192 s =3D i; 1193 = 1194 while (isalnum(str[i]) || str[i] =3D=3D '_') 1195 i++; 1196 = 1197 len =3D i - s; 1198 = 1199 if (!len) 1200 return -1; 1201 = 1202 field_name =3D kmemdup_nul(str + s, len, GFP_KERNEL); 1203 if (!field_name) 1204 return -ENOMEM; 1205 = 1206 /* Make sure that the field exists */ 1207 = 1208 field =3D trace_find_event_field(call, field_name); 1209 kfree(field_name); 1210 if (!field) { 1211 parse_error(pe, FILT_ERR_FIELD_NOT_FOUND, pos + i); 1212 return -EINVAL; 1213 } 1214 = 1215 while (isspace(str[i])) 1216 i++; 1217 = 1218 /* Make sure this op is supported */ 1219 for (op =3D 0; ops[op]; op++) { 1220 /* This is why '<=3D' must come before '<' in ops[] */ 1221 if (strncmp(str + i, ops[op], strlen(ops[op])) =3D=3D 0) 1222 break; 1223 } 1224 = 1225 if (!ops[op]) { 1226 parse_error(pe, FILT_ERR_INVALID_OP, pos + i); 1227 goto err_free; 1228 } 1229 = 1230 i +=3D strlen(ops[op]); 1231 = 1232 while (isspace(str[i])) 1233 i++; 1234 = 1235 s =3D i; 1236 = 1237 pred =3D kzalloc(sizeof(*pred), GFP_KERNEL); 1238 if (!pred) 1239 return -ENOMEM; 1240 = 1241 pred->field =3D field; 1242 field->uaccess =3D 0; 1243 pred->offset =3D field->offset; 1244 pred->op =3D op; 1245 = 1246 if (ftrace_event_is_function(call)) { 1247 /* 1248 * Perf does things different with function events. 1249 * It only allows an "ip" field, and expects a string. 1250 * But the string does not need to be surrounded by quotes. 1251 * If it is a string, the assigned function as a nop, 1252 * (perf doesn't use it) and grab everything. 1253 */ 1254 if (strcmp(field->name, "ip") !=3D 0) { 1255 parse_error(pe, FILT_ERR_IP_FIELD_ONLY, pos + i); 1256 goto err_free; 1257 } 1258 pred->fn =3D filter_pred_none; 1259 = 1260 /* 1261 * Quotes are not required, but if they exist then we need 1262 * to read them till we hit a matching one. 1263 */ 1264 if (str[i] =3D=3D '\'' || str[i] =3D=3D '"') 1265 q =3D str[i]; 1266 else 1267 q =3D 0; 1268 = 1269 for (i++; str[i]; i++) { 1270 if (q && str[i] =3D=3D q) 1271 break; 1272 if (!q && (str[i] =3D=3D ')' || str[i] =3D=3D '&' || 1273 str[i] =3D=3D '|')) 1274 break; 1275 } 1276 /* Skip quotes */ 1277 if (q) 1278 s++; 1279 len =3D i - s; 1280 if (len >=3D MAX_FILTER_STR_VAL) { 1281 parse_error(pe, FILT_ERR_OPERAND_TOO_LONG, pos + i); 1282 goto err_free; 1283 } 1284 = 1285 pred->regex.len =3D len; 1286 strncpy(pred->regex.pattern, str + s, len); 1287 pred->regex.pattern[len] =3D 0; 1288 = 1289 /* This is either a string, or an integer */ 1290 } else if (str[i] =3D=3D '\'' || str[i] =3D=3D '"') { 1291 char q =3D str[i]; 1292 = 1293 /* Make sure the op is OK for strings */ 1294 switch (op) { 1295 case OP_NE: 1296 pred->not =3D 1; 1297 fallthrough; 1298 case OP_GLOB: 1299 case OP_EQ: 1300 break; 1301 default: 1302 parse_error(pe, FILT_ERR_ILLEGAL_FIELD_OP, pos + i); 1303 goto err_free; 1304 } 1305 = 1306 /* Make sure the field is OK for strings */ 1307 if (!is_string_field(field)) { 1308 parse_error(pe, FILT_ERR_EXPECT_DIGIT, pos + i); 1309 goto err_free; 1310 } 1311 = 1312 for (i++; str[i]; i++) { 1313 if (str[i] =3D=3D q) 1314 break; 1315 } 1316 if (!str[i]) { 1317 parse_error(pe, FILT_ERR_MISSING_QUOTE, pos + i); 1318 goto err_free; 1319 } 1320 = 1321 /* Skip quotes */ 1322 s++; 1323 len =3D i - s; 1324 if (len >=3D MAX_FILTER_STR_VAL) { 1325 parse_error(pe, FILT_ERR_OPERAND_TOO_LONG, pos + i); 1326 goto err_free; 1327 } 1328 = 1329 pred->regex.len =3D len; 1330 strncpy(pred->regex.pattern, str + s, len); 1331 pred->regex.pattern[len] =3D 0; 1332 = 1333 filter_build_regex(pred); 1334 = 1335 if (field->filter_type =3D=3D FILTER_COMM) { 1336 pred->fn =3D filter_pred_comm; 1337 = 1338 } else if (field->filter_type =3D=3D FILTER_STATIC_STRING) { 1339 pred->fn =3D filter_pred_string; 1340 pred->regex.field_len =3D field->size; 1341 = 1342 } else if (field->filter_type =3D=3D FILTER_DYN_STRING) 1343 pred->fn =3D filter_pred_strloc; 1344 else { 1345 pred->fn =3D filter_pred_pchar; > 1346 if (data->class =3D=3D &event_class_syscall_enter) 1347 pred->field->uaccess =3D 1; 1348 } 1349 /* go past the last quote */ 1350 i++; 1351 = 1352 } else if (isdigit(str[i]) || str[i] =3D=3D '-') { 1353 = 1354 /* Make sure the field is not a string */ 1355 if (is_string_field(field)) { 1356 parse_error(pe, FILT_ERR_EXPECT_STRING, pos + i); 1357 goto err_free; 1358 } 1359 = 1360 if (op =3D=3D OP_GLOB) { 1361 parse_error(pe, FILT_ERR_ILLEGAL_FIELD_OP, pos + i); 1362 goto err_free; 1363 } 1364 = 1365 if (str[i] =3D=3D '-') 1366 i++; 1367 = 1368 /* We allow 0xDEADBEEF */ 1369 while (isalnum(str[i])) 1370 i++; 1371 = 1372 len =3D i - s; 1373 /* 0xfeedfacedeadbeef is 18 chars max */ 1374 if (len >=3D sizeof(num_buf)) { 1375 parse_error(pe, FILT_ERR_OPERAND_TOO_LONG, pos + i); 1376 goto err_free; 1377 } 1378 = 1379 strncpy(num_buf, str + s, len); 1380 num_buf[len] =3D 0; 1381 = 1382 /* Make sure it is a value */ 1383 if (field->is_signed) 1384 ret =3D kstrtoll(num_buf, 0, &val); 1385 else 1386 ret =3D kstrtoull(num_buf, 0, &val); 1387 if (ret) { 1388 parse_error(pe, FILT_ERR_ILLEGAL_INTVAL, pos + s); 1389 goto err_free; 1390 } 1391 = 1392 pred->val =3D val; 1393 = 1394 if (field->filter_type =3D=3D FILTER_CPU) 1395 pred->fn =3D filter_pred_cpu; 1396 else { 1397 pred->fn =3D select_comparison_fn(pred->op, field->size, 1398 field->is_signed); 1399 if (pred->op =3D=3D OP_NE) 1400 pred->not =3D 1; 1401 } 1402 = 1403 } else { 1404 parse_error(pe, FILT_ERR_INVALID_VALUE, pos + i); 1405 goto err_free; 1406 } 1407 = 1408 *pred_ptr =3D pred; 1409 return i; 1410 = 1411 err_free: 1412 kfree(pred); 1413 return -EINVAL; 1414 } 1415 = --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org --===============3998748111118331478==--